 |
Crossfire Server, Trunk
1.75.0
|
Go to the documentation of this file.
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;
938 if (op->
race != NULL && strcmp(op->
race,
"doppleganger") == 0) {
1021 LOG(
llevMonster,
"monster %s (%d, %d on %s) can't reach enemy %s (%d, %d on %s)\n",
1075 for (diff = 1; diff <= maxdiff; diff++) {
1108 if (nearest_player && nearest_player != enemy && !
monster_can_hit(part, enemy, &rv)) {
1110 enemy = nearest_player;
1167 for (more = ob2->
more; more != NULL; more = more->
more) {
1199 assert(spell_ob != NULL);
1223 #define MAX_KNOWN_SPELLS 20
1259 return altern[
RANDOM()%i];
1295 if (owner != NULL) {
1312 if (spell_item == NULL) {
1318 if (!spell_item->
inv) {
1319 LOG(
llevError,
"spellbook %s does not contain a spell?\n", spell_item->
name);
1322 spell_item = spell_item->
inv;
1348 return cast_spell(part, part, dir, spell_item, NULL);
1382 if (owner != NULL) {
1459 if (owner != NULL) {
1484 LOG(
llevDebug,
"Error: Monster %s (%d) has FLAG_READY_SKILL without skill.\n", head->
name, head->
count);
1508 int at_least_one = 0;
1516 if (owner != NULL) {
1527 if (wand->type ==
WAND) {
1530 if (wand->stats.food <= 0)
1540 if (wand->type ==
ROD && wand->inv) {
1543 if (wand->stats.hp <
MAX(wand->inv->stats.sp, wand->inv->stats.grace))
1561 LOG(
llevError,
"Error: Monster %s (%d) HAS_READY_RANG() without wand/horn/rod.\n", head->
name, head->
count);
1607 while (x != pl->
x || y != pl->
y || map != pl->
map) {
1612 LOG(
llevError,
"monster_use_bow: no map but still path exists??\n");
1617 if (owner && owner->
x == x && owner->
y == y && owner->
map == map)
1628 return fire_bow(head, NULL, dir, 0, part->
x, part->
y);
1644 val += item->
magic*3;
1670 if (other_weap == NULL)
1696 val += item->
magic*3;
1713 object *other_armour;
1717 if (other_armour == NULL)
1751 && mon->
arch != NULL
1805 }
else if (item->
type ==
BOW) {
1867 for (part =
monster; part != NULL; part = part->
more)
1878 if (tmp->weight > 0) {
1879 int32_t weight_limit;
1883 nrof = (weight_limit-
monster->weight-
monster->carrying)/tmp->weight;
1887 nrof =
MAX(1, tmp->nrof);
1928 else switch (item->
type) {
1978 if (((!(
monster->pick_up&32)) && flag) || ((
monster->pick_up&32) && (!flag)))
1991 switch (tmp->type) {
2027 int help_radius = 3;
2031 int override_help_radius;
2033 override_help_radius = strtol(value, NULL, 10);
2034 if (override_help_radius >= 0 && override_help_radius < 30)
2035 help_radius = override_help_radius;
2037 LOG(
llevDebug,
"monster_npc_call_help: invalid help_radius %d\n", override_help_radius);
2040 for (
int x = -help_radius; x <= help_radius; x++)
2041 for (
int y = -help_radius; y <= help_radius; y++) {
2043 int16_t sx = op->
x+x;
2044 int16_t sy = op->
y+y;
2174 static const int circle [12] = { 3, 3, 4, 5, 5, 6, 7, 7, 8, 1, 1, 2 };
2187 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 };
2263 for (i = 0; i < 5; i++) {
2281 int cum_client_type = 0;
2290 if (ob->
map->
shopmin && price < ob->map->shopmin) {
2293 snprintf(buf2,
sizeof(buf2),
"Liquidating %s (price %lu < shopmin %lu)",
buf, price, ob->
map->
shopmin);
2301 cum_client_type += tmp->client_type;
2311 sscanf(curr,
"%f", &last);
2313 const float alpha = 1.0/50;
2314 newavg = alpha*nbelow + (1-alpha)*last;
2315 snprintf(
buf,
sizeof(
buf),
"%f", newavg);
2320 snprintf(buf2,
sizeof(buf2),
"%d items below, shop avg %.1f", nbelow, newavg);
2325 const int want_pile = on_shop_tile ?
MAX(1, newavg) : 0;
2326 if (nbelow > want_pile) {
2336 if (nbelow - npicked <= want_pile)
2342 snprintf(buf2,
sizeof(buf2),
"picked up %d items", npicked);
2345 }
else if (on_shop_tile) {
2356 dtype = abs(tmp->client_type - cum_client_type/nbelow);
2357 dtype =
MAX(1, dtype);
2361 if (nbelow + ndropped >= want_pile)
2367 snprintf(buf2,
sizeof(buf2),
"dropped %d items", ndropped);
2400 if (tmp->type ==
DOOR) {
2524 if (orig_map != op->
map) {
2525 LOG(
llevDebug,
"Warning: Forced to swap out very recent map\n");
2537 snprintf(own,
sizeof(own),
"You say: %s", txt);
2538 snprintf(others,
sizeof(others),
"%s says: %s", op->
name, txt);
2596 value[0] =
'3' + rand() % 6;
2605 reply = reply->
next;
2645 if (info->
who == npc)
2674 LOG(
llevDebug,
"%s chooses to throw: %s (%d)\n", op->
name, what, tmp->count);
2705 if (!op || !enemy || !op->
map || !enemy->
map)
2744 if (sk_hide != NULL)
2747 LOG(
llevError,
"monster_can_detect_enemy() got hidden player w/o hiding skill!\n");
2755 hide_discovery +=
bonus*5;
2761 radius = radius/2, hide_discovery = hide_discovery/3;
2776 if (radius < MIN_MON_RADIUS && op->map->darkness < 5 && rv->
distance <= 1)
2798 if (enemy->
hide && rv->
distance <= 1 &&
RANDOM()%100 <= (
unsigned int)hide_discovery) {
2803 "You are discovered by %s!",
2814 if (
RANDOM()%50 <= (
unsigned int)hide_discovery) {
2820 "You see %s noticing your position.",
2879 object *looker =
HEAD(op);
2901 "Your light reveals your hiding spot!");
2904 }
else if (enemy->
hide)
bool object_value_set(const object *op, const char *const key)
Determine if an extra value is set.
#define FLAG_USE_BOW
(Monster) can apply and fire bows
#define GET_MAP_OB(M, X, Y)
Gets the bottom object on a map.
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 * object_get_owner(object *op)
Returns the object which this object marks as being the owner.
int path_to_player(object *mon, object *pl, unsigned mindiff)
Returns the direction to the player, if valid.
static void monster_pace2_movev(object *ob)
Move the monster in a specified movement pattern.
static int monster_check_wakeup(object *op, object *enemy, rv_vector *rv)
Sees if this monster should wake up.
#define FLAG_NEUTRAL
monster is from type neutral
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.
object * object_find_by_type_subtype(const object *who, int type, int subtype)
Find object in inventory.
int32_t move_status
What stage in attack mode.
sstring replies[MAX_REPLIES]
Description for replies_words.
#define FOR_MAP_FINISH()
Finishes FOR_MAP_PREPARE().
void remove_friendly_object(object *op)
Removes the specified object from the linked list of friendly objects.
int16_t maxhp
Max hit points.
object * object_find_by_type_applied(const object *who, int type)
Find applied object in inventory.
struct struct_dialog_reply * next
Next reply, NULL for last.
#define NUM_BODY_LOCATIONS
Number of body locations.
#define FLAG_STAND_STILL
NPC will not (ever) move.
#define FLAG_CONFUSED
Will also be unable to cast spells.
#define AP_APPLY
Item is to be applied.
#define WAITATT
Wait for player to approach then hit, move if hit.
@ llevError
Error, serious thing.
#define FABS(x)
Decstations have trouble with fabs()...
object * find_skill_by_number(object *who, int skillno)
This returns the first skill pointer of the given subtype (the one that accumulates exp,...
#define FLAG_USE_RING
(Monster) can use rings, boots, gauntlets, etc
void LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
#define ALLRUN
Always run, never attack good for sim.
sstring replies_words[MAX_REPLIES]
Available reply words.
int npc_msg_count
How many NPCs reacted to the text being said.
#define CAN_APPLY_NOT_MASK
void monster_check_apply_all(object *monster)
Calls monster_check_apply() for all inventory objects.
#define FLAG_GENERATOR
Will generate type ob->stats.food.
object * inv
Pointer to the first object in the inventory.
#define RUNATT
Run but attack if player catches up to object.
#define MSG_TYPE_SKILL
Messages related to skill use.
#define QUERY_FLAG(xyz, p)
uint64_t shopmin
Minimum price a shop will trade for.
static int monster_stand_in_light_internal(object *op)
Determine if op stands in a lighted square.
#define PACEV2
The monster will pace as above but the length of the pace area is longer and the monster stops before...
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.
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...
Structure to store data so we can use a minheap.
void make_visible(object *op)
Makes an object visible again.
void stringbuffer_append_printf(StringBuffer *sb, const char *format,...)
Append a formatted string to a string buffer instance.
#define WILL_APPLY_HANDLE
Apply handles and triggers.
bool pick_up(object *op, object *alt)
Try to pick up an item.
#define FLAG_SEE_IN_DARK
if set ob not effected by darkness
int map_light_on(mapstruct *m, int x, int y)
Return the light level at position (X, Y) on map M.
struct archetype * arch
Pointer to archetype.
int cast_spell(object *op, object *caster, int dir, object *spell_ob, char *stringarg)
Main dispatch when someone casts a spell.
StringBuffer * stringbuffer_new(void)
Create a new string buffer.
uint16_t attack_movement
What kind of attack movement.
int absdir(int d)
Computes an absolute direction.
#define FOR_BELOW_PREPARE(op_, it_)
Constructs a loop iterating over all objects below an object.
int8_t range
Range of the spell.
float speed
Frequency of object 'moves' relative to server tick rate.
void object_set_enemy(object *op, object *enemy)
Sets the enemy of an object.
#define FLAG_UNIQUE
Item is really unique (UNIQUE_ITEMS)
int16_t invisible
How much longer the object will be invis.
static int monster_check_good_weapon(object *who, object *item)
Checks if using weapon 'item' would be better for 'who'.
#define HITRUN
Run to then hit player then run away cyclicly.
uint32_t peaceful
If set, won't attack friendly creatures.
object * monster_check_enemy(object *npc, rv_vector *rv)
Checks npc->enemy and returns that enemy if still valid, NULL otherwise.
uint8_t pick_up
See crossfire.doc.
struct mapstruct * map
Pointer to the map in which this object is present.
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.
In order to adequately path for A* search, we will need a minheap to efficiently handle pathing from ...
void monster_check_doors(object *op, mapstruct *m, int x, int y)
Living creature attempts to open a door.
uint16_t height
Width and height of map.
#define FLAG_SEE_INVISIBLE
Will see invisible player.
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...) PRINTF_ARGS(6
static void monster_check_pickup(object *monster)
Checks for items that monster can pick up.
@ SKILL
Also see SKILL_TOOL (74) below.
int8_t direction
Means the object is moving that way.
static int monster_check_good_armour(object *who, object *item)
Checks if using armor 'item' would be better for 'who'.
tag_t count
Unique object number for this object.
#define FLAG_SCARED
Monster is scared (mb player in future)
void fix_object(object *op)
Updates all abilities given by applied objects in the inventory of the given object.
#define FLAG_ONLY_ATTACK
NPC will evaporate if there is no enemy.
#define FLAG_READY_SCROLL
monster has scroll in inv and can use it
#define RANDO
The monster will go in a random direction until it is stopped by an obstacle, then it chooses another...
static int monster_can_hit(object *ob1, object *ob2, rv_vector *rv)
Checks if monster can hit in hand-to-hand combat.
@ llevMonster
Many many details.
object * get_nearest_criminal(object *mon)
the faster the spell may be cast there are several other common only the caster may be affected by the spell The most common spell range is that of touch This denotes that the caster much touch the recipient of the spell in order to release the spell monster
uint32_t hidden
If True, player (DM) is hidden from view.
object * enemy
Monster/player to follow even if not closest.
object * part
Part we found.
uint8_t hide
The object is hidden, not invisible.
int apply_manual(object *op, object *tmp, int aflag)
Main apply handler.
#define FOR_OB_AND_ABOVE_FINISH()
Finishes FOR_OB_AND_ABOVE_PREPARE().
char path[HUGE_BUF]
Filename of the map.
#define P_IS_ALIVE
Something alive is on this space.
#define FLAG_APPLIED
Object is ready for use by living.
int16_t level
Level of creature or object.
#define FLAG_STEALTH
Will wake monsters with less range.
uint32_t pticks
Number of ticks since time reset.
static object * monster_find_enemy(object *npc, rv_vector *rv)
Tries to find an enmy for npc.
object * object_insert_in_ob(object *op, object *where)
This function inserts the object op in the linked list inside the object environment.
uint8_t will_apply
See crossfire.doc and What monsters apply.
#define PACEH
The monster will pace back and forth until attacked.
object * get_nearest_player(object *mon)
Finds the nearest visible player or player-friendly for some object.
int16_t resist[NROFATTACKS]
Resistance adjustments for attacks.
#define FLAG_NO_PICK
Object can't be picked up.
Plugin animator file specs[Config] name
static void monster_rand_move(object *ob)
Move the monster in a specified movement pattern.
sstring message
If not NULL, what the player will be displayed as said.
#define FLAG_IS_FLOOR
Can't see what's underneath this object.
#define FOR_BELOW_FINISH()
Finishes FOR_BELOW_PREPARE().
int replies_count
How many items in replies_words and replies.
#define FLAG_ALIVE
Object can fight (or be fought)
object * monster_find_nearest_enemy(object *npc, object *owner)
Returns the nearest enemy (monster or generator) which is visible to npc.
#define FOR_OB_AND_ABOVE_PREPARE(op_)
Constructs a loop iterating over an object and all objects above it in the same pile.
#define SP_SUMMON_MONSTER
#define LOOK_OBJ(ob)
This returns TRUE if the object is something that should be displayed in the look window.
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 y
Position in the map for this object.
object * object_find_by_type_and_race(const object *who, int type, const char *race)
Find object in inventory by type and race.
static event_registration m
char * stringbuffer_finish(StringBuffer *sb)
Deallocate the string buffer instance and return the string.
#define FLAG_NO_ATTACK
monster don't attack
void object_free_drop_inventory(object *ob)
Frees everything allocated by an object, removes it from the list of used objects,...
struct player * contr
Pointer to the player which control this object.
object * chosen_skill
The skill chosen to use.
const char * key_shopkeeper_pilesize
int32_t last_heal
Last healed.
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,...
uint8_t subtype
Subtype of object.
sstring add_refcount(sstring str)
This will increase the refcount of the string str.
short freearr_y[SIZEOFFREE]
Y offset when searching around a spot.
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 drop(object *op, object *tmp)
Drop an item, either on the floor or in a container.
char * message
What the player will actually say for this reply.
static int monster_get_armour_quality(const object *item)
Returns the "quality" value of an armour of a monster.
void query_name(const object *op, char *buf, size_t size)
Describes an item.
#define FLAG_USE_RANGE
(Monster) can apply and use range items
#define FLAG_RUN_AWAY
Object runs away from nearest player \ but can still attack at a distance.
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.
static int monster_get_weapon_quality(const object *item)
Returns the "quality" value of a weapon of a monster.
#define MOVE_WALK
Object walks.
sstring stringbuffer_finish_shared(StringBuffer *sb)
Deallocate the string buffer instance and return the string as a shared string.
object clone
An object from which to do object_copy()
uint8_t run_away
Monster runs away if it's hp goes below this percentage.
int monster_can_see_enemy(object *op, object *enemy)
Assuming no walls/barriers, lets check to see if its possible to see an enemy.
uint64_t price_base(const object *obj)
Price an item based on its value or archetype value, type, identification/BUC status,...
sstring add_string(const char *str)
This will add 'str' to the hash table.
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 HEAD(op)
Returns the head part of an object.
void dialog_preparse(object *op)
MoveType move_type
Type of movement this object uses.
#define NDI_DELAYED
If set, then message is sent only after the player's tick completes.
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 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.
#define FLAG_FREED
Object is in the list of free objects.
int path_measure_func(const void *ob)
Function to retrieve the measurement the minheap will organize by.
#define FLAG_BLIND
If set, object cannot see (visually)
const Face * face
Face with colors.
#define AP_IGNORE_CURSE
Apply/unapply regardless of cursed/damned status.
static void monster_circ2_move(object *ob)
Move the monster in a specified movement pattern.
int has_carried_lights(const object *op)
Checks if op has a light source.
#define MIN_MON_RADIUS
Minimum monster detection radius.
One reply a NPC can expect.
static void monster_pace2_moveh(object *ob)
Move the monster in a specified movement pattern.
#define MAX_NPC
How many NPCs maximum will reply to the player.
#define CIRCLE2
Same as CIRCLE1 but a larger circle is used.
uint32_t tmp_invis
Will invis go away when we attack?
uint8_t type
PLAYER, BULLET, etc.
TIPS on SURVIVING Crossfire is populated with a wealth of different monsters These monsters can have varying immunities and attack types In some of them can be quite a bit smarter than others It will be important for new players to learn the abilities of different monsters and learn just how much it will take to kill them This section discusses how monsters can interact with players Most monsters in the game are out to mindlessly kill and destroy the players These monsters will help boost a player s after he kills them When fighting a large amount of monsters in a single attempt to find a narrower hallway so that you are not being attacked from all sides Charging into a room full of Beholders for instance would not be open the door and fight them one at a time For there are several maps designed for them Find these areas and clear them out All throughout these a player can find signs and books which they can read by stepping onto them and hitting A to apply the book sign These messages will help the player to learn the system One more always keep an eye on your food If your food drops to your character will soon so BE CAREFUL ! NPCs Non Player Character are special monsters which have intelligence Players may be able to interact with these monsters to help solve puzzles and find items of interest To speak with a monster you suspect to be a simply move to an adjacent square to them and push the double ie Enter your message
static void monster_pace_moveh(object *ob)
Move the monster in a specified movement pattern.
int16_t dam
How much damage this object does when hitting.
int8_t magic
Any magical bonuses to this item.
const char * key_shopkeeper_debug
#define FLAG_PARALYZED
Monster or player is paralyzed.
#define FLAG_USE_SHIELD
Can this creature use a shield?
void object_free(object *ob, int flags)
Frees everything allocated by an object, removes it from the list of used objects,...
#define GET_MAP_MOVE_BLOCK(M, X, Y)
Gets the blocking state of a square.
#define FOR_INV_FINISH()
Finishes FOR_INV_PREPARE().
static int is_enemy(object *who, object *owner)
Determine if an object can be considered an enemy.
int apply_can_apply_object(const object *who, const object *op)
Checks to see if 'who' can apply object 'op'.
#define FLAG_UNAGGRESSIVE
Monster doesn't attack players.
static object * monster_choose_random_spell(object *monster)
Selects a spell to cast for a monster.
#define FLAG_USE_WEAPON
(Monster) can wield weapons
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...
#define FLAG_CAN_USE_SKILL
The monster can use skills.
@ rt_reply
Reply to something.
#define PACEV
The monster will pace back and forth until attacked.
static int monster_can_pick(object *monster, object *item)
Check if the monster can and is interested in picking up an item.
int16_t SP_level_spellpoint_cost(object *caster, object *spell, int flags)
Scales the spellpoint cost of a spell by it's increased effectiveness.
static StringBuffer * monster_format_say(const object *npc, const char *message)
Format an NPC message.
int monster_compute_path(object *source, object *target, int default_dir)
Computes a path from source to target.
sstring race
Human, goblin, dragon, etc.
int8_t facing
Object is oriented/facing that way.
const Animations * animation
Animation of this item, NULL if not animated.
object * monster_find_throw_ob(object *op)
Find an item for the monster to throw.
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.
#define LO4
bitmasks for upper and lower 4 bits from 8 bit fields
#define FLAG_MONSTER
Will attack players.
#define FLAG_RANDOM_MOVE
NPC will move randomly.
void fatal(enum fatal_error err)
fatal() is meant to be called whenever a fatal signal is intercepted.
static int monster_hitrun_att(int dir, object *ob)
Return the next direction the monster should move for a specific movement type.
void monster_npc_call_help(object *op)
A monster calls for help against its enemy.
#define P_OUT_OF_MAP
This space is outside the map.
#define MAX_BUF
Used for all kinds of things.
static int monster_use_range(object *head, object *part, object *pl, int dir)
Monster will use a ranged attack (ROD, WAND, ...).
#define MSG_TYPE_DIALOG
NPCs, magic mouths, and altars.
void * minheap_remove(MinHeap *heap)
Pops the top of the minheap off.
uint32_t get_weight_limit(int stat)
const char * text
What the player actually said.
void free_string(sstring str)
This will reduce the refcount, and if it has reached 0, str will be freed.
MoveType move_slow
Movement types this slows down.
int8_t wc
Weapon Class, lower WC increases probability of hitting.
void pets_move(object *ob)
Handles a pet's movement.
float move_slow_penalty
How much this slows down the object.
int move_object(object *op, int dir)
Try to move op in the direction "dir".
A buffer that will be expanded as content is added to it.
#define MOVE_FLY_LOW
Low flying object.
#define FOR_MAP_PREPARE(map_, mx_, my_, it_)
Constructs a loop iterating over all objects of a map tile.
#define OUT_OF_REAL_MAP(M, X, Y)
Checks if a square is out of the map.
void get_search_arr(int *search_arr)
New function to make monster searching more efficient, and effective! This basically returns a random...
#define MAX_KNOWN_SPELLS
Maximum number of spells to consider when choosing a spell for a monster.
#define FLAG_READY_SKILL
(Monster or Player) has a skill readied
#define FLAG_READY_BOW
not implemented yet
#define FLAG_REMOVED
Object is not in any map or invenory.
reply_type
Various kind of messages a player or NPC can say.
#define FLAG_WIZ
Object has special privilegies.
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.
char * reply
Reply expected from the player.
reply_type message_type
A reply_type value for message.
#define NDI_UNIQUE
Print immediately, don't buffer.
static void monster_circ1_move(object *ob)
Move the monster in a specified movement pattern.
int8_t glow_radius
indicates the glow radius of the object
#define FLAG_FRIENDLY
Will help players.
One message a NPC can react to.
sstring name
The name of the object, obviously...
#define MSG_TYPE_SKILL_FAILURE
Failure in using skill.
static int monster_move_no_enemy(object *op)
Makes a monster without any enemy move.
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 * spellitem
Spell ability monster is choosing to use.
#define MAX_REPLIES
How many NPC replies maximum to tell the player.
int object_can_pick(const object *who, const object *item)
Finds out if an object can be picked up.
int monster_can_detect_enemy(object *op, object *enemy, rv_vector *rv)
Determine if we can 'detect' the enemy.
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_.
void monster_do_say(const mapstruct *map, const char *message)
Output a NPC message on a map.
#define FLAG_USE_ARMOUR
(Monster) can wear armour/shield/helmet
#define FLAG_CAST_SPELL
(Monster) can learn and cast spells
int16_t maxsp
Max spell points.
int32_t last_sp
As last_heal, but for spell points.
const typedef char * sstring
static void shopkeeper_move(object *ob)
Special move for shopkeepers.
@ rt_question
Asking a question.
void animate_object(object *op, int dir)
Updates the face-variable of an object.
object * object_split(object *orig_ob, uint32_t nr, char *err, size_t size)
object_split(ob,nr) splits up ob into two parts.
static int monster_move_randomly(object *op)
Handles random object movement.
int monster_move(object *op)
Main monster processing routine.
static int monster_use_skill(object *head, object *part, object *pl, int dir)
A monster attempts using a skill.
char * name
Name of map as given by its creator.
uint32_t light_cached_time
Computing whether or not an item is in the light is very expensive, so cache it.
tag_t attacked_by_count
The tag of attacker, so we can be sure.
static int monster_use_bow(object *head, object *part, object *pl, int dir)
Tries to make a (part of a) monster fire a bow.
void pets_follow_owner(object *ob, object *owner)
A pet is trying to follow its owner.
This is used by get_rangevector to determine where the other creature is.
int hit_player(object *op, int dam, object *hitter, uint32_t type, int full_hit)
Object is attacked by something.
int get_randomized_dir(int dir)
Returns a random direction (1..8) similar to a given direction.
sstring object_get_value(const object *op, const char *const key)
Get an extra value by key.
void do_hidden_move(object *op)
For hidden creatures - a chance of becoming 'unhidden' every time they move - as we subtract off 'inv...
int on_same_map(const object *op1, const object *op2)
Checks whether 2 objects are on the same map or not.
#define CLEAR_FLAG(xyz, p)
#define AP_NOPRINT
Don't print messages - caller will do that may be some that still print.
Structure used to build up dialog information when a player says something.
int8_t ac
Armor Class, lower AC increases probability of not getting hit.
object * attacked_by
This object start to attack us! only player & monster.
#define MSG_TYPE_DIALOG_MAGIC_EAR
Magic ear.
void minheap_init_static(MinHeap *heap, void **arr, int amt, int(*measure_func)(const void *))
Initialize the minheap using statically allocated components.
#define MSG_TYPE_DIALOG_NPC
A message from the npc.
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.
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.
static void monster_pace_movev(object *ob)
Move the monster in a specified movement pattern.
sstring npc_msgs[MAX_NPC]
What the NPCs will say.
#define MIN_ACTIVE_SPEED
Cut off point of when an object is put on the active list or not.
int8_t body_info[NUM_BODY_LOCATIONS]
Body info as loaded from the file.
#define FLAG_BERSERK
monster will attack closest living object
int monster_stand_in_light(object *op)
Cache monster_stand_in_light_internal().
void object_remove(object *op)
This function removes the object op from the linked list of objects which it is currently tied to.
void monster_do_living(object *op)
For a monster, regenerate hp and sp, potentially clear scared status.
int player_can_view(object *pl, object *op)
Check the player los field for viewability of the object op.
#define FLAG_UNPAID
Object hasn't been paid for yet.
#define WAIT2
Monster does not try to move towards player if far.
void monster_npc_say(object *npc, const char *cp)
Simple function to have some NPC say something.
#define FLAG_READY_RANGE
(Monster) has a range attack readied...
const char * key_shopkeeper
static int monster_talk_to_npc(object *npc, talk_info *info)
Give an object the chance to handle something being said.
#define DISTHIT
Attack from a distance if hit as recommended by Frank.
#define FLAG_XRAYS
X-ray vision.
#define RUSH
Rush toward player blindly, similiar to dumb monster.
#define PETMOVE
If the upper four bits of attack_movement are set to this number, the monster follows a player until ...
bool chance(int a, int b)
Return true with a probability of a/b.
static int monster_use_scroll(object *head, object *part, object *pl, int dir)
Tries to make a (part of a) monster apply a spell.
living stats
Str, Con, Dex, etc.
int object_set_value(object *op, const char *key, const char *value, int add_key)
Updates the key in op to value.
object * more
Pointer to the rest of a large body of objects.
#define MSG_TYPE_COMMUNICATION
Communication between players.
int8_t get_attr_value(const living *stats, int attr)
Gets the value of a stat.
void drain_rod_charge(object *rod)
Drain charges from a rod.
#define DISTATT
Move toward a player if far, but maintain some space, attack from a distance - good for missile users...
#define WILL_APPLY_TREASURE
Open chests.
int minheap_insert(MinHeap *heap, void *ob)
Inserts an element into the min-heap.
short freearr_x[SIZEOFFREE]
X offset when searching around a spot.
Player Stats effect how well a character can survie and interact inside the crossfire world This section discusses the various what they and how they effect the player s actions Also in this section are the stat modifiers that specific classes professions bring Player and sps the current and maximum the Current and Maximum The Current Sp can go somewhat negative When Sp is negative not all spells can be and a more negative Sp makes spell casting less likey to succeed can affect Damage and how the characters as well as how often the character can attack this affects the prices when buying and selling items if this drops the player will start losing hit points wd Cleric or Dwarf sm Elf wd Fireborn ft Human ra Mage C Monk se Ninja hi Priest C Quetzalcoatl mw Swashbuckler si Thief st Viking ba Warrior or Wizard C Wraith C Class Prof Str Dex Con Wis Cha Int Pow Net Skills Enclosed are codes used for the skills above The ones in and fighting should all be pretty self explanatory For the other a brief description is for a more detailed look at the skills doc file Skill remove use magic items phys no fire cold Fireborns are supposed to be fire spirits They re closely in tune with magic and are powerful and learn magic easily Being fire they are immune to fire and and vulnerable to cold They are vulnerable to ghosthit and drain because being mostly non anything which strikes directly at the spirit hits them harder race attacktype restrictions immunities prot vuln Quetzalcoatl physical no armour fire cold Quetzalcoatl s are now born knowing the spell of burning but because of their negative wisdom bonus
#define MAX_EXPLORE
Maximum map size to consider when finding a path in monster_compute_path().
static int monster_cast_spell(object *head, object *part, object *pl, int dir)
Tries to make a (part of a) monster cast a spell.
int events_execute_object_say(object *npc, talk_info *talk)
Execute an EVENT_SAY on the specified object.
uint8_t darkness
Indicates level of darkness of map.
#define FLAG_USE_SCROLL
(Monster) can read scroll
#define CIRCLE1
If the upper four bits of move_type / attack_movement are set to this number, the monster will move i...
int direction
General direction to the targer.
int dirdiff(int dir1, int dir2)
Computes a direction difference.
int makes_invisible_to(object *pl, object *mon)
This checks to see if 'pl' is invisible to 'mon'.
#define PACEH2
The monster will pace as above but the length of the pace area is longer and the monster stops before...
#define FLAG_IS_THROWN
Object is designed to be thrown.
#define FLAG_SLEEP
NPC is sleeping.
unsigned int distance
Distance, in squares.
@ NUM_STATS
Number of statistics.
MoveType move_block
What movement types this blocks.
void monster_check_earthwalls(object *op, mapstruct *m, int x, int y)
Living creature attempts to hit an earthwall.
const char * get_reply_text_own(reply_type rt)
Return the verb for the player's dialog type.
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.
#define FOR_INV_PREPARE(op_, it_)
Constructs a loop iterating over the inventory of an object.
#define MSG_TYPE_COMMUNICATION_SAY
Player says something.
void drain_wand_charge(object *wand)
Drains a charge from a wand.
static int monster_should_cast_spell(object *spell_ob)
Checks if a monster should cast a spell.
reply_type type
Type of message.
void monster_communicate(object *op, const char *txt)
This function looks for an object or creature that is listening to said text.
#define WILL_APPLY_FOOD
Eat food (not drinks).
@ llevDebug
Only for debugging purposes.
#define RANDO2
Constantly move in a different random direction.
static int monster_do_talk_npc(object *npc, talk_info *info)
Checks the messages of a NPC for a matching text.
static void monster_check_apply(object *mon, object *item)
Called after an item is inserted in a monster.
int is_true_undead(object *op)
Is the object a true undead?
struct object * who
Player saying something.
bool coords_in_shop(mapstruct *map, int x, int y)
Check if the given map coordinates are in a shop.
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.
object * identify(object *op)
Identifies an item.
static const char * get_reply_text_other(reply_type rt)
Return the verb for the player's dialog type seen from others (third person).