OSDN Git Service

[Refactor] #40030 Separated monster-runaway.c/h from monster-process.c
authorHourier <hourier@users.sourceforge.jp>
Sun, 8 Mar 2020 03:33:41 +0000 (12:33 +0900)
committerHourier <hourier@users.sourceforge.jp>
Sun, 8 Mar 2020 03:33:41 +0000 (12:33 +0900)
Hengband_vcs2017/Hengband/Hengband.vcxproj
Hengband_vcs2017/Hengband/Hengband.vcxproj.filters
src/Makefile.am
src/monster-process.c
src/monster/monster-runaway.c [new file with mode: 0644]
src/monster/monster-runaway.h [new file with mode: 0644]

index d3b0237..ddaebc4 100644 (file)
     <ClCompile Include="..\..\src\monster\monster-direction.c" />\r
     <ClCompile Include="..\..\src\monster\monster-move.c" />\r
     <ClCompile Include="..\..\src\monster\monster-object.c" />\r
+    <ClCompile Include="..\..\src\monster\monster-runaway.c" />\r
     <ClCompile Include="..\..\src\monster\monster-safety-hiding.c" />\r
     <ClCompile Include="..\..\src\monster\monster-update.c" />\r
     <ClCompile Include="..\..\src\monster\monster-util.c" />\r
     <ClInclude Include="..\..\src\monster\monster-direction.h" />\r
     <ClInclude Include="..\..\src\monster\monster-move.h" />\r
     <ClInclude Include="..\..\src\monster\monster-object.h" />\r
+    <ClInclude Include="..\..\src\monster\monster-runaway.h" />\r
     <ClInclude Include="..\..\src\monster\monster-safety-hiding.h" />\r
     <ClInclude Include="..\..\src\monster\monster-update.h" />\r
     <ClInclude Include="..\..\src\monster\monster-util.h" />\r
index 98bf623..e29df9b 100644 (file)
     <ClCompile Include="..\..\src\monster\monster-direction.c">
       <Filter>monster</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\src\monster\monster-runaway.c">
+      <Filter>monster</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\src\gamevalue.h" />
     <ClInclude Include="..\..\src\monster\monster-direction.h">
       <Filter>monster</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\monster\monster-runaway.h">
+      <Filter>monster</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="..\..\src\wall.bmp" />
index e36f9d3..b713c99 100644 (file)
@@ -63,6 +63,7 @@ hengband_SOURCES = \
        monster/monster-attack.c monster/monster-attack.h \
        monster/monster-move.c monster/monster-move.h \
        monster/monster-object.c monster/monster-object.h \
+       monster/monster-runaway.c monster/monster-runaway.h \
        monster/monster-safety-hiding.c monster/monster-safety-hiding.h \
        monster/monster-update.c monster/monster-update.h \
        monster/quantum-effect.c monster/quantum-effect.h \
index f28e4ab..5b41dd2 100644 (file)
@@ -19,6 +19,7 @@
 #include "monster/monster-direction.h"
 #include "monster/monster-object.h"
 #include "monster/monster-move.h"
+#include "monster/monster-runaway.h"
 #include "monster/monster-safety-hiding.h"
 #include "monster/monster-util.h"
 #include "monster/monster-update.h"
@@ -31,7 +32,6 @@
 #include "spells.h"
 #include "spells-floor.h"
 #include "spells-summon.h"
-#include "quest.h"
 #include "avatar.h"
 #include "realm-hex.h"
 #include "feature.h"
@@ -52,8 +52,6 @@ void awake_monster(player_type *target_ptr, MONSTER_IDX m_idx);
 void process_angar(player_type *target_ptr, MONSTER_IDX m_idx, bool see_m);
 bool explode_grenade(player_type *target_ptr, MONSTER_IDX m_idx);
 bool decide_monster_multiplication(player_type *target_ptr, MONSTER_IDX m_idx, POSITION oy, POSITION ox);
-bool runaway_monster(player_type *target_ptr, turn_flags *turn_flags_ptr, MONSTER_IDX m_idx);
-void escape_monster(player_type *target_ptr, turn_flags *turn_flags_ptr, monster_type *m_ptr, GAME_TEXT *m_name);
 void process_special(player_type *target_ptr, MONSTER_IDX m_idx);
 void process_speak_sound(player_type *target_ptr, MONSTER_IDX m_idx, POSITION oy, POSITION ox, bool aware);
 bool cast_spell(player_type *target_ptr, MONSTER_IDX m_idx, bool aware);
