Crossfire Server, Branches 1.12  R18729
monster.c File Reference
#include <assert.h>
#include <global.h>
#include <sproto.h>
#include <spells.h>
#include <skills.h>
+ Include dependency graph for monster.c:

Go to the source code of this file.

Macros

#define MAX_EXPLORE   5000
 
#define MAX_KNOWN_SPELLS   20
 
#define MIN_MON_RADIUS   3 /* minimum monster detection radius */
 

Functions

int can_detect_enemy (object *op, object *enemy, rv_vector *rv)
 
static int can_hit (object *ob1, object *ob2, rv_vector *rv)
 
int can_see_enemy (object *op, object *enemy)
 
void check_doors (object *op, mapstruct *m, int x, int y)
 
void check_earthwalls (object *op, mapstruct *m, int x, int y)
 
objectcheck_enemy (object *npc, rv_vector *rv)
 
static int check_good_armour (object *who, object *item)
 
static int check_good_weapon (object *who, object *item)
 
static int check_wakeup (object *op, object *enemy, rv_vector *rv)
 
static void circ1_move (object *ob)
 
static void circ2_move (object *ob)
 
void communicate (object *op, const char *txt)
 
int compute_path (object *source, object *target, int default_dir)
 
static int dist_att (int dir, object *ob, object *enemy, object *part, rv_vector *rv)
 
static int disthit_att (int dir, object *ob, object *enemy, object *part, rv_vector *rv)
 
static int do_talk_npc (object *op, object *npc, const char *txt, int *talked)
 
static objectfind_enemy (object *npc, rv_vector *rv)
 
objectfind_mon_throw_ob (object *op)
 
objectfind_nearest_living_creature (object *npc)
 
static int hitrun_att (int dir, object *ob, object *enemy)
 
static void monster_apply_below (object *monster)
 
static int monster_can_pick (object *monster, object *item)
 
static int monster_cast_spell (object *head, object *part, object *pl, int dir, rv_vector *rv)
 
void monster_check_apply (object *mon, object *item)
 
static void monster_check_pickup (object *monster)
 
static objectmonster_choose_random_spell (object *monster)
 
static void monster_do_living (object *op)
 
static int monster_move_no_enemy (object *op)
 
static int monster_should_cast_spell (object *monster, object *spell_ob)
 
static int monster_use_bow (object *head, object *part, object *pl, int dir)
 
static int monster_use_range (object *head, object *part, object *pl, int dir)
 
static int monster_use_scroll (object *head, object *part, object *pl, int dir, rv_vector *rv)
 
static int monster_use_skill (object *head, object *part, object *pl, int dir)
 
int move_monster (object *op)
 
static int move_randomly (object *op)
 
void npc_call_help (object *op)
 
void npc_say (object *npc, const char *cp)
 
static void pace2_moveh (object *ob)
 
static void pace2_movev (object *ob)
 
static void pace_moveh (object *ob)
 
static void pace_movev (object *ob)
 
static void rand_move (object *ob)
 
static int run_att (int dir, object *ob, object *enemy, object *part, rv_vector *rv)
 
int stand_in_light (object *op)
 
static int talk_to_npc (object *op, object *npc, const char *txt, int *talked)
 
static int wait_att (int dir, object *ob, object *enemy, object *part, rv_vector *rv)
 
static int wait_att2 (int dir, object *ob, object *enemy, object *part, rv_vector *rv)
 

Detailed Description

This deals with monster moving, attacking, using items and such. The core function is move_monster().

Definition in file monster.c.

Macro Definition Documentation

#define MAX_EXPLORE   5000

Definition at line 355 of file monster.c.

Referenced by compute_path().

#define MAX_KNOWN_SPELLS   20

Maximum number of spells to consider when choosing a spell for a monster.

Definition at line 900 of file monster.c.

Referenced by monster_choose_random_spell().

#define MIN_MON_RADIUS   3 /* minimum monster detection radius */

Definition at line 67 of file monster.c.

Referenced by can_detect_enemy(), and check_wakeup().

Function Documentation

int can_detect_enemy ( object op,
object enemy,
rv_vector rv 
)
static int can_hit ( object ob1,
object ob2,
rv_vector rv 
)
static

Checks if monster can hit in hand-to-hand combat. Multitile aware.

Parameters
ob1monster trying to hit.
ob2target to hit.
rvvector from ob1 to ob2.
Returns
1 if ob1 is adjacent to ob2, 0 else.
Todo:
rename to something more clear (is_adjacent?).

