OSDN Git Service

[Refactor] #40514 have_resist_fear() を calc_bonuses() から分離. / Separated have_resist_f...
authordeskull <deskull@users.sourceforge.jp>
Mon, 10 Aug 2020 04:33:25 +0000 (13:33 +0900)
committerdeskull <deskull@users.sourceforge.jp>
Mon, 10 Aug 2020 04:33:25 +0000 (13:33 +0900)
src/player/player-class.c
src/player/player-race.c
src/player/player-status-flags.c
src/player/player-status-flags.h
src/player/player-status.c

index 72e52d7..0b0c666 100644 (file)
@@ -1201,27 +1201,7 @@ const concptr player_title[MAX_CLASS][PY_MAX_LEVEL / 5] =
 void calc_class_status(player_type *creature_ptr)
 {
     switch (creature_ptr->pclass) {
-    case CLASS_WARRIOR:
-        if (creature_ptr->lev > 29)
-            creature_ptr->resist_fear = TRUE;
-        break;
-    case CLASS_PALADIN:
-        if (creature_ptr->lev > 39)
-            creature_ptr->resist_fear = TRUE;
-        break;
-    case CLASS_CHAOS_WARRIOR:
 
-        if (creature_ptr->lev > 39)
-            creature_ptr->resist_fear = TRUE;
-        break;
-    case CLASS_MINDCRAFTER:
-        if (creature_ptr->lev > 9)
-            creature_ptr->resist_fear = TRUE;
-        break;
-    case CLASS_SAMURAI:
-        if (creature_ptr->lev > 29)
-            creature_ptr->resist_fear = TRUE;
-        break;
     case CLASS_BERSERKER:
         creature_ptr->shero = 1;
         creature_ptr->redraw |= PR_STATUS;
@@ -1240,7 +1220,6 @@ void calc_class_status(player_type *creature_ptr)
             creature_ptr->dis_to_a += creature_ptr->lev / 2 + 5;
         }
 
-        creature_ptr->resist_fear = TRUE;
         if (creature_ptr->lev > 44) {
             creature_ptr->oppose_pois = 1;
             creature_ptr->redraw |= PR_STATUS;
index bf6801f..f7f8b8c 100644 (file)
@@ -134,9 +134,6 @@ void calc_race_status(player_type *creature_ptr)
             creature_ptr->oppose_fire = 1;
             creature_ptr->redraw |= PR_STATUS;
             break;
-        case MIMIC_DEMON_LORD:
-            creature_ptr->resist_fear = TRUE;
-            break;
         case MIMIC_VAMPIRE:
             if (creature_ptr->pclass != CLASS_NINJA)
                 creature_ptr->lite = TRUE;
@@ -144,9 +141,6 @@ void calc_race_status(player_type *creature_ptr)
         }
     } else {
         switch (creature_ptr->prace) {
-        case RACE_BARBARIAN:
-            creature_ptr->resist_fear = TRUE;
-            break;
         case RACE_YEEK:
             if (creature_ptr->lev > 19)
                 creature_ptr->immune_acid = TRUE;
index c09f898..5962b9a 100644 (file)
@@ -3,12 +3,13 @@
 #include "inventory/inventory-slot-types.h"
 #include "monster-race/monster-race.h"
 #include "monster-race/race-flags2.h"
+#include "monster-race/race-flags7.h"
 #include "mutation/mutation-flag-types.h"
-#include "object/object-flags.h"
 #include "object-enchant/object-ego.h"
 #include "object-enchant/tr-types.h"
 #include "object-enchant/trc-types.h"
 #include "object-hook/hook-checker.h"
+#include "object/object-flags.h"
 #include "player/player-class.h"
 #include "player/player-race-types.h"
 #include "player/player-race.h"
@@ -24,7 +25,6 @@
 #include "util/bit-flags-calculator.h"
 #include "util/quarks.h"
 #include "util/string-processor.h"
-#include "monster-race/race-flags7.h"
 
 void have_kill_wall(player_type *creature_ptr)
 {
@@ -793,8 +793,8 @@ void have_hold_exp(player_type *creature_ptr)
     if (!creature_ptr->mimic_form
         && (creature_ptr->prace == RACE_SKELETON || creature_ptr->prace == RACE_ZOMBIE || creature_ptr->prace == RACE_VAMPIRE
             || creature_ptr->prace == RACE_SPECTRE || creature_ptr->prace == RACE_BALROG || creature_ptr->prace == RACE_ANDROID)) {
-        creature_ptr->hold_exp = TRUE;    
-       }
+        creature_ptr->hold_exp = TRUE;
+    }
 
     if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
         creature_ptr->hold_exp = TRUE;
@@ -849,7 +849,7 @@ void have_see_inv(player_type *creature_ptr)
         creature_ptr->see_inv = TRUE;
     }
 
-       if (creature_ptr->tim_invis) {
+    if (creature_ptr->tim_invis) {
         creature_ptr->see_inv = TRUE;
     }
 
@@ -869,12 +869,12 @@ void have_free_act(player_type *creature_ptr)
     object_type *o_ptr;
     BIT_FLAGS flgs[TR_FLAG_SIZE];
     creature_ptr->free_act = FALSE;
-       
-       if (creature_ptr->muta3 & MUT3_MOTION)
+
+    if (creature_ptr->muta3 & MUT3_MOTION)
         creature_ptr->free_act = TRUE;
 
     if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_GNOME) {
-               creature_ptr->free_act = TRUE;
+        creature_ptr->free_act = TRUE;
     }
 
     if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_GOLEM) {
@@ -932,7 +932,7 @@ void have_sustain_str(player_type *creature_ptr)
     creature_ptr->sustain_str = FALSE;
     if (creature_ptr->pclass == CLASS_BERSERKER) {
         creature_ptr->sustain_str = TRUE;
-       }
+    }
     if (!creature_ptr->mimic_form
         && (creature_ptr->prace == RACE_HALF_TROLL || creature_ptr->prace == RACE_HALF_OGRE || creature_ptr->prace == RACE_HALF_GIANT)) {
         creature_ptr->sustain_str = TRUE;
@@ -957,8 +957,7 @@ void have_sustain_int(player_type *creature_ptr)
     object_type *o_ptr;
     BIT_FLAGS flgs[TR_FLAG_SIZE];
     creature_ptr->sustain_int = FALSE;
-    if (!creature_ptr->mimic_form
-        && (creature_ptr->prace == RACE_MIND_FLAYER)) {
+    if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_MIND_FLAYER)) {
         creature_ptr->sustain_int = TRUE;
     }
 
