OSDN Git Service

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