Definition at line 835 of file monster.c.

References rv_vector::distance_x, rv_vector::distance_y, FLAG_CONFUSED, get_rangevector(), obj::more, and QUERY_FLAG.

Referenced by dist_att(), move_monster(), run_att(), and wait_att().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void check_doors ( object op,
mapstruct m,
int  x,
int  y 
)

Definition at line 1802 of file monster.c.

References obj::above, AT_PHYSICAL, DOOR, GET_MAP_OB, hit_player(), and obj::type.

Referenced by move_ob().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void check_earthwalls ( object op,
mapstruct m,
int  x,
int  y 
)

Definition at line 1791 of file monster.c.

References obj::above, AT_PHYSICAL, liv::dam, EARTHWALL, GET_MAP_OB, hit_player(), obj::stats, and obj::type.

Referenced by move_ob().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

object* check_enemy ( object npc,
rv_vector rv 
)

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.

Parameters
npcmonster we're considering
[out]rvwill contain vector to go to enemy if function returns not NULL.
Returns
valid enemy for npc.

Definition at line 83 of file monster.c.

References obj::attack_movement, can_detect_enemy(), obj::enemy, FLAG_FREED, FLAG_FRIENDLY, FLAG_GENERATOR, FLAG_MONSTER, FLAG_NEUTRAL, FLAG_REMOVED, GOLEM, HI4, on_same_map(), obj::owner, PETMOVE, PLAYER, QUERY_FLAG, should_arena_attack(), and obj::type.

Referenced by find_enemy(), and get_pet_enemy().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int check_good_armour ( object who,
object item 
)
static

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.

Parameters
whocreature considering to apply item.
itemitem to check.
Returns
1 if item is a better object, 0 else.

Definition at line 1336 of file monster.c.

References liv::ac, ATNR_PHYSICAL, obj::below, FLAG_APPLIED, obj::inv, obj::magic, NROFATTACKS, QUERY_FLAG, obj::resist, obj::stats, and obj::type.

Referenced by monster_check_apply().

+ Here is the caller graph for this function:

static int check_good_weapon ( object who,
object item 
)
static

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.

Parameters
whocreature considering to apply item.
itemitem to check.
Returns
1 if item is a better object, 0 else.

Definition at line 1293 of file monster.c.

References obj::below, liv::dam, FLAG_APPLIED, get_attr_value(), obj::inv, obj::magic, NUM_STATS, QUERY_FLAG, obj::stats, and obj::type.

Referenced by monster_check_apply().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int check_wakeup ( object op,
object enemy,
rv_vector rv 
)
static

Sees if this monster should wake up. Currently, this is only called from move_monster, and if enemy is set, then so should be rv.

Parameters
opmonster to check.
enemyenemy that can cause to wake up.
[out]rvvector pointing to enemy.
Returns
1 if the monster should wake up, 0 otherwise.
Note
will return 0 if enemy is NULL.

Definition at line 298 of file monster.c.

References CLEAR_FLAG, mapdef::darkness, rv_vector::distance, FLAG_BLIND, FLAG_SEE_IN_DARK, FLAG_SEE_INVISIBLE, FLAG_SLEEP, FLAG_STEALTH, obj::invisible, obj::map, MAX, MIN_MON_RADIUS, QUERY_FLAG, stand_in_light(), obj::stats, and liv::Wis.

Referenced by move_monster().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void circ1_move ( object ob)
static

Definition at line 1718 of file monster.c.

References move_object(), and obj::move_status.

Referenced by monster_move_no_enemy().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void circ2_move ( object ob)
static

Definition at line 1727 of file monster.c.

References move_object(), and obj::move_status.

Referenced by monster_move_no_enemy().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void communicate ( object op,
const char *  txt 
)

This function looks for an object or creature that is listening to said text.

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.

Parameters
opwho is saying something.
txtwhat is said.

Definition at line 1831 of file monster.c.

References obj::above, ext_info_map(), freearr_x, freearr_y, get_map_flags(), GET_MAP_OB, llevDebug, LOG(), obj::map, MAX_BUF, MSG_TYPE_COMMUNICATION, MSG_TYPE_COMMUNICATION_SAY, obj::name, NDI_WHITE, P_OUT_OF_MAP, PLAYER, SIZEOFFREE2, snprintf(), talk_to_npc(), obj::type, obj::x, and obj::y.

Referenced by command_say().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int compute_path ( object source,
object target,
int  default_dir 
)

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.

