Crossfire Server, Branch 1.12  R12190
Defines | Functions
monster.c File Reference

This deals with monster moving, attacking, using items and such. More...

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

Defines

#define MAX_EXPLORE   5000
#define MAX_KNOWN_SPELLS   20
 Maximum number of spells to consider when choosing a spell for a monster.
#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)
 Checks if monster can hit in hand-to-hand combat.
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)
object * check_enemy (object *npc, rv_vector *rv)
 Checks npc->enemy and returns that enemy if still valid, NULL otherwise.
static int check_good_armour (object *who, object *item)
 Checks if using armor 'item' would be better for 'who'.
static int check_good_weapon (object *who, object *item)
 Checks if using weapon 'item' would be better for 'who'.
static int check_wakeup (object *op, object *enemy, rv_vector *rv)
 Sees if this monster should wake up.
static void circ1_move (object *ob)
static void circ2_move (object *ob)
void communicate (object *op, const char *txt)
 This function looks for an object or creature that is listening to said text.
int compute_path (object *source, object *target, int default_dir)
 Computes a path from source to target.
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)
 Checks the messages of a NPC for a matching text.
static object * find_enemy (object *npc, rv_vector *rv)
 Tries to find an enmy for npc.
object * find_mon_throw_ob (object *op)
object * find_nearest_living_creature (object *npc)
 Returns the nearest living creature (monster or generator).
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)
 Tries to make a (part of a) monster cast a spell.
void monster_check_apply (object *mon, object *item)
static void monster_check_pickup (object *monster)
 Checks for items that monster can pick up.
static object * monster_choose_random_spell (object *monster)
 Selects a spell to cast for a monster.
static void monster_do_living (object *op)
 For a monster, regenerate hp and sp, potentially clear scared status.
static int monster_move_no_enemy (object *op)
 Makes a monster without any enemy move.
static int monster_should_cast_spell (object *monster, object *spell_ob)
 Checks if a monster should cast a spell.
static int monster_use_bow (object *head, object *part, object *pl, int dir)
 Tries to make a (part of a) monster fire a bow.
static int monster_use_range (object *head, object *part, object *pl, int dir)
 Monster will use a ranged attack (HORN, WAND, ...).
static int monster_use_scroll (object *head, object *part, object *pl, int dir, rv_vector *rv)
 Tries to make a (part of a) monster apply a spell.
static int monster_use_skill (object *head, object *part, object *pl, int dir)
 monster_use_skill()-implemented 95-04-28 to allow monster skill use.
int move_monster (object *op)
 Main monster processing routine.
static int move_randomly (object *op)
 Makes an object move in a random direction.
void npc_call_help (object *op)
void npc_say (object *npc, const char *cp)
 Simple function to have some NPC say something.
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)
 Give an object the chance to handle something being said.
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.


Define 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 
)

Definition at line 2020 of file monster.c.

References can_see_enemy(), find_skill_by_number(), FLAG_WIZ, get_rangevector(), llevError, LOG(), make_visible(), MAX, MIN_MON_RADIUS, on_same_map(), PLAYER, QUERY_FLAG, and SK_HIDING.

Referenced by attempt_steal(), check_enemy(), get_nearest_player(), and get_pet_enemy().

Here is the call graph for this function:

Here is the caller graph for this function:

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(), 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:

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

Definition at line 1802 of file monster.c.

