OSDN Git Service

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