OSDN Git Service

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