… | |
… | |
484 | * but that probably will make it more difficult to read, and |
484 | * but that probably will make it more difficult to read, and |
485 | * not make it any more efficient |
485 | * not make it any more efficient |
486 | */ |
486 | */ |
487 | if (params && item_matched_string (op, tmp, params)) |
487 | if (params && item_matched_string (op, tmp, params)) |
488 | { |
488 | { |
|
|
489 | if (--cnt < 0) break; |
489 | pick_up (op, tmp); |
490 | pick_up (op, tmp); |
490 | if (--cnt <= 0) break; |
|
|
491 | } |
491 | } |
492 | else if (can_pick (op, tmp) && !params) |
492 | else if (can_pick (op, tmp) && !params) |
493 | { |
493 | { |
|
|
494 | if (--cnt < 0) break; |
494 | pick_up (op, tmp); |
495 | pick_up (op, tmp); |
495 | break; |
496 | break; |
496 | } |
497 | } |
497 | |
498 | |
498 | tmp = next; |
499 | tmp = next; |
499 | } |
500 | } |
500 | |
501 | |
501 | if (cnt <= 0) |
502 | if (cnt < 0) |
502 | { |
503 | { |
503 | op->failmsg ("Couldn't pick up so many items at once."); |
504 | op->failmsg ("Couldn't pick up so many items at once."); |
504 | return 0; |
505 | return 0; |
505 | } |
506 | } |
506 | |
507 | |
… | |
… | |
606 | |
607 | |
607 | /* We are only dropping some of the items. We split the current object |
608 | /* We are only dropping some of the items. We split the current object |
608 | * off |
609 | * off |
609 | */ |
610 | */ |
610 | if (!can_split (op, tmp, nrof)) |
611 | if (!can_split (op, tmp, nrof)) |
|
|
612 | return; |
611 | |
613 | |
612 | if (INVOKE_OBJECT (DROP, tmp, ARG_OBJECT (op))) |
614 | if (INVOKE_OBJECT (DROP, tmp, ARG_OBJECT (op))) |
613 | return; |
615 | return; |
614 | |
616 | |
615 | if (QUERY_FLAG (tmp, FLAG_STARTEQUIP)) |
617 | if (QUERY_FLAG (tmp, FLAG_STARTEQUIP)) |
616 | { |
618 | { |
617 | op->statusmsg (format ("You drop the %s.", query_name (tmp))); |
619 | op->statusmsg (format ("You drop the %s.", query_name (tmp))); |
618 | op->statusmsg ("The gods who lent it to you retrieves it."); |
620 | op->statusmsg ("The god who lent it to you retrieves it."); |
619 | |
621 | |
620 | tmp->destroy (); |
622 | tmp->destroy (); |
621 | op->update_stats (); |
623 | op->update_stats (); |
622 | return; |
624 | return; |
623 | } |
625 | } |
… | |
… | |
633 | return; |
635 | return; |
634 | |
636 | |
635 | if (is_in_shop (op) && !QUERY_FLAG (tmp, FLAG_UNPAID) && tmp->type != MONEY) |
637 | if (is_in_shop (op) && !QUERY_FLAG (tmp, FLAG_UNPAID) && tmp->type != MONEY) |
636 | { |
638 | { |
637 | if (!sell_item (tmp, op)) |
639 | if (!sell_item (tmp, op)) |
638 | return; // if we can't sell it we don't drop it |
640 | { |
|
|
641 | // if we can't sell it we don't drop it, so give it back to the seller |
|
|
642 | op->insert (tmp); |
|
|
643 | return; |
|
|
644 | } |
639 | } |
645 | } |
640 | |
646 | |
641 | tmp->x = op->x; |
647 | tmp->x = op->x; |
642 | tmp->y = op->y; |
648 | tmp->y = op->y; |
643 | |
649 | |
… | |
… | |
658 | if (tmp->env && tmp->env->type != PLAYER) |
664 | if (tmp->env && tmp->env->type != PLAYER) |
659 | { |
665 | { |
660 | /* Just toss the object - probably shouldn't be hanging |
666 | /* Just toss the object - probably shouldn't be hanging |
661 | * around anyways |
667 | * around anyways |
662 | */ |
668 | */ |
663 | tmp->remove (); |
|
|
664 | tmp->destroy (); |
669 | tmp->destroy (); |
665 | return; |
670 | return; |
666 | } |
671 | } |
667 | else |
672 | else |
668 | { |
673 | { |
… | |
… | |
969 | dynbuf_text buf (512, 512); |
974 | dynbuf_text buf (512, 512); |
970 | |
975 | |
971 | object *mon = head ? head : this; |
976 | object *mon = head ? head : this; |
972 | |
977 | |
973 | if (QUERY_FLAG (mon, FLAG_UNDEAD)) |
978 | if (QUERY_FLAG (mon, FLAG_UNDEAD)) |
974 | buf << "It is an undead force.\n"; |
979 | buf << "It is an undead force.\r"; |
975 | |
980 | |
976 | if (mon->level > who->level) |
981 | if (mon->level > who->level) |
977 | buf << "It is likely more powerful than you.\n"; |
982 | buf << "It is likely more powerful than you.\r"; |
978 | else if (mon->level < who->level) |
983 | else if (mon->level < who->level) |
979 | buf << "It is likely less powerful than you.\n"; |
984 | buf << "It is likely less powerful than you.\r"; |
980 | else |
985 | else |
981 | buf << "It is probably as powerful as you.\n"; |
986 | buf << "It is probably as powerful as you.\r"; |
982 | |
987 | |
983 | if (mon->attacktype & AT_ACID) |
988 | if (mon->attacktype & AT_ACID) |
984 | buf << "You seem to smell an acrid odor.\n"; |
989 | buf << "You seem to smell an acrid odor.\r"; |
985 | |
990 | |
986 | /* Anyone know why this used to use the clone value instead of the |
991 | /* Anyone know why this used to use the clone value instead of the |
987 | * maxhp field? This seems that it should give more accurate results. |
992 | * maxhp field? This seems that it should give more accurate results. |
988 | */ |
993 | */ |
989 | switch ((mon->stats.hp + 1) * 4 / (mon->stats.maxhp + 1)) |
994 | switch ((mon->stats.hp + 1) * 4 / (mon->stats.maxhp + 1)) |
990 | { /* From 1-4 */ |
995 | { /* From 1-4 */ |
991 | case 1: |
996 | case 1: |
992 | buf << "It is in a bad shape.\n"; |
997 | buf << "It is in a bad shape.\r"; |
993 | break; |
998 | break; |
994 | case 2: |
999 | case 2: |
995 | buf << "It is hurt.\n"; |
1000 | buf << "It is hurt.\r"; |
996 | break; |
1001 | break; |
997 | case 3: |
1002 | case 3: |
998 | buf << "It is somewhat hurt.\n"; |
1003 | buf << "It is somewhat hurt.\r"; |
999 | break; |
1004 | break; |
1000 | case 4: |
1005 | case 4: |
1001 | buf << "It is in excellent shape.\n"; |
1006 | buf << "It is in excellent shape.\r"; |
1002 | break; |
1007 | break; |
1003 | } |
1008 | } |
1004 | |
1009 | |
1005 | if (present_in_ob (POISONING, mon)) |
1010 | if (present_in_ob (POISONING, mon)) |
1006 | buf << "It looks very ill.\n"; |
1011 | buf << "It looks very ill.\r"; |
|
|
1012 | |
|
|
1013 | buf << '\n'; |
1007 | |
1014 | |
1008 | return buf; |
1015 | return buf; |
1009 | } |
1016 | } |
1010 | |
1017 | |
1011 | /* tmp is the object being described, pl is who is examing it. */ |
1018 | /* tmp is the object being described, pl is who is examing it. */ |
… | |
… | |
1069 | std::string |
1076 | std::string |
1070 | object::describe (object *who) |
1077 | object::describe (object *who) |
1071 | { |
1078 | { |
1072 | dynbuf_text buf (1024, 1024); |
1079 | dynbuf_text buf (1024, 1024); |
1073 | |
1080 | |
1074 | buf.printf ("That is: %s.\n", long_desc (who).c_str ()); |
1081 | buf.printf ("That is: %s.\r", long_desc (who).c_str ()); |
1075 | |
1082 | |
1076 | if (custom_name) |
1083 | if (custom_name) |
1077 | buf.printf ("You call it %s\n", &custom_name); |
1084 | buf.printf ("You call it %s.\r", &custom_name); |
1078 | |
1085 | |
1079 | switch (type) |
1086 | switch (type) |
1080 | { |
1087 | { |
1081 | case SPELLBOOK: |
1088 | case SPELLBOOK: |
1082 | if (flag [FLAG_IDENTIFIED] && inv) |
1089 | if (flag [FLAG_IDENTIFIED] && inv) |
1083 | buf.printf ("%s is a %s %s spell\n", &inv->name, get_levelnumber (inv->level), &inv->skill); |
1090 | buf.printf ("%s is a %s %s spell.\r", &inv->name, get_levelnumber (inv->level), &inv->skill); |
1084 | break; |
1091 | break; |
1085 | |
1092 | |
1086 | case BOOK: |
1093 | case BOOK: |
1087 | if (msg) |
1094 | if (msg) |
1088 | buf << "Something is written in it.\n"; |
1095 | buf << "Something is written in it.\r"; |
1089 | break; |
1096 | break; |
1090 | |
1097 | |
1091 | case CONTAINER: |
1098 | case CONTAINER: |
1092 | if (race != NULL) |
1099 | if (race) |
1093 | { |
1100 | { |
1094 | if (weight_limit && stats.Str < 100) |
1101 | if (weight_limit && stats.Str < 100) |
1095 | buf.printf ("It can hold only %s and its weight limit is %.1f kg.\n", |
1102 | buf.printf ("It can hold only %s and its weight limit is %.1f kg.\r", |
1096 | &race, weight_limit / (10.0 * (100 - stats.Str))); |
1103 | &race, weight_limit / (10.0 * (100 - stats.Str))); |
1097 | else |
1104 | else |
1098 | buf.printf ("It can hold only %s.\n", &race); |
1105 | buf.printf ("It can hold only %s.\r", &race); |
1099 | } |
1106 | } |
1100 | else if (weight_limit && stats.Str < 100) |
1107 | else if (weight_limit && stats.Str < 100) |
1101 | buf.printf ("Its weight limit is %.1f kg.\n", weight_limit / (10.0 * (100 - stats.Str))); |
1108 | buf.printf ("Its weight limit is %.1f kg.\r", weight_limit / (10.0 * (100 - stats.Str))); |
1102 | break; |
1109 | break; |
1103 | |
1110 | |
1104 | case WAND: |
1111 | case WAND: |
1105 | if (flag [FLAG_IDENTIFIED]) |
1112 | if (flag [FLAG_IDENTIFIED]) |
1106 | buf.printf ("It has %d charges left.\n", stats.food); |
1113 | buf.printf ("It has %d charges left.\r", stats.food); |
1107 | break; |
1114 | break; |
1108 | } |
1115 | } |
1109 | |
1116 | |
1110 | if (materialname && !msg) |
1117 | if (materialname && !msg) |
1111 | buf.printf ("It is made of: %s.\n", &materialname); |
1118 | buf.printf ("It is made of: %s.\r", &materialname); |
1112 | |
1119 | |
1113 | if (who) |
1120 | if (who) |
1114 | /* Where to wear this item */ |
1121 | /* Where to wear this item */ |
1115 | for (int i = 0; i < NUM_BODY_LOCATIONS; i++) |
1122 | for (int i = 0; i < NUM_BODY_LOCATIONS; i++) |
1116 | if (slot[i].info) |
1123 | if (slot[i].info) |
… | |
… | |
1118 | buf << (who->slot[i].info ? body_locations[i].use_name : body_locations[i].nonuse_name); |
1125 | buf << (who->slot[i].info ? body_locations[i].use_name : body_locations[i].nonuse_name); |
1119 | |
1126 | |
1120 | if (slot[i].info < -1 && who->slot[i].info) |
1127 | if (slot[i].info < -1 && who->slot[i].info) |
1121 | buf.printf ("(%d)", -slot[i].info); |
1128 | buf.printf ("(%d)", -slot[i].info); |
1122 | |
1129 | |
1123 | buf << ".\n"; |
1130 | buf << ".\r"; |
1124 | } |
1131 | } |
1125 | |
1132 | |
1126 | if (weight) |
1133 | if (weight) |
1127 | buf.printf (nrof > 1 ? "They weigh %3.3f kg.\n" : "It weighs %3.3f kg.\n", weight * (nrof ? nrof : 1) / 1000.0); |
1134 | buf.printf ("%s %3.3f kg.\r", nrof > 1 ? "They weigh" : "It weighs", weight * (nrof ? nrof : 1) / 1000.0); |
1128 | |
1135 | |
1129 | if (value && !flag [FLAG_STARTEQUIP] && !flag [FLAG_NO_PICK] && who) |
1136 | if (value && !flag [FLAG_STARTEQUIP] && !flag [FLAG_NO_PICK] && who) |
1130 | { |
1137 | { |
1131 | buf.printf ("You reckon %s worth %s.\n", nrof > 1 ? "they are" : "it is", query_cost_string (this, who, F_TRUE | F_APPROX)); |
1138 | buf.printf ("You reckon %s worth %s.\r", nrof > 1 ? "they are" : "it is", query_cost_string (this, who, F_TRUE | F_APPROX)); |
1132 | |
1139 | |
1133 | if (is_in_shop (who)) |
1140 | if (is_in_shop (who)) |
1134 | { |
1141 | { |
1135 | if (flag [FLAG_UNPAID]) |
1142 | if (flag [FLAG_UNPAID]) |
1136 | buf.printf ("%s would cost you %s.\n", nrof > 1 ? "They" : "It", query_cost_string (this, who, F_BUY | F_SHOP)); |
1143 | buf.printf ("%s would cost you %s.\r", nrof > 1 ? "They" : "It", query_cost_string (this, who, F_BUY | F_SHOP)); |
1137 | else |
1144 | else |
1138 | buf.printf ("You are offered %s for %s.\n", query_cost_string (this, who, F_SELL + F_SHOP), nrof > 1 ? "them" : "it"); |
1145 | buf.printf ("You are offered %s for %s.\r", query_cost_string (this, who, F_SELL + F_SHOP), nrof > 1 ? "them" : "it"); |
1139 | } |
1146 | } |
1140 | } |
1147 | } |
1141 | |
1148 | |
1142 | if (flag [FLAG_MONSTER]) |
1149 | if (flag [FLAG_MONSTER]) |
1143 | buf << describe_monster (who); |
1150 | buf << describe_monster (who); |
1144 | |
1151 | |
1145 | /* Is this item buildable? */ |
1152 | /* Is this item buildable? */ |
1146 | if (flag [FLAG_IS_BUILDABLE]) |
1153 | if (flag [FLAG_IS_BUILDABLE]) |
1147 | buf << "This is a buildable item.\n"; |
1154 | buf << "This is a buildable item.\r"; |
1148 | |
1155 | |
1149 | /* Does the object have a message? Don't show message for all object |
1156 | /* Does the object have a message? Don't show message for all object |
1150 | * types - especially if the first entry is a match |
1157 | * types - especially if the first entry is a match |
1151 | */ |
1158 | */ |
1152 | if (msg && type != EXIT && type != BOOK && type != CORPSE && !move_on && *msg != '@') |
1159 | if (msg && type != EXIT && type != BOOK && type != CORPSE && !move_on && !has_dialogue ()) |
1153 | { |
1160 | { |
1154 | /* This is just a hack so when identifying the items, we print |
1161 | /* This is just a hack so when identifying the items, we print |
1155 | * out the extra message |
1162 | * out the extra message |
1156 | */ |
1163 | */ |
1157 | if (need_identify (this) && flag [FLAG_IDENTIFIED]) |
1164 | if (need_identify (this) && flag [FLAG_IDENTIFIED]) |
1158 | buf << "The object has a story:\n"; |
1165 | buf << "The object has a story:\r"; |
1159 | |
1166 | |
1160 | buf << msg << '\n'; |
1167 | buf << msg << '\n'; |
1161 | } |
1168 | } |
1162 | |
1169 | |
1163 | buf << '\n'; |
1170 | buf << '\n'; |