Debian Codegraph @

include/object.h

raw symbols SCIP
1 /**
2 * @file
3 * Object structure, the core of Crossfire.
4 */
5
6 #include "dialog.h"
7
8 #ifndef OBJECT_H
9 #define OBJECT_H
10
11 /** Object tag, unique during the whole game. */
12 typedef uint32_t tag_t;
13 #define NUM_BODY_LOCATIONS 13 /**< Number of body locations. */
14 #define BODY_ARMS 1 /**< This should be the index of the arms. */
15
16 /**
17 * One body location.
18 * See common/item.c.
19 */
20 typedef struct body_locations_struct {
21 const char *save_name; /**< Name used to load/save it to disk */
22 const char *use_name; /**< Name used when describing an item we can use */
23 const char *nonuse_name; /**< Name to describe objects we can't use */
24 } body_locations_struct;
25
26 extern body_locations_struct body_locations[NUM_BODY_LOCATIONS];
27
28 extern const char *const move_name[];
29
30 /**
31 * Each object (this also means archetypes!) could have a few of these
32 * "dangling" from it; this could also end up containing 'parse errors'.
33 *
34 * key and value are shared-strings.
35 *
36 * Please use object_get_value(), object_set_value() from object.c rather than
37 * accessing the list directly.
38 * Exception is if you want to walk this list for some reason.
39 */
40 typedef struct _key_value {
41 const char *key; /**< Name of the key. */
42 const char *value; /**< Key's value. */
43 struct _key_value *next; /**< Next key in the list. */
44 } key_value;
45
46 /**
47 * @defgroup WILL_APPLY_xxx What monsters apply
48 * How monsters should handle some items they have or things on the ground.
49 * Those flags correspond to the object::will_apply field.
50 */
51 /*@{*/
52 #define WILL_APPLY_HANDLE 0x1 /**< Apply handles and triggers. */
53 #define WILL_APPLY_TREASURE 0x2 /**< Open chests. */
54 #define WILL_APPLY_EARTHWALL 0x4 /**< Destroy earthwalls. */
55 #define WILL_APPLY_DOOR 0x8 /**< Open non-locked doors. */
56 #define WILL_APPLY_FOOD 0x10 /**< Eat food (not drinks). */
57 /*@}*/
58
59 /**
60 * Checks if an object still exists.
61 * @param op
62 * object to check
63 * @param old_tag
64 * old tag of the object.
65 * @return
66 * true if the object was destroyed, 0 otherwise
67 */
68 #define object_was_destroyed(op, old_tag) \
69 (op->count != old_tag || QUERY_FLAG(op, FLAG_FREED))
70
71
72 /**
73 * Defines default size of the *spell_tags pointer.
74 * The OB_SPELL_TAG_HASH is a simple mechanism to get/set the
75 * spell tags based on a simple hash - it should change if the tag size
76 * also changes. Note that since count is used for this, this value
77 * is effectively random or at least fairly evenly distributed, at
78 * least in the low bits. And a size of 16 lets us do a very
79 * fast operation.
80 */
81 #define SPELL_TAG_SIZE 16
82 /**
83 * Get the hash on an object for a specified count.
84 * @param op what to check.
85 * @param count item to check the hash for.
86 */
87 #define OB_SPELL_TAG_HASH(op, count) (op->spell_tags[count&0xf])
88 /**
89 * Check whether a tag matches in the tags.
90 * @param op item to check against.
91 * @param count tag to check.
92 */
93 #define OB_SPELL_TAG_MATCH(op, count) (op->spell_tags[count&0xf] == count)
94
95 /**
96 * Only add new values to this list if somewhere in the program code, it is
97 * actually needed. Just because you add a new monster does not mean it has to
98 * have a type defined here. That only needs to happen if in some .c file, it
99 * needs to do certain special actions based on the monster type, that can not
100 * be handled by any of the numerous flags. Also, if you add new entries, try
101 * and fill up the holes in this list. Additionally, when you add a new entry,
102 * include it in the table in common/item.c
103 *
104 * type 0 is undefined and indicates non-valid type information.
105 */
106 enum object_type {
107 PLAYER = 1,
108 TRANSPORT = 2, /**< see doc/Developers/objects */
109 ROD = 3,
110 TREASURE = 4,
111 POTION = 5,
112 FOOD = 6,
113 POISON = 7,
114 BOOK = 8,
115 CLOCK = 9,
116 DRAGON_FOCUS = 10, /**< Used during character creation */
117 ARROW = 13,
118 BOW = 14,
119 WEAPON = 15,
120 ARMOUR = 16,
121 PEDESTAL = 17,
122 ALTAR = 18,
123 LOCKED_DOOR = 20,
124 SPECIAL_KEY = 21,
125 MAP = 22,
126 DOOR = 23,
127 KEY = 24,
128 TIMED_GATE = 26,
129 TRIGGER = 27,
130 GRIMREAPER = 28,
131 MAGIC_EAR = 29,
132 TRIGGER_BUTTON = 30,
133 TRIGGER_ALTAR = 31,
134 TRIGGER_PEDESTAL = 32,
135 SHIELD = 33,
136 HELMET = 34,
137 MONEY = 36,
138 CLASS = 37, /**< Object for applying character class modifications to someone */
139 AMULET = 39,
140 PLAYERMOVER = 40,
141 TELEPORTER = 41,
142 CREATOR = 42,
143 SKILL = 43, /**< Also see ::SKILL_TOOL (74) below */
144 EARTHWALL = 45,
145 GOLEM = 46,
146 THROWN_OBJ = 48,
147 BLINDNESS = 49,
148 GOD = 50,
149 DETECTOR = 51, /**< peterm: detector is an object
150 * which notices the presense of
151 * another object and is triggered
152 * like buttons. */
153 TRIGGER_MARKER = 52, /**< inserts an invisible, weightless
154 * force into a player with a
155 * specified string WHEN TRIGGERED. */
156 DEAD_OBJECT = 53,
157 DRINK = 54,
158 MARKER = 55, /**< inserts an invisible, weightless
159 * force into a player with a
160 * specified string. */
161 HOLY_ALTAR = 56,
162 PLAYER_CHANGER = 57,
163 BATTLEGROUND = 58, /**< battleground, by Andreas Vogl */
164 PEACEMAKER = 59, /**< Object owned by a player which can
165 * convert a monster into a peaceful
166 * being incapable of attack. */
167 GEM = 60,
168 FIREWALL = 62,
169 CHECK_INV = 64, /**< b.t. [email protected] */
170 MOOD_FLOOR = 65, /**< b.t. [email protected]
171 * values of last_sp set how to
172 * change:
173 * 0 = furious, all monsters become
174 * aggressive
175 * 1 = angry, all but friendly become
176 * aggressive
177 * 2 = calm, all aggressive monsters
178 * calm down
179 * 3 = sleep, all monsters fall asleep
180 * 4 = charm, monsters become pets */
181 EXIT = 66,
182 ENCOUNTER = 67,
183 SHOP_FLOOR = 68,
184 SHOP_MAT = 69,
185 RING = 70,
186 FLOOR = 71, /**< Floor tile -> native layer 0 */
187 FLESH = 72, /**< animal 'body parts' -b.t. */
188 INORGANIC = 73, /**< metals, minerals, dragon scales */
189 SKILL_TOOL = 74, /**< Allows the use of a skill */
190 LIGHTER = 75,
191 WALL = 77, /**< Wall. Put it always in layer 1 if
192 * not set is_floor */
193 MISC_OBJECT = 79, /**< misc. objects are for objects
194 * without a function in the engine.
195 * Like statues, clocks, chairs...
196 * If perhaps we create a function
197 * where we can sit on chairs, we
198 * create a new type and remove all
199 * chairs from here. */
200 MONSTER = 80, /**< A real, living creature */
201 LAMP = 82, /**< Lamp */
202 DUPLICATOR = 83, /**< Duplicator/multiplier object */
203 SPELLBOOK = 85,
204 CLOAK = 87,
205 SPINNER = 90,
206 GATE = 91,
207 BUTTON = 92,
208 CF_HANDLE = 93,
209 HOLE = 94, /* When open, objects fall through */
210 TRAPDOOR = 95,
211 SIGN = 98,
212 BOOTS = 99,
213 GLOVES = 100,
214 SPELL = 101,
215 SPELL_EFFECT = 102,
216 CONVERTER = 103,
217 BRACERS = 104,
218 POISONING = 105,
219 SAVEBED = 106,
220 WAND = 109,
221 SCROLL = 111,
222 DIRECTOR = 112,
223 GIRDLE = 113,
224 FORCE = 114,
225 POTION_RESIST_EFFECT = 115, /**< A force, holding the effect of a
226 * resistance potion */
227 EVENT_CONNECTOR = 116, /**< Lauwenmark: an invisible object
228 * holding a plugin event hook */
229 CLOSE_CON = 121, /**< Eneq((at)csd.uu.se): Id for
230 * close_container archetype. */
231 CONTAINER = 122,
232 ARMOUR_IMPROVER = 123,
233 WEAPON_IMPROVER = 124,
234 SKILLSCROLL = 130, /**< can add a skill to player's
235 * inventory -bt.*/
236 DEEP_SWAMP = 138,
237 IDENTIFY_ALTAR = 139,
238 SHOP_INVENTORY = 150, /**< Mark Wedel ([email protected]) Shop
239 * inventories */
240 RUNE = 154,
241 TRAP = 155,
242 POWER_CRYSTAL = 156,
243 CORPSE = 157,
244 DISEASE = 158,
245 SYMPTOM = 159,
246 BUILDER = 160, /**< Generic item builder, see subtypes
247 * below */
248 MATERIAL = 161, /**< Material for building */
249 MIMIC = 162,
250 OBJECT_TYPE_MAX = 163, /**< Update if you add new types */
251 };
252
253 /**
254 * Main Crossfire structure, one ingame object.
255 *
256 * Note that the ordering of this structure is sort of relevent -
257 * object_copy() copies everything over beyond 'name' using memcpy.
258 * Thus, values that need to be copied need to be located beyond that
259 * point.
260 *
261 * However, if you're keeping a pointer of some sort, you probably
262 * don't just want it copied, so you'll need to add to common/object.c,
263 * e.g. copy-object
264 *
265 * I've tried to clean up this structure a bit (in terms of formatting)
266 * by making it more consistent. I've also tried to locate some of the fields
267 * more logically together (put the item related ones together, the monster
268 * related ones, etc.
269 * This structure is best viewed with about a 100 width screen.
270 * MSW 2002-07-05
271 *
272 * See the @ref page_object "documentation page" for more details.
273 */
274 typedef struct obj {
275 /* These variables are not changed by object_copy() */
276 struct pl *contr; /**< Pointer to the player which control this object */
277 struct obj *next; /**< Pointer to the next object in the free/used list */
278 struct obj *prev; /**< Pointer to the previous object in the free/used list*/
279 struct obj *active_next; /**< Next object in the 'active' list
280 * This is used in process_events
281 * so that the entire object list does not
282 * need to be gone through.*/
283 struct obj *active_prev; /**< Previous object in the 'active list
284 * This is used in process_events
285 * so that the entire object list does not
286 * need to be gone through. */
287 struct obj *below; /**< Pointer to the object stacked below this one */
288 struct obj *above; /**< Pointer to the object stacked above this one */
289 /* Note: stacked in the *same *environment*/
290 struct obj *inv; /**< Pointer to the first object in the inventory */
291 struct obj *container; /**< Current container being used. I think this
292 * is only used by the player right now. */
293 struct obj *env; /**< Pointer to the object which is the environment.
294 * This is typically the container that the object is in. */
295 struct obj *more; /**< Pointer to the rest of a large body of objects */
296 struct obj *head; /**< Points to the main object of a large body */
297 struct mapdef *map; /**< Pointer to the map in which this object is present */
298
299 tag_t count; /**< Unique object number for this object */
300 struct struct_dialog_information *dialog_information; /**< Parsed dialog information for this object.
301 * Valid if FLAG_DIALOG_PARSED is set (but can be NULL). */
302
303 /* These get an extra add_refcount(), after having been copied by memcpy().
304 *
305 * Fields below name (included) are copied by memcpy in object_copy().
306 *
307 * If adding something that needs a refcount updated, make sure you modify
308 * object_copy() to do so.
309 * Everything below here also gets cleared by object_clear().
310 */
311 const char *name; /**< The name of the object, obviously... */
312 /* Place new attributes that should get copied and cleared below name */
313
314 sstring artifact; /**< If set, the item is the artifact with this name and the matching type. */
315 const char *name_pl; /**< The plural name of the object */
316 const char *anim_suffix; /**< Used to determine combined animations */
317 const char *title; /**< Of foo, etc */
318 const char *race; /**< Human, goblin, dragon, etc */
319 const char *slaying; /**< Which race to do double damage to.
320 * If this is an exit, this is the filename */
321 const char *skill; /**< Name of the skill this object uses/grants */
322 const char* msg; /**< If this is a book/sign/magic mouth/etc. Modify with
323 object_set_msg() to preserve invariants. */
324 const char *lore; /**< Obscure information about this object,
325 * to get put into books and the like. */
326
327 int16_t x, y; /**< Position in the map for this object */
328 int16_t ox, oy; /**< For debugging: Where it was last inserted */
329 float speed; /**< Frequency of object 'moves' relative to server tick rate */
330 float speed_left; /**< How much speed is left to spend this round */
331 float weapon_speed; /**< The overall speed of this object */
332 float weapon_speed_left; /**< How much speed is left to spend this round */
333 const Face *face; /**< Face with colors */
334 uint32_t nrof; /**< Number of objects. Consider accessing
335 with NROF() macro. */
336 int8_t direction; /**< Means the object is moving that way. */
337 int8_t facing; /**< Object is oriented/facing that way. */
338
339 /* This next big block are basically used for monsters and equipment */
340 uint8_t type; /**< PLAYER, BULLET, etc. See define.h */
341 uint8_t subtype; /**< Subtype of object */
342 uint16_t client_type; /**< Public type information. see doc/Developers/objects */
343 int16_t resist[NROFATTACKS]; /**< Resistance adjustments for attacks */
344 uint32_t attacktype; /**< Bitmask of attacks this object does */
345 uint32_t path_attuned; /**< Paths the object is attuned to */
346 uint32_t path_repelled; /**< Paths the object is repelled from */
347 uint32_t path_denied; /**< Paths the object is denied access to */
348 const char *materialname; /**< Specific material name */
349 uint16_t material; /**< What materials this object consist of */
350 int8_t magic; /**< Any magical bonuses to this item */
351 uint8_t state; /**< How the object was last drawn (animation) */
352 int32_t value; /**< How much money it is worth (or contains) */
353 int16_t level; /**< Level of creature or object */
354
355 /* Note that the last_.. values are sometimes used for non obvious
356 * meanings by some objects, eg, sp penalty, permanent exp.
357 */
358 int32_t last_eat; /**< How long since we last ate */
359 int32_t last_heal; /**< Last healed. Depends on constitution */
360 int32_t last_sp; /**< As last_heal, but for spell points */
361 int16_t last_grace; /**< As last_sp, except for grace */
362 int16_t invisible; /**< How much longer the object will be invis */
363 uint8_t pick_up; /**< See crossfire.doc */
364 int8_t item_power; /**< Power rating of the object */
365 int8_t gen_sp_armour; /**< Sp regen penalty this object has (was last_heal)*/
366 int8_t glow_radius; /**< indicates the glow radius of the object */
367 int32_t weight; /**< Attributes of the object */
368 int32_t weight_limit; /**< Weight-limit of object */
369 int32_t carrying; /**< How much weight this object contains */
370 living stats; /**< Str, Con, Dex, etc */
371 //int64_t perm_exp; /**< Permanent exp */
372 int64_t total_exp; /**< All exp ever earned (used to calc perm_exp) */
373 struct obj *current_weapon; /**< Pointer to the weapon currently used */
374 uint32_t weapontype; /**< Type of weapon */
375 int8_t body_info[NUM_BODY_LOCATIONS]; /**< Body info as loaded from the file */
376 int8_t body_used[NUM_BODY_LOCATIONS]; /**< Calculated value based on items equipped */
377 /* See the doc/Developers/objects for more info about body locations */
378
379 /* Following mostly refers to fields only used for monsters */
380 struct obj *owner; /**< Pointer to the object which controls this one.
381 * Owner should not be referred to directly -
382 * object_get_owner() should be used instead. */
383 tag_t ownercount; /**< What count the owner had (in case owner has been freed) */
384 struct obj *enemy; /**< Monster/player to follow even if not closest */
385 struct obj *attacked_by; /**< This object start to attack us! only player & monster */
386 tag_t attacked_by_count; /**< The tag of attacker, so we can be sure */
387 uint8_t run_away; /**< Monster runs away if it's hp goes below this percentage. */
388 struct treasureliststruct *randomitems; /**< Items to be generated */
389 struct obj *chosen_skill; /**< The skill chosen to use */
390 uint8_t hide; /**< The object is hidden, not invisible */
391 /* changes made by [email protected] */
392 /* allows different movement patterns for attackers */
393 int32_t move_status; /**< What stage in attack mode */
394 uint16_t attack_movement;/**< What kind of attack movement */
395 uint8_t will_apply; /**< See crossfire.doc and @ref WILL_APPLY_xxx */
396 uint8_t sound_chance; /**< Ignored. Probability, 0 to 100, of the object emitting a sound. */
397 struct obj *spellitem; /**< Spell ability monster is choosing to use */
398 double expmul; /**< needed experience = (calc_exp*expmul) - means some
399 * races/classes can need less/more exp to gain levels */
400
401 /* Spell related information, may be useful elsewhere
402 * Note that other fields are used - these files are basically
403 * only used in spells.
404 */
405 int16_t casting_time; /**< Time left before spell goes off */
406 int16_t duration; /**< Number of moves (see 'speed') spell lasts */
407 uint8_t duration_modifier; /**< how level modifies duration */
408 int8_t range; /**< Range of the spell */
409 uint8_t range_modifier; /**< How going up in level affects range */
410 uint8_t dam_modifier; /**< How going up in level affects damage */
411 struct obj *spell; /**< Spell that was being cast */
412 char *spellarg; /**< Optional argument when casting obj::spell. */
413
414 /* Following are values used by any object */
415 struct archt *arch; /**< Pointer to archetype */
416 struct archt *other_arch; /**< Pointer used for various things - mostly used for what
417 * this objects turns into or what this object creates */
418 uint32_t flags[4]; /**< Various flags */
419 const Animations *animation; /**< Animation of this item, NULL if not animated. */
420 uint8_t anim_speed; /**< Ticks between animation-frames */
421 uint8_t last_anim; /**< Last sequence used to draw face */
422 const Animations *temp_animation; /**< A temporary animation. */
423 uint8_t temp_anim_speed; /**< Ticks between temporary animation-frames */
424 uint8_t smoothlevel; /**< how to smooth this square around*/
425 uint8_t map_layer; /**< What level to draw this on the map */
426
427 MoveType move_type; /**< Type of movement this object uses */
428 MoveType move_block; /**< What movement types this blocks */
429 MoveType move_allow; /**< What movement types explicitly allowed */
430 MoveType move_on; /**< Move types affected moving on to this space */
431 MoveType move_off; /**< Move types affected moving off this space */
432 MoveType move_slow; /**< Movement types this slows down */
433 float move_slow_penalty; /**< How much this slows down the object */
434
435 const char *custom_name; /**< Custom name assigned by player */
436 key_value *key_values; /**< Fields not explictly known by the loader. */
437
438 tag_t *spell_tags; /**< Tags used for spell effect merging. */
439 } object;
440
441 /**
442 * Used to link together several objects
443 */
444 typedef struct oblnk {
445 object *ob; /**< Item to link to. */
446 struct oblnk *next; /**< Next item to link to. */
447 tag_t id; /**< ob's tag, in case it is removed. */
448 } objectlink;
449
450 /**
451 * Used to link together several object links
452 */
453 typedef struct oblinkpt {
454 struct oblnk *link; /**< Items for this value. */
455 long value; /**< Used as connected value in buttons/gates */
456 struct oblinkpt *next;/**< Next value in the list. */
457 } oblinkpt;
458
459 /**
460 * The archetype structure is a set of rules on how to generate and manipulate
461 * objects which point to archetypes.
462 * This probably belongs in arch.h, but there really doesn't appear to
463 * be much left in the archetype - all it really is is a holder for the
464 * object and pointers. This structure should get removed, and just replaced
465 * by the object structure
466 */
467 typedef struct archt {
468 const char *name; /**< More definite name, like "generate_kobold" */
469 struct archt *next; /**< Next archetype in a linked list */
470 struct archt *head; /**< The main part of a linked object */
471 struct archt *more; /**< Next part of a linked object */
472 object clone; /**< An object from which to do object_copy() */
473 int8_t tail_x, tail_y; /**< Where the lower right most portion of the object is
474 * in comparison to the head. */
475 int reference_count; /**< How many times this temporary archetype is used. If 0, "permanent" archetype. */
476 } archetype;
477
478 extern object *objects;
479 extern object *active_objects;
480
481 extern int nrofallocobjects;
482 extern int nroffreeobjects;
483
484 static inline int compare_flags(const object *p, const object *q) {
485 return ((p)->flags[0] == (q)->flags[0]) &&
486 ((p)->flags[1] == (q)->flags[1]) &&
487 ((p)->flags[2] == (q)->flags[2]) &&
488 ((p)->flags[3] == (q)->flags[3]);
489 }
490
491 static inline int query_flag(const object *op, int flag) {
492 return op->flags[flag / 32] & (1U << (flag % 32));
493 }
494
495 static inline void clear_flag(object *op, int flag) {
496 op->flags[flag / 32] &= ~(1U << (flag % 32));
497 }
498
499 static inline void set_flag(object *op, int flag) {
500 op->flags[flag / 32] |= (1U << (flag % 32));
501 }
502
503 /**
504 * This returns TRUE if the object is something that
505 * should be displayed in the look window
506 */
507 #define LOOK_OBJ(ob) (!ob->invisible && ob->type != PLAYER && ob->type != EVENT_CONNECTOR)
508
509 /**
510 * @defgroup UP_OBJ_xxx Object update flags
511 *
512 * Used by object_update() to know if the object being passed is
513 * being added or removed.
514 */
515 /*@{*/
516 #define UP_OBJ_INSERT 1 /**< Object was inserted. */
517 #define UP_OBJ_REMOVE 2 /**< Object was removed. */
518 #define UP_OBJ_CHANGE 3 /**< Object changed. */
519 #define UP_OBJ_FACE 4 /**< Only thing that changed was the face. In this case,
520 * we always update everything as that is easier than trying
521 * to look at what may have changed. */
522 /*@}*/
523
524 /**
525 * @defgroup FREE_OBJ_xxx Object free flags
526 *
527 * Used by object_free() to specify options.
528 */
529 /*@{*/
530 #define FREE_OBJ_FREE_INVENTORY 1 /**< Free inventory objects; if not set, drop inventory. */
531 #define FREE_OBJ_NO_DESTROY_CALLBACK 2 /**< Do not run the destroy callback. */
532 #define FREE_OBJ_DROP_ABOVE_FLOOR 4 /**< If FREE_OBJ_FREE_INVENTORY is not set, drop inventory just above ground instead on top. */
533 /*@}*/
534
535 /**
536 * @defgroup INS_xxx Object insertion flags.
537 *
538 * These are flags passed to object_insert_in_map() and
539 * object_insert_in_ob(). Note that all flags may not be meaningful
540 * for both functions.
541 * Most are fairly explanatory:
542 * - INS_NO_MERGE: don't try to merge inserted object with ones alrady
543 * on space.
544 * - INS_ABOVE_FLOOR_ONLY: Put object immediatly above the floor.
545 * - INS_NO_WALK_ON: Don't call check_walk_on against the
546 * originator - saves cpu time if you know the inserted object
547 * is not meaningful in terms of having an effect.
548 * - INS_ON_TOP: Always put object on top. Generally only needed when loading
549 * files from disk and ordering needs to be preserved.
550 * - INS_BELOW_ORIGINATOR: Insert new object immediately below originator -
551 * Use for treasure chests so the new object is the highest thing
552 * beneath the player, but not actually above it. Note - the
553 * map and x,y coordinates for the object to be inserted must
554 * match the originator.
555 * - INS_MAP_LOAD: disable lots of checkings done at insertion to
556 * speed up map loading process, as we assume the ordering in
557 * loaded map is correct.
558 *
559 * Note that INS_BELOW_ORIGINATOR, INS_ON_TOP, INS_ABOVE_FLOOR_ONLY
560 * are mutually exclusive. The behaviour for passing more than one
561 * should be considered undefined - while you may notice what happens
562 * right now if you pass more than one, that could very well change
563 * in future revisions of the code.
564 */
565 /*@{*/
566 #define INS_NO_MERGE 0x0001 /**< Don't try to merge with other items. */
567 #define INS_ABOVE_FLOOR_ONLY 0x0002 /**< Put object immediatly above the floor. */
568 #define INS_NO_WALK_ON 0x0004 /**< Don't call check_walk_on against the originator. */
569 #define INS_ON_TOP 0x0008 /**< Always put object on top. */
570 #define INS_BELOW_ORIGINATOR 0x0010 /**< Insert new object immediately below originator. */
571 #define INS_MAP_LOAD 0x0020 /**< Disable lots of checkings. */
572 /*@}*/
573
574 #define ARCH_SINGULARITY "singularity" /**< Archetype for singularity. */
575 #define ARCH_SINGULARITY_LEN 11 /**< Length of ::ARCH_SINGULARITY. */
576 #define ARCH_DETECT_MAGIC "detect_magic" /**< Archetype for detect magic spell. */
577 #define ARCH_DEPLETION "depletion" /**< Archetype for depletion. */
578 #define ARCH_SYMPTOM "symptom" /**< Archetype for disease symptom. */
579 #define ARCH_PORTAL_FAILED "town_portal_failed" /**< Archetype for town portal failure. */
580 #define ARCH_SPELL_BLOCKED "spell_blocked" /**< Archetype when a spell is blocked (unholy ground or non magic). */
581 #define ARCH_SPELL_BUNGLE "spell_bungle" /**< Archetype when player bungles a spell. */
582
583 /**
584 * Returns the head part of an object. For single-tile objects returns the
585 * object itself.
586 *
587 * @param op
588 * the object
589 * @return
590 * the head object
591 */
592 #define HEAD(op) ((op)->head != NULL ? (op)->head : (op))
593
594 static inline bool IS_PLAYER(object *op) {
595 return op->type == PLAYER;
596 }
597
598 /**
599 * Determine whether the given object can have an HP bar.
600 */
601 static inline bool CAN_PROBE(const object *ob) {
602 return QUERY_FLAG(ob, FLAG_ALIVE) &&
603 (ob->type == PLAYER || QUERY_FLAG(ob, FLAG_MONSTER));
604 }
605
606 /**
607 * Returns ob->nrof, unless it is 0, in which case return 1. Most of the code
608 * assumes that nrof=0 is the same as nrof=1.
609 */
610 static inline uint32_t NROF(const object * const ob) {
611 return ob->nrof ? ob->nrof : 1;
612 }
613
614 #endif /* OBJECT_H */