@@ -863,91 +861,6 @@ bool decide_monster_multiplication(player_type *target_ptr, MONSTER_IDX m_idx, P
 
 
 /*!
- * @brief ペットや友好的なモンスターがフロアから逃げる処理を行う
- * @param target_ptr プレーヤーへの参照ポインタ
- * @param m_idx モンスターID
- * @param is_riding_mon 騎乗状態ならばTRUE
- * @param see_m モンスターが視界内にいたらTRUE
- * @return モンスターがフロアから消えたらTRUE
- */
-bool runaway_monster(player_type *target_ptr, turn_flags *turn_flags_ptr, MONSTER_IDX m_idx)
-{
-       monster_type *m_ptr = &target_ptr->current_floor_ptr->m_list[m_idx];
-       monster_race *r_ptr = &r_info[m_ptr->r_idx];
-       bool can_runaway = is_pet(m_ptr) || is_friendly(m_ptr);
-       can_runaway &= ((r_ptr->flags1 & RF1_UNIQUE) != 0) || ((r_ptr->flags7 & RF7_NAZGUL) != 0);
-       can_runaway &= !target_ptr->phase_out;
-       if (!can_runaway) return FALSE;
-
-       static int riding_pinch = 0;
-
-       if (m_ptr->hp >= m_ptr->maxhp / 3)
-       {
-               /* Reset the counter */
-               if (turn_flags_ptr->is_riding_mon) riding_pinch = 0;
-
-               return FALSE;
-       }
-
-       GAME_TEXT m_name[MAX_NLEN];
-       monster_desc(target_ptr, m_name, m_ptr, 0);
-       if (turn_flags_ptr->is_riding_mon && riding_pinch < 2)
-       {
-               msg_format(_("%sは傷の痛さの余りあなたの束縛から逃れようとしている。",
-                       "%^s seems to be in so much pain and tries to escape from your restriction."), m_name);
-               riding_pinch++;
-               disturb(target_ptr, TRUE, TRUE);
-               return FALSE;
-       }
-
-       escape_monster(target_ptr, turn_flags_ptr, m_ptr, m_name);
-       check_quest_completion(target_ptr, m_ptr);
-       delete_monster_idx(target_ptr, m_idx);
-       return TRUE;
-}
-
-
-/*!
- * @brief HPが1/3未満になった有効的なユニークモンスターの逃走処理を行う
- * @param target_ptr プレーヤーへの参照ポインタ
- * @param is_riding_mon 騎乗状態ならばTRUE
- * @param m_ptr モンスターへの参照ポインタ
- * @param m_name モンスター名称
- * @param see_m モンスターが視界内にいたらTRUE
- * @return なし
- */
-void escape_monster(player_type *target_ptr, turn_flags *turn_flags_ptr, monster_type *m_ptr, GAME_TEXT *m_name)
-{
-       monster_race *r_ptr = &r_info[m_ptr->r_idx];
-       if (turn_flags_ptr->is_riding_mon)
-       {
-               msg_format(_("%sはあなたの束縛から脱出した。", "%^s succeeded to escape from your restriction!"), m_name);
-               if (rakuba(target_ptr, -1, FALSE))
-               {
-                       msg_print(_("地面に落とされた。", "You have fallen from the pet you were riding."));
-               }
-       }
-
-       if (turn_flags_ptr->see_m)
-       {
-               if ((r_ptr->flags2 & RF2_CAN_SPEAK) && (m_ptr->r_idx != MON_GRIP) && (m_ptr->r_idx != MON_WOLF) && (m_ptr->r_idx != MON_FANG) &&
-                       player_has_los_bold(target_ptr, m_ptr->fy, m_ptr->fx) && projectable(target_ptr, m_ptr->fy, m_ptr->fx, target_ptr->y, target_ptr->x))
-               {
-                       msg_format(_("%^s「ピンチだ!退却させてもらう!」", "%^s says 'It is the pinch! I will retreat'."), m_name);
-               }
-
-               msg_format(_("%^sがテレポート・レベルの巻物を読んだ。", "%^s reads a scroll of teleport level."), m_name);
-               msg_format(_("%^sが消え去った。", "%^s disappears."), m_name);
-       }
-
-       if (turn_flags_ptr->is_riding_mon && rakuba(target_ptr, -1, FALSE))
-       {
-               msg_print(_("地面に落とされた。", "You have fallen from the pet you were riding."));
-       }
-}
-
-
-/*!
  * @brief モンスターに魔法を試行させる
  * @param target_ptr プレーヤーへの参照ポインタ
  * @param m_idx モンスターID
diff --git a/src/monster/monster-runaway.c b/src/monster/monster-runaway.c
new file mode 100644 (file)
index 0000000..95ccd05
--- /dev/null
@@ -0,0 +1,94 @@
+/*!
+ * @brief モンスターの逃走に関する処理
+ * @date 2020/03/08
+ * @author Hourier
+ */
+
+#include "monster/monster-runaway.h"
+#include "player-move.h"
+#include "cmd/cmd-pet.h"
+#include "quest.h"
+
+ /*!
+  * @brief HPが1/3未満になった有効的なユニークモンスターの逃走処理を行う
+  * @param target_ptr プレーヤーへの参照ポインタ
+  * @param is_riding_mon 騎乗状態ならばTRUE
+  * @param m_ptr モンスターへの参照ポインタ
+  * @param m_name モンスター名称
+  * @param see_m モンスターが視界内にいたらTRUE
+  * @return なし
+  */
+static void escape_monster(player_type *target_ptr, turn_flags *turn_flags_ptr, monster_type *m_ptr, GAME_TEXT *m_name)
+{
+       monster_race *r_ptr = &r_info[m_ptr->r_idx];
+       if (turn_flags_ptr->is_riding_mon)
+       {
+               msg_format(_("%sはあなたの束縛から脱出した。", "%^s succeeded to escape from your restriction!"), m_name);
+               if (rakuba(target_ptr, -1, FALSE))
+               {
+                       msg_print(_("地面に落とされた。", "You have fallen from the pet you were riding."));
+               }
+       }
+
+       if (turn_flags_ptr->see_m)
+       {
+               if ((r_ptr->flags2 & RF2_CAN_SPEAK) && (m_ptr->r_idx != MON_GRIP) && (m_ptr->r_idx != MON_WOLF) && (m_ptr->r_idx != MON_FANG) &&
+                       player_has_los_bold(target_ptr, m_ptr->fy, m_ptr->fx) && projectable(target_ptr, m_ptr->fy, m_ptr->fx, target_ptr->y, target_ptr->x))
+               {
+                       msg_format(_("%^s「ピンチだ!退却させてもらう!」", "%^s says 'It is the pinch! I will retreat'."), m_name);
+               }
+
+               msg_format(_("%^sがテレポート・レベルの巻物を読んだ。", "%^s reads a scroll of teleport level."), m_name);
+               msg_format(_("%^sが消え去った。", "%^s disappears."), m_name);
+       }
+
+       if (turn_flags_ptr->is_riding_mon && rakuba(target_ptr, -1, FALSE))
+       {
+               msg_print(_("地面に落とされた。", "You have fallen from the pet you were riding."));
+       }
+}
+
+
+/*!
+ * @brief ペットや友好的なモンスターがフロアから逃げる処理を行う
+ * @param target_ptr プレーヤーへの参照ポインタ
+ * @param m_idx モンスターID
+ * @param is_riding_mon 騎乗状態ならばTRUE
+ * @param see_m モンスターが視界内にいたらTRUE
+ * @return モンスターがフロアから消えたらTRUE
+ */
+bool runaway_monster(player_type *target_ptr, turn_flags *turn_flags_ptr, MONSTER_IDX m_idx)
+{
+       monster_type *m_ptr = &target_ptr->current_floor_ptr->m_list[m_idx];
+       monster_race *r_ptr = &r_info[m_ptr->r_idx];
+       bool can_runaway = is_pet(m_ptr) || is_friendly(m_ptr);
+       can_runaway &= ((r_ptr->flags1 & RF1_UNIQUE) != 0) || ((r_ptr->flags7 & RF7_NAZGUL) != 0);
+       can_runaway &= !target_ptr->phase_out;
+       if (!can_runaway) return FALSE;
+
+       static int riding_pinch = 0;
+
+       if (m_ptr->hp >= m_ptr->maxhp / 3)
+       {
+               /* Reset the counter */
+               if (turn_flags_ptr->is_riding_mon) riding_pinch = 0;
+
+               return FALSE;
+       }
+
+       GAME_TEXT m_name[MAX_NLEN];
+       monster_desc(target_ptr, m_name, m_ptr, 0);
+       if (turn_flags_ptr->is_riding_mon && riding_pinch < 2)
+       {
+               msg_format(_("%sは傷の痛さの余りあなたの束縛から逃れようとしている。",
+                       "%^s seems to be in so much pain and tries to escape from your restriction."), m_name);
+               riding_pinch++;
+               disturb(target_ptr, TRUE, TRUE);
+               return FALSE;
+       }
+
+       escape_monster(target_ptr, turn_flags_ptr, m_ptr, m_name);
+       check_quest_completion(target_ptr, m_ptr);
+       delete_monster_idx(target_ptr, m_idx);
+       return TRUE;
+}
diff --git a/src/monster/monster-runaway.h b/src/monster/monster-runaway.h
new file mode 100644 (file)
index 0000000..24eb8d4
--- /dev/null
@@ -0,0 +1,6 @@
+#pragma once
+
+#include "angband.h"
+#include "monster/monster-util.h"
+
+bool runaway_monster(player_type *target_ptr, turn_flags *turn_flags_ptr, MONSTER_IDX m_idx);