OSDN Git Service

[Refactor] #40514 immune_cold は has_immune_cold() を直接参照. / For immune_cold, directly...
[hengband/hengband.git] / src / object / warning.c
1 #include "object/warning.h"
2 #include "art-definition/art-sword-types.h"
3 #include "core/asking-player.h"
4 #include "core/disturbance.h"
5 #include "dungeon/dungeon-flag-types.h"
6 #include "dungeon/dungeon.h"
7 #include "flavor/flavor-describer.h"
8 #include "flavor/object-flavor-types.h"
9 #include "floor/cave.h"
10 #include "game-option/input-options.h"
11 #include "grid/feature.h"
12 #include "grid/grid.h"
13 #include "inventory/inventory-slot-types.h"
14 #include "monster-attack/monster-attack-effect.h"
15 #include "monster-attack/monster-attack-types.h"
16 #include "monster-race/monster-race.h"
17 #include "monster-race/race-flags-ability1.h"
18 #include "monster-race/race-flags-ability2.h"
19 #include "monster-race/race-flags1.h"
20 #include "monster-race/race-flags4.h"
21 #include "monster-race/race-indice-types.h"
22 #include "monster/monster-info.h"
23 #include "monster/monster-status.h"
24 #include "mspell/mspell-damage-calculator.h"
25 #include "mspell/mspell-type.h"
26 #include "mutation/mutation-flag-types.h"
27 #include "object-enchant/tr-types.h"
28 #include "object/object-flags.h"
29 #include "player/mimic-info-table.h"
30 #include "player/player-class.h"
31 #include "player/player-race-types.h"
32 #include "player/special-defense-types.h"
33 #include "player/player-status-flags.h"
34 #include "spell/spell-types.h"
35 #include "status/element-resistance.h"
36 #include "system/floor-type-definition.h"
37 #include "target/projection-path-calculator.h"
38 #include "util/bit-flags-calculator.h"
39 #include "view/display-messages.h"
40
41 /*!
42  * @brief 警告を放つアイテムを選択する /
43  * Choose one of items that have warning flag
44  * Calculate spell damages
45  * @return 警告を行う
46  */
47 object_type *choose_warning_item(player_type *creature_ptr)
48 {
49     int choices[INVEN_TOTAL - INVEN_RARM];
50
51     /* Paranoia -- Player has no warning ability */
52     if (!creature_ptr->warning)
53         return NULL;
54
55     /* Search Inventory */
56     int number = 0;
57     for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
58         BIT_FLAGS flgs[TR_FLAG_SIZE];
59         object_type *o_ptr = &creature_ptr->inventory_list[i];
60
61         object_flags(creature_ptr, o_ptr, flgs);
62         if (has_flag(flgs, TR_WARNING)) {
63             choices[number] = i;
64             number++;
65         }
66     }
67
68     /* Choice one of them */
69     return number ? &creature_ptr->inventory_list[choices[randint0(number)]] : NULL;
70 }
71
72 /*!
73  * @brief 警告基準を定めるために魔法の効果属性に基づいて最大魔法ダメージを計算する /
74  * Calculate spell damages
75  * @param m_ptr 魔法を行使するモンスターの構造体参照ポインタ
76  * @param typ 効果属性のID
77  * @param dam 基本ダメージ
78  * @param max 算出した最大ダメージを返すポインタ
79  * @return なし
80  */
81 static void spell_damcalc(player_type *target_ptr, monster_type *m_ptr, EFFECT_ID typ, HIT_POINT dam, int *max)
82 {
83     monster_race *r_ptr = &r_info[m_ptr->r_idx];
84     int rlev = r_ptr->level;
85     bool ignore_wraith_form = FALSE;
86
87     /* Vulnerability, resistance and immunity */
88     switch (typ) {
89     case GF_ELEC:
90         if (has_immune_elec(target_ptr)) {
91             dam = 0;
92             ignore_wraith_form = TRUE;
93             break;
94         }
95
96         if (target_ptr->muta3 & MUT3_VULN_ELEM)
97             dam *= 2;
98         if (target_ptr->special_defense & KATA_KOUKIJIN)
99             dam += dam / 3;
100         if (is_specific_player_race(target_ptr, RACE_ANDROID))
101             dam += dam / 3;
102         if (target_ptr->resist_elec)
103             dam = (dam + 2) / 3;
104         if (is_oppose_elec(target_ptr))
105             dam = (dam + 2) / 3;
106         break;
107
108     case GF_POIS:
109         if (target_ptr->resist_pois)
110             dam = (dam + 2) / 3;
111         if (is_oppose_pois(target_ptr))
112             dam = (dam + 2) / 3;
113         break;
114
115     case GF_ACID:
116         if (has_immune_acid(target_ptr)) {
117             dam = 0;
118             ignore_wraith_form = TRUE;
119             break;
120         }
121
122         if (target_ptr->muta3 & MUT3_VULN_ELEM)
123             dam *= 2;
124         if (target_ptr->special_defense & KATA_KOUKIJIN)
125             dam += dam / 3;
126         if (target_ptr->resist_acid)
127             dam = (dam + 2) / 3;
128         if (is_oppose_acid(target_ptr))
129             dam = (dam + 2) / 3;
130         break;
131
132     case GF_COLD:
133     case GF_ICE:
134         if (has_immune_cold(target_ptr)) {
135             dam = 0;
136             ignore_wraith_form = TRUE;
137             break;
138         }
139
140         if (target_ptr->muta3 & MUT3_VULN_ELEM)
141             dam *= 2;
142         if (target_ptr->special_defense & KATA_KOUKIJIN)
143             dam += dam / 3;
144         if (target_ptr->resist_cold)
145             dam = (dam + 2) / 3;
146         if (is_oppose_cold(target_ptr))
147             dam = (dam + 2) / 3;
148         break;
149
150     case GF_FIRE:
151         if (has_immune_fire(target_ptr)) {
152             dam = 0;
153             ignore_wraith_form = TRUE;
154             break;
155         }
156
157         if (target_ptr->muta3 & MUT3_VULN_ELEM)
158             dam *= 2;
159         if (is_specific_player_race(target_ptr, RACE_ENT))
160             dam += dam / 3;
161         if (target_ptr->special_defense & KATA_KOUKIJIN)
162             dam += dam / 3;
163         if (target_ptr->resist_fire)
164             dam = (dam + 2) / 3;
165         if (is_oppose_fire(target_ptr))
166             dam = (dam + 2) / 3;
167         break;
168
169     case GF_PSY_SPEAR:
170         ignore_wraith_form = TRUE;
171         break;
172
173     case GF_ARROW:
174         if (!target_ptr->blind
175             && ((target_ptr->inventory_list[INVEN_RARM].k_idx && (target_ptr->inventory_list[INVEN_RARM].name1 == ART_ZANTETSU))
176                 || (target_ptr->inventory_list[INVEN_LARM].k_idx && (target_ptr->inventory_list[INVEN_LARM].name1 == ART_ZANTETSU)))) {
177             dam = 0;
178             ignore_wraith_form = TRUE;
179         }
180
181         break;
182
183     case GF_LITE:
184         if (target_ptr->resist_lite)
185             dam /= 2; /* Worst case of 4 / (d4 + 7) */
186         if (is_specific_player_race(target_ptr, RACE_VAMPIRE) || (target_ptr->mimic_form == MIMIC_VAMPIRE))
187             dam *= 2;
188         else if (is_specific_player_race(target_ptr, RACE_S_FAIRY))
189             dam = dam * 4 / 3;
190
191         if (target_ptr->wraith_form)
192             dam *= 2;
193         break;
194
195     case GF_DARK:
196         if (is_specific_player_race(target_ptr, RACE_VAMPIRE) || (target_ptr->mimic_form == MIMIC_VAMPIRE) || target_ptr->wraith_form) {
197             dam = 0;
198             ignore_wraith_form = TRUE;
199         } else if (target_ptr->resist_dark)
200             dam /= 2; /* Worst case of 4 / (d4 + 7) */
201         break;
202
203     case GF_SHARDS:
204         if (target_ptr->resist_shard)
205             dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
206         break;
207
208     case GF_SOUND:
209         if (target_ptr->resist_sound)
210             dam = dam * 5 / 8; /* Worst case of 5 / (d4 + 7) */
211         break;
212
213     case GF_CONFUSION:
214         if (target_ptr->resist_conf)
215             dam = dam * 5 / 8; /* Worst case of 5 / (d4 + 7) */
216         break;
217
218     case GF_CHAOS:
219         if (target_ptr->resist_chaos)
220             dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
221         break;
222
223     case GF_NETHER:
224         if (is_specific_player_race(target_ptr, RACE_SPECTRE)) {
225             dam = 0;
226             ignore_wraith_form = TRUE;
227         } else if (target_ptr->resist_neth)
228             dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
229         break;
230
231     case GF_DISENCHANT:
232         if (target_ptr->resist_disen)
233             dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
234         break;
235
236     case GF_NEXUS:
237         if (target_ptr->resist_nexus)
238             dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
239         break;
240
241     case GF_TIME:
242         if (target_ptr->resist_time)
243             dam /= 2; /* Worst case of 4 / (d4 + 7) */
244         break;
245
246     case GF_GRAVITY:
247         if (target_ptr->levitation)
248             dam = (dam * 2) / 3;
249         break;
250
251     case GF_ROCKET:
252         if (target_ptr->resist_shard)
253             dam /= 2;
254         break;
255
256     case GF_NUKE:
257         if (target_ptr->resist_pois)
258             dam = (2 * dam + 2) / 5;
259         if (is_oppose_pois(target_ptr))
260             dam = (2 * dam + 2) / 5;
261         break;
262
263     case GF_DEATH_RAY:
264         if (target_ptr->mimic_form) {
265             if (mimic_info[target_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_NONLIVING) {
266                 dam = 0;
267                 ignore_wraith_form = TRUE;
268             }
269
270             break;
271         }
272
273         switch (target_ptr->prace) {
274         case RACE_GOLEM:
275         case RACE_SKELETON:
276         case RACE_ZOMBIE:
277         case RACE_VAMPIRE:
278         case RACE_BALROG:
279         case RACE_SPECTRE:
280             dam = 0;
281             ignore_wraith_form = TRUE;
282             break;
283         }
284
285         break;
286
287     case GF_HOLY_FIRE:
288         if (target_ptr->align > 10)
289             dam /= 2;
290         else if (target_ptr->align < -10)
291             dam *= 2;
292         break;
293
294     case GF_HELL_FIRE:
295         if (target_ptr->align > 10)
296             dam *= 2;
297         break;
298
299     case GF_MIND_BLAST:
300     case GF_BRAIN_SMASH:
301         if (100 + rlev / 2 <= MAX(5, target_ptr->skill_sav)) {
302             dam = 0;
303             ignore_wraith_form = TRUE;
304         }
305
306         break;
307
308     case GF_CAUSE_1:
309     case GF_CAUSE_2:
310     case GF_CAUSE_3:
311     case GF_HAND_DOOM:
312         if (100 + rlev / 2 <= target_ptr->skill_sav) {
313             dam = 0;
314             ignore_wraith_form = TRUE;
315         }
316
317         break;
318
319     case GF_CAUSE_4:
320         if ((100 + rlev / 2 <= target_ptr->skill_sav) && (m_ptr->r_idx != MON_KENSHIROU)) {
321             dam = 0;
322             ignore_wraith_form = TRUE;
323         }
324
325         break;
326     }
327
328     if (target_ptr->wraith_form && !ignore_wraith_form) {
329         dam /= 2;
330         if (!dam)
331             dam = 1;
332     }
333
334     if (dam > *max)
335         *max = dam;
336 }
337
338 /*!
339  * @brief 警告基準を定めるために魔法の効果属性に基づいて最大魔法ダメージを計算する。 /
340  * Calculate spell damages
341  * @param spell_num RF4ならRF4_SPELL_STARTのように32区切りのベースとなる数値
342  * @param typ 効果属性のID
343  * @param m_idx 魔法を行使するモンスターのID
344  * @param max 算出した最大ダメージを返すポインタ
345  * @return なし
346  */
347 void spell_damcalc_by_spellnum(player_type *creature_ptr, monster_spell_type ms_type, EFFECT_ID typ, MONSTER_IDX m_idx, int *max)
348 {
349     monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[m_idx];
350     HIT_POINT dam = monspell_damage(creature_ptr, ms_type, m_idx, DAM_MAX);
351     spell_damcalc(creature_ptr, m_ptr, typ, dam, max);
352 }
353
354 /*!
355  * @brief 警告基準を定めるためにモンスターの打撃最大ダメージを算出する /
356  * Calculate blow damages
357  * @param m_ptr 打撃を行使するモンスターの構造体参照ポインタ
358  * @param blow_ptr モンスターの打撃能力の構造体参照ポインタ
359  * @return 算出された最大ダメージを返す。
360  */
361 static int blow_damcalc(monster_type *m_ptr, player_type *target_ptr, monster_blow *blow_ptr)
362 {
363     int dam = blow_ptr->d_dice * blow_ptr->d_side;
364     int dummy_max = 0;
365
366     if (blow_ptr->method == RBM_EXPLODE) {
367         dam = (dam + 1) / 2;
368         spell_damcalc(target_ptr, m_ptr, mbe_info[blow_ptr->effect].explode_type, dam, &dummy_max);
369         dam = dummy_max;
370         return dam;
371     }
372
373     ARMOUR_CLASS ac = target_ptr->ac + target_ptr->to_a;
374     bool check_wraith_form = TRUE;
375     switch (blow_ptr->effect) {
376     case RBE_SUPERHURT: {
377         int tmp_dam = dam - (dam * ((ac < 150) ? ac : 150) / 250);
378         dam = MAX(dam, tmp_dam * 2);
379         break;
380     }
381
382     case RBE_HURT:
383     case RBE_SHATTER:
384         dam -= (dam * ((ac < 150) ? ac : 150) / 250);
385         break;
386
387     case RBE_ACID:
388         spell_damcalc(target_ptr, m_ptr, GF_ACID, dam, &dummy_max);
389         dam = dummy_max;
390         check_wraith_form = FALSE;
391         break;
392
393     case RBE_ELEC:
394         spell_damcalc(target_ptr, m_ptr, GF_ELEC, dam, &dummy_max);
395         dam = dummy_max;
396         check_wraith_form = FALSE;
397         break;
398
399     case RBE_FIRE:
400         spell_damcalc(target_ptr, m_ptr, GF_FIRE, dam, &dummy_max);
401         dam = dummy_max;
402         check_wraith_form = FALSE;
403         break;
404
405     case RBE_COLD:
406         spell_damcalc(target_ptr, m_ptr, GF_COLD, dam, &dummy_max);
407         dam = dummy_max;
408         check_wraith_form = FALSE;
409         break;
410
411     case RBE_DR_MANA:
412         dam = 0;
413         check_wraith_form = FALSE;
414         break;
415     }
416
417     if (check_wraith_form && target_ptr->wraith_form) {
418         dam /= 2;
419         if (!dam)
420             dam = 1;
421     }
422
423     return dam;
424 }
425
426 /*!
427  * @brief プレイヤーが特定地点へ移動した場合に警告を発する処理 /
428  * Examine the grid (xx,yy) and warn the player if there are any danger
429  * @param xx 危険性を調査するマスのX座標
430  * @param yy 危険性を調査するマスのY座標
431  * @return 警告を無視して進むことを選択するかか問題が無ければTRUE、警告に従ったならFALSEを返す。
432  */
433 bool process_warning(player_type *creature_ptr, POSITION xx, POSITION yy)
434 {
435     POSITION mx, my;
436     grid_type *g_ptr;
437     GAME_TEXT o_name[MAX_NLEN];
438
439 #define WARNING_AWARE_RANGE 12
440     int dam_max = 0;
441     static int old_damage = 0;
442
443     for (mx = xx - WARNING_AWARE_RANGE; mx < xx + WARNING_AWARE_RANGE + 1; mx++) {
444         for (my = yy - WARNING_AWARE_RANGE; my < yy + WARNING_AWARE_RANGE + 1; my++) {
445             int dam_max0 = 0;
446             monster_type *m_ptr;
447             monster_race *r_ptr;
448
449             if (!in_bounds(creature_ptr->current_floor_ptr, my, mx) || (distance(my, mx, yy, xx) > WARNING_AWARE_RANGE))
450                 continue;
451
452             g_ptr = &creature_ptr->current_floor_ptr->grid_array[my][mx];
453
454             if (!g_ptr->m_idx)
455                 continue;
456
457             m_ptr = &creature_ptr->current_floor_ptr->m_list[g_ptr->m_idx];
458
459             if (monster_csleep_remaining(m_ptr))
460                 continue;
461             if (!is_hostile(m_ptr))
462                 continue;
463
464             r_ptr = &r_info[m_ptr->r_idx];
465
466             /* Monster spells (only powerful ones)*/
467             if (projectable(creature_ptr, my, mx, yy, xx)) {
468                 BIT_FLAGS f4 = r_ptr->flags4;
469                 BIT_FLAGS f5 = r_ptr->a_ability_flags1;
470                 BIT_FLAGS f6 = r_ptr->a_ability_flags2;
471
472                 if (!(d_info[creature_ptr->dungeon_idx].flags1 & DF1_NO_MAGIC)) {
473                     if (f4 & RF4_BA_CHAO)
474                         spell_damcalc_by_spellnum(creature_ptr, MS_BALL_CHAOS, GF_CHAOS, g_ptr->m_idx, &dam_max0);
475                     if (f5 & RF5_BA_MANA)
476                         spell_damcalc_by_spellnum(creature_ptr, MS_BALL_MANA, GF_MANA, g_ptr->m_idx, &dam_max0);
477                     if (f5 & RF5_BA_DARK)
478                         spell_damcalc_by_spellnum(creature_ptr, MS_BALL_DARK, GF_DARK, g_ptr->m_idx, &dam_max0);
479                     if (f5 & RF5_BA_LITE)
480                         spell_damcalc_by_spellnum(creature_ptr, MS_STARBURST, GF_LITE, g_ptr->m_idx, &dam_max0);
481                     if (f6 & RF6_HAND_DOOM)
482                         spell_damcalc_by_spellnum(creature_ptr, MS_HAND_DOOM, GF_HAND_DOOM, g_ptr->m_idx, &dam_max0);
483                     if (f6 & RF6_PSY_SPEAR)
484                         spell_damcalc_by_spellnum(creature_ptr, MS_PSY_SPEAR, GF_PSY_SPEAR, g_ptr->m_idx, &dam_max0);
485                 }
486
487                 if (f4 & RF4_ROCKET)
488                     spell_damcalc_by_spellnum(creature_ptr, MS_ROCKET, GF_ROCKET, g_ptr->m_idx, &dam_max0);
489                 if (f4 & RF4_BR_ACID)
490                     spell_damcalc_by_spellnum(creature_ptr, MS_BR_ACID, GF_ACID, g_ptr->m_idx, &dam_max0);
491                 if (f4 & RF4_BR_ELEC)
492                     spell_damcalc_by_spellnum(creature_ptr, MS_BR_ELEC, GF_ELEC, g_ptr->m_idx, &dam_max0);
493                 if (f4 & RF4_BR_FIRE)
494                     spell_damcalc_by_spellnum(creature_ptr, MS_BR_FIRE, GF_FIRE, g_ptr->m_idx, &dam_max0);
495                 if (f4 & RF4_BR_COLD)
496                     spell_damcalc_by_spellnum(creature_ptr, MS_BR_COLD, GF_COLD, g_ptr->m_idx, &dam_max0);
497                 if (f4 & RF4_BR_POIS)
498                     spell_damcalc_by_spellnum(creature_ptr, MS_BR_POIS, GF_POIS, g_ptr->m_idx, &dam_max0);
499                 if (f4 & RF4_BR_NETH)
500                     spell_damcalc_by_spellnum(creature_ptr, MS_BR_NETHER, GF_NETHER, g_ptr->m_idx, &dam_max0);
501                 if (f4 & RF4_BR_LITE)
502                     spell_damcalc_by_spellnum(creature_ptr, MS_BR_LITE, GF_LITE, g_ptr->m_idx, &dam_max0);
503                 if (f4 & RF4_BR_DARK)
504                     spell_damcalc_by_spellnum(creature_ptr, MS_BR_DARK, GF_DARK, g_ptr->m_idx, &dam_max0);
505                 if (f4 & RF4_BR_CONF)
506                     spell_damcalc_by_spellnum(creature_ptr, MS_BR_CONF, GF_CONFUSION, g_ptr->m_idx, &dam_max0);
507                 if (f4 & RF4_BR_SOUN)
508                     spell_damcalc_by_spellnum(creature_ptr, MS_BR_SOUND, GF_SOUND, g_ptr->m_idx, &dam_max0);
509                 if (f4 & RF4_BR_CHAO)
510                     spell_damcalc_by_spellnum(creature_ptr, MS_BR_CHAOS, GF_CHAOS, g_ptr->m_idx, &dam_max0);
511                 if (f4 & RF4_BR_DISE)
512                     spell_damcalc_by_spellnum(creature_ptr, MS_BR_DISEN, GF_DISENCHANT, g_ptr->m_idx, &dam_max0);
513                 if (f4 & RF4_BR_NEXU)
514                     spell_damcalc_by_spellnum(creature_ptr, MS_BR_NEXUS, GF_NEXUS, g_ptr->m_idx, &dam_max0);
515                 if (f4 & RF4_BR_TIME)
516                     spell_damcalc_by_spellnum(creature_ptr, MS_BR_TIME, GF_TIME, g_ptr->m_idx, &dam_max0);
517                 if (f4 & RF4_BR_INER)
518                     spell_damcalc_by_spellnum(creature_ptr, MS_BR_INERTIA, GF_INERTIAL, g_ptr->m_idx, &dam_max0);
519                 if (f4 & RF4_BR_GRAV)
520                     spell_damcalc_by_spellnum(creature_ptr, MS_BR_GRAVITY, GF_GRAVITY, g_ptr->m_idx, &dam_max0);
521                 if (f4 & RF4_BR_SHAR)
522                     spell_damcalc_by_spellnum(creature_ptr, MS_BR_SHARDS, GF_SHARDS, g_ptr->m_idx, &dam_max0);
523                 if (f4 & RF4_BR_PLAS)
524                     spell_damcalc_by_spellnum(creature_ptr, MS_BR_PLASMA, GF_PLASMA, g_ptr->m_idx, &dam_max0);
525                 if (f4 & RF4_BR_WALL)
526                     spell_damcalc_by_spellnum(creature_ptr, MS_BR_FORCE, GF_FORCE, g_ptr->m_idx, &dam_max0);
527                 if (f4 & RF4_BR_MANA)
528                     spell_damcalc_by_spellnum(creature_ptr, MS_BR_MANA, GF_MANA, g_ptr->m_idx, &dam_max0);
529                 if (f4 & RF4_BR_NUKE)
530                     spell_damcalc_by_spellnum(creature_ptr, MS_BR_NUKE, GF_NUKE, g_ptr->m_idx, &dam_max0);
531                 if (f4 & RF4_BR_DISI)
532                     spell_damcalc_by_spellnum(creature_ptr, MS_BR_DISI, GF_DISINTEGRATE, g_ptr->m_idx, &dam_max0);
533             }
534
535             /* Monster melee attacks */
536             if ((r_ptr->flags1 & RF1_NEVER_BLOW) || (d_info[creature_ptr->dungeon_idx].flags1 & DF1_NO_MELEE)) {
537                 dam_max += dam_max0;
538                 continue;
539             }
540
541             if (!(mx <= xx + 1 && mx >= xx - 1 && my <= yy + 1 && my >= yy - 1)) {
542                 dam_max += dam_max0;
543                 continue;
544             }
545
546             int dam_melee = 0;
547             for (int m = 0; m < 4; m++) {
548                 /* Skip non-attacks */
549                 if (!r_ptr->blow[m].method || (r_ptr->blow[m].method == RBM_SHOOT))
550                     continue;
551
552                 /* Extract the attack info */
553                 dam_melee += blow_damcalc(m_ptr, creature_ptr, &r_ptr->blow[m]);
554                 if (r_ptr->blow[m].method == RBM_EXPLODE)
555                     break;
556             }
557
558             if (dam_melee > dam_max0)
559                 dam_max0 = dam_melee;
560             dam_max += dam_max0;
561         }
562     }
563
564     /* Prevent excessive warning */
565     if (dam_max > old_damage) {
566         old_damage = dam_max * 3 / 2;
567
568         if (dam_max > creature_ptr->chp / 2) {
569             object_type *o_ptr = choose_warning_item(creature_ptr);
570
571             if (o_ptr)
572                 describe_flavor(creature_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
573             else
574                 strcpy(o_name, _("体", "body")); /* Warning ability without item */
575             msg_format(_("%sが鋭く震えた!", "Your %s pulsates sharply!"), o_name);
576
577             disturb(creature_ptr, FALSE, TRUE);
578             return get_check(_("本当にこのまま進むか?", "Really want to go ahead? "));
579         }
580     } else
581         old_damage = old_damage / 2;
582
583     g_ptr = &creature_ptr->current_floor_ptr->grid_array[yy][xx];
584     bool is_warning = (!easy_disarm && is_trap(creature_ptr, g_ptr->feat)) || (g_ptr->mimic && is_trap(creature_ptr, g_ptr->feat));
585     is_warning &= !one_in_(13);
586     if (!is_warning)
587         return TRUE;
588
589     object_type *o_ptr = choose_warning_item(creature_ptr);
590     if (o_ptr != NULL)
591         describe_flavor(creature_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
592     else
593         strcpy(o_name, _("体", "body")); /* Warning ability without item */
594     msg_format(_("%sが鋭く震えた!", "Your %s pulsates sharply!"), o_name);
595     disturb(creature_ptr, FALSE, TRUE);
596     return get_check(_("本当にこのまま進むか?", "Really want to go ahead? "));
597 }