@@ -984,8 +983,8 @@ void have_sustain_wis(player_type *creature_ptr)
     creature_ptr->sustain_wis = FALSE;
     if (creature_ptr->pclass == CLASS_MINDCRAFTER && creature_ptr->lev > 19)
         creature_ptr->sustain_wis = TRUE;
-       
-       if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_MIND_FLAYER)) {
+
+    if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_MIND_FLAYER)) {
         creature_ptr->sustain_wis = TRUE;
     }
 
@@ -1040,7 +1039,7 @@ void have_sustain_con(player_type *creature_ptr)
         creature_ptr->sustain_con = TRUE;
     }
 
-       if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_AMBERITE || creature_ptr->prace == RACE_DUNADAN)) {
+    if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_AMBERITE || creature_ptr->prace == RACE_DUNADAN)) {
         creature_ptr->sustain_con = TRUE;
     }
 
@@ -1102,7 +1101,7 @@ void have_levitation(player_type *creature_ptr)
 
     if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
         creature_ptr->levitation = TRUE;
-       }
+    }
 
     if (creature_ptr->magicdef) {
     }
@@ -1129,7 +1128,7 @@ void have_levitation(player_type *creature_ptr)
 
 void have_can_swim(player_type *creature_ptr)
 {
-       creature_ptr->can_swim = FALSE;
+    creature_ptr->can_swim = FALSE;
     if (creature_ptr->riding) {
         monster_type *riding_m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
         monster_race *riding_r_ptr = &r_info[riding_m_ptr->r_idx];
@@ -1148,7 +1147,7 @@ void have_slow_digest(player_type *creature_ptr)
         creature_ptr->slow_digest = TRUE;
     }
 
-       if (creature_ptr->lev > 14 && !creature_ptr->mimic_form && creature_ptr->prace == RACE_HALF_TROLL) {
+    if (creature_ptr->lev > 14 && !creature_ptr->mimic_form && creature_ptr->prace == RACE_HALF_TROLL) {
         if (creature_ptr->pclass == CLASS_WARRIOR || creature_ptr->pclass == CLASS_BERSERKER) {
             creature_ptr->slow_digest = TRUE;
             /* Let's not make Regeneration
@@ -1224,7 +1223,7 @@ void have_regenerate(player_type *creature_ptr)
         }
     }
 
-       if (creature_ptr->tim_regen) {
+    if (creature_ptr->tim_regen) {
         creature_ptr->regenerate = TRUE;
     }
 
@@ -1329,7 +1328,6 @@ void have_impact(player_type *creature_ptr)
         if (have_flag(flgs, TR_IMPACT))
             creature_ptr->impact[(i == INVEN_RARM) ? 0 : 1] = TRUE;
     }
-
 }
 
 void have_extra_blow(player_type *creature_ptr)
@@ -1374,13 +1372,13 @@ void have_resist_acid(player_type *creature_ptr)
         creature_ptr->resist_acid = TRUE;
     }
 
-       if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_DRACONIAN && creature_ptr->lev > 14) {
+    if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_DRACONIAN && creature_ptr->lev > 14) {
         creature_ptr->resist_acid = TRUE;
-       }
+    }
 
-       if (creature_ptr->special_defense & KAMAE_SEIRYU) {
+    if (creature_ptr->special_defense & KAMAE_SEIRYU) {
         creature_ptr->resist_acid = TRUE;
-       }
+    }
 
     if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
         creature_ptr->resist_acid = TRUE;
@@ -1396,7 +1394,7 @@ void have_resist_acid(player_type *creature_ptr)
             creature_ptr->resist_acid = TRUE;
     }
 
-       if (creature_ptr->immune_acid)
+    if (creature_ptr->immune_acid)
         creature_ptr->resist_acid = TRUE;
 }
 
@@ -1450,7 +1448,7 @@ void have_resist_fire(player_type *creature_ptr)
         creature_ptr->resist_fire = TRUE;
     }
 
-       if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_IMP || creature_ptr->prace == RACE_BALROG)) {
+    if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_IMP || creature_ptr->prace == RACE_BALROG)) {
         creature_ptr->resist_fire = TRUE;
     }
 
@@ -1483,7 +1481,6 @@ void have_resist_cold(player_type *creature_ptr)
     BIT_FLAGS flgs[TR_FLAG_SIZE];
     creature_ptr->resist_cold = FALSE;
 
-
     if (creature_ptr->mimic_form == MIMIC_DEMON_LORD || creature_ptr->mimic_form == MIMIC_VAMPIRE) {
         creature_ptr->resist_cold = TRUE;
     }
@@ -1492,20 +1489,19 @@ void have_resist_cold(player_type *creature_ptr)
         creature_ptr->resist_cold = TRUE;
     }
 
-    if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_DRACONIAN || creature_ptr->prace == RACE_SKELETON)
-                        && creature_ptr->lev > 9) {
+    if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_DRACONIAN || creature_ptr->prace == RACE_SKELETON) && creature_ptr->lev > 9) {
         creature_ptr->resist_cold = TRUE;
     }
 
-       if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_VAMPIRE || creature_ptr->prace == RACE_SPECTRE)) {
+    if (!creature_ptr->mimic_form && (creature_ptr->prace == RACE_VAMPIRE || creature_ptr->prace == RACE_SPECTRE)) {
         creature_ptr->resist_fire = TRUE;
     }
 
-       if (creature_ptr->special_defense & KAMAE_SEIRYU) {
+    if (creature_ptr->special_defense & KAMAE_SEIRYU) {
         creature_ptr->resist_cold = TRUE;
     }
 
-       if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
+    if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
         creature_ptr->resist_cold = TRUE;
     }
 
@@ -1516,7 +1512,7 @@ void have_resist_cold(player_type *creature_ptr)
 
         object_flags(creature_ptr, o_ptr, flgs);
 
-           if (have_flag(flgs, TR_RES_COLD))
+        if (have_flag(flgs, TR_RES_COLD))
             creature_ptr->resist_cold = TRUE;
     }
 
@@ -1551,7 +1547,7 @@ void have_resist_pois(player_type *creature_ptr)
         creature_ptr->resist_pois = TRUE;
     }
 
-       if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
+    if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
         creature_ptr->resist_pois = TRUE;
     }
 
@@ -1562,7 +1558,7 @@ void have_resist_pois(player_type *creature_ptr)
 
         object_flags(creature_ptr, o_ptr, flgs);
 
-           if (have_flag(flgs, TR_RES_POIS))
+        if (have_flag(flgs, TR_RES_POIS))
             creature_ptr->resist_pois = TRUE;
     }
 }
@@ -1603,8 +1599,8 @@ void have_resist_conf(player_type *creature_ptr)
 
         object_flags(creature_ptr, o_ptr, flgs);
 
-               if (have_flag(flgs, TR_RES_CONF))
-                               creature_ptr->resist_conf = TRUE;
+        if (have_flag(flgs, TR_RES_CONF))
+            creature_ptr->resist_conf = TRUE;
     }
 }
 
@@ -1614,7 +1610,7 @@ void have_resist_sound(player_type *creature_ptr)
     BIT_FLAGS flgs[TR_FLAG_SIZE];
     creature_ptr->resist_sound = FALSE;
 
-       if (creature_ptr->pclass == CLASS_BARD) {
+    if (creature_ptr->pclass == CLASS_BARD) {
         creature_ptr->resist_sound = TRUE;
     }
 
@@ -1622,7 +1618,7 @@ void have_resist_sound(player_type *creature_ptr)
         creature_ptr->resist_conf = TRUE;
     }
 
-       if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
+    if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
         creature_ptr->lite = TRUE;
     }
 
@@ -1633,8 +1629,8 @@ void have_resist_sound(player_type *creature_ptr)
 
         object_flags(creature_ptr, o_ptr, flgs);
 
-               if (have_flag(flgs, TR_RES_SOUND))
-                               creature_ptr->resist_sound = TRUE;
+        if (have_flag(flgs, TR_RES_SOUND))
+            creature_ptr->resist_sound = TRUE;
     }
 }
 
@@ -1659,8 +1655,8 @@ void have_resist_lite(player_type *creature_ptr)
 
         object_flags(creature_ptr, o_ptr, flgs);
 
-               if (have_flag(flgs, TR_RES_LITE))
-                       creature_ptr->resist_lite = TRUE;
+        if (have_flag(flgs, TR_RES_LITE))
+            creature_ptr->resist_lite = TRUE;
     }
 }
 
@@ -1680,7 +1676,7 @@ void have_resist_dark(player_type *creature_ptr)
         creature_ptr->resist_lite = TRUE;
     }
 
-       if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
+    if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
         creature_ptr->resist_dark = TRUE;
     }
 
@@ -1691,8 +1687,8 @@ void have_resist_dark(player_type *creature_ptr)
 
         object_flags(creature_ptr, o_ptr, flgs);
 
-               if (have_flag(flgs, TR_RES_DARK))
-                               creature_ptr->resist_dark = TRUE;
+        if (have_flag(flgs, TR_RES_DARK))
+            creature_ptr->resist_dark = TRUE;
     }
 }
 
@@ -1723,8 +1719,8 @@ void have_resist_chaos(player_type *creature_ptr)
 
         object_flags(creature_ptr, o_ptr, flgs);
 
-               if (have_flag(flgs, TR_RES_CHAOS))
-                               creature_ptr->resist_chaos = TRUE;
+        if (have_flag(flgs, TR_RES_CHAOS))
+            creature_ptr->resist_chaos = TRUE;
     }
 }
 
@@ -1752,8 +1748,8 @@ void have_resist_disen(player_type *creature_ptr)
 
         object_flags(creature_ptr, o_ptr, flgs);
 
-               if (have_flag(flgs, TR_RES_DISEN))
-                       creature_ptr->resist_disen = TRUE;
+        if (have_flag(flgs, TR_RES_DISEN))
+            creature_ptr->resist_disen = TRUE;
     }
 }
 
@@ -1770,7 +1766,7 @@ void have_resist_shard(player_type *creature_ptr)
         creature_ptr->resist_shard = TRUE;
     }
 
-       for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -1825,7 +1821,7 @@ void have_resist_blind(player_type *creature_ptr)
         creature_ptr->resist_blind = TRUE;
     }
 
-       if (creature_ptr->magicdef) {
+    if (creature_ptr->magicdef) {
         creature_ptr->resist_blind = TRUE;
     }
 
@@ -1885,7 +1881,7 @@ void have_resist_time(player_type *creature_ptr)
         creature_ptr->resist_time = TRUE;
     }
 
-       for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -1898,10 +1894,66 @@ void have_resist_time(player_type *creature_ptr)
 
 void have_resist_water(player_type *creature_ptr)
 {
-    object_type *o_ptr;
-    BIT_FLAGS flgs[TR_FLAG_SIZE];
     creature_ptr->resist_water = FALSE;
 
     if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_MERFOLK)
-               creature_ptr->resist_water = TRUE;
+        creature_ptr->resist_water = TRUE;
+}
+
+void have_resist_fear(player_type *creature_ptr)
+{
+    object_type *o_ptr;
+    BIT_FLAGS flgs[TR_FLAG_SIZE];
+    creature_ptr->resist_fear = FALSE;
+
+    switch (creature_ptr->pclass) {
+    case CLASS_WARRIOR:
+        if (creature_ptr->lev > 29)
+            creature_ptr->resist_fear = TRUE;
+        break;
+    case CLASS_PALADIN:
+        if (creature_ptr->lev > 39)
+            creature_ptr->resist_fear = TRUE;
+        break;
+    case CLASS_CHAOS_WARRIOR:
+        if (creature_ptr->lev > 39)
+            creature_ptr->resist_fear = TRUE;
+        break;
+    case CLASS_MINDCRAFTER:
+        if (creature_ptr->lev > 9)
+            creature_ptr->resist_fear = TRUE;
+        break;
+    case CLASS_SAMURAI:
+        if (creature_ptr->lev > 29)
+            creature_ptr->resist_fear = TRUE;
+        break;
+    case CLASS_NINJA:
+        creature_ptr->resist_fear = TRUE;
+        break;
+    }
+
+    if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
+        creature_ptr->resist_fear = TRUE;
+    }
+
+    if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_BARBARIAN)
+        creature_ptr->resist_fear = TRUE;
+
+    if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
+        creature_ptr->resist_fear = TRUE;
+    }
+
+       if (is_hero(creature_ptr) || creature_ptr->shero) {
+        creature_ptr->resist_fear = TRUE;
+    }
+
+    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+        o_ptr = &creature_ptr->inventory_list[i];
+        if (!o_ptr->k_idx)
+            continue;
+
+        object_flags(creature_ptr, o_ptr, flgs);
+        if (have_flag(flgs, TR_RES_FEAR))
+            creature_ptr->resist_fear = TRUE;
+    }
 }
index 5f826ed..2a2f23f 100644 (file)
@@ -66,5 +66,6 @@ void have_resist_blind(player_type *creature_ptr);
 void have_resist_neth(player_type *creature_ptr);
 void have_resist_time(player_type *creature_ptr);
 void have_resist_water(player_type *creature_ptr);
+void have_resist_fear(player_type *creature_ptr);
 
 
index 6181312..f384948 100644 (file)
@@ -560,7 +560,6 @@ static void delayed_visual_update(player_type *player_ptr)
  */
 static void clear_creature_bonuses(player_type *creature_ptr)
 {
-    creature_ptr->resist_fear = FALSE;
     creature_ptr->immune_acid = FALSE;
     creature_ptr->immune_elec = FALSE;
     creature_ptr->immune_fire = FALSE;
@@ -731,6 +730,7 @@ void calc_bonuses(player_type *creature_ptr)
     have_resist_blind(creature_ptr);
     have_resist_neth(creature_ptr);
     have_resist_time(creature_ptr);
+    have_resist_fear(creature_ptr);
 
     calc_race_status(creature_ptr);
 
@@ -4438,7 +4438,6 @@ void calc_timelimit_status(player_type *creature_ptr)
 {
     if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
         creature_ptr->lite = TRUE;
-        creature_ptr->resist_fear = TRUE;
     }
 
     if (creature_ptr->ele_immune) {
@@ -4452,9 +4451,6 @@ void calc_timelimit_status(player_type *creature_ptr)
             creature_ptr->immune_cold = TRUE;
     }
 
-    if (is_hero(creature_ptr) || creature_ptr->shero) {
-        creature_ptr->resist_fear = TRUE;
-    }
 }
 
 void calc_equipment_status(player_type *creature_ptr)
@@ -4488,9 +4484,6 @@ void calc_equipment_status(player_type *creature_ptr)
         if (have_flag(flgs, TR_IM_ELEC))
             creature_ptr->immune_elec = TRUE;
 
-        if (have_flag(flgs, TR_RES_FEAR))
-            creature_ptr->resist_fear = TRUE;
-
         if (o_ptr->tval == TV_CAPTURE)
             continue;