OSDN Git Service

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