1 #include "player/player-status-resist.h"
2 #include "artifact/fixed-art-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/mimic-info-table.h"
16 #include "player/player-class.h"
17 #include "player/player-race-types.h"
18 #include "player/player-race.h"
19 #include "player/player-skill.h"
20 #include "player/player-status-flags.h"
21 #include "player/player-status.h"
22 #include "player/special-defense-types.h"
23 #include "realm/realm-hex-numbers.h"
24 #include "realm/realm-song-numbers.h"
25 #include "realm/realm-types.h"
26 #include "spell-realm/spells-hex.h"
27 #include "status/element-resistance.h"
28 #include "sv-definition/sv-weapon-types.h"
29 #include "system/floor-type-definition.h"
30 #include "system/monster-type-definition.h"
31 #include "system/object-type-definition.h"
32 #include "util/bit-flags-calculator.h"
33 #include "util/quarks.h"
34 #include "util/string-processor.h"
37 * @brief 耐性倍率計算の用途に応じた分岐処理
39 PERCENTAGE randrate(int dice, int fix, rate_calc_type_mode mode)
43 return randint1(dice) * 100 + fix * 100;
46 return (dice + 1) * 50 + fix * 100;
49 return (fix + 1) * 100;
52 return (dice + fix) * 100;
55 return (fix + 1) * 100;
61 * @brief 酸属性攻撃に対するダメージ倍率計算
63 PERCENTAGE calc_acid_damage_rate(player_type *creature_ptr)
67 if (has_immune_acid(creature_ptr)) {
71 BIT_FLAGS flgs = has_vuln_acid(creature_ptr);
72 for (int i = 0; i < FLAG_CAUSE_MAX; i++) {
73 if (flgs & (0x01 << i)) {
74 if (i == FLAG_CAUSE_MUTATION) {
82 if (has_resist_acid(creature_ptr))
84 if (is_oppose_acid(creature_ptr))
91 * @brief 電撃属性攻撃に対するダメージ倍率計算
93 PERCENTAGE calc_elec_damage_rate(player_type *creature_ptr)
97 if (has_immune_elec(creature_ptr)) {
101 BIT_FLAGS flgs = has_vuln_elec(creature_ptr);
102 for (int i = 0; i < FLAG_CAUSE_MAX; i++) {
103 if (flgs & (0x01 << i)) {
104 if (i == FLAG_CAUSE_MUTATION) {
112 if (has_resist_elec(creature_ptr))
114 if (is_oppose_elec(creature_ptr))
121 * @brief 火炎属性攻撃に対するダメージ倍率計算
123 PERCENTAGE calc_fire_damage_rate(player_type *creature_ptr)
125 PERCENTAGE per = 100;
126 BIT_FLAGS flgs = has_vuln_fire(creature_ptr);
127 for (int i = 0; i < FLAG_CAUSE_MAX; i++) {
128 if (flgs & (0x01 << i)) {
129 if (i == FLAG_CAUSE_MUTATION) {
137 /* Resist the damage */
138 if (has_resist_fire(creature_ptr))
140 if (is_oppose_fire(creature_ptr))
147 * @brief 冷気属性攻撃に対するダメージ倍率計算
149 PERCENTAGE calc_cold_damage_rate(player_type *creature_ptr)
151 PERCENTAGE per = 100;
152 BIT_FLAGS flgs = has_vuln_cold(creature_ptr);
153 for (int i = 0; i < FLAG_CAUSE_MAX; i++) {
154 if (flgs & (0x01 << i)) {
155 if (i == FLAG_CAUSE_MUTATION) {
163 if (has_resist_cold(creature_ptr))
165 if (is_oppose_cold(creature_ptr))
172 * @brief 毒属性攻撃に対するダメージ倍率計算
174 PERCENTAGE calc_pois_damage_rate(player_type *creature_ptr)
176 PERCENTAGE per = 100;
177 if (has_resist_pois(creature_ptr))
179 if (is_oppose_pois(creature_ptr))
186 * @brief 放射性廃棄物攻撃に対するダメージ倍率計算
188 PERCENTAGE calc_nuke_damage_rate(player_type *creature_ptr)
191 PERCENTAGE per = 100;
192 if (has_resist_pois(creature_ptr))
193 per = (2 * per + 2) / 5;
194 if (is_oppose_pois(creature_ptr))
195 per = (2 * per + 2) / 5;
201 * @brief 死の光線に対するダメージ倍率計算
203 PERCENTAGE calc_deathray_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
205 (void)mode; // unused
206 if (creature_ptr->mimic_form) {
207 if (mimic_info[creature_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_NONLIVING) {
212 switch (creature_ptr->prace) {
227 * @brief 閃光属性攻撃に対するダメージ倍率計算
229 PERCENTAGE calc_lite_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
231 PERCENTAGE per = 100;
232 if (is_specific_player_race(creature_ptr, RACE_VAMPIRE) || (creature_ptr->mimic_form == MIMIC_VAMPIRE)) {
234 } else if (is_specific_player_race(creature_ptr, RACE_S_FAIRY)) {
238 if (has_resist_lite(creature_ptr)) {
240 per /= randrate(4, 7, mode);
243 if (creature_ptr->wraith_form)
250 * @brief 暗黒属性攻撃に対するダメージ倍率計算
252 PERCENTAGE calc_dark_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
254 PERCENTAGE per = 100;
256 if (is_specific_player_race(creature_ptr, RACE_VAMPIRE) || (creature_ptr->mimic_form == MIMIC_VAMPIRE) || creature_ptr->wraith_form) {
260 if (has_resist_dark(creature_ptr)) {
262 per /= randrate(4, 7, mode);
269 * @brief 破片属性攻撃に対するダメージ倍率計算
271 PERCENTAGE calc_shards_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
273 PERCENTAGE per = 100;
275 if (creature_ptr->resist_shard) {
277 per /= randrate(4, 7, mode);
284 * @brief 轟音属性攻撃に対するダメージ倍率計算
286 PERCENTAGE calc_sound_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
288 PERCENTAGE per = 100;
290 if (has_resist_sound(creature_ptr)) {
292 per /= randrate(4, 7, mode);
299 * @brief 混乱属性攻撃に対するダメージ倍率計算
301 PERCENTAGE calc_conf_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
303 PERCENTAGE per = 100;
305 if (has_resist_conf(creature_ptr)) {
307 per /= randrate(4, 7, mode);
314 * @brief 混沌属性攻撃に対するダメージ倍率計算
316 PERCENTAGE calc_chaos_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
318 PERCENTAGE per = 100;
320 if (has_resist_chaos(creature_ptr)) {
322 per /= randrate(4, 7, mode);
329 * @brief 劣化属性攻撃に対するダメージ倍率計算
331 PERCENTAGE calc_disenchant_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
333 PERCENTAGE per = 100;
335 if (creature_ptr->resist_disen) {
337 per /= randrate(4, 7, mode);
344 * @brief 因果混乱属性攻撃に対するダメージ倍率計算
346 PERCENTAGE calc_nexus_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
348 PERCENTAGE per = 100;
350 if (creature_ptr->resist_disen) {
352 per /= randrate(4, 7, mode);
359 * @brief ロケット属性攻撃に対するダメージ倍率計算
361 PERCENTAGE calc_rocket_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
363 (void)mode; // unused
364 PERCENTAGE per = 100;
366 if (creature_ptr->resist_shard) {
374 * @brief 地獄属性攻撃に対するダメージ倍率計算
376 PERCENTAGE calc_nether_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
378 PERCENTAGE per = 100;
380 if (creature_ptr->resist_neth) {
381 if (!is_specific_player_race(creature_ptr, RACE_SPECTRE))
384 per /= randrate(4, 7, mode);
391 * @brief 時間逆転攻撃に対するダメージ倍率計算
393 PERCENTAGE calc_time_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
395 (void)mode; // unused
396 PERCENTAGE per = 100;
398 if (creature_ptr->resist_time) {
400 per /= randrate(4, 7, mode);
407 * @brief 聖なる火炎攻撃に対するダメージ倍率計算
409 PERCENTAGE calc_holy_fire_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
411 (void)mode; // unused
412 PERCENTAGE per = 100;
413 if (creature_ptr->align > 10)
415 else if (creature_ptr->align < -10)
421 * @brief 地獄の火炎攻撃に対するダメージ倍率計算
423 PERCENTAGE calc_hell_fire_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
425 (void)mode; // unused
426 PERCENTAGE per = 100;
427 if (creature_ptr->align > 10)
433 * @brief 重力攻撃に対するダメージ倍率計算
435 PERCENTAGE calc_gravity_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
437 (void)mode; // unused
438 PERCENTAGE per = 100;
439 if (creature_ptr->levitation) {