--- deliantra/server/common/treasure.C 2010/04/28 19:49:50 1.108 +++ deliantra/server/common/treasure.C 2011/04/16 02:35:53 1.111 @@ -777,6 +777,29 @@ return 0; } +static double +value_factor_from_spell_item (object *spell, object *item) +{ + double factor = + pow ((spell->value > 0 ? spell->value : 1) + * spell->level, 1.5); + + if (item) // this if for: wands/staffs/rods: + { + /* Old crossfire comment ahead: + * Add 50 to both level an divisor to keep prices a little more + * reasonable. Otherwise, a high level version of a low level + * spell can be worth tons a money (eg, level 20 rod, level 2 spell = + * 10 time multiplier). This way, the value are a bit more reasonable. + */ + + factor *= item->level + 50; + factor /= item->inv->level + 50; + } + + return factor; +} + #define DICE2 (get_magic(2) == 2 ? 2 : 1) #define DICESPELL (rndm (3) + rndm (3) + rndm (3) + rndm (3) + rndm (3)) @@ -1043,9 +1066,7 @@ break; case SPELLBOOK: - op->value *= pow ((op->inv->value > 0 ? op->inv->value : 1) - * op->inv->level, - 1.5); + op->value *= value_factor_from_spell_item (op->inv, 0); /* add exp so learning gives xp */ op->level = op->inv->level; @@ -1060,30 +1081,21 @@ op->stats.food = op->inv->nrof; op->nrof = 1; /* If the spell changes by level, choose a random level - * for it, and adjust price. If the spell doesn't - * change by level, just set the wand to the level of - * the spell, and value calculation is simpler. + * for it. */ - if (op->inv->duration_modifier || op->inv->dam_modifier || op->inv->range_modifier) - { - op->level = level_for_item (op, difficulty); - op->value = op->value * op->inv->value * (op->level + 50) / (op->inv->level + 50); - } + if (op->inv->duration_modifier + || op->inv->dam_modifier + || op->inv->range_modifier) + op->level = level_for_item (op, difficulty); else - { - op->level = op->inv->level; - op->value = op->value * op->inv->value; - } + op->level = op->inv->level; + + op->value *= value_factor_from_spell_item (op->inv, op); break; case ROD: op->level = level_for_item (op, difficulty); - /* Add 50 to both level an divisor to keep prices a little more - * reasonable. Otherwise, a high level version of a low level - * spell can be worth tons a money (eg, level 20 rod, level 2 spell = - * 10 time multiplier). This way, the value are a bit more reasonable. - */ - op->value = op->value * op->inv->value * (op->level + 50) / (op->inv->level + 50); + op->value *= value_factor_from_spell_item (op->inv, op); /* maxhp is used to denote how many 'charges' the rod holds before */ if (op->stats.maxhp) @@ -1096,7 +1108,7 @@ case SCROLL: op->level = level_for_item (op, difficulty); - op->value = op->value * op->inv->value * (op->level + 50) / (op->inv->level + 50); + op->value *= value_factor_from_spell_item (op->inv, op); /* add exp so reading them properly gives xp */ op->stats.exp = op->value / 5; @@ -1284,12 +1296,7 @@ add_abilities (object *op, object *change) { if (change->face != blank_face) - { -#ifdef TREASURE_VERBOSE - LOG (llevDebug, "add_abilities change face: %d\n", change->face); -#endif - op->face = change->face; - } + op->face = change->face; for (int i = 0; i < NUM_STATS; i++) change_attr_value (&(op->stats), i, change->stats.stat (i)); @@ -1484,7 +1491,7 @@ name = tmp->name, neg = 0; /* If we match name, then return the opposite of 'neg' */ - if (!strcmp (name, op->name) || (op->arch && !strcmp (name, op->arch->archname))) + if (!strcmp (name, op->arch->archname)) return !neg; /* Set success as true, since if the match was an inverse, it means