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