… | |
… | |
492 | * 1000 |
492 | * 1000 |
493 | * (type == CONTAINER ? 1000 : 1) |
493 | * (type == CONTAINER ? 1000 : 1) |
494 | / dominant_material ()->density; |
494 | / dominant_material ()->density; |
495 | } |
495 | } |
496 | |
496 | |
|
|
497 | MTH bool is_arch () const { return this == (const object *)(const archetype *)arch; } |
|
|
498 | |
497 | MTH bool is_wiz () const { return flag [FLAG_WIZ]; } |
499 | MTH bool is_wiz () const { return flag [FLAG_WIZ]; } |
498 | MTH bool is_weapon () const { return type == ARROW || type == BOW || type == WEAPON; } |
500 | MTH bool is_weapon () const { return type == ARROW || type == BOW || type == WEAPON; } |
499 | MTH bool is_armor () const { return type == ARMOUR || type == SHIELD || type == HELMET |
501 | MTH bool is_armor () const { return type == ARMOUR || type == SHIELD || type == HELMET |
500 | || type == CLOAK || type == BOOTS || type == GLOVES |
502 | || type == CLOAK || type == BOOTS || type == GLOVES |
501 | || type == BRACERS || type == GIRDLE; } |
503 | || type == BRACERS || type == GIRDLE; } |
… | |
… | |
519 | /* This return true if object has still randomitems which |
521 | /* This return true if object has still randomitems which |
520 | * could be expanded. |
522 | * could be expanded. |
521 | */ |
523 | */ |
522 | MTH bool has_random_items () const { return randomitems && !flag [FLAG_IS_A_TEMPLATE]; } |
524 | MTH bool has_random_items () const { return randomitems && !flag [FLAG_IS_A_TEMPLATE]; } |
523 | |
525 | |
524 | MTH bool has_dialogue () const { return *&msg == '@'; } |
526 | static bool msg_has_dialogue (const char *msg) { return *msg == '@'; } |
|
|
527 | |
|
|
528 | MTH bool has_dialogue () const { return msg_has_dialogue (&msg); } |
525 | |
529 | |
526 | // returns the outermost owner, never returns 0 |
530 | // returns the outermost owner, never returns 0 |
527 | MTH object *outer_owner () |
531 | MTH object *outer_owner () |
528 | { |
532 | { |
529 | object *op; |
533 | object *op; |
… | |
… | |
546 | } |
550 | } |
547 | |
551 | |
548 | // returns the outermost environment, may return 0 |
552 | // returns the outermost environment, may return 0 |
549 | MTH object *outer_env () const |
553 | MTH object *outer_env () const |
550 | { |
554 | { |
551 | return env ? outer_env () : 0; |
555 | return env ? outer_env_or_self () : 0; |
552 | } |
556 | } |
553 | |
557 | |
554 | // returns the player that has this object in his inventory, or 0 |
558 | // returns the player that has this object in his inventory, or 0 |
555 | // we assume the player is always the outer env |
559 | // we assume the player is always the outer env |
556 | MTH object *in_player () const |
560 | MTH object *in_player () const |
… | |
… | |
597 | } |
601 | } |
598 | |
602 | |
599 | // returns the player that cna see this object, if any |
603 | // returns the player that cna see this object, if any |
600 | MTH object *visible_to () const; |
604 | MTH object *visible_to () const; |
601 | |
605 | |
602 | MTH std::string long_desc (object *who = 0); |
606 | MTH std::string long_desc (object *who = 0); // query_name . " " . describe |
603 | MTH std::string describe_monster (object *who = 0); |
607 | MTH std::string describe_monster (object *who = 0); |
604 | MTH std::string describe_item (object *who = 0); |
608 | MTH std::string describe_item (object *who = 0); |
605 | MTH std::string describe (object *who = 0); |
609 | MTH std::string describe (object *who = 0); // long description, without name |
606 | |
610 | |
607 | MTH const char *query_weight () { return ::query_weight (this); } |
611 | MTH const char *query_weight () { return ::query_weight (this); } |
608 | MTH const char *query_name () { return ::query_name (this); } |
612 | MTH const char *query_name () { return ::query_name (this); } |
609 | MTH const char *query_short_name () { return ::query_short_name (this); } |
613 | MTH const char *query_short_name () { return ::query_short_name (this); } |
610 | MTH const char *query_base_name (bool plural) { return ::query_base_name (this, plural); } |
614 | MTH const char *query_base_name (bool plural) { return ::query_base_name (this, plural); } |
… | |
… | |
705 | // currently only used for players to make them temporarily visible |
709 | // currently only used for players to make them temporarily visible |
706 | // when they are invisible. |
710 | // when they are invisible. |
707 | MTH void make_noise (); |
711 | MTH void make_noise (); |
708 | |
712 | |
709 | /* animation */ |
713 | /* animation */ |
710 | bool has_anim () { return animation_id; } |
714 | MTH bool has_anim () const { return animation_id; } |
711 | const animation &anim () const { return animations [animation_id]; } |
715 | const animation &anim () const { return animations [animation_id]; } |
712 | faceidx get_anim_frame (int frame) const { return anim ().faces [frame]; } |
716 | MTH faceidx get_anim_frame (int frame) const { return anim ().faces [frame]; } |
713 | void set_anim_frame (int frame) { face = get_anim_frame (frame); } |
717 | MTH void set_anim_frame (int frame) { face = get_anim_frame (frame); } |
714 | /* anim_frames () returns the number of animations allocated. The last |
718 | /* anim_frames () returns the number of animations allocated. The last |
715 | * usuable animation will be anim_frames () - 1 (for example, if an object |
719 | * usuable animation will be anim_frames () - 1 (for example, if an object |
716 | * has 8 animations, anim_frames () will return 8, but the values will |
720 | * has 8 animations, anim_frames () will return 8, but the values will |
717 | * range from 0 through 7. |
721 | * range from 0 through 7. |
718 | */ |
722 | */ |
719 | int anim_frames () const { return anim ().num_animations; } |
723 | MTH int anim_frames () const { return anim ().num_animations; } |
720 | int anim_facings () const { return anim ().facings; } |
724 | MTH int anim_facings () const { return anim ().facings; } |
|
|
725 | |
|
|
726 | MTH char *as_string (); |
721 | |
727 | |
722 | protected: |
728 | protected: |
723 | void link (); |
729 | void link (); |
724 | void unlink (); |
730 | void unlink (); |
725 | |
731 | |
… | |
… | |
734 | // move this object to the top of its env's inventory to speed up |
740 | // move this object to the top of its env's inventory to speed up |
735 | // searches for it. |
741 | // searches for it. |
736 | static object * |
742 | static object * |
737 | splay (object *ob) |
743 | splay (object *ob) |
738 | { |
744 | { |
739 | if (ob->env && ob->env->inv != ob) |
745 | if (ob->above && ob->env) |
740 | { |
746 | { |
741 | if (ob->above) ob->above->below = ob->below; |
747 | if (ob->above) ob->above->below = ob->below; |
742 | if (ob->below) ob->below->above = ob->above; |
748 | if (ob->below) ob->below->above = ob->above; |
743 | |
749 | |
744 | ob->above = 0; |
750 | ob->above = 0; |