… | |
… | |
270 | }; |
270 | }; |
271 | |
271 | |
272 | struct object : zero_initialised, object_copy |
272 | struct object : zero_initialised, object_copy |
273 | { |
273 | { |
274 | // These variables are not changed by ->copy_to |
274 | // These variables are not changed by ->copy_to |
275 | maptile_ptr ACC (RW, map); /* Pointer to the map in which this object is present */ |
275 | maptile *ACC (RW, map); /* Pointer to the map in which this object is present */ |
276 | |
276 | |
277 | UUID ACC (RW, uuid); // Unique Identifier, survives saves etc. |
277 | UUID ACC (RW, uuid); // Unique Identifier, survives saves etc. |
278 | int ACC (RO, count); |
278 | int ACC (RO, count); |
279 | object_vector_index ACC (RO, index); // index into objects |
279 | object_vector_index ACC (RO, index); // index into objects |
280 | object_vector_index ACC (RO, active); // index into actives |
280 | object_vector_index ACC (RO, active); // index into actives |
… | |
… | |
344 | MTH void copy_to (object *dst); |
344 | MTH void copy_to (object *dst); |
345 | MTH object *clone (); // create + copy_to a single object |
345 | MTH object *clone (); // create + copy_to a single object |
346 | MTH object *deep_clone (); // copy whole more chain and inventory |
346 | MTH object *deep_clone (); // copy whole more chain and inventory |
347 | void do_destroy (); |
347 | void do_destroy (); |
348 | void gather_callbacks (AV *&callbacks, event_type event) const; |
348 | void gather_callbacks (AV *&callbacks, event_type event) const; |
349 | MTH void destroy (bool destroy_inventory = false); |
349 | MTH void destroy (); |
|
|
350 | MTH void drop_and_destroy () |
|
|
351 | { |
|
|
352 | destroy_inv (true); |
|
|
353 | destroy (); |
|
|
354 | } |
350 | |
355 | |
351 | // recursively destroy all objects in inventory, optionally dropping them to the ground instead |
356 | // recursively destroy all objects in inventory, optionally dropping them to the ground instead |
352 | MTH void destroy_inv (bool drop_to_ground = false); |
357 | MTH void destroy_inv (bool drop_to_ground = false); |
353 | MTH object *insert (object *item); // insert into inventory |
358 | MTH object *insert (object *item); // insert into inventory |
354 | MTH void play_sound (faceidx sound); |
359 | MTH void play_sound (faceidx sound); |
… | |
… | |
441 | * 1000 |
446 | * 1000 |
442 | * (type == CONTAINER ? 1000 : 1) |
447 | * (type == CONTAINER ? 1000 : 1) |
443 | / dominant_material ()->density; |
448 | / dominant_material ()->density; |
444 | } |
449 | } |
445 | |
450 | |
|
|
451 | MTH bool is_wiz () const { return flag [FLAG_WIZ]; } |
446 | MTH bool is_weapon () const { return type == ARROW || type == BOW || type == WEAPON; } |
452 | MTH bool is_weapon () const { return type == ARROW || type == BOW || type == WEAPON; } |
447 | MTH bool is_armor () const { return type == ARMOUR || type == SHIELD || type == HELMET |
453 | MTH bool is_armor () const { return type == ARMOUR || type == SHIELD || type == HELMET |
448 | || type == CLOAK || type == BOOTS || type == GLOVES |
454 | || type == CLOAK || type == BOOTS || type == GLOVES |
449 | || type == BRACERS || type == GIRDLE; } |
455 | || type == BRACERS || type == GIRDLE; } |
450 | MTH bool is_alive () const { return (type == PLAYER |
456 | MTH bool is_alive () const { return (type == PLAYER |
… | |
… | |
514 | } |
520 | } |
515 | |
521 | |
516 | MTH bool is_on_map () const |
522 | MTH bool is_on_map () const |
517 | { |
523 | { |
518 | return !env && !flag [FLAG_REMOVED]; |
524 | return !env && !flag [FLAG_REMOVED]; |
|
|
525 | } |
|
|
526 | |
|
|
527 | MTH bool is_in_map_or_inv () const |
|
|
528 | { |
|
|
529 | return !flag [FLAG_REMOVED]; |
519 | } |
530 | } |
520 | |
531 | |
521 | // returns the player that cna see this object, if any |
532 | // returns the player that cna see this object, if any |
522 | MTH object *visible_to () const; |
533 | MTH object *visible_to () const; |
523 | |
534 | |