Parameters
sourcewhat wants to move.
targettarget to go to.
default_dirgeneral direction from source to target.
Returns
direction to go into. Will be default_dir if no path found.
Todo:
cache path, smart ajustment and such things to not compute all the time ; try directions randomly.

Definition at line 371 of file monster.c.

References absdir(), fatal(), freearr_x, freearr_y, mapdef::height, obj::map, MAX_EXPLORE, ob_blocked(), OUT_OF_MEMORY, OUT_OF_REAL_MAP, mapdef::width, obj::x, and obj::y.

Referenced by move_monster(), and move_to().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int dist_att ( int  dir,
object ob,
object enemy,
object part,
rv_vector rv 
)
static

Definition at line 1654 of file monster.c.

References absdir(), can_hit(), and rv_vector::distance.

Referenced by disthit_att(), and move_monster().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int disthit_att ( int  dir,
object ob,
object enemy,
object part,
rv_vector rv 
)
static

Definition at line 1699 of file monster.c.

References absdir(), dist_att(), liv::hp, liv::maxhp, obj::run_away, and obj::stats.

Referenced by move_monster().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int do_talk_npc ( object op,
object npc,
const char *  txt,
int *  talked 
)
static

Checks the messages of a NPC for a matching text. Will not call plugin events. Called by talk_to_npc().

Parameters
opwho is saying something
npcobject that gets a chance to reply.
txttext being said.
talkeddid op already talk? Will be modified if this function makes op talk.
Returns
1 if npc talked, 0 else.

Definition at line 1883 of file monster.c.

References draw_ext_info(), draw_ext_info_format(), ext_info_map(), get_dialog_message(), MAGIC_EAR, obj::map, MAX_BUF, struct_dialog_reply::message, struct_dialog_message::message, MSG_TYPE_COMMUNICATION, MSG_TYPE_COMMUNICATION_SAY, MSG_TYPE_DIALOG, MSG_TYPE_DIALOG_MAGIC_MOUTH, obj::name, NDI_NAVY, NDI_UNIQUE, NDI_WHITE, struct_dialog_reply::next, npc_say(), struct_dialog_message::replies, struct_dialog_reply::reply, rt_reply, snprintf(), struct_dialog_reply::type, obj::type, and use_trigger().

Referenced by talk_to_npc().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static object* find_enemy ( object npc,
rv_vector rv 
)
static

Tries to find an enmy for npc. We pass the range vector since our caller will find the information useful. Currently, only move_monster 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.

Parameters
npcmonster we're considering.
[out]rvvector that will contain how to reach the target. Must not be NULL.
Returns
enemy npc wants to attack, or NULL if nont found.

Definition at line 216 of file monster.c.

References obj::attack_movement, obj::attacked_by, obj::attacked_by_count, check_enemy(), CLEAR_FLAG, obj::count, obj::enemy, find_nearest_living_creature(), FLAG_BERSERK, FLAG_FRIENDLY, FLAG_NEUTRAL, FLAG_SLEEP, FLAG_UNAGGRESSIVE, get_nearest_player(), get_pet_enemy(), get_rangevector(), HI4, on_same_map(), PETMOVE, PLAYER, QUERY_FLAG, and obj::type.

Referenced by move_monster().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

object* find_mon_throw_ob ( object op)

Definition at line 1978 of file monster.c.

References obj::below, obj::count, FLAG_APPLIED, FLAG_IS_THROWN, obj::head, obj::inv, obj::invisible, llevDebug, LOG(), MAX_BUF, obj::name, QUERY_FLAG, and query_name().

Referenced by skill_throw().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

object* find_nearest_living_creature ( object npc)

Returns the nearest living creature (monster or generator). Modified to deal with tiled maps properly. Also fixed logic so that monsters in the lower directions were more likely to be skipped - instead of just skipping the 'start' number of direction, revisit them after looking at all the other spaces.

Note that being this may skip some number of spaces, it will not necessarily find the nearest living creature - it basically chooses one from within a 3 space radius, and since it skips the first few directions, it could very well choose something 3 spaces away even though something directly north is closer.

This function is map tile aware.

Parameters
npcmonster to consider
Returns
living creature, or NULL if none found.

Definition at line 162 of file monster.c.

References obj::above, can_see_monsterP(), FLAG_GENERATOR, FLAG_MONSTER, freearr_x, freearr_y, get_map_flags(), GET_MAP_OB, get_search_arr(), llevDebug, LOG(), obj::map, P_IS_ALIVE, P_OUT_OF_MAP, mapdef::path, PLAYER, QUERY_FLAG, SIZEOFFREE, obj::type, obj::x, and obj::y.

