OSDN Git Service

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