1 #include "monster/monster-status.h"
2 #include "autopick/autopick-pref-processor.h"
3 #include "cmd-io/cmd-dump.h"
4 #include "cmd-visual/cmd-draw.h"
5 #include "core/player-redraw-types.h"
6 #include "core/player-update-types.h"
7 #include "core/speed-table.h"
8 #include "core/stuff-handler.h"
9 #include "core/window-redrawer.h"
10 #include "dungeon/dungeon.h"
11 #include "game-option/birth-options.h"
12 #include "game-option/play-record-options.h"
13 #include "game-option/text-display-options.h"
14 #include "grid/grid.h"
15 #include "io/files-util.h"
16 #include "io/report.h"
17 #include "io/write-diary.h"
18 #include "main/sound-definitions-table.h"
19 #include "main/sound-of-music.h"
20 #include "mind/mind-ninja.h"
21 #include "monster-attack/monster-attack-effect.h"
22 #include "monster-attack/monster-attack-types.h"
23 #include "monster-floor/monster-death.h"
24 #include "monster-floor/monster-move.h"
25 #include "monster-floor/monster-remover.h"
26 #include "monster-floor/monster-summon.h"
27 #include "monster-floor/place-monster-types.h"
28 #include "monster-race/monster-race-hook.h"
29 #include "monster-race/monster-race.h"
30 #include "monster-race/race-flags-ability2.h"
31 #include "monster-race/race-flags-resistance.h"
32 #include "monster-race/race-flags1.h"
33 #include "monster-race/race-flags2.h"
34 #include "monster-race/race-flags3.h"
35 #include "monster-race/race-flags4.h"
36 #include "monster-race/race-flags7.h"
37 #include "monster-race/race-flags8.h"
38 #include "monster-race/race-indice-types.h"
39 #include "monster/monster-describer.h"
40 #include "monster/monster-description-types.h"
41 #include "monster/monster-flag-types.h"
42 #include "monster/monster-info.h"
43 #include "monster/monster-list.h"
44 #include "monster/monster-processor.h"
45 #include "monster/monster-update.h"
46 #include "monster/monster-util.h"
47 #include "monster/smart-learn-types.h"
48 #include "mspell/mspell-mask-definitions.h"
49 #include "object-enchant/object-curse.h"
50 #include "player/avatar.h"
51 #include "player/player-personalities-types.h"
52 #include "player/special-defense-types.h"
53 #include "spell-kind/spells-random.h"
54 #include "spell/spells-summon.h"
55 #include "status/experience.h"
56 #include "system/floor-type-definition.h"
57 #include "view/display-messages.h"
58 #include "world/world.h"
61 * @brief モンスターIDからPOWERFULフラグの有無を取得する /
62 * @param floor_ptr 現在フロアへの参照ポインタ
63 * @param m_idx モンスターID
64 * @return POWERFULフラグがあればTRUE、なければFALSEを返す。
66 bool monster_is_powerful(floor_type *floor_ptr, MONSTER_IDX m_idx)
68 monster_type *m_ptr = &floor_ptr->m_list[m_idx];
69 monster_race *r_ptr = &r_info[m_ptr->r_idx];
70 bool powerful = r_ptr->flags2 & RF2_POWERFUL ? TRUE : FALSE;
76 * @brief モンスターIDからモンスターのレベルを取得する(ただし最低1を保証する) /
77 * @param m_idx モンスターID
80 DEPTH monster_level_idx(floor_type *floor_ptr, MONSTER_IDX m_idx)
82 monster_type *m_ptr = &floor_ptr->m_list[m_idx];
83 monster_race *r_ptr = &r_info[m_ptr->r_idx];
84 DEPTH rlev = ((r_ptr->level >= 1) ? r_ptr->level : 1);
90 * @brief モンスターに与えたダメージの修正処理 /
91 * Modify the physical damage done to the monster.
92 * @param target_ptr プレーヤーへの参照ポインタ
93 * @param m_ptr ダメージを受けるモンスターの構造体参照ポインタ
95 * @param is_psy_spear 攻撃手段が光の剣ならばTRUE
96 * @return 修正を行った結果のダメージ量
99 * (for example when it's invulnerable or shielded)
100 * ToDo: Accept a damage-type to calculate the modified damage from
101 * things like fire, frost, lightning, poison, ... attacks.
102 * "type" is not yet used and should be 0.
105 HIT_POINT mon_damage_mod(player_type *target_ptr, monster_type *m_ptr, HIT_POINT dam, bool is_psy_spear)
107 monster_race *r_ptr = &r_info[m_ptr->r_idx];
109 if ((r_ptr->flagsr & RFR_RES_ALL) && dam > 0)
112 if ((dam == 0) && one_in_(3)) dam = 1;
115 if (monster_invulner_remaining(m_ptr))
119 if (!target_ptr->blind && is_seen(target_ptr, m_ptr))
121 msg_print(_("バリアを切り裂いた!", "The barrier is penetrated!"));
124 else if (!one_in_(PENETRATE_INVULNERABILITY))
135 * @brief モンスターに与えたダメージを元に経験値を加算する /
136 * Calculate experience point to be get
137 * @param dam 与えたダメージ量
138 * @param m_ptr ダメージを与えたモンスターの構造体参照ポインタ
142 * Even the 64 bit operation is not big enough to avoid overflaw
143 * unless we carefully choose orders of multiplication and division.
144 * Get the coefficient first, and multiply (potentially huge) base
145 * experience point of a monster later.
148 static void get_exp_from_mon(player_type *target_ptr, HIT_POINT dam, monster_type *m_ptr)
150 monster_race *r_ptr = &r_info[m_ptr->r_idx];
152 if (!monster_is_valid(m_ptr)) return;
153 if (is_pet(m_ptr) || target_ptr->phase_out) return;
156 * todo 変数宣言と代入を同時に実行するとコンパイル警告が出る
165 * - Ratio of monster's level to player's level effects
166 * - Varying speed effects
167 * - Get a fraction in proportion of damage point
169 new_exp = r_ptr->level * SPEED_TO_ENERGY(m_ptr->mspeed) * dam;
172 div_l = (target_ptr->max_plv + 2) * SPEED_TO_ENERGY(r_ptr->speed);
174 /* Use (average maxhp * 2) as a denominator */
175 if (!(r_ptr->flags1 & RF1_FORCE_MAXHP))
176 s64b_mul(&div_h, &div_l, 0, r_ptr->hdice * (ironman_nightmare ? 2 : 1) * (r_ptr->hside + 1));
178 s64b_mul(&div_h, &div_l, 0, r_ptr->hdice * (ironman_nightmare ? 2 : 1) * r_ptr->hside * 2);
180 /* Special penalty in the wilderness */
181 if (!target_ptr->current_floor_ptr->dun_level && (!(r_ptr->flags8 & RF8_WILD_ONLY) || !(r_ptr->flags1 & RF1_UNIQUE)))
182 s64b_mul(&div_h, &div_l, 0, 5);
184 /* Do division first to prevent overflaw */
185 s64b_div(&new_exp, &new_exp_frac, div_h, div_l);
187 /* Special penalty for mutiply-monster */
188 if ((r_ptr->flags2 & RF2_MULTIPLY) || (m_ptr->r_idx == MON_DAWN))
190 int monnum_penarty = r_ptr->r_akills / 400;
191 if (monnum_penarty > 8) monnum_penarty = 8;
193 while (monnum_penarty--)
196 s64b_RSHIFT(new_exp, new_exp_frac, 2);
200 /* Special penalty for rest_and_shoot exp scum */
201 if ((m_ptr->dealt_damage > m_ptr->max_maxhp) && (m_ptr->hp >= 0))
203 int over_damage = m_ptr->dealt_damage / m_ptr->max_maxhp;
204 if (over_damage > 32) over_damage = 32;
206 while (over_damage--)
209 s64b_mul(&new_exp, &new_exp_frac, 0, 9);
210 s64b_div(&new_exp, &new_exp_frac, 0, 10);
214 s64b_mul(&new_exp, &new_exp_frac, 0, r_ptr->mexp);
215 gain_exp_64(target_ptr, new_exp, new_exp_frac);
220 * @brief モンスターの時限ステータスを取得する
221 * @param floor_ptr 現在フロアへの参照ポインタ
222 * @return m_idx モンスターの参照ID
223 * @return mproc_type モンスターの時限ステータスID
226 int get_mproc_idx(floor_type *floor_ptr, MONSTER_IDX m_idx, int mproc_type)
228 s16b *cur_mproc_list = floor_ptr->mproc_list[mproc_type];
229 for (int i = floor_ptr->mproc_max[mproc_type] - 1; i >= 0; i--)
231 if (cur_mproc_list[i] == m_idx) return i;
239 * @brief モンスターの時限ステータスリストを追加する
240 * @param floor_ptr 現在フロアへの参照ポインタ
241 * @return m_idx モンスターの参照ID
242 * @return mproc_type 追加したいモンスターの時限ステータスID
245 static void mproc_add(floor_type *floor_ptr, MONSTER_IDX m_idx, int mproc_type)
247 if (floor_ptr->mproc_max[mproc_type] < current_world_ptr->max_m_idx)
249 floor_ptr->mproc_list[mproc_type][floor_ptr->mproc_max[mproc_type]++] = (s16b)m_idx;
255 * @brief モンスターの時限ステータスリストを削除
256 * @param floor_ptr 現在フロアへの参照ポインタ
257 * @return m_idx モンスターの参照ID
258 * @return mproc_type 削除したいモンスターの時限ステータスID
261 static void mproc_remove(floor_type *floor_ptr, MONSTER_IDX m_idx, int mproc_type)
263 int mproc_idx = get_mproc_idx(floor_ptr, m_idx, mproc_type);
266 floor_ptr->mproc_list[mproc_type][mproc_idx] = floor_ptr->mproc_list[mproc_type][--floor_ptr->mproc_max[mproc_type]];
272 * @brief モンスターの時限ステータスリストを初期化する / Initialize monster process
273 * @param floor_ptr 現在フロアへの参照ポインタ
276 void mproc_init(floor_type *floor_ptr)
278 /* Reset "target_ptr->current_floor_ptr->mproc_max[]" */
279 for (int i = 0; i < MAX_MTIMED; i++)
281 floor_ptr->mproc_max[i] = 0;
284 /* Process the monsters (backwards) */
285 for (MONSTER_IDX i = floor_ptr->m_max - 1; i >= 1; i--)
288 m_ptr = &floor_ptr->m_list[i];
290 /* Ignore "dead" monsters */
291 if (!monster_is_valid(m_ptr)) continue;
293 for (int cmi = 0; cmi < MAX_MTIMED; cmi++)
295 if (m_ptr->mtimed[cmi]) mproc_add(floor_ptr, i, cmi);
302 * @brief モンスターの睡眠状態値をセットする。0で起きる。 /
303 * Set "m_ptr->mtimed[MTIMED_CSLEEP]", notice observable changes
304 * @param target_ptr プレーヤーへの参照ポインタ
305 * @param m_idx モンスター参照ID
307 * @return 別途更新処理が必要な場合TRUEを返す
309 bool set_monster_csleep(player_type *target_ptr, MONSTER_IDX m_idx, int v)
311 floor_type *floor_ptr = target_ptr->current_floor_ptr;
312 monster_type *m_ptr = &floor_ptr->m_list[m_idx];
314 v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
318 if (!monster_csleep_remaining(m_ptr))
320 mproc_add(floor_ptr, m_idx, MTIMED_CSLEEP);
327 if (monster_csleep_remaining(m_ptr))
329 mproc_remove(floor_ptr, m_idx, MTIMED_CSLEEP);
335 m_ptr->mtimed[MTIMED_CSLEEP] = (s16b)v;
337 if (!notice) return FALSE;
341 /* Update health bar as needed */
342 if (target_ptr->health_who == m_idx) target_ptr->redraw |= (PR_HEALTH);
343 if (target_ptr->riding == m_idx) target_ptr->redraw |= (PR_UHEALTH);
346 if (r_info[m_ptr->r_idx].flags7 & RF7_HAS_LD_MASK) target_ptr->update |= (PU_MON_LITE);
353 * @brief モンスターの加速状態値をセット /
354 * Set "m_ptr->mtimed[MTIMED_FAST]", notice observable changes
355 * @param target_ptr プレーヤーへの参照ポインタ
356 * @param m_idx モンスター参照ID
358 * @return 別途更新処理が必要な場合TRUEを返す
360 bool set_monster_fast(player_type *target_ptr, MONSTER_IDX m_idx, int v)
362 floor_type *floor_ptr = target_ptr->current_floor_ptr;
363 monster_type *m_ptr = &floor_ptr->m_list[m_idx];
365 v = (v > 200) ? 200 : (v < 0) ? 0 : v;
369 if (!monster_fast_remaining(m_ptr))
371 mproc_add(floor_ptr, m_idx, MTIMED_FAST);
378 if (monster_fast_remaining(m_ptr))
380 mproc_remove(floor_ptr, m_idx, MTIMED_FAST);
386 m_ptr->mtimed[MTIMED_FAST] = (s16b)v;
388 if (!notice) return FALSE;
390 if ((target_ptr->riding == m_idx) && !target_ptr->leaving) target_ptr->update |= (PU_BONUS);
397 * Set "m_ptr->mtimed[MTIMED_SLOW]", notice observable changes
399 bool set_monster_slow(player_type *target_ptr, MONSTER_IDX m_idx, int v)
401 floor_type *floor_ptr = target_ptr->current_floor_ptr;
402 monster_type *m_ptr = &floor_ptr->m_list[m_idx];
404 v = (v > 200) ? 200 : (v < 0) ? 0 : v;
408 if (!monster_slow_remaining(m_ptr))
410 mproc_add(floor_ptr, m_idx, MTIMED_SLOW);
417 if (monster_slow_remaining(m_ptr))
419 mproc_remove(floor_ptr, m_idx, MTIMED_SLOW);
425 m_ptr->mtimed[MTIMED_SLOW] = (s16b)v;
427 if (!notice) return FALSE;
429 if ((target_ptr->riding == m_idx) && !target_ptr->leaving) target_ptr->update |= (PU_BONUS);
436 * @brief モンスターの朦朧状態値をセット /
437 * Set "m_ptr->mtimed[MTIMED_STUNNED]", notice observable changes
438 * @param target_ptr プレーヤーへの参照ポインタ
439 * @param m_idx モンスター参照ID
441 * @return 別途更新処理が必要な場合TRUEを返す
443 bool set_monster_stunned(player_type *target_ptr, MONSTER_IDX m_idx, int v)
445 floor_type *floor_ptr = target_ptr->current_floor_ptr;
446 monster_type *m_ptr = &floor_ptr->m_list[m_idx];
448 v = (v > 200) ? 200 : (v < 0) ? 0 : v;
452 if (!monster_stunned_remaining(m_ptr))
454 mproc_add(floor_ptr, m_idx, MTIMED_STUNNED);
461 if (monster_stunned_remaining(m_ptr))
463 mproc_remove(floor_ptr, m_idx, MTIMED_STUNNED);
469 m_ptr->mtimed[MTIMED_STUNNED] = (s16b)v;
476 * @brief モンスターの混乱状態値をセット /
477 * Set "m_ptr->mtimed[MTIMED_CONFUSED]", notice observable changes
478 * @param target_ptr プレーヤーへの参照ポインタ
479 * @param m_idx モンスター参照ID
481 * @return 別途更新処理が必要な場合TRUEを返す
483 bool set_monster_confused(player_type *target_ptr, MONSTER_IDX m_idx, int v)
485 floor_type *floor_ptr = target_ptr->current_floor_ptr;
486 monster_type *m_ptr = &floor_ptr->m_list[m_idx];
488 v = (v > 200) ? 200 : (v < 0) ? 0 : v;
492 if (!monster_confused_remaining(m_ptr))
494 mproc_add(floor_ptr, m_idx, MTIMED_CONFUSED);
501 if (monster_confused_remaining(m_ptr))
503 mproc_remove(floor_ptr, m_idx, MTIMED_CONFUSED);
509 m_ptr->mtimed[MTIMED_CONFUSED] = (s16b)v;
516 * @brief モンスターの恐慌状態値をセット /
517 * Set "m_ptr->mtimed[MTIMED_MONFEAR]", notice observable changes
518 * @param target_ptr プレーヤーへの参照ポインタ
519 * @param m_idx モンスター参照ID
521 * @return 別途更新処理が必要な場合TRUEを返す
523 bool set_monster_monfear(player_type *target_ptr, MONSTER_IDX m_idx, int v)
525 floor_type *floor_ptr = target_ptr->current_floor_ptr;
526 monster_type *m_ptr = &floor_ptr->m_list[m_idx];
528 v = (v > 200) ? 200 : (v < 0) ? 0 : v;
532 if (!monster_fear_remaining(m_ptr))
534 mproc_add(floor_ptr, m_idx, MTIMED_MONFEAR);
541 if (monster_fear_remaining(m_ptr))
543 mproc_remove(floor_ptr, m_idx, MTIMED_MONFEAR);
549 m_ptr->mtimed[MTIMED_MONFEAR] = (s16b)v;
551 if (!notice) return FALSE;
555 /* Update health bar as needed */
556 if (target_ptr->health_who == m_idx) target_ptr->redraw |= (PR_HEALTH);
557 if (target_ptr->riding == m_idx) target_ptr->redraw |= (PR_UHEALTH);
565 * @brief モンスターの無敵状態値をセット /
566 * Set "m_ptr->mtimed[MTIMED_INVULNER]", notice observable changes
567 * @param target_ptr プレーヤーへの参照ポインタ
568 * @param m_idx モンスター参照ID
570 * @param energy_need TRUEならば無敵解除時に行動ターン消費を行う
571 * @return 別途更新処理が必要な場合TRUEを返す
573 bool set_monster_invulner(player_type *target_ptr, MONSTER_IDX m_idx, int v, bool energy_need)
575 floor_type *floor_ptr = target_ptr->current_floor_ptr;
576 monster_type *m_ptr = &floor_ptr->m_list[m_idx];
578 v = (v > 200) ? 200 : (v < 0) ? 0 : v;
582 if (!monster_invulner_remaining(m_ptr))
584 mproc_add(floor_ptr, m_idx, MTIMED_INVULNER);
591 if (monster_invulner_remaining(m_ptr))
593 mproc_remove(floor_ptr, m_idx, MTIMED_INVULNER);
594 if (energy_need && !target_ptr->wild_mode) m_ptr->energy_need += ENERGY_NEED();
600 m_ptr->mtimed[MTIMED_INVULNER] = (s16b)v;
602 if (!notice) return FALSE;
606 /* Update health bar as needed */
607 if (target_ptr->health_who == m_idx) target_ptr->redraw |= (PR_HEALTH);
608 if (target_ptr->riding == m_idx) target_ptr->redraw |= (PR_UHEALTH);
615 static u32b csleep_noise;
618 * @brief モンスターの各種状態値を時間経過により更新するサブルーチン
619 * @param floor_ptr 現在フロアへの参照ポインタ
620 * @param m_idx モンスター参照ID
621 * @param mtimed_idx 更新するモンスターの時限ステータスID
624 static void process_monsters_mtimed_aux(player_type *target_ptr, MONSTER_IDX m_idx, int mtimed_idx)
626 monster_type *m_ptr = &target_ptr->current_floor_ptr->m_list[m_idx];
632 monster_race *r_ptr = &r_info[m_ptr->r_idx];
634 /* Assume does not wake up */
637 /* Hack -- Require proximity */
638 if (m_ptr->cdis < AAF_LIMIT)
640 /* Handle "sensing radius" */
641 if (m_ptr->cdis <= (is_pet(m_ptr) ? ((r_ptr->aaf > MAX_SIGHT) ? MAX_SIGHT : r_ptr->aaf) : r_ptr->aaf))
647 /* Handle "sight" and "aggravation" */
648 else if ((m_ptr->cdis <= MAX_SIGHT) && (player_has_los_bold(target_ptr, m_ptr->fy, m_ptr->fx)))
657 u32b notice = randint0(1024);
659 /* Nightmare monsters are more alert */
660 if (ironman_nightmare) notice /= 2;
662 /* Hack -- See if monster "notices" player */
663 if ((notice * notice * notice) > csleep_noise) break;
665 /* Hack -- amount of "waking" */
666 /* Wake up faster near the player */
667 int d = (m_ptr->cdis < AAF_LIMIT / 2) ? (AAF_LIMIT / m_ptr->cdis) : 1;
669 /* Hack -- amount of "waking" is affected by speed of player */
670 d = (d * SPEED_TO_ENERGY(target_ptr->pspeed)) / 10;
673 /* Monster wakes up "a little bit" */
676 if (!set_monster_csleep(target_ptr, m_idx, monster_csleep_remaining(m_ptr) - d))
678 /* Notice the "not waking up" */
679 if (is_original_ap_and_seen(target_ptr, m_ptr))
681 /* Hack -- Count the ignores */
682 if (r_ptr->r_ignore < MAX_UCHAR) r_ptr->r_ignore++;
688 /* Notice the "waking up" */
691 GAME_TEXT m_name[MAX_NLEN];
692 monster_desc(target_ptr, m_name, m_ptr, 0);
693 msg_format(_("%^sが目を覚ました。", "%^s wakes up."), m_name);
696 if (is_original_ap_and_seen(target_ptr, m_ptr))
698 /* Hack -- Count the wakings */
699 if (r_ptr->r_wake < MAX_UCHAR) r_ptr->r_wake++;
706 /* Reduce by one, note if expires */
707 if (set_monster_fast(target_ptr, m_idx, monster_fast_remaining(m_ptr) - 1))
709 if (is_seen(target_ptr, m_ptr))
711 GAME_TEXT m_name[MAX_NLEN];
712 monster_desc(target_ptr, m_name, m_ptr, 0);
713 msg_format(_("%^sはもう加速されていない。", "%^s is no longer fast."), m_name);
720 /* Reduce by one, note if expires */
721 if (set_monster_slow(target_ptr, m_idx, monster_slow_remaining(m_ptr) - 1))
723 if (is_seen(target_ptr, m_ptr))
725 GAME_TEXT m_name[MAX_NLEN];
726 monster_desc(target_ptr, m_name, m_ptr, 0);
727 msg_format(_("%^sはもう減速されていない。", "%^s is no longer slow."), m_name);
735 int rlev = r_info[m_ptr->r_idx].level;
737 /* Recover from stun */
738 if (set_monster_stunned(target_ptr, m_idx, (randint0(10000) <= rlev * rlev) ? 0 : (monster_stunned_remaining(m_ptr) - 1)))
740 /* Message if visible */
741 if (is_seen(target_ptr, m_ptr))
743 GAME_TEXT m_name[MAX_NLEN];
744 monster_desc(target_ptr, m_name, m_ptr, 0);
745 msg_format(_("%^sは朦朧状態から立ち直った。", "%^s is no longer stunned."), m_name);
752 case MTIMED_CONFUSED:
754 /* Reduce the confusion */
755 if (!set_monster_confused(target_ptr, m_idx, monster_confused_remaining(m_ptr) - randint1(r_info[m_ptr->r_idx].level / 20 + 1)))
757 /* Message if visible */
758 if (is_seen(target_ptr, m_ptr))
760 GAME_TEXT m_name[MAX_NLEN];
761 monster_desc(target_ptr, m_name, m_ptr, 0);
762 msg_format(_("%^sは混乱から立ち直った。", "%^s is no longer confused."), m_name);
770 /* Reduce the fear */
771 if (!set_monster_monfear(target_ptr, m_idx, monster_fear_remaining(m_ptr) - randint1(r_info[m_ptr->r_idx].level / 20 + 1)))
775 if (is_seen(target_ptr, m_ptr))
777 GAME_TEXT m_name[MAX_NLEN];
782 /* Acquire the monster possessive */
783 monster_desc(target_ptr, m_poss, m_ptr, MD_PRON_VISIBLE | MD_POSSESSIVE);
785 monster_desc(target_ptr, m_name, m_ptr, 0);
787 msg_format("%^sは勇気を取り戻した。", m_name);
789 msg_format("%^s recovers %s courage.", m_name, m_poss);
796 case MTIMED_INVULNER:
798 /* Reduce by one, note if expires */
799 if (!set_monster_invulner(target_ptr, m_idx, monster_invulner_remaining(m_ptr) - 1, TRUE))
802 if (is_seen(target_ptr, m_ptr))
804 GAME_TEXT m_name[MAX_NLEN];
805 monster_desc(target_ptr, m_name, m_ptr, 0);
806 msg_format(_("%^sはもう無敵でない。", "%^s is no longer invulnerable."), m_name);
816 * @brief 全モンスターの各種状態値を時間経過により更新するメインルーチン
817 * @param mtimed_idx 更新するモンスターの時限ステータスID
818 * @param target_ptr プレーヤーへの参照ポインタ
821 * Process the counters of monsters (once per 10 game turns)\n
822 * These functions are to process monsters' counters same as player's.
824 void process_monsters_mtimed(player_type *target_ptr, int mtimed_idx)
826 floor_type *floor_ptr = target_ptr->current_floor_ptr;
827 s16b *cur_mproc_list = floor_ptr->mproc_list[mtimed_idx];
829 /* Hack -- calculate the "player noise" */
830 if (mtimed_idx == MTIMED_CSLEEP) csleep_noise = (1L << (30 - target_ptr->skill_stl));
832 /* Process the monsters (backwards) */
833 for (int i = floor_ptr->mproc_max[mtimed_idx] - 1; i >= 0; i--)
835 process_monsters_mtimed_aux(target_ptr, cur_mproc_list[i], mtimed_idx);
841 * @brief モンスターへの魔力消去処理
842 * @param target_ptr プレーヤーへの参照ポインタ
843 * @param m_idx 魔力消去を受けるモンスターの参照ID
846 void dispel_monster_status(player_type *target_ptr, MONSTER_IDX m_idx)
848 monster_type *m_ptr = &target_ptr->current_floor_ptr->m_list[m_idx];
849 GAME_TEXT m_name[MAX_NLEN];
851 monster_desc(target_ptr, m_name, m_ptr, 0);
852 if (set_monster_invulner(target_ptr, m_idx, 0, TRUE))
854 if (m_ptr->ml) msg_format(_("%sはもう無敵ではない。", "%^s is no longer invulnerable."), m_name);
857 if (set_monster_fast(target_ptr, m_idx, 0))
859 if (m_ptr->ml) msg_format(_("%sはもう加速されていない。", "%^s is no longer fast."), m_name);
862 if (set_monster_slow(target_ptr, m_idx, 0))
864 if (m_ptr->ml) msg_format(_("%sはもう減速されていない。", "%^s is no longer slow."), m_name);
870 * @brief モンスターの時間停止処理
871 * @param target_ptr プレーヤーへの参照ポインタ
872 * @param num 時間停止を行った敵が行動できる回数
873 * @param who 時間停止処理の主体ID
874 * @param vs_player TRUEならば時間停止開始処理を行う
875 * @return 時間停止が行われている状態ならばTRUEを返す
877 bool set_monster_timewalk(player_type *target_ptr, int num, MONSTER_IDX who, bool vs_player)
879 monster_type *m_ptr = &target_ptr->current_floor_ptr->m_list[hack_m_idx]; /* the world monster */
881 if (current_world_ptr->timewalk_m_idx) return FALSE;
885 GAME_TEXT m_name[MAX_NLEN];
886 monster_desc(target_ptr, m_name, m_ptr, 0);
889 msg_format(_("「『ザ・ワールド』!時は止まった!」", "%s yells 'The World! Time has stopped!'"), m_name);
891 msg_format(_("「時よ!」", "%s yells 'Time!'"), m_name);
892 else msg_print("hek!");
897 /* This monster cast spells */
898 current_world_ptr->timewalk_m_idx = hack_m_idx;
900 if (vs_player) do_cmd_redraw(target_ptr);
904 if (!monster_is_valid(m_ptr)) break;
905 process_monster(target_ptr, current_world_ptr->timewalk_m_idx);
907 handle_stuff(target_ptr);
909 if (vs_player) term_xtra(TERM_XTRA_DELAY, 500);
912 target_ptr->redraw |= (PR_MAP);
913 target_ptr->update |= (PU_MONSTERS);
914 target_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
916 current_world_ptr->timewalk_m_idx = 0;
917 if (vs_player || (player_has_los_bold(target_ptr, m_ptr->fy, m_ptr->fx) && projectable(target_ptr, target_ptr->y, target_ptr->x, m_ptr->fy, m_ptr->fx)))
919 msg_print(_("「時は動きだす…」", "You feel time flowing around you once more."));
923 handle_stuff(target_ptr);
928 * @brief モンスターの経験値取得処理
929 * @param target_ptr プレーヤーへの参照ポインタ
930 * @param m_idx 経験値を得るモンスターの参照ID
931 * @param s_idx 撃破されたモンスター種族の参照ID
934 void monster_gain_exp(player_type *target_ptr, MONSTER_IDX m_idx, MONRACE_IDX s_idx)
939 if (m_idx <= 0 || s_idx <= 0) return;
941 floor_type *floor_ptr = target_ptr->current_floor_ptr;
942 m_ptr = &floor_ptr->m_list[m_idx];
944 if (!monster_is_valid(m_ptr)) return;
946 r_ptr = &r_info[m_ptr->r_idx];
947 s_ptr = &r_info[s_idx];
949 if (target_ptr->phase_out) return;
951 if (!r_ptr->next_exp) return;
953 int new_exp = s_ptr->mexp * s_ptr->level / (r_ptr->level + 2);
954 if (m_idx == target_ptr->riding) new_exp = (new_exp + 1) / 2;
955 if (!floor_ptr->dun_level) new_exp /= 5;
956 m_ptr->exp += new_exp;
957 if (m_ptr->mflag2 & MFLAG2_CHAMELEON) return;
959 if (m_ptr->exp < r_ptr->next_exp)
961 if (m_idx == target_ptr->riding) target_ptr->update |= PU_BONUS;
965 GAME_TEXT m_name[MAX_NLEN];
966 int old_hp = m_ptr->hp;
967 int old_maxhp = m_ptr->max_maxhp;
968 int old_r_idx = m_ptr->r_idx;
969 byte old_sub_align = m_ptr->sub_align;
971 /* Hack -- Reduce the racial counter of previous monster */
972 real_r_ptr(m_ptr)->cur_num--;
974 monster_desc(target_ptr, m_name, m_ptr, 0);
975 m_ptr->r_idx = r_ptr->next_r_idx;
977 /* Count the monsters on the level */
978 real_r_ptr(m_ptr)->cur_num++;
980 m_ptr->ap_r_idx = m_ptr->r_idx;
981 r_ptr = &r_info[m_ptr->r_idx];
983 if (r_ptr->flags1 & RF1_FORCE_MAXHP)
985 m_ptr->max_maxhp = maxroll(r_ptr->hdice, r_ptr->hside);
989 m_ptr->max_maxhp = damroll(r_ptr->hdice, r_ptr->hside);
991 if (ironman_nightmare)
993 HIT_POINT hp = m_ptr->max_maxhp * 2L;
994 m_ptr->max_maxhp = MIN(30000, hp);
997 m_ptr->maxhp = m_ptr->max_maxhp;
998 m_ptr->hp = old_hp * m_ptr->maxhp / old_maxhp;
1000 /* dealt damage is 0 at initial*/
1001 m_ptr->dealt_damage = 0;
1003 /* Extract the monster base speed */
1004 m_ptr->mspeed = get_mspeed(target_ptr, r_ptr);
1006 /* Sub-alignment of a monster */
1007 if (!is_pet(m_ptr) && !(r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)))
1008 m_ptr->sub_align = old_sub_align;
1011 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
1012 if (r_ptr->flags3 & RF3_EVIL) m_ptr->sub_align |= SUB_ALIGN_EVIL;
1013 if (r_ptr->flags3 & RF3_GOOD) m_ptr->sub_align |= SUB_ALIGN_GOOD;
1018 if (is_pet(m_ptr) || m_ptr->ml)
1020 if (!ignore_unview || player_can_see_bold(target_ptr, m_ptr->fy, m_ptr->fx))
1022 if (target_ptr->image)
1024 monster_race *hallu_race;
1028 hallu_race = &r_info[randint1(max_r_idx - 1)];
1029 } while (!hallu_race->name || (hallu_race->flags1 & RF1_UNIQUE));
1030 msg_format(_("%sは%sに進化した。", "%^s evolved into %s."), m_name, r_name + hallu_race->name);
1034 msg_format(_("%sは%sに進化した。", "%^s evolved into %s."), m_name, r_name + r_ptr->name);
1038 if (!target_ptr->image) r_info[old_r_idx].r_xtra1 |= MR1_EVOLUTION;
1040 /* Now you feel very close to this pet. */
1041 m_ptr->parent_m_idx = 0;
1044 update_monster(target_ptr, m_idx, FALSE);
1045 lite_spot(target_ptr, m_ptr->fy, m_ptr->fx);
1047 if (m_idx == target_ptr->riding) target_ptr->update |= PU_BONUS;
1051 * @brief モンスターのHPをダメージに応じて減算する /
1052 * Decreases monsters hit points, handling monster death.
1053 * @param dam 与えたダメージ量
1054 * @param m_idx ダメージを与えたモンスターのID
1055 * @param fear ダメージによってモンスターが恐慌状態に陥ったならばTRUEを返す
1056 * @param note モンスターが倒された際の特別なメッセージ述語
1060 * We return TRUE if the monster has been killed (and deleted).
1061 * We announce monster death (using an optional "death message"
1062 * if given, and a otherwise a generic killed/destroyed message).
1063 * Only "physical attacks" can induce the "You have slain" message.
1064 * Missile and Spell attacks will induce the "dies" message, or
1065 * various "specialized" messages. Note that "You have destroyed"
1066 * and "is destroyed" are synonyms for "You have slain" and "dies".
1067 * Hack -- unseen monsters yield "You have killed it." message.
1068 * Added fear (DGK) and check whether to print fear messages -CWS
1069 * Made name, sex, and capitalization generic -BEN-
1070 * As always, the "ghost" processing is a total hack.
1071 * Hack -- we "delay" fear messages by passing around a "fear" flag.
1072 * Consider decreasing monster experience over time, say,
1073 * by using "(m_exp * m_lev * (m_lev)) / (p_lev * (m_lev + n_killed))"
1074 * instead of simply "(m_exp * m_lev) / (p_lev)", to make the first
1075 * monster worth more than subsequent monsters. This would also need
1076 * to induce changes in the monster recall code.
1079 bool mon_take_hit(player_type *target_ptr, MONSTER_IDX m_idx, HIT_POINT dam, bool *fear, concptr note)
1081 monster_type *m_ptr = &target_ptr->current_floor_ptr->m_list[m_idx];
1082 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1083 monster_type exp_mon;
1085 /* Innocent until proven otherwise */
1086 bool innocent = TRUE, thief = FALSE;
1090 (void)COPY(&exp_mon, m_ptr, monster_type);
1092 expdam = (m_ptr->hp > dam) ? dam : m_ptr->hp;
1094 get_exp_from_mon(target_ptr, expdam, &exp_mon);
1096 /* Genocided by chaos patron */
1097 if (!monster_is_valid(m_ptr)) m_idx = 0;
1099 /* Redraw (later) if needed */
1100 if (target_ptr->health_who == m_idx) target_ptr->redraw |= (PR_HEALTH);
1101 if (target_ptr->riding == m_idx) target_ptr->redraw |= (PR_UHEALTH);
1103 (void)set_monster_csleep(target_ptr, m_idx, 0);
1105 /* Hack - Cancel any special player stealth magics. -LM- */
1106 if (target_ptr->special_defense & NINJA_S_STEALTH)
1108 set_superstealth(target_ptr, FALSE);
1111 /* Genocided by chaos patron */
1112 if (!m_idx) return TRUE;
1115 m_ptr->dealt_damage += dam;
1117 if (m_ptr->dealt_damage > m_ptr->max_maxhp * 100) m_ptr->dealt_damage = m_ptr->max_maxhp * 100;
1119 if (current_world_ptr->wizard)
1121 msg_format(_("合計%d/%dのダメージを与えた。", "You do %d (out of %d) damage."), m_ptr->dealt_damage, m_ptr->maxhp);
1124 /* It is dead now */
1127 GAME_TEXT m_name[MAX_NLEN];
1129 if (r_info[m_ptr->r_idx].flags7 & RF7_TANUKI)
1131 /* You might have unmasked Tanuki first time */
1132 r_ptr = &r_info[m_ptr->r_idx];
1133 m_ptr->ap_r_idx = m_ptr->r_idx;
1134 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1137 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
1139 /* You might have unmasked Chameleon first time */
1140 r_ptr = real_r_ptr(m_ptr);
1141 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1144 if (!(m_ptr->smart & SM_CLONED))
1146 /* When the player kills a Unique, it stays dead */
1147 if (r_ptr->flags1 & RF1_UNIQUE)
1151 /* Mega-Hack -- Banor & Lupart */
1152 if ((m_ptr->r_idx == MON_BANOR) || (m_ptr->r_idx == MON_LUPART))
1154 r_info[MON_BANORLUPART].max_num = 0;
1155 r_info[MON_BANORLUPART].r_pkills++;
1156 r_info[MON_BANORLUPART].r_akills++;
1157 if (r_info[MON_BANORLUPART].r_tkills < MAX_SHORT) r_info[MON_BANORLUPART].r_tkills++;
1159 else if (m_ptr->r_idx == MON_BANORLUPART)
1161 r_info[MON_BANOR].max_num = 0;
1162 r_info[MON_BANOR].r_pkills++;
1163 r_info[MON_BANOR].r_akills++;
1164 if (r_info[MON_BANOR].r_tkills < MAX_SHORT) r_info[MON_BANOR].r_tkills++;
1165 r_info[MON_LUPART].max_num = 0;
1166 r_info[MON_LUPART].r_pkills++;
1167 r_info[MON_LUPART].r_akills++;
1168 if (r_info[MON_LUPART].r_tkills < MAX_SHORT) r_info[MON_LUPART].r_tkills++;
1172 /* When the player kills a Nazgul, it stays dead */
1173 else if (r_ptr->flags7 & RF7_NAZGUL) r_ptr->max_num--;
1176 /* Count all monsters killed */
1177 if (r_ptr->r_akills < MAX_SHORT) r_ptr->r_akills++;
1179 /* Recall even invisible uniques or winners */
1180 if ((m_ptr->ml && !target_ptr->image) || (r_ptr->flags1 & RF1_UNIQUE))
1182 /* Count kills this life */
1183 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_pkills < MAX_SHORT)) r_info[MON_KAGE].r_pkills++;
1184 else if (r_ptr->r_pkills < MAX_SHORT) r_ptr->r_pkills++;
1186 /* Count kills in all lives */
1187 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_tkills < MAX_SHORT)) r_info[MON_KAGE].r_tkills++;
1188 else if (r_ptr->r_tkills < MAX_SHORT) r_ptr->r_tkills++;
1190 /* Hack -- Auto-recall */
1191 monster_race_track(target_ptr, m_ptr->ap_r_idx);
1194 monster_desc(target_ptr, m_name, m_ptr, MD_TRUE_NAME);
1196 /* Don't kill Amberites */
1197 if ((r_ptr->flags3 & RF3_AMBERITE) && one_in_(2))
1199 int curses = 1 + randint1(3);
1200 bool stop_ty = FALSE;
1203 msg_format(_("%^sは恐ろしい血の呪いをあなたにかけた!", "%^s puts a terrible blood curse on you!"), m_name);
1204 curse_equipment(target_ptr, 100, 50);
1208 stop_ty = activate_ty_curse(target_ptr, stop_ty, &count);
1212 if (r_ptr->flags2 & RF2_CAN_SPEAK)
1214 char line_got[1024];
1215 if (!get_rnd_line(_("mondeath_j.txt", "mondeath.txt"), m_ptr->r_idx, line_got))
1217 msg_format("%^s %s", m_name, line_got);
1221 if (m_ptr->r_idx == MON_SERPENT)
1223 screen_dump = make_screen_dump(target_ptr, process_autopick_file_command);
1228 if (!(d_info[target_ptr->dungeon_idx].flags1 & DF1_BEGINNER))
1230 if (!target_ptr->current_floor_ptr->dun_level && !target_ptr->ambush_flag && !target_ptr->current_floor_ptr->inside_arena)
1232 chg_virtue(target_ptr, V_VALOUR, -1);
1234 else if (r_ptr->level > target_ptr->current_floor_ptr->dun_level)
1236 if (randint1(10) <= (r_ptr->level - target_ptr->current_floor_ptr->dun_level))
1237 chg_virtue(target_ptr, V_VALOUR, 1);
1239 if (r_ptr->level > 60)
1241 chg_virtue(target_ptr, V_VALOUR, 1);
1243 if (r_ptr->level >= 2 * (target_ptr->lev + 1))
1244 chg_virtue(target_ptr, V_VALOUR, 2);
1247 if (r_ptr->flags1 & RF1_UNIQUE)
1249 if (r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)) chg_virtue(target_ptr, V_HARMONY, 2);
1251 if (r_ptr->flags3 & RF3_GOOD)
1253 chg_virtue(target_ptr, V_UNLIFE, 2);
1254 chg_virtue(target_ptr, V_VITALITY, -2);
1257 if (one_in_(3)) chg_virtue(target_ptr, V_INDIVIDUALISM, -1);
1260 if (m_ptr->r_idx == MON_BEGGAR || m_ptr->r_idx == MON_LEPER)
1262 chg_virtue(target_ptr, V_COMPASSION, -1);
1265 if ((r_ptr->flags3 & RF3_GOOD) && ((r_ptr->level) / 10 + (3 * target_ptr->current_floor_ptr->dun_level) >= randint1(100)))
1266 chg_virtue(target_ptr, V_UNLIFE, 1);
1268 if (r_ptr->d_char == 'A')
1270 if (r_ptr->flags1 & RF1_UNIQUE)
1271 chg_virtue(target_ptr, V_FAITH, -2);
1272 else if ((r_ptr->level) / 10 + (3 * target_ptr->current_floor_ptr->dun_level) >= randint1(100))
1274 if (r_ptr->flags3 & RF3_GOOD) chg_virtue(target_ptr, V_FAITH, -1);
1275 else chg_virtue(target_ptr, V_FAITH, 1);
1278 else if (r_ptr->flags3 & RF3_DEMON)
1280 if (r_ptr->flags1 & RF1_UNIQUE)
1281 chg_virtue(target_ptr, V_FAITH, 2);
1282 else if ((r_ptr->level) / 10 + (3 * target_ptr->current_floor_ptr->dun_level) >= randint1(100))
1283 chg_virtue(target_ptr, V_FAITH, 1);
1286 if ((r_ptr->flags3 & RF3_UNDEAD) && (r_ptr->flags1 & RF1_UNIQUE))
1287 chg_virtue(target_ptr, V_VITALITY, 2);
1289 if (r_ptr->r_deaths)
1291 if (r_ptr->flags1 & RF1_UNIQUE)
1293 chg_virtue(target_ptr, V_HONOUR, 10);
1295 else if ((r_ptr->level) / 10 + (2 * target_ptr->current_floor_ptr->dun_level) >= randint1(100))
1297 chg_virtue(target_ptr, V_HONOUR, 1);
1300 if ((r_ptr->flags2 & RF2_MULTIPLY) && (r_ptr->r_akills > 1000) && one_in_(10))
1302 chg_virtue(target_ptr, V_VALOUR, -1);
1305 for (i = 0; i < 4; i++)
1307 if (r_ptr->blow[i].d_dice != 0) innocent = FALSE; /* Murderer! */
1309 if ((r_ptr->blow[i].effect == RBE_EAT_ITEM)
1310 || (r_ptr->blow[i].effect == RBE_EAT_GOLD))
1312 thief = TRUE; /* Thief! */
1315 /* The new law says it is illegal to live in the dungeon */
1316 if (r_ptr->level != 0) innocent = FALSE;
1320 if (r_ptr->flags1 & RF1_UNIQUE)
1321 chg_virtue(target_ptr, V_JUSTICE, 3);
1322 else if (1 + ((r_ptr->level) / 10 + (2 * target_ptr->current_floor_ptr->dun_level)) >= randint1(100))
1323 chg_virtue(target_ptr, V_JUSTICE, 1);
1327 chg_virtue(target_ptr, V_JUSTICE, -1);
1330 if ((r_ptr->flags3 & RF3_ANIMAL) && !(r_ptr->flags3 & RF3_EVIL) && !(r_ptr->flags4 & ~(RF4_NOMAGIC_MASK)) && !(r_ptr->a_ability_flags1 & ~(RF5_NOMAGIC_MASK)) && !(r_ptr->a_ability_flags2 & ~(RF6_NOMAGIC_MASK)))
1332 if (one_in_(4)) chg_virtue(target_ptr, V_NATURE, -1);
1335 if ((r_ptr->flags1 & RF1_UNIQUE) && record_destroy_uniq)
1338 sprintf(note_buf, "%s%s", r_name + r_ptr->name, (m_ptr->smart & SM_CLONED) ? _("(クローン)", "(Clone)") : "");
1339 exe_write_diary(target_ptr, DIARY_UNIQUE, 0, note_buf);
1345 /* Death by Missile/Spell attack */
1348 msg_format("%^s%s", m_name, note);
1351 /* Death by physical attack -- invisible monster */
1352 else if (!m_ptr->ml)
1355 if (is_echizen(target_ptr))
1356 msg_format("せっかくだから%sを殺した。", m_name);
1358 msg_format("%sを殺した。", m_name);
1360 msg_format("You have killed %s.", m_name);
1365 /* Death by Physical attack -- non-living monster */
1366 else if (!monster_living(m_ptr->r_idx))
1368 bool explode = FALSE;
1370 for (i = 0; i < 4; i++)
1372 if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
1375 /* Special note at death */
1377 msg_format(_("%sは爆発して粉々になった。", "%^s explodes into tiny shreds."), m_name);
1381 if (is_echizen(target_ptr))
1382 msg_format("せっかくだから%sを倒した。", m_name);
1384 msg_format("%sを倒した。", m_name);
1386 msg_format("You have destroyed %s.", m_name);
1391 /* Death by Physical attack -- living monster */
1395 if (is_echizen(target_ptr))
1396 msg_format("せっかくだから%sを葬り去った。", m_name);
1398 msg_format("%sを葬り去った。", m_name);
1400 msg_format("You have slain %s.", m_name);
1404 if ((r_ptr->flags1 & RF1_UNIQUE) && !(m_ptr->smart & SM_CLONED) && !vanilla_town)
1406 for (i = 0; i < MAX_BOUNTY; i++)
1408 if ((current_world_ptr->bounty_r_idx[i] == m_ptr->r_idx) && !(m_ptr->mflag2 & MFLAG2_CHAMELEON))
1410 msg_format(_("%sの首には賞金がかかっている。", "There is a price on %s's head."), m_name);
1416 /* Generate treasure */
1417 monster_death(target_ptr, m_idx, TRUE);
1419 /* Mega hack : replace IKETA to BIKETAL */
1420 if ((m_ptr->r_idx == MON_IKETA) && !(target_ptr->current_floor_ptr->inside_arena || target_ptr->phase_out))
1422 POSITION dummy_y = m_ptr->fy;
1423 POSITION dummy_x = m_ptr->fx;
1424 BIT_FLAGS mode = 0L;
1425 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
1426 delete_monster_idx(target_ptr, m_idx);
1427 if (summon_named_creature(target_ptr, 0, dummy_y, dummy_x, MON_BIKETAL, mode))
1429 msg_print(_("「ハァッハッハッハ!!私がバイケタルだ!!」", "Uwa-hahaha! *I* am Biketal!"));
1434 delete_monster_idx(target_ptr, m_idx);
1437 get_exp_from_mon(target_ptr, (long)exp_mon.max_maxhp * 2, &exp_mon);
1442 /* Monster is dead */
1446 /* Mega-Hack -- Pain cancels fear */
1447 if (monster_fear_remaining(m_ptr) && (dam > 0))
1450 if (set_monster_monfear(target_ptr, m_idx, monster_fear_remaining(m_ptr) - randint1(dam)))
1457 /* Sometimes a monster gets scared by damage */
1458 if (!monster_fear_remaining(m_ptr) && !(r_ptr->flags3 & (RF3_NO_FEAR)))
1460 /* Percentage of fully healthy */
1461 int percentage = (100L * m_ptr->hp) / m_ptr->maxhp;
1464 * Run (sometimes) if at 10% or less of max hit points,
1465 * or (usually) when hit for half its current hit points
1467 if ((randint1(10) >= percentage) || ((dam >= m_ptr->hp) && (randint0(100) < 80)))
1469 /* Hack -- note fear */
1472 /* Hack -- Add some timed fear */
1473 (void)set_monster_monfear(target_ptr, m_idx, (randint1(10) +
1474 (((dam >= m_ptr->hp) && (percentage > 7)) ?
1475 20 : ((11 - percentage) * 5))));
1484 bool monster_is_valid(monster_type *m_ptr)
1486 return (m_ptr->r_idx != 0);
1489 TIME_EFFECT monster_csleep_remaining(monster_type *m_ptr) { return m_ptr->mtimed[MTIMED_CSLEEP]; }
1491 TIME_EFFECT monster_fast_remaining(monster_type *m_ptr) { return m_ptr->mtimed[MTIMED_FAST]; }
1493 TIME_EFFECT monster_slow_remaining(monster_type *m_ptr) { return m_ptr->mtimed[MTIMED_SLOW]; }
1495 TIME_EFFECT monster_stunned_remaining(monster_type* m_ptr) { return m_ptr->mtimed[MTIMED_STUNNED]; }
1497 TIME_EFFECT monster_confused_remaining(monster_type *m_ptr) { return m_ptr->mtimed[MTIMED_CONFUSED]; }
1499 TIME_EFFECT monster_fear_remaining(monster_type *m_ptr) { return m_ptr->mtimed[MTIMED_MONFEAR]; }
1501 TIME_EFFECT monster_invulner_remaining(monster_type *m_ptr) { return m_ptr->mtimed[MTIMED_INVULNER]; }