Referenced by find_enemy(), and get_pet_enemy().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int hitrun_att ( int  dir,
object ob,
object enemy 
)
static

Definition at line 1673 of file monster.c.

References absdir(), and obj::move_status.

Referenced by move_monster().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void monster_apply_below ( object monster)
static

Definition at line 1500 of file monster.c.

References obj::below, CF_HANDLE, FLAG_IS_FLOOR, manual_apply(), QUERY_FLAG, TREASURE, TRIGGER, obj::type, obj::will_apply, WILL_APPLY_HANDLE, and WILL_APPLY_TREASURE.

Referenced by move_monster().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int monster_can_pick ( object monster,
object item 
)
static
static int monster_cast_spell ( object head,
object part,
object pl,
int  dir,
rv_vector rv 
)
static

Tries to make a (part of a) monster cast a spell.

Handles sp/gr limits, and confusion.

Parameters
headhead of the monster.
partpart of the monster that we use to cast.
pltarget.
dirdirection to cast.
rvvector describing where the enemy is.
Returns
1 if monster casted a spell, 0 else.

Definition at line 957 of file monster.c.

References absdir(), cast_spell(), CLEAR_FLAG, liv::dam, dirdiff(), rv_vector::direction, FLAG_CAST_SPELL, FLAG_CONFUSED, FLAG_FRIENDLY, get_owner(), get_rangevector(), liv::grace, obj::inv, llevError, llevMonster, LOG(), monster_choose_random_spell(), obj::name, path_to_player(), QUERY_FLAG, obj::range, liv::sp, SP_level_spellpoint_cost(), SPELL_GRACE, SPELL_MANA, SPELLBOOK, obj::spellitem, obj::stats, and obj::type.

Referenced by move_monster().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void monster_check_pickup ( object monster)
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.

Parameters
monstermonster that can pick up items.

Definition at line 1393 of file monster.c.

References obj::below, obj::count, insert_ob_in_ob(), monster_can_pick(), monster_check_apply(), remove_ob(), and was_destroyed.

Referenced by move_monster().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static object* monster_choose_random_spell ( object monster)
static

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?

Parameters
monstermonster trying to cast a spell.
Returns
spell to cast, NULL if none suitable found.
Note
Will only consider the first MAX_KNOWN_SPELLS spells found.

Definition at line 917 of file monster.c.

References obj::below, obj::inv, MAX_KNOWN_SPELLS, monster_should_cast_spell(), SPELL, SPELLBOOK, and obj::type.

Referenced by monster_cast_spell().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void monster_do_living ( object op)
static

For a monster, regenerate hp and sp, potentially clear scared status.

Parameters
opmonster. Must have FLAG_MONSTER set.

Definition at line 436 of file monster.c.

References CLEAR_FLAG, liv::Con, FABS, FLAG_MONSTER, FLAG_RUN_AWAY, FLAG_SCARED, liv::hp, obj::last_heal, obj::last_sp, liv::maxhp, liv::maxsp, MIN, liv::Pow, QUERY_FLAG, obj::run_away, liv::sp, obj::speed, and obj::stats.

Referenced by move_monster().

+ Here is the caller graph for this function:

static int monster_move_no_enemy ( object op)
static

Makes a monster without any enemy move.

Parameters
opmonster, must have FLAG_MONSTER set.
Returns
1 if monster was removed, 0 else.

Definition at line 495 of file monster.c.

References obj::attack_movement, circ1_move(), circ2_move(), CIRCLE1, CIRCLE2, FLAG_MONSTER, FLAG_ONLY_ATTACK, FLAG_RANDOM_MOVE, FLAG_STAND_STILL, free_object(), HI4, move_randomly(), pace2_moveh(), pace2_movev(), pace_moveh(), pace_movev(), PACEH, PACEH2, PACEV, PACEV2, pet_move(), PETMOVE, QUERY_FLAG, rand_move(), RANDO, RANDO2, and remove_ob().

Referenced by move_monster().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int monster_should_cast_spell ( object monster,
object spell_ob 
)
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.

Parameters
monstermonster trying to cast a spell.
spell_obspell considered.
Returns
1 is monster should cast spell sp, 0 else.
Todo:
improve logic, take enemy into consideration.

Definition at line 880 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().

+ Here is the caller graph for this function:

static int monster_use_bow ( object head,
object part,
object pl,
int  dir 
)
static

