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-weapon.h"
13 #include "object/object-flags.h"
14 #include "player-base/player-race.h"
15 #include "player-info/class-info.h"
16 #include "player-info/race-info.h"
17 #include "player/player-skill.h"
18 #include "player/player-status-flags.h"
19 #include "player/player-status.h"
20 #include "player/special-defense-types.h"
21 #include "realm/realm-hex-numbers.h"
22 #include "realm/realm-song-numbers.h"
23 #include "realm/realm-types.h"
24 #include "spell-realm/spells-hex.h"
25 #include "status/element-resistance.h"
26 #include "sv-definition/sv-weapon-types.h"
27 #include "system/floor-type-definition.h"
28 #include "system/monster-type-definition.h"
29 #include "system/object-type-definition.h"
30 #include "system/player-type-definition.h"
31 #include "util/bit-flags-calculator.h"
32 #include "util/quarks.h"
33 #include "util/string-processor.h"
36 * @brief 耐性倍率計算の用途に応じた分岐処理
38 PERCENTAGE randrate(int dice, int fix, rate_calc_type_mode mode)
42 return randint1(dice) * 100 + fix * 100;
45 return (dice + 1) * 50 + fix * 100;
48 return (fix + 1) * 100;
51 return (dice + fix) * 100;
54 return (fix + 1) * 100;
60 * @brief 酸属性攻撃に対するダメージ倍率計算
62 PERCENTAGE calc_acid_damage_rate(PlayerType *player_ptr)
66 if (has_immune_acid(player_ptr)) {
70 BIT_FLAGS flgs = has_vuln_acid(player_ptr);
72 for (BIT_FLAGS check_flag = 0x01U; check_flag < FLAG_CAUSE_MAX; check_flag <<= 1) {
73 if (any_bits(flgs, check_flag)) {
74 if (check_flag == FLAG_CAUSE_MUTATION) {
82 if (has_resist_acid(player_ptr))
84 if (is_oppose_acid(player_ptr))
91 * @brief 電撃属性攻撃に対するダメージ倍率計算
93 PERCENTAGE calc_elec_damage_rate(PlayerType *player_ptr)
97 if (has_immune_elec(player_ptr)) {
101 BIT_FLAGS flgs = has_vuln_elec(player_ptr);
102 for (BIT_FLAGS check_flag = 0x01U; check_flag < FLAG_CAUSE_MAX; check_flag <<= 1) {
103 if (any_bits(flgs, check_flag)) {
104 if (check_flag == FLAG_CAUSE_MUTATION) {
112 if (has_resist_elec(player_ptr))
114 if (is_oppose_elec(player_ptr))
121 * @brief 火炎属性攻撃に対するダメージ倍率計算
123 PERCENTAGE calc_fire_damage_rate(PlayerType *player_ptr)
125 PERCENTAGE per = 100;
126 BIT_FLAGS flgs = has_vuln_fire(player_ptr);
127 for (BIT_FLAGS check_flag = 0x01U; check_flag < FLAG_CAUSE_MAX; check_flag <<= 1) {
128 if (any_bits(flgs, check_flag)) {
129 if (check_flag == FLAG_CAUSE_MUTATION) {
137 /* Resist the damage */
138 if (has_resist_fire(player_ptr))
140 if (is_oppose_fire(player_ptr))
147 * @brief 冷気属性攻撃に対するダメージ倍率計算
149 PERCENTAGE calc_cold_damage_rate(PlayerType *player_ptr)
151 PERCENTAGE per = 100;
152 BIT_FLAGS flgs = has_vuln_cold(player_ptr);
153 for (BIT_FLAGS check_flag = 0x01U; check_flag < FLAG_CAUSE_MAX; check_flag <<= 1) {
154 if (any_bits(flgs, check_flag)) {
155 if (check_flag == FLAG_CAUSE_MUTATION) {
163 if (has_resist_cold(player_ptr))
165 if (is_oppose_cold(player_ptr))
172 * @brief 毒属性攻撃に対するダメージ倍率計算
174 PERCENTAGE calc_pois_damage_rate(PlayerType *player_ptr)
176 PERCENTAGE per = 100;
177 if (has_resist_pois(player_ptr))
179 if (is_oppose_pois(player_ptr))
186 * @brief 放射性廃棄物攻撃に対するダメージ倍率計算
188 PERCENTAGE calc_nuke_damage_rate(PlayerType *player_ptr)
191 PERCENTAGE per = 100;
192 if (has_resist_pois(player_ptr))
193 per = (2 * per + 2) / 5;
194 if (is_oppose_pois(player_ptr))
195 per = (2 * per + 2) / 5;
201 * @brief 死の光線に対するダメージ倍率計算
203 PERCENTAGE calc_deathray_damage_rate(PlayerType *player_ptr, rate_calc_type_mode mode)
205 (void)mode; // unused
206 if (player_ptr->mimic_form) {
207 if (PlayerRace(player_ptr).is_mimic_nonliving()) {
212 switch (player_ptr->prace) {
213 case PlayerRaceType::GOLEM:
214 case PlayerRaceType::SKELETON:
215 case PlayerRaceType::ZOMBIE:
216 case PlayerRaceType::VAMPIRE:
217 case PlayerRaceType::BALROG:
218 case PlayerRaceType::SPECTRE:
230 * @brief 閃光属性攻撃に対するダメージ倍率計算
232 PERCENTAGE calc_lite_damage_rate(PlayerType *player_ptr, rate_calc_type_mode mode)
234 PERCENTAGE per = 100;
236 PlayerRace race(player_ptr);
238 if (race.tr_flags().has(TR_VUL_LITE)) {
239 switch (race.life()) {
240 case PlayerRaceLifeType::UNDEAD:
249 if (has_resist_lite(player_ptr)) {
251 per /= randrate(4, 7, mode);
254 if (player_ptr->wraith_form)
261 * @brief 暗黒属性攻撃に対するダメージ倍率計算
263 PERCENTAGE calc_dark_damage_rate(PlayerType *player_ptr, rate_calc_type_mode mode)
265 PERCENTAGE per = 100;
267 if (has_immune_dark(player_ptr))
270 if (has_resist_dark(player_ptr)) {
272 per /= randrate(4, 7, mode);
279 * @brief 破片属性攻撃に対するダメージ倍率計算
281 PERCENTAGE calc_shards_damage_rate(PlayerType *player_ptr, rate_calc_type_mode mode)
283 PERCENTAGE per = 100;
285 if (has_resist_shard(player_ptr)) {
287 per /= randrate(4, 7, mode);
294 * @brief 轟音属性攻撃に対するダメージ倍率計算
296 PERCENTAGE calc_sound_damage_rate(PlayerType *player_ptr, rate_calc_type_mode mode)
298 PERCENTAGE per = 100;
300 if (has_resist_sound(player_ptr)) {
302 per /= randrate(4, 7, mode);
309 * @brief 混乱属性攻撃に対するダメージ倍率計算
311 PERCENTAGE calc_conf_damage_rate(PlayerType *player_ptr, rate_calc_type_mode mode)
313 PERCENTAGE per = 100;
315 if (has_resist_conf(player_ptr)) {
317 per /= randrate(4, 7, mode);
324 * @brief 混沌属性攻撃に対するダメージ倍率計算
326 PERCENTAGE calc_chaos_damage_rate(PlayerType *player_ptr, rate_calc_type_mode mode)
328 PERCENTAGE per = 100;
330 if (has_resist_chaos(player_ptr)) {
332 per /= randrate(4, 7, mode);
339 * @brief 劣化属性攻撃に対するダメージ倍率計算
341 PERCENTAGE calc_disenchant_damage_rate(PlayerType *player_ptr, rate_calc_type_mode mode)
343 PERCENTAGE per = 100;
345 if (has_resist_disen(player_ptr)) {
347 per /= randrate(4, 7, mode);
354 * @brief 因果混乱属性攻撃に対するダメージ倍率計算
356 PERCENTAGE calc_nexus_damage_rate(PlayerType *player_ptr, rate_calc_type_mode mode)
358 PERCENTAGE per = 100;
360 if (has_resist_disen(player_ptr)) {
362 per /= randrate(4, 7, mode);
369 * @brief ロケット属性攻撃に対するダメージ倍率計算
371 PERCENTAGE calc_rocket_damage_rate(PlayerType *player_ptr, rate_calc_type_mode mode)
373 (void)mode; // unused
374 PERCENTAGE per = 100;
376 if (has_resist_shard(player_ptr)) {
384 * @brief 地獄属性攻撃に対するダメージ倍率計算
386 PERCENTAGE calc_nether_damage_rate(PlayerType *player_ptr, rate_calc_type_mode mode)
388 PERCENTAGE per = 100;
390 if (has_resist_neth(player_ptr)) {
391 if (!PlayerRace(player_ptr).equals(PlayerRaceType::SPECTRE))
394 per /= randrate(4, 7, mode);
401 * @brief 時間逆転攻撃に対するダメージ倍率計算
403 PERCENTAGE calc_time_damage_rate(PlayerType *player_ptr, rate_calc_type_mode mode)
405 (void)mode; // unused
406 PERCENTAGE per = 100;
408 if (has_resist_time(player_ptr)) {
410 per /= randrate(4, 7, mode);
417 * @brief 水流攻撃に対するダメージ倍率計算
419 PERCENTAGE calc_water_damage_rate(PlayerType *player_ptr, rate_calc_type_mode mode)
421 (void)mode; // unused
422 PERCENTAGE per = 100;
424 if (has_resist_water(player_ptr)) {
426 per /= randrate(4, 7, mode);
433 * @brief 聖なる火炎攻撃に対するダメージ倍率計算
435 PERCENTAGE calc_holy_fire_damage_rate(PlayerType *player_ptr, rate_calc_type_mode mode)
437 (void)mode; // unused
438 PERCENTAGE per = 100;
439 if (player_ptr->alignment > 10)
441 else if (player_ptr->alignment < -10)
447 * @brief 地獄の火炎攻撃に対するダメージ倍率計算
449 PERCENTAGE calc_hell_fire_damage_rate(PlayerType *player_ptr, rate_calc_type_mode mode)
451 (void)mode; // unused
452 PERCENTAGE per = 100;
453 if (player_ptr->alignment > 10)
459 * @brief 重力攻撃に対するダメージ倍率計算
461 PERCENTAGE calc_gravity_damage_rate(PlayerType *player_ptr, rate_calc_type_mode mode)
463 (void)mode; // unused
464 PERCENTAGE per = 100;
465 if (player_ptr->levitation) {
472 * @brief 虚無攻撃に対するダメージ倍率計算
474 PERCENTAGE calc_void_damage_rate(PlayerType *player_ptr, rate_calc_type_mode mode)
476 (void)mode; // unused
477 PERCENTAGE per = 100;
478 if (player_ptr->tim_pass_wall) {
480 } else if (player_ptr->anti_tele) {
482 per /= randrate(4, 7, mode);
483 } else if (player_ptr->levitation) {
490 * @brief 深淵攻撃に対するダメージ倍率計算
492 PERCENTAGE calc_abyss_damage_rate(PlayerType *player_ptr, rate_calc_type_mode mode)
494 (void)mode; // unused
495 PERCENTAGE per = 100;
497 if (has_resist_dark(player_ptr)) {
499 per /= randrate(4, 7, mode);
500 } else if (!player_ptr->levitation && player_ptr->anti_tele) {