2 * @brief モンスターの逃走に関する処理
7 #include "monster-floor/monster-runaway.h"
8 #include "core/disturbance.h"
9 #include "dungeon/quest-completion-checker.h"
10 #include "floor/cave.h"
11 #include "grid/grid.h"
12 #include "monster-floor/monster-remover.h"
13 #include "monster-race/monster-race.h"
14 #include "monster-race/race-flags1.h"
15 #include "monster-race/race-flags2.h"
16 #include "monster-race/race-flags7.h"
17 #include "monster-race/race-indice-types.h"
18 #include "monster/monster-describer.h"
19 #include "monster/monster-info.h"
20 #include "monster/monster-processor-util.h"
21 #include "pet/pet-fall-off.h"
22 #include "system/floor-type-definition.h"
23 #include "system/monster-race-definition.h"
24 #include "system/monster-type-definition.h"
25 #include "system/player-type-definition.h"
26 #include "target/projection-path-calculator.h"
27 #include "view/display-messages.h"
30 * @brief HPが1/3未満になった有効的なユニークモンスターの逃走処理を行う
31 * @param target_ptr プレーヤーへの参照ポインタ
32 * @param is_riding_mon 騎乗状態ならばTRUE
33 * @param m_ptr モンスターへの参照ポインタ
34 * @param m_name モンスター名称
35 * @param see_m モンスターが視界内にいたらTRUE
37 static void escape_monster(player_type *target_ptr, turn_flags *turn_flags_ptr, monster_type *m_ptr, GAME_TEXT *m_name)
39 monster_race *r_ptr = &r_info[m_ptr->r_idx];
40 if (turn_flags_ptr->is_riding_mon) {
41 msg_format(_("%sはあなたの束縛から脱出した。", "%^s succeeded to escape from your restriction!"), m_name);
42 if (process_fall_off_horse(target_ptr, -1, false)) {
43 msg_print(_("地面に落とされた。", "You have fallen from the pet you were riding."));
47 if (turn_flags_ptr->see_m) {
48 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)
49 && 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)) {
50 msg_format(_("%^s「ピンチだ!退却させてもらう!」", "%^s says 'It is the pinch! I will retreat'."), m_name);
53 msg_format(_("%^sがテレポート・レベルの巻物を読んだ。", "%^s reads a scroll of teleport level."), m_name);
54 msg_format(_("%^sが消え去った。", "%^s disappears."), m_name);
57 if (turn_flags_ptr->is_riding_mon && process_fall_off_horse(target_ptr, -1, false)) {
58 msg_print(_("地面に落とされた。", "You have fallen from the pet you were riding."));
63 * @brief ペットや友好的なモンスターがフロアから逃げる処理を行う
64 * @param target_ptr プレーヤーへの参照ポインタ
65 * @param m_idx モンスターID
66 * @param is_riding_mon 騎乗状態ならばTRUE
67 * @param see_m モンスターが視界内にいたらTRUE
68 * @return モンスターがフロアから消えたらTRUE
70 bool runaway_monster(player_type *target_ptr, turn_flags *turn_flags_ptr, MONSTER_IDX m_idx)
72 monster_type *m_ptr = &target_ptr->current_floor_ptr->m_list[m_idx];
73 monster_race *r_ptr = &r_info[m_ptr->r_idx];
74 bool can_runaway = is_pet(m_ptr) || is_friendly(m_ptr);
75 can_runaway &= ((r_ptr->flags1 & RF1_UNIQUE) != 0) || ((r_ptr->flags7 & RF7_NAZGUL) != 0);
76 can_runaway &= !target_ptr->phase_out;
80 static int riding_pinch = 0;
82 if (m_ptr->hp >= m_ptr->maxhp / 3) {
83 /* Reset the counter */
84 if (turn_flags_ptr->is_riding_mon)
90 GAME_TEXT m_name[MAX_NLEN];
91 monster_desc(target_ptr, m_name, m_ptr, 0);
92 if (turn_flags_ptr->is_riding_mon && riding_pinch < 2) {
94 _("%sは傷の痛さの余りあなたの束縛から逃れようとしている。", "%^s seems to be in so much pain and tries to escape from your restriction."), m_name);
96 disturb(target_ptr, true, true);
100 escape_monster(target_ptr, turn_flags_ptr, m_ptr, m_name);
101 check_quest_completion(target_ptr, m_ptr);
102 delete_monster_idx(target_ptr, m_idx);