OSDN Git Service

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