OSDN Git Service

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