OSDN Git Service

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