Tries to make a (part of a) monster fire a bow.

Handles confusion effect.

Parameters
headhead of the monster.
partpart of the monster that we use to cast.
pltarget.
dirdirection to cast.
Returns
1 if monster fired something, 0 else.

Definition at line 1233 of file monster.c.

References absdir(), rv_vector::distance, rv_vector::distance_x, rv_vector::distance_y, find_dir_2(), fire_bow(), FLAG_CONFUSED, FLAG_FRIENDLY, freearr_x, freearr_y, get_map_from_coord(), GET_MAP_MOVE_BLOCK, get_owner(), get_rangevector(), llevError, LOG(), obj::map, MOVE_FLY_LOW, QUERY_FLAG, obj::x, and obj::y.

Referenced by move_monster().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int monster_use_range ( object head,
object part,
object pl,
int  dir 
)
static

Monster will use a ranged attack (HORN, WAND, ...).

Parameters
headhead of the monster.
partpart of the monster that can do a range attack.
pltarget.
dirdirection to fire.
Returns
1 if monster casted a spell, 0 else.

Definition at line 1164 of file monster.c.

References absdir(), obj::below, cast_spell(), CLEAR_FLAG, obj::count, dirdiff(), drain_rod_charge(), drain_wand_charge(), find_dir_2(), FLAG_CONFUSED, FLAG_FRIENDLY, FLAG_READY_RANGE, liv::food, get_owner(), liv::grace, HORN, liv::hp, obj::inv, llevError, LOG(), MAX, obj::name, path_to_player(), QUERY_FLAG, ROD, liv::sp, obj::stats, obj::type, WAND, obj::x, and obj::y.

Referenced by move_monster().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int monster_use_scroll ( object head,
object part,
object pl,
int  dir,
rv_vector rv 
)
static

Tries to make a (part of a) monster apply a spell.

Parameters
headhead of the monster.
partpart of the monster that we use to cast.
pltarget.
dirdirection to cast.
rvvector describing where the enemy is.
Returns
1 if monster applied a scroll, 0 else.

Definition at line 1040 of file monster.c.

References absdir(), animate_object(), obj::animation_id, obj::below, CLEAR_FLAG, dirdiff(), obj::direction, rv_vector::direction, obj::facing, FLAG_CONFUSED, FLAG_FRIENDLY, FLAG_READY_SCROLL, get_owner(), get_rangevector(), obj::inv, monster_should_cast_spell(), ob_apply(), path_to_player(), QUERY_FLAG, obj::range, SCROLL, and obj::type.

Referenced by move_monster().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int monster_use_skill ( object head,
object part,
object pl,
int  dir 
)
static

monster_use_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.

Parameters
headhead of the monster.
partpart of the monster that may use a skill.
pltarget.
dirdirection to cast.
Returns
1 if monster used a skill, 0 else.
Todo:
improve skill logic? Fix comments.

Definition at line 1115 of file monster.c.

References absdir(), obj::below, obj::chosen_skill, CLEAR_FLAG, obj::count, dirdiff(), do_skill(), find_dir_2(), FLAG_CONFUSED, FLAG_FRIENDLY, FLAG_READY_SKILL, get_owner(), obj::inv, llevDebug, LOG(), obj::name, path_to_player(), QUERY_FLAG, SKILL, obj::type, obj::x, and obj::y.

Referenced by move_monster().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int move_monster ( object op)

Main monster processing routine.

Will regenerate spell points, hit points. Moves the monster, handle attack, item applying, pickup, ...

Parameters
opmonster to process.
Returns
1 if the object has been freed, otherwise 0.

Definition at line 566 of file monster.c.

References absdir(), add_refcount(), ALLRUN, animate_object(), obj::animation_id, obj::attack_movement, obj::attacked_by, obj::attacked_by_count, can_hit(), check_wakeup(), compute_path(), obj::count, mapdef::darkness, obj::direction, rv_vector::direction, dist_att(), DISTATT, DISTHIT, disthit_att(), do_hidden_move(), obj::enemy, FABS, obj::face, obj::facing, find_enemy(), FLAG_BLIND, FLAG_CAST_SPELL, FLAG_CONFUSED, FLAG_FREED, FLAG_FRIENDLY, FLAG_NO_ATTACK, FLAG_ONLY_ATTACK, 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, follow_owner(), free_object(), free_string(), get_nearest_player(), get_owner(), get_rangevector(), obj::head, HI4, obj::hide, HITRUN, hitrun_att(), llevDebug, LO4, LOG(), obj::map, MIN_ACTIVE_SPEED, monster_apply_below(), monster_cast_spell(), monster_check_pickup(), monster_do_living(), monster_move_no_enemy(), monster_use_bow(), monster_use_range(), monster_use_scroll(), monster_use_skill(), obj::more, move_object(), move_randomly(), obj::name, on_same_map(), rv_vector::part, PETMOVE, obj::pick_up, QUERY_FLAG, obj::race, remove_friendly_object(), remove_ob(), run_att(), RUNATT, RUSH, skill_attack(), obj::speed, obj::stats, WAIT2, wait_att(), wait_att2(), WAITATT, liv::wc, and obj::will_apply.

