OSDN Git Service

[Refactor] #3677 object_known() をItemEntity のオブジェクトメソッドに繰り込んだ
[hengbandforosx/hengbandosx.git] / src / object / warning.cpp
1 #include "object/warning.h"
2 #include "artifact/fixed-art-types.h"
3 #include "core/asking-player.h"
4 #include "core/disturbance.h"
5 #include "dungeon/dungeon-flag-types.h"
6 #include "flavor/flavor-describer.h"
7 #include "flavor/object-flavor-types.h"
8 #include "floor/cave.h"
9 #include "floor/geometry.h"
10 #include "game-option/input-options.h"
11 #include "grid/feature.h"
12 #include "inventory/inventory-slot-types.h"
13 #include "monster-attack/monster-attack-effect.h"
14 #include "monster-attack/monster-attack-table.h"
15 #include "monster-race/monster-race.h"
16 #include "monster-race/race-ability-flags.h"
17 #include "monster-race/race-flags1.h"
18 #include "monster-race/race-indice-types.h"
19 #include "monster/monster-info.h"
20 #include "monster/monster-status.h"
21 #include "mspell/mspell-damage-calculator.h"
22 #include "mutation/mutation-flag-types.h"
23 #include "object-enchant/tr-types.h"
24 #include "player-base/player-race.h"
25 #include "player/player-status-flags.h"
26 #include "player/player-status-resist.h"
27 #include "player/special-defense-types.h"
28 #include "status/element-resistance.h"
29 #include "system/dungeon-info.h"
30 #include "system/floor-type-definition.h"
31 #include "system/grid-type-definition.h"
32 #include "system/item-entity.h"
33 #include "system/monster-entity.h"
34 #include "system/monster-race-info.h"
35 #include "system/player-type-definition.h"
36 #include "target/projection-path-calculator.h"
37 #include "timed-effect/player-blindness.h"
38 #include "timed-effect/timed-effects.h"
39 #include "util/bit-flags-calculator.h"
40 #include "view/display-messages.h"
41 #include <vector>
42
43 /*!
44  * @brief 警告を放つアイテムを選択する /
45  * Choose one of items that have warning flag
46  * Calculate spell damages
47  * @return 警告を行う
48  */
49 ItemEntity *choose_warning_item(PlayerType *player_ptr)
50 {
51     /* Paranoia -- Player has no warning ability */
52     if (!player_ptr->warning) {
53         return nullptr;
54     }
55
56     /* Search Inventory */
57     std::vector<int> candidates;
58     for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
59         const auto *o_ptr = &player_ptr->inventory_list[i];
60         if (o_ptr->get_flags().has(TR_WARNING)) {
61             candidates.push_back(i);
62         }
63     }
64
65     /* Choice one of them */
66     return candidates.empty() ? nullptr : &player_ptr->inventory_list[rand_choice(candidates)];
67 }
68
69 /*!
70  * @brief 警告基準を定めるために魔法の効果属性に基づいて最大魔法ダメージを計算する /
71  * Calculate spell damages
72  * @param m_ptr 魔法を行使するモンスターの構造体参照ポインタ
73  * @param typ 効果属性のID
74  * @param dam 基本ダメージ
75  * @param max 算出した最大ダメージを返すポインタ
76  */
77 static void spell_damcalc(PlayerType *player_ptr, MonsterEntity *m_ptr, AttributeType typ, int dam, int *max)
78 {
79     auto *r_ptr = &m_ptr->get_monrace();
80     int rlev = r_ptr->level;
81     bool ignore_wraith_form = false;
82
83     /* Vulnerability, resistance and immunity */
84     switch (typ) {
85     case AttributeType::ELEC:
86         if (has_immune_elec(player_ptr)) {
87             ignore_wraith_form = true;
88         }
89         dam = dam * calc_elec_damage_rate(player_ptr) / 100;
90         break;
91
92     case AttributeType::POIS:
93         dam = dam * calc_pois_damage_rate(player_ptr) / 100;
94         break;
95
96     case AttributeType::ACID:
97         if (has_immune_acid(player_ptr)) {
98             ignore_wraith_form = true;
99         }
100         dam = dam * calc_acid_damage_rate(player_ptr) / 100;
101         break;
102
103     case AttributeType::COLD:
104     case AttributeType::ICE:
105         if (has_immune_cold(player_ptr)) {
106             ignore_wraith_form = true;
107         }
108         dam = dam * calc_cold_damage_rate(player_ptr) / 100;
109         break;
110
111     case AttributeType::FIRE:
112         if (has_immune_fire(player_ptr)) {
113             ignore_wraith_form = true;
114         }
115         dam = dam * calc_fire_damage_rate(player_ptr) / 100;
116         break;
117
118     case AttributeType::PSY_SPEAR:
119         ignore_wraith_form = true;
120         break;
121
122     case AttributeType::MONSTER_SHOOT:
123         if (!player_ptr->effects()->blindness()->is_blind() && (has_invuln_arrow(player_ptr))) {
124             dam = 0;
125             ignore_wraith_form = true;
126         }
127         break;
128
129     case AttributeType::LITE:
130         dam = dam * calc_lite_damage_rate(player_ptr, CALC_MAX) / 100;
131         break;
132
133     case AttributeType::DARK:
134         dam = dam * calc_dark_damage_rate(player_ptr, CALC_MAX) / 100;
135         if (has_immune_dark(player_ptr) || player_ptr->wraith_form) {
136             ignore_wraith_form = true;
137         }
138         break;
139
140     case AttributeType::SHARDS:
141         dam = dam * calc_shards_damage_rate(player_ptr, CALC_MAX) / 100;
142         break;
143
144     case AttributeType::SOUND:
145         dam = dam * calc_sound_damage_rate(player_ptr, CALC_MAX) / 100;
146         break;
147
148     case AttributeType::CONFUSION:
149         dam = dam * calc_conf_damage_rate(player_ptr, CALC_MAX) / 100;
150         break;
151
152     case AttributeType::CHAOS:
153         dam = dam * calc_chaos_damage_rate(player_ptr, CALC_MAX) / 100;
154         break;
155
156     case AttributeType::NETHER:
157         dam = dam * calc_nether_damage_rate(player_ptr, CALC_MAX) / 100;
158         if (PlayerRace(player_ptr).equals(PlayerRaceType::SPECTRE)) {
159             ignore_wraith_form = true;
160             dam = 0;
161         }
162         break;
163
164     case AttributeType::DISENCHANT:
165         dam = dam * calc_disenchant_damage_rate(player_ptr, CALC_MAX) / 100;
166         break;
167
168     case AttributeType::NEXUS:
169         dam = dam * calc_nexus_damage_rate(player_ptr, CALC_MAX) / 100;
170         break;
171
172     case AttributeType::TIME:
173         dam = dam * calc_time_damage_rate(player_ptr, CALC_MAX) / 100;
174         break;
175
176     case AttributeType::GRAVITY:
177         dam = dam * calc_gravity_damage_rate(player_ptr, CALC_MAX) / 100;
178         break;
179
180     case AttributeType::ROCKET:
181         dam = dam * calc_rocket_damage_rate(player_ptr, CALC_MAX) / 100;
182         break;
183
184     case AttributeType::NUKE:
185         dam = dam * calc_nuke_damage_rate(player_ptr) / 100;
186         break;
187
188     case AttributeType::DEATH_RAY:
189         dam = dam * calc_deathray_damage_rate(player_ptr, CALC_MAX) / 100;
190         if (dam == 0) {
191             ignore_wraith_form = true;
192         }
193         break;
194
195     case AttributeType::HOLY_FIRE:
196         dam = dam * calc_holy_fire_damage_rate(player_ptr, CALC_MAX) / 100;
197         break;
198
199     case AttributeType::HELL_FIRE:
200         dam = dam * calc_hell_fire_damage_rate(player_ptr, CALC_MAX) / 100;
201         break;
202
203     case AttributeType::ABYSS:
204         dam = dam * calc_abyss_damage_rate(player_ptr, CALC_MAX) / 100;
205         break;
206
207     case AttributeType::VOID_MAGIC:
208         dam = dam * calc_void_damage_rate(player_ptr, CALC_MAX) / 100;
209         break;
210
211     case AttributeType::MIND_BLAST:
212     case AttributeType::BRAIN_SMASH:
213         if (100 + rlev / 2 <= std::max<short>(5, player_ptr->skill_sav)) {
214             dam = 0;
215             ignore_wraith_form = true;
216         }
217
218         break;
219
220     case AttributeType::CAUSE_1:
221     case AttributeType::CAUSE_2:
222     case AttributeType::CAUSE_3:
223     case AttributeType::HAND_DOOM:
224         if (100 + rlev / 2 <= player_ptr->skill_sav) {
225             dam = 0;
226             ignore_wraith_form = true;
227         }
228
229         break;
230
231     case AttributeType::CAUSE_4:
232         if ((100 + rlev / 2 <= player_ptr->skill_sav) && (m_ptr->r_idx != MonsterRaceId::KENSHIROU)) {
233             dam = 0;
234             ignore_wraith_form = true;
235         }
236
237         break;
238     default:
239         break;
240     }
241
242     if (player_ptr->wraith_form && !ignore_wraith_form) {
243         dam /= 2;
244         if (!dam) {
245             dam = 1;
246         }
247     }
248
249     if (dam > *max) {
250         *max = dam;
251     }
252 }
253
254 /*!
255  * @brief 警告基準を定めるために魔法の効果属性に基づいて最大魔法ダメージを計算する。 /
256  * Calculate spell damages
257  * @param spell_num RF4ならRF_ABILITY::SPELL_STARTのように32区切りのベースとなる数値
258  * @param typ 効果属性のID
259  * @param m_idx 魔法を行使するモンスターのID
260  * @param max 算出した最大ダメージを返すポインタ
261  */
262 static void spell_damcalc_by_spellnum(PlayerType *player_ptr, MonsterAbilityType ms_type, AttributeType typ, MONSTER_IDX m_idx, int *max)
263 {
264     auto *m_ptr = &player_ptr->current_floor_ptr->m_list[m_idx];
265     int dam = monspell_damage(player_ptr, ms_type, m_idx, DAM_MAX);
266     spell_damcalc(player_ptr, m_ptr, typ, dam, max);
267 }
268
269 /*!
270  * @brief 警告基準を定めるためにモンスターの打撃最大ダメージを算出する /
271  * Calculate blow damages
272  * @param m_ptr 打撃を行使するモンスターの構造体参照ポインタ
273  * @param blow モンスターの打撃能力の構造体参照
274  * @return 算出された最大ダメージを返す。
275  */
276 static int blow_damcalc(MonsterEntity *m_ptr, PlayerType *player_ptr, const MonsterBlow &blow)
277 {
278     int dam = blow.d_dice * blow.d_side;
279     int dummy_max = 0;
280
281     if (blow.method == RaceBlowMethodType::EXPLODE) {
282         dam = (dam + 1) / 2;
283         spell_damcalc(player_ptr, m_ptr, mbe_info[enum2i(blow.effect)].explode_type, dam, &dummy_max);
284         dam = dummy_max;
285         return dam;
286     }
287
288     ARMOUR_CLASS ac = player_ptr->ac + player_ptr->to_a;
289     bool check_wraith_form = true;
290     switch (blow.effect) {
291     case RaceBlowEffectType::SUPERHURT: {
292         int tmp_dam = dam - (dam * ((ac < 150) ? ac : 150) / 250);
293         dam = std::max(dam, tmp_dam * 2);
294         break;
295     }
296
297     case RaceBlowEffectType::HURT:
298     case RaceBlowEffectType::SHATTER:
299         dam -= (dam * ((ac < 150) ? ac : 150) / 250);
300         break;
301
302     case RaceBlowEffectType::ACID:
303         spell_damcalc(player_ptr, m_ptr, AttributeType::ACID, dam, &dummy_max);
304         dam = dummy_max;
305         check_wraith_form = false;
306         break;
307
308     case RaceBlowEffectType::ELEC:
309         spell_damcalc(player_ptr, m_ptr, AttributeType::ELEC, dam, &dummy_max);
310         dam = dummy_max;
311         check_wraith_form = false;
312         break;
313
314     case RaceBlowEffectType::FIRE:
315         spell_damcalc(player_ptr, m_ptr, AttributeType::FIRE, dam, &dummy_max);
316         dam = dummy_max;
317         check_wraith_form = false;
318         break;
319
320     case RaceBlowEffectType::COLD:
321         spell_damcalc(player_ptr, m_ptr, AttributeType::COLD, dam, &dummy_max);
322         dam = dummy_max;
323         check_wraith_form = false;
324         break;
325
326     case RaceBlowEffectType::DR_MANA:
327         dam = 0;
328         check_wraith_form = false;
329         break;
330
331     default:
332         break;
333     }
334
335     if (check_wraith_form && player_ptr->wraith_form) {
336         dam /= 2;
337         if (!dam) {
338             dam = 1;
339         }
340     }
341
342     return dam;
343 }
344
345 /*!
346  * @brief プレイヤーが特定地点へ移動した場合に警告を発する処理 /
347  * Examine the grid (xx,yy) and warn the player if there are any danger
348  * @param xx 危険性を調査するマスのX座標
349  * @param yy 危険性を調査するマスのY座標
350  * @return 警告を無視して進むことを選択するかか問題が無ければTRUE、警告に従ったならFALSEを返す。
351  */
352 bool process_warning(PlayerType *player_ptr, POSITION xx, POSITION yy)
353 {
354     POSITION mx, my;
355 #define WARNING_AWARE_RANGE 12
356     int dam_max = 0;
357     static int old_damage = 0;
358
359     auto &floor = *player_ptr->current_floor_ptr;
360     const auto &dungeon = floor.get_dungeon_definition();
361     for (mx = xx - WARNING_AWARE_RANGE; mx < xx + WARNING_AWARE_RANGE + 1; mx++) {
362         for (my = yy - WARNING_AWARE_RANGE; my < yy + WARNING_AWARE_RANGE + 1; my++) {
363             int dam_max0 = 0;
364             if (!in_bounds(&floor, my, mx) || (distance(my, mx, yy, xx) > WARNING_AWARE_RANGE)) {
365                 continue;
366             }
367
368             const auto *g_ptr = &floor.grid_array[my][mx];
369
370             if (!g_ptr->m_idx) {
371                 continue;
372             }
373
374             auto *m_ptr = &floor.m_list[g_ptr->m_idx];
375
376             if (m_ptr->is_asleep()) {
377                 continue;
378             }
379             if (!m_ptr->is_hostile()) {
380                 continue;
381             }
382
383             auto *r_ptr = &m_ptr->get_monrace();
384
385             /* Monster spells (only powerful ones)*/
386             if (projectable(player_ptr, my, mx, yy, xx)) {
387                 const auto flags = r_ptr->ability_flags;
388
389                 if (dungeon.flags.has_not(DungeonFeatureType::NO_MAGIC)) {
390                     if (flags.has(MonsterAbilityType::BA_CHAO)) {
391                         spell_damcalc_by_spellnum(player_ptr, MonsterAbilityType::BA_CHAO, AttributeType::CHAOS, g_ptr->m_idx, &dam_max0);
392                     }
393                     if (flags.has(MonsterAbilityType::BA_MANA)) {
394                         spell_damcalc_by_spellnum(player_ptr, MonsterAbilityType::BA_MANA, AttributeType::MANA, g_ptr->m_idx, &dam_max0);
395                     }
396                     if (flags.has(MonsterAbilityType::BA_DARK)) {
397                         spell_damcalc_by_spellnum(player_ptr, MonsterAbilityType::BA_DARK, AttributeType::DARK, g_ptr->m_idx, &dam_max0);
398                     }
399                     if (flags.has(MonsterAbilityType::BA_LITE)) {
400                         spell_damcalc_by_spellnum(player_ptr, MonsterAbilityType::BA_LITE, AttributeType::LITE, g_ptr->m_idx, &dam_max0);
401                     }
402                     if (flags.has(MonsterAbilityType::HAND_DOOM)) {
403                         spell_damcalc_by_spellnum(player_ptr, MonsterAbilityType::HAND_DOOM, AttributeType::HAND_DOOM, g_ptr->m_idx, &dam_max0);
404                     }
405                     if (flags.has(MonsterAbilityType::PSY_SPEAR)) {
406                         spell_damcalc_by_spellnum(player_ptr, MonsterAbilityType::PSY_SPEAR, AttributeType::PSY_SPEAR, g_ptr->m_idx, &dam_max0);
407                     }
408                     if (flags.has(MonsterAbilityType::BA_VOID)) {
409                         spell_damcalc_by_spellnum(player_ptr, MonsterAbilityType::BA_VOID, AttributeType::VOID_MAGIC, g_ptr->m_idx, &dam_max0);
410                     }
411                     if (flags.has(MonsterAbilityType::BA_ABYSS)) {
412                         spell_damcalc_by_spellnum(player_ptr, MonsterAbilityType::BA_ABYSS, AttributeType::ABYSS, g_ptr->m_idx, &dam_max0);
413                     }
414                 }
415
416                 if (flags.has(MonsterAbilityType::ROCKET)) {
417                     spell_damcalc_by_spellnum(player_ptr, MonsterAbilityType::ROCKET, AttributeType::ROCKET, g_ptr->m_idx, &dam_max0);
418                 }
419                 if (flags.has(MonsterAbilityType::BR_ACID)) {
420                     spell_damcalc_by_spellnum(player_ptr, MonsterAbilityType::BR_ACID, AttributeType::ACID, g_ptr->m_idx, &dam_max0);
421                 }
422                 if (flags.has(MonsterAbilityType::BR_ELEC)) {
423                     spell_damcalc_by_spellnum(player_ptr, MonsterAbilityType::BR_ELEC, AttributeType::ELEC, g_ptr->m_idx, &dam_max0);
424                 }
425                 if (flags.has(MonsterAbilityType::BR_FIRE)) {
426                     spell_damcalc_by_spellnum(player_ptr, MonsterAbilityType::BR_FIRE, AttributeType::FIRE, g_ptr->m_idx, &dam_max0);
427                 }
428                 if (flags.has(MonsterAbilityType::BR_COLD)) {
429                     spell_damcalc_by_spellnum(player_ptr, MonsterAbilityType::BR_COLD, AttributeType::COLD, g_ptr->m_idx, &dam_max0);
430                 }
431                 if (flags.has(MonsterAbilityType::BR_POIS)) {
432                     spell_damcalc_by_spellnum(player_ptr, MonsterAbilityType::BR_POIS, AttributeType::POIS, g_ptr->m_idx, &dam_max0);
433                 }
434                 if (flags.has(MonsterAbilityType::BR_NETH)) {
435                     spell_damcalc_by_spellnum(player_ptr, MonsterAbilityType::BR_NETH, AttributeType::NETHER, g_ptr->m_idx, &dam_max0);
436                 }
437                 if (flags.has(MonsterAbilityType::BR_LITE)) {
438                     spell_damcalc_by_spellnum(player_ptr, MonsterAbilityType::BR_LITE, AttributeType::LITE, g_ptr->m_idx, &dam_max0);
439                 }
440                 if (flags.has(MonsterAbilityType::BR_DARK)) {
441                     spell_damcalc_by_spellnum(player_ptr, MonsterAbilityType::BR_DARK, AttributeType::DARK, g_ptr->m_idx, &dam_max0);
442                 }
443                 if (flags.has(MonsterAbilityType::BR_CONF)) {
444                     spell_damcalc_by_spellnum(player_ptr, MonsterAbilityType::BR_CONF, AttributeType::CONFUSION, g_ptr->m_idx, &dam_max0);
445                 }
446                 if (flags.has(MonsterAbilityType::BR_SOUN)) {
447                     spell_damcalc_by_spellnum(player_ptr, MonsterAbilityType::BR_SOUN, AttributeType::SOUND, g_ptr->m_idx, &dam_max0);
448                 }
449                 if (flags.has(MonsterAbilityType::BR_CHAO)) {
450                     spell_damcalc_by_spellnum(player_ptr, MonsterAbilityType::BR_CHAO, AttributeType::CHAOS, g_ptr->m_idx, &dam_max0);
451                 }
452                 if (flags.has(MonsterAbilityType::BR_DISE)) {
453                     spell_damcalc_by_spellnum(player_ptr, MonsterAbilityType::BR_DISE, AttributeType::DISENCHANT, g_ptr->m_idx, &dam_max0);
454                 }
455                 if (flags.has(MonsterAbilityType::BR_NEXU)) {
456                     spell_damcalc_by_spellnum(player_ptr, MonsterAbilityType::BR_NEXU, AttributeType::NEXUS, g_ptr->m_idx, &dam_max0);
457                 }
458                 if (flags.has(MonsterAbilityType::BR_TIME)) {
459                     spell_damcalc_by_spellnum(player_ptr, MonsterAbilityType::BR_TIME, AttributeType::TIME, g_ptr->m_idx, &dam_max0);
460                 }
461                 if (flags.has(MonsterAbilityType::BR_INER)) {
462                     spell_damcalc_by_spellnum(player_ptr, MonsterAbilityType::BR_INER, AttributeType::INERTIAL, g_ptr->m_idx, &dam_max0);
463                 }
464                 if (flags.has(MonsterAbilityType::BR_GRAV)) {
465                     spell_damcalc_by_spellnum(player_ptr, MonsterAbilityType::BR_GRAV, AttributeType::GRAVITY, g_ptr->m_idx, &dam_max0);
466                 }
467                 if (flags.has(MonsterAbilityType::BR_SHAR)) {
468                     spell_damcalc_by_spellnum(player_ptr, MonsterAbilityType::BR_SHAR, AttributeType::SHARDS, g_ptr->m_idx, &dam_max0);
469                 }
470                 if (flags.has(MonsterAbilityType::BR_PLAS)) {
471                     spell_damcalc_by_spellnum(player_ptr, MonsterAbilityType::BR_PLAS, AttributeType::PLASMA, g_ptr->m_idx, &dam_max0);
472                 }
473                 if (flags.has(MonsterAbilityType::BR_FORC)) {
474                     spell_damcalc_by_spellnum(player_ptr, MonsterAbilityType::BR_FORC, AttributeType::FORCE, g_ptr->m_idx, &dam_max0);
475                 }
476                 if (flags.has(MonsterAbilityType::BR_MANA)) {
477                     spell_damcalc_by_spellnum(player_ptr, MonsterAbilityType::BR_MANA, AttributeType::MANA, g_ptr->m_idx, &dam_max0);
478                 }
479                 if (flags.has(MonsterAbilityType::BR_NUKE)) {
480                     spell_damcalc_by_spellnum(player_ptr, MonsterAbilityType::BR_NUKE, AttributeType::NUKE, g_ptr->m_idx, &dam_max0);
481                 }
482                 if (flags.has(MonsterAbilityType::BR_DISI)) {
483                     spell_damcalc_by_spellnum(player_ptr, MonsterAbilityType::BR_DISI, AttributeType::DISINTEGRATE, g_ptr->m_idx, &dam_max0);
484                 }
485                 if (flags.has(MonsterAbilityType::BR_VOID)) {
486                     spell_damcalc_by_spellnum(player_ptr, MonsterAbilityType::BR_VOID, AttributeType::VOID_MAGIC, g_ptr->m_idx, &dam_max0);
487                 }
488                 if (flags.has(MonsterAbilityType::BR_ABYSS)) {
489                     spell_damcalc_by_spellnum(player_ptr, MonsterAbilityType::BR_ABYSS, AttributeType::ABYSS, g_ptr->m_idx, &dam_max0);
490                 }
491             }
492             /* Monster melee attacks */
493             if (r_ptr->behavior_flags.has(MonsterBehaviorType::NEVER_BLOW) || dungeon.flags.has(DungeonFeatureType::NO_MELEE)) {
494                 dam_max += dam_max0;
495                 continue;
496             }
497
498             if (!(mx <= xx + 1 && mx >= xx - 1 && my <= yy + 1 && my >= yy - 1)) {
499                 dam_max += dam_max0;
500                 continue;
501             }
502
503             int dam_melee = 0;
504             for (const auto &blow : r_ptr->blows) {
505                 /* Skip non-attacks */
506                 if (blow.method == RaceBlowMethodType::NONE || (blow.method == RaceBlowMethodType::SHOOT)) {
507                     continue;
508                 }
509
510                 /* Extract the attack info */
511                 dam_melee += blow_damcalc(m_ptr, player_ptr, blow);
512                 if (blow.method == RaceBlowMethodType::EXPLODE) {
513                     break;
514                 }
515             }
516
517             if (dam_melee > dam_max0) {
518                 dam_max0 = dam_melee;
519             }
520             dam_max += dam_max0;
521         }
522     }
523
524     /* Prevent excessive warning */
525     if (dam_max > old_damage) {
526         old_damage = dam_max * 3 / 2;
527
528         if (dam_max > player_ptr->chp / 2) {
529             auto *o_ptr = choose_warning_item(player_ptr);
530             std::string item_name;
531             if (o_ptr != nullptr) {
532                 item_name = describe_flavor(player_ptr, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
533             } else {
534                 item_name = _("体", "body");
535             }
536
537             msg_format(_("%sが鋭く震えた!", "Your %s pulsates sharply!"), item_name.data());
538
539             disturb(player_ptr, false, true);
540             return input_check(_("本当にこのまま進むか?", "Really want to go ahead? "));
541         }
542     } else {
543         old_damage = old_damage / 2;
544     }
545
546     auto *g_ptr = &floor.grid_array[yy][xx];
547     bool is_warning = (!easy_disarm && is_trap(player_ptr, g_ptr->feat)) || (g_ptr->mimic && is_trap(player_ptr, g_ptr->feat));
548     is_warning &= !one_in_(13);
549     if (!is_warning) {
550         return true;
551     }
552
553     auto *o_ptr = choose_warning_item(player_ptr);
554     std::string item_name;
555     if (o_ptr != nullptr) {
556         item_name = describe_flavor(player_ptr, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
557     } else {
558         item_name = _("体", "body");
559     }
560
561     msg_format(_("%sが鋭く震えた!", "Your %s pulsates sharply!"), item_name.data());
562     disturb(player_ptr, false, true);
563     return input_check(_("本当にこのまま進むか?", "Really want to go ahead? "));
564 }