OSDN Git Service

Merge branch 'master' of https://github.com/hengband/hengband
[hengbandforosx/hengbandosx.git] / src / player / player-damage.cpp
1 #include "player/player-damage.h"
2 #include "autopick/autopick-pref-processor.h"
3 #include "avatar/avatar.h"
4 #include "blue-magic/blue-magic-checker.h"
5 #include "cmd-io/cmd-process-screen.h"
6 #include "core/asking-player.h"
7 #include "core/disturbance.h"
8 #include "core/stuff-handler.h"
9 #include "core/window-redrawer.h"
10 #include "dungeon/quest.h"
11 #include "flavor/flavor-describer.h"
12 #include "flavor/object-flavor-types.h"
13 #include "floor/wild.h"
14 #include "game-option/birth-options.h"
15 #include "game-option/cheat-options.h"
16 #include "game-option/game-play-options.h"
17 #include "game-option/input-options.h"
18 #include "game-option/play-record-options.h"
19 #include "game-option/special-options.h"
20 #include "inventory/inventory-damage.h"
21 #include "inventory/inventory-slot-types.h"
22 #include "io/files-util.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-entry.h"
30 #include "mind/mind-mirror-master.h"
31 #include "monster/monster-describer.h"
32 #include "monster/monster-description-types.h"
33 #include "monster/monster-info.h"
34 #include "mutation/mutation-flag-types.h"
35 #include "object-enchant/tr-types.h"
36 #include "object-hook/hook-armor.h"
37 #include "object/item-tester-hooker.h"
38 #include "object/object-broken.h"
39 #include "player-base/player-class.h"
40 #include "player-base/player-race.h"
41 #include "player-info/class-info.h"
42 #include "player-info/race-types.h"
43 #include "player-info/samurai-data-type.h"
44 #include "player/player-personality-types.h"
45 #include "player/player-status-flags.h"
46 #include "player/player-status-resist.h"
47 #include "player/player-status.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/building-type-definition.h"
55 #include "system/dungeon-info.h"
56 #include "system/floor-type-definition.h"
57 #include "system/item-entity.h"
58 #include "system/monster-entity.h"
59 #include "system/monster-race-info.h"
60 #include "system/player-type-definition.h"
61 #include "system/redrawing-flags-updater.h"
62 #include "term/screen-processor.h"
63 #include "term/term-color-types.h"
64 #include "timed-effect/timed-effects.h"
65 #include "util/bit-flags-calculator.h"
66 #include "util/string-processor.h"
67 #include "view/display-messages.h"
68 #include "world/world.h"
69 #include <sstream>
70 #include <string>
71
72 using dam_func = int (*)(PlayerType *player_ptr, int dam, std::string_view kb_str, bool aura);
73
74 /*!
75  * @brief 酸攻撃による装備のAC劣化処理 /
76  * Acid has hit the player, attempt to affect some armor.
77  * @param 酸を浴びたキャラクタへの参照ポインタ
78  * @return 装備による軽減があったならTRUEを返す
79  * @details
80  * 免疫があったらそもそもこの関数は実行されない (確実に錆びない).
81  * Note that the "base armor" of an object never changes.
82  * If any armor is damaged (or resists), the player takes less damage.
83  */
84 static bool acid_minus_ac(PlayerType *player_ptr)
85 {
86     constexpr static auto candidates = {
87         INVEN_MAIN_HAND,
88         INVEN_SUB_HAND,
89         INVEN_BODY,
90         INVEN_OUTER,
91         INVEN_ARMS,
92         INVEN_HEAD,
93         INVEN_FEET,
94     };
95
96     const auto slot = rand_choice(candidates);
97     auto *o_ptr = &player_ptr->inventory_list[slot];
98
99     if ((o_ptr == nullptr) || !o_ptr->is_valid() || !o_ptr->is_protector()) {
100         return false;
101     }
102
103     const auto item_name = describe_flavor(player_ptr, o_ptr, OD_OMIT_PREFIX | OD_NAME_ONLY);
104     const auto item_flags = o_ptr->get_flags();
105     if (o_ptr->ac + o_ptr->to_a <= 0) {
106         msg_format(_("%sは既にボロボロだ!", "Your %s is already fully corroded!"), item_name.data());
107         return false;
108     }
109
110     if (item_flags.has(TR_IGNORE_ACID)) {
111         msg_format(_("しかし%sには効果がなかった!", "Your %s is unaffected!"), item_name.data());
112         return true;
113     }
114
115     msg_format(_("%sが酸で腐食した!", "Your %s is corroded!"), item_name.data());
116     o_ptr->to_a--;
117     auto &rfu = RedrawingFlagsUpdater::get_instance();
118     rfu.set_flag(StatusRecalculatingFlag::BONUS);
119     static constexpr auto flags_swrf = {
120         SubWindowRedrawingFlag::EQUIPMENT,
121         SubWindowRedrawingFlag::PLAYER,
122     };
123     rfu.set_flags(flags_swrf);
124     calc_android_exp(player_ptr);
125     return true;
126 }
127
128 /*!
129  * @brief 酸属性によるプレイヤー損害処理 /
130  * Hurt the player with Acid
131  * @param player_ptr 酸を浴びたキャラクタへの参照ポインタ
132  * @param dam 基本ダメージ量
133  * @param kb_str ダメージ原因記述
134  * @param monspell 原因となったモンスター特殊攻撃ID
135  * @param aura オーラよるダメージが原因ならばTRUE
136  * @return 修正HPダメージ量
137  * @details 酸オーラは存在しないが関数ポインタのために引数だけは用意している
138  */
139 int acid_dam(PlayerType *player_ptr, int dam, std::string_view kb_str, bool aura)
140 {
141     int inv = (dam < 30) ? 1 : (dam < 60) ? 2
142                                           : 3;
143     bool double_resist = is_oppose_acid(player_ptr);
144     dam = dam * calc_acid_damage_rate(player_ptr) / 100;
145     if (dam <= 0) {
146         return 0;
147     }
148
149     if (aura || !check_multishadow(player_ptr)) {
150         if ((!(double_resist || has_resist_acid(player_ptr))) && one_in_(CHANCE_ABILITY_SCORE_DECREASE)) {
151             (void)do_dec_stat(player_ptr, A_CHR);
152         }
153
154         if (acid_minus_ac(player_ptr)) {
155             dam = (dam + 1) / 2;
156         }
157     }
158
159     int get_damage = take_hit(player_ptr, aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str);
160     if (!aura && !(double_resist && has_resist_acid(player_ptr))) {
161         inventory_damage(player_ptr, BreakerAcid(), inv);
162     }
163
164     return get_damage;
165 }
166
167 /*!
168  * @brief 電撃属性によるプレイヤー損害処理 /
169  * Hurt the player with electricity
170  * @param player_ptr 電撃を浴びたキャラクタへの参照ポインタ
171  * @param dam 基本ダメージ量
172  * @param kb_str ダメージ原因記述
173  * @param monspell 原因となったモンスター特殊攻撃ID
174  * @param aura オーラよるダメージが原因ならばTRUE
175  * @return 修正HPダメージ量
176  */
177 int elec_dam(PlayerType *player_ptr, int dam, std::string_view kb_str, bool aura)
178 {
179     int inv = (dam < 30) ? 1 : (dam < 60) ? 2
180                                           : 3;
181     bool double_resist = is_oppose_elec(player_ptr);
182
183     dam = dam * calc_elec_damage_rate(player_ptr) / 100;
184
185     if (dam <= 0) {
186         return 0;
187     }
188
189     if (aura || !check_multishadow(player_ptr)) {
190         if ((!(double_resist || has_resist_elec(player_ptr))) && one_in_(CHANCE_ABILITY_SCORE_DECREASE)) {
191             (void)do_dec_stat(player_ptr, A_DEX);
192         }
193     }
194
195     int get_damage = take_hit(player_ptr, aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str);
196     if (!aura && !(double_resist && has_resist_elec(player_ptr))) {
197         inventory_damage(player_ptr, BreakerElec(), inv);
198     }
199
200     return get_damage;
201 }
202
203 /*!
204  * @brief 火炎属性によるプレイヤー損害処理 /
205  * Hurt the player with Fire
206  * @param player_ptr 火炎を浴びたキャラクタへの参照ポインタ
207  * @param dam 基本ダメージ量
208  * @param kb_str ダメージ原因記述
209  * @param monspell 原因となったモンスター特殊攻撃ID
210  * @param aura オーラよるダメージが原因ならばTRUE
211  * @return 修正HPダメージ量
212  */
213 int fire_dam(PlayerType *player_ptr, int dam, std::string_view kb_str, bool aura)
214 {
215     int inv = (dam < 30) ? 1 : (dam < 60) ? 2
216                                           : 3;
217     bool double_resist = is_oppose_fire(player_ptr);
218
219     /* Totally immune */
220     if (has_immune_fire(player_ptr) || (dam <= 0)) {
221         return 0;
222     }
223
224     dam = dam * calc_fire_damage_rate(player_ptr) / 100;
225     if (aura || !check_multishadow(player_ptr)) {
226         if ((!(double_resist || has_resist_fire(player_ptr))) && one_in_(CHANCE_ABILITY_SCORE_DECREASE)) {
227             (void)do_dec_stat(player_ptr, A_STR);
228         }
229     }
230
231     int get_damage = take_hit(player_ptr, aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str);
232     if (!aura && !(double_resist && has_resist_fire(player_ptr))) {
233         inventory_damage(player_ptr, BreakerFire(), inv);
234     }
235
236     return get_damage;
237 }
238
239 /*!
240  * @brief 冷気属性によるプレイヤー損害処理 /
241  * Hurt the player with Cold
242  * @param player_ptr 冷気を浴びたキャラクタへの参照ポインタ
243  * @param dam 基本ダメージ量
244  * @param kb_str ダメージ原因記述
245  * @param monspell 原因となったモンスター特殊攻撃ID
246  * @param aura オーラよるダメージが原因ならばTRUE
247  * @return 修正HPダメージ量
248  */
249 int cold_dam(PlayerType *player_ptr, int dam, std::string_view kb_str, bool aura)
250 {
251     int inv = (dam < 30) ? 1 : (dam < 60) ? 2
252                                           : 3;
253     bool double_resist = is_oppose_cold(player_ptr);
254     if (has_immune_cold(player_ptr) || (dam <= 0)) {
255         return 0;
256     }
257
258     dam = dam * calc_cold_damage_rate(player_ptr) / 100;
259     if (aura || !check_multishadow(player_ptr)) {
260         if ((!(double_resist || has_resist_cold(player_ptr))) && one_in_(CHANCE_ABILITY_SCORE_DECREASE)) {
261             (void)do_dec_stat(player_ptr, A_STR);
262         }
263     }
264
265     int get_damage = take_hit(player_ptr, aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str);
266     if (!aura && !(double_resist && has_resist_cold(player_ptr))) {
267         inventory_damage(player_ptr, BreakerCold(), inv);
268     }
269
270     return get_damage;
271 }
272
273 /*
274  * Decreases players hit points and sets death flag if necessary
275  *
276  * Invulnerability needs to be changed into a "shield"
277  *
278  * Hack -- this function allows the user to save (or quit)
279  * the game when he dies, since the "You die." message is shown before
280  * setting the player to "dead".
281  */
282 int take_hit(PlayerType *player_ptr, int damage_type, int damage, std::string_view hit_from)
283 {
284     int old_chp = player_ptr->chp;
285     int warning = (player_ptr->mhp * hitpoint_warn / 10);
286     if (player_ptr->is_dead) {
287         return 0;
288     }
289
290     if (player_ptr->sutemi) {
291         damage *= 2;
292     }
293     if (PlayerClass(player_ptr).samurai_stance_is(SamuraiStanceType::IAI)) {
294         damage += (damage + 4) / 5;
295     }
296
297     if (damage_type != DAMAGE_USELIFE) {
298         disturb(player_ptr, true, true);
299         if (auto_more) {
300             player_ptr->now_damaged = true;
301         }
302     }
303
304     if ((damage_type != DAMAGE_USELIFE) && (damage_type != DAMAGE_LOSELIFE)) {
305         if (is_invuln(player_ptr) && (damage < 9000)) {
306             if (damage_type == DAMAGE_FORCE) {
307                 msg_print(_("バリアが切り裂かれた!", "The attack cuts your shield of invulnerability open!"));
308             } else if (one_in_(PENETRATE_INVULNERABILITY)) {
309                 msg_print(_("無敵のバリアを破って攻撃された!", "The attack penetrates your shield of invulnerability!"));
310             } else {
311                 return 0;
312             }
313         }
314
315         if (check_multishadow(player_ptr)) {
316             if (damage_type == DAMAGE_FORCE) {
317                 msg_print(_("幻影もろとも体が切り裂かれた!", "The attack hits Shadow together with you!"));
318             } else if (damage_type == DAMAGE_ATTACK) {
319                 msg_print(_("攻撃は幻影に命中し、あなたには届かなかった。", "The attack hits Shadow, but you are unharmed!"));
320                 return 0;
321             }
322         }
323
324         if (player_ptr->wraith_form) {
325             if (damage_type == DAMAGE_FORCE) {
326                 msg_print(_("半物質の体が切り裂かれた!", "The attack cuts through your ethereal body!"));
327             } else {
328                 damage /= 2;
329                 if ((damage == 0) && one_in_(2)) {
330                     damage = 1;
331                 }
332             }
333         }
334
335         if (PlayerClass(player_ptr).samurai_stance_is(SamuraiStanceType::MUSOU)) {
336             damage /= 2;
337             if ((damage == 0) && one_in_(2)) {
338                 damage = 1;
339             }
340         }
341     }
342
343     player_ptr->chp -= damage;
344     if (player_ptr->chp < -9999) {
345         player_ptr->chp = -9999;
346     }
347     if (damage_type == DAMAGE_GENO && player_ptr->chp < 0) {
348         damage += player_ptr->chp;
349         player_ptr->chp = 0;
350     }
351
352     auto &rfu = RedrawingFlagsUpdater::get_instance();
353     rfu.set_flag(MainWindowRedrawingFlag::HP);
354     rfu.set_flag(SubWindowRedrawingFlag::PLAYER);
355
356     if (damage_type != DAMAGE_GENO && player_ptr->chp == 0) {
357         chg_virtue(player_ptr, Virtue::SACRIFICE, 1);
358         chg_virtue(player_ptr, Virtue::CHANCE, 2);
359     }
360
361     const auto &floor = *player_ptr->current_floor_ptr;
362     auto &world = AngbandWorld::get_instance();
363     if (player_ptr->chp < 0 && !cheat_immortal) {
364         bool android = PlayerRace(player_ptr).equals(PlayerRaceType::ANDROID);
365
366         /* 死んだ時に強制終了して死を回避できなくしてみた by Habu */
367         if (!cheat_save && !save_player(player_ptr, SaveType::CLOSE_GAME)) {
368             msg_print(_("セーブ失敗!", "death save failed!"));
369         }
370
371         sound(SOUND_DEATH);
372         chg_virtue(player_ptr, Virtue::SACRIFICE, 10);
373         handle_stuff(player_ptr);
374         player_ptr->leaving = true;
375         if (!cheat_immortal) {
376             player_ptr->is_dead = true;
377         }
378
379         if (floor.inside_arena) {
380             auto &entries = ArenaEntryList::get_instance();
381             entries.set_defeated_entry();
382             const auto &m_name = entries.get_monrace().name;
383             msg_format(_("あなたは%sの前に敗れ去った。", "You are beaten by %s."), m_name.data());
384             msg_print(nullptr);
385             if (record_arena) {
386                 exe_write_diary(floor, DiaryKind::ARENA, 0, m_name);
387             }
388         } else {
389             const auto q_idx = floor.get_quest_id();
390             const auto seppuku = hit_from == "Seppuku";
391             const auto winning_seppuku = world.total_winner && seppuku;
392
393             play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_GAMEOVER);
394
395 #ifdef WORLD_SCORE
396             screen_dump = make_screen_dump(player_ptr);
397 #endif
398             if (seppuku) {
399                 player_ptr->died_from = hit_from;
400                 if (!winning_seppuku) {
401                     player_ptr->died_from = _("切腹", "Seppuku");
402                 }
403             } else {
404                 const auto effects = player_ptr->effects();
405                 const auto is_hallucinated = effects->hallucination().is_hallucinated();
406                 auto paralysis_state = "";
407                 if (effects->paralysis().is_paralyzed()) {
408                     paralysis_state = player_ptr->free_act ? _("彫像状態で", " while being the statue") : _("麻痺状態で", " while paralyzed");
409                 }
410
411                 auto hallucintion_state = is_hallucinated ? _("幻覚に歪んだ", "hallucinatingly distorted ") : "";
412 #ifdef JP
413                 player_ptr->died_from = format("%s%s%s", paralysis_state, hallucintion_state, hit_from.data());
414 #else
415                 player_ptr->died_from = format("%s%s%s", hallucintion_state, hit_from.data(), paralysis_state);
416 #endif
417             }
418
419             world.total_winner = false;
420             if (winning_seppuku) {
421                 world.add_retired_class(player_ptr->pclass);
422                 exe_write_diary(floor, DiaryKind::DESCRIPTION, 0, _("勝利の後切腹した。", "committed seppuku after the winning."));
423             } else {
424                 std::string place;
425
426                 if (floor.inside_arena) {
427                     place = _("アリーナ", "in the Arena");
428                 } else if (!floor.is_in_underground()) {
429                     place = _("地上", "on the surface");
430                 } else if (inside_quest(q_idx) && (QuestType::is_fixed(q_idx) && !((q_idx == QuestId::OBERON) || (q_idx == QuestId::SERPENT)))) {
431                     place = _("クエスト", "in a quest");
432                 } else {
433                     place = format(_("%d階", "on level %d"), static_cast<int>(floor.dun_level));
434                 }
435
436 #ifdef JP
437                 const auto note = format("%sで%sに殺された。", place.data(), player_ptr->died_from.data());
438 #else
439                 const auto note = format("killed by %s %s.", player_ptr->died_from.data(), place.data());
440 #endif
441                 exe_write_diary(floor, DiaryKind::DESCRIPTION, 0, note);
442             }
443
444             exe_write_diary(floor, DiaryKind::GAMESTART, 1, _("-------- ゲームオーバー --------", "--------   Game  Over   --------"));
445             exe_write_diary(floor, DiaryKind::DESCRIPTION, 1, "\n\n\n\n");
446             flush();
447             if (input_check_strict(player_ptr, _("画面を保存しますか?", "Dump the screen? "), UserCheck::NO_HISTORY)) {
448                 do_cmd_save_screen(player_ptr);
449             }
450
451             flush();
452             player_ptr->last_message = "";
453             if (!last_words) {
454 #ifdef JP
455                 msg_format("あなたは%sました。", android ? "壊れ" : "死に");
456 #else
457                 msg_print(android ? "You are broken." : "You die.");
458 #endif
459
460                 msg_print(nullptr);
461             } else {
462                 std::optional<std::string> death_message_opt;
463                 if (winning_seppuku) {
464                     death_message_opt = get_random_line(_("seppuku_j.txt", "seppuku.txt"), 0);
465                 } else {
466                     death_message_opt = get_random_line(_("death_j.txt", "death.txt"), 0);
467                 }
468
469                 auto &death_message = *death_message_opt;
470                 constexpr auto max_last_words = 1024;
471                 const auto prompt = winning_seppuku ? _("辞世の句: ", "Haiku: ") : _("断末魔の叫び: ", "Last words: ");
472                 while (true) {
473                     const auto input_last_words = input_string(prompt, max_last_words, death_message);
474                     if (!input_last_words) {
475                         continue;
476                     }
477
478                     if (input_check_strict(player_ptr, _("よろしいですか?", "Are you sure? "), UserCheck::NO_HISTORY)) {
479                         death_message = *input_last_words;
480                         break;
481                     }
482                 }
483
484                 if (death_message.empty()) {
485 #ifdef JP
486                     death_message = format("あなたは%sました。", android ? "壊れ" : "死に");
487 #else
488                     death_message = android ? "You are broken." : "You die.";
489 #endif
490                 } else {
491                     player_ptr->last_message = death_message;
492                 }
493
494 #ifdef JP
495                 if (winning_seppuku) {
496                     int i, len;
497                     int w = game_term->wid;
498                     int h = game_term->hgt;
499                     int msg_pos_x[9] = { 5, 7, 9, 12, 14, 17, 19, 21, 23 };
500                     int msg_pos_y[9] = { 3, 4, 5, 4, 5, 4, 5, 6, 4 };
501                     term_clear();
502
503                     /* 桜散る */
504                     for (i = 0; i < 40; i++) {
505                         term_putstr(randint0(w / 2) * 2, randint0(h), 2, TERM_VIOLET, "υ");
506                     }
507
508                     auto str = death_message.data();
509                     if (strncmp(str, "「", 2) == 0) {
510                         str += 2;
511                     }
512
513                     auto *str2 = angband_strstr(str, "」");
514                     if (str2 != nullptr) {
515                         *str2 = '\0';
516                     }
517
518                     i = 0;
519                     while (i < 9) {
520                         str2 = angband_strstr(str, " ");
521                         if (str2 == nullptr) {
522                             len = strlen(str);
523                         } else {
524                             len = str2 - str;
525                         }
526
527                         if (len != 0) {
528                             term_putstr_v(w * 3 / 4 - 2 - msg_pos_x[i] * 2, msg_pos_y[i], len, TERM_WHITE, str);
529                             if (str2 == nullptr) {
530                                 break;
531                             }
532                             i++;
533                         }
534                         str = str2 + 1;
535                         if (*str == 0) {
536                             break;
537                         }
538                     }
539
540                     term_putstr(w - 1, h - 1, 1, TERM_WHITE, " ");
541                     flush();
542 #ifdef WORLD_SCORE
543                     screen_dump = make_screen_dump(player_ptr);
544 #endif
545                     (void)inkey();
546                 } else
547 #endif
548                     msg_print(death_message);
549             }
550         }
551
552         return damage;
553     }
554
555     handle_stuff(player_ptr);
556     if (player_ptr->chp < warning) {
557         if (old_chp > warning) {
558             bell();
559         }
560
561         sound(SOUND_WARN);
562         if (record_danger && (old_chp > warning)) {
563             if (player_ptr->effects()->hallucination().is_hallucinated() && damage_type == DAMAGE_ATTACK) {
564                 hit_from = _("何か", "something");
565             }
566
567             std::stringstream ss;
568             ss << _(hit_from, "was in a critical situation because of ");
569             ss << _("によってピンチに陥った。", hit_from);
570             ss << _("", ".");
571             exe_write_diary(floor, DiaryKind::DESCRIPTION, 0, ss.str());
572         }
573
574         if (auto_more) {
575             player_ptr->now_damaged = true;
576         }
577
578         msg_print(_("*** 警告:低ヒット・ポイント! ***", "*** LOW HITPOINT WARNING! ***"));
579         msg_print(nullptr);
580         flush();
581     }
582
583     if (world.is_wild_mode() && !player_ptr->leaving && (player_ptr->chp < std::max(warning, player_ptr->mhp / 5))) {
584         change_wild_mode(player_ptr, false);
585     }
586
587     return damage;
588 }
589
590 /*!
591  * @brief 属性に応じた敵オーラによるプレイヤーのダメージ処理
592  * @param m_ptr オーラを持つモンスターの構造体参照ポインタ
593  * @param immune ダメージを回避できる免疫フラグ
594  * @param flags_offset オーラフラグ配列の参照オフセット
595  * @param r_flags_offset モンスターの耐性配列の参照オフセット
596  * @param aura_flag オーラフラグ配列
597  * @param dam_func ダメージ処理を行う関数の参照ポインタ
598  * @param message オーラダメージを受けた際のメッセージ
599  */
600 static void process_aura_damage(MonsterEntity *m_ptr, PlayerType *player_ptr, bool immune, MonsterAuraType aura_flag, dam_func dam_func, concptr message)
601 {
602     auto *r_ptr = &m_ptr->get_monrace();
603     if (r_ptr->aura_flags.has_not(aura_flag) || immune) {
604         return;
605     }
606
607     int aura_damage = Dice::roll(1 + (r_ptr->level / 26), 1 + (r_ptr->level / 17));
608     msg_print(message);
609     (*dam_func)(player_ptr, aura_damage, monster_desc(player_ptr, m_ptr, MD_WRONGDOER_NAME).data(), true);
610     if (is_original_ap_and_seen(player_ptr, m_ptr)) {
611         r_ptr->r_aura_flags.set(aura_flag);
612     }
613
614     handle_stuff(player_ptr);
615 }
616
617 /*!
618  * @brief 敵オーラによるプレイヤーのダメージ処理
619  * @param m_ptr オーラを持つモンスターの構造体参照ポインタ
620  * @param player_ptr プレイヤーへの参照ポインタ
621  */
622 void touch_zap_player(MonsterEntity *m_ptr, PlayerType *player_ptr)
623 {
624     constexpr auto fire_mes = _("突然とても熱くなった!", "You are suddenly very hot!");
625     constexpr auto cold_mes = _("突然とても寒くなった!", "You are suddenly very cold!");
626     constexpr auto elec_mes = _("電撃をくらった!", "You get zapped!");
627     process_aura_damage(m_ptr, player_ptr, has_immune_fire(player_ptr) != 0, MonsterAuraType::FIRE, fire_dam, fire_mes);
628     process_aura_damage(m_ptr, player_ptr, has_immune_cold(player_ptr) != 0, MonsterAuraType::COLD, cold_dam, cold_mes);
629     process_aura_damage(m_ptr, player_ptr, has_immune_elec(player_ptr) != 0, MonsterAuraType::ELEC, elec_dam, elec_mes);
630 }