… | |
… | |
940 | /* Pos. and neg. protections are counted separate (-> pro/vuln). |
940 | /* Pos. and neg. protections are counted separate (-> pro/vuln). |
941 | * (Negative protections are calculated exactly like positive.) |
941 | * (Negative protections are calculated exactly like positive.) |
942 | * Resistance from potions are treated special as well. If there's |
942 | * Resistance from potions are treated special as well. If there's |
943 | * more than one potion-effect, the bigger prot.-value is taken. |
943 | * more than one potion-effect, the bigger prot.-value is taken. |
944 | */ |
944 | */ |
945 | if (tmp->type != POTION) |
945 | if (tmp->type == POTION_EFFECT) |
946 | { |
|
|
947 | for (int i = 0; i < NROFATTACKS; i++) |
946 | for (int i = 0; i < NROFATTACKS; i++) |
948 | { |
947 | { |
949 | /* Potential for cursed potions, in which case we just can use |
948 | /* Potential for cursed potions, in which case we just can use |
950 | * a straight MAX, as potion_resist is initialised to zero. |
949 | * a straight MAX, as potion_resist is initialised to zero. |
|
|
950 | // TODO: this is askign for a magic marker optimisation |
951 | */ |
951 | */ |
952 | if (tmp->type == POTION_EFFECT) |
|
|
953 | { |
|
|
954 | if (potion_resist[i]) |
952 | if (potion_resist[i]) |
955 | potion_resist[i] = max (potion_resist[i], tmp->resist[i]); |
953 | max_it (potion_resist[i], tmp->resist[i]); |
956 | else |
954 | else |
957 | potion_resist[i] = tmp->resist[i]; |
955 | potion_resist[i] = tmp->resist[i]; |
958 | } |
956 | } |
|
|
957 | else if (tmp->type != POTION) |
|
|
958 | for (int i = 0; i < NROFATTACKS; i++) |
959 | else if (tmp->resist[i] > 0) |
959 | if (tmp->resist[i] > 0) |
960 | prot[i] += ((100 - prot[i]) * tmp->resist[i]) / 100; |
960 | prot[i] += ((100 - prot[i]) * tmp->resist[i]) / 100; |
961 | else if (tmp->resist[i] < 0) |
961 | else if (tmp->resist[i] < 0) |
962 | vuln[i] += ((100 - vuln[i]) * -tmp->resist[i]) / 100; |
962 | vuln[i] += ((100 - vuln[i]) * -tmp->resist[i]) / 100; |
963 | } |
|
|
964 | } |
|
|
965 | |
963 | |
966 | /* There may be other things that should not adjust the attacktype */ |
964 | /* There may be other things that should not adjust the attacktype */ |
967 | if (tmp->type != SYMPTOM) |
965 | if (tmp->type != SYMPTOM) |
968 | { |
966 | { |
969 | attacktype |= tmp->attacktype; |
967 | attacktype |= tmp->attacktype; |