OSDN Git Service

[Refactor] #40014 Moved update_smart_learn() from monster2.c/h to monster-update.c/h
authorHourier <hourier@users.sourceforge.jp>
Thu, 11 Jun 2020 11:22:58 +0000 (20:22 +0900)
committerHourier <hourier@users.sourceforge.jp>
Thu, 11 Jun 2020 11:22:58 +0000 (20:22 +0900)
src/monster-attack/monster-attack-switcher.c
src/monster/monster-update.c
src/monster/monster-update.h
src/monster/monster2.c
src/monster/monster2.h
src/mspell/mspell-ball.c
src/mspell/mspell-bolt.c
src/mspell/mspell-breath.c
src/mspell/mspell-floor.c
src/mspell/mspell-particularity.c
src/mspell/mspell-status.c

index 0b89f6b..dbca9e3 100644 (file)
@@ -11,7 +11,7 @@
 #include "mind/drs-types.h"
 #include "mind/mind-mirror-master.h"
 #include "monster/monster-status.h"
-#include "monster/monster2.h"
+#include "monster/monster-update.h"
 #include "player/player-damage.h"
 #include "player/player-effects.h"
 #include "spell-kind/earthquake.h"
index 930b531..eada1c4 100644 (file)
@@ -6,6 +6,7 @@
 
 #include "monster/monster-update.h"
 #include "dungeon/dungeon.h"
+#include "mind/drs-types.h"
 #include "monster-race/race-flags1.h"
 #include "monster-race/race-flags2.h"
 #include "monster-race/race-flags3.h"
@@ -14,6 +15,7 @@
 #include "monster/monster-flag-types.h"
 #include "monster/monster-info.h"
 #include "monster/monster-status.h"
+#include "monster/smart-learn-types.h"
 #include "player/eldritch-horror.h"
 #include "player/player-move.h"
 
@@ -411,3 +413,137 @@ void update_monsters(player_type *player_ptr, bool full)
         update_monster(player_ptr, i, full);
     }
 }
