7 #include "player-move.h"
11 #include "player-status.h"
13 #include "monster-spell.h"
15 #include "object-flavor.h"
17 #include "player-race.h"
18 #include "player-class.h"
20 #include "realm-song.h"
23 * @brief 警告を放つアイテムを選択する /
24 * Choose one of items that have warning flag
25 * Calculate spell damages
28 object_type *choose_warning_item(void)
31 int choices[INVEN_TOTAL - INVEN_RARM];
34 /* Paranoia -- Player has no warning ability */
35 if (!p_ptr->warning) return NULL;
37 /* Search Inventory */
38 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
40 BIT_FLAGS flgs[TR_FLAG_SIZE];
41 object_type *o_ptr = &p_ptr->inventory_list[i];
43 object_flags(o_ptr, flgs);
44 if (have_flag(flgs, TR_WARNING))
51 /* Choice one of them */
52 return number ? &p_ptr->inventory_list[choices[randint0(number)]] : NULL;
56 * @brief 警告基準を定めるために魔法の効果属性に基づいて最大魔法ダメージを計算する /
57 * Calculate spell damages
58 * @param m_ptr 魔法を行使するモンスターの構造体参照ポインタ
61 * @param max 算出した最大ダメージを返すポインタ
64 static void spell_damcalc(monster_type *m_ptr, EFFECT_ID typ, HIT_POINT dam, int *max)
66 monster_race *r_ptr = &r_info[m_ptr->r_idx];
67 int rlev = r_ptr->level;
68 bool ignore_wraith_form = FALSE;
70 /* Vulnerability, resistance and immunity */
74 if (p_ptr->immune_elec)
77 ignore_wraith_form = TRUE;
81 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
82 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
83 if (PRACE_IS_(p_ptr, RACE_ANDROID)) dam += dam / 3;
84 if (p_ptr->resist_elec) dam = (dam + 2) / 3;
91 if (p_ptr->resist_pois) dam = (dam + 2) / 3;
92 if (IS_OPPOSE_POIS()) dam = (dam + 2) / 3;
96 if (p_ptr->immune_acid)
99 ignore_wraith_form = TRUE;
103 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
104 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
105 if (p_ptr->resist_acid) dam = (dam + 2) / 3;
106 if (IS_OPPOSE_ACID()) dam = (dam + 2) / 3;
112 if (p_ptr->immune_cold)
115 ignore_wraith_form = TRUE;
119 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
120 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
121 if (p_ptr->resist_cold) dam = (dam + 2) / 3;
122 if (IS_OPPOSE_COLD()) dam = (dam + 2) / 3;
127 if (p_ptr->immune_fire)
130 ignore_wraith_form = TRUE;
134 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
135 if (PRACE_IS_(p_ptr, RACE_ENT)) dam += dam / 3;
136 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
137 if (p_ptr->resist_fire) dam = (dam + 2) / 3;
138 if (IS_OPPOSE_FIRE()) dam = (dam + 2) / 3;
143 ignore_wraith_form = TRUE;
148 ((p_ptr->inventory_list[INVEN_RARM].k_idx && (p_ptr->inventory_list[INVEN_RARM].name1 == ART_ZANTETSU)) ||
149 (p_ptr->inventory_list[INVEN_LARM].k_idx && (p_ptr->inventory_list[INVEN_LARM].name1 == ART_ZANTETSU))))
152 ignore_wraith_form = TRUE;
157 if (p_ptr->resist_lite) dam /= 2; /* Worst case of 4 / (d4 + 7) */
158 if (PRACE_IS_(p_ptr, RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE)) dam *= 2;
159 else if (PRACE_IS_(p_ptr, RACE_S_FAIRY)) dam = dam * 4 / 3;
162 * Cannot use "ignore_wraith_form" strictly (for "random one damage")
163 * "dam *= 2;" for later "dam /= 2"
165 if (p_ptr->wraith_form) dam *= 2;
169 if (PRACE_IS_(p_ptr, RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE) || p_ptr->wraith_form)
172 ignore_wraith_form = TRUE;
174 else if (p_ptr->resist_dark) dam /= 2; /* Worst case of 4 / (d4 + 7) */
178 if (p_ptr->resist_shard) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
182 if (p_ptr->resist_sound) dam = dam * 5 / 8; /* Worst case of 5 / (d4 + 7) */
186 if (p_ptr->resist_conf) dam = dam * 5 / 8; /* Worst case of 5 / (d4 + 7) */
190 if (p_ptr->resist_chaos) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
194 if (PRACE_IS_(p_ptr, RACE_SPECTRE))
197 ignore_wraith_form = TRUE;
199 else if (p_ptr->resist_neth) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
203 if (p_ptr->resist_disen) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
207 if (p_ptr->resist_nexus) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
211 if (p_ptr->resist_time) dam /= 2; /* Worst case of 4 / (d4 + 7) */
215 if (p_ptr->levitation) dam = (dam * 2) / 3;
219 if (p_ptr->resist_shard) dam /= 2;
223 if (p_ptr->resist_pois) dam = (2 * dam + 2) / 5;
224 if (IS_OPPOSE_POIS()) dam = (2 * dam + 2) / 5;
228 if (p_ptr->mimic_form)
230 if (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_NONLIVING)
233 ignore_wraith_form = TRUE;
238 switch (p_ptr->prace)
247 ignore_wraith_form = TRUE;
254 if (p_ptr->align > 10) dam /= 2;
255 else if (p_ptr->align < -10) dam *= 2;
259 if (p_ptr->align > 10) dam *= 2;
264 if (100 + rlev / 2 <= MAX(5, p_ptr->skill_sav))
267 ignore_wraith_form = TRUE;
275 if (100 + rlev / 2 <= p_ptr->skill_sav)
278 ignore_wraith_form = TRUE;
283 if ((100 + rlev / 2 <= p_ptr->skill_sav) && (m_ptr->r_idx != MON_KENSHIROU))
286 ignore_wraith_form = TRUE;
291 if (p_ptr->wraith_form && !ignore_wraith_form)
297 if (dam > *max) *max = dam;
301 * @brief 警告基準を定めるために魔法の効果属性に基づいて最大魔法ダメージを計算する。 /
302 * Calculate spell damages
303 * @param spell_num RF4ならRF4_SPELL_STARTのように32区切りのベースとなる数値
305 * @param m_idx 魔法を行使するモンスターのID
306 * @param max 算出した最大ダメージを返すポインタ
309 void spell_damcalc_by_spellnum(int spell_num, EFFECT_ID typ, MONSTER_IDX m_idx, int *max)
311 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
312 HIT_POINT dam = monspell_damage((spell_num), m_idx, DAM_MAX);
313 spell_damcalc(m_ptr, typ, dam, max);
317 * @brief 警告基準を定めるためにモンスターの打撃最大ダメージを算出する /
318 * Calculate blow damages
319 * @param m_ptr 打撃を行使するモンスターの構造体参照ポインタ
320 * @param blow_ptr モンスターの打撃能力の構造体参照ポインタ
321 * @return 算出された最大ダメージを返す。
323 static int blow_damcalc(monster_type *m_ptr, monster_blow *blow_ptr)
325 int dam = blow_ptr->d_dice * blow_ptr->d_side;
327 bool check_wraith_form = TRUE;
329 if (blow_ptr->method != RBM_EXPLODE)
331 ARMOUR_CLASS ac = p_ptr->ac + p_ptr->to_a;
333 switch (blow_ptr->effect)
337 int tmp_dam = dam - (dam * ((ac < 150) ? ac : 150) / 250);
338 dam = MAX(dam, tmp_dam * 2);
344 dam -= (dam * ((ac < 150) ? ac : 150) / 250);
348 spell_damcalc(m_ptr, GF_ACID, dam, &dummy_max);
350 check_wraith_form = FALSE;
354 spell_damcalc(m_ptr, GF_ELEC, dam, &dummy_max);
356 check_wraith_form = FALSE;
360 spell_damcalc(m_ptr, GF_FIRE, dam, &dummy_max);
362 check_wraith_form = FALSE;
366 spell_damcalc(m_ptr, GF_COLD, dam, &dummy_max);
368 check_wraith_form = FALSE;
373 check_wraith_form = FALSE;
377 if (check_wraith_form && p_ptr->wraith_form)
386 spell_damcalc(m_ptr, mbe_info[blow_ptr->effect].explode_type, dam, &dummy_max);
394 * @brief プレイヤーが特定地点へ移動した場合に警告を発する処理 /
395 * Examine the grid (xx,yy) and warn the player if there are any danger
396 * @param xx 危険性を調査するマスのX座標
397 * @param yy 危険性を調査するマスのY座標
398 * @return 警告を無視して進むことを選択するかか問題が無ければTRUE、警告に従ったならFALSEを返す。
400 bool process_warning(POSITION xx, POSITION yy)
404 GAME_TEXT o_name[MAX_NLEN];
406 #define WARNING_AWARE_RANGE 12
408 static int old_damage = 0;
410 for (mx = xx - WARNING_AWARE_RANGE; mx < xx + WARNING_AWARE_RANGE + 1; mx++)
412 for (my = yy - WARNING_AWARE_RANGE; my < yy + WARNING_AWARE_RANGE + 1; my++)
418 if (!in_bounds(my, mx) || (distance(my, mx, yy, xx) > WARNING_AWARE_RANGE)) continue;
420 g_ptr = ¤t_floor_ptr->grid_array[my][mx];
422 if (!g_ptr->m_idx) continue;
424 m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
426 if (MON_CSLEEP(m_ptr)) continue;
427 if (!is_hostile(m_ptr)) continue;
429 r_ptr = &r_info[m_ptr->r_idx];
431 /* Monster spells (only powerful ones)*/
432 if (projectable(my, mx, yy, xx))
434 BIT_FLAGS f4 = r_ptr->flags4;
435 BIT_FLAGS f5 = r_ptr->a_ability_flags1;
436 BIT_FLAGS f6 = r_ptr->a_ability_flags2;
438 if (!(d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_MAGIC))
440 if (f4 & RF4_BA_CHAO) spell_damcalc_by_spellnum(MS_BALL_CHAOS, GF_CHAOS, g_ptr->m_idx, &dam_max0);
441 if (f5 & RF5_BA_MANA) spell_damcalc_by_spellnum(MS_BALL_MANA, GF_MANA, g_ptr->m_idx, &dam_max0);
442 if (f5 & RF5_BA_DARK) spell_damcalc_by_spellnum(MS_BALL_DARK, GF_DARK, g_ptr->m_idx, &dam_max0);
443 if (f5 & RF5_BA_LITE) spell_damcalc_by_spellnum(MS_STARBURST, GF_LITE, g_ptr->m_idx, &dam_max0);
444 if (f6 & RF6_HAND_DOOM) spell_damcalc_by_spellnum(MS_HAND_DOOM, GF_HAND_DOOM, g_ptr->m_idx, &dam_max0);
445 if (f6 & RF6_PSY_SPEAR) spell_damcalc_by_spellnum(MS_PSY_SPEAR, GF_PSY_SPEAR, g_ptr->m_idx, &dam_max0);
447 if (f4 & RF4_ROCKET) spell_damcalc_by_spellnum(MS_ROCKET, GF_ROCKET, g_ptr->m_idx, &dam_max0);
448 if (f4 & RF4_BR_ACID) spell_damcalc_by_spellnum(MS_BR_ACID, GF_ACID, g_ptr->m_idx, &dam_max0);
449 if (f4 & RF4_BR_ELEC) spell_damcalc_by_spellnum(MS_BR_ELEC, GF_ELEC, g_ptr->m_idx, &dam_max0);
450 if (f4 & RF4_BR_FIRE) spell_damcalc_by_spellnum(MS_BR_FIRE, GF_FIRE, g_ptr->m_idx, &dam_max0);
451 if (f4 & RF4_BR_COLD) spell_damcalc_by_spellnum(MS_BR_COLD, GF_COLD, g_ptr->m_idx, &dam_max0);
452 if (f4 & RF4_BR_POIS) spell_damcalc_by_spellnum(MS_BR_POIS, GF_POIS, g_ptr->m_idx, &dam_max0);
453 if (f4 & RF4_BR_NETH) spell_damcalc_by_spellnum(MS_BR_NETHER, GF_NETHER, g_ptr->m_idx, &dam_max0);
454 if (f4 & RF4_BR_LITE) spell_damcalc_by_spellnum(MS_BR_LITE, GF_LITE, g_ptr->m_idx, &dam_max0);
455 if (f4 & RF4_BR_DARK) spell_damcalc_by_spellnum(MS_BR_DARK, GF_DARK, g_ptr->m_idx, &dam_max0);
456 if (f4 & RF4_BR_CONF) spell_damcalc_by_spellnum(MS_BR_CONF, GF_CONFUSION, g_ptr->m_idx, &dam_max0);
457 if (f4 & RF4_BR_SOUN) spell_damcalc_by_spellnum(MS_BR_SOUND, GF_SOUND, g_ptr->m_idx, &dam_max0);
458 if (f4 & RF4_BR_CHAO) spell_damcalc_by_spellnum(MS_BR_CHAOS, GF_CHAOS, g_ptr->m_idx, &dam_max0);
459 if (f4 & RF4_BR_DISE) spell_damcalc_by_spellnum(MS_BR_DISEN, GF_DISENCHANT, g_ptr->m_idx, &dam_max0);
460 if (f4 & RF4_BR_NEXU) spell_damcalc_by_spellnum(MS_BR_NEXUS, GF_NEXUS, g_ptr->m_idx, &dam_max0);
461 if (f4 & RF4_BR_TIME) spell_damcalc_by_spellnum(MS_BR_TIME, GF_TIME, g_ptr->m_idx, &dam_max0);
462 if (f4 & RF4_BR_INER) spell_damcalc_by_spellnum(MS_BR_INERTIA, GF_INERTIAL, g_ptr->m_idx, &dam_max0);
463 if (f4 & RF4_BR_GRAV) spell_damcalc_by_spellnum(MS_BR_GRAVITY, GF_GRAVITY, g_ptr->m_idx, &dam_max0);
464 if (f4 & RF4_BR_SHAR) spell_damcalc_by_spellnum(MS_BR_SHARDS, GF_SHARDS, g_ptr->m_idx, &dam_max0);
465 if (f4 & RF4_BR_PLAS) spell_damcalc_by_spellnum(MS_BR_PLASMA, GF_PLASMA, g_ptr->m_idx, &dam_max0);
466 if (f4 & RF4_BR_WALL) spell_damcalc_by_spellnum(MS_BR_FORCE, GF_FORCE, g_ptr->m_idx, &dam_max0);
467 if (f4 & RF4_BR_MANA) spell_damcalc_by_spellnum(MS_BR_MANA, GF_MANA, g_ptr->m_idx, &dam_max0);
468 if (f4 & RF4_BR_NUKE) spell_damcalc_by_spellnum(MS_BR_NUKE, GF_NUKE, g_ptr->m_idx, &dam_max0);
469 if (f4 & RF4_BR_DISI) spell_damcalc_by_spellnum(MS_BR_DISI, GF_DISINTEGRATE, g_ptr->m_idx, &dam_max0);
472 /* Monster melee attacks */
473 if (!(r_ptr->flags1 & RF1_NEVER_BLOW) && !(d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_MELEE))
475 if (mx <= xx + 1 && mx >= xx - 1 && my <= yy + 1 && my >= yy - 1)
479 for (m = 0; m < 4; m++)
481 /* Skip non-attacks */
482 if (!r_ptr->blow[m].method || (r_ptr->blow[m].method == RBM_SHOOT)) continue;
484 /* Extract the attack info */
485 dam_melee += blow_damcalc(m_ptr, &r_ptr->blow[m]);
486 if (r_ptr->blow[m].method == RBM_EXPLODE) break;
488 if (dam_melee > dam_max0) dam_max0 = dam_melee;
492 /* Contribution from this monster */
497 /* Prevent excessive warning */
498 if (dam_max > old_damage)
500 old_damage = dam_max * 3 / 2;
502 if (dam_max > p_ptr->chp / 2)
504 object_type *o_ptr = choose_warning_item();
507 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
509 strcpy(o_name, _("体", "body")); /* Warning ability without item */
510 msg_format(_("%sが鋭く震えた!", "Your %s pulsates sharply!"), o_name);
512 disturb(FALSE, TRUE);
513 return get_check(_("本当にこのまま進むか?", "Really want to go ahead? "));
516 else old_damage = old_damage / 2;
518 g_ptr = ¤t_floor_ptr->grid_array[yy][xx];
519 if (((!easy_disarm && is_trap(g_ptr->feat))
520 || (g_ptr->mimic && is_trap(g_ptr->feat))) && !one_in_(13))
522 object_type *o_ptr = choose_warning_item();
525 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
527 strcpy(o_name, _("体", "body")); /* Warning ability without item */
528 msg_format(_("%sが鋭く震えた!", "Your %s pulsates sharply!"), o_name);
529 disturb(FALSE, TRUE);
530 return get_check(_("本当にこのまま進むか?", "Really want to go ahead? "));