OSDN Git Service

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

index 482b8d8..a450777 100644 (file)
@@ -1982,3 +1982,24 @@ void have_immune_acid(player_type *creature_ptr)
             creature_ptr->immune_acid = TRUE;
     }
 }
+
+void have_immune_elec(player_type *creature_ptr)
+{
+    object_type *o_ptr;
+    BIT_FLAGS flgs[TR_FLAG_SIZE];
+    creature_ptr->immune_elec = FALSE;
+    if (creature_ptr->ele_immune) {
+        if (creature_ptr->special_defense & DEFENSE_ELEC)
+            creature_ptr->immune_elec = 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_IM_ELEC))
+            creature_ptr->immune_elec = TRUE;
+    }
+}
index 7a8b6cc..ea3b870 100644 (file)
@@ -68,5 +68,6 @@ void have_resist_time(player_type *creature_ptr);
 void have_resist_water(player_type *creature_ptr);
 void have_resist_fear(player_type *creature_ptr);
 void have_immune_acid(player_type *creature_ptr);
+void have_immune_elec(player_type *creature_ptr);
 
 
index b473c0b..5b51f39 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->immune_elec = FALSE;
     creature_ptr->immune_fire = FALSE;
     creature_ptr->immune_cold = FALSE;
     creature_ptr->two_handed_weapon = FALSE;
@@ -731,6 +730,7 @@ void calc_bonuses(player_type *creature_ptr)
     have_resist_time(creature_ptr);
     have_resist_fear(creature_ptr);
     have_immune_acid(creature_ptr);
+    have_immune_elec(creature_ptr);
 
     calc_race_status(creature_ptr);
 
@@ -4441,9 +4441,7 @@ void calc_timelimit_status(player_type *creature_ptr)
     }
 
     if (creature_ptr->ele_immune) {
-        if (creature_ptr->special_defense & DEFENSE_ELEC)
-            creature_ptr->immune_elec = TRUE;
-        else if (creature_ptr->special_defense & DEFENSE_FIRE)
+        if (creature_ptr->special_defense & DEFENSE_FIRE)
             creature_ptr->immune_fire = TRUE;
         else if (creature_ptr->special_defense & DEFENSE_COLD)
             creature_ptr->immune_cold = TRUE;
@@ -4477,8 +4475,7 @@ void calc_equipment_status(player_type *creature_ptr)
             creature_ptr->immune_fire = TRUE;
         if (have_flag(flgs, TR_IM_COLD))
             creature_ptr->immune_cold = TRUE;
-        if (have_flag(flgs, TR_IM_ELEC))
-            creature_ptr->immune_elec = TRUE;
+
 
         if (o_ptr->tval == TV_CAPTURE)
             continue;