OSDN Git Service

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