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.113 by root, Sun May 1 16:58:16 2011 UTC

1/* 1/*
2 * This file is part of Deliantra, the Roguelike Realtime MMORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992 Frank Tore Johansen 6 * Copyright (©) 1992 Frank Tore Johansen
7 * 7 *
8 * Deliantra is free software: you can redistribute it and/or modify it under 8 * Deliantra is free software: you can redistribute it and/or modify it under
9 * the terms of the Affero GNU General Public License as published by the 9 * the terms of the Affero GNU General Public License as published by the
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
896 { 919 {
897 if (op->type == POTION) 920 if (op->type == POTION)
898 /* Handle healing and magic power potions */ 921 /* Handle healing and magic power potions */
899 if (op->stats.sp && !op->randomitems) 922 if (op->stats.sp && !op->randomitems)
900 { 923 {
901 object *tmp = get_archetype (spell_mapping [op->stats.sp]); 924 object *tmp = archetype::get (spell_mapping [op->stats.sp]);
902 insert_ob_in_ob (tmp, op); 925 insert_ob_in_ob (tmp, op);
903 op->stats.sp = 0; 926 op->stats.sp = 0;
904 } 927 }
905 } 928 }
906 else if (!op->title) /* Only modify object if not special */ 929 else if (!op->title) /* Only modify object if not special */
929 int too_many_tries = 0, is_special = 0; 952 int too_many_tries = 0, is_special = 0;
930 953
931 /* Handle healing and magic power potions */ 954 /* Handle healing and magic power potions */
932 if (op->stats.sp && !op->randomitems) 955 if (op->stats.sp && !op->randomitems)
933 { 956 {
934 object *tmp = get_archetype (spell_mapping[op->stats.sp]); 957 object *tmp = archetype::get (spell_mapping[op->stats.sp]);
935 insert_ob_in_ob (tmp, op); 958 insert_ob_in_ob (tmp, op);
936 op->stats.sp = 0; 959 op->stats.sp = 0;
937 } 960 }
938 961
939 while (!(is_special = special_potion (op)) && !op->inv) 962 while (!(is_special = special_potion (op)) && !op->inv)
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;
1477 name = tmp->name + 1, neg = 1; 1489 name = tmp->name + 1, neg = 1;
1478 else 1490 else
1479 name = tmp->name, neg = 0; 1491 name = tmp->name, neg = 0;
1480 1492
1481 /* If we match name, then return the opposite of 'neg' */ 1493 /* If we match name, then return the opposite of 'neg' */
1482 if (!strcmp (name, op->name) || (op->arch && !strcmp (name, op->arch->archname))) 1494 if (!strcmp (name, op->arch->archname))
1483 return !neg; 1495 return !neg;
1484 1496
1485 /* Set success as true, since if the match was an inverse, it means 1497 /* Set success as true, since if the match was an inverse, it means
1486 * everything is allowed except what we match 1498 * everything is allowed except what we match
1487 */ 1499 */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines