OSDN Git Service

Merge remote-tracking branch 'remotes/origin/feature/Refactor-Unnecessary-Files-Remov...
[hengband/hengband.git] / src / player / player-status-resist.c
index 2f86070..92326b0 100644 (file)
@@ -1,5 +1,5 @@
 #include "player/player-status-resist.h"
-#include "art-definition/art-sword-types.h"
+#include "artifact/fixed-art-types.h"
 #include "grid/grid.h"
 #include "inventory/inventory-slot-types.h"
 #include "monster-race/monster-race.h"
@@ -12,6 +12,7 @@
 #include "object-hook/hook-checker.h"
 #include "object-hook/hook-weapon.h"
 #include "object/object-flags.h"
+#include "player/mimic-info-table.h"
 #include "player/player-class.h"
 #include "player/player-race-types.h"
 #include "player/player-race.h"
@@ -32,6 +33,9 @@
 #include "util/quarks.h"
 #include "util/string-processor.h"
 
+/*!
+ * @brief 耐性倍率計算の用途に応じた分岐処理
+ */
 PERCENTAGE randrate(int dice, int fix, rate_calc_type_mode mode)
 {
     switch (mode) {
@@ -53,17 +57,19 @@ PERCENTAGE randrate(int dice, int fix, rate_calc_type_mode mode)
     }
 }
 
