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.29 by root, Thu May 3 04:50:26 2007 UTC vs.
Revision 1.37 by root, Mon Jun 4 13:04:00 2007 UTC

1/* 1/*
2 * CrossFire, A Multiplayer game 2 * This file is part of Crossfire TRT, the Multiplayer Online Role Playing Game.
3 * 3 *
4 * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team 4 * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team
5 * Copyright (C) 2002 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
6 * Copyright (C) 1992 Frank Tore Johansen 6 * Copyright (©) 1992,2007 Frank Tore Johansen
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * Crossfire TRT is free software; you can redistribute it and/or modify it
9 * it under the terms of the GNU General Public License as published by 9 * under the terms of the GNU General Public License as published by the Free
10 * the Free Software Foundation; either version 2 of the License, or 10 * Software Foundation; either version 2 of the License, or (at your option)
11 * (at your option) any later version. 11 * any later version.
12 * 12 *
13 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful, but
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 * GNU General Public License for more details. 16 * for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License along
19 * along with this program; if not, write to the Free Software 19 * with Crossfire TRT; if not, write to the Free Software Foundation, Inc. 51
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 * 21 *
22 * The authors can be reached via e-mail at <crossfire@schmorp.de> 22 * The authors can be reached via e-mail to <crossfire@schmorp.de>
23 */ 23 */
24 24
25#include <global.h> 25#include <global.h>
26#include <funcpoint.h> 26#include <funcpoint.h>
27#include <living.h> 27#include <living.h>
47 * may be better. 47 * may be better.
48 * Basically, for the use/nonuse, the code does something like: 48 * Basically, for the use/nonuse, the code does something like:
49 * "This item goes %s\n", with the use/nonuse values filling in the %s 49 * "This item goes %s\n", with the use/nonuse values filling in the %s
50 */ 50 */
51Body_Locations body_locations[NUM_BODY_LOCATIONS] = { 51Body_Locations body_locations[NUM_BODY_LOCATIONS] = {
52 {"body_range", "in your range slot", "in a human's range slot"}, 52 {KW_body_skill , "You can use it as your skill" , "It is used as a skill"},
53 {"body_arm", "on your arm", "on a human's arm"}, 53 {KW_body_combat , "You can wield it as your weapon" , "It is used as a combat weapon"},
54 {"body_torso", "on your body", "on a human's torso"}, 54 {KW_body_range , "You can use it as your range weapon" , "It is used as a range weapon"},
55 {"body_head", "on your head", "on a human's head"}, 55 {KW_body_shield , "You can wield it as a shield" , "It is used as a shield"},
56 {"body_neck", "around your neck", "around a humans neck"}, 56 {KW_body_arm , "You can put it on your arm" , "It goes on a human's arm"},
57 {"body_skill", "in your skill slot", "in a human's skill slot"}, 57 {KW_body_torso , "You can wear it on your body" , "It goes on a human's torso"},
58 {"body_finger", "on your finger", "on a human's finger"} , 58 {KW_body_head , "You can wear it on your head" , "It goes on a human's head"},
59 {KW_body_neck , "You can wear it around your neck" , "It goes around a human's neck"},
60 {KW_body_finger , "You can wear it on your finger" , "It goes on a human's finger"} ,
59 {"body_shoulder", "around your shoulders", "around a human's shoulders"}, 61 {KW_body_shoulder, "You can wear it around your shoulders", "It goes around a human's shoulders"},
60 {"body_foot", "on your feet", "on a human's feet"}, 62 {KW_body_foot , "You can put it on your foot" , "It goes on a human's foot"},
61 {"body_hand", "on your hands", "on a human's hands"}, 63 {KW_body_hand , "You can put it on your hand" , "It goes on a human's hand"},
62 {"body_wrist", "around your wrists", "around a human's wrist"}, 64 {KW_body_wrist , "You can wear it around your wrist" , "It goes around a human's wrist"},
63 {"body_waist", "around your waist", "around a human's waist"}, 65 {KW_body_waist , "You can wear it around your waist" , "It goes around a human's waist"},
64/*{"body_dragon_torso", "your body", "a dragon's body"} */ 66/*{"body_dragon_torso", "your body", "a dragon's body"} */
65}; 67};
66 68
67static char numbers[21][20] = { 69static char numbers[21][20] = {
68 "no", "", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", 70 "no", "", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten",
270{ 272{
271 int i, tmp, enc; 273 int i, tmp, enc;
272 274
273 enc = 0; 275 enc = 0;
274 for (i = 0; i < NUM_STATS; i++) 276 for (i = 0; i < NUM_STATS; i++)
275 enc += get_attr_value (&op->stats, i); 277 enc += op->stats.stat (i);
276 278
277 /* This protection logic is pretty flawed. 20% fire resistance 279 /* This protection logic is pretty flawed. 20% fire resistance
278 * is much more valuable than 20% confusion, or 20% slow, or 280 * is much more valuable than 20% confusion, or 20% slow, or
279 * several others. Start at 1 - ignore physical - all that normal 281 * several others. Start at 1 - ignore physical - all that normal
280 * armour shouldn't be counted against 282 * armour shouldn't be counted against
500 if (!QUERY_FLAG (op, FLAG_IDENTIFIED)) 502 if (!QUERY_FLAG (op, FLAG_IDENTIFIED))
501 return buf; 503 return buf;
502 504
503 for (attr = 0; attr < NUM_STATS; attr++) 505 for (attr = 0; attr < NUM_STATS; attr++)
504 { 506 {
505 if ((val = get_attr_value (&(op->stats), attr)) != 0) 507 if ((val = op->stats.stat (attr)))
506 {
507 sprintf (buf + strlen (buf), "(%s%+d)", short_stat_name[attr], val); 508 sprintf (buf + strlen (buf), "(%s%+d)", short_stat_name[attr], val);
508 }
509 } 509 }
510 510
511 if (op->stats.exp) 511 if (op->stats.exp)
512 sprintf (buf + strlen (buf), "(speed %+lld)", (long long) op->stats.exp); 512 sprintf (buf + strlen (buf), "(speed %+lld)", (long long) op->stats.exp);
513 if (op->stats.wc) 513 if (op->stats.wc)
771 if ((op->is_armor () || op->is_weapon ()) && op->materialname) 771 if ((op->is_armor () || op->is_weapon ()) && op->materialname)
772 mt = name_to_material (op->materialname); 772 mt = name_to_material (op->materialname);
773 773
774#ifdef NEW_MATERIAL_CODE 774#ifdef NEW_MATERIAL_CODE
775 if ((op->is_armor () || op->is_weapon ()) && op->materialname && mt && 775 if ((op->is_armor () || op->is_weapon ()) && op->materialname && mt &&
776 op->arch->clone.materialname != mt->name && !(op->material & M_SPECIAL)) 776 op->arch->materialname != mt->name && !(op->material & M_SPECIAL))
777 { 777 {
778 strcpy (buf, mt->description); 778 strcpy (buf, mt->description);
779 len = strlen (buf); 779 len = strlen (buf);
780 safe_strcat (buf, " ", &len, MAX_BUF); 780 safe_strcat (buf, " ", &len, MAX_BUF);
781 if (!plural) 781 if (!plural)
934 { 934 {
935 treasure *t; 935 treasure *t;
936 int first = 1; 936 int first = 1;
937 937
938 for (t = op->randomitems->items; t != NULL; t = t->next) 938 for (t = op->randomitems->items; t != NULL; t = t->next)
939 if (t->item && t->item->clone.type == SPELL) 939 if (t->item && t->item->type == SPELL)
940 { 940 {
941 if (first) 941 if (first)
942 { 942 {
943 first = 0; 943 first = 0;
944 strcat (retbuf, "(Spell abilities:)"); 944 strcat (retbuf, "(Spell abilities:)");
945 } 945 }
946 strcat (retbuf, "("); 946 strcat (retbuf, "(");
947 strcat (retbuf, t->item->clone.name); 947 strcat (retbuf, t->item->object::name);
948 strcat (retbuf, ")"); 948 strcat (retbuf, ")");
949 } 949 }
950 } 950 }
951 if (op->type == PLAYER) 951 if (op->type == PLAYER)
952 { 952 {
1082 break; /* We have more information to do below this switch */ 1082 break; /* We have more information to do below this switch */
1083 1083
1084 case POWER_CRYSTAL: 1084 case POWER_CRYSTAL:
1085 if (op->stats.maxsp > 1000) 1085 if (op->stats.maxsp > 1000)
1086 { /*higher capacity crystals */ 1086 { /*higher capacity crystals */
1087 i = (op->stats.maxsp % 100) / 10; 1087 i = (op->stats.maxsp % 1000) / 100;
1088
1088 if (i) 1089 if (i)
1089 snprintf (buf, MAX_BUF, "(capacity %d.%dk). It is ", op->stats.maxsp / 100, i); 1090 snprintf (buf, MAX_BUF, "(capacity %d.%dk). It is ", op->stats.maxsp / 1000, i);
1090 else 1091 else
1091 snprintf (buf, MAX_BUF, "(capacity %dk). It is ", op->stats.maxsp / 100); 1092 snprintf (buf, MAX_BUF, "(capacity %dk). It is ", op->stats.maxsp / 1000);
1092 } 1093 }
1093 else 1094 else
1094 snprintf (buf, MAX_BUF, "(capacity %d). It is ", op->stats.maxsp); 1095 snprintf (buf, MAX_BUF, "(capacity %d). It is ", op->stats.maxsp);
1096
1095 strcat (retbuf, buf); 1097 strcat (retbuf, buf);
1096 i = (op->stats.sp * 10) / op->stats.maxsp; 1098 i = (op->stats.sp * 10) / op->stats.maxsp;
1097 if (op->stats.sp == 0) 1099 if (op->stats.sp == 0)
1098 strcat (retbuf, "empty."); 1100 strcat (retbuf, "empty.");
1099 else if (i == 0) 1101 else if (i == 0)
1164 { 1166 {
1165 int attr, val; 1167 int attr, val;
1166 1168
1167 for (attr = 0; attr < NUM_STATS; attr++) 1169 for (attr = 0; attr < NUM_STATS; attr++)
1168 { 1170 {
1169 if ((val = get_attr_value (&(op->stats), attr)) != 0) 1171 if ((val = op->stats.stat (attr)))
1170 { 1172 {
1171 sprintf (buf, "(%s%+d)", short_stat_name[attr], val); 1173 sprintf (buf, "(%s%+d)", short_stat_name[attr], val);
1172 strcat (retbuf, buf); 1174 strcat (retbuf, buf);
1173 } 1175 }
1174 } 1176 }
1431 if (op->magic || op->type == POWER_CRYSTAL || op->type == SPELLBOOK || op->type == SCROLL || op->type == GIRDLE) 1433 if (op->magic || op->type == POWER_CRYSTAL || op->type == SPELLBOOK || op->type == SCROLL || op->type == GIRDLE)
1432 return 1; 1434 return 1;
1433 1435
1434 /* Check to see if it increases/decreases any stats */ 1436 /* Check to see if it increases/decreases any stats */
1435 for (i = 0; i < NUM_STATS; i++) 1437 for (i = 0; i < NUM_STATS; i++)
1436 if (get_attr_value (&(op->stats), i) != 0) 1438 if (op->stats.stat (i))
1437 return 1; 1439 return 1;
1438 1440
1439 /* If it doesn't fall into any of the above categories, must 1441 /* If it doesn't fall into any of the above categories, must
1440 * be non magical. 1442 * be non magical.
1441 */ 1443 */
1450int 1452int
1451need_identify (const object *op) 1453need_identify (const object *op)
1452{ 1454{
1453 switch (op->type) 1455 switch (op->type)
1454 { 1456 {
1455 case RING: 1457 case RING:
1456 case WAND: 1458 case WAND:
1457 case ROD: 1459 case ROD:
1458 case HORN: 1460 case HORN:
1459 case SCROLL: 1461 case SCROLL:
1460 case SKILL: 1462 case SKILL:
1461 case SKILLSCROLL: 1463 case SKILLSCROLL:
1462 case SPELLBOOK: 1464 case SPELLBOOK:
1463 case FOOD: 1465 case FOOD:
1464 case POTION: 1466 case POTION:
1465 case BOW: 1467 case BOW:
1466 case ARROW: 1468 case ARROW:
1467 case WEAPON: 1469 case WEAPON:
1468 case ARMOUR: 1470 case ARMOUR:
1469 case SHIELD: 1471 case SHIELD:
1470 case HELMET: 1472 case HELMET:
1471 case AMULET: 1473 case AMULET:
1472 case BOOTS: 1474 case BOOTS:
1473 case GLOVES: 1475 case GLOVES:
1474 case BRACERS: 1476 case BRACERS:
1475 case GIRDLE: 1477 case GIRDLE:
1476 case CONTAINER: 1478 case CONTAINER:
1477 case DRINK: 1479 case DRINK:
1478 case FLESH: 1480 case FLESH:
1479 case INORGANIC: 1481 case INORGANIC:
1480 case CLOSE_CON: 1482 case CLOSE_CON:
1481 case CLOAK: 1483 case CLOAK:
1482 case GEM: 1484 case GEM:
1483 case POWER_CRYSTAL: 1485 case POWER_CRYSTAL:
1484 case POISON: 1486 case POISON:
1485 case BOOK: 1487 case BOOK:
1486 case SKILL_TOOL: 1488 case SKILL_TOOL:
1487 return 1; 1489 return 1;
1488 } 1490 }
1491
1489 /* Try to track down some stuff that may show up here. Thus, the 1492 /* Try to track down some stuff that may show up here. Thus, the
1490 * archetype file can be updated, and this function removed. 1493 * archetype file can be updated, and this function removed.
1491 */ 1494 */
1492#if 0 1495#if 0
1493 LOG (llevDebug, "need_identify: %s does not need to be id'd\n", op->name); 1496 LOG (llevDebug, "need_identify: %s does not need to be id'd\n", op->name);
1517 { 1520 {
1518 if (op->inv && op->randomitems) 1521 if (op->inv && op->randomitems)
1519 op->title = op->inv->name; 1522 op->title = op->inv->name;
1520 else if (op->arch) 1523 else if (op->arch)
1521 { 1524 {
1522 op->name = op->arch->clone.name; 1525 op->name = op->arch->object::name;
1523 op->name_pl = op->arch->clone.name_pl; 1526 op->name_pl = op->arch->object::name_pl;
1524 } 1527 }
1525 } 1528 }
1526 1529
1527 /* If the object is on a map, make sure we update its face */ 1530 /* If the object is on a map, make sure we update its face */
1528 if (op->map) 1531 if (op->map)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines