OSDN Git Service

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