OSDN Git Service

bd163c4e5acbce1e881821c8fab35f62f2d2a4f6
[hengband/hengband.git] / src / player / player-damage.c
1 #include "player/player-damage.h"
2 #include "autopick/autopick-pref-processor.h"
3 #include "blue-magic/blue-magic-checker.h"
4 #include "cmd-building/cmd-building.h"
5 #include "cmd-io/cmd-process-screen.h"
6 #include "core/asking-player.h"
7 #include "core/disturbance.h"
8 #include "core/player-redraw-types.h"
9 #include "core/player-update-types.h"
10 #include "core/stuff-handler.h"
11 #include "core/window-redrawer.h"
12 #include "dungeon/quest.h"
13 #include "flavor/flavor-describer.h"
14 #include "flavor/object-flavor-types.h"
15 #include "floor/wild.h"
16 #include "game-option/birth-options.h"
17 #include "game-option/cheat-options.h"
18 #include "game-option/game-play-options.h"
19 #include "game-option/input-options.h"
20 #include "game-option/play-record-options.h"
21 #include "game-option/special-options.h"
22 #include "inventory/inventory-damage.h"
23 #include "inventory/inventory-slot-types.h"
24 #include "io/input-key-acceptor.h"
25 #include "io/report.h"
26 #include "io/write-diary.h"
27 #include "main/music-definitions-table.h"
28 #include "main/sound-definitions-table.h"
29 #include "main/sound-of-music.h"
30 #include "market/arena-info-table.h"
31 #include "mind/mind-mirror-master.h"
32 #include "monster-race/monster-race.h"
33 #include "monster-race/race-flags2.h"
34 #include "monster-race/race-flags3.h"
35 #include "monster/monster-describer.h"
36 #include "monster/monster-description-types.h"
37 #include "monster/monster-info.h"
38 #include "mutation/mutation-flag-types.h"
39 #include "object-enchant/tr-types.h"
40 #include "object-hook/hook-armor.h"
41 #include "object/item-tester-hooker.h"
42 #include "object/object-broken.h"
43 #include "object/object-flags.h"
44 #include "player-info/avatar.h"
45 #include "player/player-class.h"
46 #include "player/player-personalities-types.h"
47 #include "player/player-race-types.h"
48 #include "player/race-info-table.h"
49 #include "player/special-defense-types.h"
50 #include "racial/racial-android.h"
51 #include "save/save.h"
52 #include "status/base-status.h"
53 #include "status/element-resistance.h"
54 #include "system/floor-type-definition.h"
55 #include "term/screen-processor.h"
56 #include "term/term-color-types.h"
57 #include "util/bit-flags-calculator.h"
58 #include "util/string-processor.h"
59 #include "view/display-messages.h"
60 #include "world/world.h"
61
62 /*!
63  * @brief 酸攻撃による装備のAC劣化処理 /
64  * Acid has hit the player, attempt to affect some armor.
65  * @param 酸を浴びたキャラクタへの参照ポインタ
66  * @return 装備による軽減があったならTRUEを返す
67  * @details
68  * Note that the "base armor" of an object never changes.
69  * If any armor is damaged (or resists), the player takes less damage.
70  */
71 static bool acid_minus_ac(player_type *creature_ptr)
72 {
73     object_type *o_ptr = NULL;
74     BIT_FLAGS flgs[TR_FLAG_SIZE];
75     GAME_TEXT o_name[MAX_NLEN];
76
77     /* Pick a (possibly empty) creature_ptr->inventory_list slot */
78     switch (randint1(7)) {
79     case 1:
80         o_ptr = &creature_ptr->inventory_list[INVEN_RARM];
81         break;
82     case 2:
83         o_ptr = &creature_ptr->inventory_list[INVEN_LARM];
84         break;
85     case 3:
86         o_ptr = &creature_ptr->inventory_list[INVEN_BODY];
87         break;
88     case 4:
89         o_ptr = &creature_ptr->inventory_list[INVEN_OUTER];
90         break;
91     case 5:
92         o_ptr = &creature_ptr->inventory_list[INVEN_HANDS];
93         break;
94     case 6:
95         o_ptr = &creature_ptr->inventory_list[INVEN_HEAD];
96         break;
97     case 7:
98         o_ptr = &creature_ptr->inventory_list[INVEN_FEET];
99         break;
100     }
101
102     if (!o_ptr->k_idx)
103         return FALSE;
104     if (!object_is_armour(creature_ptr, o_ptr))
105         return FALSE;
106
107     describe_flavor(creature_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
108     object_flags(creature_ptr, o_ptr, flgs);
109     /* No damage left to be done */
110     if (o_ptr->ac + o_ptr->to_a <= 0) {
111         msg_format(_("%sは既にボロボロだ!", "Your %s is already fully corroded!"), o_name);
112         return FALSE;
113     }
114
115     /* Object resists */
116     if (have_flag(flgs, TR_IGNORE_ACID)) {
117         msg_format(_("しかし%sには効果がなかった!", "Your %s is unaffected!"), o_name);
118         return TRUE;
119     }
120
121     msg_format(_("%sが酸で腐食した!", "Your %s is corroded!"), o_name);
122
123     /* Damage the item */
124     o_ptr->to_a--;
125
126     /* Calculate bonuses */
127     creature_ptr->update |= (PU_BONUS);
128     creature_ptr->window |= (PW_EQUIP | PW_PLAYER);
129
130     calc_android_exp(creature_ptr);
131
132     /* Item was damaged */
133     return TRUE;
134 }
135
136 /*!
137  * @brief 酸属性によるプレイヤー損害処理 /
138  * Hurt the player with Acid
139  * @param creature_ptr 酸を浴びたキャラクタへの参照ポインタ
140  * @param dam 基本ダメージ量
141  * @param kb_str ダメージ原因記述
142  * @param monspell 原因となったモンスター特殊攻撃ID
143  * @param aura オーラよるダメージが原因ならばTRUE
144  * @return 修正HPダメージ量
145  */
146 HIT_POINT acid_dam(player_type *creature_ptr, HIT_POINT dam, concptr kb_str, int monspell, bool aura)
147 {
148     HIT_POINT get_damage;
149     int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
150     bool double_resist = is_oppose_acid(creature_ptr);
151
152     /* Total Immunity */
153     if (creature_ptr->immune_acid || (dam <= 0)) {
154         learn_spell(creature_ptr, monspell);
155         return 0;
156     }
157
158     /* Vulnerability (Ouch!) */
159     if (creature_ptr->muta3 & MUT3_VULN_ELEM)
160         dam *= 2;
161     if (creature_ptr->special_defense & KATA_KOUKIJIN)
162         dam += dam / 3;
163
164     /* Resist the damage */
165     if (creature_ptr->resist_acid)
166         dam = (dam + 2) / 3;
167     if (double_resist)
168         dam = (dam + 2) / 3;
169
170     if (aura || !check_multishadow(creature_ptr)) {
171         if ((!(double_resist || creature_ptr->resist_acid)) && one_in_(HURT_CHANCE))
172             (void)do_dec_stat(creature_ptr, A_CHR);
173
174         /* If any armor gets hit, defend the player */
175         if (acid_minus_ac(creature_ptr))
176             dam = (dam + 1) / 2;
177     }
178
179     get_damage = take_hit(creature_ptr, aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
180
181     /* Inventory damage */
182     if (!aura && !(double_resist && creature_ptr->resist_acid))
183         inventory_damage(creature_ptr, set_acid_destroy, inv);
184     return get_damage;
185 }
186
187 /*!
188  * @brief 電撃属性によるプレイヤー損害処理 /
189  * Hurt the player with electricity
190  * @param creature_ptr 電撃を浴びたキャラクタへの参照ポインタ
191  * @param dam 基本ダメージ量
192  * @param kb_str ダメージ原因記述
193  * @param monspell 原因となったモンスター特殊攻撃ID
194  * @param aura オーラよるダメージが原因ならばTRUE
195  * @return 修正HPダメージ量
196  */
197 HIT_POINT elec_dam(player_type *creature_ptr, HIT_POINT dam, concptr kb_str, int monspell, bool aura)
198 {
199     HIT_POINT get_damage;
200     int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
201     bool double_resist = is_oppose_elec(creature_ptr);
202
203     /* Total immunity */
204     if (creature_ptr->immune_elec || (dam <= 0)) {
205         learn_spell(creature_ptr, monspell);
206         return 0;
207     }
208
209     /* Vulnerability (Ouch!) */
210     if (creature_ptr->muta3 & MUT3_VULN_ELEM)
211         dam *= 2;
212     if (creature_ptr->special_defense & KATA_KOUKIJIN)
213         dam += dam / 3;
214     if (is_specific_player_race(creature_ptr, RACE_ANDROID))
215         dam += dam / 3;
216
217     /* Resist the damage */
218     if (creature_ptr->resist_elec)
219         dam = (dam + 2) / 3;
220     if (double_resist)
221         dam = (dam + 2) / 3;
222
223     if (aura || !check_multishadow(creature_ptr)) {
224         if ((!(double_resist || creature_ptr->resist_elec)) && one_in_(HURT_CHANCE))
225             (void)do_dec_stat(creature_ptr, A_DEX);
226     }
227
228     get_damage = take_hit(creature_ptr, aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
229
230     /* Inventory damage */
231     if (!aura && !(double_resist && creature_ptr->resist_elec))
232         inventory_damage(creature_ptr, set_elec_destroy, inv);
233
234     return get_damage;
235 }
236
237 /*!
238  * @brief 火炎属性によるプレイヤー損害処理 /
239  * Hurt the player with Fire
240  * @param creature_ptr 火炎を浴びたキャラクタへの参照ポインタ
241  * @param dam 基本ダメージ量
242  * @param kb_str ダメージ原因記述
243  * @param monspell 原因となったモンスター特殊攻撃ID
244  * @param aura オーラよるダメージが原因ならばTRUE
245  * @return 修正HPダメージ量
246  */
247 HIT_POINT fire_dam(player_type *creature_ptr, HIT_POINT dam, concptr kb_str, int monspell, bool aura)
248 {
249     HIT_POINT get_damage;
250     int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
251     bool double_resist = is_oppose_fire(creature_ptr);
252
253     /* Totally immune */
254     if (creature_ptr->immune_fire || (dam <= 0)) {
255         learn_spell(creature_ptr, monspell);
256         return 0;
257     }
258
259     /* Vulnerability (Ouch!) */
260     if (creature_ptr->muta3 & MUT3_VULN_ELEM)
261         dam *= 2;
262     if (is_specific_player_race(creature_ptr, RACE_ENT))
263         dam += dam / 3;
264     if (creature_ptr->special_defense & KATA_KOUKIJIN)
265         dam += dam / 3;
266
267     /* Resist the damage */
268     if (creature_ptr->resist_fire)
269         dam = (dam + 2) / 3;
270     if (double_resist)
271         dam = (dam + 2) / 3;
272
273     if (aura || !check_multishadow(creature_ptr)) {
274         if ((!(double_resist || creature_ptr->resist_fire)) && one_in_(HURT_CHANCE))
275             (void)do_dec_stat(creature_ptr, A_STR);
276     }
277
278     get_damage = take_hit(creature_ptr, aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
279
280     /* Inventory damage */
281     if (!aura && !(double_resist && creature_ptr->resist_fire))
282         inventory_damage(creature_ptr, set_fire_destroy, inv);
283
284     return get_damage;
285 }
286
287 /*!
288  * @brief 冷気属性によるプレイヤー損害処理 /
289  * Hurt the player with Cold
290  * @param creature_ptr 冷気を浴びたキャラクタへの参照ポインタ
291  * @param dam 基本ダメージ量
292  * @param kb_str ダメージ原因記述
293  * @param monspell 原因となったモンスター特殊攻撃ID
294  * @param aura オーラよるダメージが原因ならばTRUE
295  * @return 修正HPダメージ量
296  */
297 HIT_POINT cold_dam(player_type *creature_ptr, HIT_POINT dam, concptr kb_str, int monspell, bool aura)
298 {
299     HIT_POINT get_damage;
300     int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
301     bool double_resist = is_oppose_cold(creature_ptr);
302
303     /* Total immunity */
304     if (creature_ptr->immune_cold || (dam <= 0)) {
305         learn_spell(creature_ptr, monspell);
306         return 0;
307     }
308
309     /* Vulnerability (Ouch!) */
310     if (creature_ptr->muta3 & MUT3_VULN_ELEM)
311         dam *= 2;
312     if (creature_ptr->special_defense & KATA_KOUKIJIN)
313         dam += dam / 3;
314
315     /* Resist the damage */
316     if (creature_ptr->resist_cold)
317         dam = (dam + 2) / 3;
318     if (double_resist)
319         dam = (dam + 2) / 3;
320
321     if (aura || !check_multishadow(creature_ptr)) {
322         if ((!(double_resist || creature_ptr->resist_cold)) && one_in_(HURT_CHANCE))
323             (void)do_dec_stat(creature_ptr, A_STR);
324     }
325
326     get_damage = take_hit(creature_ptr, aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
327
328     /* Inventory damage */
329     if (!aura && !(double_resist && creature_ptr->resist_cold))
330         inventory_damage(creature_ptr, set_cold_destroy, inv);
331
332     return get_damage;
333 }
334
335 #ifdef JP
336 /*
337  * Move to a location and, using an attr, add a string vertically
338  */
339 static errr term_putstr_v(TERM_LEN x, TERM_LEN y, int n, byte a, concptr s)
340 {
341     errr res;
342     int y0 = y;
343
344     for (int i = 0; i < n && s[i] != 0; i++) {
345         /* Move first */
346         if ((res = term_gotoxy(x, y0)) != 0)
347             return (res);
348
349         if (iskanji(s[i])) {
350             if ((res = term_addstr(2, a, &s[i])) != 0)
351                 return (res);
352             i++;
353             y0++;
354             if (s[i] == 0)
355                 break;
356         } else {
357             if ((res = term_addstr(1, a, &s[i])) != 0)
358                 return (res);
359             y0++;
360         }
361     }
362
363     return 0;
364 }
365 #endif
366
367 /*
368  * Decreases players hit points and sets death flag if necessary
369  *
370  * Invulnerability needs to be changed into a "shield"
371  *
372  * Hack -- this function allows the user to save (or quit)
373  * the game when he dies, since the "You die." message is shown before
374  * setting the player to "dead".
375  */
376 int take_hit(player_type *creature_ptr, int damage_type, HIT_POINT damage, concptr hit_from, int monspell)
377 {
378     int old_chp = creature_ptr->chp;
379
380     char death_message[1024];
381     char tmp[1024];
382
383     int warning = (creature_ptr->mhp * hitpoint_warn / 10);
384     if (creature_ptr->is_dead)
385         return 0;
386
387     if (creature_ptr->sutemi)
388         damage *= 2;
389     if (creature_ptr->special_defense & KATA_IAI)
390         damage += (damage + 4) / 5;
391
392     if (easy_band)
393         damage = (damage + 1) / 2;
394
395     if (damage_type != DAMAGE_USELIFE) {
396         disturb(creature_ptr, TRUE, TRUE);
397         if (auto_more) {
398             creature_ptr->now_damaged = TRUE;
399         }
400     }
401
402     if (monspell >= 0)
403         learn_spell(creature_ptr, monspell);
404
405     /* Mega-Hack -- Apply "invulnerability" */
406     if ((damage_type != DAMAGE_USELIFE) && (damage_type != DAMAGE_LOSELIFE)) {
407         if (is_invuln(creature_ptr) && (damage < 9000)) {
408             if (damage_type == DAMAGE_FORCE) {
409                 msg_print(_("バリアが切り裂かれた!", "The attack cuts your shield of invulnerability open!"));
410             } else if (one_in_(PENETRATE_INVULNERABILITY)) {
411                 msg_print(_("無敵のバリアを破って攻撃された!", "The attack penetrates your shield of invulnerability!"));
412             } else {
413                 return 0;
414             }
415         }
416
417         if (check_multishadow(creature_ptr)) {
418             if (damage_type == DAMAGE_FORCE) {
419                 msg_print(_("幻影もろとも体が切り裂かれた!", "The attack hits Shadow together with you!"));
420             } else if (damage_type == DAMAGE_ATTACK) {
421                 msg_print(_("攻撃は幻影に命中し、あなたには届かなかった。", "The attack hits Shadow, but you are unharmed!"));
422                 return 0;
423             }
424         }
425
426         if (creature_ptr->wraith_form) {
427             if (damage_type == DAMAGE_FORCE) {
428                 msg_print(_("半物質の体が切り裂かれた!", "The attack cuts through your ethereal body!"));
429             } else {
430                 damage /= 2;
431                 if ((damage == 0) && one_in_(2))
432                     damage = 1;
433             }
434         }
435
436         if (creature_ptr->special_defense & KATA_MUSOU) {
437             damage /= 2;
438             if ((damage == 0) && one_in_(2))
439                 damage = 1;
440         }
441     } /* not if LOSELIFE USELIFE */
442
443     /* Hurt the player */
444     creature_ptr->chp -= damage;
445     if (damage_type == DAMAGE_GENO && creature_ptr->chp < 0) {
446         damage += creature_ptr->chp;
447         creature_ptr->chp = 0;
448     }
449
450     /* Display the hitpoints */
451     creature_ptr->redraw |= (PR_HP);
452
453     creature_ptr->window |= (PW_PLAYER);
454
455     if (damage_type != DAMAGE_GENO && creature_ptr->chp == 0) {
456         chg_virtue(creature_ptr, V_SACRIFICE, 1);
457         chg_virtue(creature_ptr, V_CHANCE, 2);
458     }
459
460     /* Dead player */
461     if (creature_ptr->chp < 0) {
462         bool android = (creature_ptr->prace == RACE_ANDROID ? TRUE : FALSE);
463
464 #ifdef JP
465         /* 死んだ時に強制終了して死を回避できなくしてみた by Habu */
466         if (!cheat_save)
467             if (!save_player(creature_ptr))
468                 msg_print("セーブ失敗!");
469 #endif
470
471         sound(SOUND_DEATH);
472
473         chg_virtue(creature_ptr, V_SACRIFICE, 10);
474
475         handle_stuff(creature_ptr);
476         creature_ptr->leaving = TRUE;
477
478         /* Note death */
479         creature_ptr->is_dead = TRUE;
480
481         if (creature_ptr->current_floor_ptr->inside_arena) {
482             concptr m_name = r_name + r_info[arena_info[creature_ptr->arena_number].r_idx].name;
483             msg_format(_("あなたは%sの前に敗れ去った。", "You are beaten by %s."), m_name);
484             msg_print(NULL);
485             if (record_arena)
486                 exe_write_diary(creature_ptr, DIARY_ARENA, -1 - creature_ptr->arena_number, m_name);
487         } else {
488             QUEST_IDX q_idx = quest_number(creature_ptr, creature_ptr->current_floor_ptr->dun_level);
489             bool seppuku = streq(hit_from, "Seppuku");
490             bool winning_seppuku = current_world_ptr->total_winner && seppuku;
491
492             play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_GAMEOVER);
493
494 #ifdef WORLD_SCORE
495             /* Make screen dump */
496             screen_dump = make_screen_dump(creature_ptr, process_autopick_file_command);
497 #endif
498
499             /* Note cause of death */
500             if (seppuku) {
501                 strcpy(creature_ptr->died_from, hit_from);
502 #ifdef JP
503                 if (!winning_seppuku)
504                     strcpy(creature_ptr->died_from, "切腹");
505 #endif
506             } else {
507                 char dummy[1024];
508 #ifdef JP
509                 sprintf(dummy, "%s%s%s", !creature_ptr->paralyzed ? "" : creature_ptr->free_act ? "彫像状態で" : "麻痺状態で",
510                     creature_ptr->image ? "幻覚に歪んだ" : "", hit_from);
511 #else
512                 sprintf(dummy, "%s%s", hit_from, !creature_ptr->paralyzed ? "" : " while helpless");
513 #endif
514                 angband_strcpy(creature_ptr->died_from, dummy, sizeof creature_ptr->died_from);
515             }
516
517             /* No longer a winner */
518             current_world_ptr->total_winner = FALSE;
519
520             if (winning_seppuku) {
521                 exe_write_diary(creature_ptr, DIARY_DESCRIPTION, 0, _("勝利の後切腹した。", "committed seppuku after the winning."));
522             } else {
523                 char buf[20];
524
525                 if (creature_ptr->current_floor_ptr->inside_arena)
526                     strcpy(buf, _("アリーナ", "in the Arena"));
527                 else if (!creature_ptr->current_floor_ptr->dun_level)
528                     strcpy(buf, _("地上", "on the surface"));
529                 else if (q_idx && (is_fixed_quest_idx(q_idx) && !((q_idx == QUEST_OBERON) || (q_idx == QUEST_SERPENT))))
530                     strcpy(buf, _("クエスト", "in a quest"));
531                 else
532                     sprintf(buf, _("%d階", "level %d"), (int)creature_ptr->current_floor_ptr->dun_level);
533
534                 sprintf(tmp, _("%sで%sに殺された。", "killed by %s %s."), buf, creature_ptr->died_from);
535                 exe_write_diary(creature_ptr, DIARY_DESCRIPTION, 0, tmp);
536             }
537
538             exe_write_diary(creature_ptr, DIARY_GAMESTART, 1, _("-------- ゲームオーバー --------", "--------   Game  Over   --------"));
539             exe_write_diary(creature_ptr, DIARY_DESCRIPTION, 1, "\n\n\n\n");
540
541             flush();
542
543             if (get_check_strict(creature_ptr, _("画面を保存しますか?", "Dump the screen? "), CHECK_NO_HISTORY)) {
544                 do_cmd_save_screen(creature_ptr, process_autopick_file_command);
545             }
546
547             flush();
548
549             /* Initialize "last message" buffer */
550             if (creature_ptr->last_message)
551                 string_free(creature_ptr->last_message);
552             creature_ptr->last_message = NULL;
553
554             /* Hack -- Note death */
555             if (!last_words) {
556 #ifdef JP
557                 msg_format("あなたは%sました。", android ? "壊れ" : "死に");
558 #else
559                 msg_print(android ? "You are broken." : "You die.");
560 #endif
561
562                 msg_print(NULL);
563             } else {
564                 if (winning_seppuku) {
565                     get_rnd_line(_("seppuku_j.txt", "seppuku.txt"), 0, death_message);
566                 } else {
567                     get_rnd_line(_("death_j.txt", "death.txt"), 0, death_message);
568                 }
569
570                 do {
571 #ifdef JP
572                     while (!get_string(winning_seppuku ? "辞世の句: " : "断末魔の叫び: ", death_message, 1024))
573                         ;
574 #else
575                     while (!get_string("Last word: ", death_message, 1024))
576                         ;
577 #endif
578                 } while (winning_seppuku && !get_check_strict(creature_ptr, _("よろしいですか?", "Are you sure? "), CHECK_NO_HISTORY));
579
580                 if (death_message[0] == '\0') {
581 #ifdef JP
582                     strcpy(death_message, format("あなたは%sました。", android ? "壊れ" : "死に"));
583 #else
584                     strcpy(death_message, android ? "You are broken." : "You die.");
585 #endif
586                 } else
587                     creature_ptr->last_message = string_make(death_message);
588
589 #ifdef JP
590                 if (winning_seppuku) {
591                     int i, len;
592                     int w = Term->wid;
593                     int h = Term->hgt;
594                     int msg_pos_x[9] = { 5, 7, 9, 12, 14, 17, 19, 21, 23 };
595                     int msg_pos_y[9] = { 3, 4, 5, 4, 5, 4, 5, 6, 4 };
596                     concptr str;
597                     char *str2;
598
599                     term_clear();
600
601                     /* 桜散る */
602                     for (i = 0; i < 40; i++)
603                         term_putstr(randint0(w / 2) * 2, randint0(h), 2, TERM_VIOLET, "υ");
604
605                     str = death_message;
606                     if (strncmp(str, "「", 2) == 0)
607                         str += 2;
608
609                     str2 = angband_strstr(str, "」");
610                     if (str2 != NULL)
611                         *str2 = '\0';
612
613                     i = 0;
614                     while (i < 9) {
615                         str2 = angband_strstr(str, " ");
616                         if (str2 == NULL)
617                             len = strlen(str);
618                         else
619                             len = str2 - str;
620
621                         if (len != 0) {
622                             term_putstr_v(w * 3 / 4 - 2 - msg_pos_x[i] * 2, msg_pos_y[i], len, TERM_WHITE, str);
623                             if (str2 == NULL)
624                                 break;
625                             i++;
626                         }
627                         str = str2 + 1;
628                         if (*str == 0)
629                             break;
630                     }
631
632                     /* Hide cursor */
633                     term_putstr(w - 1, h - 1, 1, TERM_WHITE, " ");
634
635                     flush();
636 #ifdef WORLD_SCORE
637                     /* Make screen dump */
638                     screen_dump = make_screen_dump(creature_ptr, process_autopick_file_command);
639 #endif
640
641                     /* Wait a key press */
642                     (void)inkey();
643                 } else
644 #endif
645                     msg_print(death_message);
646             }
647         }
648
649         /* Dead */
650         return damage;
651     }
652
653     handle_stuff(creature_ptr);
654
655     /* Hitpoint warning */
656     if (creature_ptr->chp < warning) {
657         /* Hack -- bell on first notice */
658         if (old_chp > warning)
659             bell();
660
661         sound(SOUND_WARN);
662
663         if (record_danger && (old_chp > warning)) {
664             if (creature_ptr->image && damage_type == DAMAGE_ATTACK)
665                 hit_from = _("何か", "something");
666
667             sprintf(tmp, _("%sによってピンチに陥った。", "was in a critical situation because of %s."), hit_from);
668             exe_write_diary(creature_ptr, DIARY_DESCRIPTION, 0, tmp);
669         }
670
671         if (auto_more) {
672             /* stop auto_more even if DAMAGE_USELIFE */
673             creature_ptr->now_damaged = TRUE;
674         }
675
676         msg_print(_("*** 警告:低ヒット・ポイント! ***", "*** LOW HITPOINT WARNING! ***"));
677         msg_print(NULL);
678         flush();
679     }
680     if (creature_ptr->wild_mode && !creature_ptr->leaving && (creature_ptr->chp < MAX(warning, creature_ptr->mhp / 5))) {
681         change_wild_mode(creature_ptr, FALSE);
682     }
683     return damage;
684 }
685
686 /*!
687  * @brief 属性に応じた敵オーラによるプレイヤーのダメージ処理
688  * @param m_ptr オーラを持つモンスターの構造体参照ポインタ
689  * @param immune ダメージを回避できる免疫フラグ
690  * @param flags_offset オーラフラグ配列の参照オフセット
691  * @param r_flags_offset モンスターの耐性配列の参照オフセット
692  * @param aura_flag オーラフラグ配列
693  * @param dam_func ダメージ処理を行う関数の参照ポインタ
694  * @param message オーラダメージを受けた際のメッセージ
695  * @return なし
696  */
697 static void process_aura_damage(monster_type *m_ptr, player_type *touched_ptr, bool immune, int flags_offset, int r_flags_offset, u32b aura_flag,
698     HIT_POINT (*dam_func)(player_type *creature_type, HIT_POINT dam, concptr kb_str, int monspell, bool aura), concptr message)
699 {
700     monster_race *r_ptr = &r_info[m_ptr->r_idx];
701     if (!(atoffset(BIT_FLAGS, r_ptr, flags_offset) & aura_flag) || immune)
702         return;
703
704     GAME_TEXT mon_name[MAX_NLEN];
705     int aura_damage = damroll(1 + (r_ptr->level / 26), 1 + (r_ptr->level / 17));
706
707     monster_desc(touched_ptr, mon_name, m_ptr, MD_WRONGDOER_NAME);
708     msg_print(message);
709     dam_func(touched_ptr, aura_damage, mon_name, -1, TRUE);
710
711     if (is_original_ap_and_seen(touched_ptr, m_ptr)) {
712         atoffset(BIT_FLAGS, r_ptr, r_flags_offset) |= aura_flag;
713     }
714
715     handle_stuff(touched_ptr);
716 }
717
718 /*!
719  * @brief 敵オーラによるプレイヤーのダメージ処理
720  * @param m_ptr オーラを持つモンスターの構造体参照ポインタ
721  * @param touched_ptr オーラを持つ相手に振れたクリーチャーの参照ポインタ
722  * @return なし
723  */
724 void touch_zap_player(monster_type *m_ptr, player_type *touched_ptr)
725 {
726     process_aura_damage(m_ptr, touched_ptr, touched_ptr->immune_fire, offsetof(monster_race, flags2), offsetof(monster_race, r_flags2), RF2_AURA_FIRE, fire_dam,
727         _("突然とても熱くなった!", "You are suddenly very hot!"));
728     process_aura_damage(m_ptr, touched_ptr, touched_ptr->immune_cold, offsetof(monster_race, flags3), offsetof(monster_race, r_flags3), RF3_AURA_COLD, cold_dam,
729         _("突然とても寒くなった!", "You are suddenly very cold!"));
730     process_aura_damage(m_ptr, touched_ptr, touched_ptr->immune_elec, offsetof(monster_race, flags2), offsetof(monster_race, r_flags2), RF2_AURA_ELEC, elec_dam,
731         _("電撃をくらった!", "You get zapped!"));
732 }