+/*!
+ * @brief 酸属性攻撃に対するダメージ倍率計算
+ */
 PERCENTAGE calc_acid_damage_rate(player_type *creature_ptr)
 {
     PERCENTAGE per = 100;
-    int i;
 
-    if (is_immune_acid(creature_ptr)) {
+    if (has_immune_acid(creature_ptr)) {
         return 0;
     }
 
-    BIT_FLAGS flgs = is_vuln_acid(creature_ptr);
-    for (i = 0; i < FLAG_CAUSE_MAX; i++) {
+    BIT_FLAGS flgs = has_vuln_acid(creature_ptr);
+    for (int i = 0; i < FLAG_CAUSE_MAX; i++) {
         if (flgs & (0x01 << i)) {
             if (i == FLAG_CAUSE_MUTATION) {
                 per *= 2;
@@ -73,7 +79,7 @@ PERCENTAGE calc_acid_damage_rate(player_type *creature_ptr)
         }
     }
 
-    if (creature_ptr->resist_acid)
+    if (has_resist_acid(creature_ptr))
         per = (per + 2) / 3;
     if (is_oppose_acid(creature_ptr))
         per = (per + 2) / 3;
@@ -81,17 +87,19 @@ PERCENTAGE calc_acid_damage_rate(player_type *creature_ptr)
     return per;
 }
 
+/*!
+ * @brief 電撃属性攻撃に対するダメージ倍率計算
+ */
 PERCENTAGE calc_elec_damage_rate(player_type *creature_ptr)
 {
     PERCENTAGE per = 100;
-    int i;
 
-    if (is_immune_elec(creature_ptr)) {
+    if (has_immune_elec(creature_ptr)) {
         return 0;
     }
 
-    BIT_FLAGS flgs = is_vuln_elec(creature_ptr);
-    for (i = 0; i < FLAG_CAUSE_MAX; i++) {
+    BIT_FLAGS flgs = has_vuln_elec(creature_ptr);
+    for (int i = 0; i < FLAG_CAUSE_MAX; i++) {
         if (flgs & (0x01 << i)) {
             if (i == FLAG_CAUSE_MUTATION) {
                 per *= 2;
@@ -101,7 +109,7 @@ PERCENTAGE calc_elec_damage_rate(player_type *creature_ptr)
         }
     }
 
-    if (creature_ptr->resist_elec)
+    if (has_resist_elec(creature_ptr))
         per = (per + 2) / 3;
     if (is_oppose_elec(creature_ptr))
         per = (per + 2) / 3;
@@ -109,12 +117,14 @@ PERCENTAGE calc_elec_damage_rate(player_type *creature_ptr)
     return per;
 }
 
+/*!
+ * @brief 火炎属性攻撃に対するダメージ倍率計算
+ */
 PERCENTAGE calc_fire_damage_rate(player_type *creature_ptr)
 {
     PERCENTAGE per = 100;
-    int i;
-    BIT_FLAGS flgs = is_vuln_fire(creature_ptr);
-    for (i = 0; i < FLAG_CAUSE_MAX; i++) {
+    BIT_FLAGS flgs = has_vuln_fire(creature_ptr);
+     for (int i = 0; i < FLAG_CAUSE_MAX; i++) {
         if (flgs & (0x01 << i)) {
             if (i == FLAG_CAUSE_MUTATION) {
                 per *= 2;
@@ -125,7 +135,7 @@ PERCENTAGE calc_fire_damage_rate(player_type *creature_ptr)
     }
 
     /* Resist the damage */
-    if (creature_ptr->resist_fire)
+    if (has_resist_fire(creature_ptr))
         per = (per + 2) / 3;
     if (is_oppose_fire(creature_ptr))
         per = (per + 2) / 3;
@@ -133,12 +143,14 @@ PERCENTAGE calc_fire_damage_rate(player_type *creature_ptr)
     return per;
 }
 
+/*!
+ * @brief 冷気属性攻撃に対するダメージ倍率計算
+ */
 PERCENTAGE calc_cold_damage_rate(player_type *creature_ptr)
 {
     PERCENTAGE per = 100;
-    int i;
-    BIT_FLAGS flgs = is_vuln_cold(creature_ptr);
-    for (i = 0; i < FLAG_CAUSE_MAX; i++) {
+    BIT_FLAGS flgs = has_vuln_cold(creature_ptr);
+    for (int i = 0; i < FLAG_CAUSE_MAX; i++) {
         if (flgs & (0x01 << i)) {
             if (i == FLAG_CAUSE_MUTATION) {
                 per *= 2;
@@ -148,7 +160,7 @@ PERCENTAGE calc_cold_damage_rate(player_type *creature_ptr)
         }
     }
 
-    if (creature_ptr->resist_cold)
+    if (has_resist_cold(creature_ptr))
         per = (per + 2) / 3;
     if (is_oppose_cold(creature_ptr))
         per = (per + 2) / 3;
@@ -156,10 +168,13 @@ PERCENTAGE calc_cold_damage_rate(player_type *creature_ptr)
     return per;
 }
 
+/*!
+ * @brief 毒属性攻撃に対するダメージ倍率計算
+ */
 PERCENTAGE calc_pois_damage_rate(player_type *creature_ptr)
 {
     PERCENTAGE per = 100;
-    if (creature_ptr->resist_pois)
+    if (has_resist_pois(creature_ptr))
         per = (per + 2) / 3;
     if (is_oppose_pois(creature_ptr))
         per = (per + 2) / 3;
@@ -167,17 +182,50 @@ PERCENTAGE calc_pois_damage_rate(player_type *creature_ptr)
     return per;
 }
 
+/*!
+ * @brief 放射性廃棄物攻撃に対するダメージ倍率計算
+ */
 PERCENTAGE calc_nuke_damage_rate(player_type *creature_ptr)
 {
+
     PERCENTAGE per = 100;
-    if (creature_ptr->resist_pois)
-        per = (per + 2) / 3;
+    if (has_resist_pois(creature_ptr))
+        per = (2 * per + 2) / 5;
     if (is_oppose_pois(creature_ptr))
-        per = (per + 2) / 3;
+        per = (2 * per + 2) / 5;
 
     return per;
 }
 
+/*!
+ * @brief 死の光線に対するダメージ倍率計算
+ */
+PERCENTAGE calc_deathray_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
+{
+    (void)mode; // unused
+    if (creature_ptr->mimic_form) {
+        if (mimic_info[creature_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_NONLIVING) {
+            return 0;
+        }
+    }
+
+    switch (creature_ptr->prace) {
+    case RACE_GOLEM:
+    case RACE_SKELETON:
+    case RACE_ZOMBIE:
+    case RACE_VAMPIRE:
+    case RACE_BALROG:
+    case RACE_SPECTRE:
+        return 0;
+        break;
+    }
+
+    return 100;
+}
+
+/*!
+ * @brief 閃光属性攻撃に対するダメージ倍率計算
+ */
 PERCENTAGE calc_lite_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
 {
     PERCENTAGE per = 100;
@@ -187,7 +235,7 @@ PERCENTAGE calc_lite_damage_rate(player_type *creature_ptr, rate_calc_type_mode
         per = per * 4 / 3;
     }
 
-    if (creature_ptr->resist_lite) {
+    if (has_resist_lite(creature_ptr)) {
         per *= 400;
         per /= randrate(4, 7, mode);
     }
@@ -198,6 +246,9 @@ PERCENTAGE calc_lite_damage_rate(player_type *creature_ptr, rate_calc_type_mode
     return per;
 }
 
+/*!
+ * @brief 暗黒属性攻撃に対するダメージ倍率計算
+ */
 PERCENTAGE calc_dark_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
 {
     PERCENTAGE per = 100;
@@ -206,7 +257,7 @@ PERCENTAGE calc_dark_damage_rate(player_type *creature_ptr, rate_calc_type_mode
         return 0;
     }
 
-    if (creature_ptr->resist_dark) {
+    if (has_resist_dark(creature_ptr)) {
         per *= 400;
         per /= randrate(4, 7, mode);
     }
@@ -214,11 +265,14 @@ PERCENTAGE calc_dark_damage_rate(player_type *creature_ptr, rate_calc_type_mode
     return per;
 }
 
+/*!
+ * @brief 破片属性攻撃に対するダメージ倍率計算
+ */
 PERCENTAGE calc_shards_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
 {
     PERCENTAGE per = 100;
 
-    if (creature_ptr->resist_shard) {
+    if (has_resist_shard(creature_ptr)) {
         per *= 600;
         per /= randrate(4, 7, mode);
     }
@@ -226,11 +280,14 @@ PERCENTAGE calc_shards_damage_rate(player_type *creature_ptr, rate_calc_type_mod
     return per;
 }
 
+/*!
+ * @brief 轟音属性攻撃に対するダメージ倍率計算
+ */
 PERCENTAGE calc_sound_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
 {
     PERCENTAGE per = 100;
 
-    if (creature_ptr->resist_sound) {
+    if (has_resist_sound(creature_ptr)) {
         per *= 500;
         per /= randrate(4, 7, mode);
     }
@@ -238,11 +295,14 @@ PERCENTAGE calc_sound_damage_rate(player_type *creature_ptr, rate_calc_type_mode
     return per;
 }
 
+/*!
+ * @brief 混乱属性攻撃に対するダメージ倍率計算
+ */
 PERCENTAGE calc_conf_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
 {
     PERCENTAGE per = 100;
 
-    if (creature_ptr->resist_conf) {
+    if (has_resist_conf(creature_ptr)) {
         per *= 500;
         per /= randrate(4, 7, mode);
     }
@@ -250,11 +310,14 @@ PERCENTAGE calc_conf_damage_rate(player_type *creature_ptr, rate_calc_type_mode
     return per;
 }
 
+/*!
+ * @brief 混沌属性攻撃に対するダメージ倍率計算
+ */
 PERCENTAGE calc_chaos_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
 {
     PERCENTAGE per = 100;
 
-    if (creature_ptr->resist_chaos) {
+    if (has_resist_chaos(creature_ptr)) {
         per *= 600;
         per /= randrate(4, 7, mode);
     }
@@ -262,11 +325,14 @@ PERCENTAGE calc_chaos_damage_rate(player_type *creature_ptr, rate_calc_type_mode
     return per;
 }
 
+/*!
+ * @brief 劣化属性攻撃に対するダメージ倍率計算
+ */
 PERCENTAGE calc_disenchant_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
 {
     PERCENTAGE per = 100;
 
-    if (creature_ptr->resist_disen) {
+    if (has_resist_disen(creature_ptr)) {
         per *= 600;
         per /= randrate(4, 7, mode);
     }
@@ -274,11 +340,14 @@ PERCENTAGE calc_disenchant_damage_rate(player_type *creature_ptr, rate_calc_type
     return per;
 }
 
+/*!
+ * @brief 因果混乱属性攻撃に対するダメージ倍率計算
+ */
 PERCENTAGE calc_nexus_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
 {
     PERCENTAGE per = 100;
 
-    if (creature_ptr->resist_disen) {
+    if (has_resist_disen(creature_ptr)) {
         per *= 600;
         per /= randrate(4, 7, mode);
     }
@@ -286,23 +355,29 @@ PERCENTAGE calc_nexus_damage_rate(player_type *creature_ptr, rate_calc_type_mode
     return per;
 }
 
+/*!
+ * @brief ロケット属性攻撃に対するダメージ倍率計算
+ */
 PERCENTAGE calc_rocket_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
 {
-    (mode); // unused
+    (void)mode; // unused
     PERCENTAGE per = 100;
 
-    if (creature_ptr->resist_shard) {
+    if (has_resist_shard(creature_ptr)) {
         per /= 2;
     }
 
     return per;
 }
 
+/*!
+ * @brief 地獄属性攻撃に対するダメージ倍率計算
+ */
 PERCENTAGE calc_nether_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
 {
     PERCENTAGE per = 100;
 
-    if (creature_ptr->resist_neth) {
+    if (has_resist_neth(creature_ptr)) {
         if (!is_specific_player_race(creature_ptr, RACE_SPECTRE))
             per *= 6;
         per *= 100;
@@ -312,12 +387,15 @@ PERCENTAGE calc_nether_damage_rate(player_type *creature_ptr, rate_calc_type_mod
     return per;
 }
 
+/*!
+ * @brief 時間逆転攻撃に対するダメージ倍率計算
+ */
 PERCENTAGE calc_time_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
 {
-    (mode); // unused
+    (void)mode; // unused
     PERCENTAGE per = 100;
 
-    if (creature_ptr->resist_time) {
+    if (has_resist_time(creature_ptr)) {
         per *= 400;
         per /= randrate(4, 7, mode);
     }
@@ -325,9 +403,12 @@ PERCENTAGE calc_time_damage_rate(player_type *creature_ptr, rate_calc_type_mode
     return per;
 }
 
+/*!
+ * @brief 聖なる火炎攻撃に対するダメージ倍率計算
+ */
 PERCENTAGE calc_holy_fire_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
 {
-    (mode); // unused
+    (void)mode; // unused
     PERCENTAGE per = 100;
     if (creature_ptr->align > 10)
         per /= 2;
@@ -336,18 +417,24 @@ PERCENTAGE calc_holy_fire_damage_rate(player_type *creature_ptr, rate_calc_type_
     return per;
 }
 
+/*!
+ * @brief 地獄の火炎攻撃に対するダメージ倍率計算
+ */
 PERCENTAGE calc_hell_fire_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
 {
-    (mode); // unused
+    (void)mode; // unused
     PERCENTAGE per = 100;
     if (creature_ptr->align > 10)
         per *= 2;
     return per;
 }
 
+/*!
+ * @brief 重力攻撃に対するダメージ倍率計算
+ */
 PERCENTAGE calc_gravity_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
 {
-    (mode); // unused
+    (void)mode; // unused
     PERCENTAGE per = 100;
     if (creature_ptr->levitation) {
         per = (per * 2) / 3;