+
+/*!
+ * @brief SMART(適格に攻撃を行う)モンスターの学習状況を更新する / Learn about an "observed" resistance.
+ * @param m_idx 更新を行う「モンスター情報ID
+ * @param what 学習対象ID
+ * @return なし
+ */
+void update_smart_learn(player_type *player_ptr, MONSTER_IDX m_idx, int what)
+{
+    monster_type *m_ptr = &player_ptr->current_floor_ptr->m_list[m_idx];
+    monster_race *r_ptr = &r_info[m_ptr->r_idx];
+
+    if (!smart_learn)
+        return;
+    if (r_ptr->flags2 & (RF2_STUPID))
+        return;
+    if (!(r_ptr->flags2 & (RF2_SMART)) && (randint0(100) < 50))
+        return;
+
+    switch (what) {
+    case DRS_ACID:
+        if (player_ptr->resist_acid)
+            m_ptr->smart |= (SM_RES_ACID);
+        if (is_oppose_acid(player_ptr))
+            m_ptr->smart |= (SM_OPP_ACID);
+        if (player_ptr->immune_acid)
+            m_ptr->smart |= (SM_IMM_ACID);
+        break;
+
+    case DRS_ELEC:
+        if (player_ptr->resist_elec)
+            m_ptr->smart |= (SM_RES_ELEC);
+        if (is_oppose_elec(player_ptr))
+            m_ptr->smart |= (SM_OPP_ELEC);
+        if (player_ptr->immune_elec)
+            m_ptr->smart |= (SM_IMM_ELEC);
+        break;
+
+    case DRS_FIRE:
+        if (player_ptr->resist_fire)
+            m_ptr->smart |= (SM_RES_FIRE);
+        if (is_oppose_fire(player_ptr))
+            m_ptr->smart |= (SM_OPP_FIRE);
+        if (player_ptr->immune_fire)
+            m_ptr->smart |= (SM_IMM_FIRE);
+        break;
+
+    case DRS_COLD:
+        if (player_ptr->resist_cold)
+            m_ptr->smart |= (SM_RES_COLD);
+        if (is_oppose_cold(player_ptr))
+            m_ptr->smart |= (SM_OPP_COLD);
+        if (player_ptr->immune_cold)
+            m_ptr->smart |= (SM_IMM_COLD);
+        break;
+
+    case DRS_POIS:
+        if (player_ptr->resist_pois)
+            m_ptr->smart |= (SM_RES_POIS);
+        if (is_oppose_pois(player_ptr))
+            m_ptr->smart |= (SM_OPP_POIS);
+        break;
+
+    case DRS_NETH:
+        if (player_ptr->resist_neth)
+            m_ptr->smart |= (SM_RES_NETH);
+        break;
+
+    case DRS_LITE:
+        if (player_ptr->resist_lite)
+            m_ptr->smart |= (SM_RES_LITE);
+        break;
+
+    case DRS_DARK:
+        if (player_ptr->resist_dark)
+            m_ptr->smart |= (SM_RES_DARK);
+        break;
+
+    case DRS_FEAR:
+        if (player_ptr->resist_fear)
+            m_ptr->smart |= (SM_RES_FEAR);
+        break;
+
+    case DRS_CONF:
+        if (player_ptr->resist_conf)
+            m_ptr->smart |= (SM_RES_CONF);
+        break;
+
+    case DRS_CHAOS:
+        if (player_ptr->resist_chaos)
+            m_ptr->smart |= (SM_RES_CHAOS);
+        break;
+
+    case DRS_DISEN:
+        if (player_ptr->resist_disen)
+            m_ptr->smart |= (SM_RES_DISEN);
+        break;
+
+    case DRS_BLIND:
+        if (player_ptr->resist_blind)
+            m_ptr->smart |= (SM_RES_BLIND);
+        break;
+
+    case DRS_NEXUS:
+        if (player_ptr->resist_nexus)
+            m_ptr->smart |= (SM_RES_NEXUS);
+        break;
+
+    case DRS_SOUND:
+        if (player_ptr->resist_sound)
+            m_ptr->smart |= (SM_RES_SOUND);
+        break;
+
+    case DRS_SHARD:
+        if (player_ptr->resist_shard)
+            m_ptr->smart |= (SM_RES_SHARD);
+        break;
+
+    case DRS_FREE:
+        if (player_ptr->free_act)
+            m_ptr->smart |= (SM_IMM_FREE);
+        break;
+
+    case DRS_MANA:
+        if (!player_ptr->msp)
+            m_ptr->smart |= (SM_IMM_MANA);
+        break;
+
+    case DRS_REFLECT:
+        if (player_ptr->reflect)
+            m_ptr->smart |= (SM_IMM_REFLECT);
+        break;
+    }
+}
index 07482e8..101f5a6 100644 (file)
@@ -10,3 +10,4 @@ void update_monster_race_flags(player_type *target_ptr, turn_flags *turn_flags_p
 void update_player_window(player_type *target_ptr, old_race_flags *old_race_flags_ptr);
 void update_monster(player_type *subject_ptr, MONSTER_IDX m_idx, bool full);
 void update_monsters(player_type *player_ptr, bool full);
+void update_smart_learn(player_type *player_ptr, MONSTER_IDX m_idx, int what);
index 6e6ecfe..77b903d 100644 (file)
  */
 
 #include "monster/monster2.h"
-#include "core/player-processor.h"
 #include "core/speed-table.h"
 #include "dungeon/dungeon.h"
-#include "dungeon/quest.h"
-#include "effect/effect-characteristics.h"
 #include "floor/floor-object.h"
 #include "floor/wild.h"
-#include "io/files-util.h"
-#include "main/sound-definitions-table.h"
-#include "mind/drs-types.h"
-#include "monster-race/monster-race-hook.h"
 #include "monster-race/race-flags1.h"
 #include "monster-race/race-flags2.h"
 #include "monster-race/race-flags3.h"
 #include "monster-race/race-flags7.h"
 #include "monster-race/race-indice-types.h"
-#include "monster/monster-describer.h" // todo 相互参照している.
-#include "monster/monster-flag-types.h"
+#include "monster/monster-describer.h"
 #include "monster/monster-generator.h"
 #include "monster/monster-info.h"
 #include "monster/monster-update.h"
 #include "monster/monster-util.h"
-#include "monster/place-monster-types.h"
-#include "monster/smart-learn-types.h"
-#include "mspell/summon-checker.h"
-#include "object/object-flavor.h"
 #include "object/object-generator.h"
-#include "object/warning.h"
 #include "pet/pet-fall-off.h"
-#include "player/eldritch-horror.h"
-#include "player/player-move.h"
-#include "spell/process-effect.h"
-#include "spell/spells-summon.h"
-#include "spell/spells-type.h"
 #include "world/world.h"
 
 #define HORDE_NOGOOD 0x01 /*!< (未実装フラグ)HORDE生成でGOODなモンスターの生成を禁止する? */
@@ -443,140 +425,6 @@ SPEED get_mspeed(player_type *player_ptr, monster_race *r_ptr)
 }
 
 /*!
- * @brief SMART(適格に攻撃を行う)モンスターの学習状況を更新する / Learn about an "observed" resistance.
- * @param m_idx 更新を行う「モンスター情報ID
- * @param what 学習対象ID
- * @return なし
- */
-void update_smart_learn(player_type *player_ptr, MONSTER_IDX m_idx, int what)
-{
-    monster_type *m_ptr = &player_ptr->current_floor_ptr->m_list[m_idx];
-    monster_race *r_ptr = &r_info[m_ptr->r_idx];
-
-    if (!smart_learn)
-        return;
-    if (r_ptr->flags2 & (RF2_STUPID))
-        return;
-    if (!(r_ptr->flags2 & (RF2_SMART)) && (randint0(100) < 50))
-        return;
-
-    switch (what) {
-    case DRS_ACID:
-        if (player_ptr->resist_acid)
-            m_ptr->smart |= (SM_RES_ACID);
-        if (is_oppose_acid(player_ptr))
-            m_ptr->smart |= (SM_OPP_ACID);
-        if (player_ptr->immune_acid)
-            m_ptr->smart |= (SM_IMM_ACID);
-        break;
-
-    case DRS_ELEC:
-        if (player_ptr->resist_elec)
-            m_ptr->smart |= (SM_RES_ELEC);
-        if (is_oppose_elec(player_ptr))
-            m_ptr->smart |= (SM_OPP_ELEC);
-        if (player_ptr->immune_elec)
-            m_ptr->smart |= (SM_IMM_ELEC);
-        break;
-
-    case DRS_FIRE:
-        if (player_ptr->resist_fire)
-            m_ptr->smart |= (SM_RES_FIRE);
-        if (is_oppose_fire(player_ptr))
-            m_ptr->smart |= (SM_OPP_FIRE);
-        if (player_ptr->immune_fire)
-            m_ptr->smart |= (SM_IMM_FIRE);
-        break;
-
-    case DRS_COLD:
-        if (player_ptr->resist_cold)
-            m_ptr->smart |= (SM_RES_COLD);
-        if (is_oppose_cold(player_ptr))
-            m_ptr->smart |= (SM_OPP_COLD);
-        if (player_ptr->immune_cold)
-            m_ptr->smart |= (SM_IMM_COLD);
-        break;
-
-    case DRS_POIS:
-        if (player_ptr->resist_pois)
-            m_ptr->smart |= (SM_RES_POIS);
-        if (is_oppose_pois(player_ptr))
-            m_ptr->smart |= (SM_OPP_POIS);
-        break;
-
-    case DRS_NETH:
-        if (player_ptr->resist_neth)
-            m_ptr->smart |= (SM_RES_NETH);
-        break;
-
-    case DRS_LITE:
-        if (player_ptr->resist_lite)
-            m_ptr->smart |= (SM_RES_LITE);
-        break;
-
-    case DRS_DARK:
-        if (player_ptr->resist_dark)
-            m_ptr->smart |= (SM_RES_DARK);
-        break;
-
-    case DRS_FEAR:
-        if (player_ptr->resist_fear)
-            m_ptr->smart |= (SM_RES_FEAR);
-        break;
-
-    case DRS_CONF:
-        if (player_ptr->resist_conf)
-            m_ptr->smart |= (SM_RES_CONF);
-        break;
-
-    case DRS_CHAOS:
-        if (player_ptr->resist_chaos)
-            m_ptr->smart |= (SM_RES_CHAOS);
-        break;
-
-    case DRS_DISEN:
-        if (player_ptr->resist_disen)
-            m_ptr->smart |= (SM_RES_DISEN);
-        break;
-
-    case DRS_BLIND:
-        if (player_ptr->resist_blind)
-            m_ptr->smart |= (SM_RES_BLIND);
-        break;
-
-    case DRS_NEXUS:
-        if (player_ptr->resist_nexus)
-            m_ptr->smart |= (SM_RES_NEXUS);
-        break;
-
-    case DRS_SOUND:
-        if (player_ptr->resist_sound)
-            m_ptr->smart |= (SM_RES_SOUND);
-        break;
-
-    case DRS_SHARD:
-        if (player_ptr->resist_shard)
-            m_ptr->smart |= (SM_RES_SHARD);
-        break;
-
-    case DRS_FREE:
-        if (player_ptr->free_act)
-            m_ptr->smart |= (SM_IMM_FREE);
-        break;
-
-    case DRS_MANA:
-        if (!player_ptr->msp)
-            m_ptr->smart |= (SM_IMM_MANA);
-        break;
-
-    case DRS_REFLECT:
-        if (player_ptr->reflect)
-            m_ptr->smart |= (SM_IMM_REFLECT);
-        break;
-    }
-}
-
-/*!
  * @brief モンスターが盗みや拾いで確保していたアイテムを全てドロップさせる / Drop all items carried by a monster
  * @param player_ptr プレーヤーへの参照ポインタ
  * @param m_ptr モンスター参照ポインタ
index a238425..bc1cbe0 100644 (file)
@@ -10,7 +10,6 @@ MONSTER_IDX m_pop(player_type *player_ptr);
 
 #define GMN_ARENA 0x00000001 //!< 賭け闘技場向け生成
 MONRACE_IDX get_mon_num(player_type *player_ptr, DEPTH level, BIT_FLAGS option);
-void update_smart_learn(player_type *player_ptr, MONSTER_IDX m_idx, int what);
 void choose_new_monster(player_type *player_ptr, MONSTER_IDX m_idx, bool born, MONRACE_IDX r_idx);
 SPEED get_mspeed(player_type *player_ptr, monster_race *r_ptr);
 void monster_drop_carried_objects(player_type *player_ptr, monster_type *m_ptr);
index 2b82dc2..b51786b 100644 (file)
@@ -2,9 +2,9 @@
 #include "floor/floor.h"
 #include "mind/drs-types.h"
 #include "monster-race/race-indice-types.h"
-#include "monster/monster-status.h"
 #include "monster/monster-info.h"
-#include "monster/monster2.h"
+#include "monster/monster-status.h"
+#include "monster/monster-update.h"
 #include "mspell/monster-spell.h"
 #include "mspell/mspell-damage-calculator.h"
 #include "mspell/mspell-type.h"
index 50d5d67..ec5e696 100644 (file)
@@ -2,7 +2,7 @@
 #include "main/sound-definitions-table.h"
 #include "mind/drs-types.h"
 #include "monster/monster-info.h"
-#include "monster/monster2.h"
+#include "monster/monster-update.h"
 #include "mspell/monster-spell.h"
 #include "mspell/mspell-damage-calculator.h"
 #include "mspell/mspell-type.h"
index 5622708..bf3d8bd 100644 (file)
@@ -3,7 +3,7 @@
 #include "mind/drs-types.h"
 #include "monster-race/race-indice-types.h"
 #include "monster/monster-info.h"
-#include "monster/monster2.h"
+#include "monster/monster-update.h"
 #include "mspell/monster-spell.h"
 #include "mspell/mspell-damage-calculator.h"
 #include "mspell/mspell-util.h"
index db6d54b..d25f070 100644 (file)
@@ -15,7 +15,7 @@
 #include "monster-race/race-indice-types.h"
 #include "monster/monster-info.h"
 #include "monster/monster-status.h"
-#include "monster/monster2.h"
+#include "monster/monster-update.h"
 #include "mspell/monster-spell.h"
 #include "mspell/mspell-status.h"
 #include "mspell/mspell-util.h"
index a5663b4..be96705 100644 (file)
@@ -10,7 +10,7 @@
 
 #include "mspell/mspell-particularity.h"
 #include "mind/drs-types.h"
-#include "monster/monster2.h"
+#include "monster/monster-update.h"
 #include "mspell/mspell-type.h"
 #include "mspell/monster-spell.h"
 #include "spell/spells-type.h"
index a437266..923fa15 100644 (file)
@@ -14,7 +14,7 @@
 #include "monster/monster-description-types.h"
 #include "monster/monster-info.h"
 #include "monster/monster-status.h"
-#include "monster/monster2.h"
+#include "monster/monster-update.h"
 #include "mspell/monster-spell.h"
 #include "mspell/mspell-damage-calculator.h"
 #include "mspell/mspell-util.h"