<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
<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" />
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 \
#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"
#include "spells.h"
#include "spells-floor.h"
#include "spells-summon.h"
-#include "quest.h"
#include "avatar.h"
#include "realm-hex.h"
#include "feature.h"
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);
/*!
- * @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
--- /dev/null
+/*!
+ * @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;
+}
--- /dev/null
+#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);