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