Crossfire Server, Trunk
R22047
|
#include "global.h"
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "skills.h"
#include "spells.h"
#include "sproto.h"
Go to the source code of this file.
Macros | |
#define | MAX_EXPLORE 5000 |
#define | MAX_KNOWN_SPELLS 20 |
#define | MIN_MON_RADIUS 3 |
Functions | |
static const char * | get_reply_text_other (reply_type rt) |
static const char * | get_reply_text_own (reply_type rt) |
static void | monster_apply_below (object *monster) |
int | monster_can_detect_enemy (object *op, object *enemy, rv_vector *rv) |
static int | monster_can_hit (object *ob1, object *ob2, rv_vector *rv) |
static int | monster_can_pick (object *monster, object *item) |
int | monster_can_see_enemy (object *op, object *enemy) |
static int | monster_cast_spell (object *head, object *part, object *pl, int dir) |
static void | monster_check_apply (object *mon, object *item) |
void | monster_check_apply_all (object *monster) |
void | monster_check_doors (object *op, mapstruct *m, int x, int y) |
void | monster_check_earthwalls (object *op, mapstruct *m, int x, int y) |
object * | monster_check_enemy (object *npc, rv_vector *rv) |
static int | monster_check_good_armour (object *who, object *item) |
static int | monster_check_good_weapon (object *who, object *item) |
static void | monster_check_pickup (object *monster) |
static int | monster_check_wakeup (object *op, object *enemy, rv_vector *rv) |
static object * | monster_choose_random_spell (object *monster) |
static void | monster_circ1_move (object *ob) |
static void | monster_circ2_move (object *ob) |
void | monster_communicate (object *op, const char *txt) |
int | monster_compute_path (object *source, object *target, int default_dir) |
static int | monster_dist_att (int dir, object *enemy, object *part, rv_vector *rv) |
static int | monster_disthit_att (int dir, object *ob, object *enemy, object *part, rv_vector *rv) |
void | monster_do_living (object *op) |
void | monster_do_say (const mapstruct *map, const char *message) |
static int | monster_do_talk_npc (object *npc, talk_info *info) |
static object * | monster_find_enemy (object *npc, rv_vector *rv) |
object * | monster_find_nearest_living_creature (object *npc) |
object * | monster_find_throw_ob (object *op) |
static StringBuffer * | monster_format_say (const object *npc, const char *message) |
static int | monster_get_armour_quality (const object *item) |
static int | monster_get_weapon_quality (const object *item) |
static int | monster_hitrun_att (int dir, object *ob, object *enemy) |
int | monster_move (object *op) |
static int | monster_move_no_enemy (object *op) |
static int | monster_move_randomly (object *op) |
void | monster_npc_call_help (object *op) |
void | monster_npc_say (object *npc, const char *cp) |
static void | monster_pace2_moveh (object *ob) |
static void | monster_pace2_movev (object *ob) |
static void | monster_pace_moveh (object *ob) |
static void | monster_pace_movev (object *ob) |
static void | monster_rand_move (object *ob) |
static int | monster_run_att (int dir, object *ob, object *enemy, object *part, rv_vector *rv) |
static int | monster_should_cast_spell (object *spell_ob) |
int | monster_stand_in_light (object *op) |
static int | monster_talk_to_npc (object *npc, talk_info *info) |
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) |
static int | monster_use_skill (object *head, object *part, object *pl, int dir) |
static int | monster_wait_att (int dir, object *ob, object *enemy, object *part, rv_vector *rv) |
static int | monster_wait_att2 (int dir, rv_vector *rv) |
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().
Definition at line 375 of file monster.c.
Referenced by monster_compute_path().
#define MAX_KNOWN_SPELLS 20 |
Maximum number of spells to consider when choosing a spell for a monster.
Definition at line 1039 of file monster.c.
Referenced by monster_choose_random_spell().
#define MIN_MON_RADIUS 3 |
Minimum monster detection radius.
Definition at line 55 of file monster.c.
Referenced by monster_can_detect_enemy(), and monster_check_wakeup().
|
static |
Return the verb for the player's dialog type seen from others (third person).
rt | dialog type. |
Definition at line 2150 of file monster.c.
References rt_question, rt_reply, and rt_say.
Referenced by monster_communicate().
|
static |
Return the verb for the player's dialog type.
rt | dialog type. |
Definition at line 2132 of file monster.c.
References rt_question, rt_reply, and rt_say.
Referenced by monster_communicate().
|
static |
If a monster who's eager to apply things encounters something apply-able, then make him apply it.
Definition at line 1804 of file monster.c.
References apply_manual(), FLAG_IS_FLOOR, FOR_BELOW_FINISH, FOR_BELOW_PREPARE, and QUERY_FLAG.
Referenced by monster_move().
int monster_can_detect_enemy | ( | object * | op, |
object * | enemy, | ||
rv_vector * | rv | ||
) |
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 2391 of file monster.c.
References rv_vector::distance, draw_ext_info_format(), find_skill_by_number(), FLAG_SEE_IN_DARK, FLAG_STEALTH, FLAG_WIZ, get_rangevector(), is_true_undead(), llevError, LOG(), make_visible(), MAX, MAX_BUF, MIN_MON_RADIUS, monster_can_see_enemy(), monster_stand_in_light(), MSG_TYPE_SKILL, MSG_TYPE_SKILL_FAILURE, NDI_UNIQUE, player_can_view(), QUERY_FLAG, query_name(), RANDOM, and SK_HIDING.
Referenced by attempt_steal(), get_nearest_player(), monster_check_enemy(), and pets_get_enemy().
|
static |
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 973 of file monster.c.
References rv_vector::distance_x, rv_vector::distance_y, FLAG_CONFUSED, get_rangevector(), QUERY_FLAG, and RANDOM.
Referenced by monster_dist_att(), monster_move(), monster_run_att(), and monster_wait_att().
|
static |
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 1723 of file monster.c.
References 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, IS_ARMOR, IS_SHIELD, IS_WEAPON, object_can_pick(), object_find_by_type_subtype(), QUERY_FLAG, and SK_THROWING.
Referenced by monster_check_pickup().
int monster_can_see_enemy | ( | object * | op, |
object * | enemy | ||
) |
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 2574 of file monster.c.
References draw_ext_info(), FLAG_ALIVE, FLAG_BLIND, FLAG_SEE_IN_DARK, FLAG_SEE_INVISIBLE, FLAG_XRAYS, has_carried_lights(), is_true_undead(), make_visible(), makes_invisible_to(), monster_stand_in_light(), MSG_TYPE_SKILL, MSG_TYPE_SKILL_FAILURE, NDI_UNIQUE, player_can_view(), and QUERY_FLAG.
Referenced by adj_attackroll(), attack_ob_simple(), monster_can_detect_enemy(), and pets_get_enemy().
|
static |
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 1094 of file monster.c.
References cast_spell(), CLEAR_FLAG, dirdiff(), rv_vector::direction, FLAG_CAST_SPELL, FLAG_CONFUSED, FLAG_FRIENDLY, get_randomized_dir(), get_rangevector(), llevError, llevMonster, LOG(), monster_choose_random_spell(), object_get_owner(), path_to_player(), QUERY_FLAG, SP_level_spellpoint_cost(), SPELL_GRACE, and SPELL_MANA.
Referenced by monster_move().
|
static |
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 1562 of file monster.c.
References AP_APPLY, AP_IGNORE_CURSE, AP_NOPRINT, apply_can_apply_object(), apply_manual(), CAN_APPLY_NOT_MASK, FLAG_APPLIED, FLAG_CAST_SPELL, FLAG_READY_BOW, FLAG_READY_RANGE, FLAG_READY_SCROLL, FLAG_READY_SKILL, FLAG_USE_BOW, FLAG_USE_SCROLL, IS_ARMOR, IS_SHIELD, llevDebug, llevMonster, LOG(), monster_check_good_armour(), monster_check_good_weapon(), monster_should_cast_spell(), object_find_by_type_and_race(), QUERY_FLAG, and SET_FLAG.
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 1827 of file monster.c.
References fix_object(), FOR_INV_FINISH, FOR_INV_PREPARE, 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().
void monster_check_doors | ( | object * | op, |
mapstruct * | m, | ||
int | x, | ||
int | y | ||
) |
Living creature attempts to open a door.
op | creature to consider. |
m | map to consider. |
x | coordinate. |
y | coordinate. |
Definition at line 2092 of file monster.c.
References AT_PHYSICAL, FOR_MAP_FINISH, FOR_MAP_PREPARE, and hit_player().
Referenced by move_ob().
void monster_check_earthwalls | ( | object * | op, |
mapstruct * | m, | ||
int | x, | ||
int | y | ||
) |
Living creature attempts to hit an earthwall.
op | creature to consider. |
m | map to consider. |
x | coordinate. |
y | coordinate. |
Definition at line 2076 of file monster.c.
References AT_PHYSICAL, FOR_MAP_FINISH, FOR_MAP_PREPARE, and hit_player().
Referenced by move_ob().
object* monster_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.
npc | monster we're considering | |
[out] | rv | will contain vector to go to enemy if function returns not NULL. |
Definition at line 71 of file monster.c.
References FLAG_FREED, FLAG_FRIENDLY, FLAG_GENERATOR, FLAG_MONSTER, FLAG_NEUTRAL, FLAG_REMOVED, HI4, monster_can_detect_enemy(), object_get_owner(), object_set_enemy(), on_same_map(), PETMOVE, pets_should_arena_attack(), and QUERY_FLAG.
Referenced by monster_find_enemy(), and pets_get_enemy().
|
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.
who | creature considering to apply item. |
item | item to check. |
Definition at line 1527 of file monster.c.
References monster_get_armour_quality(), NROFATTACKS, and object_find_by_type_applied().
Referenced by monster_check_apply().
|
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.
who | creature considering to apply item. |
item | item to check. |
Definition at line 1480 of file monster.c.
References monster_get_weapon_quality(), and object_find_by_type_applied().
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 1679 of file monster.c.
References FOR_BELOW_FINISH, FOR_BELOW_PREPARE, get_weight_limit(), MAX, MIN, monster_can_pick(), monster_check_apply(), object_insert_in_ob(), and object_split().
Referenced by monster_move().
|
static |
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 296 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, monster_stand_in_light(), and QUERY_FLAG.
Referenced by monster_move().
|
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?
monster | monster trying to cast a spell. |
Definition at line 1056 of file monster.c.
References FOR_INV_FINISH, FOR_INV_PREPARE, MAX_KNOWN_SPELLS, monster_should_cast_spell(), and RANDOM.
Referenced by monster_cast_spell().
|
static |
Move the monster in a specified movement pattern.
ob | monster. |
Definition at line 1974 of file monster.c.
References move_object(), and RANDOM.
Referenced by monster_move_no_enemy().
|
static |
Move the monster in a specified movement pattern.
ob | monster. |
Definition at line 1987 of file monster.c.
References move_object(), and RANDOM.
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 2188 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, talk_info::npc_msg_count, talk_info::npc_msgs, P_OUT_OF_MAP, talk_info::replies, talk_info::replies_count, talk_info::replies_words, SIZEOFFREE2, snprintf, talk_info::text, and talk_info::who.
Referenced by command_say().
int monster_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.
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 393 of file monster.c.
References absdir(), fatal(), freearr_x, freearr_y, mapdef::height, MAX_EXPLORE, ob_blocked(), OUT_OF_MEMORY, OUT_OF_REAL_MAP, RANDOM, and mapdef::width.
Referenced by monster_move(), and move_to().
|
static |
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 1867 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 1945 of file monster.c.
References absdir(), and monster_dist_att().
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 564 of file monster.c.
References CLEAR_FLAG, FABS, FLAG_MONSTER, FLAG_RUN_AWAY, FLAG_SCARED, MIN, 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 2106 of file monster.c.
References ext_info_map(), MSG_TYPE_DIALOG, MSG_TYPE_DIALOG_NPC, NDI_NAVY, and NDI_UNIQUE.
Referenced by monster_communicate(), and monster_npc_say().
|
static |
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 2262 of file monster.c.
References add_string(), ext_info_map(), get_dialog_message(), MAX_NPC, MAX_REPLIES, struct_dialog_reply::message, struct_dialog_message::message, talk_info::message, talk_info::message_type, monster_format_say(), MSG_TYPE_DIALOG, MSG_TYPE_DIALOG_MAGIC_EAR, NDI_NAVY, NDI_UNIQUE, struct_dialog_reply::next, talk_info::npc_msg_count, talk_info::npc_msgs, object_set_value(), struct_dialog_message::replies, talk_info::replies, talk_info::replies_count, talk_info::replies_words, struct_dialog_reply::reply, stringbuffer_finish_shared(), talk_info::text, struct_dialog_reply::type, and use_trigger().
Referenced by monster_talk_to_npc().
|
static |
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 209 of file monster.c.
References CLEAR_FLAG, FLAG_BERSERK, FLAG_FRIENDLY, FLAG_NEUTRAL, FLAG_SLEEP, FLAG_UNAGGRESSIVE, get_nearest_player(), get_rangevector(), HI4, monster_check_enemy(), monster_find_nearest_living_creature(), object_set_enemy(), on_same_map(), PETMOVE, pets_get_enemy(), and QUERY_FLAG.
Referenced by monster_move().
object* monster_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.
npc | monster to consider |
Definition at line 152 of file monster.c.
References can_see_monsterP(), FLAG_GENERATOR, FLAG_MONSTER, FOR_MAP_FINISH, FOR_MAP_PREPARE, freearr_x, freearr_y, get_map_flags(), get_search_arr(), llevDebug, LOG(), P_IS_ALIVE, P_OUT_OF_MAP, mapdef::path, QUERY_FLAG, and SIZEOFFREE.
Referenced by monster_find_enemy(), and pets_get_enemy().
object* monster_find_throw_ob | ( | object * | op | ) |
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 2352 of file monster.c.
References FLAG_APPLIED, FLAG_IS_THROWN, FOR_INV_FINISH, FOR_INV_PREPARE, llevDebug, LOG(), MAX_BUF, QUERY_FLAG, and query_name().
Referenced by skill_throw().
|
static |
Format an NPC message.
npc | who is talking. |
message | what is being said. |
Definition at line 2117 of file monster.c.
References buf, MAX_BUF, 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 1506 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 1454 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. |
enemy | target of the monster. |
Definition at line 1902 of file monster.c.
References absdir().
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 699 of file monster.c.
References absdir(), add_refcount(), ALLRUN, animate_object(), CLEAR_FLAG, rv_vector::direction, DISTATT, DISTHIT, do_hidden_move(), FABS, 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, LO4, LOG(), 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(), object_free_drop_inventory(), object_get_owner(), object_remove(), object_set_enemy(), on_same_map(), rv_vector::part, PETMOVE, pets_follow_owner(), QUERY_FLAG, RANDOM, remove_friendly_object(), RUNATT, RUSH, skill_attack(), WAIT2, and WAITATT.
Referenced by process_object().
|
static |
Makes a monster without any enemy move.
op | monster, must have FLAG_MONSTER set. |
Definition at line 627 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(), 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 342 of file monster.c.
References FLAG_UNAGGRESSIVE, move_object(), object_get_value(), object_set_value(), QUERY_FLAG, and RANDOM.
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 1840 of file monster.c.
References FLAG_ALIVE, FLAG_UNAGGRESSIVE, FOR_MAP_FINISH, FOR_MAP_PREPARE, get_map_flags(), object_set_enemy(), P_IS_ALIVE, P_OUT_OF_MAP, and QUERY_FLAG.
Referenced by alchemy_failure_effect(), attack_ob_simple(), attempt_steal(), and hit_player().
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 2307 of file monster.c.
References buf, monster_do_say(), monster_format_say(), and stringbuffer_finish().
Referenced by cfapi_object_say().
|
static |
Move the monster in a specified movement pattern.
ob | monster. |
Definition at line 2041 of file monster.c.
References move_object().
Referenced by monster_move_no_enemy().
|
static |
Move the monster in a specified movement pattern.
ob | monster. |
Definition at line 2026 of file monster.c.
References move_object().
Referenced by monster_move_no_enemy().
|
static |
Move the monster in a specified movement pattern.
ob | monster. |
Definition at line 2013 of file monster.c.
References move_object().
Referenced by monster_move_no_enemy().
|
static |
Move the monster in a specified movement pattern.
ob | monster. |
Definition at line 2000 of file monster.c.
References move_object().
Referenced by monster_move_no_enemy().
|
static |
Move the monster in a specified movement pattern.
ob | monster. |
Definition at line 2056 of file monster.c.
References move_object(), 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 1886 of file monster.c.
References absdir(), and monster_can_hit().
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 1016 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().
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 2531 of file monster.c.
References get_map_flags(), GET_MAP_LIGHT, isqrt(), MAX_LIGHT_RADII, and P_OUT_OF_MAP.
Referenced by adj_attackroll(), monster_can_detect_enemy(), monster_can_see_enemy(), and monster_check_wakeup().
|
static |
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 2324 of file monster.c.
References events_execute_object_say(), FOR_INV_FINISH, FOR_INV_PREPARE, monster_do_talk_npc(), and talk_info::who.
Referenced by monster_communicate().
|
static |
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 1397 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(), MOVE_FLY_LOW, object_get_owner(), and QUERY_FLAG.
Referenced by monster_move().
|
static |
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 1321 of file monster.c.
References cast_spell(), CLEAR_FLAG, 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(), llevError, LOG(), MAX, object_get_owner(), path_to_player(), and QUERY_FLAG.
Referenced by monster_move().
|
static |
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 1180 of file monster.c.
References animate_object(), apply_manual(), CLEAR_FLAG, dirdiff(), rv_vector::direction, FLAG_CONFUSED, FLAG_FRIENDLY, FLAG_READY_SCROLL, FOR_INV_FINISH, FOR_INV_PREPARE, get_randomized_dir(), get_rangevector(), monster_should_cast_spell(), object_get_owner(), path_to_player(), and QUERY_FLAG.
Referenced by monster_move().
|
static |
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 1264 of file monster.c.
References CLEAR_FLAG, dirdiff(), rv_vector::direction, do_skill(), FLAG_CONFUSED, FLAG_FRIENDLY, FLAG_READY_SKILL, FOR_INV_FINISH, FOR_INV_PREPARE, get_randomized_dir(), get_rangevector(), llevDebug, LOG(), object_get_owner(), path_to_player(), and QUERY_FLAG.
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 1920 of file monster.c.
References absdir(), and monster_can_hit().
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 1964 of file monster.c.
References absdir(), and rv_vector::distance.
Referenced by monster_move().