1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
|
|
4 | * Copyright (©) 2017,2018 Marc Alexander Lehmann / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * |
8 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * the terms of the Affero GNU General Public License as published by the |
10 | * the terms of the Affero GNU General Public License as published by the |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * option) any later version. |
12 | * option) any later version. |
12 | * |
13 | * |
13 | * This program is distributed in the hope that it will be useful, |
14 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. |
17 | * GNU General Public License for more details. |
17 | * |
18 | * |
18 | * You should have received a copy of the Affero GNU General Public License |
19 | * You should have received a copy of the Affero GNU General Public License |
19 | * and the GNU General Public License along with this program. If not, see |
20 | * and the GNU General Public License along with this program. If not, see |
20 | * <http://www.gnu.org/licenses/>. |
21 | * <http://www.gnu.org/licenses/>. |
21 | * |
22 | * |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
23 | * The authors can be reached via e-mail to <support@deliantra.net> |
23 | */ |
24 | */ |
24 | |
25 | |
25 | #include <global.h> |
26 | #include <global.h> |
26 | #include <living.h> |
27 | #include <living.h> |
… | |
… | |
49 | * Basically, for the use/nonuse, the code does something like: |
50 | * Basically, for the use/nonuse, the code does something like: |
50 | * "This item goes %s\n", with the use/nonuse values filling in the %s |
51 | * "This item goes %s\n", with the use/nonuse values filling in the %s |
51 | */ |
52 | */ |
52 | // see include/object.h |
53 | // see include/object.h |
53 | Body_Locations body_locations[NUM_BODY_LOCATIONS] = { |
54 | Body_Locations body_locations[NUM_BODY_LOCATIONS] = { |
54 | {KW_body_skill , "You can use it as your skill" , "It is used as a skill"}, |
55 | # define def(name, use, nonuse) { # name, KW_body_ ## name, use, nonuse }, |
55 | {KW_body_combat , "You can wield it as your weapon" , "It is used as a combat weapon"}, |
56 | # include "slotinc.h" |
56 | {KW_body_range , "You can use it as your range weapon" , "It is used as a range weapon"}, |
57 | # undef def |
57 | {KW_body_shield , "You can wield it as a shield" , "It is used as a shield"}, |
|
|
58 | {KW_body_arm , "You can put it on your arm" , "It goes on a human's arm"}, |
|
|
59 | {KW_body_torso , "You can wear it on your body" , "It goes on a human's torso"}, |
|
|
60 | {KW_body_head , "You can wear it on your head" , "It goes on a human's head"}, |
|
|
61 | {KW_body_neck , "You can wear it around your neck" , "It goes around a human's neck"}, |
|
|
62 | {KW_body_finger , "You can wear it on your finger" , "It goes on a human's finger"} , |
|
|
63 | {KW_body_shoulder, "You can wear it around your shoulders", "It goes around a human's shoulders"}, |
|
|
64 | {KW_body_foot , "You can put it on your foot" , "It goes on a human's foot"}, |
|
|
65 | {KW_body_hand , "You can put it on your hand" , "It goes on a human's hand"}, |
|
|
66 | {KW_body_wrist , "You can wear it around your wrist" , "It goes around a human's wrist"}, |
|
|
67 | {KW_body_waist , "You can wear it around your waist" , "It goes around a human's waist"}, |
|
|
68 | /*{"body_dragon_torso", "your body", "a dragon's body"} */ |
|
|
69 | }; |
58 | }; |
70 | |
59 | |
71 | static char numbers_10[10][20] = { |
60 | static char numbers_10[10][20] = { |
72 | "zero", "ten", "twenty", "thirty", "fourty", "fifty", "sixty", "seventy", |
61 | "zero", "ten", "twenty", "thirty", "fourty", "fifty", "sixty", "seventy", |
73 | "eighty", "ninety" |
62 | "eighty", "ninety" |
… | |
… | |
86 | }; |
75 | }; |
87 | |
76 | |
88 | /* The following is a large table of item types, the fields are: |
77 | /* The following is a large table of item types, the fields are: |
89 | * item number, item name, item name (plural), and two numbers that are the skills |
78 | * item number, item name, item name (plural), and two numbers that are the skills |
90 | * used to identify them. Anytime a new item type is added or removed, this list |
79 | * used to identify them. Anytime a new item type is added or removed, this list |
91 | * should be altered to reflect that. The defines for the numerical values are in |
80 | * should be altered to reflect that. The defines for the numerical values are in |
92 | * define.h |
81 | * define.h |
93 | */ |
82 | */ |
94 | static const typedata item_types[] = { |
83 | static const typedata item_types[] = { |
95 | {PLAYER, "player", "players", 0, 0}, |
84 | {PLAYER, "player", "players", 0, 0}, |
96 | {ROD, "rod", "rods", SK_THAUMATURGY, 0}, |
85 | {ROD, "rod", "rods", SK_THAUMATURGY, 0}, |
97 | {TREASURE, "treasure", "treasure", 0, 0}, |
86 | {TREASURE, "treasure", "treasure", 0, 0}, |
… | |
… | |
158 | {INORGANIC, "inorganic", "inorganics", SK_ALCHEMY, 0}, |
147 | {INORGANIC, "inorganic", "inorganics", SK_ALCHEMY, 0}, |
159 | {SKILL_TOOL, "skill tool", "skill tools", 0, 0}, |
148 | {SKILL_TOOL, "skill tool", "skill tools", 0, 0}, |
160 | {LIGHTER, "lighter", "lighters", 0, 0}, |
149 | {LIGHTER, "lighter", "lighters", 0, 0}, |
161 | {BUILDABLE_WALL, "buildable wall", "buildable walls", 0, 0}, |
150 | {BUILDABLE_WALL, "buildable wall", "buildable walls", 0, 0}, |
162 | {MISC_OBJECT, "bric-a-brac", "bric-a-brac", 0, 0}, |
151 | {MISC_OBJECT, "bric-a-brac", "bric-a-brac", 0, 0}, |
|
|
152 | {TORCH, "torch", "torches", 0, 0}, |
163 | {LAMP, "lamp", "lamps", 0, 0}, |
153 | {LAMP, "lamp", "lamps", 0, 0}, |
164 | {DUPLICATOR, "duplicator", "duplicators", 0, 0}, |
154 | {DUPLICATOR, "duplicator", "duplicators", 0, 0}, |
165 | {SPELLBOOK, "spellbook", "spellbooks", SK_LITERACY, 0}, |
155 | {SPELLBOOK, "spellbook", "spellbooks", SK_LITERACY, 0}, |
166 | {CLOAK, "cloak", "cloaks", SK_SMITHERY, 0}, |
156 | {CLOAK, "cloak", "cloaks", SK_SMITHERY, 0}, |
167 | {SPINNER, "spinner", "spinners", 0, 0}, |
157 | {SPINNER, "spinner", "spinners", 0, 0}, |
… | |
… | |
202 | {BUILDER, "item builder", "item builders", 0, 0}, |
192 | {BUILDER, "item builder", "item builders", 0, 0}, |
203 | {MATERIAL, "building material", "building materials", 0, 0}, |
193 | {MATERIAL, "building material", "building materials", 0, 0}, |
204 | {ITEM_TRANSFORMER, "item_transformer", "item_transformers", 0, 0}, |
194 | {ITEM_TRANSFORMER, "item_transformer", "item_transformers", 0, 0}, |
205 | }; |
195 | }; |
206 | |
196 | |
207 | static const int item_types_size = sizeof (item_types) / sizeof (*item_types); |
197 | static const int item_types_size = ecb_array_length (item_types); |
208 | |
198 | |
209 | /* This curve may be too steep. But the point is that there should |
199 | /* This curve may be too steep. But the point is that there should |
210 | * be tough choices - there is no real point to this if everyone can |
200 | * be tough choices - there is no real point to this if everyone can |
211 | * wear whatever they want with no worries. Perhaps having the steep |
201 | * wear whatever they want with no worries. Perhaps having the steep |
212 | * curve is good (maybe even steeper), but allowing players to |
202 | * curve is good (maybe even steeper), but allowing players to |
… | |
… | |
214 | * able to use 2-3 of the most powerful items. |
204 | * able to use 2-3 of the most powerful items. |
215 | * note that this table is only really used for program generated items - |
205 | * note that this table is only really used for program generated items - |
216 | * custom objects can use whatever they want. |
206 | * custom objects can use whatever they want. |
217 | */ |
207 | */ |
218 | static int enc_to_item_power[21] = { |
208 | static int enc_to_item_power[21] = { |
|
|
209 | 0, |
219 | 0, 0, 1, 2, 3, 4, /* 5 */ |
210 | 0, 1, 2, 3, 4, // 5 |
220 | 5, 7, 9, 11, 13, /* 10 */ |
211 | 5, 7, 9, 11, 13, // 10 |
221 | 15, 18, 21, 24, 27, /* 15 */ |
212 | 15, 18, 21, 24, 27, // 15 |
222 | 30, 35, 40, 45, 50 /* 20 */ |
213 | 30, 35, 40, 45, 50 // 20 |
223 | }; |
214 | }; |
224 | |
215 | |
225 | int |
216 | int |
226 | get_power_from_ench (int ench) |
217 | get_power_from_ench (int ench) |
227 | { |
218 | { |
228 | return enc_to_item_power [clamp (ench, 0, 20)]; |
219 | return enc_to_item_power [clamp (ench, 0, 20)]; |
|
|
220 | } |
|
|
221 | |
|
|
222 | static const struct need_identify_types : typeset |
|
|
223 | { |
|
|
224 | need_identify_types () |
|
|
225 | { |
|
|
226 | set (RING); |
|
|
227 | set (WAND); |
|
|
228 | set (ROD); |
|
|
229 | set (HORN); |
|
|
230 | set (SCROLL); |
|
|
231 | set (SKILL); |
|
|
232 | set (SKILLSCROLL); |
|
|
233 | set (SPELLBOOK); |
|
|
234 | set (FOOD); |
|
|
235 | set (POTION); |
|
|
236 | set (BOW); |
|
|
237 | set (ARROW); |
|
|
238 | set (WEAPON); |
|
|
239 | set (ARMOUR); |
|
|
240 | set (SHIELD); |
|
|
241 | set (HELMET); |
|
|
242 | set (AMULET); |
|
|
243 | set (BOOTS); |
|
|
244 | set (GLOVES); |
|
|
245 | set (BRACERS); |
|
|
246 | set (GIRDLE); |
|
|
247 | set (CONTAINER); |
|
|
248 | set (DRINK); |
|
|
249 | set (FLESH); |
|
|
250 | set (INORGANIC); |
|
|
251 | set (CLOSE_CON); |
|
|
252 | set (CLOAK); |
|
|
253 | set (GEM); |
|
|
254 | set (POWER_CRYSTAL); |
|
|
255 | set (POISON); |
|
|
256 | set (BOOK); |
|
|
257 | set (SKILL_TOOL); |
|
|
258 | } |
|
|
259 | } need_identify_types; |
|
|
260 | |
|
|
261 | bool |
|
|
262 | object::need_identify () const |
|
|
263 | { |
|
|
264 | return need_identify_types [type]; |
229 | } |
265 | } |
230 | |
266 | |
231 | /* This takes an object 'op' and figures out what its item_power |
267 | /* This takes an object 'op' and figures out what its item_power |
232 | * rating should be. This should only really be used by the treasure |
268 | * rating should be. This should only really be used by the treasure |
233 | * generation code, and when loading legacy objects. It returns |
269 | * generation code, and when loading legacy objects. It returns |
… | |
… | |
245 | enc += op->stats.stat (i); |
281 | enc += op->stats.stat (i); |
246 | |
282 | |
247 | /* This protection logic is pretty flawed. 20% fire resistance |
283 | /* This protection logic is pretty flawed. 20% fire resistance |
248 | * is much more valuable than 20% confusion, or 20% slow, or |
284 | * is much more valuable than 20% confusion, or 20% slow, or |
249 | * several others. Start at 1 - ignore physical - all that normal |
285 | * several others. Start at 1 - ignore physical - all that normal |
250 | * armour shouldn't be counted against |
286 | * armour shouldn't be counted against |
251 | */ |
287 | */ |
252 | tmp = 0; |
288 | tmp = 0; |
253 | for (i = 1; i < NROFATTACKS; i++) |
289 | for (i = 1; i < NROFATTACKS; i++) |
254 | tmp += op->resist[i]; |
290 | tmp += op->resist[i]; |
255 | |
291 | |
… | |
… | |
307 | if (op->flag [FLAG_MAKE_INVIS ]) enc += 1; |
343 | if (op->flag [FLAG_MAKE_INVIS ]) enc += 1; |
308 | |
344 | |
309 | return get_power_from_ench (enc); |
345 | return get_power_from_ench (enc); |
310 | } |
346 | } |
311 | |
347 | |
|
|
348 | static const struct get_typedata |
|
|
349 | { |
|
|
350 | const typedata *data [NUM_TYPES]; |
|
|
351 | |
|
|
352 | get_typedata () |
|
|
353 | { |
|
|
354 | for (int i = 0; i < item_types_size; i++) |
|
|
355 | data [item_types[i].number] = &item_types [i]; |
|
|
356 | } |
|
|
357 | |
|
|
358 | const typedata *operator ()(int itemtype) const |
|
|
359 | { |
|
|
360 | return data [itemtype]; |
|
|
361 | } |
|
|
362 | } get_typedata_; |
|
|
363 | |
312 | /* returns the typedata that has a number equal to itemtype, if there |
364 | /* returns the typedata that has a number equal to itemtype, if there |
313 | * isn't one, returns NULL */ |
365 | * isn't one, returns NULL */ |
314 | const typedata * |
366 | const typedata * |
315 | get_typedata (int itemtype) |
367 | get_typedata (int itemtype) |
316 | { |
368 | { |
317 | for (int i = 0; i < item_types_size; i++) |
369 | return get_typedata_ (itemtype); |
318 | if (item_types[i].number == itemtype) |
|
|
319 | return &item_types[i]; |
|
|
320 | |
|
|
321 | return NULL; |
|
|
322 | } |
370 | } |
323 | |
371 | |
324 | /* returns the typedata that has a name equal to itemtype, if there |
372 | /* returns the typedata that has a name equal to itemtype, if there |
325 | * isn't one, return the plural name that matches, if there still isn't |
373 | * isn't one, return the plural name that matches, if there still isn't |
326 | * one return NULL */ |
374 | * one return NULL */ |
327 | const typedata * |
375 | const typedata * |
328 | get_typedata_by_name (const char *name) |
376 | get_typedata_by_name (const char *name) |
329 | { |
377 | { |
… | |
… | |
368 | * Seems to be used only by unimportant stuff. Remove? |
416 | * Seems to be used only by unimportant stuff. Remove? |
369 | */ |
417 | */ |
370 | const char * |
418 | const char * |
371 | query_weight (const object *op) |
419 | query_weight (const object *op) |
372 | { |
420 | { |
373 | static char buf[10]; |
421 | static char buf[32]; |
374 | sint32 i = op->total_weight (); |
422 | sint32 i = op->total_weight (); |
375 | |
423 | |
376 | if (op->weight < 0) |
424 | if (op->weight < 0) |
377 | return " "; |
425 | return " "; |
378 | |
426 | |
… | |
… | |
429 | */ |
477 | */ |
430 | static const char * |
478 | static const char * |
431 | ring_desc (const object *op) |
479 | ring_desc (const object *op) |
432 | { |
480 | { |
433 | static dynbuf_text buf; buf.clear (); |
481 | static dynbuf_text buf; buf.clear (); |
434 | int attr, val, len; |
482 | int attr, val; |
435 | |
483 | |
436 | if (op->flag [FLAG_IDENTIFIED]) |
484 | if (op->flag [FLAG_IDENTIFIED]) |
437 | { |
485 | { |
438 | for (attr = 0; attr < NUM_STATS; attr++) |
486 | for (attr = 0; attr < NUM_STATS; attr++) |
439 | if ((val = op->stats.stat (attr))) |
487 | if ((val = op->stats.stat (attr))) |
440 | buf.printf ("(%s%+d)", short_stat_name[attr], val); |
488 | buf.printf ("(%s%+d)", short_stat_name[attr], val); |
441 | |
489 | |
442 | if (op->stats.exp) buf.printf ("(speed %+lld)", (long long)op->stats.exp); |
490 | if (op->stats.exp) buf.printf ("(speed %+d)", (int)op->stats.exp); |
443 | if (op->stats.wc) buf.printf ("(wc%+d)", op->stats.wc); |
491 | if (op->stats.wc) buf.printf ("(wc%+d)", op->stats.wc); |
444 | if (op->stats.dam) buf.printf ("(dam%+d)", op->stats.dam); |
492 | if (op->stats.dam) buf.printf ("(dam%+d)", op->stats.dam); |
445 | if (op->stats.ac) buf.printf ("(ac%+d)", op->stats.ac); |
493 | if (op->stats.ac) buf.printf ("(ac%+d)", op->stats.ac); |
446 | |
494 | |
447 | buf << describe_resistance (op, 0); |
495 | buf << describe_resistance (op, 0); |
… | |
… | |
467 | |
515 | |
468 | return buf; |
516 | return buf; |
469 | } |
517 | } |
470 | |
518 | |
471 | /* |
519 | /* |
472 | * query_short_name(object) is similar to query_name, but doesn't |
520 | * query_short_name(object) is similar to query_name, but doesn't |
473 | * contain any information about object status (worn/cursed/etc.) |
521 | * contain any information about object status (worn/cursed/etc.) |
474 | * |
522 | * |
475 | * It is sometimes used when printing messages, so should fit well into a sentence. |
523 | * It is sometimes used when printing messages, so should fit well into a sentence. |
476 | */ |
524 | */ |
477 | const char * |
525 | const char * |
… | |
… | |
547 | buf << " " << s; |
595 | buf << " " << s; |
548 | } |
596 | } |
549 | break; |
597 | break; |
550 | |
598 | |
551 | default: |
599 | default: |
552 | if (op->magic && ((op->flag [FLAG_BEEN_APPLIED] && need_identify (op)) || op->flag [FLAG_IDENTIFIED])) |
600 | if (op->magic |
|
|
601 | && ((op->flag [FLAG_BEEN_APPLIED] && op->need_identify ()) |
|
|
602 | || op->flag [FLAG_IDENTIFIED])) |
553 | buf.printf (" %+d", op->magic); |
603 | buf.printf (" %+d", op->magic); |
554 | } |
604 | } |
555 | |
605 | |
556 | return buf; |
606 | return buf; |
557 | } |
607 | } |
… | |
… | |
571 | * It is also used by examine/ex and similar functions. |
621 | * It is also used by examine/ex and similar functions. |
572 | */ |
622 | */ |
573 | const char * |
623 | const char * |
574 | query_name (const object *op) |
624 | query_name (const object *op) |
575 | { |
625 | { |
576 | int len = 0; |
|
|
577 | static dynbuf_text bufs[5]; |
626 | static dynbuf_text bufs[5]; |
578 | static int use_buf = 0; |
627 | static int use_buf = 0; |
579 | |
628 | |
580 | use_buf++; |
629 | use_buf++; |
581 | use_buf %= 5; |
630 | use_buf %= 5; |
… | |
… | |
626 | |
675 | |
627 | if (op->flag [FLAG_APPLIED]) |
676 | if (op->flag [FLAG_APPLIED]) |
628 | { |
677 | { |
629 | switch (op->type) |
678 | switch (op->type) |
630 | { |
679 | { |
|
|
680 | case RANGED: |
631 | case BOW: |
681 | case BOW: |
632 | case WAND: |
682 | case WAND: |
633 | case ROD: |
683 | case ROD: |
634 | case HORN: |
684 | case HORN: |
635 | buf << " (applied)"; |
|
|
636 | break; |
|
|
637 | case WEAPON: |
685 | case WEAPON: |
638 | buf << " (applied)"; |
686 | buf << " (applied)"; |
639 | break; |
687 | break; |
640 | case ARMOUR: |
688 | case ARMOUR: |
641 | case HELMET: |
689 | case HELMET: |
… | |
… | |
756 | else if (!EXIT_PATH (op)) |
804 | else if (!EXIT_PATH (op)) |
757 | buf << " (closed)"; |
805 | buf << " (closed)"; |
758 | break; |
806 | break; |
759 | |
807 | |
760 | default: |
808 | default: |
761 | if (op->magic && ((op->flag [FLAG_BEEN_APPLIED] && need_identify (op)) || op->flag [FLAG_IDENTIFIED])) |
809 | if (op->magic |
|
|
810 | && ((op->flag [FLAG_BEEN_APPLIED] && op->need_identify ()) |
|
|
811 | || op->flag [FLAG_IDENTIFIED])) |
762 | buf.printf (" %+d", op->magic); |
812 | buf.printf (" %+d", op->magic); |
763 | } |
813 | } |
764 | |
814 | |
765 | return buf; |
815 | return buf; |
766 | } |
816 | } |
… | |
… | |
923 | int identified, i; |
973 | int identified, i; |
924 | |
974 | |
925 | /* figure this out once, instead of making multiple calls to need_identify. |
975 | /* figure this out once, instead of making multiple calls to need_identify. |
926 | * also makes the code easier to read. |
976 | * also makes the code easier to read. |
927 | */ |
977 | */ |
928 | identified = !need_identify (op) || op->flag [FLAG_IDENTIFIED]; |
978 | identified = !op->need_identify () || op->flag [FLAG_IDENTIFIED]; |
929 | if (!identified) |
979 | if (!identified) |
930 | buf << "(unidentified)"; |
980 | buf << "(unidentified)"; |
931 | |
981 | |
932 | switch (op->type) |
982 | switch (op->type) |
933 | { |
983 | { |
|
|
984 | case RANGED: |
934 | case BOW: |
985 | case BOW: |
935 | case ARROW: |
986 | case ARROW: |
936 | case WAND: |
987 | case WAND: |
937 | case ROD: |
988 | case ROD: |
938 | case HORN: |
989 | case HORN: |
… | |
… | |
959 | buf.printf ("(capacity %dk; it is ", op->stats.maxsp / 1000); |
1010 | buf.printf ("(capacity %dk; it is ", op->stats.maxsp / 1000); |
960 | } |
1011 | } |
961 | else |
1012 | else |
962 | buf.printf ("(capacity %d; it is ", op->stats.maxsp); |
1013 | buf.printf ("(capacity %d; it is ", op->stats.maxsp); |
963 | |
1014 | |
964 | i = (op->stats.sp * 10) / op->stats.maxsp; |
1015 | i = op->stats.sp * 10 / max (op->stats.maxsp, 1); |
965 | if (op->stats.sp == 0) |
1016 | |
966 | buf << "empty"; |
1017 | if (op->stats.sp == 0) buf << "empty"; |
967 | else if (i == 0) |
1018 | else if (i <= 0) buf << "almost empty"; |
968 | buf << "almost empty"; |
1019 | else if (i <= 2) buf << "partially filled"; |
969 | else if (i < 3) |
1020 | else if (i <= 5) buf << "half full"; |
970 | buf << "partially filled"; |
1021 | else if (i <= 8) buf << "well charged"; |
971 | else if (i < 6) |
|
|
972 | buf << "half full"; |
|
|
973 | else if (i < 9) |
|
|
974 | buf << "well charged"; |
|
|
975 | else if (op->stats.sp == op->stats.maxsp) |
1022 | else if (op->stats.sp < op->stats.maxsp) buf << "almost full"; |
976 | buf << "fully charged"; |
1023 | else buf << "fully charged"; |
977 | else |
|
|
978 | buf << "almost full"; |
|
|
979 | |
1024 | |
980 | buf << ')'; |
1025 | buf << ')'; |
981 | break; |
1026 | break; |
982 | |
1027 | |
983 | case LAMP: |
1028 | case LAMP: |
… | |
… | |
1043 | /* Down here, we more further describe equipment type items. |
1088 | /* Down here, we more further describe equipment type items. |
1044 | * only describe them if they have been identified or the like. |
1089 | * only describe them if they have been identified or the like. |
1045 | */ |
1090 | */ |
1046 | if (identified || op->flag [FLAG_BEEN_APPLIED]) |
1091 | if (identified || op->flag [FLAG_BEEN_APPLIED]) |
1047 | { |
1092 | { |
1048 | int attr, val; |
|
|
1049 | |
|
|
1050 | for (attr = 0; attr < NUM_STATS; attr++) |
1093 | for (int attr = 0; attr < NUM_STATS; attr++) |
1051 | if ((val = op->stats.stat (attr))) |
1094 | if (int val = op->stats.stat (attr)) |
1052 | buf.printf ("(%s%+d)", short_stat_name[attr], val); |
1095 | buf.printf ("(%s%+d)", short_stat_name[attr], val); |
1053 | |
1096 | |
1054 | if (op->stats.exp) |
1097 | if (op->stats.exp) |
1055 | buf.printf ("(speed %+lld)", (long long) op->stats.exp); |
1098 | buf.printf ("(speed %+lld)", (long long) op->stats.exp); |
1056 | |
1099 | |
1057 | switch (op->type) |
1100 | switch (op->type) |
1058 | { |
1101 | { |
|
|
1102 | case RANGED: |
1059 | case BOW: |
1103 | case BOW: |
1060 | case ARROW: |
1104 | case ARROW: |
1061 | case GIRDLE: |
1105 | case GIRDLE: |
1062 | case HELMET: |
1106 | case HELMET: |
1063 | case SHIELD: |
1107 | case SHIELD: |
… | |
… | |
1106 | { |
1150 | { |
1107 | int more_info = 0; |
1151 | int more_info = 0; |
1108 | |
1152 | |
1109 | switch (op->type) |
1153 | switch (op->type) |
1110 | { |
1154 | { |
|
|
1155 | case RANGED: |
1111 | case ROD: /* These use stats.sp for spell selection and stats.food */ |
1156 | case ROD: /* These use stats.sp for spell selection and stats.food */ |
1112 | case HORN: /* and stats.hp for spell-point regeneration... */ |
1157 | case HORN: /* and stats.hp for spell-point regeneration... */ |
1113 | case BOW: |
1158 | case BOW: |
1114 | case ARROW: |
1159 | case ARROW: |
1115 | case WAND: |
1160 | case WAND: |
… | |
… | |
1148 | |
1193 | |
1149 | if (more_info) |
1194 | if (more_info) |
1150 | { |
1195 | { |
1151 | if (op->stats.food) buf.printf ("(sustenance%+d)", op->stats.food); |
1196 | if (op->stats.food) buf.printf ("(sustenance%+d)", op->stats.food); |
1152 | if (op->stats.grace) buf.printf ("(grace%+d)", op->stats.grace); |
1197 | if (op->stats.grace) buf.printf ("(grace%+d)", op->stats.grace); |
1153 | if (op->stats.sp) buf.printf ("(magic%+d)", op->stats.sp); |
1198 | if (op->stats.sp) buf.printf ("(magic%+d)", op->stats.sp); |
1154 | if (op->stats.hp) buf.printf ("(regeneration%+d)", op->stats.hp); |
1199 | if (op->stats.hp) buf.printf ("(regeneration%+d)", op->stats.hp); |
1155 | } |
1200 | } |
1156 | |
1201 | |
1157 | if (op->stats.luck) |
1202 | if (op->stats.luck) |
1158 | buf.printf ("(luck%+d)", op->stats.luck); |
1203 | buf.printf ("(luck%+d)", op->stats.luck); |
… | |
… | |
1291 | */ |
1336 | */ |
1292 | if (msg) |
1337 | if (msg) |
1293 | { |
1338 | { |
1294 | if (type != EXIT && type != BOOK && type != CORPSE && !move_on && !has_dialogue ()) |
1339 | if (type != EXIT && type != BOOK && type != CORPSE && !move_on && !has_dialogue ()) |
1295 | { |
1340 | { |
1296 | buf << '\r'; |
1341 | if (!need_identify ()) |
1297 | |
1342 | buf << '\r' << msg << '\n'; |
1298 | /* This is just a hack so when identifying the items, we print |
1343 | else if (flag [FLAG_IDENTIFIED]) |
1299 | * out the extra message |
|
|
1300 | */ |
|
|
1301 | if (need_identify (this) && flag [FLAG_IDENTIFIED]) |
|
|
1302 | buf << "The object has a story:\r"; |
1344 | buf << '\r' << "The object has a story:\r" << msg; |
1303 | |
|
|
1304 | buf << msg << '\n'; |
|
|
1305 | } |
1345 | } |
1306 | } |
1346 | } |
1307 | else if (inv && inv->type == SPELL && flag [FLAG_IDENTIFIED] |
1347 | else if (inv |
|
|
1348 | && inv->msg |
|
|
1349 | && inv->type == SPELL |
|
|
1350 | && flag [FLAG_IDENTIFIED] |
1308 | && (type == SPELLBOOK || type == ROD || type == WAND |
1351 | && (type == SPELLBOOK || type == ROD || type == WAND |
1309 | || type == ROD || type == POTION || type == SCROLL)) |
1352 | || type == POTION || type == SCROLL)) |
1310 | // for spellbooks and other stuff that contains spells, print the spell message, |
1353 | // for spellbooks and other stuff that contains spells, print the spell message, |
1311 | // unless the object has a custom message handled above. |
1354 | // unless the object has a custom message handled above. |
1312 | buf << '\r' << inv->msg << '\n'; |
1355 | buf << '\r' << inv->msg << '\n'; |
1313 | |
1356 | |
1314 | // try to display the duration for some potions and scrolls |
1357 | // try to display the duration for some potions and scrolls |
… | |
… | |
1369 | op->contr->infobox (MSG_CHANNEL ("examine"), info.c_str ()); |
1412 | op->contr->infobox (MSG_CHANNEL ("examine"), info.c_str ()); |
1370 | } |
1413 | } |
1371 | |
1414 | |
1372 | /* |
1415 | /* |
1373 | * inventory prints object's inventory. If inv==NULL then print player's |
1416 | * inventory prints object's inventory. If inv==NULL then print player's |
1374 | * inventory. |
1417 | * inventory. |
1375 | * [ Only items which are applied are showed. Tero.Haatanen@lut.fi ] |
1418 | * [ Only items which are applied are showed. Tero.Haatanen@lut.fi ] |
1376 | */ |
1419 | */ |
1377 | const char * |
1420 | const char * |
1378 | object::query_inventory (object *who, const char *indent) |
1421 | object::query_inventory (object *who, const char *indent) |
1379 | { |
1422 | { |
… | |
… | |
1466 | * be non magical. |
1509 | * be non magical. |
1467 | */ |
1510 | */ |
1468 | return 0; |
1511 | return 0; |
1469 | } |
1512 | } |
1470 | |
1513 | |
1471 | /* need_identify returns true if the item should be identified. This |
|
|
1472 | * function really should not exist - by default, any item not identified |
|
|
1473 | * should need it. |
|
|
1474 | */ |
|
|
1475 | |
|
|
1476 | int |
|
|
1477 | need_identify (const object *op) |
|
|
1478 | { |
|
|
1479 | switch (op->type) |
|
|
1480 | { |
|
|
1481 | case RING: |
|
|
1482 | case WAND: |
|
|
1483 | case ROD: |
|
|
1484 | case HORN: |
|
|
1485 | case SCROLL: |
|
|
1486 | case SKILL: |
|
|
1487 | case SKILLSCROLL: |
|
|
1488 | case SPELLBOOK: |
|
|
1489 | case FOOD: |
|
|
1490 | case POTION: |
|
|
1491 | case BOW: |
|
|
1492 | case ARROW: |
|
|
1493 | case WEAPON: |
|
|
1494 | case ARMOUR: |
|
|
1495 | case SHIELD: |
|
|
1496 | case HELMET: |
|
|
1497 | case AMULET: |
|
|
1498 | case BOOTS: |
|
|
1499 | case GLOVES: |
|
|
1500 | case BRACERS: |
|
|
1501 | case GIRDLE: |
|
|
1502 | case CONTAINER: |
|
|
1503 | case DRINK: |
|
|
1504 | case FLESH: |
|
|
1505 | case INORGANIC: |
|
|
1506 | case CLOSE_CON: |
|
|
1507 | case CLOAK: |
|
|
1508 | case GEM: |
|
|
1509 | case POWER_CRYSTAL: |
|
|
1510 | case POISON: |
|
|
1511 | case BOOK: |
|
|
1512 | case SKILL_TOOL: |
|
|
1513 | return 1; |
|
|
1514 | } |
|
|
1515 | |
|
|
1516 | /* Try to track down some stuff that may show up here. Thus, the |
|
|
1517 | * archetype file can be updated, and this function removed. |
|
|
1518 | */ |
|
|
1519 | #if 0 |
|
|
1520 | LOG (llevDebug, "need_identify: %s does not need to be id'd\n", op->name); |
|
|
1521 | #endif |
|
|
1522 | return 0; |
|
|
1523 | } |
|
|
1524 | |
|
|
1525 | /* |
1514 | /* |
1526 | * Supposed to fix face-values as well here, but later. |
1515 | * Supposed to fix face-values as well here, but later. |
1527 | */ |
1516 | */ |
1528 | void |
1517 | void |
1529 | identify (object *op) |
1518 | identify (object *op) |