… | |
… | |
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 (tmp->flag [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); |
… | |
… | |
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_EFFECT) |
938 | if (tmp->type == POTION_EFFECT) |
946 | for (int i = 0; i < NROFATTACKS; i++) |
939 | for (int i = 0; i < NROFATTACKS; i++) |
947 | { |
|
|
948 | /* Potential for cursed potions, in which case we just can use |
|
|
949 | * a straight MAX, as potion_resist is initialised to zero. |
|
|
950 | // TODO: this is askign for a magic marker optimisation |
|
|
951 | */ |
|
|
952 | if (potion_resist[i]) |
|
|
953 | max_it (potion_resist[i], tmp->resist[i]); |
940 | max_it (potion_resist[i], tmp->resist[i]); |
954 | else |
|
|
955 | potion_resist[i] = tmp->resist[i]; |
|
|
956 | } |
|
|
957 | else if (tmp->type != POTION) |
941 | else if (tmp->type != POTION) |
958 | for (int i = 0; i < NROFATTACKS; i++) |
942 | for (int i = 0; i < NROFATTACKS; i++) |
959 | 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) |
… | |
… | |
975 | flag |= tmp->flag & copy_flags; |
959 | flag |= tmp->flag & copy_flags; |
976 | |
960 | |
977 | if (QUERY_FLAG (tmp, FLAG_UNDEAD) && !QUERY_FLAG (arch, FLAG_UNDEAD)) |
961 | if (QUERY_FLAG (tmp, FLAG_UNDEAD) && !QUERY_FLAG (arch, FLAG_UNDEAD)) |
978 | SET_FLAG (this, FLAG_UNDEAD); |
962 | SET_FLAG (this, FLAG_UNDEAD); |
979 | |
963 | |
|
|
964 | //TODO: copy_flags? |
980 | if (QUERY_FLAG (tmp, FLAG_MAKE_INVIS)) |
965 | if (QUERY_FLAG (tmp, FLAG_MAKE_INVIS)) |
981 | { |
966 | { |
982 | SET_FLAG (this, FLAG_MAKE_INVIS); |
967 | SET_FLAG (this, FLAG_MAKE_INVIS); |
983 | invisible = 1; |
968 | invisible = 1; |
984 | } |
969 | } |
… | |
… | |
994 | added_speed += tmp->stats.exp; |
979 | added_speed += tmp->stats.exp; |
995 | } |
980 | } |
996 | |
981 | |
997 | switch (tmp->type) |
982 | switch (tmp->type) |
998 | { |
983 | { |
999 | /* skills modifying the character -b.t. */ |
|
|
1000 | /* for all skills and skill granting objects */ |
|
|
1001 | case SKILL: |
984 | case SKILL: |
1002 | { |
985 | { |
|
|
986 | // some skills will end up here without counting as "applied" |
1003 | if (!QUERY_FLAG (tmp, FLAG_APPLIED) || skill_flags [tmp->subtype] & SF_APPLY) |
987 | if (!tmp->flag [FLAG_APPLIED] || skill_flags [tmp->subtype] & SF_APPLY) |
1004 | break; |
988 | break; |
1005 | |
989 | |
1006 | if (chosen_skill) |
990 | if (chosen_skill) |
1007 | { |
991 | { |
1008 | 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", |
… | |
… | |
1010 | |
994 | |
1011 | tmp->flag [FLAG_APPLIED] = false; |
995 | tmp->flag [FLAG_APPLIED] = false; |
1012 | update_stats (); |
996 | update_stats (); |
1013 | return; |
997 | return; |
1014 | } |
998 | } |
1015 | else |
999 | |
1016 | chosen_skill = tmp; |
1000 | chosen_skill = tmp; |
1017 | |
1001 | |
1018 | if (tmp->stats.dam > 0) |
1002 | if (tmp->stats.dam > 0) |
1019 | { /* skill is a 'weapon' */ |
1003 | { /* skill is a 'weapon' */ |
1020 | if (!QUERY_FLAG (this, FLAG_READY_WEAPON)) |
1004 | if (!QUERY_FLAG (this, FLAG_READY_WEAPON)) |
1021 | weapon_speed = WEAPON_SPEED (tmp); |
1005 | weapon_speed = max (0, WEAPON_SPEED (tmp)); |
1022 | |
|
|
1023 | if (weapon_speed < 0) |
|
|
1024 | weapon_speed = 0; |
|
|
1025 | |
1006 | |
1026 | weapon_weight = tmp->weight; |
1007 | weapon_weight = tmp->weight; |
1027 | stats.dam += 1 + chosen_skill->level * tmp->stats.dam / 9; |
1008 | stats.dam += 1 + chosen_skill->level * tmp->stats.dam / 9; |
1028 | |
1009 | |
1029 | if (tmp->magic) |
1010 | if (tmp->magic) |
… | |
… | |
1068 | break; |
1049 | break; |
1069 | |
1050 | |
1070 | case WAND: |
1051 | case WAND: |
1071 | case ROD: |
1052 | case ROD: |
1072 | case HORN: |
1053 | case HORN: |
1073 | case SKILL_TOOL: |
|
|
1074 | if (type != PLAYER) |
|
|
1075 | chosen_skill = find_skill_by_name (this, tmp->skill); |
|
|
1076 | break; |
1054 | break; |
1077 | |
1055 | |
1078 | case BOW: |
1056 | case BOW: |
1079 | case WEAPON: |
1057 | case WEAPON: |
1080 | if (type != PLAYER || current_weapon == tmp) |
|
|
1081 | { |
|
|
1082 | chosen_skill = find_skill_by_name (this, tmp->skill); |
|
|
1083 | |
|
|
1084 | wc -= tmp->stats.wc + tmp->magic; |
1058 | wc -= tmp->stats.wc + tmp->magic; |
1085 | |
1059 | |
1086 | if (tmp->stats.ac && tmp->stats.ac + tmp->magic > 0) |
1060 | if (tmp->stats.ac && tmp->stats.ac + tmp->magic > 0) |
1087 | ac -= tmp->stats.ac + tmp->magic; |
1061 | ac -= tmp->stats.ac + tmp->magic; |
1088 | |
1062 | |
1089 | stats.dam += tmp->stats.dam + tmp->magic; |
1063 | stats.dam += tmp->stats.dam + tmp->magic; |
1090 | weapon_weight = tmp->weight; |
1064 | weapon_weight = tmp->weight; |
1091 | weapon_speed = (WEAPON_SPEED (tmp) * 2 - tmp->magic) / 2; |
1065 | weapon_speed = (WEAPON_SPEED (tmp) * 2 - tmp->magic) / 2; |
1092 | |
1066 | |
1093 | if (weapon_speed < 0) |
1067 | if (weapon_speed < 0) |
1094 | weapon_speed = 0; |
1068 | weapon_speed = 0; |
1095 | |
1069 | |
1096 | slaying = tmp->slaying; |
1070 | slaying = tmp->slaying; |
1097 | |
1071 | |
1098 | /* If there is desire that two handed weapons should do |
1072 | /* If there is desire that two handed weapons should do |
1099 | * extra strength damage, this is where the code should |
1073 | * extra strength damage, this is where the code should |
1100 | * go. |
1074 | * go. |
1101 | */ |
1075 | */ |
1102 | |
1076 | |
1103 | if (type == PLAYER) |
1077 | if (type == PLAYER) |
1104 | if (settings.spell_encumbrance) |
1078 | if (settings.spell_encumbrance) |
1105 | contr->encumbrance += tmp->weight * 3 / 1000; |
1079 | contr->encumbrance += tmp->weight * 3 / 1000; |
1106 | } |
|
|
1107 | |
1080 | |
1108 | break; |
1081 | break; |
1109 | |
1082 | |
1110 | case ARMOUR: /* Only the best of these three are used: */ |
1083 | case ARMOUR: /* Only the best of these three are used: */ |
1111 | if (settings.spell_encumbrance == TRUE && type == PLAYER) |
1084 | if (settings.spell_encumbrance == TRUE && type == PLAYER) |
… | |
… | |
1147 | break; |
1120 | break; |
1148 | } /* switch tmp->type */ |
1121 | } /* switch tmp->type */ |
1149 | } /* item is equipped */ |
1122 | } /* item is equipped */ |
1150 | } /* for loop of items */ |
1123 | } /* for loop of items */ |
1151 | |
1124 | |
1152 | if (type != PLAYER) |
|
|
1153 | this->chosen_skill = chosen_skill; |
|
|
1154 | |
|
|
1155 | glow_radius = min (glow_radius, MAX_LIGHT_RADIUS); |
1125 | min_it (glow_radius, MAX_LIGHT_RADIUS); |
1156 | |
1126 | |
1157 | /* 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 |
1158 | * have generated intermediate values which we now need to assign. |
1128 | * have generated intermediate values which we now need to assign. |
1159 | */ |
1129 | */ |
1160 | |
1130 | |
… | |
… | |
1166 | */ |
1136 | */ |
1167 | for (int i = 0; i < NROFATTACKS; i++) |
1137 | for (int i = 0; i < NROFATTACKS; i++) |
1168 | { |
1138 | { |
1169 | resist[i] = prot[i] - vuln[i]; |
1139 | resist[i] = prot[i] - vuln[i]; |
1170 | |
1140 | |
1171 | 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])) |
1172 | resist[i] = potion_resist[i]; |
1143 | resist[i] = potion_resist[i]; |
1173 | } |
1144 | } |
1174 | |
1145 | |
1175 | if (type == PLAYER) |
1146 | if (type == PLAYER) |
1176 | { |
1147 | { |