… | |
… | |
49 | * Basically, for the use/nonuse, the code does something like: |
49 | * 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 |
50 | * "This item goes %s\n", with the use/nonuse values filling in the %s |
51 | */ |
51 | */ |
52 | // see include/object.h |
52 | // see include/object.h |
53 | Body_Locations body_locations[NUM_BODY_LOCATIONS] = { |
53 | Body_Locations body_locations[NUM_BODY_LOCATIONS] = { |
54 | {KW_body_skill , "You can use it as your skill" , "It is used as a skill"}, |
54 | # 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"}, |
55 | # include "slotinc.h" |
56 | {KW_body_range , "You can use it as your range weapon" , "It is used as a range weapon"}, |
56 | # 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 | }; |
57 | }; |
70 | |
58 | |
71 | static char numbers_10[10][20] = { |
59 | static char numbers_10[10][20] = { |
72 | "zero", "ten", "twenty", "thirty", "fourty", "fifty", "sixty", "seventy", |
60 | "zero", "ten", "twenty", "thirty", "fourty", "fifty", "sixty", "seventy", |
73 | "eighty", "ninety" |
61 | "eighty", "ninety" |
… | |
… | |
202 | {BUILDER, "item builder", "item builders", 0, 0}, |
190 | {BUILDER, "item builder", "item builders", 0, 0}, |
203 | {MATERIAL, "building material", "building materials", 0, 0}, |
191 | {MATERIAL, "building material", "building materials", 0, 0}, |
204 | {ITEM_TRANSFORMER, "item_transformer", "item_transformers", 0, 0}, |
192 | {ITEM_TRANSFORMER, "item_transformer", "item_transformers", 0, 0}, |
205 | }; |
193 | }; |
206 | |
194 | |
207 | static const int item_types_size = sizeof (item_types) / sizeof (*item_types); |
195 | static const int item_types_size = array_length (item_types); |
208 | |
196 | |
209 | /* This curve may be too steep. But the point is that there should |
197 | /* 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 |
198 | * 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 |
199 | * wear whatever they want with no worries. Perhaps having the steep |
212 | * curve is good (maybe even steeper), but allowing players to |
200 | * curve is good (maybe even steeper), but allowing players to |
… | |
… | |
215 | * note that this table is only really used for program generated items - |
203 | * note that this table is only really used for program generated items - |
216 | * custom objects can use whatever they want. |
204 | * custom objects can use whatever they want. |
217 | */ |
205 | */ |
218 | static int enc_to_item_power[21] = { |
206 | static int enc_to_item_power[21] = { |
219 | 0, |
207 | 0, |
220 | 0, 1, 2, 3, 4, /* 5 */ |
208 | 0, 1, 2, 3, 4, // 5 |
221 | 5, 7, 9, 11, 13, /* 10 */ |
209 | 5, 7, 9, 11, 13, // 10 |
222 | 15, 18, 21, 24, 27, /* 15 */ |
210 | 15, 18, 21, 24, 27, // 15 |
223 | 30, 35, 40, 45, 50 /* 20 */ |
211 | 30, 35, 40, 45, 50 // 20 |
224 | }; |
212 | }; |
225 | |
213 | |
226 | int |
214 | int |
227 | get_power_from_ench (int ench) |
215 | get_power_from_ench (int ench) |
228 | { |
216 | { |
… | |
… | |
353 | if (op->flag [FLAG_MAKE_INVIS ]) enc += 1; |
341 | if (op->flag [FLAG_MAKE_INVIS ]) enc += 1; |
354 | |
342 | |
355 | return get_power_from_ench (enc); |
343 | return get_power_from_ench (enc); |
356 | } |
344 | } |
357 | |
345 | |
|
|
346 | static const struct get_typedata |
|
|
347 | { |
|
|
348 | const typedata *data [NUM_TYPES]; |
|
|
349 | |
|
|
350 | get_typedata () |
|
|
351 | { |
|
|
352 | for (int i = 0; i < item_types_size; i++) |
|
|
353 | data [item_types[i].number] = &item_types [i]; |
|
|
354 | } |
|
|
355 | |
|
|
356 | const typedata *operator ()(int itemtype) const |
|
|
357 | { |
|
|
358 | return data [itemtype]; |
|
|
359 | } |
|
|
360 | } get_typedata_; |
|
|
361 | |
358 | /* returns the typedata that has a number equal to itemtype, if there |
362 | /* returns the typedata that has a number equal to itemtype, if there |
359 | * isn't one, returns NULL */ |
363 | * isn't one, returns NULL */ |
360 | const typedata * |
364 | const typedata * |
361 | get_typedata (int itemtype) |
365 | get_typedata (int itemtype) |
362 | { |
366 | { |
363 | for (int i = 0; i < item_types_size; i++) |
367 | return get_typedata_ (itemtype); |
364 | if (item_types[i].number == itemtype) |
|
|
365 | return &item_types[i]; |
|
|
366 | |
|
|
367 | return NULL; |
|
|
368 | } |
368 | } |
369 | |
369 | |
370 | /* returns the typedata that has a name equal to itemtype, if there |
370 | /* returns the typedata that has a name equal to itemtype, if there |
371 | * isn't one, return the plural name that matches, if there still isn't |
371 | * isn't one, return the plural name that matches, if there still isn't |
372 | * one return NULL */ |
372 | * one return NULL */ |
… | |
… | |
483 | { |
483 | { |
484 | for (attr = 0; attr < NUM_STATS; attr++) |
484 | for (attr = 0; attr < NUM_STATS; attr++) |
485 | if ((val = op->stats.stat (attr))) |
485 | if ((val = op->stats.stat (attr))) |
486 | buf.printf ("(%s%+d)", short_stat_name[attr], val); |
486 | buf.printf ("(%s%+d)", short_stat_name[attr], val); |
487 | |
487 | |
488 | if (op->stats.exp) buf.printf ("(speed %+lld)", (long long)op->stats.exp); |
488 | if (op->stats.exp) buf.printf ("(speed %+d)", (int)op->stats.exp); |
489 | if (op->stats.wc) buf.printf ("(wc%+d)", op->stats.wc); |
489 | if (op->stats.wc) buf.printf ("(wc%+d)", op->stats.wc); |
490 | if (op->stats.dam) buf.printf ("(dam%+d)", op->stats.dam); |
490 | if (op->stats.dam) buf.printf ("(dam%+d)", op->stats.dam); |
491 | if (op->stats.ac) buf.printf ("(ac%+d)", op->stats.ac); |
491 | if (op->stats.ac) buf.printf ("(ac%+d)", op->stats.ac); |
492 | |
492 | |
493 | buf << describe_resistance (op, 0); |
493 | buf << describe_resistance (op, 0); |
… | |
… | |
674 | |
674 | |
675 | if (op->flag [FLAG_APPLIED]) |
675 | if (op->flag [FLAG_APPLIED]) |
676 | { |
676 | { |
677 | switch (op->type) |
677 | switch (op->type) |
678 | { |
678 | { |
|
|
679 | case RANGED: |
679 | case BOW: |
680 | case BOW: |
680 | case WAND: |
681 | case WAND: |
681 | case ROD: |
682 | case ROD: |
682 | case HORN: |
683 | case HORN: |
683 | buf << " (applied)"; |
|
|
684 | break; |
|
|
685 | case WEAPON: |
684 | case WEAPON: |
686 | buf << " (applied)"; |
685 | buf << " (applied)"; |
687 | break; |
686 | break; |
688 | case ARMOUR: |
687 | case ARMOUR: |
689 | case HELMET: |
688 | case HELMET: |
… | |
… | |
979 | if (!identified) |
978 | if (!identified) |
980 | buf << "(unidentified)"; |
979 | buf << "(unidentified)"; |
981 | |
980 | |
982 | switch (op->type) |
981 | switch (op->type) |
983 | { |
982 | { |
|
|
983 | case RANGED: |
984 | case BOW: |
984 | case BOW: |
985 | case ARROW: |
985 | case ARROW: |
986 | case WAND: |
986 | case WAND: |
987 | case ROD: |
987 | case ROD: |
988 | case HORN: |
988 | case HORN: |
… | |
… | |
1093 | /* Down here, we more further describe equipment type items. |
1093 | /* Down here, we more further describe equipment type items. |
1094 | * only describe them if they have been identified or the like. |
1094 | * only describe them if they have been identified or the like. |
1095 | */ |
1095 | */ |
1096 | if (identified || op->flag [FLAG_BEEN_APPLIED]) |
1096 | if (identified || op->flag [FLAG_BEEN_APPLIED]) |
1097 | { |
1097 | { |
1098 | int attr, val; |
|
|
1099 | |
|
|
1100 | for (attr = 0; attr < NUM_STATS; attr++) |
1098 | for (int attr = 0; attr < NUM_STATS; attr++) |
1101 | if ((val = op->stats.stat (attr))) |
1099 | if (int val = op->stats.stat (attr)) |
1102 | buf.printf ("(%s%+d)", short_stat_name[attr], val); |
1100 | buf.printf ("(%s%+d)", short_stat_name[attr], val); |
1103 | |
1101 | |
1104 | if (op->stats.exp) |
1102 | if (op->stats.exp) |
1105 | buf.printf ("(speed %+lld)", (long long) op->stats.exp); |
1103 | buf.printf ("(speed %+lld)", (long long) op->stats.exp); |
1106 | |
1104 | |
1107 | switch (op->type) |
1105 | switch (op->type) |
1108 | { |
1106 | { |
|
|
1107 | case RANGED: |
1109 | case BOW: |
1108 | case BOW: |
1110 | case ARROW: |
1109 | case ARROW: |
1111 | case GIRDLE: |
1110 | case GIRDLE: |
1112 | case HELMET: |
1111 | case HELMET: |
1113 | case SHIELD: |
1112 | case SHIELD: |
… | |
… | |
1156 | { |
1155 | { |
1157 | int more_info = 0; |
1156 | int more_info = 0; |
1158 | |
1157 | |
1159 | switch (op->type) |
1158 | switch (op->type) |
1160 | { |
1159 | { |
|
|
1160 | case RANGED: |
1161 | case ROD: /* These use stats.sp for spell selection and stats.food */ |
1161 | case ROD: /* These use stats.sp for spell selection and stats.food */ |
1162 | case HORN: /* and stats.hp for spell-point regeneration... */ |
1162 | case HORN: /* and stats.hp for spell-point regeneration... */ |
1163 | case BOW: |
1163 | case BOW: |
1164 | case ARROW: |
1164 | case ARROW: |
1165 | case WAND: |
1165 | case WAND: |