… | |
… | |
775 | return 1; |
775 | return 1; |
776 | |
776 | |
777 | return 0; |
777 | return 0; |
778 | } |
778 | } |
779 | |
779 | |
|
|
780 | static double |
|
|
781 | value_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; |
… | |
… | |
1282 | */ |
1294 | */ |
1283 | void |
1295 | void |
1284 | add_abilities (object *op, object *change) |
1296 | add_abilities (object *op, object *change) |
1285 | { |
1297 | { |
1286 | if (change->face != blank_face) |
1298 | if (change->face != blank_face) |
1287 | { |
|
|
1288 | #ifdef TREASURE_VERBOSE |
|
|
1289 | LOG (llevDebug, "add_abilities change face: %d\n", change->face); |
|
|
1290 | #endif |
|
|
1291 | op->face = change->face; |
1299 | op->face = change->face; |
1292 | } |
|
|
1293 | |
1300 | |
1294 | for (int i = 0; i < NUM_STATS; i++) |
1301 | for (int i = 0; i < NUM_STATS; i++) |
1295 | change_attr_value (&(op->stats), i, change->stats.stat (i)); |
1302 | change_attr_value (&(op->stats), i, change->stats.stat (i)); |
1296 | |
1303 | |
1297 | op->attacktype |= change->attacktype; |
1304 | op->attacktype |= change->attacktype; |
… | |
… | |
1482 | name = tmp->name + 1, neg = 1; |
1489 | name = tmp->name + 1, neg = 1; |
1483 | else |
1490 | else |
1484 | name = tmp->name, neg = 0; |
1491 | name = tmp->name, neg = 0; |
1485 | |
1492 | |
1486 | /* If we match name, then return the opposite of 'neg' */ |
1493 | /* If we match name, then return the opposite of 'neg' */ |
1487 | if (!strcmp (name, op->name) || (op->arch && !strcmp (name, op->arch->archname))) |
1494 | if (!strcmp (name, op->arch->archname)) |
1488 | return !neg; |
1495 | return !neg; |
1489 | |
1496 | |
1490 | /* 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 |
1491 | * everything is allowed except what we match |
1498 | * everything is allowed except what we match |
1492 | */ |
1499 | */ |