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 BIT_FLAGS flgs = is_vuln_acid(creature_ptr);
62 for (i = 0; i < FLAG_CAUSE_MAX; i++) {
63 if (flgs & (0x01 << i)) {
64 if (i == FLAG_CAUSE_MUTATION) {
72 if (creature_ptr->resist_acid)
74 if (is_oppose_acid(creature_ptr))
80 PERCENTAGE calc_elec_damage_rate(player_type *creature_ptr)
85 if (is_immune_elec(creature_ptr)) {
89 BIT_FLAGS flgs = is_vuln_elec(creature_ptr);
90 for (i = 0; i < FLAG_CAUSE_MAX; i++) {
91 if (flgs & (0x01 << i)) {
92 if (i == FLAG_CAUSE_MUTATION) {
100 if (creature_ptr->resist_elec)
102 if (is_oppose_elec(creature_ptr))
108 PERCENTAGE calc_fire_damage_rate(player_type *creature_ptr)
110 PERCENTAGE per = 100;
112 BIT_FLAGS flgs = is_vuln_fire(creature_ptr);
113 for (i = 0; i < FLAG_CAUSE_MAX; i++) {
114 if (flgs & (0x01 << i)) {
115 if (i == FLAG_CAUSE_MUTATION) {
123 /* Resist the damage */
124 if (creature_ptr->resist_fire)
126 if (is_oppose_fire(creature_ptr))
132 PERCENTAGE calc_cold_damage_rate(player_type *creature_ptr)
134 PERCENTAGE per = 100;
136 BIT_FLAGS flgs = is_vuln_cold(creature_ptr);
137 for (i = 0; i < FLAG_CAUSE_MAX; i++) {
138 if (flgs & (0x01 << i)) {
139 if (i == FLAG_CAUSE_MUTATION) {
147 if (creature_ptr->resist_cold)
149 if (is_oppose_cold(creature_ptr))
155 PERCENTAGE calc_pois_damage_rate(player_type *creature_ptr)
157 PERCENTAGE per = 100;
158 if (creature_ptr->resist_pois)
160 if (is_oppose_pois(creature_ptr))
166 PERCENTAGE calc_nuke_damage_rate(player_type *creature_ptr)
168 PERCENTAGE per = 100;
169 if (creature_ptr->resist_pois)
171 if (is_oppose_pois(creature_ptr))
177 PERCENTAGE calc_lite_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
179 PERCENTAGE per = 100;
180 if (is_specific_player_race(creature_ptr, RACE_VAMPIRE) || (creature_ptr->mimic_form == MIMIC_VAMPIRE)) {
182 } else if (is_specific_player_race(creature_ptr, RACE_S_FAIRY)) {
186 if (creature_ptr->resist_lite) {
188 per /= randrate(4, 7, mode);
191 if (creature_ptr->wraith_form)
197 PERCENTAGE calc_dark_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
199 PERCENTAGE per = 100;
201 if (is_specific_player_race(creature_ptr, RACE_VAMPIRE) || (creature_ptr->mimic_form == MIMIC_VAMPIRE) || creature_ptr->wraith_form) {
205 if (creature_ptr->resist_dark) {
207 per /= randrate(4, 7, mode);