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

Comparing deliantra/server/common/treasure.C (file contents):
Revision 1.109 by root, Sun May 2 20:37:57 2010 UTC vs.
Revision 1.110 by elmex, Wed May 5 09:42:52 2010 UTC

775 return 1; 775 return 1;
776 776
777 return 0; 777 return 0;
778} 778}
779 779
780static double
781value_factor_from_spell_item (object *spell, object *item)
782{
783 double factor =
784 pow ((spell->value > 0 ? spell->value : 1)
785 * spell->level, 1.5);
786
787 if (item) // this if for: wands/staffs/rods:
788 {
789 /* Old crossfire comment ahead:
790 * Add 50 to both level an divisor to keep prices a little more
791 * reasonable. Otherwise, a high level version of a low level
792 * spell can be worth tons a money (eg, level 20 rod, level 2 spell =
793 * 10 time multiplier). This way, the value are a bit more reasonable.
794 */
795
796 factor *= item->level + 50;
797 factor /= item->inv->level + 50;
798 }
799
800 return factor;
801}
802
780#define DICE2 (get_magic(2) == 2 ? 2 : 1) 803#define DICE2 (get_magic(2) == 2 ? 2 : 1)
781#define DICESPELL (rndm (3) + rndm (3) + rndm (3) + rndm (3) + rndm (3)) 804#define DICESPELL (rndm (3) + rndm (3) + rndm (3) + rndm (3) + rndm (3))
782 805
783/* 806/*
784 * fix_generated_item(): This is called after an item is generated, in 807 * fix_generated_item(): This is called after an item is generated, in
1041 if (creator->slaying && !op->slaying) /* for check_inv floors */ 1064 if (creator->slaying && !op->slaying) /* for check_inv floors */
1042 op->slaying = creator->slaying; 1065 op->slaying = creator->slaying;
1043 break; 1066 break;
1044 1067
1045 case SPELLBOOK: 1068 case SPELLBOOK:
1046 op->value *= pow ((op->inv->value > 0 ? op->inv->value : 1) 1069 op->value *= value_factor_from_spell_item (op->inv, 0);
1047 * op->inv->level,
1048 1.5);
1049 1070
1050 /* add exp so learning gives xp */ 1071 /* add exp so learning gives xp */
1051 op->level = op->inv->level; 1072 op->level = op->inv->level;
1052 op->stats.exp = op->value; 1073 op->stats.exp = op->value;
1053 break; 1074 break;
1058 * and reset nrof. 1079 * and reset nrof.
1059 */ 1080 */
1060 op->stats.food = op->inv->nrof; 1081 op->stats.food = op->inv->nrof;
1061 op->nrof = 1; 1082 op->nrof = 1;
1062 /* If the spell changes by level, choose a random level 1083 /* If the spell changes by level, choose a random level
1063 * for it, and adjust price. If the spell doesn't 1084 * for it.
1064 * change by level, just set the wand to the level of
1065 * the spell, and value calculation is simpler.
1066 */ 1085 */
1067 if (op->inv->duration_modifier || op->inv->dam_modifier || op->inv->range_modifier) 1086 if (op->inv->duration_modifier
1068 { 1087 || op->inv->dam_modifier
1088 || op->inv->range_modifier)
1069 op->level = level_for_item (op, difficulty); 1089 op->level = level_for_item (op, difficulty);
1070 op->value = op->value * op->inv->value * (op->level + 50) / (op->inv->level + 50);
1071 }
1072 else 1090 else
1073 {
1074 op->level = op->inv->level; 1091 op->level = op->inv->level;
1075 op->value = op->value * op->inv->value; 1092
1076 } 1093 op->value *= value_factor_from_spell_item (op->inv, op);
1077 break; 1094 break;
1078 1095
1079 case ROD: 1096 case ROD:
1080 op->level = level_for_item (op, difficulty); 1097 op->level = level_for_item (op, difficulty);
1081 /* Add 50 to both level an divisor to keep prices a little more 1098 op->value *= value_factor_from_spell_item (op->inv, op);
1082 * reasonable. Otherwise, a high level version of a low level
1083 * spell can be worth tons a money (eg, level 20 rod, level 2 spell =
1084 * 10 time multiplier). This way, the value are a bit more reasonable.
1085 */
1086 op->value = op->value * op->inv->value * (op->level + 50) / (op->inv->level + 50);
1087 1099
1088 /* maxhp is used to denote how many 'charges' the rod holds before */ 1100 /* maxhp is used to denote how many 'charges' the rod holds before */
1089 if (op->stats.maxhp) 1101 if (op->stats.maxhp)
1090 op->stats.maxhp *= max (op->inv->stats.sp, op->inv->stats.grace); 1102 op->stats.maxhp *= max (op->inv->stats.sp, op->inv->stats.grace);
1091 else 1103 else
1094 op->stats.hp = op->stats.maxhp; 1106 op->stats.hp = op->stats.maxhp;
1095 break; 1107 break;
1096 1108
1097 case SCROLL: 1109 case SCROLL:
1098 op->level = level_for_item (op, difficulty); 1110 op->level = level_for_item (op, difficulty);
1099 op->value = op->value * op->inv->value * (op->level + 50) / (op->inv->level + 50); 1111 op->value *= value_factor_from_spell_item (op->inv, op);
1100 1112
1101 /* add exp so reading them properly gives xp */ 1113 /* add exp so reading them properly gives xp */
1102 op->stats.exp = op->value / 5; 1114 op->stats.exp = op->value / 5;
1103 op->nrof = op->inv->nrof; 1115 op->nrof = op->inv->nrof;
1104 break; 1116 break;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines