OSDN Git Service

[Refactor] #40514 have_levitation() を calc_bonuses() から分離. / Separated have_levitatio...
authordeskull <deskull@users.sourceforge.jp>
Thu, 6 Aug 2020 16:45:26 +0000 (01:45 +0900)
committerHourier <hourier@users.sourceforge.jp>
Thu, 6 Aug 2020 16:45:26 +0000 (01:45 +0900)
src/player/player-race.c
src/player/player-status-flags.c
src/player/player-status-flags.h
src/player/player-status.c

index eee27c5..d167e29 100644 (file)
@@ -150,7 +150,6 @@ void calc_race_status(player_type *creature_ptr)
             creature_ptr->resist_disen = TRUE;
             creature_ptr->resist_nexus = TRUE;
             creature_ptr->resist_fear = TRUE;
-            creature_ptr->levitation = TRUE;
             break;
         case MIMIC_VAMPIRE:
             creature_ptr->resist_dark = TRUE;
@@ -226,7 +225,6 @@ void calc_race_status(player_type *creature_ptr)
             creature_ptr->resist_dark = TRUE;
             break;
         case RACE_DRACONIAN:
-            creature_ptr->levitation = TRUE;
             if (creature_ptr->lev > 4)
                 creature_ptr->resist_fire = TRUE;
             if (creature_ptr->lev > 9)
@@ -267,7 +265,6 @@ void calc_race_status(player_type *creature_ptr)
                 creature_ptr->lite = TRUE;
             break;
         case RACE_SPECTRE:
-            creature_ptr->levitation = TRUE;
             creature_ptr->resist_neth = TRUE;
             creature_ptr->resist_pois = TRUE;
             creature_ptr->slow_digest = TRUE;
@@ -275,16 +272,12 @@ void calc_race_status(player_type *creature_ptr)
             creature_ptr->pass_wall = TRUE;
             break;
         case RACE_SPRITE:
-            creature_ptr->levitation = TRUE;
             creature_ptr->resist_lite = TRUE;
             break;
         case RACE_BEASTMAN:
             creature_ptr->resist_conf = TRUE;
             creature_ptr->resist_sound = TRUE;
             break;
-        case RACE_ARCHON:
-            creature_ptr->levitation = TRUE;
-            break;
         case RACE_BALROG:
             creature_ptr->resist_fire = TRUE;
             creature_ptr->resist_neth = TRUE;
@@ -294,9 +287,6 @@ void calc_race_status(player_type *creature_ptr)
             }
 
             break;
-        case RACE_S_FAIRY:
-            creature_ptr->levitation = TRUE;
-            break;
         case RACE_KUTAR:
             creature_ptr->resist_conf = TRUE;
             break;
index 712a67f..4d65840 100644 (file)
@@ -21,6 +21,7 @@
 #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)
 {
@@ -1075,3 +1076,53 @@ void have_sustain_chr(player_type *creature_ptr)
             creature_ptr->sustain_chr = TRUE;
     }
 }
+
+void have_levitation(player_type *creature_ptr)
+{
+    object_type *o_ptr;
+    BIT_FLAGS flgs[TR_FLAG_SIZE];
+    creature_ptr->levitation = FALSE;
+
+    if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
+        creature_ptr->levitation = TRUE;
+    }
+
+    if (!creature_ptr->mimic_form
+        && (creature_ptr->prace == RACE_DRACONIAN || creature_ptr->prace == RACE_SPECTRE || creature_ptr->prace == RACE_SPRITE
+            || creature_ptr->prace == RACE_ARCHON || creature_ptr->prace == RACE_S_FAIRY)) {
+        creature_ptr->levitation = TRUE;
+    }
+
+    if (creature_ptr->special_defense & KAMAE_SEIRYU || creature_ptr->special_defense & KAMAE_SUZAKU) {
+        creature_ptr->levitation = TRUE;
+    }
+
+    if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
+        creature_ptr->slow_digest = TRUE;
+        creature_ptr->regenerate = TRUE;
+       }
+
+    if (creature_ptr->magicdef) {
+        creature_ptr->levitation = TRUE;
+    }
+
+    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];
+        creature_ptr->levitation = (riding_r_ptr->flags7 & RF7_CAN_FLY) ? TRUE : FALSE;
+    }
+
+    if (creature_ptr->tim_levitation) {
+        creature_ptr->levitation = 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_LEVITATION))
+            creature_ptr->levitation = TRUE;
+    }
+}
index 6def3d5..b0e45f4 100644 (file)
@@ -42,5 +42,6 @@ void have_sustain_wis(player_type *creature_ptr);
 void have_sustain_dex(player_type *creature_ptr);
 void have_sustain_con(player_type *creature_ptr);
 void have_sustain_chr(player_type *creature_ptr);
+void have_levitation(player_type *creature_ptr);
 
 
index bf060cd..f884901 100644 (file)
@@ -570,8 +570,6 @@ static void clear_creature_bonuses(player_type *creature_ptr)
     creature_ptr->slow_digest = FALSE;
     creature_ptr->regenerate = FALSE;
     creature_ptr->can_swim = FALSE;
-    creature_ptr->levitation = FALSE;
-    creature_ptr->lite = FALSE;
     creature_ptr->resist_acid = FALSE;
     creature_ptr->resist_elec = FALSE;
     creature_ptr->resist_fire = FALSE;
@@ -738,6 +736,7 @@ void calc_bonuses(player_type *creature_ptr)
     have_sustain_dex(creature_ptr);
     have_sustain_con(creature_ptr);
     have_sustain_chr(creature_ptr);
+    have_levitation(creature_ptr);
 
     calc_race_status(creature_ptr);
 
@@ -820,8 +819,6 @@ void calc_bonuses(player_type *creature_ptr)
         monster_race *riding_r_ptr = &r_info[riding_m_ptr->r_idx];
         if (riding_r_ptr->flags7 & (RF7_CAN_SWIM | RF7_AQUATIC))
             creature_ptr->can_swim = TRUE;
-
-        creature_ptr->levitation = (riding_r_ptr->flags7 & RF7_CAN_FLY) ? TRUE : FALSE;
     }
 
     creature_ptr->hold = adj_str_hold[creature_ptr->stat_ind[A_STR]];
@@ -2111,7 +2108,6 @@ static void calc_num_blow(player_type *creature_ptr, int i)
             creature_ptr->resist_elec = TRUE;
             creature_ptr->resist_cold = TRUE;
             creature_ptr->resist_pois = TRUE;
-            creature_ptr->levitation = TRUE;
         } else if (creature_ptr->special_defense & KAMAE_GENBU) {
             creature_ptr->to_a += (creature_ptr->lev * creature_ptr->lev) / 50;
             creature_ptr->dis_to_a += (creature_ptr->lev * creature_ptr->lev) / 50;
@@ -2127,7 +2123,6 @@ static void calc_num_blow(player_type *creature_ptr, int i)
             creature_ptr->dis_to_h[i] -= (creature_ptr->lev / 3);
             creature_ptr->dis_to_d[i] -= (creature_ptr->lev / 6);
             creature_ptr->num_blow[i] /= 2;
-            creature_ptr->levitation = TRUE;
         }
 
         creature_ptr->num_blow[i] += 1 + creature_ptr->extra_blows[0];
@@ -4482,7 +4477,6 @@ void calc_timelimit_status(player_type *creature_ptr)
     if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
         creature_ptr->slow_digest = TRUE;
         creature_ptr->regenerate = TRUE;
-        creature_ptr->levitation = TRUE;
         creature_ptr->lite = TRUE;
         creature_ptr->resist_acid = TRUE;
         creature_ptr->resist_elec = TRUE;
@@ -4510,14 +4504,11 @@ void calc_timelimit_status(player_type *creature_ptr)
         creature_ptr->resist_time = TRUE;
     }
 
-
     if (creature_ptr->magicdef) {
         creature_ptr->resist_blind = TRUE;
         creature_ptr->resist_conf = TRUE;
-        creature_ptr->levitation = TRUE;
     }
 
-
     if (creature_ptr->ele_immune) {
         if (creature_ptr->special_defense & DEFENSE_ACID)
             creature_ptr->immune_acid = TRUE;
@@ -4533,10 +4524,6 @@ void calc_timelimit_status(player_type *creature_ptr)
         creature_ptr->regenerate = TRUE;
     }
 
-    if (creature_ptr->tim_levitation) {
-        creature_ptr->levitation = TRUE;
-    }
-
     if (is_hero(creature_ptr) || creature_ptr->shero) {
         creature_ptr->resist_fear = TRUE;
     }
@@ -4619,9 +4606,6 @@ void calc_equipment_status(player_type *creature_ptr)
         if (have_flag(flgs, TR_REGEN))
             creature_ptr->regenerate = TRUE;
 
-        if (have_flag(flgs, TR_LEVITATION))
-            creature_ptr->levitation = TRUE;
-
         if (have_flag(flgs, TR_TELEPORT)) {
             if (object_is_cursed(o_ptr))
                 creature_ptr->cursed |= TRC_TELEPORT;