… | |
… | |
810 | path_repelled = arch->path_repelled; |
810 | path_repelled = arch->path_repelled; |
811 | path_denied = arch->path_denied; |
811 | path_denied = arch->path_denied; |
812 | glow_radius = arch->glow_radius; |
812 | glow_radius = arch->glow_radius; |
813 | move_type = arch->move_type; |
813 | move_type = arch->move_type; |
814 | |
814 | |
815 | object *chosen_skill = 0; |
|
|
816 | |
|
|
817 | /* initializing resistances from the values in player/monster's |
815 | /* initializing resistances from the values in player/monster's |
818 | * archetype clone |
816 | * archetype clone |
819 | */ |
817 | */ |
820 | memcpy (&resist, &arch->resist, sizeof (resist)); |
818 | memcpy (&resist, &arch->resist, sizeof (resist)); |
821 | |
819 | |
822 | for (int i = 0; i < NROFATTACKS; i++) |
820 | for (int i = 0; i < NROFATTACKS; i++) |
823 | { |
821 | { |
824 | if (resist[i] > 0) |
822 | if (resist[i] > 0) |
825 | prot[i] = resist[i], vuln[i] = 0; |
823 | prot[i] = resist[i], vuln[i] = 0; |
826 | else |
824 | else |
827 | vuln[i] = -(resist[i]), prot[i] = 0; |
825 | vuln[i] = -resist[i], prot[i] = 0; |
828 | |
826 | |
829 | potion_resist[i] = 0; |
827 | potion_resist[i] = -1000; |
830 | } |
828 | } |
831 | |
829 | |
832 | wc = arch->stats.wc; |
830 | wc = arch->stats.wc; |
833 | stats.dam = arch->stats.dam; |
831 | stats.dam = arch->stats.dam; |
834 | |
832 | |
… | |
… | |
847 | else |
845 | else |
848 | ac = arch->stats.ac; |
846 | ac = arch->stats.ac; |
849 | |
847 | |
850 | stats.luck = arch->stats.luck; |
848 | stats.luck = arch->stats.luck; |
851 | speed = arch->speed; |
849 | speed = arch->speed; |
|
|
850 | |
|
|
851 | chosen_skill = 0; |
852 | |
852 | |
853 | /* OK - we've reset most all the objects attributes to sane values. |
853 | /* OK - we've reset most all the objects attributes to sane values. |
854 | * now go through and make adjustments for what the player has equipped. |
854 | * now go through and make adjustments for what the player has equipped. |
855 | */ |
855 | */ |
856 | for (tmp = inv; tmp; tmp = tmp->below) |
856 | for (tmp = inv; tmp; tmp = tmp->below) |
… | |
… | |
900 | || (tmp->type == SKILL && tmp->subtype == SK_PRAYING)) |
900 | || (tmp->type == SKILL && tmp->subtype == SK_PRAYING)) |
901 | { |
901 | { |
902 | if (type == PLAYER) |
902 | if (type == PLAYER) |
903 | { |
903 | { |
904 | contr->item_power += tmp->item_power; |
904 | contr->item_power += tmp->item_power; |
905 | |
|
|
906 | if (tmp == contr->combat_ob || tmp == contr->ranged_ob) |
|
|
907 | if (tmp != current_weapon |
|
|
908 | && (tmp->type != SKILL || tmp->subtype != SK_PRAYING) |
|
|
909 | && !tmp->flag [FLAG_CURSED] |
|
|
910 | && !tmp->flag [FLAG_DAMNED]) |
|
|
911 | continue; |
|
|
912 | |
905 | |
913 | for (int i = 0; i < NUM_STATS; i++) |
906 | for (int i = 0; i < NUM_STATS; i++) |
914 | stat_sum [i] += tmp->stats.stat (i); |
907 | stat_sum [i] += tmp->stats.stat (i); |
915 | |
908 | |
916 | if (digest_types [tmp->type]) |
909 | if (digest_types [tmp->type]) |
… | |
… | |
928 | if (tmp->type == WEAPON) |
921 | if (tmp->type == WEAPON) |
929 | current_weapon = tmp; |
922 | current_weapon = tmp; |
930 | } |
923 | } |
931 | |
924 | |
932 | /* Update slots used for items */ |
925 | /* Update slots used for items */ |
933 | if (QUERY_FLAG (tmp, FLAG_APPLIED)) |
926 | if (tmp->flag [FLAG_APPLIED]) // exclude praying... |
934 | for (int i = 0; i < NUM_BODY_LOCATIONS; i++) |
927 | for (int i = 0; i < NUM_BODY_LOCATIONS; i++) |
935 | slot[i].used += tmp->slot[i].info; |
928 | slot[i].used += tmp->slot[i].info; |
936 | |
929 | |
937 | if (tmp->type == SYMPTOM) |
930 | if (tmp->type == SYMPTOM) |
938 | min_it (speed_reduce_from_disease, tmp->last_sp ? tmp->last_sp / 100.f : 1.f); |
931 | min_it (speed_reduce_from_disease, tmp->last_sp ? tmp->last_sp / 100.f : 1.f); |
… | |
… | |
940 | /* Pos. and neg. protections are counted separate (-> pro/vuln). |
933 | /* Pos. and neg. protections are counted separate (-> pro/vuln). |
941 | * (Negative protections are calculated exactly like positive.) |
934 | * (Negative protections are calculated exactly like positive.) |
942 | * Resistance from potions are treated special as well. If there's |
935 | * Resistance from potions are treated special as well. If there's |
943 | * more than one potion-effect, the bigger prot.-value is taken. |
936 | * more than one potion-effect, the bigger prot.-value is taken. |
944 | */ |
937 | */ |
945 | if (tmp->type != POTION) |
938 | if (tmp->type == POTION_EFFECT) |
946 | { |
|
|
947 | for (int i = 0; i < NROFATTACKS; i++) |
939 | for (int i = 0; i < NROFATTACKS; i++) |
948 | { |
|
|
949 | /* Potential for cursed potions, in which case we just can use |
|
|
950 | * a straight MAX, as potion_resist is initialised to zero. |
|
|
951 | */ |
|
|
952 | if (tmp->type == POTION_EFFECT) |
|
|
953 | { |
|
|
954 | if (potion_resist[i]) |
|
|
955 | potion_resist[i] = max (potion_resist[i], tmp->resist[i]); |
|
|
956 | else |
|
|
957 | potion_resist[i] = tmp->resist[i]; |
940 | max_it (potion_resist[i], tmp->resist[i]); |
958 | } |
941 | else if (tmp->type != POTION) |
|
|
942 | for (int i = 0; i < NROFATTACKS; i++) |
959 | else if (tmp->resist[i] > 0) |
943 | if (tmp->resist[i] > 0) |
960 | prot[i] += ((100 - prot[i]) * tmp->resist[i]) / 100; |
944 | prot[i] += ((100 - prot[i]) * tmp->resist[i]) / 100; |
961 | else if (tmp->resist[i] < 0) |
945 | else if (tmp->resist[i] < 0) |
962 | vuln[i] += ((100 - vuln[i]) * -tmp->resist[i]) / 100; |
946 | vuln[i] += ((100 - vuln[i]) * -tmp->resist[i]) / 100; |
963 | } |
|
|
964 | } |
|
|
965 | |
947 | |
966 | /* There may be other things that should not adjust the attacktype */ |
948 | /* There may be other things that should not adjust the attacktype */ |
967 | if (tmp->type != SYMPTOM) |
949 | if (tmp->type != SYMPTOM) |
968 | { |
950 | { |
969 | attacktype |= tmp->attacktype; |
951 | attacktype |= tmp->attacktype; |
… | |
… | |
977 | flag |= tmp->flag & copy_flags; |
959 | flag |= tmp->flag & copy_flags; |
978 | |
960 | |
979 | if (QUERY_FLAG (tmp, FLAG_UNDEAD) && !QUERY_FLAG (arch, FLAG_UNDEAD)) |
961 | if (QUERY_FLAG (tmp, FLAG_UNDEAD) && !QUERY_FLAG (arch, FLAG_UNDEAD)) |
980 | SET_FLAG (this, FLAG_UNDEAD); |
962 | SET_FLAG (this, FLAG_UNDEAD); |
981 | |
963 | |
|
|
964 | //TODO: copy_flags? |
982 | if (QUERY_FLAG (tmp, FLAG_MAKE_INVIS)) |
965 | if (QUERY_FLAG (tmp, FLAG_MAKE_INVIS)) |
983 | { |
966 | { |
984 | SET_FLAG (this, FLAG_MAKE_INVIS); |
967 | SET_FLAG (this, FLAG_MAKE_INVIS); |
985 | invisible = 1; |
968 | invisible = 1; |
986 | } |
969 | } |
… | |
… | |
996 | added_speed += tmp->stats.exp; |
979 | added_speed += tmp->stats.exp; |
997 | } |
980 | } |
998 | |
981 | |
999 | switch (tmp->type) |
982 | switch (tmp->type) |
1000 | { |
983 | { |
1001 | /* skills modifying the character -b.t. */ |
|
|
1002 | /* for all skills and skill granting objects */ |
|
|
1003 | case SKILL: |
984 | case SKILL: |
1004 | { |
985 | { |
|
|
986 | // some skills will end up here without counting as "applied" |
1005 | if (!QUERY_FLAG (tmp, FLAG_APPLIED) || skill_flags [tmp->subtype] & SF_APPLY) |
987 | if (!tmp->flag [FLAG_APPLIED] || skill_flags [tmp->subtype] & SF_APPLY) |
1006 | break; |
988 | break; |
1007 | |
989 | |
1008 | if (chosen_skill) |
990 | if (chosen_skill) |
1009 | { |
991 | { |
1010 | LOG (llevDebug, "fix_player, op %s has multiple skills applied (%s and %s)\n", |
992 | LOG (llevDebug, "fix_player, op %s has multiple skills applied (%s and %s)\n", |
… | |
… | |
1012 | |
994 | |
1013 | tmp->flag [FLAG_APPLIED] = false; |
995 | tmp->flag [FLAG_APPLIED] = false; |
1014 | update_stats (); |
996 | update_stats (); |
1015 | return; |
997 | return; |
1016 | } |
998 | } |
1017 | else |
999 | |
1018 | chosen_skill = tmp; |
1000 | chosen_skill = tmp; |
1019 | |
1001 | |
1020 | if (tmp->stats.dam > 0) |
1002 | if (tmp->stats.dam > 0) |
1021 | { /* skill is a 'weapon' */ |
1003 | { /* skill is a 'weapon' */ |
1022 | if (!QUERY_FLAG (this, FLAG_READY_WEAPON)) |
1004 | if (!QUERY_FLAG (this, FLAG_READY_WEAPON)) |
1023 | weapon_speed = WEAPON_SPEED (tmp); |
1005 | weapon_speed = max (0, WEAPON_SPEED (tmp)); |
1024 | |
|
|
1025 | if (weapon_speed < 0) |
|
|
1026 | weapon_speed = 0; |
|
|
1027 | |
1006 | |
1028 | weapon_weight = tmp->weight; |
1007 | weapon_weight = tmp->weight; |
1029 | stats.dam += 1 + chosen_skill->level * tmp->stats.dam / 9; |
1008 | stats.dam += 1 + chosen_skill->level * tmp->stats.dam / 9; |
1030 | |
1009 | |
1031 | if (tmp->magic) |
1010 | if (tmp->magic) |
… | |
… | |
1070 | break; |
1049 | break; |
1071 | |
1050 | |
1072 | case WAND: |
1051 | case WAND: |
1073 | case ROD: |
1052 | case ROD: |
1074 | case HORN: |
1053 | case HORN: |
1075 | case SKILL_TOOL: |
|
|
1076 | if (type != PLAYER) |
|
|
1077 | chosen_skill = find_skill_by_name (this, tmp->skill); |
|
|
1078 | break; |
1054 | break; |
1079 | |
1055 | |
1080 | case BOW: |
1056 | case BOW: |
1081 | case WEAPON: |
1057 | case WEAPON: |
1082 | if (type != PLAYER || current_weapon == tmp) |
|
|
1083 | { |
|
|
1084 | chosen_skill = find_skill_by_name (this, tmp->skill); |
|
|
1085 | |
|
|
1086 | wc -= tmp->stats.wc + tmp->magic; |
1058 | wc -= tmp->stats.wc + tmp->magic; |
1087 | |
1059 | |
1088 | if (tmp->stats.ac && tmp->stats.ac + tmp->magic > 0) |
1060 | if (tmp->stats.ac && tmp->stats.ac + tmp->magic > 0) |
1089 | ac -= tmp->stats.ac + tmp->magic; |
1061 | ac -= tmp->stats.ac + tmp->magic; |
1090 | |
1062 | |
1091 | stats.dam += tmp->stats.dam + tmp->magic; |
1063 | stats.dam += tmp->stats.dam + tmp->magic; |
1092 | weapon_weight = tmp->weight; |
1064 | weapon_weight = tmp->weight; |
1093 | weapon_speed = (WEAPON_SPEED (tmp) * 2 - tmp->magic) / 2; |
1065 | weapon_speed = (WEAPON_SPEED (tmp) * 2 - tmp->magic) / 2; |
1094 | |
1066 | |
1095 | if (weapon_speed < 0) |
1067 | if (weapon_speed < 0) |
1096 | weapon_speed = 0; |
1068 | weapon_speed = 0; |
1097 | |
1069 | |
1098 | slaying = tmp->slaying; |
1070 | slaying = tmp->slaying; |
1099 | |
1071 | |
1100 | /* If there is desire that two handed weapons should do |
1072 | /* If there is desire that two handed weapons should do |
1101 | * extra strength damage, this is where the code should |
1073 | * extra strength damage, this is where the code should |
1102 | * go. |
1074 | * go. |
1103 | */ |
1075 | */ |
1104 | |
1076 | |
1105 | if (type == PLAYER) |
1077 | if (type == PLAYER) |
1106 | if (settings.spell_encumbrance) |
1078 | if (settings.spell_encumbrance) |
1107 | contr->encumbrance += tmp->weight * 3 / 1000; |
1079 | contr->encumbrance += tmp->weight * 3 / 1000; |
1108 | } |
|
|
1109 | |
1080 | |
1110 | break; |
1081 | break; |
1111 | |
1082 | |
1112 | case ARMOUR: /* Only the best of these three are used: */ |
1083 | case ARMOUR: /* Only the best of these three are used: */ |
1113 | if (settings.spell_encumbrance == TRUE && type == PLAYER) |
1084 | if (settings.spell_encumbrance == TRUE && type == PLAYER) |
… | |
… | |
1149 | break; |
1120 | break; |
1150 | } /* switch tmp->type */ |
1121 | } /* switch tmp->type */ |
1151 | } /* item is equipped */ |
1122 | } /* item is equipped */ |
1152 | } /* for loop of items */ |
1123 | } /* for loop of items */ |
1153 | |
1124 | |
1154 | if (type != PLAYER) |
|
|
1155 | this->chosen_skill = chosen_skill; |
|
|
1156 | |
|
|
1157 | glow_radius = min (glow_radius, MAX_LIGHT_RADIUS); |
1125 | min_it (glow_radius, MAX_LIGHT_RADIUS); |
1158 | |
1126 | |
1159 | /* We've gone through all the objects the player has equipped. For many things, we |
1127 | /* We've gone through all the objects the player has equipped. For many things, we |
1160 | * have generated intermediate values which we now need to assign. |
1128 | * have generated intermediate values which we now need to assign. |
1161 | */ |
1129 | */ |
1162 | |
1130 | |
… | |
… | |
1168 | */ |
1136 | */ |
1169 | for (int i = 0; i < NROFATTACKS; i++) |
1137 | for (int i = 0; i < NROFATTACKS; i++) |
1170 | { |
1138 | { |
1171 | resist[i] = prot[i] - vuln[i]; |
1139 | resist[i] = prot[i] - vuln[i]; |
1172 | |
1140 | |
1173 | if (potion_resist[i] && ((potion_resist[i] > resist[i]) || (potion_resist[i] < 0))) |
1141 | if (potion_resist[i] != -1000 |
|
|
1142 | && (potion_resist[i] < 0 || potion_resist[i] > resist[i])) |
1174 | resist[i] = potion_resist[i]; |
1143 | resist[i] = potion_resist[i]; |
1175 | } |
1144 | } |
1176 | |
1145 | |
1177 | if (type == PLAYER) |
1146 | if (type == PLAYER) |
1178 | { |
1147 | { |