1 #include "player/player-status-resist.h"
2 #include "art-definition/art-sword-types.h"
4 #include "inventory/inventory-slot-types.h"
5 #include "monster-race/monster-race.h"
6 #include "monster-race/race-flags2.h"
7 #include "monster-race/race-flags7.h"
8 #include "mutation/mutation-flag-types.h"
9 #include "object-enchant/object-ego.h"
10 #include "object-enchant/tr-types.h"
11 #include "object-enchant/trc-types.h"
12 #include "object-hook/hook-checker.h"
13 #include "object-hook/hook-weapon.h"
14 #include "object/object-flags.h"
15 #include "player/player-class.h"
16 #include "player/player-race-types.h"
17 #include "player/player-race.h"
18 #include "player/player-skill.h"
19 #include "player/player-status-flags.h"
20 #include "player/player-status.h"
21 #include "player/special-defense-types.h"
22 #include "realm/realm-hex-numbers.h"
23 #include "realm/realm-song-numbers.h"
24 #include "realm/realm-types.h"
25 #include "spell-realm/spells-hex.h"
26 #include "status/element-resistance.h"
27 #include "sv-definition/sv-weapon-types.h"
28 #include "system/floor-type-definition.h"
29 #include "system/monster-type-definition.h"
30 #include "system/object-type-definition.h"
31 #include "util/bit-flags-calculator.h"
32 #include "util/quarks.h"
33 #include "util/string-processor.h"
35 PERCENTAGE randrate(int dice, int fix, rate_calc_type_mode mode)
39 return randint1(dice) * 100 + fix * 100;
42 return (dice + 1) * 50 + fix * 100;
45 return (fix + 1) * 100;
48 return (dice + fix) * 100;
51 return (fix + 1) * 100;
56 PERCENTAGE calc_acid_damage_rate(player_type *creature_ptr)
61 if (is_immune_acid(creature_ptr)) {
65 BIT_FLAGS flgs = is_vuln_acid(creature_ptr);
66 for (i = 0; i < FLAG_CAUSE_MAX; i++) {
67 if (flgs & (0x01 << i)) {
68 if (i == FLAG_CAUSE_MUTATION) {
76 if (creature_ptr->resist_acid)
78 if (is_oppose_acid(creature_ptr))
84 PERCENTAGE calc_elec_damage_rate(player_type *creature_ptr)
89 if (is_immune_elec(creature_ptr)) {
93 BIT_FLAGS flgs = is_vuln_elec(creature_ptr);
94 for (i = 0; i < FLAG_CAUSE_MAX; i++) {
95 if (flgs & (0x01 << i)) {
96 if (i == FLAG_CAUSE_MUTATION) {
104 if (creature_ptr->resist_elec)
106 if (is_oppose_elec(creature_ptr))
112 PERCENTAGE calc_fire_damage_rate(player_type *creature_ptr)
114 PERCENTAGE per = 100;
116 BIT_FLAGS flgs = is_vuln_fire(creature_ptr);
117 for (i = 0; i < FLAG_CAUSE_MAX; i++) {
118 if (flgs & (0x01 << i)) {
119 if (i == FLAG_CAUSE_MUTATION) {
127 /* Resist the damage */
128 if (creature_ptr->resist_fire)
130 if (is_oppose_fire(creature_ptr))
136 PERCENTAGE calc_cold_damage_rate(player_type *creature_ptr)
138 PERCENTAGE per = 100;
140 BIT_FLAGS flgs = is_vuln_cold(creature_ptr);
141 for (i = 0; i < FLAG_CAUSE_MAX; i++) {
142 if (flgs & (0x01 << i)) {
143 if (i == FLAG_CAUSE_MUTATION) {
151 if (creature_ptr->resist_cold)
153 if (is_oppose_cold(creature_ptr))
159 PERCENTAGE calc_pois_damage_rate(player_type *creature_ptr)
161 PERCENTAGE per = 100;
162 if (creature_ptr->resist_pois)
164 if (is_oppose_pois(creature_ptr))
170 PERCENTAGE calc_nuke_damage_rate(player_type *creature_ptr)
172 PERCENTAGE per = 100;
173 if (creature_ptr->resist_pois)
175 if (is_oppose_pois(creature_ptr))
181 PERCENTAGE calc_lite_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
183 PERCENTAGE per = 100;
184 if (is_specific_player_race(creature_ptr, RACE_VAMPIRE) || (creature_ptr->mimic_form == MIMIC_VAMPIRE)) {
186 } else if (is_specific_player_race(creature_ptr, RACE_S_FAIRY)) {
190 if (creature_ptr->resist_lite) {
192 per /= randrate(4, 7, mode);
195 if (creature_ptr->wraith_form)
201 PERCENTAGE calc_dark_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
203 PERCENTAGE per = 100;
205 if (is_specific_player_race(creature_ptr, RACE_VAMPIRE) || (creature_ptr->mimic_form == MIMIC_VAMPIRE) || creature_ptr->wraith_form) {
209 if (creature_ptr->resist_dark) {
211 per /= randrate(4, 7, mode);
217 PERCENTAGE calc_shards_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
219 PERCENTAGE per = 100;
221 if (creature_ptr->resist_shard) {
223 per /= randrate(4, 7, mode);
229 PERCENTAGE calc_sound_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
231 PERCENTAGE per = 100;
233 if (creature_ptr->resist_sound) {
235 per /= randrate(4, 7, mode);
241 PERCENTAGE calc_conf_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
243 PERCENTAGE per = 100;
245 if (creature_ptr->resist_conf) {
247 per /= randrate(4, 7, mode);
253 PERCENTAGE calc_chaos_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
255 PERCENTAGE per = 100;
257 if (creature_ptr->resist_chaos) {
259 per /= randrate(4, 7, mode);
265 PERCENTAGE calc_disenchant_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
267 PERCENTAGE per = 100;
269 if (creature_ptr->resist_disen) {
271 per /= randrate(4, 7, mode);
277 PERCENTAGE calc_nether_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
279 PERCENTAGE per = 100;
281 if (creature_ptr->resist_neth) {
282 if (!is_specific_player_race(creature_ptr, RACE_SPECTRE))
285 per /= randrate(4, 7, mode);
291 PERCENTAGE calc_holy_fire_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
294 PERCENTAGE per = 100;
295 if (creature_ptr->align > 10)
297 else if (creature_ptr->align < -10)
302 PERCENTAGE calc_hell_fire_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
305 PERCENTAGE per = 100;
306 if (creature_ptr->align > 10)