ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/item.C
(Generate patch)

Comparing deliantra/server/common/item.C (file contents):
Revision 1.84 by root, Thu Apr 15 02:51:39 2010 UTC vs.
Revision 1.92 by root, Sat Aug 13 23:18:20 2011 UTC

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 (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992 Frank Tore Johansen 6 * Copyright (©) 1992 Frank Tore Johansen
7 * 7 *
8 * Deliantra is free software: you can redistribute it and/or modify it under 8 * 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 9 * the terms of the Affero GNU General Public License as published by the
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
53Body_Locations body_locations[NUM_BODY_LOCATIONS] = { 53Body_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
71static char numbers_10[10][20] = { 59static 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"
158 {INORGANIC, "inorganic", "inorganics", SK_ALCHEMY, 0}, 146 {INORGANIC, "inorganic", "inorganics", SK_ALCHEMY, 0},
159 {SKILL_TOOL, "skill tool", "skill tools", 0, 0}, 147 {SKILL_TOOL, "skill tool", "skill tools", 0, 0},
160 {LIGHTER, "lighter", "lighters", 0, 0}, 148 {LIGHTER, "lighter", "lighters", 0, 0},
161 {BUILDABLE_WALL, "buildable wall", "buildable walls", 0, 0}, 149 {BUILDABLE_WALL, "buildable wall", "buildable walls", 0, 0},
162 {MISC_OBJECT, "bric-a-brac", "bric-a-brac", 0, 0}, 150 {MISC_OBJECT, "bric-a-brac", "bric-a-brac", 0, 0},
151 {TORCH, "torch", "torches", 0, 0},
163 {LAMP, "lamp", "lamps", 0, 0}, 152 {LAMP, "lamp", "lamps", 0, 0},
164 {DUPLICATOR, "duplicator", "duplicators", 0, 0}, 153 {DUPLICATOR, "duplicator", "duplicators", 0, 0},
165 {SPELLBOOK, "spellbook", "spellbooks", SK_LITERACY, 0}, 154 {SPELLBOOK, "spellbook", "spellbooks", SK_LITERACY, 0},
166 {CLOAK, "cloak", "cloaks", SK_SMITHERY, 0}, 155 {CLOAK, "cloak", "cloaks", SK_SMITHERY, 0},
167 {SPINNER, "spinner", "spinners", 0, 0}, 156 {SPINNER, "spinner", "spinners", 0, 0},
202 {BUILDER, "item builder", "item builders", 0, 0}, 191 {BUILDER, "item builder", "item builders", 0, 0},
203 {MATERIAL, "building material", "building materials", 0, 0}, 192 {MATERIAL, "building material", "building materials", 0, 0},
204 {ITEM_TRANSFORMER, "item_transformer", "item_transformers", 0, 0}, 193 {ITEM_TRANSFORMER, "item_transformer", "item_transformers", 0, 0},
205}; 194};
206 195
207static const int item_types_size = sizeof (item_types) / sizeof (*item_types); 196static const int item_types_size = array_length (item_types);
208 197
209/* This curve may be too steep. But the point is that there should 198/* 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 199 * 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 200 * wear whatever they want with no worries. Perhaps having the steep
212 * curve is good (maybe even steeper), but allowing players to 201 * curve is good (maybe even steeper), but allowing players to
214 * able to use 2-3 of the most powerful items. 203 * able to use 2-3 of the most powerful items.
215 * note that this table is only really used for program generated items - 204 * note that this table is only really used for program generated items -
216 * custom objects can use whatever they want. 205 * custom objects can use whatever they want.
217 */ 206 */
218static int enc_to_item_power[21] = { 207static int enc_to_item_power[21] = {
208 0,
219 0, 0, 1, 2, 3, 4, /* 5 */ 209 0, 1, 2, 3, 4, // 5
220 5, 7, 9, 11, 13, /* 10 */ 210 5, 7, 9, 11, 13, // 10
221 15, 18, 21, 24, 27, /* 15 */ 211 15, 18, 21, 24, 27, // 15
222 30, 35, 40, 45, 50 /* 20 */ 212 30, 35, 40, 45, 50 // 20
223}; 213};
224 214
225int 215int
226get_power_from_ench (int ench) 216get_power_from_ench (int ench)
227{ 217{
352 if (op->flag [FLAG_MAKE_INVIS ]) enc += 1; 342 if (op->flag [FLAG_MAKE_INVIS ]) enc += 1;
353 343
354 return get_power_from_ench (enc); 344 return get_power_from_ench (enc);
355} 345}
356 346
347static const struct get_typedata
348{
349 const typedata *data [NUM_TYPES];
350
351 get_typedata ()
352 {
353 for (int i = 0; i < item_types_size; i++)
354 data [item_types[i].number] = &item_types [i];
355 }
356
357 const typedata *operator ()(int itemtype) const
358 {
359 return data [itemtype];
360 }
361} get_typedata_;
362
357/* returns the typedata that has a number equal to itemtype, if there 363/* returns the typedata that has a number equal to itemtype, if there
358 * isn't one, returns NULL */ 364 * isn't one, returns NULL */
359const typedata * 365const typedata *
360get_typedata (int itemtype) 366get_typedata (int itemtype)
361{ 367{
362 for (int i = 0; i < item_types_size; i++) 368 return get_typedata_ (itemtype);
363 if (item_types[i].number == itemtype)
364 return &item_types[i];
365
366 return NULL;
367} 369}
368 370
369/* returns the typedata that has a name equal to itemtype, if there 371/* returns the typedata that has a name equal to itemtype, if there
370 * isn't one, return the plural name that matches, if there still isn't 372 * isn't one, return the plural name that matches, if there still isn't
371 * one return NULL */ 373 * one return NULL */
482 { 484 {
483 for (attr = 0; attr < NUM_STATS; attr++) 485 for (attr = 0; attr < NUM_STATS; attr++)
484 if ((val = op->stats.stat (attr))) 486 if ((val = op->stats.stat (attr)))
485 buf.printf ("(%s%+d)", short_stat_name[attr], val); 487 buf.printf ("(%s%+d)", short_stat_name[attr], val);
486 488
487 if (op->stats.exp) buf.printf ("(speed %+lld)", (long long)op->stats.exp); 489 if (op->stats.exp) buf.printf ("(speed %+d)", (int)op->stats.exp);
488 if (op->stats.wc) buf.printf ("(wc%+d)", op->stats.wc); 490 if (op->stats.wc) buf.printf ("(wc%+d)", op->stats.wc);
489 if (op->stats.dam) buf.printf ("(dam%+d)", op->stats.dam); 491 if (op->stats.dam) buf.printf ("(dam%+d)", op->stats.dam);
490 if (op->stats.ac) buf.printf ("(ac%+d)", op->stats.ac); 492 if (op->stats.ac) buf.printf ("(ac%+d)", op->stats.ac);
491 493
492 buf << describe_resistance (op, 0); 494 buf << describe_resistance (op, 0);
673 675
674 if (op->flag [FLAG_APPLIED]) 676 if (op->flag [FLAG_APPLIED])
675 { 677 {
676 switch (op->type) 678 switch (op->type)
677 { 679 {
680 case RANGED:
678 case BOW: 681 case BOW:
679 case WAND: 682 case WAND:
680 case ROD: 683 case ROD:
681 case HORN: 684 case HORN:
682 buf << " (applied)";
683 break;
684 case WEAPON: 685 case WEAPON:
685 buf << " (applied)"; 686 buf << " (applied)";
686 break; 687 break;
687 case ARMOUR: 688 case ARMOUR:
688 case HELMET: 689 case HELMET:
978 if (!identified) 979 if (!identified)
979 buf << "(unidentified)"; 980 buf << "(unidentified)";
980 981
981 switch (op->type) 982 switch (op->type)
982 { 983 {
984 case RANGED:
983 case BOW: 985 case BOW:
984 case ARROW: 986 case ARROW:
985 case WAND: 987 case WAND:
986 case ROD: 988 case ROD:
987 case HORN: 989 case HORN:
1092 /* Down here, we more further describe equipment type items. 1094 /* Down here, we more further describe equipment type items.
1093 * only describe them if they have been identified or the like. 1095 * only describe them if they have been identified or the like.
1094 */ 1096 */
1095 if (identified || op->flag [FLAG_BEEN_APPLIED]) 1097 if (identified || op->flag [FLAG_BEEN_APPLIED])
1096 { 1098 {
1097 int attr, val;
1098
1099 for (attr = 0; attr < NUM_STATS; attr++) 1099 for (int attr = 0; attr < NUM_STATS; attr++)
1100 if ((val = op->stats.stat (attr))) 1100 if (int val = op->stats.stat (attr))
1101 buf.printf ("(%s%+d)", short_stat_name[attr], val); 1101 buf.printf ("(%s%+d)", short_stat_name[attr], val);
1102 1102
1103 if (op->stats.exp) 1103 if (op->stats.exp)
1104 buf.printf ("(speed %+lld)", (long long) op->stats.exp); 1104 buf.printf ("(speed %+lld)", (long long) op->stats.exp);
1105 1105
1106 switch (op->type) 1106 switch (op->type)
1107 { 1107 {
1108 case RANGED:
1108 case BOW: 1109 case BOW:
1109 case ARROW: 1110 case ARROW:
1110 case GIRDLE: 1111 case GIRDLE:
1111 case HELMET: 1112 case HELMET:
1112 case SHIELD: 1113 case SHIELD:
1155 { 1156 {
1156 int more_info = 0; 1157 int more_info = 0;
1157 1158
1158 switch (op->type) 1159 switch (op->type)
1159 { 1160 {
1161 case RANGED:
1160 case ROD: /* These use stats.sp for spell selection and stats.food */ 1162 case ROD: /* These use stats.sp for spell selection and stats.food */
1161 case HORN: /* and stats.hp for spell-point regeneration... */ 1163 case HORN: /* and stats.hp for spell-point regeneration... */
1162 case BOW: 1164 case BOW:
1163 case ARROW: 1165 case ARROW:
1164 case WAND: 1166 case WAND:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines