OSDN Git Service

[Refactor] #40514 player_type の resist_lite 変数を廃止. / Abolished the resist_lite variab...
[hengband/hengband.git] / src / player / player-status-resist.c
index 0340a74..1c986fb 100644 (file)
@@ -1,6 +1,5 @@
 #include "player/player-status-resist.h"
-#include "player/mimic-info-table.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"
@@ -13,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"
@@ -63,14 +63,13 @@ PERCENTAGE randrate(int dice, int fix, rate_calc_type_mode mode)
 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;
@@ -80,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;
@@ -94,14 +93,13 @@ PERCENTAGE calc_acid_damage_rate(player_type *creature_ptr)
 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;
@@ -111,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;
@@ -125,9 +123,8 @@ PERCENTAGE calc_elec_damage_rate(player_type *creature_ptr)
 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;
@@ -138,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;
@@ -152,9 +149,8 @@ PERCENTAGE calc_fire_damage_rate(player_type *creature_ptr)
 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;
@@ -164,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;
@@ -178,7 +174,7 @@ PERCENTAGE calc_cold_damage_rate(player_type *creature_ptr)
 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;
@@ -193,7 +189,7 @@ PERCENTAGE calc_nuke_damage_rate(player_type *creature_ptr)
 {
 
     PERCENTAGE per = 100;
-    if (creature_ptr->resist_pois)
+    if (has_resist_pois(creature_ptr))
         per = (2 * per + 2) / 5;
     if (is_oppose_pois(creature_ptr))
         per = (2 * per + 2) / 5;
@@ -206,7 +202,7 @@ PERCENTAGE calc_nuke_damage_rate(player_type *creature_ptr)
  */
 PERCENTAGE calc_deathray_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
 {
-    (mode); // unused
+    (void)mode; // unused
     if (creature_ptr->mimic_form) {
         if (mimic_info[creature_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_NONLIVING) {
             return 0;
@@ -239,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);
     }
@@ -291,7 +287,7 @@ PERCENTAGE calc_sound_damage_rate(player_type *creature_ptr, rate_calc_type_mode
 {
     PERCENTAGE per = 100;
 
-    if (creature_ptr->resist_sound) {
+    if (has_resist_sound(creature_ptr)) {
         per *= 500;
         per /= randrate(4, 7, mode);
     }
@@ -306,7 +302,7 @@ PERCENTAGE calc_conf_damage_rate(player_type *creature_ptr, rate_calc_type_mode
 {
     PERCENTAGE per = 100;
 
-    if (creature_ptr->resist_conf) {
+    if (has_resist_conf(creature_ptr)) {
         per *= 500;
         per /= randrate(4, 7, mode);
     }
@@ -364,7 +360,7 @@ PERCENTAGE calc_nexus_damage_rate(player_type *creature_ptr, rate_calc_type_mode
  */
 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) {
@@ -391,13 +387,12 @@ 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) {
@@ -413,7 +408,7 @@ PERCENTAGE calc_time_damage_rate(player_type *creature_ptr, rate_calc_type_mode
  */
 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;
@@ -427,7 +422,7 @@ PERCENTAGE calc_holy_fire_damage_rate(player_type *creature_ptr, rate_calc_type_
  */
 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;
@@ -439,7 +434,7 @@ PERCENTAGE calc_hell_fire_damage_rate(player_type *creature_ptr, rate_calc_type_
  */
 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;