References AT_PHYSICAL, DOOR, GET_MAP_OB, and hit_player().

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 AT_PHYSICAL, EARTHWALL, GET_MAP_OB, and hit_player().

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 can_detect_enemy(), FLAG_FREED, FLAG_FRIENDLY, FLAG_GENERATOR, FLAG_MONSTER, FLAG_NEUTRAL, FLAG_REMOVED, GOLEM, HI4, on_same_map(), PETMOVE, PLAYER, QUERY_FLAG, and should_arena_attack().

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 ATNR_PHYSICAL, FLAG_APPLIED, NROFATTACKS, and QUERY_FLAG.

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 FLAG_APPLIED, get_attr_value(), NUM_STATS, and QUERY_FLAG.

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, rv_vector::distance, FLAG_BLIND, FLAG_SEE_IN_DARK, FLAG_SEE_INVISIBLE, FLAG_SLEEP, FLAG_STEALTH, MAX, MIN_MON_RADIUS, QUERY_FLAG, and stand_in_light().

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().

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().

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 ext_info_map(), freearr_x, freearr_y, get_map_flags(), GET_MAP_OB, llevDebug, LOG(), MAX_BUF, MSG_TYPE_COMMUNICATION, MSG_TYPE_COMMUNICATION_SAY, NDI_WHITE, P_OUT_OF_MAP, PLAYER, SIZEOFFREE2, snprintf(), and talk_to_npc().

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, MAX_EXPLORE, ob_blocked(), OUT_OF_MEMORY, and OUT_OF_REAL_MAP.

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(), and dist_att().

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, 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, 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, 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 check_enemy(), CLEAR_FLAG, 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, and QUERY_FLAG.

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 FLAG_APPLIED, FLAG_IS_THROWN, llevDebug, LOG(), MAX_BUF, 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 can_see_monsterP(), FLAG_GENERATOR, FLAG_MONSTER, freearr_x, freearr_y, get_map_flags(), GET_MAP_OB, get_search_arr(), llevDebug, LOG(), P_IS_ALIVE, P_OUT_OF_MAP, mapdef::path, PLAYER, QUERY_FLAG, and SIZEOFFREE.

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().

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 CF_HANDLE, FLAG_IS_FLOOR, manual_apply(), QUERY_FLAG, TREASURE, and TRIGGER.

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]

Definition at line 1420 of file monster.c.

References ARROW, BOW, can_pick(), FLAG_CAN_USE_SKILL, FLAG_CAST_SPELL, 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, HORN, IS_ARMOR, IS_SHIELD, IS_WEAPON, MONEY, QUERY_FLAG, RING, ROD, SCROLL, SKILL, SPELLBOOK, and WAND.

Referenced by monster_check_pickup().

Here is the call graph for this function:

Here is the caller graph for this function:

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, dirdiff(), rv_vector::direction, FLAG_CAST_SPELL, FLAG_CONFUSED, FLAG_FRIENDLY, get_owner(), get_rangevector(), llevError, llevMonster, LOG(), monster_choose_random_spell(), path_to_player(), QUERY_FLAG, SP_level_spellpoint_cost(), SPELL_GRACE, SPELL_MANA, and SPELLBOOK.

Referenced by move_monster().

Here is the call graph for this function:

Here is the caller graph for this function:

void monster_check_apply ( object *  mon,
object *  item 
)
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 insert_ob_in_ob(), monster_can_pick(), monster_check_apply(), and remove_ob().

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 MAX_KNOWN_SPELLS, monster_should_cast_spell(), SPELL, and SPELLBOOK.

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, FABS, FLAG_MONSTER, FLAG_RUN_AWAY, FLAG_SCARED, MIN, and QUERY_FLAG.

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 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, and SP_SWARM.

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(), MOVE_FLY_LOW, and QUERY_FLAG.

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(), cast_spell(), CLEAR_FLAG, dirdiff(), drain_rod_charge(), drain_wand_charge(), find_dir_2(), FLAG_CONFUSED, FLAG_FRIENDLY, FLAG_READY_RANGE, get_owner(), HORN, llevError, LOG(), MAX, path_to_player(), QUERY_FLAG, ROD, and WAND.

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(), CLEAR_FLAG, dirdiff(), rv_vector::direction, FLAG_CONFUSED, FLAG_FRIENDLY, FLAG_READY_SCROLL, get_owner(), get_rangevector(), monster_should_cast_spell(), ob_apply(), path_to_player(), QUERY_FLAG, and SCROLL.

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(), CLEAR_FLAG, dirdiff(), do_skill(), find_dir_2(), FLAG_CONFUSED, FLAG_FRIENDLY, FLAG_READY_SKILL, get_owner(), llevDebug, LOG(), path_to_player(), QUERY_FLAG, and SKILL.

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)
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 FLAG_ALIVE, FLAG_UNAGGRESSIVE, get_map_flags(), GET_MAP_OB, P_IS_ALIVE, P_OUT_OF_MAP, and QUERY_FLAG.

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, 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().

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().

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().

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().

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().

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(), and can_hit().

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, isqrt(), MAX_LIGHT_RADII, and P_OUT_OF_MAP.

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 do_talk_npc(), EVENT_SAY, execute_event(), 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(), and can_hit().

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: