Crossfire Server, Trunk
|
#include "global.h"
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "skills.h"
#include "spells.h"
#include "sproto.h"
#include "minheap.h"
Go to the source code of this file.
Data Structures | |
struct | path_data |
Macros | |
#define | MAX_EXPLORE 5000 |
#define | MAX_KNOWN_SPELLS 20 |
#define | MIN_MON_RADIUS 3 |
This deals with monster moving, attacking, using items and such. The core function is monster_move().
Definition in file monster.c.
#define MAX_EXPLORE 5000 |
Maximum map size to consider when finding a path in monster_compute_path().
#define MAX_KNOWN_SPELLS 20 |
|
inlinestatic |
|
static |
Return the verb for the player's dialog type seen from others (third person).
rt | dialog type. |
Definition at line 2328 of file monster.c.
References rt_question, rt_reply, and rt_say.
Referenced by monster_communicate().
const char* get_reply_text_own | ( | reply_type | rt | ) |
Return the verb for the player's dialog type.
rt | dialog type. |
Definition at line 2310 of file monster.c.
References rt_question, rt_reply, and rt_say.
Referenced by convertType(), CREMessageTypeDelegate::createEditor(), and monster_communicate().
Determine if an object can be considered an enemy.
who | who to consider, must not be NULL. |
owner | potential owner of the object we're searching an enemy for. |
Definition at line 142 of file monster.c.
References obj::contr, FLAG_GENERATOR, FLAG_MONSTER, object_get_owner(), pl::peaceful, PLAYER, QUERY_FLAG, obj::type, and autojail::who.
Referenced by monster_find_nearest_enemy().
|
static |
If a monster who's eager to apply things encounters something apply-able, then make him apply it.
Definition at line 1968 of file monster.c.
References apply_manual(), CF_HANDLE, FLAG_IS_FLOOR, FOR_BELOW_FINISH, FOR_BELOW_PREPARE, QUERY_FLAG, Ice::tmp, TREASURE, TRIGGER, obj::will_apply, WILL_APPLY_HANDLE, and WILL_APPLY_TREASURE.
Referenced by monster_move().
Determine if we can 'detect' the enemy. Check for walls blocking the los. Also, just because its hidden/invisible, we may be sensitive/smart enough (based on Wis & Int) to figure out where the enemy is. -b.t.
Modified by MSW to use the get_rangevector so that map tiling works properly. I also so odd code in place that checked for x distance OR y distance being within some range - that seemed wrong - both should be within the valid range. MSW 2001-08-05
op | who should detect. |
enemy | what to detect. |
rv | if the function returns 1, contains the range vector towards enemy. |
Definition at line 2569 of file monster.c.
References obj::contr, rv_vector::distance, draw_ext_info_format(), find_skill_by_number(), FLAG_SEE_IN_DARK, FLAG_STEALTH, FLAG_WIZ, get_rangevector(), pl::hidden, obj::hide, obj::invisible, is_true_undead(), obj::level, llevError, LOG(), make_visible(), disinfect::map, obj::map, MAX, MAX_BUF, MIN_MON_RADIUS, monster_can_see_enemy(), monster_stand_in_light(), MSG_TYPE_SKILL, MSG_TYPE_SKILL_FAILURE, give::name, NDI_UNIQUE, give::op, PLAYER, player_can_view(), QUERY_FLAG, query_name(), RANDOM, SK_HIDING, pl::tmp_invis, and obj::type.
Referenced by attempt_steal(), get_nearest_criminal(), get_nearest_player(), monster_check_enemy(), and pets_get_enemy().
Checks if monster can hit in hand-to-hand combat. Multitile aware.
ob1 | monster trying to hit. |
ob2 | target to hit. |
rv | vector from ob1 to ob2. |
Definition at line 1137 of file monster.c.
References rv_vector::distance_x, rv_vector::distance_y, FLAG_CONFUSED, get_rangevector(), obj::more, guildbuy::ob1, guildbuy::ob2, QUERY_FLAG, and RANDOM.
Referenced by monster_dist_att(), monster_move(), monster_run_att(), and monster_wait_att().
Check if the monster can and is interested in picking up an item.
monster | monster to check. |
item | what item to check against |
Definition at line 1887 of file monster.c.
References obj::arch, ARROW, obj::body_info, BOW, archt::clone, FLAG_CAN_USE_SKILL, FLAG_CAST_SPELL, FLAG_IS_THROWN, FLAG_UNPAID, FLAG_USE_ARMOUR, FLAG_USE_BOW, FLAG_USE_RANGE, FLAG_USE_RING, FLAG_USE_SCROLL, FLAG_USE_SHIELD, FLAG_USE_WEAPON, FOOD, GEM, IS_ARMOR, IS_SHIELD, IS_WEAPON, MONEY, NUM_BODY_LOCATIONS, object_can_pick(), object_find_by_type_subtype(), obj::pick_up, QUERY_FLAG, RING, ROD, SCROLL, SK_THROWING, SKILL, SPELLBOOK, and WAND.
Referenced by monster_check_pickup().
Assuming no walls/barriers, lets check to see if its possible to see an enemy. Note, "detection" is different from "seeing". See monster_can_detect_enemy() for more details. -b.t.
op | who is trying to see enemy. |
enemy | victim op is trying to see. |
Definition at line 2752 of file monster.c.
References mapdef::darkness, draw_ext_info(), FLAG_ALIVE, FLAG_BLIND, FLAG_SEE_IN_DARK, FLAG_SEE_INVISIBLE, FLAG_XRAYS, has_carried_lights(), HEAD, obj::hide, obj::invisible, is_true_undead(), make_visible(), makes_invisible_to(), obj::map, monster_stand_in_light(), MSG_TYPE_SKILL, MSG_TYPE_SKILL_FAILURE, NDI_UNIQUE, give::op, PLAYER, player_can_view(), QUERY_FLAG, and obj::type.
Referenced by adj_attackroll(), attack_ob_simple(), monster_can_detect_enemy(), and pets_get_enemy().
Tries to make a (part of a) monster cast a spell.
Handles sp/gr limits, and confusion.
head | head of the monster. |
part | part of the monster that we use to cast. |
pl | target. |
dir | direction to cast. |
Definition at line 1258 of file monster.c.
References cast_spell(), CLEAR_FLAG, liv::dam, dirdiff(), rv_vector::direction, FLAG_CAST_SPELL, FLAG_CONFUSED, FLAG_FRIENDLY, get_randomized_dir(), get_rangevector(), liv::grace, obj::inv, llevError, llevMonster, LOG(), monster_choose_random_spell(), obj::name, object_get_owner(), path_to_player(), QUERY_FLAG, obj::range, liv::sp, SP_level_spellpoint_cost(), SPELL_GRACE, SPELL_MANA, SPELLBOOK, obj::spellitem, obj::stats, obj::type, and guild_entry::x1.
Referenced by monster_move().
Called after an item is inserted in a monster. Will look if item should be applied to replace another item.
mon | monster who picked an item. |
item | what was picked up. |
Definition at line 1726 of file monster.c.
References AP_APPLY, AP_IGNORE_CURSE, AP_NOPRINT, apply_can_apply_object(), apply_manual(), obj::arch, ARROW, BOW, CAN_APPLY_NOT_MASK, archt::clone, obj::count, FLAG_APPLIED, FLAG_CAST_SPELL, FLAG_READY_BOW, FLAG_READY_RANGE, FLAG_READY_SCROLL, FLAG_READY_SKILL, FLAG_USE_BOW, FLAG_USE_SCROLL, FOOD, IS_ARMOR, IS_SHIELD, llevDebug, llevMonster, LOG(), mon, monster_check_good_armour(), monster_check_good_weapon(), monster_should_cast_spell(), object_find_by_type_and_race(), QUERY_FLAG, RING, ROD, SCROLL, SET_FLAG, SKILL, SPELLBOOK, TREASURE, WAND, WEAPON, obj::will_apply, WILL_APPLY_FOOD, and WILL_APPLY_TREASURE.
Referenced by monster_check_apply_all(), and monster_check_pickup().
void monster_check_apply_all | ( | object * | monster | ) |
Calls monster_check_apply() for all inventory objects.
monster | the monster to operate on |
Definition at line 1991 of file monster.c.
References fix_object(), FOR_INV_FINISH, FOR_INV_PREPARE, obj::head, commongive::inv, and monster_check_apply().
Referenced by apply_auto_fix(), command_create(), fix_summon_pet(), generate_monster_arch(), generate_monster_inv(), pets_summon_object(), polymorph_living(), and START_TEST().
Living creature attempts to open a door.
op | creature to consider. |
m | map to consider. |
x | coordinate. |
y | coordinate. |
Definition at line 2270 of file monster.c.
References AT_PHYSICAL, DOOR, FOR_MAP_FINISH, FOR_MAP_PREPARE, hit_player(), m, give::op, Ice::tmp, diamondslots::x, and diamondslots::y.
Referenced by move_ob().
Living creature attempts to hit an earthwall.
op | creature to consider. |
m | map to consider. |
x | coordinate. |
y | coordinate. |
Definition at line 2254 of file monster.c.
References AT_PHYSICAL, EARTHWALL, FOR_MAP_FINISH, FOR_MAP_PREPARE, hit_player(), m, give::op, Ice::tmp, diamondslots::x, and diamondslots::y.
Referenced by move_ob().
Checks npc->enemy and returns that enemy if still valid, NULL otherwise. This is map tile aware. If this returns an enemy, the range vector rv should also be set to sane values.
npc | monster we're considering | |
[out] | rv | will contain vector to go to enemy if function returns not NULL. |
Definition at line 72 of file monster.c.
References obj::enemy, FLAG_FREED, FLAG_FRIENDLY, FLAG_GENERATOR, FLAG_MONSTER, FLAG_NEUTRAL, FLAG_REMOVED, GOLEM, HI4, monster_can_detect_enemy(), npc_dialog::npc, object_get_owner(), object_set_enemy(), object_value_set(), on_same_map(), PETMOVE, pets_should_arena_attack(), PLAYER, and QUERY_FLAG.
Referenced by monster_find_enemy(), and pets_get_enemy().
Checks if using armor 'item' would be better for 'who'. This is a very simplistic check - also checking things like speed and ac are also relevant.
who | creature considering to apply item. |
item | item to check. |
Definition at line 1691 of file monster.c.
References monster_get_armour_quality(), NROFATTACKS, object_find_by_type_applied(), obj::resist, and autojail::who.
Referenced by monster_check_apply().
Checks if using weapon 'item' would be better for 'who'. This is a very simplistic check - also checking things like speed and ac are also relevant.
who | creature considering to apply item. |
item | item to check. |
Definition at line 1644 of file monster.c.
References monster_get_weapon_quality(), object_find_by_type_applied(), and autojail::who.
Referenced by monster_check_apply().
|
static |
Checks for items that monster can pick up.
Vick's (vick(at)bern.docs.uu.se) fix 921030 for the sweeper blob. Each time the blob passes over some treasure, it will grab it a.s.a.p.
Eneq((at)csd.uu.se): This can now be defined in the archetypes, added code to handle this.
This function was seen be continueing looping at one point (tmp->below became a recursive loop. It may be better to call monster_check_apply after we pick everything up, since that function may call others which affect stacking on this space.
monster | monster that can pick up items. |
Definition at line 1843 of file monster.c.
References obj::carrying, FOR_BELOW_FINISH, FOR_BELOW_PREPARE, get_weight_limit(), MAX, MIN, monster_can_pick(), monster_check_apply(), obj::more, object_insert_in_ob(), object_split(), obj::stats, liv::Str, THROWN_OBJ, Ice::tmp, nlohmann::detail::void(), and obj::weight.
Referenced by monster_move().
Sees if this monster should wake up. Currently, this is only called from monster_move(), and if enemy is set, then so should be rv.
op | monster to check. | |
enemy | enemy that can cause to wake up. | |
[out] | rv | vector pointing to enemy. |
Definition at line 331 of file monster.c.
References CLEAR_FLAG, rv_vector::distance, FLAG_BLIND, FLAG_SEE_IN_DARK, FLAG_SEE_INVISIBLE, FLAG_SLEEP, FLAG_STEALTH, obj::invisible, MAX, MIN_MON_RADIUS, monster_stand_in_light(), give::op, and QUERY_FLAG.
Referenced by monster_move().
Selects a spell to cast for a monster.
Returns a randomly selected spell. This logic is still less than ideal. This code also only seems to deal with wizard spells, as the check is against sp, and not grace. can monsters know cleric spells?
monster | monster trying to cast a spell. |
Definition at line 1220 of file monster.c.
References FOR_INV_FINISH, FOR_INV_PREPARE, MAX_KNOWN_SPELLS, monster_should_cast_spell(), RANDOM, SPELL, SPELLBOOK, and Ice::tmp.
Referenced by monster_cast_spell().
|
static |
Move the monster in a specified movement pattern.
ob | monster. |
Definition at line 2152 of file monster.c.
References move_object(), guildjoin::ob, RANDOM, and nlohmann::detail::void().
Referenced by monster_move_no_enemy().
|
static |
Move the monster in a specified movement pattern.
ob | monster. |
Definition at line 2165 of file monster.c.
References move_object(), guildjoin::ob, RANDOM, and nlohmann::detail::void().
Referenced by monster_move_no_enemy().
void monster_communicate | ( | object * | op, |
const char * | txt | ||
) |
This function looks for an object or creature that is listening to said text.
The process is such:
There is a rare event that the orig_map is used for - basically, if a player says the magic word that gets him teleported off the map, it can result in the new map putting the object count too high, which forces the swap out of some other map. In some cases, the map the player was just on now gets swapped out - thus, the object on that map are no longer in memory. So check to see if the players map changes, and if so, don't process any further. If it does change, most likely we don't care about the results of further conversation. Also, depending on the value of i, the conversation would continue on the new map, which probably isn't what is really wanted either.
op | who is saying something. |
txt | what is said. |
Definition at line 2366 of file monster.c.
References draw_ext_info(), draw_ext_info_format(), ext_info_map_except(), FOR_MAP_FINISH, FOR_MAP_PREPARE, free_string(), freearr_x, freearr_y, get_map_flags(), get_reply_text_other(), get_reply_text_own(), llevDebug, LOG(), MAX_BUF, talk_info::message, talk_info::message_type, monster_do_say(), monster_talk_to_npc(), MSG_TYPE_COMMUNICATION, MSG_TYPE_COMMUNICATION_SAY, NDI_WHITE, npc_dialog::npc, talk_info::npc_msg_count, talk_info::npc_msgs, give::op, P_OUT_OF_MAP, talk_info::replies, talk_info::replies_count, talk_info::replies_words, SIZEOFFREE2, talk_info::text, talk_info::who, diamondslots::x, and diamondslots::y.
Referenced by command_say().
Computes a path from source to target. Takes into account walls, other living things, and such. Only works if both items are on same map.
Computes the path from target to source, so that the last direction is the one we need.
source | what wants to move. |
target | target to go to. |
default_dir | general direction from source to target. |
Also, do a quick check to make sure our source monster is not completely sandwiched Do this before we malloc our distance array since we can check this without needing that array.
Does not do multitile right: I keep seeing two-tile monsters that can only go south not do so because of this code. So skip multitile monsters. – 2018-05-28
It is worth noting that the variables used here are also used later – their info here is irrelevant there, and vice versa. Daniel Hawkins 2018-02-12
Definition at line 465 of file monster.c.
References absdir(), obj::attack_movement, replace::current, path_data::distance, estimate_distance(), fatal(), FOR_OB_AND_ABOVE_FINISH, FOR_OB_AND_ABOVE_PREPARE, freearr_x, freearr_y, GET_MAP_OB, mapdef::height, path_data::heuristic_dist, liv::Int, obj::map, MAX_EXPLORE, minheap_init_static(), minheap_insert(), minheap_remove(), obj::more, obj::move_type, MOVE_WALK, path_data::movement_penalty, ob_blocked(), OUT_OF_MEMORY, OUT_OF_REAL_MAP, path_measure_func(), RANDOM, RUSH, obj::stats, Ice::tmp, mapdef::width, liv::Wis, diamondslots::x, obj::x, path_data::x, diamondslots::y, obj::y, and path_data::y.
Referenced by monster_move(), and move_to().
Return the direction the monster should move or look to attack an enemy.
dir | direction the monster is currently facing. |
enemy | target of the monster. |
part | monster's part we're considering. |
rv | vector to enemy. |
Definition at line 2046 of file monster.c.
References absdir(), rv_vector::distance, and monster_can_hit().
Referenced by monster_disthit_att(), and monster_move().
|
static |
Return the next direction the monster should move for a specific movement type.
dir | direction the monster is currently facing. |
ob | unused. |
enemy | target of the monster. |
part | monster's part we're considering. |
rv | vector to enemy. |
Definition at line 2123 of file monster.c.
References absdir(), monster_dist_att(), and guildjoin::ob.
Referenced by monster_move().
void monster_do_living | ( | object * | op | ) |
For a monster, regenerate hp and sp, potentially clear scared status.
op | monster. Must have FLAG_MONSTER set. |
Definition at line 715 of file monster.c.
References CLEAR_FLAG, FABS, FLAG_MONSTER, FLAG_RUN_AWAY, FLAG_SCARED, make_face_from_files::int, MIN, give::op, QUERY_FLAG, and RANDOM.
Referenced by CRECombatSimulator::fight(), monster_move(), and monsterFight().
void monster_do_say | ( | const mapstruct * | map, |
const char * | message | ||
) |
Output a NPC message on a map.
map | where to talk to. |
message | what to say. |
Definition at line 2284 of file monster.c.
References ext_info_map(), disinfect::map, diamondslots::message, MSG_TYPE_DIALOG, MSG_TYPE_DIALOG_NPC, NDI_NAVY, and NDI_UNIQUE.
Referenced by monster_communicate(), and monster_npc_say().
Checks the messages of a NPC for a matching text. Will not call plugin events. Called by monster_talk_to_npc().
npc | object that gets a chance to reply. |
info | message information. |
Definition at line 2440 of file monster.c.
References add_string(), ext_info_map(), get_dialog_message(), MAGIC_EAR, MAX_NPC, MAX_REPLIES, talk_info::message, diamondslots::message, talk_info::message_type, monster_format_say(), MSG_TYPE_DIALOG, MSG_TYPE_DIALOG_MAGIC_EAR, NDI_DELAYED, NDI_NAVY, NDI_UNIQUE, npc_dialog::npc, talk_info::npc_msg_count, talk_info::npc_msgs, object_set_value(), talk_info::replies, talk_info::replies_count, talk_info::replies_words, say::reply, stringbuffer_finish_shared(), talk_info::text, use_trigger(), and autojail::value.
Referenced by monster_talk_to_npc().
Tries to find an enmy for npc. We pass the range vector since our caller will find the information useful. Currently, only monster_move() calls this function. Fix function so that we always make calls to get_rangevector if we have a valid target - function as not doing so in many cases.
npc | monster we're considering. | |
[out] | rv | vector that will contain how to reach the target. Must not be NULL. |
Definition at line 234 of file monster.c.
References buf, CLEAR_FLAG, obj::count, FLAG_BERSERK, FLAG_FRIENDLY, FLAG_NEUTRAL, FLAG_SLEEP, FLAG_UNAGGRESSIVE, get_nearest_criminal(), get_nearest_player(), get_rangevector(), HI4, MAX_BUF, monster_check_enemy(), monster_find_nearest_enemy(), monster_npc_say(), npc_dialog::npc, object_set_enemy(), object_value_set(), on_same_map(), PETMOVE, pets_get_enemy(), PLAYER, QUERY_FLAG, Ice::tmp, and obj::type.
Referenced by monster_move().
Returns the nearest enemy (monster or generator) which is visible to npc. Directions are randomized so if multiple monsters are at the same distance, the same won't always be selected. This function is map tile aware.
npc | monster to consider |
owner | if not NULL, then search will:
|
Definition at line 175 of file monster.c.
References can_see_monsterP(), FOR_MAP_FINISH, FOR_MAP_PREPARE, freearr_x, freearr_y, get_map_flags(), get_search_arr(), is_enemy(), llevDebug, LOG(), m, npc_dialog::npc, P_IS_ALIVE, P_OUT_OF_MAP, SIZEOFFREE, and Ice::tmp.
Referenced by monster_find_enemy(), pets_get_enemy(), and START_TEST().
Find an item for the monster to throw. Modeled on find_throw_ob(). This is probably overly simplistic as it is now - We want monsters to throw things like chairs and other pieces of furniture, even if they are not good throwable objects. Probably better to have the monster throw a throwable object first, then throw any non equipped weapon.
op | monster to find an item to throw for. |
Definition at line 2530 of file monster.c.
References FLAG_APPLIED, FLAG_IS_THROWN, FOR_INV_FINISH, FOR_INV_PREPARE, llevDebug, LOG(), MAX_BUF, give::op, QUERY_FLAG, query_name(), and Ice::tmp.
Referenced by skill_throw().
|
static |
Format an NPC message.
npc | who is talking. |
message | what is being said. |
Definition at line 2295 of file monster.c.
References buf, MAX_BUF, diamondslots::message, give::name, npc_dialog::npc, query_name(), stringbuffer_append_printf(), and stringbuffer_new().
Referenced by monster_do_talk_npc(), and monster_npc_say().
|
static |
Returns the "quality" value of an armour of a monster. Higher quality values are considered better.
item | the item to check |
Definition at line 1670 of file monster.c.
References ATNR_PHYSICAL.
Referenced by monster_check_good_armour().
|
static |
Returns the "quality" value of a weapon of a monster. Higher quality values are considered better.
item | the item to check |
Definition at line 1618 of file monster.c.
References get_attr_value(), and NUM_STATS.
Referenced by monster_check_good_weapon().
|
static |
Return the next direction the monster should move for a specific movement type.
dir | direction the monster is currently facing. |
ob | unused. |
Definition at line 2080 of file monster.c.
References absdir(), and guildjoin::ob.
Referenced by monster_move().
int monster_move | ( | object * | op | ) |
Main monster processing routine.
Will regenerate spell points, hit points. Moves the monster, handle attack, item applying, pickup, ...
op | monster to process. |
Definition at line 850 of file monster.c.
References absdir(), add_refcount(), ALLRUN, animate_object(), obj::attacked_by, obj::attacked_by_count, CLEAR_FLAG, rv_vector::direction, DISTATT, DISTHIT, do_hidden_move(), FABS, obj::face, FLAG_BLIND, FLAG_CAST_SPELL, FLAG_CONFUSED, FLAG_FREED, FLAG_FRIENDLY, FLAG_NO_ATTACK, FLAG_ONLY_ATTACK, FLAG_PARALYZED, FLAG_READY_BOW, FLAG_READY_RANGE, FLAG_READY_SCROLL, FLAG_READY_SKILL, FLAG_REMOVED, FLAG_RUN_AWAY, FLAG_SCARED, FLAG_SEE_IN_DARK, FLAG_SEE_INVISIBLE, FLAG_SLEEP, FLAG_STAND_STILL, free_string(), get_nearest_player(), get_randomized_dir(), get_rangevector(), HI4, HITRUN, llevDebug, llevMonster, LO4, LOG(), m, obj::map, MIN_ACTIVE_SPEED, monster_apply_below(), monster_can_hit(), monster_cast_spell(), monster_check_pickup(), monster_check_wakeup(), monster_compute_path(), monster_dist_att(), monster_disthit_att(), monster_do_living(), monster_find_enemy(), monster_hitrun_att(), monster_move_no_enemy(), monster_move_randomly(), monster_run_att(), monster_use_bow(), monster_use_range(), monster_use_scroll(), monster_use_skill(), monster_wait_att(), monster_wait_att2(), move_object(), obj::name, object_free_drop_inventory(), object_get_owner(), object_remove(), object_set_enemy(), on_same_map(), give::op, rv_vector::part, mapdef::path, PETMOVE, pets_follow_owner(), QUERY_FLAG, RANDOM, remove_friendly_object(), RUNATT, RUSH, skill_attack(), obj::stats, WAIT2, WAITATT, liv::wc, obj::x, and obj::y.
Referenced by process_object().
|
static |
Makes a monster without any enemy move.
op | monster, must have FLAG_MONSTER set. |
Definition at line 778 of file monster.c.
References CIRCLE1, CIRCLE2, FLAG_MONSTER, FLAG_ONLY_ATTACK, FLAG_RANDOM_MOVE, FLAG_STAND_STILL, HI4, monster_circ1_move(), monster_circ2_move(), monster_move_randomly(), monster_pace2_moveh(), monster_pace2_movev(), monster_pace_moveh(), monster_pace_movev(), monster_rand_move(), object_free_drop_inventory(), object_remove(), give::op, PACEH, PACEH2, PACEV, PACEV2, PETMOVE, pets_move(), QUERY_FLAG, RANDO, and RANDO2.
Referenced by monster_move().
|
static |
Handles random object movement. If the monster was talked to lately, then don't move and reduce wait time.
op | object to move. |
Definition at line 377 of file monster.c.
References FLAG_UNAGGRESSIVE, move_object(), object_get_value(), object_set_value(), give::op, QUERY_FLAG, RANDOM, sstring, and autojail::value.
Referenced by monster_move(), and monster_move_no_enemy().
void monster_npc_call_help | ( | object * | op | ) |
A monster calls for help against its enemy.
op | monster calling for help. |
Definition at line 2004 of file monster.c.
References CLEAR_FLAG, FLAG_ALIVE, FLAG_UNAGGRESSIVE, FOR_MAP_FINISH, FOR_MAP_PREPARE, get_map_flags(), llevDebug, LOG(), m, npc_dialog::npc, object_get_value(), object_set_enemy(), give::op, P_IS_ALIVE, P_OUT_OF_MAP, QUERY_FLAG, autojail::value, diamondslots::x, and diamondslots::y.
Referenced by alchemy_failure_effect(), attack_ob_simple(), attempt_steal(), hit_player(), and push_ob().
void monster_npc_say | ( | object * | npc, |
const char * | cp | ||
) |
Simple function to have some NPC say something.
npc | who should say something. |
cp | what is being said. |
Definition at line 2485 of file monster.c.
References buf, diamondslots::message, monster_do_say(), monster_format_say(), npc_dialog::npc, and stringbuffer_finish().
Referenced by cfapi_object_say(), and monster_find_enemy().
|
static |
Move the monster in a specified movement pattern.
ob | monster. |
Definition at line 2219 of file monster.c.
References move_object(), guildjoin::ob, and nlohmann::detail::void().
Referenced by monster_move_no_enemy().
|
static |
Move the monster in a specified movement pattern.
ob | monster. |
Definition at line 2204 of file monster.c.
References move_object(), guildjoin::ob, and nlohmann::detail::void().
Referenced by monster_move_no_enemy().
|
static |
Move the monster in a specified movement pattern.
ob | monster. |
Definition at line 2191 of file monster.c.
References move_object(), guildjoin::ob, and nlohmann::detail::void().
Referenced by monster_move_no_enemy().
|
static |
Move the monster in a specified movement pattern.
ob | monster. |
Definition at line 2178 of file monster.c.
References move_object(), guildjoin::ob, and nlohmann::detail::void().
Referenced by monster_move_no_enemy().
|
static |
Move the monster in a specified movement pattern.
ob | monster. |
Definition at line 2234 of file monster.c.
References move_object(), guildjoin::ob, and RANDOM.
Referenced by monster_move_no_enemy().
|
static |
Return the next direction the monster should move for a specific movement type.
dir | direction the monster is currently facing. |
ob | unused. |
enemy | target of the monster. |
part | monster's part we're considering. |
rv | vector to enemy. |
Definition at line 2065 of file monster.c.
References absdir(), monster_can_hit(), and guildjoin::ob.
Referenced by monster_move().
|
static |
Checks if a monster should cast a spell.
Note that this function does not check to see if the monster can in fact cast the spell (sp dependencies and what not.) That is because this function is also sued to see if the monster should use spell items (rod/horn/wand/scroll).
Note that there are certainly other offensive spells that could be included, but I decided to leave out the spells that may kill more monsters than players (eg, disease).
This could be a lot smarter - if there are few monsters around, then disease might not be as bad. Likewise, if the monster is damaged, the right type of healing spell could be useful.
spell_ob | spell considered. |
Definition at line 1180 of file monster.c.
References SP_BOLT, SP_BOMB, SP_BULLET, SP_CONE, SP_EXPLOSION, SP_INVISIBLE, SP_MAGIC_MISSILE, SP_MAGIC_WALL, SP_MOVING_BALL, SP_SMITE, SP_SUMMON_GOLEM, SP_SUMMON_MONSTER, SP_SWARM, and obj::subtype.
Referenced by monster_check_apply(), monster_choose_random_spell(), and monster_use_scroll().
int monster_stand_in_light | ( | object * | op | ) |
Determine if op stands in a lighted square. This is not a very intellegent algorithm. For one thing, we ignore los here, SO it is possible for a bright light to illuminate a player on the other side of a wall (!).
op | who to check. |
Definition at line 2709 of file monster.c.
References get_map_flags(), GET_MAP_LIGHT, isqrt(), m, MAX_LIGHT_RADII, give::op, P_OUT_OF_MAP, diamondslots::x, guild_entry::x1, diamondslots::y, and guild_entry::y1.
Referenced by adj_attackroll(), monster_can_detect_enemy(), monster_can_see_enemy(), and monster_check_wakeup().
Give an object the chance to handle something being said. Plugin hooks will be called, including in the NPC's inventory.
npc | object to try to talk to. Can be an NPC or a MAGIC_EAR. |
info | message information. |
Definition at line 2502 of file monster.c.
References events_execute_object_say(), FOR_INV_FINISH, FOR_INV_PREPARE, monster_do_talk_npc(), npc_dialog::npc, and talk_info::who.
Referenced by monster_communicate().
Tries to make a (part of a) monster fire a bow.
Handles confusion effect.
head | head of the monster. |
part | part of the monster that we use to cast. |
pl | target. |
dir | direction to cast. |
Definition at line 1561 of file monster.c.
References rv_vector::direction, rv_vector::distance, rv_vector::distance_x, rv_vector::distance_y, fire_bow(), FLAG_CONFUSED, FLAG_FRIENDLY, freearr_x, freearr_y, get_map_from_coord(), GET_MAP_MOVE_BLOCK, get_randomized_dir(), get_rangevector(), llevError, LOG(), disinfect::map, obj::map, MOVE_FLY_LOW, object_get_owner(), QUERY_FLAG, diamondslots::x, obj::x, diamondslots::y, and obj::y.
Referenced by monster_move().
Monster will use a ranged attack (ROD, WAND, ...).
head | head of the monster. |
part | part of the monster that can do a range attack. |
pl | target. |
dir | direction to fire. |
Definition at line 1485 of file monster.c.
References cast_spell(), CLEAR_FLAG, obj::count, dirdiff(), rv_vector::direction, drain_rod_charge(), drain_wand_charge(), FLAG_CONFUSED, FLAG_FRIENDLY, FLAG_READY_RANGE, FOR_INV_FINISH, FOR_INV_PREPARE, get_randomized_dir(), get_rangevector(), obj::inv, llevError, LOG(), MAX, obj::name, object_get_owner(), path_to_player(), QUERY_FLAG, ROD, and WAND.
Referenced by monster_move().
Tries to make a (part of a) monster apply a spell.
head | head of the monster. |
part | part of the monster that we use to cast. |
pl | target. |
dir | direction to cast. |
Definition at line 1344 of file monster.c.
References animate_object(), obj::animation, apply_manual(), CLEAR_FLAG, dirdiff(), obj::direction, rv_vector::direction, obj::facing, FLAG_CONFUSED, FLAG_FRIENDLY, FLAG_READY_SCROLL, FOR_INV_FINISH, FOR_INV_PREPARE, get_randomized_dir(), get_rangevector(), obj::inv, monster_should_cast_spell(), object_get_owner(), path_to_player(), QUERY_FLAG, obj::range, SCROLL, Ice::tmp, and guild_entry::x1.
Referenced by monster_move().
A monster attempts using a skill. Implemented 95-04-28 to allow monster skill use. Note that monsters do not need the skills SK_MELEE_WEAPON and SK_MISSILE_WEAPON to make those respective attacks, if we required that we would drastically increase the memory requirements of CF!!
The skills we are treating here are all but those. -b.t.
At the moment this is only useful for throwing, perhaps for stealing. TODO: This should be more integrated in the game. -MT, 25.11.01
Will switch between at most 2 skills.
head | head of the monster. |
part | part of the monster that may use a skill. |
pl | target. |
dir | direction to cast. |
Definition at line 1428 of file monster.c.
References obj::chosen_skill, CLEAR_FLAG, obj::count, dirdiff(), rv_vector::direction, do_skill(), FLAG_CONFUSED, FLAG_FRIENDLY, FLAG_READY_SKILL, FOR_INV_FINISH, FOR_INV_PREPARE, is_valid_types_gen::found, get_randomized_dir(), get_rangevector(), llevDebug, LOG(), obj::name, object_get_owner(), path_to_player(), QUERY_FLAG, and SKILL.
Referenced by monster_move().
|
static |
Return the next direction the monster should move for a specific movement type.
dir | direction the monster is currently facing. |
ob | unused. |
enemy | target of the monster. |
part | monster's part we're considering. |
rv | vector to enemy. |
Definition at line 2098 of file monster.c.
References absdir(), monster_can_hit(), and guildjoin::ob.
Referenced by monster_move().
|
static |
Return the next direction the monster should move for a specific movement type.
dir | direction the monster is currently facing. |
rv | vector to enemy. |
Definition at line 2142 of file monster.c.
References absdir(), and rv_vector::distance.
Referenced by monster_move().
int path_measure_func | ( | const void * | ob | ) |
Function to retrieve the measurement the minheap will organize by.
ob | The path_data object we with to observe, stored as a void *. |
Definition at line 433 of file monster.c.
References path_data::distance, path_data::heuristic_dist, and guildjoin::ob.
Referenced by monster_compute_path().