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.83 by root, Sun Apr 11 00:34:05 2010 UTC vs.
Revision 1.86 by root, Fri Apr 30 20:43:17 2010 UTC

202 {BUILDER, "item builder", "item builders", 0, 0}, 202 {BUILDER, "item builder", "item builders", 0, 0},
203 {MATERIAL, "building material", "building materials", 0, 0}, 203 {MATERIAL, "building material", "building materials", 0, 0},
204 {ITEM_TRANSFORMER, "item_transformer", "item_transformers", 0, 0}, 204 {ITEM_TRANSFORMER, "item_transformer", "item_transformers", 0, 0},
205}; 205};
206 206
207static const int item_types_size = sizeof (item_types) / sizeof (*item_types); 207static const int item_types_size = array_length (item_types);
208 208
209/* This curve may be too steep. But the point is that there should 209/* 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 210 * 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 211 * wear whatever they want with no worries. Perhaps having the steep
212 * curve is good (maybe even steeper), but allowing players to 212 * curve is good (maybe even steeper), but allowing players to
214 * able to use 2-3 of the most powerful items. 214 * able to use 2-3 of the most powerful items.
215 * note that this table is only really used for program generated items - 215 * note that this table is only really used for program generated items -
216 * custom objects can use whatever they want. 216 * custom objects can use whatever they want.
217 */ 217 */
218static int enc_to_item_power[21] = { 218static int enc_to_item_power[21] = {
219 0,
219 0, 0, 1, 2, 3, 4, /* 5 */ 220 0, 1, 2, 3, 4, // 5
220 5, 7, 9, 11, 13, /* 10 */ 221 5, 7, 9, 11, 13, // 10
221 15, 18, 21, 24, 27, /* 15 */ 222 15, 18, 21, 24, 27, // 15
222 30, 35, 40, 45, 50 /* 20 */ 223 30, 35, 40, 45, 50 // 20
223}; 224};
224 225
225int 226int
226get_power_from_ench (int ench) 227get_power_from_ench (int ench)
227{ 228{
228 return enc_to_item_power [clamp (ench, 0, 20)]; 229 return enc_to_item_power [clamp (ench, 0, 20)];
230}
231
232static const struct need_identify_types : typeset
233{
234 need_identify_types ()
235 {
236 set (RING);
237 set (WAND);
238 set (ROD);
239 set (HORN);
240 set (SCROLL);
241 set (SKILL);
242 set (SKILLSCROLL);
243 set (SPELLBOOK);
244 set (FOOD);
245 set (POTION);
246 set (BOW);
247 set (ARROW);
248 set (WEAPON);
249 set (ARMOUR);
250 set (SHIELD);
251 set (HELMET);
252 set (AMULET);
253 set (BOOTS);
254 set (GLOVES);
255 set (BRACERS);
256 set (GIRDLE);
257 set (CONTAINER);
258 set (DRINK);
259 set (FLESH);
260 set (INORGANIC);
261 set (CLOSE_CON);
262 set (CLOAK);
263 set (GEM);
264 set (POWER_CRYSTAL);
265 set (POISON);
266 set (BOOK);
267 set (SKILL_TOOL);
268 }
269} need_identify_types;
270
271bool
272object::need_identify () const
273{
274 return need_identify_types [type];
229} 275}
230 276
231/* This takes an object 'op' and figures out what its item_power 277/* 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 278 * rating should be. This should only really be used by the treasure
233 * generation code, and when loading legacy objects. It returns 279 * generation code, and when loading legacy objects. It returns
547 buf << " " << s; 593 buf << " " << s;
548 } 594 }
549 break; 595 break;
550 596
551 default: 597 default:
552 if (op->magic && ((op->flag [FLAG_BEEN_APPLIED] && need_identify (op)) || op->flag [FLAG_IDENTIFIED])) 598 if (op->magic
599 && ((op->flag [FLAG_BEEN_APPLIED] && op->need_identify ())
600 || op->flag [FLAG_IDENTIFIED]))
553 buf.printf (" %+d", op->magic); 601 buf.printf (" %+d", op->magic);
554 } 602 }
555 603
556 return buf; 604 return buf;
557} 605}
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 {
1291 */ 1341 */
1292 if (msg) 1342 if (msg)
1293 { 1343 {
1294 if (type != EXIT && type != BOOK && type != CORPSE && !move_on && !has_dialogue ()) 1344 if (type != EXIT && type != BOOK && type != CORPSE && !move_on && !has_dialogue ())
1295 { 1345 {
1296 buf << '\r'; 1346 if (!need_identify ())
1297 1347 buf << '\r' << msg << '\n';
1298 /* This is just a hack so when identifying the items, we print 1348 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"; 1349 buf << '\r' << "The object has a story:\r" << msg;
1303
1304 buf << msg << '\n';
1305 } 1350 }
1306 } 1351 }
1307 else if (inv && inv->type == SPELL && flag [FLAG_IDENTIFIED] 1352 else if (inv
1353 && inv->msg
1354 && inv->type == SPELL
1355 && flag [FLAG_IDENTIFIED]
1308 && (type == SPELLBOOK || type == ROD || type == WAND 1356 && (type == SPELLBOOK || type == ROD || type == WAND
1309 || type == ROD || type == POTION || type == SCROLL)) 1357 || type == ROD || type == POTION || type == SCROLL))
1310 // for spellbooks and other stuff that contains spells, print the spell message, 1358 // for spellbooks and other stuff that contains spells, print the spell message,
1311 // unless the object has a custom message handled above. 1359 // unless the object has a custom message handled above.
1312 buf << '\r' << inv->msg << '\n'; 1360 buf << '\r' << inv->msg << '\n';
1466 * be non magical. 1514 * be non magical.
1467 */ 1515 */
1468 return 0; 1516 return 0;
1469} 1517}
1470 1518
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
1476int
1477need_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/* 1519/*
1526 * Supposed to fix face-values as well here, but later. 1520 * Supposed to fix face-values as well here, but later.
1527 */ 1521 */
1528void 1522void
1529identify (object *op) 1523identify (object *op)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines