… | |
… | |
820 | memcpy (&resist, &arch->resist, sizeof (resist)); |
820 | memcpy (&resist, &arch->resist, sizeof (resist)); |
821 | |
821 | |
822 | for (int i = 0; i < NROFATTACKS; i++) |
822 | for (int i = 0; i < NROFATTACKS; i++) |
823 | { |
823 | { |
824 | if (resist[i] > 0) |
824 | if (resist[i] > 0) |
825 | prot[i] = resist[i], vuln[i] = 0; |
825 | prot[i] = resist[i], vuln[i] = 0; |
826 | else |
826 | else |
827 | vuln[i] = -(resist[i]), prot[i] = 0; |
827 | vuln[i] = -resist[i], prot[i] = 0; |
828 | |
828 | |
829 | potion_resist[i] = 0; |
829 | potion_resist[i] = -1000; |
830 | } |
830 | } |
831 | |
831 | |
832 | wc = arch->stats.wc; |
832 | wc = arch->stats.wc; |
833 | stats.dam = arch->stats.dam; |
833 | stats.dam = arch->stats.dam; |
834 | |
834 | |
… | |
… | |
928 | if (tmp->type == WEAPON) |
928 | if (tmp->type == WEAPON) |
929 | current_weapon = tmp; |
929 | current_weapon = tmp; |
930 | } |
930 | } |
931 | |
931 | |
932 | /* Update slots used for items */ |
932 | /* Update slots used for items */ |
933 | if (QUERY_FLAG (tmp, FLAG_APPLIED)) |
933 | if (tmp->flag [FLAG_APPLIED]) |
934 | for (int i = 0; i < NUM_BODY_LOCATIONS; i++) |
934 | for (int i = 0; i < NUM_BODY_LOCATIONS; i++) |
935 | slot[i].used += tmp->slot[i].info; |
935 | slot[i].used += tmp->slot[i].info; |
936 | |
936 | |
937 | if (tmp->type == SYMPTOM) |
937 | if (tmp->type == SYMPTOM) |
938 | speed_reduce_from_disease = |
|
|
939 | min (speed_reduce_from_disease, tmp->last_sp ? tmp->last_sp / 100.f : 1.f); |
938 | min_it (speed_reduce_from_disease, tmp->last_sp ? tmp->last_sp / 100.f : 1.f); |
940 | |
939 | |
941 | /* Pos. and neg. protections are counted separate (-> pro/vuln). |
940 | /* Pos. and neg. protections are counted separate (-> pro/vuln). |
942 | * (Negative protections are calculated exactly like positive.) |
941 | * (Negative protections are calculated exactly like positive.) |
943 | * Resistance from potions are treated special as well. If there's |
942 | * Resistance from potions are treated special as well. If there's |
944 | * more than one potion-effect, the bigger prot.-value is taken. |
943 | * more than one potion-effect, the bigger prot.-value is taken. |
945 | */ |
944 | */ |
946 | if (tmp->type != POTION) |
945 | if (tmp->type == POTION_EFFECT) |
947 | { |
|
|
948 | for (int i = 0; i < NROFATTACKS; i++) |
946 | for (int i = 0; i < NROFATTACKS; i++) |
949 | { |
|
|
950 | /* Potential for cursed potions, in which case we just can use |
|
|
951 | * a straight MAX, as potion_resist is initialised to zero. |
|
|
952 | */ |
|
|
953 | if (tmp->type == POTION_EFFECT) |
|
|
954 | { |
|
|
955 | if (potion_resist[i]) |
|
|
956 | potion_resist[i] = max (potion_resist[i], tmp->resist[i]); |
|
|
957 | else |
|
|
958 | potion_resist[i] = tmp->resist[i]; |
947 | max_it (potion_resist[i], tmp->resist[i]); |
959 | } |
948 | else if (tmp->type != POTION) |
|
|
949 | for (int i = 0; i < NROFATTACKS; i++) |
960 | else if (tmp->resist[i] > 0) |
950 | if (tmp->resist[i] > 0) |
961 | prot[i] += ((100 - prot[i]) * tmp->resist[i]) / 100; |
951 | prot[i] += ((100 - prot[i]) * tmp->resist[i]) / 100; |
962 | else if (tmp->resist[i] < 0) |
952 | else if (tmp->resist[i] < 0) |
963 | vuln[i] += ((100 - vuln[i]) * -tmp->resist[i]) / 100; |
953 | vuln[i] += ((100 - vuln[i]) * -tmp->resist[i]) / 100; |
964 | } |
|
|
965 | } |
|
|
966 | |
954 | |
967 | /* There may be other things that should not adjust the attacktype */ |
955 | /* There may be other things that should not adjust the attacktype */ |
968 | if (tmp->type != SYMPTOM) |
956 | if (tmp->type != SYMPTOM) |
969 | { |
957 | { |
970 | attacktype |= tmp->attacktype; |
958 | attacktype |= tmp->attacktype; |
… | |
… | |
1041 | |
1029 | |
1042 | if (tmp->stats.ac) |
1030 | if (tmp->stats.ac) |
1043 | ac -= tmp->stats.ac + tmp->magic; |
1031 | ac -= tmp->stats.ac + tmp->magic; |
1044 | |
1032 | |
1045 | if (settings.spell_encumbrance == TRUE && type == PLAYER) |
1033 | if (settings.spell_encumbrance == TRUE && type == PLAYER) |
1046 | contr->encumbrance += (int) 3 *tmp->weight / 1000; |
1034 | contr->encumbrance += 3 * tmp->weight / 1000; |
1047 | } |
1035 | } |
1048 | |
1036 | |
1049 | break; |
1037 | break; |
1050 | |
1038 | |
1051 | case SHIELD: |
1039 | case SHIELD: |
1052 | if (settings.spell_encumbrance == TRUE && type == PLAYER) |
1040 | if (settings.spell_encumbrance == TRUE && type == PLAYER) |
1053 | contr->encumbrance += (int) tmp->weight / 2000; |
1041 | contr->encumbrance += tmp->weight / 2000; |
|
|
1042 | //FALLTHROUGH |
1054 | case RING: |
1043 | case RING: |
1055 | case AMULET: |
1044 | case AMULET: |
1056 | case GIRDLE: |
1045 | case GIRDLE: |
1057 | case HELMET: |
1046 | case HELMET: |
1058 | case BOOTS: |
1047 | case BOOTS: |
… | |
… | |
1152 | } /* for loop of items */ |
1141 | } /* for loop of items */ |
1153 | |
1142 | |
1154 | if (type != PLAYER) |
1143 | if (type != PLAYER) |
1155 | this->chosen_skill = chosen_skill; |
1144 | this->chosen_skill = chosen_skill; |
1156 | |
1145 | |
1157 | glow_radius = min (glow_radius, MAX_LIGHT_RADIUS); |
1146 | min_it (glow_radius, MAX_LIGHT_RADIUS); |
1158 | |
1147 | |
1159 | /* We've gone through all the objects the player has equipped. For many things, we |
1148 | /* 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. |
1149 | * have generated intermediate values which we now need to assign. |
1161 | */ |
1150 | */ |
1162 | |
1151 | |
… | |
… | |
1168 | */ |
1157 | */ |
1169 | for (int i = 0; i < NROFATTACKS; i++) |
1158 | for (int i = 0; i < NROFATTACKS; i++) |
1170 | { |
1159 | { |
1171 | resist[i] = prot[i] - vuln[i]; |
1160 | resist[i] = prot[i] - vuln[i]; |
1172 | |
1161 | |
1173 | if (potion_resist[i] && ((potion_resist[i] > resist[i]) || (potion_resist[i] < 0))) |
1162 | if (potion_resist[i] != -1000 |
|
|
1163 | && (potion_resist[i] < 0 || potion_resist[i] > resist[i])) |
1174 | resist[i] = potion_resist[i]; |
1164 | resist[i] = potion_resist[i]; |
1175 | } |
1165 | } |
1176 | |
1166 | |
1177 | if (type == PLAYER) |
1167 | if (type == PLAYER) |
1178 | { |
1168 | { |