… | |
… | |
284 | * (sack, luggage, etc), tmp->env->env then points to the player (nested |
284 | * (sack, luggage, etc), tmp->env->env then points to the player (nested |
285 | * containers not allowed as of now) |
285 | * containers not allowed as of now) |
286 | */ |
286 | */ |
287 | if ((pl->move_type & MOVE_FLYING) && !QUERY_FLAG (pl, FLAG_WIZ) && tmp->in_player () != pl) |
287 | if ((pl->move_type & MOVE_FLYING) && !QUERY_FLAG (pl, FLAG_WIZ) && tmp->in_player () != pl) |
288 | { |
288 | { |
289 | new_draw_info (NDI_UNIQUE, 0, pl, "You are levitating, you can't reach the ground!"); |
289 | pl->failmsg ("You are levitating, you can't reach the ground! " |
|
|
290 | "H<You have to stop levitating first, if you can, either by using your levitation skill, " |
|
|
291 | "or waiting till the levitation effect wears off.>"); |
290 | return; |
292 | return; |
291 | } |
293 | } |
292 | |
294 | |
293 | if (QUERY_FLAG (tmp, FLAG_NO_DROP)) |
295 | if (QUERY_FLAG (tmp, FLAG_NO_DROP)) |
294 | return; |
296 | return; |
… | |
… | |
482 | * but that probably will make it more difficult to read, and |
484 | * but that probably will make it more difficult to read, and |
483 | * not make it any more efficient |
485 | * not make it any more efficient |
484 | */ |
486 | */ |
485 | if (params && item_matched_string (op, tmp, params)) |
487 | if (params && item_matched_string (op, tmp, params)) |
486 | { |
488 | { |
|
|
489 | if (--cnt < 0) break; |
487 | pick_up (op, tmp); |
490 | pick_up (op, tmp); |
488 | if (--cnt <= 0) break; |
|
|
489 | } |
491 | } |
490 | else if (can_pick (op, tmp) && !params) |
492 | else if (can_pick (op, tmp) && !params) |
491 | { |
493 | { |
|
|
494 | if (--cnt < 0) break; |
492 | pick_up (op, tmp); |
495 | pick_up (op, tmp); |
493 | break; |
496 | break; |
494 | } |
497 | } |
495 | |
498 | |
496 | tmp = next; |
499 | tmp = next; |
497 | } |
500 | } |
498 | |
501 | |
499 | if (cnt <= 0) |
502 | if (cnt < 0) |
500 | { |
503 | { |
501 | op->failmsg ("Couldn't pick up so many items at once."); |
504 | op->failmsg ("Couldn't pick up so many items at once."); |
502 | return 0; |
505 | return 0; |
503 | } |
506 | } |
504 | |
507 | |
… | |
… | |
580 | if (!can_split (op, tmp, nrof)) |
583 | if (!can_split (op, tmp, nrof)) |
581 | return; |
584 | return; |
582 | |
585 | |
583 | new_draw_info_format (NDI_UNIQUE, 0, op, "You put the %s in %s.", query_name (tmp), query_name (sack)); |
586 | new_draw_info_format (NDI_UNIQUE, 0, op, "You put the %s in %s.", query_name (tmp), query_name (sack)); |
584 | sack->insert (tmp); |
587 | sack->insert (tmp); |
585 | |
|
|
586 | // elmex: 2007-11-26: removed update_stats and replaced |
|
|
587 | // it by update_after_inventory_change () in the caller |
|
|
588 | // of this function |
|
|
589 | } |
588 | } |
590 | |
589 | |
591 | /* |
590 | /* |
592 | * This function was part of drop, now is own function. |
591 | * This function was part of drop, now is own function. |
593 | * Player 'op' tries to drop object 'tmp', if tmp is non zero, then |
592 | * Player 'op' tries to drop object 'tmp', if tmp is non zero, then |
… | |
… | |
633 | for (object *floor = GET_MAP_OB (op->map, op->x, op->y); floor; floor = floor->above) |
632 | for (object *floor = GET_MAP_OB (op->map, op->x, op->y); floor; floor = floor->above) |
634 | if (INVOKE_OBJECT (DROP_ON, floor, ARG_OBJECT (tmp), ARG_OBJECT (op))) |
633 | if (INVOKE_OBJECT (DROP_ON, floor, ARG_OBJECT (tmp), ARG_OBJECT (op))) |
635 | return; |
634 | return; |
636 | |
635 | |
637 | if (is_in_shop (op) && !QUERY_FLAG (tmp, FLAG_UNPAID) && tmp->type != MONEY) |
636 | if (is_in_shop (op) && !QUERY_FLAG (tmp, FLAG_UNPAID) && tmp->type != MONEY) |
|
|
637 | { |
638 | sell_item (tmp, op); |
638 | if (!sell_item (tmp, op)) |
|
|
639 | return; // if we can't sell it we don't drop it |
|
|
640 | } |
639 | |
641 | |
640 | tmp->x = op->x; |
642 | tmp->x = op->x; |
641 | tmp->y = op->y; |
643 | tmp->y = op->y; |
642 | |
644 | |
643 | insert_ob_in_map (tmp, op->map, op, INS_BELOW_ORIGINATOR); |
645 | insert_ob_in_map (tmp, op->map, op, INS_BELOW_ORIGINATOR); |
644 | } |
|
|
645 | |
|
|
646 | void |
|
|
647 | update_after_inventory_change (object *op) |
|
|
648 | { |
|
|
649 | /* Call this before we update the various windows/players. At least |
|
|
650 | * that we, we know the weight is correct. |
|
|
651 | */ |
|
|
652 | op->update_stats (); |
|
|
653 | |
|
|
654 | // elmex: kept this for now, i have no idea what happens when i remove it: |
|
|
655 | if (op->type == PLAYER) |
|
|
656 | { |
|
|
657 | /* Need to update the weight for the player */ |
|
|
658 | esrv_send_item (op, op); |
|
|
659 | op->contr->ns->floorbox_update (); |
|
|
660 | } |
|
|
661 | } |
646 | } |
662 | |
647 | |
663 | void |
648 | void |
664 | drop (object *op, object *tmp) |
649 | drop (object *op, object *tmp) |
665 | { |
650 | { |
… | |
… | |
680 | tmp->destroy (); |
665 | tmp->destroy (); |
681 | return; |
666 | return; |
682 | } |
667 | } |
683 | else |
668 | else |
684 | { |
669 | { |
685 | while (tmp != NULL && tmp->invisible) |
670 | while (tmp && tmp->invisible) |
686 | tmp = tmp->below; |
671 | tmp = tmp->below; |
687 | } |
672 | } |
688 | } |
673 | } |
689 | |
674 | |
690 | if (tmp == NULL) |
675 | if (tmp == NULL) |
691 | { |
676 | { |
692 | new_draw_info (NDI_UNIQUE, 0, op, "You don't have anything to drop."); |
677 | new_draw_info (NDI_UNIQUE, 0, op, "You don't have anything to drop."); |
693 | return; |
678 | return; |
694 | } |
679 | } |
|
|
680 | |
695 | if (QUERY_FLAG (tmp, FLAG_INV_LOCKED)) |
681 | if (QUERY_FLAG (tmp, FLAG_INV_LOCKED)) |
696 | { |
682 | { |
697 | new_draw_info (NDI_UNIQUE, 0, op, "This item is locked"); |
683 | new_draw_info (NDI_UNIQUE, 0, op, "This item is locked"); |
698 | return; |
684 | return; |
699 | } |
685 | } |
|
|
686 | |
700 | if (QUERY_FLAG (tmp, FLAG_NO_DROP)) |
687 | if (QUERY_FLAG (tmp, FLAG_NO_DROP)) |
701 | { |
688 | { |
702 | #if 0 |
689 | #if 0 |
703 | /* Eneq(@csd.uu.se): Objects with NO_DROP defined can't be dropped. */ |
690 | /* Eneq(@csd.uu.se): Objects with NO_DROP defined can't be dropped. */ |
704 | new_draw_info (NDI_UNIQUE, 0, op, "This item can't be dropped."); |
691 | new_draw_info (NDI_UNIQUE, 0, op, "This item can't be dropped."); |
… | |
… | |
728 | |
715 | |
729 | if (op->type == PLAYER) |
716 | if (op->type == PLAYER) |
730 | op->contr->count = 0; |
717 | op->contr->count = 0; |
731 | } |
718 | } |
732 | |
719 | |
733 | |
|
|
734 | |
|
|
735 | /* Command will drop all items that have not been locked */ |
720 | /* Command will drop all items that have not been locked */ |
736 | int |
721 | int |
737 | command_dropall (object *op, char *params) |
722 | command_dropall (object *op, char *params) |
738 | { |
723 | { |
739 | |
724 | |
740 | object *curinv, *nextinv; |
|
|
741 | |
|
|
742 | if (op->inv == NULL) |
725 | if (op->inv == NULL) |
743 | { |
726 | { |
744 | new_draw_info (NDI_UNIQUE, 0, op, "Nothing to drop!"); |
727 | new_draw_info (NDI_UNIQUE, 0, op, "Nothing to drop!"); |
745 | return 0; |
728 | return 0; |
746 | } |
729 | } |
747 | |
730 | |
748 | curinv = op->inv; |
731 | object *curinv = op->inv; |
|
|
732 | object *nextinv; |
749 | |
733 | |
750 | /* |
734 | /* |
751 | This is the default. Drops everything not locked or considered |
735 | This is the default. Drops everything not locked or considered |
752 | not something that should be dropped. |
736 | not something that should be dropped. |
753 | */ |
737 | */ |
… | |
… | |
757 | in a shop. --Tero.Pelander@utu.fi |
741 | in a shop. --Tero.Pelander@utu.fi |
758 | */ |
742 | */ |
759 | |
743 | |
760 | int cnt = MAX_ITEM_PER_DROP; |
744 | int cnt = MAX_ITEM_PER_DROP; |
761 | |
745 | |
762 | if (params == NULL) |
746 | if (!params) |
763 | { |
747 | { |
764 | while (curinv != NULL) |
748 | while (curinv) |
765 | { |
749 | { |
766 | nextinv = curinv->below; |
750 | nextinv = curinv->below; |
|
|
751 | |
767 | while (nextinv && nextinv->type == MONEY) |
752 | while (nextinv && nextinv->type == MONEY) |
768 | nextinv = nextinv->below; |
753 | nextinv = nextinv->below; |
|
|
754 | |
769 | if (!QUERY_FLAG (curinv, FLAG_INV_LOCKED) && curinv->type != MONEY && |
755 | if (!QUERY_FLAG (curinv, FLAG_INV_LOCKED) && curinv->type != MONEY && |
770 | curinv->type != FOOD && curinv->type != KEY && |
756 | curinv->type != FOOD && curinv->type != KEY && |
771 | curinv->type != SPECIAL_KEY && curinv->type != GEM && |
757 | curinv->type != SPECIAL_KEY && curinv->type != GEM && |
772 | !curinv->invisible && (curinv->type != CONTAINER || op->container != curinv)) |
758 | !curinv->invisible && (curinv->type != CONTAINER || op->container != curinv)) |
773 | { |
759 | { |
774 | drop (op, curinv); |
760 | drop (op, curinv); |
775 | if (--cnt <= 0) break; |
761 | if (--cnt <= 0) break; |
776 | } |
762 | } |
|
|
763 | |
777 | curinv = nextinv; |
764 | curinv = nextinv; |
778 | } |
765 | } |
779 | } |
766 | } |
780 | |
|
|
781 | else if (strcmp (params, "weapons") == 0) |
767 | else if (strcmp (params, "weapons") == 0) |
782 | { |
768 | { |
783 | while (curinv != NULL) |
769 | while (curinv) |
784 | { |
770 | { |
785 | nextinv = curinv->below; |
771 | nextinv = curinv->below; |
|
|
772 | |
786 | while (nextinv && nextinv->type == MONEY) |
773 | while (nextinv && nextinv->type == MONEY) |
787 | nextinv = nextinv->below; |
774 | nextinv = nextinv->below; |
|
|
775 | |
788 | if (!QUERY_FLAG (curinv, FLAG_INV_LOCKED) && ((curinv->type == WEAPON) || (curinv->type == BOW) || (curinv->type == ARROW))) |
776 | if (!QUERY_FLAG (curinv, FLAG_INV_LOCKED) && ((curinv->type == WEAPON) || (curinv->type == BOW) || (curinv->type == ARROW))) |
789 | { |
777 | { |
790 | drop (op, curinv); |
778 | drop (op, curinv); |
791 | if (--cnt <= 0) break; |
779 | if (--cnt <= 0) break; |
792 | } |
780 | } |
|
|
781 | |
793 | curinv = nextinv; |
782 | curinv = nextinv; |
794 | } |
783 | } |
795 | } |
784 | } |
796 | |
|
|
797 | else if (strcmp (params, "armor") == 0 || strcmp (params, "armour") == 0) |
785 | else if (strcmp (params, "armor") == 0 || strcmp (params, "armour") == 0) |
798 | { |
786 | { |
799 | while (curinv != NULL) |
787 | while (curinv) |
800 | { |
788 | { |
801 | nextinv = curinv->below; |
789 | nextinv = curinv->below; |
|
|
790 | |
802 | while (nextinv && nextinv->type == MONEY) |
791 | while (nextinv && nextinv->type == MONEY) |
803 | nextinv = nextinv->below; |
792 | nextinv = nextinv->below; |
|
|
793 | |
804 | if (!QUERY_FLAG (curinv, FLAG_INV_LOCKED) && ((curinv->type == ARMOUR) || curinv->type == SHIELD || curinv->type == HELMET)) |
794 | if (!QUERY_FLAG (curinv, FLAG_INV_LOCKED) && ((curinv->type == ARMOUR) || curinv->type == SHIELD || curinv->type == HELMET)) |
805 | { |
795 | { |
806 | drop (op, curinv); |
796 | drop (op, curinv); |
807 | if (--cnt <= 0) break; |
797 | if (--cnt <= 0) break; |
808 | } |
798 | } |
|
|
799 | |
809 | curinv = nextinv; |
800 | curinv = nextinv; |
810 | } |
801 | } |
811 | } |
802 | } |
812 | |
|
|
813 | else if (strcmp (params, "misc") == 0) |
803 | else if (strcmp (params, "misc") == 0) |
814 | { |
804 | { |
815 | while (curinv != NULL) |
805 | while (curinv) |
816 | { |
806 | { |
817 | nextinv = curinv->below; |
807 | nextinv = curinv->below; |
|
|
808 | |
818 | while (nextinv && nextinv->type == MONEY) |
809 | while (nextinv && nextinv->type == MONEY) |
819 | nextinv = nextinv->below; |
810 | nextinv = nextinv->below; |
|
|
811 | |
820 | if (!QUERY_FLAG (curinv, FLAG_INV_LOCKED) && !QUERY_FLAG (curinv, FLAG_APPLIED)) |
812 | if (!QUERY_FLAG (curinv, FLAG_INV_LOCKED) && !QUERY_FLAG (curinv, FLAG_APPLIED)) |
821 | { |
813 | { |
822 | switch (curinv->type) |
814 | switch (curinv->type) |
823 | { |
815 | { |
824 | case HORN: |
816 | case HORN: |
… | |
… | |
842 | break; |
834 | break; |
843 | default: |
835 | default: |
844 | curinv = nextinv; |
836 | curinv = nextinv; |
845 | break; |
837 | break; |
846 | } |
838 | } |
|
|
839 | |
847 | if (--cnt <= 0) break; |
840 | if (--cnt <= 0) break; |
848 | } |
841 | } |
|
|
842 | |
849 | curinv = nextinv; |
843 | curinv = nextinv; |
850 | } |
844 | } |
851 | } |
845 | } |
852 | |
846 | |
853 | if (cnt <= 0) |
847 | if (cnt <= 0) |
854 | op->failmsg ("Only dropped some items, can't drop that many items at once."); |
848 | op->failmsg ("Only dropped some items, can't drop that many items at once."); |
855 | |
|
|
856 | update_after_inventory_change (op); |
|
|
857 | |
849 | |
858 | /* draw_look(op);*/ |
850 | /* draw_look(op);*/ |
859 | return 0; |
851 | return 0; |
860 | } |
852 | } |
861 | |
853 | |
862 | /* Object op wants to drop object(s) params. params can be a |
854 | /* Object op wants to drop object(s) params. params can be a |
863 | * comma seperated list. |
855 | * comma seperated list. |
864 | */ |
856 | */ |
865 | |
|
|
866 | int |
857 | int |
867 | command_drop (object *op, char *params) |
858 | command_drop (object *op, char *params) |
868 | { |
859 | { |
869 | object *tmp, *next; |
860 | object *tmp, *next; |
870 | int did_one = 0; |
861 | int did_one = 0; |
… | |
… | |
895 | if (!did_one) |
886 | if (!did_one) |
896 | new_draw_info (NDI_UNIQUE, 0, op, "Nothing to drop."); |
887 | new_draw_info (NDI_UNIQUE, 0, op, "Nothing to drop."); |
897 | |
888 | |
898 | if (cnt <= 0) |
889 | if (cnt <= 0) |
899 | op->failmsg ("Only dropped some items, can't drop that many items at once."); |
890 | op->failmsg ("Only dropped some items, can't drop that many items at once."); |
900 | |
|
|
901 | update_after_inventory_change (op); |
|
|
902 | } |
891 | } |
903 | |
892 | |
904 | return 0; |
893 | return 0; |
905 | } |
894 | } |
906 | |
895 | |
… | |
… | |
981 | dynbuf_text buf (512, 512); |
970 | dynbuf_text buf (512, 512); |
982 | |
971 | |
983 | object *mon = head ? head : this; |
972 | object *mon = head ? head : this; |
984 | |
973 | |
985 | if (QUERY_FLAG (mon, FLAG_UNDEAD)) |
974 | if (QUERY_FLAG (mon, FLAG_UNDEAD)) |
986 | buf << "It is an undead force.\n"; |
975 | buf << " - It is an undead force.\n"; |
987 | |
976 | |
988 | if (mon->level > who->level) |
977 | if (mon->level > who->level) |
989 | buf << "It is likely more powerful than you.\n"; |
978 | buf << " - It is likely more powerful than you.\n"; |
990 | else if (mon->level < who->level) |
979 | else if (mon->level < who->level) |
991 | buf << "It is likely less powerful than you.\n"; |
980 | buf << " - It is likely less powerful than you.\n"; |
992 | else |
981 | else |
993 | buf << "It is probably as powerful as you.\n"; |
982 | buf << " - It is probably as powerful as you.\n"; |
994 | |
983 | |
995 | if (mon->attacktype & AT_ACID) |
984 | if (mon->attacktype & AT_ACID) |
996 | buf << "You seem to smell an acrid odor.\n"; |
985 | buf << " - You seem to smell an acrid odor.\n"; |
997 | |
986 | |
998 | /* Anyone know why this used to use the clone value instead of the |
987 | /* Anyone know why this used to use the clone value instead of the |
999 | * maxhp field? This seems that it should give more accurate results. |
988 | * maxhp field? This seems that it should give more accurate results. |
1000 | */ |
989 | */ |
1001 | switch ((mon->stats.hp + 1) * 4 / (mon->stats.maxhp + 1)) |
990 | switch ((mon->stats.hp + 1) * 4 / (mon->stats.maxhp + 1)) |
1002 | { /* From 1-4 */ |
991 | { /* From 1-4 */ |
1003 | case 1: |
992 | case 1: |
1004 | buf << "It is in a bad shape.\n"; |
993 | buf << " - It is in a bad shape.\n"; |
1005 | break; |
994 | break; |
1006 | case 2: |
995 | case 2: |
1007 | buf << "It is hurt.\n"; |
996 | buf << " - It is hurt.\n"; |
1008 | break; |
997 | break; |
1009 | case 3: |
998 | case 3: |
1010 | buf << "It is somewhat hurt.\n"; |
999 | buf << " - It is somewhat hurt.\n"; |
1011 | break; |
1000 | break; |
1012 | case 4: |
1001 | case 4: |
1013 | buf << "It is in excellent shape.\n"; |
1002 | buf << " - It is in excellent shape.\n"; |
1014 | break; |
1003 | break; |
1015 | } |
1004 | } |
1016 | |
1005 | |
1017 | if (present_in_ob (POISONING, mon)) |
1006 | if (present_in_ob (POISONING, mon)) |
1018 | buf << "It looks very ill.\n"; |
1007 | buf << " - It looks very ill.\n"; |
1019 | |
1008 | |
1020 | return buf; |
1009 | return buf; |
1021 | } |
1010 | } |
1022 | |
1011 | |
1023 | /* tmp is the object being described, pl is who is examing it. */ |
1012 | /* tmp is the object being described, pl is who is examing it. */ |
… | |
… | |
1081 | std::string |
1070 | std::string |
1082 | object::describe (object *who) |
1071 | object::describe (object *who) |
1083 | { |
1072 | { |
1084 | dynbuf_text buf (1024, 1024); |
1073 | dynbuf_text buf (1024, 1024); |
1085 | |
1074 | |
1086 | buf.printf ("That is: %s.\n", long_desc (who).c_str ()); |
1075 | buf.printf ("That is: %s.\n\n", long_desc (who).c_str ()); |
1087 | |
1076 | |
1088 | if (custom_name) |
1077 | if (custom_name) |
1089 | buf.printf ("You call it %s\n", &custom_name); |
1078 | buf.printf ("You call it %s.\n\n", &custom_name); |
1090 | |
1079 | |
1091 | switch (type) |
1080 | switch (type) |
1092 | { |
1081 | { |
1093 | case SPELLBOOK: |
1082 | case SPELLBOOK: |
1094 | if (flag [FLAG_IDENTIFIED] && inv) |
1083 | if (flag [FLAG_IDENTIFIED] && inv) |
1095 | buf.printf ("%s is a %s %s spell\n", &inv->name, get_levelnumber (inv->level), &inv->skill); |
1084 | buf.printf ("%s is a %s %s spell.\n", &inv->name, get_levelnumber (inv->level), &inv->skill); |
1096 | break; |
1085 | break; |
1097 | |
1086 | |
1098 | case BOOK: |
1087 | case BOOK: |
1099 | if (msg) |
1088 | if (msg) |
1100 | buf << "Something is written in it.\n"; |
1089 | buf << "Something is written in it.\n"; |
… | |
… | |
1159 | buf << "This is a buildable item.\n"; |
1148 | buf << "This is a buildable item.\n"; |
1160 | |
1149 | |
1161 | /* Does the object have a message? Don't show message for all object |
1150 | /* Does the object have a message? Don't show message for all object |
1162 | * types - especially if the first entry is a match |
1151 | * types - especially if the first entry is a match |
1163 | */ |
1152 | */ |
1164 | if (msg && type != EXIT && type != BOOK && type != CORPSE && !move_on && *msg != '@') |
1153 | if (msg && type != EXIT && type != BOOK && type != CORPSE && !move_on && !has_dialogue ()) |
1165 | { |
1154 | { |
1166 | /* This is just a hack so when identifying the items, we print |
1155 | /* This is just a hack so when identifying the items, we print |
1167 | * out the extra message |
1156 | * out the extra message |
1168 | */ |
1157 | */ |
1169 | if (need_identify (this) && flag [FLAG_IDENTIFIED]) |
1158 | if (need_identify (this) && flag [FLAG_IDENTIFIED]) |
1170 | buf << "The object has a story:\n"; |
1159 | buf << "The object has a story:\n\n"; |
1171 | |
1160 | |
1172 | buf << msg << '\n'; |
1161 | buf << msg << '\n'; |
1173 | } |
1162 | } |
1174 | |
1163 | |
1175 | buf << '\n'; |
1164 | buf << '\n'; |