--- deliantra/server/common/item.C 2007/03/18 03:05:39 1.25 +++ deliantra/server/common/item.C 2007/05/27 23:56:21 1.35 @@ -1,5 +1,5 @@ /* - * CrossFire, A Multiplayer game for X-windows + * CrossFire, A Multiplayer game * * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team * Copyright (C) 2002 Mark Wedel & Crossfire Development Team @@ -49,18 +49,20 @@ * "This item goes %s\n", with the use/nonuse values filling in the %s */ Body_Locations body_locations[NUM_BODY_LOCATIONS] = { - {"body_range", "in your range slot", "in a human's range slot"}, - {"body_arm", "on your arm", "on a human's arm"}, - {"body_torso", "on your body", "on a human's torso"}, - {"body_head", "on your head", "on a human's head"}, - {"body_neck", "around your neck", "around a humans neck"}, - {"body_skill", "in your skill slot", "in a human's skill slot"}, - {"body_finger", "on your finger", "on a human's finger"} , - {"body_shoulder", "around your shoulders", "around a human's shoulders"}, - {"body_foot", "on your feet", "on a human's feet"}, - {"body_hand", "on your hands", "on a human's hands"}, - {"body_wrist", "around your wrists", "around a human's wrist"}, - {"body_waist", "around your waist", "around a human's waist"}, + {KW_body_skill , "You can use it as your skill" , "It is used as a skill"}, + {KW_body_combat , "You can wield it as your weapon" , "It is used as a combat weapon"}, + {KW_body_range , "You can use it as your range weapon" , "It is used as a range weapon"}, + {KW_body_shield , "You can wield it as a shield" , "It is used as a shield"}, + {KW_body_arm , "You can put it on your arm" , "It goes on a human's arm"}, + {KW_body_torso , "You can wear it on your body" , "It goes on a human's torso"}, + {KW_body_head , "You can wear it on your head" , "It goes on a human's head"}, + {KW_body_neck , "You can wear it around your neck" , "It goes around a human's neck"}, + {KW_body_finger , "You can wear it on your finger" , "It goes on a human's finger"} , + {KW_body_shoulder, "You can wear it around your shoulders", "It goes around a human's shoulders"}, + {KW_body_foot , "You can put it on your foot" , "It goes on a human's foot"}, + {KW_body_hand , "You can put it on your hand" , "It goes on a human's hand"}, + {KW_body_wrist , "You can wear it around your wrist" , "It goes around a human's wrist"}, + {KW_body_waist , "You can wear it around your waist" , "It goes around a human's waist"}, /*{"body_dragon_torso", "your body", "a dragon's body"} */ }; @@ -252,10 +254,9 @@ int get_power_from_ench (int ench) { - if (ench < 0) - ench = 0; - if (ench > 20) - ench = 20; + if (ench < 0) ench = 0; + if (ench > 20) ench = 20; + return enc_to_item_power[ench]; } @@ -273,7 +274,7 @@ enc = 0; for (i = 0; i < NUM_STATS; i++) - enc += get_attr_value (&op->stats, i); + enc += op->stats.stat (i); /* This protection logic is pretty flawed. 20% fire resistance * is much more valuable than 20% confusion, or 20% slow, or @@ -344,12 +345,10 @@ enc += 1; return get_power_from_ench (enc); - } /* returns the typedata that has a number equal to itemtype, if there * isn't one, returns NULL */ - const typedata * get_typedata (int itemtype) { @@ -364,7 +363,6 @@ /* returns the typedata that has a name equal to itemtype, if there * isn't one, return the plural name that matches, if there still isn't * one return NULL */ - const typedata * get_typedata_by_name (const char *name) { @@ -506,11 +504,10 @@ for (attr = 0; attr < NUM_STATS; attr++) { - if ((val = get_attr_value (&(op->stats), attr)) != 0) - { - sprintf (buf + strlen (buf), "(%s%+d)", short_stat_name[attr], val); - } + if ((val = op->stats.stat (attr))) + sprintf (buf + strlen (buf), "(%s%+d)", short_stat_name[attr], val); } + if (op->stats.exp) sprintf (buf + strlen (buf), "(speed %+lld)", (long long) op->stats.exp); if (op->stats.wc) @@ -542,6 +539,7 @@ strcat (buf, "(reflect missiles)"); if (QUERY_FLAG (op, FLAG_STEALTH)) strcat (buf, "(stealth)"); + /* Shorten some of the names, so they appear better in the windows */ len = strlen (buf); DESCRIBE_PATH_SAFE (buf, op->path_attuned, "Attuned", &len, VERY_BIG_BUF); @@ -716,10 +714,10 @@ case WAND: case ROD: case HORN: - safe_strcat (buf[use_buf], " (readied)", &len, HUGE_BUF); + safe_strcat (buf[use_buf], op->env && op->env->current_weapon == op ? " (readied)" : " (applied)", &len, HUGE_BUF); break; case WEAPON: - safe_strcat (buf[use_buf], " (wielded)", &len, HUGE_BUF); + safe_strcat (buf[use_buf], op->env && op->env->current_weapon == op ? " (wielded)" : " (applied)", &len, HUGE_BUF); break; case ARMOUR: case HELMET: @@ -844,11 +842,10 @@ } } break; + default: if (op->magic && ((QUERY_FLAG (op, FLAG_BEEN_APPLIED) && need_identify (op)) || QUERY_FLAG (op, FLAG_IDENTIFIED))) - { - sprintf (buf + strlen (buf), " %+d", op->magic); - } + sprintf (buf + strlen (buf), " %+d", op->magic); } return buf; @@ -1087,14 +1084,16 @@ case POWER_CRYSTAL: if (op->stats.maxsp > 1000) { /*higher capacity crystals */ - i = (op->stats.maxsp % 100) / 10; + i = (op->stats.maxsp % 1000) / 100; + if (i) - snprintf (buf, MAX_BUF, "(capacity %d.%dk). It is ", op->stats.maxsp / 100, i); + snprintf (buf, MAX_BUF, "(capacity %d.%dk). It is ", op->stats.maxsp / 1000, i); else - snprintf (buf, MAX_BUF, "(capacity %dk). It is ", op->stats.maxsp / 100); + snprintf (buf, MAX_BUF, "(capacity %dk). It is ", op->stats.maxsp / 1000); } else snprintf (buf, MAX_BUF, "(capacity %d). It is ", op->stats.maxsp); + strcat (retbuf, buf); i = (op->stats.sp * 10) / op->stats.maxsp; if (op->stats.sp == 0) @@ -1169,7 +1168,7 @@ for (attr = 0; attr < NUM_STATS; attr++) { - if ((val = get_attr_value (&(op->stats), attr)) != 0) + if ((val = op->stats.stat (attr))) { sprintf (buf, "(%s%+d)", short_stat_name[attr], val); strcat (retbuf, buf); @@ -1363,6 +1362,12 @@ return retbuf; } +std::string +object::describe_item (object *who) +{ + return std::string (::describe_item (this, who)); +} + /* Return true if the item is magical. A magical item is one that * increases/decreases any abilities, provides a resistance, * has a generic magical bonus, or is an artifact. @@ -1430,7 +1435,7 @@ /* Check to see if it increases/decreases any stats */ for (i = 0; i < NUM_STATS; i++) - if (get_attr_value (&(op->stats), i) != 0) + if (op->stats.stat (i)) return 1; /* If it doesn't fall into any of the above categories, must @@ -1449,40 +1454,41 @@ { switch (op->type) { - case RING: - case WAND: - case ROD: - case HORN: - case SCROLL: - case SKILL: - case SKILLSCROLL: - case SPELLBOOK: - case FOOD: - case POTION: - case BOW: - case ARROW: - case WEAPON: - case ARMOUR: - case SHIELD: - case HELMET: - case AMULET: - case BOOTS: - case GLOVES: - case BRACERS: - case GIRDLE: - case CONTAINER: - case DRINK: - case FLESH: - case INORGANIC: - case CLOSE_CON: - case CLOAK: - case GEM: - case POWER_CRYSTAL: - case POISON: - case BOOK: - case SKILL_TOOL: - return 1; + case RING: + case WAND: + case ROD: + case HORN: + case SCROLL: + case SKILL: + case SKILLSCROLL: + case SPELLBOOK: + case FOOD: + case POTION: + case BOW: + case ARROW: + case WEAPON: + case ARMOUR: + case SHIELD: + case HELMET: + case AMULET: + case BOOTS: + case GLOVES: + case BRACERS: + case GIRDLE: + case CONTAINER: + case DRINK: + case FLESH: + case INORGANIC: + case CLOSE_CON: + case CLOAK: + case GEM: + case POWER_CRYSTAL: + case POISON: + case BOOK: + case SKILL_TOOL: + return 1; } + /* Try to track down some stuff that may show up here. Thus, the * archetype file can be updated, and this function removed. */