OSDN Git Service

[Refactor] #37353 CAVE_* をgrid.hへ移動。
[hengband/hengband.git] / src / monster-status.c
1 #include "angband.h"
2 #include "floor.h"
3 #include "grid.h"
4 #include "monster.h"
5 #include "monster-status.h"
6 #include "monster-spell.h"
7 #include "spells-summon.h"
8 #include "monsterrace-hook.h"
9 #include "object-curse.h"
10 #include "artifact.h"
11 #include "avatar.h"
12
13
14
15 /*!
16  * @brief モンスターに与えたダメージの修正処理 /
17  * Modify the physical damage done to the monster.
18  * @param m_ptr ダメージを受けるモンスターの構造体参照ポインタ
19  * @param dam ダメージ基本値
20  * @param is_psy_spear 攻撃手段が光の剣ならばTRUE
21  * @return 修正を行った結果のダメージ量
22  * @details
23  * <pre>
24  * (for example when it's invulnerable or shielded)
25  * ToDo: Accept a damage-type to calculate the modified damage from
26  * things like fire, frost, lightning, poison, ... attacks.
27  * "type" is not yet used and should be 0.
28  * </pre>
29  */
30 HIT_POINT mon_damage_mod(monster_type *m_ptr, HIT_POINT dam, bool is_psy_spear)
31 {
32         monster_race *r_ptr = &r_info[m_ptr->r_idx];
33
34         if ((r_ptr->flagsr & RFR_RES_ALL) && dam > 0)
35         {
36                 dam /= 100;
37                 if ((dam == 0) && one_in_(3)) dam = 1;
38         }
39
40         if (MON_INVULNER(m_ptr))
41         {
42                 if (is_psy_spear)
43                 {
44                         if (!p_ptr->blind && is_seen(m_ptr))
45                         {
46                                 msg_print(_("バリアを切り裂いた!", "The barrier is penetrated!"));
47                         }
48                 }
49                 else if (!one_in_(PENETRATE_INVULNERABILITY))
50                 {
51                         return (0);
52                 }
53         }
54         return (dam);
55 }
56
57
58
59 /*!
60  * @brief モンスターに与えたダメージを元に経験値を加算する /
61  * Calculate experience point to be get
62  * @param dam 与えたダメージ量
63  * @param m_ptr ダメージを与えたモンスターの構造体参照ポインタ
64  * @return なし
65  * @details
66  * <pre>
67  * Even the 64 bit operation is not big enough to avoid overflaw
68  * unless we carefully choose orders of multiplication and division.
69  * Get the coefficient first, and multiply (potentially huge) base
70  * experience point of a monster later.
71  * </pre>
72  */
73 static void get_exp_from_mon(HIT_POINT dam, monster_type *m_ptr)
74 {
75         monster_race *r_ptr = &r_info[m_ptr->r_idx];
76
77         s32b new_exp;
78         u32b new_exp_frac;
79         s32b div_h;
80         u32b div_l;
81
82         if (!monster_is_valid(m_ptr)) return;
83         if (is_pet(m_ptr) || p_ptr->inside_battle) return;
84
85         /*
86          * - Ratio of monster's level to player's level effects
87          * - Varying speed effects
88          * - Get a fraction in proportion of damage point
89          */
90         new_exp = r_ptr->level * SPEED_TO_ENERGY(m_ptr->mspeed) * dam;
91         new_exp_frac = 0;
92         div_h = 0L;
93         div_l = (p_ptr->max_plv + 2) * SPEED_TO_ENERGY(r_ptr->speed);
94
95         /* Use (average maxhp * 2) as a denominator */
96         if (!(r_ptr->flags1 & RF1_FORCE_MAXHP))
97                 s64b_mul(&div_h, &div_l, 0, r_ptr->hdice * (ironman_nightmare ? 2 : 1) * (r_ptr->hside + 1));
98         else
99                 s64b_mul(&div_h, &div_l, 0, r_ptr->hdice * (ironman_nightmare ? 2 : 1) * r_ptr->hside * 2);
100
101         /* Special penalty in the wilderness */
102         if (!current_floor_ptr->dun_level && (!(r_ptr->flags8 & RF8_WILD_ONLY) || !(r_ptr->flags1 & RF1_UNIQUE)))
103                 s64b_mul(&div_h, &div_l, 0, 5);
104
105         /* Do division first to prevent overflaw */
106         s64b_div(&new_exp, &new_exp_frac, div_h, div_l);
107
108         /* Special penalty for mutiply-monster */
109         if ((r_ptr->flags2 & RF2_MULTIPLY) || (m_ptr->r_idx == MON_DAWN))
110         {
111                 int monnum_penarty = r_ptr->r_akills / 400;
112                 if (monnum_penarty > 8) monnum_penarty = 8;
113
114                 while (monnum_penarty--)
115                 {
116                         /* Divide by 4 */
117                         s64b_RSHIFT(new_exp, new_exp_frac, 2);
118                 }
119         }
120
121         /* Special penalty for rest_and_shoot exp scum */
122         if ((m_ptr->dealt_damage > m_ptr->max_maxhp) && (m_ptr->hp >= 0))
123         {
124                 int over_damage = m_ptr->dealt_damage / m_ptr->max_maxhp;
125                 if (over_damage > 32) over_damage = 32;
126
127                 while (over_damage--)
128                 {
129                         /* 9/10 for once */
130                         s64b_mul(&new_exp, &new_exp_frac, 0, 9);
131                         s64b_div(&new_exp, &new_exp_frac, 0, 10);
132                 }
133         }
134
135         /* Finally multiply base experience point of the monster */
136         s64b_mul(&new_exp, &new_exp_frac, 0, r_ptr->mexp);
137
138         /* Gain experience */
139         gain_exp_64(new_exp, new_exp_frac);
140 }
141
142
143
144 /*!
145 * @brief モンスターの時限ステータスを取得する
146 * @return m_idx モンスターの参照ID
147 * @return mproc_type モンスターの時限ステータスID
148 * @return 残りターン値
149 */
150 int get_mproc_idx(MONSTER_IDX m_idx, int mproc_type)
151 {
152         s16b *cur_mproc_list = current_floor_ptr->mproc_list[mproc_type];
153         int i;
154
155         for (i = current_floor_ptr->mproc_max[mproc_type] - 1; i >= 0; i--)
156         {
157                 if (cur_mproc_list[i] == m_idx) return i;
158         }
159
160         return -1;
161 }
162
163 /*!
164 * @brief モンスターの時限ステータスリストを追加する
165 * @return m_idx モンスターの参照ID
166 * @return mproc_type 追加したいモンスターの時限ステータスID
167 * @return なし
168 */
169 static void mproc_add(MONSTER_IDX m_idx, int mproc_type)
170 {
171         if (current_floor_ptr->mproc_max[mproc_type] < current_floor_ptr->max_m_idx) current_floor_ptr->mproc_list[mproc_type][current_floor_ptr->mproc_max[mproc_type]++] = (s16b)m_idx;
172 }
173
174
175 /*!
176 * @brief モンスターの時限ステータスリストを削除
177 * @return m_idx モンスターの参照ID
178 * @return mproc_type 削除したいモンスターの時限ステータスID
179 * @return なし
180 */
181 static void mproc_remove(MONSTER_IDX m_idx, int mproc_type)
182 {
183         int mproc_idx = get_mproc_idx(m_idx, mproc_type);
184         if (mproc_idx >= 0) current_floor_ptr->mproc_list[mproc_type][mproc_idx] = current_floor_ptr->mproc_list[mproc_type][--current_floor_ptr->mproc_max[mproc_type]];
185 }
186
187
188 /*!
189 * @brief モンスターの時限ステータスリストを初期化する / Initialize monster process
190 * @return なし
191 */
192 void mproc_init(void)
193 {
194         monster_type *m_ptr;
195         MONSTER_IDX i;
196         int cmi;
197
198         /* Reset "current_floor_ptr->mproc_max[]" */
199         for (cmi = 0; cmi < MAX_MTIMED; cmi++) current_floor_ptr->mproc_max[cmi] = 0;
200
201         /* Process the monsters (backwards) */
202         for (i = m_max - 1; i >= 1; i--)
203         {
204                 /* Access the monster */
205                 m_ptr = &current_floor_ptr->m_list[i];
206
207                 /* Ignore "dead" monsters */
208                 if (!monster_is_valid(m_ptr)) continue;
209
210                 for (cmi = 0; cmi < MAX_MTIMED; cmi++)
211                 {
212                         if (m_ptr->mtimed[cmi]) mproc_add(i, cmi);
213                 }
214         }
215 }
216
217
218 /*!
219 * @brief モンスターの睡眠状態値をセットする。0で起きる。 /
220 * Set "m_ptr->mtimed[MTIMED_CSLEEP]", notice observable changes
221 * @param m_idx モンスター参照ID
222 * @param v セットする値
223 * @return 別途更新処理が必要な場合TRUEを返す
224 */
225 bool set_monster_csleep(MONSTER_IDX m_idx, int v)
226 {
227         monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
228         bool notice = FALSE;
229         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
230
231         /* Open */
232         if (v)
233         {
234                 if (!MON_CSLEEP(m_ptr))
235                 {
236                         mproc_add(m_idx, MTIMED_CSLEEP);
237                         notice = TRUE;
238                 }
239         }
240
241         /* Shut */
242         else
243         {
244                 if (MON_CSLEEP(m_ptr))
245                 {
246                         mproc_remove(m_idx, MTIMED_CSLEEP);
247                         notice = TRUE;
248                 }
249         }
250
251         /* Use the value */
252         m_ptr->mtimed[MTIMED_CSLEEP] = (s16b)v;
253
254         if (!notice) return FALSE;
255
256         if (m_ptr->ml)
257         {
258                 /* Update health bar as needed */
259                 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
260                 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
261         }
262
263         if (r_info[m_ptr->r_idx].flags7 & RF7_HAS_LD_MASK) p_ptr->update |= (PU_MON_LITE);
264
265         return TRUE;
266 }
267
268
269 /*!
270 * @brief モンスターの加速状態値をセット /
271 * Set "m_ptr->mtimed[MTIMED_FAST]", notice observable changes
272 * @param m_idx モンスター参照ID
273 * @param v セットする値
274 * @return 別途更新処理が必要な場合TRUEを返す
275 */
276 bool set_monster_fast(MONSTER_IDX m_idx, int v)
277 {
278         monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
279         bool notice = FALSE;
280         v = (v > 200) ? 200 : (v < 0) ? 0 : v;
281
282         /* Open */
283         if (v)
284         {
285                 if (!MON_FAST(m_ptr))
286                 {
287                         mproc_add(m_idx, MTIMED_FAST);
288                         notice = TRUE;
289                 }
290         }
291
292         /* Shut */
293         else
294         {
295                 if (MON_FAST(m_ptr))
296                 {
297                         mproc_remove(m_idx, MTIMED_FAST);
298                         notice = TRUE;
299                 }
300         }
301
302         /* Use the value */
303         m_ptr->mtimed[MTIMED_FAST] = (s16b)v;
304
305         if (!notice) return FALSE;
306
307         if ((p_ptr->riding == m_idx) && !p_ptr->leaving) p_ptr->update |= (PU_BONUS);
308
309         return TRUE;
310 }
311
312
313 /*
314 * Set "m_ptr->mtimed[MTIMED_SLOW]", notice observable changes
315 */
316 bool set_monster_slow(MONSTER_IDX m_idx, int v)
317 {
318         monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
319         bool notice = FALSE;
320         v = (v > 200) ? 200 : (v < 0) ? 0 : v;
321
322         /* Open */
323         if (v)
324         {
325                 if (!MON_SLOW(m_ptr))
326                 {
327                         mproc_add(m_idx, MTIMED_SLOW);
328                         notice = TRUE;
329                 }
330         }
331
332         /* Shut */
333         else
334         {
335                 if (MON_SLOW(m_ptr))
336                 {
337                         mproc_remove(m_idx, MTIMED_SLOW);
338                         notice = TRUE;
339                 }
340         }
341
342         /* Use the value */
343         m_ptr->mtimed[MTIMED_SLOW] = (s16b)v;
344
345         if (!notice) return FALSE;
346
347         if ((p_ptr->riding == m_idx) && !p_ptr->leaving) p_ptr->update |= (PU_BONUS);
348
349         return TRUE;
350 }
351
352
353 /*!
354 * @brief モンスターの朦朧状態値をセット /
355 * Set "m_ptr->mtimed[MTIMED_STUNNED]", notice observable changes
356 * @param m_idx モンスター参照ID
357 * @param v セットする値
358 * @return 別途更新処理が必要な場合TRUEを返す
359 */
360 bool set_monster_stunned(MONSTER_IDX m_idx, int v)
361 {
362         monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
363         bool notice = FALSE;
364         v = (v > 200) ? 200 : (v < 0) ? 0 : v;
365
366         /* Open */
367         if (v)
368         {
369                 if (!MON_STUNNED(m_ptr))
370                 {
371                         mproc_add(m_idx, MTIMED_STUNNED);
372                         notice = TRUE;
373                 }
374         }
375
376         /* Shut */
377         else
378         {
379                 if (MON_STUNNED(m_ptr))
380                 {
381                         mproc_remove(m_idx, MTIMED_STUNNED);
382                         notice = TRUE;
383                 }
384         }
385
386         /* Use the value */
387         m_ptr->mtimed[MTIMED_STUNNED] = (s16b)v;
388
389         return notice;
390 }
391
392
393 /*!
394 * @brief モンスターの混乱状態値をセット /
395 * Set "m_ptr->mtimed[MTIMED_CONFUSED]", notice observable changes
396 * @param m_idx モンスター参照ID
397 * @param v セットする値
398 * @return 別途更新処理が必要な場合TRUEを返す
399 */
400 bool set_monster_confused(MONSTER_IDX m_idx, int v)
401 {
402         monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
403         bool notice = FALSE;
404         v = (v > 200) ? 200 : (v < 0) ? 0 : v;
405
406         /* Open */
407         if (v)
408         {
409                 if (!MON_CONFUSED(m_ptr))
410                 {
411                         mproc_add(m_idx, MTIMED_CONFUSED);
412                         notice = TRUE;
413                 }
414         }
415
416         /* Shut */
417         else
418         {
419                 if (MON_CONFUSED(m_ptr))
420                 {
421                         mproc_remove(m_idx, MTIMED_CONFUSED);
422                         notice = TRUE;
423                 }
424         }
425
426         /* Use the value */
427         m_ptr->mtimed[MTIMED_CONFUSED] = (s16b)v;
428
429         return notice;
430 }
431
432
433 /*!
434 * @brief モンスターの恐慌状態値をセット /
435 * Set "m_ptr->mtimed[MTIMED_MONFEAR]", notice observable changes
436 * @param m_idx モンスター参照ID
437 * @param v セットする値
438 * @return 別途更新処理が必要な場合TRUEを返す
439 */
440 bool set_monster_monfear(MONSTER_IDX m_idx, int v)
441 {
442         monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
443         bool notice = FALSE;
444         v = (v > 200) ? 200 : (v < 0) ? 0 : v;
445
446         /* Open */
447         if (v)
448         {
449                 if (!MON_MONFEAR(m_ptr))
450                 {
451                         mproc_add(m_idx, MTIMED_MONFEAR);
452                         notice = TRUE;
453                 }
454         }
455
456         /* Shut */
457         else
458         {
459                 if (MON_MONFEAR(m_ptr))
460                 {
461                         mproc_remove(m_idx, MTIMED_MONFEAR);
462                         notice = TRUE;
463                 }
464         }
465
466         /* Use the value */
467         m_ptr->mtimed[MTIMED_MONFEAR] = (s16b)v;
468
469         if (!notice) return FALSE;
470
471         if (m_ptr->ml)
472         {
473                 /* Update health bar as needed */
474                 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
475                 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
476         }
477
478         return TRUE;
479 }
480
481
482 /*!
483 * @brief モンスターの無敵状態値をセット /
484 * Set "m_ptr->mtimed[MTIMED_INVULNER]", notice observable changes
485 * @param m_idx モンスター参照ID
486 * @param v セットする値
487 * @param energy_need TRUEならば無敵解除時に行動ターン消費を行う
488 * @return 別途更新処理が必要な場合TRUEを返す
489 */
490 bool set_monster_invulner(MONSTER_IDX m_idx, int v, bool energy_need)
491 {
492         monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
493         bool notice = FALSE;
494         v = (v > 200) ? 200 : (v < 0) ? 0 : v;
495
496         /* Open */
497         if (v)
498         {
499                 if (!MON_INVULNER(m_ptr))
500                 {
501                         mproc_add(m_idx, MTIMED_INVULNER);
502                         notice = TRUE;
503                 }
504         }
505
506         /* Shut */
507         else
508         {
509                 if (MON_INVULNER(m_ptr))
510                 {
511                         mproc_remove(m_idx, MTIMED_INVULNER);
512                         if (energy_need && !p_ptr->wild_mode) m_ptr->energy_need += ENERGY_NEED();
513                         notice = TRUE;
514                 }
515         }
516
517         /* Use the value */
518         m_ptr->mtimed[MTIMED_INVULNER] = (s16b)v;
519
520         if (!notice) return FALSE;
521
522         if (m_ptr->ml)
523         {
524                 /* Update health bar as needed */
525                 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
526                 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
527         }
528
529         return TRUE;
530 }
531
532
533 static u32b csleep_noise;
534
535 /*!
536 * @brief モンスターの各種状態値を時間経過により更新するサブルーチン
537 * @param m_idx モンスター参照ID
538 * @param mtimed_idx 更新するモンスターの時限ステータスID
539 * @return なし
540 */
541 static void process_monsters_mtimed_aux(MONSTER_IDX m_idx, int mtimed_idx)
542 {
543         monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
544
545         switch (mtimed_idx)
546         {
547         case MTIMED_CSLEEP:
548         {
549                 monster_race *r_ptr = &r_info[m_ptr->r_idx];
550
551                 /* Assume does not wake up */
552                 bool test = FALSE;
553
554                 /* Hack -- Require proximity */
555                 if (m_ptr->cdis < AAF_LIMIT)
556                 {
557                         /* Handle "sensing radius" */
558                         if (m_ptr->cdis <= (is_pet(m_ptr) ? ((r_ptr->aaf > MAX_SIGHT) ? MAX_SIGHT : r_ptr->aaf) : r_ptr->aaf))
559                         {
560                                 /* We may wake up */
561                                 test = TRUE;
562                         }
563
564                         /* Handle "sight" and "aggravation" */
565                         else if ((m_ptr->cdis <= MAX_SIGHT) && (player_has_los_bold(m_ptr->fy, m_ptr->fx)))
566                         {
567                                 /* We may wake up */
568                                 test = TRUE;
569                         }
570                 }
571
572                 if (test)
573                 {
574                         u32b notice = randint0(1024);
575
576                         /* Nightmare monsters are more alert */
577                         if (ironman_nightmare) notice /= 2;
578
579                         /* Hack -- See if monster "notices" player */
580                         if ((notice * notice * notice) <= csleep_noise)
581                         {
582                                 /* Hack -- amount of "waking" */
583                                 /* Wake up faster near the player */
584                                 int d = (m_ptr->cdis < AAF_LIMIT / 2) ? (AAF_LIMIT / m_ptr->cdis) : 1;
585
586                                 /* Hack -- amount of "waking" is affected by speed of player */
587                                 d = (d * SPEED_TO_ENERGY(p_ptr->pspeed)) / 10;
588                                 if (d < 0) d = 1;
589
590                                 /* Monster wakes up "a little bit" */
591
592                                 /* Still asleep */
593                                 if (!set_monster_csleep(m_idx, MON_CSLEEP(m_ptr) - d))
594                                 {
595                                         /* Notice the "not waking up" */
596                                         if (is_original_ap_and_seen(m_ptr))
597                                         {
598                                                 /* Hack -- Count the ignores */
599                                                 if (r_ptr->r_ignore < MAX_UCHAR) r_ptr->r_ignore++;
600                                         }
601                                 }
602
603                                 /* Just woke up */
604                                 else
605                                 {
606                                         /* Notice the "waking up" */
607                                         if (m_ptr->ml)
608                                         {
609                                                 GAME_TEXT m_name[MAX_NLEN];
610                                                 monster_desc(m_name, m_ptr, 0);
611                                                 msg_format(_("%^sが目を覚ました。", "%^s wakes up."), m_name);
612                                         }
613
614                                         if (is_original_ap_and_seen(m_ptr))
615                                         {
616                                                 /* Hack -- Count the wakings */
617                                                 if (r_ptr->r_wake < MAX_UCHAR) r_ptr->r_wake++;
618                                         }
619                                 }
620                         }
621                 }
622                 break;
623         }
624
625         case MTIMED_FAST:
626                 /* Reduce by one, note if expires */
627                 if (set_monster_fast(m_idx, MON_FAST(m_ptr) - 1))
628                 {
629                         if (is_seen(m_ptr))
630                         {
631                                 GAME_TEXT m_name[MAX_NLEN];
632                                 monster_desc(m_name, m_ptr, 0);
633                                 msg_format(_("%^sはもう加速されていない。", "%^s is no longer fast."), m_name);
634                         }
635                 }
636                 break;
637
638         case MTIMED_SLOW:
639                 /* Reduce by one, note if expires */
640                 if (set_monster_slow(m_idx, MON_SLOW(m_ptr) - 1))
641                 {
642                         if (is_seen(m_ptr))
643                         {
644                                 GAME_TEXT m_name[MAX_NLEN];
645                                 monster_desc(m_name, m_ptr, 0);
646                                 msg_format(_("%^sはもう減速されていない。", "%^s is no longer slow."), m_name);
647                         }
648                 }
649                 break;
650
651         case MTIMED_STUNNED:
652         {
653                 int rlev = r_info[m_ptr->r_idx].level;
654
655                 /* Recover from stun */
656                 if (set_monster_stunned(m_idx, (randint0(10000) <= rlev * rlev) ? 0 : (MON_STUNNED(m_ptr) - 1)))
657                 {
658                         /* Message if visible */
659                         if (is_seen(m_ptr))
660                         {
661                                 GAME_TEXT m_name[MAX_NLEN];
662                                 monster_desc(m_name, m_ptr, 0);
663                                 msg_format(_("%^sは朦朧状態から立ち直った。", "%^s is no longer stunned."), m_name);
664                         }
665                 }
666                 break;
667         }
668
669         case MTIMED_CONFUSED:
670                 /* Reduce the confusion */
671                 if (set_monster_confused(m_idx, MON_CONFUSED(m_ptr) - randint1(r_info[m_ptr->r_idx].level / 20 + 1)))
672                 {
673                         /* Message if visible */
674                         if (is_seen(m_ptr))
675                         {
676                                 GAME_TEXT m_name[MAX_NLEN];
677                                 monster_desc(m_name, m_ptr, 0);
678                                 msg_format(_("%^sは混乱から立ち直った。", "%^s is no longer confused."), m_name);
679                         }
680                 }
681                 break;
682
683         case MTIMED_MONFEAR:
684                 /* Reduce the fear */
685                 if (set_monster_monfear(m_idx, MON_MONFEAR(m_ptr) - randint1(r_info[m_ptr->r_idx].level / 20 + 1)))
686                 {
687                         /* Visual note */
688                         if (is_seen(m_ptr))
689                         {
690                                 GAME_TEXT m_name[MAX_NLEN];
691 #ifndef JP
692                                 char m_poss[80];
693
694                                 /* Acquire the monster possessive */
695                                 monster_desc(m_poss, m_ptr, MD_PRON_VISIBLE | MD_POSSESSIVE);
696 #endif
697                                 monster_desc(m_name, m_ptr, 0);
698 #ifdef JP
699                                 msg_format("%^sは勇気を取り戻した。", m_name);
700 #else
701                                 msg_format("%^s recovers %s courage.", m_name, m_poss);
702 #endif
703                         }
704                 }
705                 break;
706
707         case MTIMED_INVULNER:
708                 /* Reduce by one, note if expires */
709                 if (set_monster_invulner(m_idx, MON_INVULNER(m_ptr) - 1, TRUE))
710                 {
711                         if (is_seen(m_ptr))
712                         {
713                                 GAME_TEXT m_name[MAX_NLEN];
714                                 monster_desc(m_name, m_ptr, 0);
715                                 msg_format(_("%^sはもう無敵でない。", "%^s is no longer invulnerable."), m_name);
716                         }
717                 }
718                 break;
719         }
720 }
721
722
723 /*!
724 * @brief 全モンスターの各種状態値を時間経過により更新するメインルーチン
725 * @param mtimed_idx 更新するモンスターの時限ステータスID
726 * @return なし
727 * @details
728 * Process the counters of monsters (once per 10 game turns)\n
729 * These functions are to process monsters' counters same as player's.
730 */
731 void process_monsters_mtimed(int mtimed_idx)
732 {
733         int  i;
734         s16b *cur_mproc_list = current_floor_ptr->mproc_list[mtimed_idx];
735
736         /* Hack -- calculate the "player noise" */
737         if (mtimed_idx == MTIMED_CSLEEP) csleep_noise = (1L << (30 - p_ptr->skill_stl));
738
739         /* Process the monsters (backwards) */
740         for (i = current_floor_ptr->mproc_max[mtimed_idx] - 1; i >= 0; i--)
741         {
742                 /* Access the monster */
743                 process_monsters_mtimed_aux(cur_mproc_list[i], mtimed_idx);
744         }
745 }
746
747 /*!
748 * @brief モンスターへの魔力消去処理
749 * @param m_idx 魔力消去を受けるモンスターの参照ID
750 * @return なし
751 */
752 void dispel_monster_status(MONSTER_IDX m_idx)
753 {
754         monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
755         GAME_TEXT m_name[MAX_NLEN];
756
757         monster_desc(m_name, m_ptr, 0);
758         if (set_monster_invulner(m_idx, 0, TRUE))
759         {
760                 if (m_ptr->ml) msg_format(_("%sはもう無敵ではない。", "%^s is no longer invulnerable."), m_name);
761         }
762         if (set_monster_fast(m_idx, 0))
763         {
764                 if (m_ptr->ml) msg_format(_("%sはもう加速されていない。", "%^s is no longer fast."), m_name);
765         }
766         if (set_monster_slow(m_idx, 0))
767         {
768                 if (m_ptr->ml) msg_format(_("%sはもう減速されていない。", "%^s is no longer slow."), m_name);
769         }
770 }
771
772 /*!
773 * @brief モンスターの時間停止処理
774 * @param num 時間停止を行った敵が行動できる回数
775 * @param who 時間停止処理の主体ID
776 * @param vs_player TRUEならば時間停止開始処理を行う
777 * @return 時間停止が行われている状態ならばTRUEを返す
778 */
779 bool process_the_world(int num, MONSTER_IDX who, bool vs_player)
780 {
781         monster_type *m_ptr = &current_floor_ptr->m_list[hack_m_idx];  /* the world monster */
782
783         if (current_world_ptr->timewalk_m_idx) return (FALSE);
784
785         if (vs_player)
786         {
787                 GAME_TEXT m_name[MAX_NLEN];
788                 monster_desc(m_name, m_ptr, 0);
789
790                 if (who == 1)
791                         msg_format(_("「『ザ・ワールド』!時は止まった!」", "%s yells 'The World! Time has stopped!'"), m_name);
792                 else if (who == 3)
793                         msg_format(_("「時よ!」", "%s yells 'Time!'"), m_name);
794                 else msg_print("hek!");
795
796                 msg_print(NULL);
797         }
798
799         /* This monster cast spells */
800         current_world_ptr->timewalk_m_idx = hack_m_idx;
801
802         if (vs_player) do_cmd_redraw();
803
804         while (num--)
805         {
806                 if (!monster_is_valid(m_ptr)) break;
807                 process_monster(current_world_ptr->timewalk_m_idx);
808                 reset_target(m_ptr);
809                 handle_stuff();
810
811                 if (vs_player) Term_xtra(TERM_XTRA_DELAY, 500);
812         }
813
814         p_ptr->redraw |= (PR_MAP);
815         p_ptr->update |= (PU_MONSTERS);
816         p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
817
818         current_world_ptr->timewalk_m_idx = 0;
819         if (vs_player || (player_has_los_bold(m_ptr->fy, m_ptr->fx) && projectable(p_ptr->y, p_ptr->x, m_ptr->fy, m_ptr->fx)))
820         {
821                 msg_print(_("「時は動きだす…」", "You feel time flowing around you once more."));
822                 msg_print(NULL);
823         }
824
825         handle_stuff();
826         return (TRUE);
827 }
828
829 /*!
830 * @brief モンスターの経験値取得処理
831 * @param m_idx 経験値を得るモンスターの参照ID
832 * @param s_idx 撃破されたモンスター種族の参照ID
833 * @return なし
834 */
835 void monster_gain_exp(MONSTER_IDX m_idx, MONRACE_IDX s_idx)
836 {
837         monster_type *m_ptr;
838         monster_race *r_ptr;
839         monster_race *s_ptr;
840         int new_exp;
841         if (m_idx <= 0 || s_idx <= 0) return;
842
843         m_ptr = &current_floor_ptr->m_list[m_idx];
844
845         if (!monster_is_valid(m_ptr)) return;
846
847         r_ptr = &r_info[m_ptr->r_idx];
848         s_ptr = &r_info[s_idx];
849
850         if (p_ptr->inside_battle) return;
851
852         if (!r_ptr->next_exp) return;
853
854         new_exp = s_ptr->mexp * s_ptr->level / (r_ptr->level + 2);
855         if (m_idx == p_ptr->riding) new_exp = (new_exp + 1) / 2;
856         if (!current_floor_ptr->dun_level) new_exp /= 5;
857         m_ptr->exp += new_exp;
858         if (m_ptr->mflag2 & MFLAG2_CHAMELEON) return;
859
860         if (m_ptr->exp >= r_ptr->next_exp)
861         {
862                 GAME_TEXT m_name[MAX_NLEN];
863                 int old_hp = m_ptr->hp;
864                 int old_maxhp = m_ptr->max_maxhp;
865                 int old_r_idx = m_ptr->r_idx;
866                 byte old_sub_align = m_ptr->sub_align;
867
868                 /* Hack -- Reduce the racial counter of previous monster */
869                 real_r_ptr(m_ptr)->cur_num--;
870
871                 monster_desc(m_name, m_ptr, 0);
872                 m_ptr->r_idx = r_ptr->next_r_idx;
873
874                 /* Count the monsters on the level */
875                 real_r_ptr(m_ptr)->cur_num++;
876
877                 m_ptr->ap_r_idx = m_ptr->r_idx;
878                 r_ptr = &r_info[m_ptr->r_idx];
879
880                 if (r_ptr->flags1 & RF1_FORCE_MAXHP)
881                 {
882                         m_ptr->max_maxhp = maxroll(r_ptr->hdice, r_ptr->hside);
883                 }
884                 else
885                 {
886                         m_ptr->max_maxhp = damroll(r_ptr->hdice, r_ptr->hside);
887                 }
888                 if (ironman_nightmare)
889                 {
890                         HIT_POINT hp = m_ptr->max_maxhp * 2L;
891                         m_ptr->max_maxhp = MIN(30000, hp);
892                 }
893                 m_ptr->maxhp = m_ptr->max_maxhp;
894                 m_ptr->hp = old_hp * m_ptr->maxhp / old_maxhp;
895
896                 /* dealt damage is 0 at initial*/
897                 m_ptr->dealt_damage = 0;
898
899                 /* Extract the monster base speed */
900                 m_ptr->mspeed = get_mspeed(r_ptr);
901
902                 /* Sub-alignment of a monster */
903                 if (!is_pet(m_ptr) && !(r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)))
904                         m_ptr->sub_align = old_sub_align;
905                 else
906                 {
907                         m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
908                         if (r_ptr->flags3 & RF3_EVIL) m_ptr->sub_align |= SUB_ALIGN_EVIL;
909                         if (r_ptr->flags3 & RF3_GOOD) m_ptr->sub_align |= SUB_ALIGN_GOOD;
910                 }
911
912                 m_ptr->exp = 0;
913
914                 if (is_pet(m_ptr) || m_ptr->ml)
915                 {
916                         if (!ignore_unview || player_can_see_bold(m_ptr->fy, m_ptr->fx))
917                         {
918                                 if (p_ptr->image)
919                                 {
920                                         monster_race *hallu_race;
921
922                                         do
923                                         {
924                                                 hallu_race = &r_info[randint1(max_r_idx - 1)];
925                                         } while (!hallu_race->name || (hallu_race->flags1 & RF1_UNIQUE));
926                                         msg_format(_("%sは%sに進化した。", "%^s evolved into %s."), m_name, r_name + hallu_race->name);
927                                 }
928                                 else
929                                 {
930                                         msg_format(_("%sは%sに進化した。", "%^s evolved into %s."), m_name, r_name + r_ptr->name);
931                                 }
932                         }
933
934                         if (!p_ptr->image) r_info[old_r_idx].r_xtra1 |= MR1_SINKA;
935
936                         /* Now you feel very close to this pet. */
937                         m_ptr->parent_m_idx = 0;
938                 }
939                 update_monster(m_idx, FALSE);
940                 lite_spot(m_ptr->fy, m_ptr->fx);
941         }
942         if (m_idx == p_ptr->riding) p_ptr->update |= PU_BONUS;
943 }
944
945 /*!
946  * @brief モンスターのHPをダメージに応じて減算する /
947  * Decreases monsters hit points, handling monster death.
948  * @param dam 与えたダメージ量
949  * @param m_idx ダメージを与えたモンスターのID
950  * @param fear ダメージによってモンスターが恐慌状態に陥ったならばTRUEを返す
951  * @param note モンスターが倒された際の特別なメッセージ述語
952  * @return なし
953  * @details
954  * <pre>
955  * We return TRUE if the monster has been killed (and deleted).
956  * We announce monster death (using an optional "death message"
957  * if given, and a otherwise a generic killed/destroyed message).
958  * Only "physical attacks" can induce the "You have slain" message.
959  * Missile and Spell attacks will induce the "dies" message, or
960  * various "specialized" messages.  Note that "You have destroyed"
961  * and "is destroyed" are synonyms for "You have slain" and "dies".
962  * Hack -- unseen monsters yield "You have killed it." message.
963  * Added fear (DGK) and check whether to print fear messages -CWS
964  * Made name, sex, and capitalization generic -BEN-
965  * As always, the "ghost" processing is a total hack.
966  * Hack -- we "delay" fear messages by passing around a "fear" flag.
967  * Consider decreasing monster experience over time, say,
968  * by using "(m_exp * m_lev * (m_lev)) / (p_lev * (m_lev + n_killed))"
969  * instead of simply "(m_exp * m_lev) / (p_lev)", to make the first
970  * monster worth more than subsequent monsters.  This would also need
971  * to induce changes in the monster recall code.
972  * </pre>
973  */
974 bool mon_take_hit(MONSTER_IDX m_idx, HIT_POINT dam, bool *fear, concptr note)
975 {
976         monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
977         monster_race *r_ptr = &r_info[m_ptr->r_idx];
978         monster_type exp_mon;
979
980         /* Innocent until proven otherwise */
981         bool innocent = TRUE, thief = FALSE;
982         int i;
983         HIT_POINT expdam;
984
985         (void)COPY(&exp_mon, m_ptr, monster_type);
986
987         expdam = (m_ptr->hp > dam) ? dam : m_ptr->hp;
988
989         get_exp_from_mon(expdam, &exp_mon);
990
991         /* Genocided by chaos patron */
992         if (!monster_is_valid(m_ptr)) m_idx = 0;
993
994         /* Redraw (later) if needed */
995         if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
996         if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
997
998         (void)set_monster_csleep(m_idx, 0);
999
1000         /* Hack - Cancel any special player stealth magics. -LM- */
1001         if (p_ptr->special_defense & NINJA_S_STEALTH)
1002         {
1003                 set_superstealth(FALSE);
1004         }
1005
1006         /* Genocided by chaos patron */
1007         if (!m_idx) return TRUE;
1008
1009         m_ptr->hp -= dam;
1010         m_ptr->dealt_damage += dam;
1011
1012         if (m_ptr->dealt_damage > m_ptr->max_maxhp * 100) m_ptr->dealt_damage = m_ptr->max_maxhp * 100;
1013
1014         if (p_ptr->wizard)
1015         {
1016                 msg_format(_("合計%d/%dのダメージを与えた。", "You do %d (out of %d) damage."), m_ptr->dealt_damage, m_ptr->maxhp);
1017         }
1018
1019         /* It is dead now */
1020         if (m_ptr->hp < 0)
1021         {
1022                 GAME_TEXT m_name[MAX_NLEN];
1023
1024                 if (r_info[m_ptr->r_idx].flags7 & RF7_TANUKI)
1025                 {
1026                         /* You might have unmasked Tanuki first time */
1027                         r_ptr = &r_info[m_ptr->r_idx];
1028                         m_ptr->ap_r_idx = m_ptr->r_idx;
1029                         if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1030                 }
1031
1032                 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
1033                 {
1034                         /* You might have unmasked Chameleon first time */
1035                         r_ptr = real_r_ptr(m_ptr);
1036                         if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1037                 }
1038
1039                 if (!(m_ptr->smart & SM_CLONED))
1040                 {
1041                         /* When the player kills a Unique, it stays dead */
1042                         if (r_ptr->flags1 & RF1_UNIQUE)
1043                         {
1044                                 r_ptr->max_num = 0;
1045
1046                                 /* Mega-Hack -- Banor & Lupart */
1047                                 if ((m_ptr->r_idx == MON_BANOR) || (m_ptr->r_idx == MON_LUPART))
1048                                 {
1049                                         r_info[MON_BANORLUPART].max_num = 0;
1050                                         r_info[MON_BANORLUPART].r_pkills++;
1051                                         r_info[MON_BANORLUPART].r_akills++;
1052                                         if (r_info[MON_BANORLUPART].r_tkills < MAX_SHORT) r_info[MON_BANORLUPART].r_tkills++;
1053                                 }
1054                                 else if (m_ptr->r_idx == MON_BANORLUPART)
1055                                 {
1056                                         r_info[MON_BANOR].max_num = 0;
1057                                         r_info[MON_BANOR].r_pkills++;
1058                                         r_info[MON_BANOR].r_akills++;
1059                                         if (r_info[MON_BANOR].r_tkills < MAX_SHORT) r_info[MON_BANOR].r_tkills++;
1060                                         r_info[MON_LUPART].max_num = 0;
1061                                         r_info[MON_LUPART].r_pkills++;
1062                                         r_info[MON_LUPART].r_akills++;
1063                                         if (r_info[MON_LUPART].r_tkills < MAX_SHORT) r_info[MON_LUPART].r_tkills++;
1064                                 }
1065                         }
1066
1067                         /* When the player kills a Nazgul, it stays dead */
1068                         else if (r_ptr->flags7 & RF7_NAZGUL) r_ptr->max_num--;
1069                 }
1070
1071                 /* Count all monsters killed */
1072                 if (r_ptr->r_akills < MAX_SHORT) r_ptr->r_akills++;
1073
1074                 /* Recall even invisible uniques or winners */
1075                 if ((m_ptr->ml && !p_ptr->image) || (r_ptr->flags1 & RF1_UNIQUE))
1076                 {
1077                         /* Count kills this life */
1078                         if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_pkills < MAX_SHORT)) r_info[MON_KAGE].r_pkills++;
1079                         else if (r_ptr->r_pkills < MAX_SHORT) r_ptr->r_pkills++;
1080
1081                         /* Count kills in all lives */
1082                         if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_tkills < MAX_SHORT)) r_info[MON_KAGE].r_tkills++;
1083                         else if (r_ptr->r_tkills < MAX_SHORT) r_ptr->r_tkills++;
1084
1085                         /* Hack -- Auto-recall */
1086                         monster_race_track(m_ptr->ap_r_idx);
1087                 }
1088
1089                 /* Extract monster name */
1090                 monster_desc(m_name, m_ptr, MD_TRUE_NAME);
1091
1092                 /* Don't kill Amberites */
1093                 if ((r_ptr->flags3 & RF3_AMBERITE) && one_in_(2))
1094                 {
1095                         int curses = 1 + randint1(3);
1096                         bool stop_ty = FALSE;
1097                         int count = 0;
1098
1099                         msg_format(_("%^sは恐ろしい血の呪いをあなたにかけた!", "%^s puts a terrible blood curse on you!"), m_name);
1100                         curse_equipment(100, 50);
1101
1102                         do
1103                         {
1104                                 stop_ty = activate_ty_curse(stop_ty, &count);
1105                         } while (--curses);
1106                 }
1107
1108                 if (r_ptr->flags2 & RF2_CAN_SPEAK)
1109                 {
1110                         char line_got[1024];
1111                         if (!get_rnd_line(_("mondeath_j.txt", "mondeath.txt"), m_ptr->r_idx, line_got))
1112                         {
1113                                 msg_format("%^s %s", m_name, line_got);
1114                         }
1115
1116 #ifdef WORLD_SCORE
1117                         if (m_ptr->r_idx == MON_SERPENT)
1118                         {
1119                                 screen_dump = make_screen_dump();
1120                         }
1121 #endif
1122                 }
1123
1124                 if (!(d_info[p_ptr->dungeon_idx].flags1 & DF1_BEGINNER))
1125                 {
1126                         if (!current_floor_ptr->dun_level && !p_ptr->ambush_flag && !p_ptr->inside_arena)
1127                         {
1128                                 chg_virtue(V_VALOUR, -1);
1129                         }
1130                         else if (r_ptr->level > current_floor_ptr->dun_level)
1131                         {
1132                                 if (randint1(10) <= (r_ptr->level - current_floor_ptr->dun_level))
1133                                         chg_virtue(V_VALOUR, 1);
1134                         }
1135                         if (r_ptr->level > 60)
1136                         {
1137                                 chg_virtue(V_VALOUR, 1);
1138                         }
1139                         if (r_ptr->level >= 2 * (p_ptr->lev + 1))
1140                                 chg_virtue(V_VALOUR, 2);
1141                 }
1142
1143                 if (r_ptr->flags1 & RF1_UNIQUE)
1144                 {
1145                         if (r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)) chg_virtue(V_HARMONY, 2);
1146
1147                         if (r_ptr->flags3 & RF3_GOOD)
1148                         {
1149                                 chg_virtue(V_UNLIFE, 2);
1150                                 chg_virtue(V_VITALITY, -2);
1151                         }
1152
1153                         if (one_in_(3)) chg_virtue(V_INDIVIDUALISM, -1);
1154                 }
1155
1156                 if (m_ptr->r_idx == MON_BEGGAR || m_ptr->r_idx == MON_LEPER)
1157                 {
1158                         chg_virtue(V_COMPASSION, -1);
1159                 }
1160
1161                 if ((r_ptr->flags3 & RF3_GOOD) && ((r_ptr->level) / 10 + (3 * current_floor_ptr->dun_level) >= randint1(100)))
1162                         chg_virtue(V_UNLIFE, 1);
1163
1164                 if (r_ptr->d_char == 'A')
1165                 {
1166                         if (r_ptr->flags1 & RF1_UNIQUE)
1167                                 chg_virtue(V_FAITH, -2);
1168                         else if ((r_ptr->level) / 10 + (3 * current_floor_ptr->dun_level) >= randint1(100))
1169                         {
1170                                 if (r_ptr->flags3 & RF3_GOOD) chg_virtue(V_FAITH, -1);
1171                                 else chg_virtue(V_FAITH, 1);
1172                         }
1173                 }
1174                 else if (r_ptr->flags3 & RF3_DEMON)
1175                 {
1176                         if (r_ptr->flags1 & RF1_UNIQUE)
1177                                 chg_virtue(V_FAITH, 2);
1178                         else if ((r_ptr->level) / 10 + (3 * current_floor_ptr->dun_level) >= randint1(100))
1179                                 chg_virtue(V_FAITH, 1);
1180                 }
1181
1182                 if ((r_ptr->flags3 & RF3_UNDEAD) && (r_ptr->flags1 & RF1_UNIQUE))
1183                         chg_virtue(V_VITALITY, 2);
1184
1185                 if (r_ptr->r_deaths)
1186                 {
1187                         if (r_ptr->flags1 & RF1_UNIQUE)
1188                         {
1189                                 chg_virtue(V_HONOUR, 10);
1190                         }
1191                         else if ((r_ptr->level) / 10 + (2 * current_floor_ptr->dun_level) >= randint1(100))
1192                         {
1193                                 chg_virtue(V_HONOUR, 1);
1194                         }
1195                 }
1196                 if ((r_ptr->flags2 & RF2_MULTIPLY) && (r_ptr->r_akills > 1000) && one_in_(10))
1197                 {
1198                         chg_virtue(V_VALOUR, -1);
1199                 }
1200
1201                 for (i = 0; i < 4; i++)
1202                 {
1203                         if (r_ptr->blow[i].d_dice != 0) innocent = FALSE; /* Murderer! */
1204
1205                         if ((r_ptr->blow[i].effect == RBE_EAT_ITEM)
1206                                 || (r_ptr->blow[i].effect == RBE_EAT_GOLD))
1207
1208                                 thief = TRUE; /* Thief! */
1209                 }
1210
1211                 /* The new law says it is illegal to live in the dungeon */
1212                 if (r_ptr->level != 0) innocent = FALSE;
1213
1214                 if (thief)
1215                 {
1216                         if (r_ptr->flags1 & RF1_UNIQUE)
1217                                 chg_virtue(V_JUSTICE, 3);
1218                         else if (1 + ((r_ptr->level) / 10 + (2 * current_floor_ptr->dun_level)) >= randint1(100))
1219                                 chg_virtue(V_JUSTICE, 1);
1220                 }
1221                 else if (innocent)
1222                 {
1223                         chg_virtue(V_JUSTICE, -1);
1224                 }
1225
1226                 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)))
1227                 {
1228                         if (one_in_(4)) chg_virtue(V_NATURE, -1);
1229                 }
1230
1231                 if ((r_ptr->flags1 & RF1_UNIQUE) && record_destroy_uniq)
1232                 {
1233                         char note_buf[160];
1234                         sprintf(note_buf, "%s%s", r_name + r_ptr->name, (m_ptr->smart & SM_CLONED) ? _("(クローン)", "(Clone)") : "");
1235                         do_cmd_write_nikki(NIKKI_UNIQUE, 0, note_buf);
1236                 }
1237
1238                 /* Make a sound */
1239                 sound(SOUND_KILL);
1240
1241                 /* Death by Missile/Spell attack */
1242                 if (note)
1243                 {
1244                         msg_format("%^s%s", m_name, note);
1245                 }
1246
1247                 /* Death by physical attack -- invisible monster */
1248                 else if (!m_ptr->ml)
1249                 {
1250 #ifdef JP
1251                         if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1252                                 msg_format("せっかくだから%sを殺した。", m_name);
1253                         else
1254                                 msg_format("%sを殺した。", m_name);
1255 #else
1256                         msg_format("You have killed %s.", m_name);
1257 #endif
1258
1259                 }
1260
1261                 /* Death by Physical attack -- non-living monster */
1262                 else if (!monster_living(m_ptr->r_idx))
1263                 {
1264                         bool explode = FALSE;
1265
1266                         for (i = 0; i < 4; i++)
1267                         {
1268                                 if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
1269                         }
1270
1271                         /* Special note at death */
1272                         if (explode)
1273                                 msg_format(_("%sは爆発して粉々になった。", "%^s explodes into tiny shreds."), m_name);
1274                         else
1275                         {
1276 #ifdef JP
1277                                 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1278                                         msg_format("せっかくだから%sを倒した。", m_name);
1279                                 else
1280                                         msg_format("%sを倒した。", m_name);
1281 #else
1282                                 msg_format("You have destroyed %s.", m_name);
1283 #endif
1284                         }
1285                 }
1286
1287                 /* Death by Physical attack -- living monster */
1288                 else
1289                 {
1290 #ifdef JP
1291                         if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1292                                 msg_format("せっかくだから%sを葬り去った。", m_name);
1293                         else
1294                                 msg_format("%sを葬り去った。", m_name);
1295 #else
1296                         msg_format("You have slain %s.", m_name);
1297 #endif
1298
1299                 }
1300                 if ((r_ptr->flags1 & RF1_UNIQUE) && !(m_ptr->smart & SM_CLONED) && !vanilla_town)
1301                 {
1302                         for (i = 0; i < MAX_KUBI; i++)
1303                         {
1304                                 if ((current_world_ptr->bounty_r_idx[i] == m_ptr->r_idx) && !(m_ptr->mflag2 & MFLAG2_CHAMELEON))
1305                                 {
1306                                         msg_format(_("%sの首には賞金がかかっている。", "There is a price on %s's head."), m_name);
1307                                         break;
1308                                 }
1309                         }
1310                 }
1311
1312                 /* Generate treasure */
1313                 monster_death(m_idx, TRUE);
1314
1315                 /* Mega hack : replace IKETA to BIKETAL */
1316                 if ((m_ptr->r_idx == MON_IKETA) && !(p_ptr->inside_arena || p_ptr->inside_battle))
1317                 {
1318                         POSITION dummy_y = m_ptr->fy;
1319                         POSITION dummy_x = m_ptr->fx;
1320                         BIT_FLAGS mode = 0L;
1321                         if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
1322                         delete_monster_idx(m_idx);
1323                         if (summon_named_creature(0, dummy_y, dummy_x, MON_BIKETAL, mode))
1324                         {
1325                                 msg_print(_("「ハァッハッハッハ!!私がバイケタルだ!!」", "Uwa-hahaha!  *I* am Biketal!"));
1326                         }
1327                 }
1328                 else
1329                 {
1330                         delete_monster_idx(m_idx);
1331                 }
1332
1333                 get_exp_from_mon((long)exp_mon.max_maxhp * 2, &exp_mon);
1334
1335                 /* Not afraid */
1336                 (*fear) = FALSE;
1337
1338                 /* Monster is dead */
1339                 return (TRUE);
1340         }
1341
1342
1343 #ifdef ALLOW_FEAR
1344
1345         /* Mega-Hack -- Pain cancels fear */
1346         if (MON_MONFEAR(m_ptr) && (dam > 0))
1347         {
1348                 /* Cure fear */
1349                 if (set_monster_monfear(m_idx, MON_MONFEAR(m_ptr) - randint1(dam)))
1350                 {
1351                         /* No more fear */
1352                         (*fear) = FALSE;
1353                 }
1354         }
1355
1356         /* Sometimes a monster gets scared by damage */
1357         if (!MON_MONFEAR(m_ptr) && !(r_ptr->flags3 & (RF3_NO_FEAR)))
1358         {
1359                 /* Percentage of fully healthy */
1360                 int percentage = (100L * m_ptr->hp) / m_ptr->maxhp;
1361
1362                 /*
1363                  * Run (sometimes) if at 10% or less of max hit points,
1364                  * or (usually) when hit for half its current hit points
1365                  */
1366                 if ((randint1(10) >= percentage) || ((dam >= m_ptr->hp) && (randint0(100) < 80)))
1367                 {
1368                         /* Hack -- note fear */
1369                         (*fear) = TRUE;
1370
1371                         /* Hack -- Add some timed fear */
1372                         (void)set_monster_monfear(m_idx, (randint1(10) +
1373                                 (((dam >= m_ptr->hp) && (percentage > 7)) ?
1374                                         20 : ((11 - percentage) * 5))));
1375                 }
1376         }
1377
1378 #endif
1379
1380         /* Not dead yet */
1381         return (FALSE);
1382 }
1383
1384 bool monster_is_valid(monster_type *m_ptr)
1385 {
1386         return (m_ptr->r_idx != 0);
1387 }