37 static int monster_use_bow(
object *head,
object *part,
object *pl,
int dir);
58 #define MIN_MON_RADIUS 3 90 else if (npc->
enemy == NULL)
120 || npc->
enemy == owner))
198 if (nx == npc->
x && ny == npc->
y) {
207 object *creature = NULL;
241 object *attacker, *tmp = NULL;
303 snprintf(buf,
sizeof(buf),
"Halt, %s, you are under arrest!", npc->
enemy->
name);
391 if (talked && strlen(talked) > 0) {
408 for (i = 0; i < 15; i++) {
416 #define MAX_EXPLORE 5000 450 uint16_t dx =
FABS(ax - bx), dy =
FABS(ay - by);
451 uint16_t diag =
MIN(dx, dy);
452 return (
MAX(dx, dy) - diag) * 2 + diag * 3;
478 if (target->
map != source->
map)
483 const uint16_t map_height = cur_map->
height;
487 const int size = cur_map->
width * map_height;
529 for (i = 1; i <= 8; ++i)
559 distance =
static_cast<path_data *
>(malloc(size *
sizeof(*distance)));
560 if (distance == NULL) {
567 memset(distance, 255,
sizeof(*distance) * size);
570 current = &distance[map_height * target->
x + target->
y];
573 current->
x = target->
x;
574 current->
y = target->
y;
588 for (i = 1; i < 8; ++i) {
594 for (i = 0; i < 8; ++i) {
595 uint16_t new_distance;
600 dir =
absdir(default_dir+4+dirs[i]);
604 if (x == source->
x && y == source->
y) {
616 const path_data *newloc = &distance[map_height * newx + newy];
639 assert(map_height * x + y >= 0);
640 assert(map_height * x + y < size);
643 explore = &distance[map_height * x +
y];
647 int16_t move_penalty = 0;
649 if (terrain_value > 0) {
671 const int base_move_cost = ((dir & 1) == 0 ? 3 : 2);
677 + (move_penalty != 0 && terrain_value != 0 ? base_move_cost + base_move_cost * move_penalty * terrain_value / 2 : base_move_cost);
680 if (explore->
distance <= new_distance)
714 }
while (current != NULL);
869 object *owner, *enemy, *part;
1010 LOG(
llevMonster,
"monster %s (%d, %d on %s) can't reach enemy %s (%d, %d on %s)\n",
1064 for (diff = 1; diff <= maxdiff; diff++) {
1097 if (nearest_player && nearest_player != enemy && !
monster_can_hit(part, enemy, &rv)) {
1099 enemy = nearest_player;
1156 for (more = ob2->
more; more != NULL; more = more->
more) {
1188 assert(spell_ob != NULL);
1212 #define MAX_KNOWN_SPELLS 20 1248 return altern[
RANDOM()%i];
1284 if (owner != NULL) {
1301 if (spell_item == NULL) {
1307 if (!spell_item->
inv) {
1308 LOG(
llevError,
"spellbook %s does not contain a spell?\n", spell_item->
name);
1311 spell_item = spell_item->
inv;
1337 return cast_spell(part, part, dir, spell_item, NULL);
1371 if (owner != NULL) {
1448 if (owner != NULL) {
1473 LOG(
llevDebug,
"Error: Monster %s (%d) has FLAG_READY_SKILL without skill.\n", head->
name, head->
count);
1497 int at_least_one = 0;
1505 if (owner != NULL) {
1516 if (wand->type ==
WAND) {
1519 if (wand->stats.food <= 0)
1529 if (wand->type ==
ROD && wand->inv) {
1532 if (wand->stats.hp <
MAX(wand->inv->stats.sp, wand->inv->stats.grace))
1550 LOG(
llevError,
"Error: Monster %s (%d) HAS_READY_RANG() without wand/horn/rod.\n", head->
name, head->
count);
1596 while (x != pl->
x || y != pl->
y || map != pl->
map) {
1601 LOG(
llevError,
"monster_use_bow: no map but still path exists??\n");
1606 if (owner && owner->
x == x && owner->
y == y && owner->
map == map)
1617 return fire_bow(head, NULL, dir, 0, part->
x, part->
y);
1633 val += item->
magic*3;
1659 if (other_weap == NULL)
1685 val += item->
magic*3;
1702 object *other_armour;
1706 if (other_armour == NULL)
1740 && mon->
arch != NULL
1794 }
else if (item->
type ==
BOW) {
1856 for (part = monster; part != NULL; part = part->
more)
1867 if (tmp->weight > 0) {
1868 int32_t weight_limit;
1872 nrof = (weight_limit-monster->
weight-monster->
carrying)/tmp->weight;
1876 nrof =
MAX(1, tmp->nrof);
1917 else switch (item->
type) {
1967 if (((!(monster->
pick_up&32)) && flag) || ((monster->
pick_up&32) && (!flag)))
1980 switch (tmp->type) {
2002 if (!monster->
head) {
2016 int help_radius = 3;
2020 int override_help_radius;
2022 override_help_radius = strtol(value, NULL, 10);
2023 if (override_help_radius >= 0 && override_help_radius < 30)
2024 help_radius = override_help_radius;
2026 LOG(
llevDebug,
"monster_npc_call_help: invalid help_radius %d\n", override_help_radius);
2029 for (
int x = -help_radius;
x <= help_radius;
x++)
2030 for (
int y = -help_radius;
y <= help_radius;
y++) {
2032 int16_t sx = op->
x+
x;
2033 int16_t sy = op->
y+
y;
2163 static const int circle [12] = { 3, 3, 4, 5, 5, 6, 7, 7, 8, 1, 1, 2 };
2176 static const int circle[20] = { 3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 7, 7, 7, 8, 8, 1, 1, 1, 2, 2 };
2252 for (i = 0; i < 5; i++) {
2270 int cum_client_type = 0;
2279 if (ob->
map->
shopmin && price < ob->map->shopmin) {
2282 snprintf(buf2,
sizeof(buf2),
"Liquidating %s (price %lu < shopmin %lu)", buf, price, ob->
map->
shopmin);
2290 cum_client_type += tmp->client_type;
2300 sscanf(curr,
"%f", &last);
2302 const float alpha = 1.0/50;
2303 newavg = alpha*nbelow + (1-alpha)*last;
2304 snprintf(buf,
sizeof(buf),
"%f", newavg);
2309 snprintf(buf2,
sizeof(buf2),
"%d items below, shop avg %.1f", nbelow, newavg);
2314 const int want_pile = on_shop_tile ?
MAX(1, newavg) : 0;
2315 if (nbelow > want_pile) {
2325 if (nbelow - npicked <= want_pile)
2331 snprintf(buf2,
sizeof(buf2),
"picked up %d items", npicked);
2334 }
else if (on_shop_tile) {
2345 dtype = abs(tmp->client_type - cum_client_type/nbelow);
2346 dtype =
MAX(1, dtype);
2350 if (nbelow + ndropped >= want_pile)
2356 snprintf(buf2,
sizeof(buf2),
"dropped %d items", ndropped);
2389 if (tmp->type ==
DOOR) {
2513 if (orig_map != op->
map) {
2514 LOG(
llevDebug,
"Warning: Forced to swap out very recent map\n");
2526 snprintf(own,
sizeof(own),
"You say: %s", txt);
2527 snprintf(others,
sizeof(others),
"%s says: %s", op->
name, txt);
2585 value[0] =
'3' + rand() % 6;
2594 reply = reply->
next;
2634 if (info->
who == npc)
2663 LOG(
llevDebug,
"%s chooses to throw: %s (%d)\n", op->
name, what, tmp->count);
2694 if (!op || !enemy || !op->
map || !enemy->
map)
2733 if (sk_hide != NULL)
2734 bonus -= sk_hide->
level;
2736 LOG(
llevError,
"monster_can_detect_enemy() got hidden player w/o hiding skill!\n");
2741 bonus -= enemy->
level;
2744 hide_discovery += bonus*5;
2750 radius = radius/2, hide_discovery = hide_discovery/3;
2765 if (radius < MIN_MON_RADIUS && op->map->darkness < 5 && rv->
distance <= 1)
2787 if (enemy->
hide && rv->
distance <= 1 &&
RANDOM()%100 <= (
unsigned int)hide_discovery) {
2792 "You are discovered by %s!",
2803 if (
RANDOM()%50 <= (
unsigned int)hide_discovery) {
2809 "You see %s noticing your position.",
2868 object *looker =
HEAD(op);
2890 "Your light reveals your hiding spot!");
2893 }
else if (enemy->
hide)
int on_same_map(const object *op1, const object *op2)
Checks whether 2 objects are on the same map or not.
static int monster_hitrun_att(int dir, object *ob)
Return the next direction the monster should move for a specific movement type.
#define NDI_DELAYED
If set, then message is sent only after the player's tick completes.
#define NUM_BODY_LOCATIONS
Number of body locations.
#define FLAG_SEE_IN_DARK
if set ob not effected by darkness
int apply_manual(object *op, object *tmp, int aflag)
Main apply handler.
uint16_t attack_movement
What kind of attack movement.
int npc_msg_count
How many NPCs reacted to the text being said.
#define FLAG_UNPAID
Object hasn't been paid for yet.
#define MOVE_WALK
Object walks.
char * stringbuffer_finish(StringBuffer *sb)
Deallocate the string buffer instance and return the string.
static void monster_circ1_move(object *ob)
Move the monster in a specified movement pattern.
Spell-related defines: spellpath, subtypes, ...
#define RANDO
The monster will go in a random direction until it is stopped by an obstacle, then it chooses another...
This is used by get_rangevector to determine where the other creature is.
struct archetype * arch
Pointer to archetype.
#define FLAG_SLEEP
NPC is sleeping.
uint32_t hidden
If True, player (DM) is hidden from view.
#define FOR_OB_AND_ABOVE_PREPARE(op_)
Constructs a loop iterating over an object and all objects above it in the same pile.
object * object_get_owner(object *op)
Returns the object which this object marks as being the owner.
#define FLAG_USE_SCROLL
(Monster) can read scroll
object * get_nearest_criminal(object *mon)
object * object_split(object *orig_ob, uint32_t nr, char *err, size_t size)
object_split(ob,nr) splits up ob into two parts.
void animate_object(object *op, int dir)
Updates the face-variable of an object.
static int monster_wait_att(int dir, object *ob, object *enemy, object *part, rv_vector *rv)
Return the next direction the monster should move for a specific movement type.
void LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
static int monster_should_cast_spell(object *spell_ob)
Checks if a monster should cast a spell.
int makes_invisible_to(object *pl, object *mon)
This checks to see if 'pl' is invisible to 'mon'.
int8_t direction
Means the object is moving that way.
#define FABS(x)
Decstations have trouble with fabs()...
object * part
Part we found.
void pets_follow_owner(object *ob, object *owner)
A pet is trying to follow its owner.
#define FLAG_USE_ARMOUR
(Monster) can wear armour/shield/helmet
#define FLAG_STAND_STILL
NPC will not (ever) move.
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...) PRINTF_ARGS(6
void drain_wand_charge(object *wand)
Drains a charge from a wand.
#define MSG_TYPE_DIALOG_MAGIC_EAR
Magic ear.
float move_slow_penalty
How much this slows down the object.
#define FLAG_FRIENDLY
Will help players.
static void monster_rand_move(object *ob)
Move the monster in a specified movement pattern.
#define FLAG_IS_FLOOR
Can't see what's underneath this object.
uint32_t peaceful
If set, won't attack friendly creatures.
void fix_object(object *op)
Updates all abilities given by applied objects in the inventory of the given object.
#define PACEV2
The monster will pace as above but the length of the pace area is longer and the monster stops before...
sstring message
If not NULL, what the player will be displayed as said.
void object_remove(object *op)
This function removes the object op from the linked list of objects which it is currently tied to...
void pets_move(object *ob)
Handles a pet's movement.
#define LOOK_OBJ(ob)
This returns TRUE if the object is something that should be displayed in the look window...
bool coords_in_shop(mapstruct *map, int x, int y)
Check if the given map coordinates are in a shop.
int monster_can_detect_enemy(object *op, object *enemy, rv_vector *rv)
Determine if we can 'detect' the enemy.
#define FLAG_READY_RANGE
(Monster) has a range attack readied...
int path_measure_func(const void *ob)
Function to retrieve the measurement the minheap will organize by.
object * more
Pointer to the rest of a large body of objects.
sstring replies[MAX_REPLIES]
Description for replies_words.
sstring add_string(const char *str)
Share a string.
#define FLAG_BLIND
If set, object cannot see (visually)
#define MSG_TYPE_DIALOG
NPCs, magic mouths, and altars.
uint8_t will_apply
See crossfire.doc and What monsters apply.
static int monster_wait_att2(int dir, rv_vector *rv)
Return the next direction the monster should move for a specific movement type.
int16_t SP_level_spellpoint_cost(object *caster, object *spell, int flags)
Scales the spellpoint cost of a spell by it's increased effectiveness.
void remove_friendly_object(object *op)
Removes the specified object from the linked list of friendly objects.
static int monster_use_range(object *head, object *part, object *pl, int dir)
Monster will use a ranged attack (ROD, WAND, ...).
static int monster_do_talk_npc(object *npc, talk_info *info)
Checks the messages of a NPC for a matching text.
#define FLAG_CONFUSED
Will also be unable to cast spells.
#define FLAG_STEALTH
Will wake monsters with less range.
#define FLAG_RANDOM_MOVE
NPC will move randomly.
void monster_communicate(object *op, const char *txt)
This function looks for an object or creature that is listening to said text.
sstring replies_words[MAX_REPLIES]
Available reply words.
int map_light_on(mapstruct *m, int x, int y)
Return the light level at position (X, Y) on map M.
const char * get_reply_text_own(reply_type rt)
Return the verb for the player's dialog type.
int16_t y
Position in the map for this object.
object * object_find_by_type_applied(const object *who, int type)
Find applied object in inventory.
int8_t magic
Any magical bonuses to this item.
#define FLAG_USE_WEAPON
(Monster) can wield weapons
char * message
What the player will actually say for this reply.
uint32_t get_weight_limit(int stat)
MoveType move_block
What movement types this blocks.
StringBuffer * stringbuffer_new(void)
Create a new string buffer.
#define OUT_OF_REAL_MAP(M, X, Y)
Checks if a square is out of the map.
uint16_t height
Width and height of map.
static object * monster_find_enemy(object *npc, rv_vector *rv)
Tries to find an enmy for npc.
int apply_can_apply_object(const object *who, const object *op)
Checks to see if 'who' can apply object 'op'.
object * attacked_by
This object start to attack us! only player & monster.
int monster_stand_in_light(object *op)
Cache monster_stand_in_light_internal().
#define FLAG_NO_ATTACK
monster don't attack
void monster_do_say(const mapstruct *map, const char *message)
Output a NPC message on a map.
object * chosen_skill
The skill chosen to use.
int monster_compute_path(object *source, object *target, int default_dir)
Computes a path from source to target.
#define MSG_TYPE_DIALOG_NPC
A message from the npc.
#define CIRCLE1
If the upper four bits of move_type / attack_movement are set to this number, the monster will move i...
static void monster_pace2_movev(object *ob)
Move the monster in a specified movement pattern.
int player_can_view(object *pl, object *op)
Check the player los field for viewability of the object op.
int path_to_player(object *mon, object *pl, unsigned mindiff)
Returns the direction to the player, if valid.
static int monster_move_no_enemy(object *op)
Makes a monster without any enemy move.
Global type definitions and header inclusions.
#define PETMOVE
If the upper four bits of attack_movement are set to this number, the monster follows a player until ...
#define AP_APPLY
Item is to be applied.
struct player * contr
Pointer to the player which control this object.
static void monster_apply_below(object *monster)
If a monster who's eager to apply things encounters something apply-able, then make him apply it...
#define FLAG_USE_RING
(Monster) can use rings, boots, gauntlets, etc
static int monster_get_armour_quality(const object *item)
Returns the "quality" value of an armour of a monster.
static int monster_talk_to_npc(object *npc, talk_info *info)
Give an object the chance to handle something being said.
#define HITRUN
Run to then hit player then run away cyclicly.
void draw_ext_info(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *message)
Sends message to player(s).
sstring stringbuffer_finish_shared(StringBuffer *sb)
Deallocate the string buffer instance and return the string as a shared string.
void monster_check_doors(object *op, mapstruct *m, int x, int y)
Living creature attempts to open a door.
#define FLAG_REMOVED
Object is not in any map or invenory.
int32_t weight
Attributes of the object.
bool chance(int a, int b)
Return true with a probability of a/b.
int monster_can_see_enemy(object *op, object *enemy)
Assuming no walls/barriers, lets check to see if its possible to see an enemy.
One reply a NPC can expect.
uint8_t run_away
Monster runs away if it's hp goes below this percentage.
#define FLAG_SEE_INVISIBLE
Will see invisible player.
void free_string(sstring str)
This will reduce the refcount, and if it has reached 0, str will be freed.
#define FLAG_READY_SKILL
(Monster or Player) has a skill readied
int16_t level
Level of creature or object.
#define RUNATT
Run but attack if player catches up to object.
void object_free(object *ob, int flags)
Frees everything allocated by an object, removes it from the list of used objects, and puts it on the list of free objects.
reply_type
Various kind of messages a player or NPC can say.
static int monster_stand_in_light_internal(object *op)
Determine if op stands in a lighted square.
object * object_find_by_type_subtype(const object *who, int type, int subtype)
Find object in inventory.
uint8_t hide
The object is hidden, not invisible.
int replies_count
How many items in replies_words and replies.
#define FLAG_ALIVE
Object can fight (or be fought)
void do_hidden_move(object *op)
For hidden creatures - a chance of becoming 'unhidden' every time they move - as we subtract off 'inv...
#define AP_IGNORE_CURSE
Apply/unapply regardless of cursed/damned status.
int16_t resist[NROFATTACKS]
Resistance adjustments for attacks.
object * identify(object *op)
Identifies an item.
#define MAX_REPLIES
How many NPC replies maximum to tell the player.
#define FOR_OB_AND_ABOVE_FINISH()
Finishes FOR_OB_AND_ABOVE_PREPARE().
void monster_npc_say(object *npc, const char *cp)
Simple function to have some NPC say something.
#define FLAG_READY_SCROLL
monster has scroll in inv and can use it
int8_t range
Range of the spell.
float speed
Frequency of object 'moves' relative to server tick rate.
int32_t carrying
How much weight this object contains.
void stringbuffer_append_printf(StringBuffer *sb, const char *format,...)
Append a formatted string to a string buffer instance.
#define FLAG_CAN_USE_SKILL
The monster can use skills.
#define MOVE_FLY_LOW
Low flying object.
Structure used to build up dialog information when a player says something.
char path[HUGE_BUF]
Filename of the map.
void drain_rod_charge(object *rod)
Drain charges from a rod.
const char * text
What the player actually said.
int32_t last_sp
As last_heal, but for spell points.
#define FLAG_UNAGGRESSIVE
Monster doesn't attack players.
#define QUERY_FLAG(xyz, p)
#define FLAG_USE_SHIELD
Can this creature use a shield?
bool identifies
Identify the speaker when this message is matched.
#define FLAG_USE_RANGE
(Monster) can apply and use range items
static void monster_check_apply(object *mon, object *item)
Called after an item is inserted in a monster.
int get_dialog_message(object *op, const char *text, struct_dialog_message **message, struct_dialog_reply **reply)
Tries to find a message matching the said text.
object * get_nearest_player(object *mon)
Finds the nearest visible player or player-friendly for some object.
uint8_t pick_up
See crossfire.doc.
static void monster_circ2_move(object *ob)
Move the monster in a specified movement pattern.
int pets_should_arena_attack(object *pet, object *owner, object *target)
Determines if checks so pets don't attack players or other pets should be overruled by the arena petm...
void query_name(const object *op, char *buf, size_t size)
Describes an item.
void object_free_drop_inventory(object *ob)
Frees everything allocated by an object, removes it from the list of used objects, and puts it on the list of free objects.
#define WILL_APPLY_TREASURE
Open chests.
short freearr_x[SIZEOFFREE]
X offset when searching around a spot.
int monster_move(object *op)
Main monster processing routine.
tag_t attacked_by_count
The tag of attacker, so we can be sure.
#define FOR_INV_FINISH()
Finishes FOR_INV_PREPARE().
object * head
Points to the main object of a large body.
int has_carried_lights(const object *op)
Checks if op has a light source.
sstring race
Human, goblin, dragon, etc.
const Animations * animation
Animation of this item, NULL if not animated.
#define PACEH
The monster will pace back and forth until attacked.
#define MAX_KNOWN_SPELLS
Maximum number of spells to consider when choosing a spell for a monster.
void get_search_arr(int *search_arr)
New function to make monster searching more efficient, and effective! This basically returns a random...
int ob_blocked(const object *ob, mapstruct *m, int16_t x, int16_t y)
Returns true if the given object can't fit in the given spot.
char * reply
Reply expected from the player.
#define MSG_TYPE_COMMUNICATION_SAY
Player says something.
void ext_info_map_except(int color, const mapstruct *map, const object *op, uint8_t type, uint8_t subtype, const char *str1)
Writes to everyone on the map except *op.
int is_true_undead(object *op)
Is the object a true undead?
static void monster_pace2_moveh(object *ob)
Move the monster in a specified movement pattern.
#define MSG_TYPE_COMMUNICATION
Communication between players.
sstring object_get_value(const object *op, const char *const key)
Get an extra value by key.
#define FLAG_PARALYZED
Monster or player is paralyzed.
int8_t glow_radius
indicates the glow radius of the object
static void monster_pace_movev(object *ob)
Move the monster in a specified movement pattern.
uint64_t shopmin
Minimum price a shop will trade for.
#define AP_NOPRINT
Don't print messages - caller will do that may be some that still print.
#define P_OUT_OF_MAP
This space is outside the map.
#define GET_MAP_MOVE_BLOCK(M, X, Y)
Gets the blocking state of a square.
int do_skill(object *op, object *part, object *skill, int dir, const char *string)
Main skills use function-similar in scope to cast_spell().
object * monster_find_throw_ob(object *op)
Find an item for the monster to throw.
#define FLAG_SCARED
Monster is scared (mb player in future)
#define MSG_TYPE_SKILL_FAILURE
Failure in using skill.
#define FLAG_ONLY_ATTACK
NPC will evaporate if there is no enemy.
#define FLAG_XRAYS
X-ray vision.
static void monster_check_pickup(object *monster)
Checks for items that monster can pick up.
int16_t dam
How much damage this object does when hitting.
#define AT_PHYSICAL
Basic attack (1)
uint32_t pticks
Number of ticks since time reset.
#define CAN_APPLY_NOT_MASK
#define HEAD(op)
Returns the head part of an object.
int get_randomized_dir(int dir)
Returns a random direction (1..8) similar to a given direction.
void fatal(enum fatal_error err)
fatal() is meant to be called whenever a fatal signal is intercepted.
#define FLAG_WIZ
Object has special privilegies.
living stats
Str, Con, Dex, etc.
#define MAX_BUF
Used for all kinds of things.
In order to adequately path for A* search, we will need a minheap to efficiently handle pathing from ...
int fire_bow(object *op, object *arrow, int dir, int wc_mod, int16_t sx, int16_t sy)
Creature (monster or player) fires a bow.
int16_t invisible
How much longer the object will be invis.
#define FLAG_CAST_SPELL
(Monster) can learn and cast spells
void minheap_init_static(MinHeap *heap, void **arr, int amt, int(*measure_func)(const void *))
Initialize the minheap using statically allocated components.
object * monster_check_enemy(object *npc, rv_vector *rv)
Checks npc->enemy and returns that enemy if still valid, NULL otherwise.
#define FLAG_BERSERK
monster will attack closest living object
void drop(object *op, object *tmp)
Drop an item, either on the floor or in a container.
uint64_t price_base(const object *obj)
Price an item based on its value or archetype value, type, identification/BUC status, and other heuristics.
void skill_attack(object *tmp, object *pl, int dir, const char *string, object *skill)
Core routine for use when we attack using a skills system.
#define WAITATT
Wait for player to approach then hit, move if hit.
mapstruct * get_map_from_coord(mapstruct *m, int16_t *x, int16_t *y)
This is basically the same as out_of_map above(), but instead we return NULL if no map is valid (coor...
static StringBuffer * monster_format_say(const object *npc, const char *message)
Format an NPC message.
struct mapstruct * map
Pointer to the map in which this object is present.
#define FLAG_RUN_AWAY
Object runs away from nearest player \ but can still attack at a distance.
Skill-related defines, including subtypes.
static int monster_get_weapon_quality(const object *item)
Returns the "quality" value of a weapon of a monster.
#define ALLRUN
Always run, never attack good for sim.
int object_can_pick(const object *who, const object *item)
Finds out if an object can be picked up.
#define FLAG_IS_THROWN
Object is designed to be thrown.
short freearr_y[SIZEOFFREE]
Y offset when searching around a spot.
#define FOR_MAP_FINISH()
Finishes FOR_MAP_PREPARE().
MoveType move_slow
Movement types this slows down.
int8_t facing
Object is oriented/facing that way.
static int monster_can_hit(object *ob1, object *ob2, rv_vector *rv)
Checks if monster can hit in hand-to-hand combat.
static int monster_can_pick(object *monster, object *item)
Check if the monster can and is interested in picking up an item.
static int monster_use_skill(object *head, object *part, object *pl, int dir)
A monster attempts using a skill.
static int is_enemy(object *who, object *owner)
Determine if an object can be considered an enemy.
static int monster_use_bow(object *head, object *part, object *pl, int dir)
Tries to make a (part of a) monster fire a bow.
#define RUSH
Rush toward player blindly, similiar to dumb monster.
const char * key_shopkeeper
int8_t body_info[NUM_BODY_LOCATIONS]
Body info as loaded from the file.
#define WAIT2
Monster does not try to move towards player if far.
#define FLAG_GENERATOR
Will generate type ob->stats.food.
int dirdiff(int dir1, int dir2)
Computes a direction difference.
#define WILL_APPLY_HANDLE
Apply handles and triggers.
static event_registration m
#define FLAG_NEUTRAL
monster is from type neutral
static int monster_disthit_att(int dir, object *ob, object *enemy, object *part, rv_vector *rv)
Return the next direction the monster should move for a specific movement type.
#define MAX_NPC
How many NPCs maximum will reply to the player.
static int monster_check_wakeup(object *op, object *enemy, rv_vector *rv)
Sees if this monster should wake up.
Also see SKILL_TOOL (74) below.
MoveType move_type
Type of movement this object uses.
sstring name
The name of the object, obviously...
int8_t get_attr_value(const living *stats, int attr)
Gets the value of a stat.
object * spellitem
Spell ability monster is choosing to use.
Only for debugging purposes.
const char * key_shopkeeper_pilesize
int get_map_flags(mapstruct *oldmap, mapstruct **newmap, int16_t x, int16_t y, int16_t *nx, int16_t *ny)
This rolls up wall, blocks_magic, blocks_view, etc, all into one function that just returns a P_...
uint8_t darkness
Indicates level of darkness of map.
#define RANDO2
Constantly move in a different random direction.
One message a NPC can react to.
#define MIN_MON_RADIUS
Minimum monster detection radius.
unsigned int distance
Distance, in squares.
static int monster_check_good_weapon(object *who, object *item)
Checks if using weapon 'item' would be better for 'who'.
const char * key_shopkeeper_debug
void object_set_enemy(object *op, object *enemy)
Sets the enemy of an object.
void dialog_preparse(object *op)
static object * monster_choose_random_spell(object *monster)
Selects a spell to cast for a monster.
#define CLEAR_FLAG(xyz, p)
uint8_t type
PLAYER, BULLET, etc.
int direction
General direction to the targer.
int8_t ac
Armor Class, lower AC increases probability of not getting hit.
#define FLAG_APPLIED
Object is ready for use by living.
int move_object(object *op, int dir)
Try to move op in the direction "dir".
Structure to store data so we can use a minheap.
int can_see_monsterP(mapstruct *m, int x, int y, int dir)
Recursive routine to see if we can find a path to a certain point.
reply_type message_type
A reply_type value for message.
static void shopkeeper_move(object *ob)
Special move for shopkeepers.
int get_rangevector(object *op1, const object *op2, rv_vector *retval, int flags)
From map.c This is used by get_player to determine where the other creature is.
int object_set_value(object *op, const char *key, const char *value, int add_key)
Updates the key in op to value.
void monster_check_earthwalls(object *op, mapstruct *m, int x, int y)
Living creature attempts to hit an earthwall.
#define SP_SUMMON_MONSTER
object * inv
Pointer to the first object in the inventory.
struct struct_dialog_reply * replies
Replies this message has.
static int monster_cast_spell(object *head, object *part, object *pl, int dir)
Tries to make a (part of a) monster cast a spell.
void monster_npc_call_help(object *op)
A monster calls for help against its enemy.
uint32_t light_cached_time
Computing whether or not an item is in the light is very expensive, so cache it.
char * message
What the NPC will say.
static int monster_move_randomly(object *op)
Handles random object movement.
struct object * who
Player saying something.
void monster_do_living(object *op)
For a monster, regenerate hp and sp, potentially clear scared status.
#define MIN_ACTIVE_SPEED
Cut off point of when an object is put on the active list or not.
#define GET_MAP_OB(M, X, Y)
Gets the bottom object on a map.
#define DISTATT
Move toward a player if far, but maintain some space, attack from a distance - good for missile users...
int minheap_insert(MinHeap *heap, void *ob)
Inserts an element into the min-heap.
int16_t maxsp
Max spell points.
#define FLAG_MONSTER
Will attack players.
#define MSG_TYPE_SKILL
Messages related to skill use.
#define NDI_UNIQUE
Print immediately, don't buffer.
int32_t last_heal
Last healed.
uint32_t tmp_invis
Will invis go away when we attack?
#define FLAG_READY_BOW
not implemented yet
bool pick_up(object *op, object *alt)
Try to pick up an item.
sstring npc_msgs[MAX_NPC]
What the NPCs will say.
object * object_find_by_type_and_race(const object *who, int type, const char *race)
Find object in inventory by type and race.
void make_visible(object *op)
Makes an object visible again.
static void monster_pace_moveh(object *ob)
Move the monster in a specified movement pattern.
int absdir(int d)
Computes an absolute direction.
#define PACEH2
The monster will pace as above but the length of the pace area is longer and the monster stops before...
#define FOR_MAP_PREPARE(map_, mx_, my_, it_)
Constructs a loop iterating over all objects of a map tile.
static int monster_run_att(int dir, object *ob, object *enemy, object *part, rv_vector *rv)
Return the next direction the monster should move for a specific movement type.
static uint16_t estimate_distance(int16_t ax, int16_t ay, int16_t bx, int16_t by)
Heuristic function to make the pathing follow an A* search.
#define PACEV
The monster will pace back and forth until attacked.
#define WILL_APPLY_FOOD
Eat food (not drinks).
struct struct_dialog_reply * next
Next reply, NULL for last.
A buffer that will be expanded as content is added to it.
int16_t maxhp
Max hit points.
uint8_t subtype
Subtype of object.
#define FOR_BELOW_PREPARE(op_, it_)
Constructs a loop iterating over all objects below an object.
object * monster_find_nearest_enemy(object *npc, object *owner)
Returns the nearest enemy (monster or generator) which is visible to npc.
#define CIRCLE2
Same as CIRCLE1 but a larger circle is used.
object * find_skill_by_number(object *who, int skillno)
This returns the first skill pointer of the given subtype (the one that accumulates exp...
reply_type type
Type of message.
#define P_IS_ALIVE
Something alive is on this space.
object * object_insert_in_ob(object *op, object *where)
This function inserts the object op in the linked list inside the object environment.
object * pets_get_enemy(object *pet, rv_vector *rv)
Given that 'pet' is a friendly object, this function returns a monster the pet should attack...
int8_t wc
Weapon Class, lower WC increases probability of hitting.
tag_t count
Unique object number for this object.
#define FLAG_UNIQUE
Item is really unique (UNIQUE_ITEMS)
#define FLAG_NO_PICK
Object can't be picked up.
static int monster_check_good_armour(object *who, object *item)
Checks if using armor 'item' would be better for 'who'.
static int monster_use_scroll(object *head, object *part, object *pl, int dir)
Tries to make a (part of a) monster apply a spell.
void * minheap_remove(MinHeap *heap)
Pops the top of the minheap off.
int hit_player(object *op, int dam, object *hitter, uint32_t type, int full_hit)
Object is attacked by something.
int32_t move_status
What stage in attack mode.
void void ext_info_map(int color, const mapstruct *map, uint8_t type, uint8_t subtype, const char *str1)
Writes to everyone on the specified map.
void query_short_name(const object *op, char *buf, size_t size)
query_short_name(object) is similar to query_name(), but doesn't contain any information about object...
void monster_check_apply_all(object *monster)
Calls monster_check_apply() for all inventory objects.
static int monster_dist_att(int dir, object *enemy, object *part, rv_vector *rv)
Return the direction the monster should move or look to attack an enemy.
static const char * get_reply_text_other(reply_type rt)
Return the verb for the player's dialog type seen from others (third person).
object clone
An object from which to do object_copy()
#define FLAG_USE_BOW
(Monster) can apply and fire bows
bool object_value_set(const object *op, const char *const key)
Determine if an extra value is set.
#define FOR_BELOW_FINISH()
Finishes FOR_BELOW_PREPARE().
#define FOR_INV_PREPARE(op_, it_)
Constructs a loop iterating over the inventory of an object.
int cast_spell(object *op, object *caster, int dir, object *spell_ob, char *stringarg)
Main dispatch when someone casts a spell.
#define DISTHIT
Attack from a distance if hit as recommended by Frank.
char * name
Name of map as given by its creator.
int events_execute_object_say(object *npc, talk_info *talk)
Execute an EVENT_SAY on the specified object.
#define FLAG_FREED
Object is in the list of free objects.
#define MAX_EXPLORE
Maximum map size to consider when finding a path in monster_compute_path().
object * enemy
Monster/player to follow even if not closest.
#define LO4
bitmasks for upper and lower 4 bits from 8 bit fields