… | |
… | |
165 | flags_t flag; /* various flags */ |
165 | flags_t flag; /* various flags */ |
166 | #if FOR_PERL |
166 | #if FOR_PERL |
167 | bool ACC (RW, flag[NUM_FLAGS]); |
167 | bool ACC (RW, flag[NUM_FLAGS]); |
168 | #endif |
168 | #endif |
169 | |
169 | |
170 | shstr ACC (RW, materialname); /* specific material name */ |
170 | materialtype_t *material; // What material this object consists of //TODO, make perl-accessible |
171 | shstr ACC (RW, skill); /* Name of the skill this object uses/grants */ |
171 | shstr ACC (RW, skill); /* Name of the skill this object uses/grants */ |
172 | // materialtype_t *ACC (RW, material); /* What material this object consists of */ |
|
|
173 | object_ptr ACC (RW, owner); /* Pointer to the object which controls this one */ |
172 | object_ptr ACC (RW, owner); /* Pointer to the object which controls this one */ |
174 | object_ptr ACC (RW, enemy); /* Monster/player to follow even if not closest */ |
173 | object_ptr ACC (RW, enemy); /* Monster/player to follow even if not closest */ |
175 | object_ptr ACC (RW, attacked_by); /* This object start to attack us! only player & monster */ |
174 | object_ptr ACC (RW, attacked_by); /* This object start to attack us! only player & monster */ |
176 | object_ptr ACC (RW, chosen_skill); /* the skill chosen to use */ |
175 | object_ptr ACC (RW, chosen_skill); /* the skill chosen to use */ |
177 | object_ptr ACC (RW, spellitem); /* Spell ability monster is choosing to use */ |
176 | object_ptr ACC (RW, spellitem); /* Spell ability monster is choosing to use */ |
… | |
… | |
489 | } |
488 | } |
490 | |
489 | |
491 | MTH void update_weight (); |
490 | MTH void update_weight (); |
492 | |
491 | |
493 | // return the dominant material of this item, always return something |
492 | // return the dominant material of this item, always return something |
494 | const materialtype_t *dominant_material () const; |
493 | const materialtype_t *dominant_material () const |
|
|
494 | { |
|
|
495 | return material; |
|
|
496 | } |
495 | |
497 | |
496 | // return the volume of this object in cm³ |
498 | // return the volume of this object in cm³ |
497 | MTH uint64 volume () const |
499 | MTH uint64 volume () const |
498 | { |
500 | { |
499 | return (uint64)total_weight () |
501 | return (uint64)total_weight () |
500 | * 1000 |
502 | * 1024 // 1000 actually |
501 | * (type == CONTAINER ? 1000 : 1) |
503 | * (type == CONTAINER ? 128 : 1) |
502 | / dominant_material ()->density; |
504 | / dominant_material ()->density; // ugh, division |
503 | } |
505 | } |
504 | |
506 | |
505 | MTH bool is_arch () const { return this == (const object *)(const archetype *)arch; } |
507 | MTH bool is_arch () const { return this == (const object *)(const archetype *)arch; } |
506 | |
508 | |
507 | MTH bool is_wiz () const { return flag [FLAG_WIZ]; } |
509 | MTH bool is_wiz () const { return flag [FLAG_WIZ]; } |
… | |
… | |
516 | MTH bool is_arrow () const { return type == ARROW |
518 | MTH bool is_arrow () const { return type == ARROW |
517 | || (type == SPELL_EFFECT |
519 | || (type == SPELL_EFFECT |
518 | && (subtype == SP_BULLET || subtype == SP_MAGIC_MISSILE)); } |
520 | && (subtype == SP_BULLET || subtype == SP_MAGIC_MISSILE)); } |
519 | MTH bool is_range () const { return type == BOW || type == ROD || type == WAND || type == HORN; } |
521 | MTH bool is_range () const { return type == BOW || type == ROD || type == WAND || type == HORN; } |
520 | |
522 | |
521 | MTH bool has_active_speed () const { return fabs (speed) >= MIN_ACTIVE_SPEED; } |
523 | MTH bool has_active_speed () const { return speed >= MIN_ACTIVE_SPEED; } |
522 | |
524 | |
523 | // temporary: wether the object can be saved in a map file |
525 | // temporary: wether the object can be saved in a map file |
524 | // contr => is a player |
526 | // contr => is a player |
525 | // head => only save head of a multitile object |
527 | // head => only save head of a multitile object |
526 | // owner => can not reference owner yet |
528 | // owner => can not reference owner yet |
… | |
… | |
821 | { |
823 | { |
822 | return at->instance (); |
824 | return at->instance (); |
823 | } |
825 | } |
824 | |
826 | |
825 | inline void |
827 | inline void |
826 | object_freezer::put (keyword k, archetype *v) |
828 | object_freezer::put (const keyword_string k, archetype *v) |
827 | { |
829 | { |
828 | put (k, v ? &v->archname : (const char *)0); |
830 | if (expect_true (v)) |
|
|
831 | put (k, v->archname); |
|
|
832 | else |
|
|
833 | put (k); |
829 | } |
834 | } |
830 | |
835 | |
831 | typedef object_vector<object, &object::index > objectvec; |
836 | typedef object_vector<object, &object::index > objectvec; |
832 | typedef object_vector<object, &object::active> activevec; |
837 | typedef object_vector<object, &object::active> activevec; |
833 | typedef object_vector<archetype, &archetype::archid> archvec; |
838 | typedef object_vector<archetype, &archetype::archid> archvec; |