5 #include "player-move.h"
8 #include "player-status.h"
12 * @brief 警告を放つアイテムを選択する /
13 * Choose one of items that have warning flag
14 * Calculate spell damages
17 object_type *choose_warning_item(void)
20 int choices[INVEN_TOTAL - INVEN_RARM];
23 /* Paranoia -- Player has no warning ability */
24 if (!p_ptr->warning) return NULL;
26 /* Search Inventory */
27 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
29 BIT_FLAGS flgs[TR_FLAG_SIZE];
30 object_type *o_ptr = &inventory[i];
32 object_flags(o_ptr, flgs);
33 if (have_flag(flgs, TR_WARNING))
40 /* Choice one of them */
41 return number ? &inventory[choices[randint0(number)]] : NULL;
45 * @brief 警告基準を定めるために魔法の効果属性に基づいて最大魔法ダメージを計算する /
46 * Calculate spell damages
47 * @param m_ptr 魔法を行使するモンスターの構造体参照ポインタ
50 * @param max 算出した最大ダメージを返すポインタ
53 static void spell_damcalc(monster_type *m_ptr, EFFECT_ID typ, HIT_POINT dam, int *max)
55 monster_race *r_ptr = &r_info[m_ptr->r_idx];
56 int rlev = r_ptr->level;
57 bool ignore_wraith_form = FALSE;
59 /* Vulnerability, resistance and immunity */
63 if (p_ptr->immune_elec)
66 ignore_wraith_form = TRUE;
70 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
71 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
72 if (prace_is_(RACE_ANDROID)) dam += dam / 3;
73 if (p_ptr->resist_elec) dam = (dam + 2) / 3;
80 if (p_ptr->resist_pois) dam = (dam + 2) / 3;
81 if (IS_OPPOSE_POIS()) dam = (dam + 2) / 3;
85 if (p_ptr->immune_acid)
88 ignore_wraith_form = TRUE;
92 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
93 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
94 if (p_ptr->resist_acid) dam = (dam + 2) / 3;
95 if (IS_OPPOSE_ACID()) dam = (dam + 2) / 3;
101 if (p_ptr->immune_cold)
104 ignore_wraith_form = TRUE;
108 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
109 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
110 if (p_ptr->resist_cold) dam = (dam + 2) / 3;
111 if (IS_OPPOSE_COLD()) dam = (dam + 2) / 3;
116 if (p_ptr->immune_fire)
119 ignore_wraith_form = TRUE;
123 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
124 if (prace_is_(RACE_ENT)) dam += dam / 3;
125 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
126 if (p_ptr->resist_fire) dam = (dam + 2) / 3;
127 if (IS_OPPOSE_FIRE()) dam = (dam + 2) / 3;
132 ignore_wraith_form = TRUE;
137 ((inventory[INVEN_RARM].k_idx && (inventory[INVEN_RARM].name1 == ART_ZANTETSU)) ||
138 (inventory[INVEN_LARM].k_idx && (inventory[INVEN_LARM].name1 == ART_ZANTETSU))))
141 ignore_wraith_form = TRUE;
146 if (p_ptr->resist_lite) dam /= 2; /* Worst case of 4 / (d4 + 7) */
147 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE)) dam *= 2;
148 else if (prace_is_(RACE_S_FAIRY)) dam = dam * 4 / 3;
151 * Cannot use "ignore_wraith_form" strictly (for "random one damage")
152 * "dam *= 2;" for later "dam /= 2"
154 if (p_ptr->wraith_form) dam *= 2;
158 if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE) || p_ptr->wraith_form)
161 ignore_wraith_form = TRUE;
163 else if (p_ptr->resist_dark) dam /= 2; /* Worst case of 4 / (d4 + 7) */
167 if (p_ptr->resist_shard) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
171 if (p_ptr->resist_sound) dam = dam * 5 / 8; /* Worst case of 5 / (d4 + 7) */
175 if (p_ptr->resist_conf) dam = dam * 5 / 8; /* Worst case of 5 / (d4 + 7) */
179 if (p_ptr->resist_chaos) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
183 if (prace_is_(RACE_SPECTRE))
186 ignore_wraith_form = TRUE;
188 else if (p_ptr->resist_neth) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
192 if (p_ptr->resist_disen) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
196 if (p_ptr->resist_nexus) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
200 if (p_ptr->resist_time) dam /= 2; /* Worst case of 4 / (d4 + 7) */
204 if (p_ptr->levitation) dam = (dam * 2) / 3;
208 if (p_ptr->resist_shard) dam /= 2;
212 if (p_ptr->resist_pois) dam = (2 * dam + 2) / 5;
213 if (IS_OPPOSE_POIS()) dam = (2 * dam + 2) / 5;
217 if (p_ptr->mimic_form)
219 if (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_NONLIVING)
222 ignore_wraith_form = TRUE;
227 switch (p_ptr->prace)
236 ignore_wraith_form = TRUE;
243 if (p_ptr->align > 10) dam /= 2;
244 else if (p_ptr->align < -10) dam *= 2;
248 if (p_ptr->align > 10) dam *= 2;
253 if (100 + rlev / 2 <= MAX(5, p_ptr->skill_sav))
256 ignore_wraith_form = TRUE;
264 if (100 + rlev / 2 <= p_ptr->skill_sav)
267 ignore_wraith_form = TRUE;
272 if ((100 + rlev / 2 <= p_ptr->skill_sav) && (m_ptr->r_idx != MON_KENSHIROU))
275 ignore_wraith_form = TRUE;
280 if (p_ptr->wraith_form && !ignore_wraith_form)
286 if (dam > *max) *max = dam;
290 * @brief 警告基準を定めるために魔法の効果属性に基づいて最大魔法ダメージを計算する。 /
291 * Calculate spell damages
292 * @param spell_num RF4ならRF4_SPELL_STARTのように32区切りのベースとなる数値
294 * @param m_idx 魔法を行使するモンスターのID
295 * @param max 算出した最大ダメージを返すポインタ
298 void spell_damcalc_by_spellnum(int spell_num, EFFECT_ID typ, MONSTER_IDX m_idx, int *max)
300 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
301 HIT_POINT dam = monspell_damage((spell_num), m_idx, DAM_MAX);
302 spell_damcalc(m_ptr, typ, dam, max);
306 * @brief 警告基準を定めるためにモンスターの打撃最大ダメージを算出する /
307 * Calculate blow damages
308 * @param m_ptr 打撃を行使するモンスターの構造体参照ポインタ
309 * @param blow_ptr モンスターの打撃能力の構造体参照ポインタ
310 * @return 算出された最大ダメージを返す。
312 static int blow_damcalc(monster_type *m_ptr, monster_blow *blow_ptr)
314 int dam = blow_ptr->d_dice * blow_ptr->d_side;
316 bool check_wraith_form = TRUE;
318 if (blow_ptr->method != RBM_EXPLODE)
320 ARMOUR_CLASS ac = p_ptr->ac + p_ptr->to_a;
322 switch (blow_ptr->effect)
326 int tmp_dam = dam - (dam * ((ac < 150) ? ac : 150) / 250);
327 dam = MAX(dam, tmp_dam * 2);
333 dam -= (dam * ((ac < 150) ? ac : 150) / 250);
337 spell_damcalc(m_ptr, GF_ACID, dam, &dummy_max);
339 check_wraith_form = FALSE;
343 spell_damcalc(m_ptr, GF_ELEC, dam, &dummy_max);
345 check_wraith_form = FALSE;
349 spell_damcalc(m_ptr, GF_FIRE, dam, &dummy_max);
351 check_wraith_form = FALSE;
355 spell_damcalc(m_ptr, GF_COLD, dam, &dummy_max);
357 check_wraith_form = FALSE;
362 check_wraith_form = FALSE;
366 if (check_wraith_form && p_ptr->wraith_form)
375 spell_damcalc(m_ptr, mbe_info[blow_ptr->effect].explode_type, dam, &dummy_max);
383 * @brief プレイヤーが特定地点へ移動した場合に警告を発する処理 /
384 * Examine the grid (xx,yy) and warn the player if there are any danger
385 * @param xx 危険性を調査するマスのX座標
386 * @param yy 危険性を調査するマスのY座標
387 * @return 警告を無視して進むことを選択するかか問題が無ければTRUE、警告に従ったならFALSEを返す。
389 bool process_warning(POSITION xx, POSITION yy)
393 GAME_TEXT o_name[MAX_NLEN];
395 #define WARNING_AWARE_RANGE 12
397 static int old_damage = 0;
399 for (mx = xx - WARNING_AWARE_RANGE; mx < xx + WARNING_AWARE_RANGE + 1; mx++)
401 for (my = yy - WARNING_AWARE_RANGE; my < yy + WARNING_AWARE_RANGE + 1; my++)
407 if (!in_bounds(my, mx) || (distance(my, mx, yy, xx) > WARNING_AWARE_RANGE)) continue;
409 g_ptr = ¤t_floor_ptr->grid_array[my][mx];
411 if (!g_ptr->m_idx) continue;
413 m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
415 if (MON_CSLEEP(m_ptr)) continue;
416 if (!is_hostile(m_ptr)) continue;
418 r_ptr = &r_info[m_ptr->r_idx];
420 /* Monster spells (only powerful ones)*/
421 if (projectable(my, mx, yy, xx))
423 BIT_FLAGS f4 = r_ptr->flags4;
424 BIT_FLAGS f5 = r_ptr->a_ability_flags1;
425 BIT_FLAGS f6 = r_ptr->a_ability_flags2;
427 if (!(d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_MAGIC))
429 if (f4 & RF4_BA_CHAO) spell_damcalc_by_spellnum(MS_BALL_CHAOS, GF_CHAOS, g_ptr->m_idx, &dam_max0);
430 if (f5 & RF5_BA_MANA) spell_damcalc_by_spellnum(MS_BALL_MANA, GF_MANA, g_ptr->m_idx, &dam_max0);
431 if (f5 & RF5_BA_DARK) spell_damcalc_by_spellnum(MS_BALL_DARK, GF_DARK, g_ptr->m_idx, &dam_max0);
432 if (f5 & RF5_BA_LITE) spell_damcalc_by_spellnum(MS_STARBURST, GF_LITE, g_ptr->m_idx, &dam_max0);
433 if (f6 & RF6_HAND_DOOM) spell_damcalc_by_spellnum(MS_HAND_DOOM, GF_HAND_DOOM, g_ptr->m_idx, &dam_max0);
434 if (f6 & RF6_PSY_SPEAR) spell_damcalc_by_spellnum(MS_PSY_SPEAR, GF_PSY_SPEAR, g_ptr->m_idx, &dam_max0);
436 if (f4 & RF4_ROCKET) spell_damcalc_by_spellnum(MS_ROCKET, GF_ROCKET, g_ptr->m_idx, &dam_max0);
437 if (f4 & RF4_BR_ACID) spell_damcalc_by_spellnum(MS_BR_ACID, GF_ACID, g_ptr->m_idx, &dam_max0);
438 if (f4 & RF4_BR_ELEC) spell_damcalc_by_spellnum(MS_BR_ELEC, GF_ELEC, g_ptr->m_idx, &dam_max0);
439 if (f4 & RF4_BR_FIRE) spell_damcalc_by_spellnum(MS_BR_FIRE, GF_FIRE, g_ptr->m_idx, &dam_max0);
440 if (f4 & RF4_BR_COLD) spell_damcalc_by_spellnum(MS_BR_COLD, GF_COLD, g_ptr->m_idx, &dam_max0);
441 if (f4 & RF4_BR_POIS) spell_damcalc_by_spellnum(MS_BR_POIS, GF_POIS, g_ptr->m_idx, &dam_max0);
442 if (f4 & RF4_BR_NETH) spell_damcalc_by_spellnum(MS_BR_NETHER, GF_NETHER, g_ptr->m_idx, &dam_max0);
443 if (f4 & RF4_BR_LITE) spell_damcalc_by_spellnum(MS_BR_LITE, GF_LITE, g_ptr->m_idx, &dam_max0);
444 if (f4 & RF4_BR_DARK) spell_damcalc_by_spellnum(MS_BR_DARK, GF_DARK, g_ptr->m_idx, &dam_max0);
445 if (f4 & RF4_BR_CONF) spell_damcalc_by_spellnum(MS_BR_CONF, GF_CONFUSION, g_ptr->m_idx, &dam_max0);
446 if (f4 & RF4_BR_SOUN) spell_damcalc_by_spellnum(MS_BR_SOUND, GF_SOUND, g_ptr->m_idx, &dam_max0);
447 if (f4 & RF4_BR_CHAO) spell_damcalc_by_spellnum(MS_BR_CHAOS, GF_CHAOS, g_ptr->m_idx, &dam_max0);
448 if (f4 & RF4_BR_DISE) spell_damcalc_by_spellnum(MS_BR_DISEN, GF_DISENCHANT, g_ptr->m_idx, &dam_max0);
449 if (f4 & RF4_BR_NEXU) spell_damcalc_by_spellnum(MS_BR_NEXUS, GF_NEXUS, g_ptr->m_idx, &dam_max0);
450 if (f4 & RF4_BR_TIME) spell_damcalc_by_spellnum(MS_BR_TIME, GF_TIME, g_ptr->m_idx, &dam_max0);
451 if (f4 & RF4_BR_INER) spell_damcalc_by_spellnum(MS_BR_INERTIA, GF_INERTIAL, g_ptr->m_idx, &dam_max0);
452 if (f4 & RF4_BR_GRAV) spell_damcalc_by_spellnum(MS_BR_GRAVITY, GF_GRAVITY, g_ptr->m_idx, &dam_max0);
453 if (f4 & RF4_BR_SHAR) spell_damcalc_by_spellnum(MS_BR_SHARDS, GF_SHARDS, g_ptr->m_idx, &dam_max0);
454 if (f4 & RF4_BR_PLAS) spell_damcalc_by_spellnum(MS_BR_PLASMA, GF_PLASMA, g_ptr->m_idx, &dam_max0);
455 if (f4 & RF4_BR_WALL) spell_damcalc_by_spellnum(MS_BR_FORCE, GF_FORCE, g_ptr->m_idx, &dam_max0);
456 if (f4 & RF4_BR_MANA) spell_damcalc_by_spellnum(MS_BR_MANA, GF_MANA, g_ptr->m_idx, &dam_max0);
457 if (f4 & RF4_BR_NUKE) spell_damcalc_by_spellnum(MS_BR_NUKE, GF_NUKE, g_ptr->m_idx, &dam_max0);
458 if (f4 & RF4_BR_DISI) spell_damcalc_by_spellnum(MS_BR_DISI, GF_DISINTEGRATE, g_ptr->m_idx, &dam_max0);
461 /* Monster melee attacks */
462 if (!(r_ptr->flags1 & RF1_NEVER_BLOW) && !(d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_MELEE))
464 if (mx <= xx + 1 && mx >= xx - 1 && my <= yy + 1 && my >= yy - 1)
468 for (m = 0; m < 4; m++)
470 /* Skip non-attacks */
471 if (!r_ptr->blow[m].method || (r_ptr->blow[m].method == RBM_SHOOT)) continue;
473 /* Extract the attack info */
474 dam_melee += blow_damcalc(m_ptr, &r_ptr->blow[m]);
475 if (r_ptr->blow[m].method == RBM_EXPLODE) break;
477 if (dam_melee > dam_max0) dam_max0 = dam_melee;
481 /* Contribution from this monster */
486 /* Prevent excessive warning */
487 if (dam_max > old_damage)
489 old_damage = dam_max * 3 / 2;
491 if (dam_max > p_ptr->chp / 2)
493 object_type *o_ptr = choose_warning_item();
496 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
498 strcpy(o_name, _("体", "body")); /* Warning ability without item */
499 msg_format(_("%sが鋭く震えた!", "Your %s pulsates sharply!"), o_name);
501 disturb(FALSE, TRUE);
502 return get_check(_("本当にこのまま進むか?", "Really want to go ahead? "));
505 else old_damage = old_damage / 2;
507 g_ptr = ¤t_floor_ptr->grid_array[yy][xx];
508 if (((!easy_disarm && is_trap(g_ptr->feat))
509 || (g_ptr->mimic && is_trap(g_ptr->feat))) && !one_in_(13))
511 object_type *o_ptr = choose_warning_item();
514 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
516 strcpy(o_name, _("体", "body")); /* Warning ability without item */
517 msg_format(_("%sが鋭く震えた!", "Your %s pulsates sharply!"), o_name);
518 disturb(FALSE, TRUE);
519 return get_check(_("本当にこのまま進むか?", "Really want to go ahead? "));