Referenced by process_object().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int move_randomly ( object op)
static

Makes an object move in a random direction.

Parameters
opobject to move.
Returns
1 if moved, 0 else.

Definition at line 344 of file monster.c.

References move_object().

Referenced by monster_move_no_enemy(), and move_monster().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void npc_call_help ( object op)

Definition at line 1632 of file monster.c.

References obj::above, obj::enemy, FLAG_ALIVE, FLAG_UNAGGRESSIVE, get_map_flags(), GET_MAP_OB, obj::map, P_IS_ALIVE, P_OUT_OF_MAP, QUERY_FLAG, obj::x, and obj::y.

Referenced by alchemy_failure_effect(), attack_ob_simple(), attempt_steal(), and hit_player().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void npc_say ( object npc,
const char *  cp 
)

Simple function to have some NPC say something.

Parameters
npcwho should say something.
cpwhat is being said.

Definition at line 1933 of file monster.c.

References ext_info_map(), HUGE_BUF, obj::map, MAX_BUF, MSG_TYPE_DIALOG, MSG_TYPE_DIALOG_NPC, NDI_NAVY, NDI_UNIQUE, query_name(), and snprintf().

Referenced by cfapi_object_say(), and do_talk_npc().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void pace2_moveh ( object ob)
static

Definition at line 1767 of file monster.c.

References move_object(), and obj::move_status.

Referenced by monster_move_no_enemy().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void pace2_movev ( object ob)
static

Definition at line 1754 of file monster.c.

References move_object(), and obj::move_status.

Referenced by monster_move_no_enemy().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void pace_moveh ( object ob)
static

Definition at line 1745 of file monster.c.

References move_object(), and obj::move_status.

Referenced by monster_move_no_enemy().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void pace_movev ( object ob)
static

Definition at line 1736 of file monster.c.

References move_object(), and obj::move_status.

Referenced by monster_move_no_enemy().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void rand_move ( object ob)
static

Definition at line 1780 of file monster.c.

References move_object(), and obj::move_status.

Referenced by monster_move_no_enemy().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int run_att ( int  dir,
object ob,
object enemy,
object part,
rv_vector rv 
)
static

Definition at line 1664 of file monster.c.

References absdir(), can_hit(), and obj::move_status.

Referenced by move_monster().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int stand_in_light ( object op)

Definition at line 2159 of file monster.c.

References get_map_flags(), GET_MAP_LIGHT, obj::glow_radius, isqrt(), obj::map, MAX_LIGHT_RADII, P_OUT_OF_MAP, obj::x, and obj::y.

Referenced by adj_attackroll(), can_see_enemy(), and check_wakeup().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int talk_to_npc ( object op,
object npc,
const char *  txt,
int *  talked 
)
static

Give an object the chance to handle something being said. Plugin hooks will be called, including in the NPC's inventory.

Parameters
opwho is talking.
npcobject to try to talk to. Can be an NPC or a MAGIC_EAR.
txtwhat op is saying.
talkeddid op already talk? Can be modified by this function.
Returns
0 if text was handled by a plugin or not handled, 1 if handled internally by the server.

Definition at line 1952 of file monster.c.

References obj::below, do_talk_npc(), EVENT_SAY, execute_event(), obj::inv, and SCRIPT_FIX_ALL.

Referenced by communicate().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int wait_att ( int  dir,
object ob,
object enemy,
object part,
rv_vector rv 
)
static

Definition at line 1683 of file monster.c.

References absdir(), can_hit(), and obj::move_status.

Referenced by move_monster().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int wait_att2 ( int  dir,
object ob,
object enemy,
object part,
rv_vector rv 
)
static

Definition at line 1712 of file monster.c.

References absdir(), and rv_vector::distance.

Referenced by move_monster().

+ Here is the call graph for this function:

+ Here is the caller graph for this function: