OSDN Git Service

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