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,2012,2013,2014,2015,2016 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 |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * option) any later version. |
11 | * option) any later version. |
12 | * |
12 | * |
13 | * This program is distributed in the hope that it will be useful, |
13 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
17 | * |
17 | * |
18 | * You should have received a copy of the Affero GNU General Public License |
18 | * You should have received a copy of the Affero GNU General Public License |
19 | * and the GNU General Public License along with this program. If not, see |
19 | * and the GNU General Public License along with this program. If not, see |
20 | * <http://www.gnu.org/licenses/>. |
20 | * <http://www.gnu.org/licenses/>. |
21 | * |
21 | * |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
23 | */ |
23 | */ |
24 | |
24 | |
25 | /* TREASURE_DEBUG does some checking on the treasurelists after loading. |
25 | /* TREASURE_DEBUG does some checking on the treasurelists after loading. |
26 | * It is useful for finding bugs in the treasures file. Since it only |
26 | * It is useful for finding bugs in the treasures file. Since it only |
… | |
… | |
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 |
… | |
… | |
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 */ |
… | |
… | |
924 | } |
947 | } |
925 | break; |
948 | break; |
926 | |
949 | |
927 | case POTION: |
950 | case POTION: |
928 | { |
951 | { |
929 | int too_many_tries = 0, is_special = 0; |
952 | int too_many_tries = 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 (!special_potion (op) && !op->inv) |
940 | { |
963 | { |
941 | generate_artifact (op, difficulty); |
964 | generate_artifact (op, difficulty); |
942 | if (too_many_tries++ > 10) |
965 | if (too_many_tries++ > 10) |
943 | break; |
966 | break; |
944 | } |
967 | } |
… | |
… | |
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 | */ |