… | |
… | |
605 | return; |
605 | return; |
606 | |
606 | |
607 | if (obj->destroyed () || obj->is_inserted ()) |
607 | if (obj->destroyed () || obj->is_inserted ()) |
608 | return; |
608 | return; |
609 | |
609 | |
610 | if (is_in_shop (dropper) && !QUERY_FLAG (obj, FLAG_UNPAID) && obj->type != MONEY) |
610 | if (dropper->is_in_shop () && !QUERY_FLAG (obj, FLAG_UNPAID) && obj->type != MONEY) |
611 | if (!sell_item (obj, dropper)) |
611 | if (!sell_item (obj, dropper)) |
612 | return; |
612 | return; |
613 | |
613 | |
614 | if (!obj->can_drop_at (dropper->map, dropper->x, dropper->y, dropper)) |
614 | if (!obj->can_drop_at (dropper->map, dropper->x, dropper->y, dropper)) |
615 | return; |
615 | return; |
… | |
… | |
1102 | { |
1102 | { |
1103 | new_draw_info (NDI_UNIQUE, 0, op, tmp->describe_monster (op).c_str ()); |
1103 | new_draw_info (NDI_UNIQUE, 0, op, tmp->describe_monster (op).c_str ()); |
1104 | } |
1104 | } |
1105 | |
1105 | |
1106 | static void |
1106 | static void |
1107 | describe_dump_object (dynbuf &buf, object *ob) |
|
|
1108 | { |
|
|
1109 | char *txt = dump_object (ob); |
|
|
1110 | for (char *p = txt; *p; ++p) if (*p == '\n') *p = '\r'; |
|
|
1111 | buf << "\n" << txt << "\n"; |
|
|
1112 | |
|
|
1113 | if (!ob->is_arch ()) |
|
|
1114 | describe_dump_object (buf, ob->arch); |
|
|
1115 | } |
|
|
1116 | |
|
|
1117 | std::string |
|
|
1118 | object::describe (object *who) |
|
|
1119 | { |
|
|
1120 | dynbuf_text buf (1024, 1024); |
|
|
1121 | |
|
|
1122 | buf.printf ("That is: %s.\r", long_desc (who).c_str ()); |
|
|
1123 | |
|
|
1124 | if (custom_name) |
|
|
1125 | buf.printf ("You call it %s.\r", &custom_name); |
|
|
1126 | |
|
|
1127 | switch (type) |
|
|
1128 | { |
|
|
1129 | case SPELLBOOK: |
|
|
1130 | if (flag [FLAG_IDENTIFIED] && inv) |
|
|
1131 | buf.printf ("%s is a level %s %s spell.\r", &inv->name, get_levelnumber (inv->level), &inv->skill); |
|
|
1132 | break; |
|
|
1133 | |
|
|
1134 | case BOOK: |
|
|
1135 | if (msg) |
|
|
1136 | buf << "Something is written in it.\r"; |
|
|
1137 | break; |
|
|
1138 | |
|
|
1139 | case CONTAINER: |
|
|
1140 | if (race) |
|
|
1141 | { |
|
|
1142 | if (weight_limit && stats.Str < 100) |
|
|
1143 | buf.printf ("It can hold only %s and its weight limit is %.1f kg.\r", |
|
|
1144 | &race, weight_limit / (10.0 * (100 - stats.Str))); |
|
|
1145 | else |
|
|
1146 | buf.printf ("It can hold only %s.\r", &race); |
|
|
1147 | } |
|
|
1148 | else if (weight_limit && stats.Str < 100) |
|
|
1149 | buf.printf ("Its weight limit is %.1f kg.\r", weight_limit / (10.0 * (100 - stats.Str))); |
|
|
1150 | break; |
|
|
1151 | |
|
|
1152 | case WAND: |
|
|
1153 | if (flag [FLAG_IDENTIFIED]) |
|
|
1154 | buf.printf ("It has %d %s left.\r", stats.food, stats.food == 1 ? "charge" : "charges"); |
|
|
1155 | break; |
|
|
1156 | } |
|
|
1157 | |
|
|
1158 | if (material != MATERIAL_NULL && !msg) |
|
|
1159 | buf << (nrof > 1 ? "They are made of " : "It is made of ") |
|
|
1160 | << material->description |
|
|
1161 | << ".\r"; |
|
|
1162 | |
|
|
1163 | if (who) |
|
|
1164 | /* Where to wear this item */ |
|
|
1165 | for (int i = 0; i < NUM_BODY_LOCATIONS; i++) |
|
|
1166 | if (slot[i].info) |
|
|
1167 | { |
|
|
1168 | buf << (who->slot[i].info ? body_locations[i].use_name : body_locations[i].nonuse_name); |
|
|
1169 | |
|
|
1170 | if (slot[i].info < -1 && who->slot[i].info) |
|
|
1171 | buf.printf ("(%d)", -slot[i].info); |
|
|
1172 | |
|
|
1173 | buf << ".\r"; |
|
|
1174 | } |
|
|
1175 | |
|
|
1176 | if (weight) |
|
|
1177 | buf.printf ("%s %3.3f kg.\r", nrof > 1 ? "They weigh" : "It weighs", weight * (nrof ? nrof : 1) / 1000.0); |
|
|
1178 | |
|
|
1179 | if (flag [FLAG_STARTEQUIP]) |
|
|
1180 | buf << (nrof > 1 ? "They were" : "It was") |
|
|
1181 | << " given by a god and will vanish when dropped.\r"; |
|
|
1182 | |
|
|
1183 | if (value && !flag [FLAG_STARTEQUIP] && !flag [FLAG_NO_PICK] && who) |
|
|
1184 | { |
|
|
1185 | buf.printf ("You reckon %s worth %s.\r", nrof > 1 ? "they are" : "it is", query_cost_string (this, who, F_TRUE | F_APPROX)); |
|
|
1186 | |
|
|
1187 | if (is_in_shop (who)) |
|
|
1188 | { |
|
|
1189 | if (flag [FLAG_UNPAID]) |
|
|
1190 | buf.printf ("%s would cost you %s.\r", nrof > 1 ? "They" : "It", query_cost_string (this, who, F_BUY | F_SHOP)); |
|
|
1191 | else |
|
|
1192 | buf.printf ("You are offered %s for %s.\r", query_cost_string (this, who, F_SELL + F_SHOP), nrof > 1 ? "them" : "it"); |
|
|
1193 | } |
|
|
1194 | } |
|
|
1195 | |
|
|
1196 | if (flag [FLAG_MONSTER]) |
|
|
1197 | buf << describe_monster (who); |
|
|
1198 | |
|
|
1199 | /* Is this item buildable? */ |
|
|
1200 | if (flag [FLAG_IS_BUILDABLE]) |
|
|
1201 | buf << "This is a buildable item.\r"; |
|
|
1202 | |
|
|
1203 | /* Does the object have a message? Don't show message for all object |
|
|
1204 | * types - especially if the first entry is a match |
|
|
1205 | */ |
|
|
1206 | if (msg) |
|
|
1207 | { |
|
|
1208 | if (type != EXIT && type != BOOK && type != CORPSE && !move_on && !has_dialogue ()) |
|
|
1209 | { |
|
|
1210 | buf << '\r'; |
|
|
1211 | |
|
|
1212 | /* This is just a hack so when identifying the items, we print |
|
|
1213 | * out the extra message |
|
|
1214 | */ |
|
|
1215 | if (need_identify (this) && flag [FLAG_IDENTIFIED]) |
|
|
1216 | buf << "The object has a story:\r"; |
|
|
1217 | |
|
|
1218 | buf << msg << '\n'; |
|
|
1219 | } |
|
|
1220 | } |
|
|
1221 | else if (inv && inv->type == SPELL && flag [FLAG_IDENTIFIED] |
|
|
1222 | && (type == SPELLBOOK || type == ROD || type == WAND |
|
|
1223 | || type == ROD || type == POTION || type == SCROLL)) |
|
|
1224 | // for spellbooks and other stuff that contains spells, print the spell message, |
|
|
1225 | // unless the object has a custom message handled above. |
|
|
1226 | buf << '\r' << inv->msg << '\n'; |
|
|
1227 | |
|
|
1228 | // try to display the duration for some potions and scrolls |
|
|
1229 | // this includes change ability potions and group spells, |
|
|
1230 | // but does not handle protection potions |
|
|
1231 | if (inv && inv->type == SPELL && flag [FLAG_IDENTIFIED] |
|
|
1232 | && (type == POTION || type == SCROLL)) |
|
|
1233 | { |
|
|
1234 | object *spell = inv; |
|
|
1235 | |
|
|
1236 | if (spell->subtype == SP_PARTY_SPELL) |
|
|
1237 | spell = spell->other_arch; |
|
|
1238 | |
|
|
1239 | if (spell->subtype == SP_CHANGE_ABILITY) |
|
|
1240 | buf.printf ("\nH<The effect will last about %.10g seconds.>", |
|
|
1241 | TICK2TIME (change_ability_duration (spell, this))); |
|
|
1242 | } |
|
|
1243 | |
|
|
1244 | // Display a hint about inscribable items [empty books] |
|
|
1245 | // This includes the amount of text they can hold. |
|
|
1246 | if (type == INSCRIBABLE) |
|
|
1247 | { |
|
|
1248 | if (other_arch && other_arch->type == SCROLL) |
|
|
1249 | buf.printf ("\nH<You can use the inscription skill to inscribe a spell into it.>"); |
|
|
1250 | else |
|
|
1251 | buf.printf ("\nH<You can use the inscription skill to inscribe text into it. It has room for up to %d characters.>", |
|
|
1252 | weight_limit); |
|
|
1253 | } |
|
|
1254 | |
|
|
1255 | buf << '\n'; |
|
|
1256 | |
|
|
1257 | // the dungeon master additionally gets a complete dump |
|
|
1258 | if (who && who->flag [FLAG_WIZLOOK]) |
|
|
1259 | { |
|
|
1260 | buf << "\nT<Object>\n"; |
|
|
1261 | describe_dump_object (buf, this); |
|
|
1262 | |
|
|
1263 | if (inv) |
|
|
1264 | { |
|
|
1265 | buf << "\nT<Top Inventory>\n"; |
|
|
1266 | describe_dump_object (buf, inv); |
|
|
1267 | } |
|
|
1268 | } |
|
|
1269 | |
|
|
1270 | return std::string (buf.linearise (), buf.size ()); |
|
|
1271 | } |
|
|
1272 | |
|
|
1273 | static void |
|
|
1274 | display_new_pickup (object *op) |
1107 | display_new_pickup (object *op) |
1275 | { |
1108 | { |
1276 | int i = op->contr->mode; |
1109 | int i = op->contr->mode; |
1277 | |
1110 | |
1278 | new_draw_info_format (NDI_UNIQUE, 0, op, "%d DEBUG", i & PU_DEBUG ? 1 : 0); |
1111 | new_draw_info_format (NDI_UNIQUE, 0, op, "%d DEBUG", i & PU_DEBUG ? 1 : 0); |