• R/O
  • HTTP
  • SSH
  • HTTPS

hengband: Commit

変愚蛮怒のメインリポジトリです


Commit MetaInfo

Revision9d3ecd593c7411b2ac36b5e3fabff31a42d9323d (tree)
Time2019-03-11 22:44:26
Authordeskull <deskull@user...>
Commiterdeskull

Log Message

[Refactor] #37353 警告の処理を warning.c に分離 / Separate warning.c from object2.c.

Change Summary

Incremental Difference

--- a/Hengband_vcs2017/Hengband/Hengband.vcxproj
+++ b/Hengband_vcs2017/Hengband/Hengband.vcxproj
@@ -259,6 +259,7 @@
259259 <ClCompile Include="..\..\src\util.c" />
260260 <ClCompile Include="..\..\src\variable.c" />
261261 <ClCompile Include="..\..\src\view-mainwindow.c" />
262+ <ClCompile Include="..\..\src\warning.c" />
262263 <ClCompile Include="..\..\src\wild.c" />
263264 <ClCompile Include="..\..\src\wizard1.c" />
264265 <ClCompile Include="..\..\src\wizard2.c" />
@@ -349,6 +350,7 @@
349350 <ClInclude Include="..\..\src\term.h" />
350351 <ClInclude Include="..\..\src\trap.h" />
351352 <ClInclude Include="..\..\src\types.h" />
353+ <ClInclude Include="..\..\src\warning.h" />
352354 <ClInclude Include="..\..\src\wild.h" />
353355 <ClInclude Include="..\..\src\world.h" />
354356 <ClInclude Include="..\..\src\z-config.h" />
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -78,7 +78,7 @@ hengband_SOURCES = \
7878 sort.c sort.h \
7979 store.h store.c tables.c trap.c trap.h types.h util.c \
8080 variable.c wild.h wild.c wizard1.c wizard2.c \
81- world.c world.h \
81+ warning.c warning.h world.c world.h \
8282 \
8383 view-mainwindow.c\
8484 \
--- a/src/externs.h
+++ b/src/externs.h
@@ -783,8 +783,6 @@ extern void inven_drop(INVENTORY_IDX item, ITEM_NUMBER amt);
783783 extern void combine_pack(void);
784784 extern void reorder_pack(void);
785785 extern void display_koff(KIND_OBJECT_IDX k_idx);
786-extern object_type *choose_warning_item(void);
787-extern bool process_warning(POSITION xx, POSITION yy);
788786 extern void torch_flags(object_type *o_ptr, BIT_FLAGS *flgs);
789787 extern void torch_dice(object_type *o_ptr, DICE_NUMBER *dd, DICE_SID *ds);
790788 extern void torch_lost_fuel(object_type *o_ptr);
--- a/src/monster2.c
+++ b/src/monster2.c
@@ -21,6 +21,7 @@
2121 #include "grid.h"
2222 #include "player-move.h"
2323 #include "wild.h"
24+#include "warning.h"
2425
2526 #define HORDE_NOGOOD 0x01 /*!< (未実装フラグ)HORDE生成でGOODなモンスターの生成を禁止する? */
2627 #define HORDE_NOEVIL 0x02 /*!< (未実装フラグ)HORDE生成でEVILなモンスターの生成を禁止する? */
--- a/src/object2.c
+++ b/src/object2.c
@@ -6139,520 +6139,6 @@ void display_koff(KIND_OBJECT_IDX k_idx)
61396139 }
61406140 }
61416141
6142-/*!
6143- * @brief 警告を放つアイテムを選択する /
6144- * Choose one of items that have warning flag
6145- * Calculate spell damages
6146- * @return 警告を行う
6147- */
6148-object_type *choose_warning_item(void)
6149-{
6150- int i;
6151- int choices[INVEN_TOTAL - INVEN_RARM];
6152- int number = 0;
6153-
6154- /* Paranoia -- Player has no warning ability */
6155- if (!p_ptr->warning) return NULL;
6156-
6157- /* Search Inventory */
6158- for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
6159- {
6160- BIT_FLAGS flgs[TR_FLAG_SIZE];
6161- object_type *o_ptr = &inventory[i];
6162-
6163- object_flags(o_ptr, flgs);
6164- if (have_flag(flgs, TR_WARNING))
6165- {
6166- choices[number] = i;
6167- number++;
6168- }
6169- }
6170-
6171- /* Choice one of them */
6172- return number ? &inventory[choices[randint0(number)]] : NULL;
6173-}
6174-
6175-/*!
6176- * @brief 警告基準を定めるために魔法の効果属性に基づいて最大魔法ダメージを計算する /
6177- * Calculate spell damages
6178- * @param m_ptr 魔法を行使するモンスターの構造体参照ポインタ
6179- * @param typ 効果属性のID
6180- * @param dam 基本ダメージ
6181- * @param max 算出した最大ダメージを返すポインタ
6182- * @return なし
6183- */
6184-static void spell_damcalc(monster_type *m_ptr, EFFECT_ID typ, HIT_POINT dam, int *max)
6185-{
6186- monster_race *r_ptr = &r_info[m_ptr->r_idx];
6187- int rlev = r_ptr->level;
6188- bool ignore_wraith_form = FALSE;
6189-
6190- /* Vulnerability, resistance and immunity */
6191- switch (typ)
6192- {
6193- case GF_ELEC:
6194- if (p_ptr->immune_elec)
6195- {
6196- dam = 0;
6197- ignore_wraith_form = TRUE;
6198- }
6199- else
6200- {
6201- if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6202- if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6203- if (prace_is_(RACE_ANDROID)) dam += dam / 3;
6204- if (p_ptr->resist_elec) dam = (dam + 2) / 3;
6205- if (IS_OPPOSE_ELEC())
6206- dam = (dam + 2) / 3;
6207- }
6208- break;
6209-
6210- case GF_POIS:
6211- if (p_ptr->resist_pois) dam = (dam + 2) / 3;
6212- if (IS_OPPOSE_POIS()) dam = (dam + 2) / 3;
6213- break;
6214-
6215- case GF_ACID:
6216- if (p_ptr->immune_acid)
6217- {
6218- dam = 0;
6219- ignore_wraith_form = TRUE;
6220- }
6221- else
6222- {
6223- if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6224- if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6225- if (p_ptr->resist_acid) dam = (dam + 2) / 3;
6226- if (IS_OPPOSE_ACID()) dam = (dam + 2) / 3;
6227- }
6228- break;
6229-
6230- case GF_COLD:
6231- case GF_ICE:
6232- if (p_ptr->immune_cold)
6233- {
6234- dam = 0;
6235- ignore_wraith_form = TRUE;
6236- }
6237- else
6238- {
6239- if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6240- if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6241- if (p_ptr->resist_cold) dam = (dam + 2) / 3;
6242- if (IS_OPPOSE_COLD()) dam = (dam + 2) / 3;
6243- }
6244- break;
6245-
6246- case GF_FIRE:
6247- if (p_ptr->immune_fire)
6248- {
6249- dam = 0;
6250- ignore_wraith_form = TRUE;
6251- }
6252- else
6253- {
6254- if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
6255- if (prace_is_(RACE_ENT)) dam += dam / 3;
6256- if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
6257- if (p_ptr->resist_fire) dam = (dam + 2) / 3;
6258- if (IS_OPPOSE_FIRE()) dam = (dam + 2) / 3;
6259- }
6260- break;
6261-
6262- case GF_PSY_SPEAR:
6263- ignore_wraith_form = TRUE;
6264- break;
6265-
6266- case GF_ARROW:
6267- if (!p_ptr->blind &&
6268- ((inventory[INVEN_RARM].k_idx && (inventory[INVEN_RARM].name1 == ART_ZANTETSU)) ||
6269- (inventory[INVEN_LARM].k_idx && (inventory[INVEN_LARM].name1 == ART_ZANTETSU))))
6270- {
6271- dam = 0;
6272- ignore_wraith_form = TRUE;
6273- }
6274- break;
6275-
6276- case GF_LITE:
6277- if (p_ptr->resist_lite) dam /= 2; /* Worst case of 4 / (d4 + 7) */
6278- if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE)) dam *= 2;
6279- else if (prace_is_(RACE_S_FAIRY)) dam = dam * 4 / 3;
6280-
6281- /*
6282- * Cannot use "ignore_wraith_form" strictly (for "random one damage")
6283- * "dam *= 2;" for later "dam /= 2"
6284- */
6285- if (p_ptr->wraith_form) dam *= 2;
6286- break;
6287-
6288- case GF_DARK:
6289- if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE) || p_ptr->wraith_form)
6290- {
6291- dam = 0;
6292- ignore_wraith_form = TRUE;
6293- }
6294- else if (p_ptr->resist_dark) dam /= 2; /* Worst case of 4 / (d4 + 7) */
6295- break;
6296-
6297- case GF_SHARDS:
6298- if (p_ptr->resist_shard) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6299- break;
6300-
6301- case GF_SOUND:
6302- if (p_ptr->resist_sound) dam = dam * 5 / 8; /* Worst case of 5 / (d4 + 7) */
6303- break;
6304-
6305- case GF_CONFUSION:
6306- if (p_ptr->resist_conf) dam = dam * 5 / 8; /* Worst case of 5 / (d4 + 7) */
6307- break;
6308-
6309- case GF_CHAOS:
6310- if (p_ptr->resist_chaos) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6311- break;
6312-
6313- case GF_NETHER:
6314- if (prace_is_(RACE_SPECTRE))
6315- {
6316- dam = 0;
6317- ignore_wraith_form = TRUE;
6318- }
6319- else if (p_ptr->resist_neth) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6320- break;
6321-
6322- case GF_DISENCHANT:
6323- if (p_ptr->resist_disen) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6324- break;
6325-
6326- case GF_NEXUS:
6327- if (p_ptr->resist_nexus) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
6328- break;
6329-
6330- case GF_TIME:
6331- if (p_ptr->resist_time) dam /= 2; /* Worst case of 4 / (d4 + 7) */
6332- break;
6333-
6334- case GF_GRAVITY:
6335- if (p_ptr->levitation) dam = (dam * 2) / 3;
6336- break;
6337-
6338- case GF_ROCKET:
6339- if (p_ptr->resist_shard) dam /= 2;
6340- break;
6341-
6342- case GF_NUKE:
6343- if (p_ptr->resist_pois) dam = (2 * dam + 2) / 5;
6344- if (IS_OPPOSE_POIS()) dam = (2 * dam + 2) / 5;
6345- break;
6346-
6347- case GF_DEATH_RAY:
6348- if (p_ptr->mimic_form)
6349- {
6350- if (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_NONLIVING)
6351- {
6352- dam = 0;
6353- ignore_wraith_form = TRUE;
6354- }
6355- }
6356- else
6357- {
6358- switch (p_ptr->prace)
6359- {
6360- case RACE_GOLEM:
6361- case RACE_SKELETON:
6362- case RACE_ZOMBIE:
6363- case RACE_VAMPIRE:
6364- case RACE_DEMON:
6365- case RACE_SPECTRE:
6366- dam = 0;
6367- ignore_wraith_form = TRUE;
6368- break;
6369- }
6370- }
6371- break;
6372-
6373- case GF_HOLY_FIRE:
6374- if (p_ptr->align > 10) dam /= 2;
6375- else if (p_ptr->align < -10) dam *= 2;
6376- break;
6377-
6378- case GF_HELL_FIRE:
6379- if (p_ptr->align > 10) dam *= 2;
6380- break;
6381-
6382- case GF_MIND_BLAST:
6383- case GF_BRAIN_SMASH:
6384- if (100 + rlev / 2 <= MAX(5, p_ptr->skill_sav))
6385- {
6386- dam = 0;
6387- ignore_wraith_form = TRUE;
6388- }
6389- break;
6390-
6391- case GF_CAUSE_1:
6392- case GF_CAUSE_2:
6393- case GF_CAUSE_3:
6394- case GF_HAND_DOOM:
6395- if (100 + rlev / 2 <= p_ptr->skill_sav)
6396- {
6397- dam = 0;
6398- ignore_wraith_form = TRUE;
6399- }
6400- break;
6401-
6402- case GF_CAUSE_4:
6403- if ((100 + rlev / 2 <= p_ptr->skill_sav) && (m_ptr->r_idx != MON_KENSHIROU))
6404- {
6405- dam = 0;
6406- ignore_wraith_form = TRUE;
6407- }
6408- break;
6409- }
6410-
6411- if (p_ptr->wraith_form && !ignore_wraith_form)
6412- {
6413- dam /= 2;
6414- if (!dam) dam = 1;
6415- }
6416-
6417- if (dam > *max) *max = dam;
6418-}
6419-
6420-/*!
6421-* @brief 警告基準を定めるために魔法の効果属性に基づいて最大魔法ダメージを計算する。 /
6422-* Calculate spell damages
6423-* @param spell_num RF4ならRF4_SPELL_STARTのように32区切りのベースとなる数値
6424-* @param typ 効果属性のID
6425-* @param m_idx 魔法を行使するモンスターのID
6426-* @param max 算出した最大ダメージを返すポインタ
6427-* @return なし
6428-*/
6429-void spell_damcalc_by_spellnum(int spell_num, EFFECT_ID typ, MONSTER_IDX m_idx, int *max)
6430-{
6431- monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
6432- HIT_POINT dam = monspell_damage((spell_num), m_idx, DAM_MAX);
6433- spell_damcalc(m_ptr, typ, dam, max);
6434-}
6435-
6436-/*!
6437- * @brief 警告基準を定めるためにモンスターの打撃最大ダメージを算出する /
6438- * Calculate blow damages
6439- * @param m_ptr 打撃を行使するモンスターの構造体参照ポインタ
6440- * @param blow_ptr モンスターの打撃能力の構造体参照ポインタ
6441- * @return 算出された最大ダメージを返す。
6442- */
6443-static int blow_damcalc(monster_type *m_ptr, monster_blow *blow_ptr)
6444-{
6445- int dam = blow_ptr->d_dice * blow_ptr->d_side;
6446- int dummy_max = 0;
6447- bool check_wraith_form = TRUE;
6448-
6449- if (blow_ptr->method != RBM_EXPLODE)
6450- {
6451- ARMOUR_CLASS ac = p_ptr->ac + p_ptr->to_a;
6452-
6453- switch (blow_ptr->effect)
6454- {
6455- case RBE_SUPERHURT:
6456- {
6457- int tmp_dam = dam - (dam * ((ac < 150) ? ac : 150) / 250);
6458- dam = MAX(dam, tmp_dam * 2);
6459- break;
6460- }
6461-
6462- case RBE_HURT:
6463- case RBE_SHATTER:
6464- dam -= (dam * ((ac < 150) ? ac : 150) / 250);
6465- break;
6466-
6467- case RBE_ACID:
6468- spell_damcalc(m_ptr, GF_ACID, dam, &dummy_max);
6469- dam = dummy_max;
6470- check_wraith_form = FALSE;
6471- break;
6472-
6473- case RBE_ELEC:
6474- spell_damcalc(m_ptr, GF_ELEC, dam, &dummy_max);
6475- dam = dummy_max;
6476- check_wraith_form = FALSE;
6477- break;
6478-
6479- case RBE_FIRE:
6480- spell_damcalc(m_ptr, GF_FIRE, dam, &dummy_max);
6481- dam = dummy_max;
6482- check_wraith_form = FALSE;
6483- break;
6484-
6485- case RBE_COLD:
6486- spell_damcalc(m_ptr, GF_COLD, dam, &dummy_max);
6487- dam = dummy_max;
6488- check_wraith_form = FALSE;
6489- break;
6490-
6491- case RBE_DR_MANA:
6492- dam = 0;
6493- check_wraith_form = FALSE;
6494- break;
6495- }
6496-
6497- if (check_wraith_form && p_ptr->wraith_form)
6498- {
6499- dam /= 2;
6500- if (!dam) dam = 1;
6501- }
6502- }
6503- else
6504- {
6505- dam = (dam + 1) / 2;
6506- spell_damcalc(m_ptr, mbe_info[blow_ptr->effect].explode_type, dam, &dummy_max);
6507- dam = dummy_max;
6508- }
6509-
6510- return dam;
6511-}
6512-
6513-/*!
6514- * @brief プレイヤーが特定地点へ移動した場合に警告を発する処理 /
6515- * Examine the grid (xx,yy) and warn the player if there are any danger
6516- * @param xx 危険性を調査するマスのX座標
6517- * @param yy 危険性を調査するマスのY座標
6518- * @return 警告を無視して進むことを選択するかか問題が無ければTRUE、警告に従ったならFALSEを返す。
6519- */
6520-bool process_warning(POSITION xx, POSITION yy)
6521-{
6522- POSITION mx, my;
6523- grid_type *g_ptr;
6524- GAME_TEXT o_name[MAX_NLEN];
6525-
6526-#define WARNING_AWARE_RANGE 12
6527- int dam_max = 0;
6528- static int old_damage = 0;
6529-
6530- for (mx = xx - WARNING_AWARE_RANGE; mx < xx + WARNING_AWARE_RANGE + 1; mx++)
6531- {
6532- for (my = yy - WARNING_AWARE_RANGE; my < yy + WARNING_AWARE_RANGE + 1; my++)
6533- {
6534- int dam_max0 = 0;
6535- monster_type *m_ptr;
6536- monster_race *r_ptr;
6537-
6538- if (!in_bounds(my, mx) || (distance(my, mx, yy, xx) > WARNING_AWARE_RANGE)) continue;
6539-
6540- g_ptr = &current_floor_ptr->grid_array[my][mx];
6541-
6542- if (!g_ptr->m_idx) continue;
6543-
6544- m_ptr = &current_floor_ptr->m_list[g_ptr->m_idx];
6545-
6546- if (MON_CSLEEP(m_ptr)) continue;
6547- if (!is_hostile(m_ptr)) continue;
6548-
6549- r_ptr = &r_info[m_ptr->r_idx];
6550-
6551- /* Monster spells (only powerful ones)*/
6552- if (projectable(my, mx, yy, xx))
6553- {
6554- BIT_FLAGS f4 = r_ptr->flags4;
6555- BIT_FLAGS f5 = r_ptr->a_ability_flags1;
6556- BIT_FLAGS f6 = r_ptr->a_ability_flags2;
6557-
6558- if (!(d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_MAGIC))
6559- {
6560- if (f4 & RF4_BA_CHAO) spell_damcalc_by_spellnum(MS_BALL_CHAOS, GF_CHAOS, g_ptr->m_idx, &dam_max0);
6561- if (f5 & RF5_BA_MANA) spell_damcalc_by_spellnum(MS_BALL_MANA, GF_MANA, g_ptr->m_idx, &dam_max0);
6562- if (f5 & RF5_BA_DARK) spell_damcalc_by_spellnum(MS_BALL_DARK, GF_DARK, g_ptr->m_idx, &dam_max0);
6563- if (f5 & RF5_BA_LITE) spell_damcalc_by_spellnum(MS_STARBURST, GF_LITE, g_ptr->m_idx, &dam_max0);
6564- if (f6 & RF6_HAND_DOOM) spell_damcalc_by_spellnum(MS_HAND_DOOM, GF_HAND_DOOM, g_ptr->m_idx, &dam_max0);
6565- if (f6 & RF6_PSY_SPEAR) spell_damcalc_by_spellnum(MS_PSY_SPEAR, GF_PSY_SPEAR, g_ptr->m_idx, &dam_max0);
6566- }
6567- if (f4 & RF4_ROCKET) spell_damcalc_by_spellnum(MS_ROCKET, GF_ROCKET, g_ptr->m_idx, &dam_max0);
6568- if (f4 & RF4_BR_ACID) spell_damcalc_by_spellnum(MS_BR_ACID, GF_ACID, g_ptr->m_idx, &dam_max0);
6569- if (f4 & RF4_BR_ELEC) spell_damcalc_by_spellnum(MS_BR_ELEC, GF_ELEC, g_ptr->m_idx, &dam_max0);
6570- if (f4 & RF4_BR_FIRE) spell_damcalc_by_spellnum(MS_BR_FIRE, GF_FIRE, g_ptr->m_idx, &dam_max0);
6571- if (f4 & RF4_BR_COLD) spell_damcalc_by_spellnum(MS_BR_COLD, GF_COLD, g_ptr->m_idx, &dam_max0);
6572- if (f4 & RF4_BR_POIS) spell_damcalc_by_spellnum(MS_BR_POIS, GF_POIS, g_ptr->m_idx, &dam_max0);
6573- if (f4 & RF4_BR_NETH) spell_damcalc_by_spellnum(MS_BR_NETHER, GF_NETHER, g_ptr->m_idx, &dam_max0);
6574- if (f4 & RF4_BR_LITE) spell_damcalc_by_spellnum(MS_BR_LITE, GF_LITE, g_ptr->m_idx, &dam_max0);
6575- if (f4 & RF4_BR_DARK) spell_damcalc_by_spellnum(MS_BR_DARK, GF_DARK, g_ptr->m_idx, &dam_max0);
6576- if (f4 & RF4_BR_CONF) spell_damcalc_by_spellnum(MS_BR_CONF, GF_CONFUSION, g_ptr->m_idx, &dam_max0);
6577- if (f4 & RF4_BR_SOUN) spell_damcalc_by_spellnum(MS_BR_SOUND, GF_SOUND, g_ptr->m_idx, &dam_max0);
6578- if (f4 & RF4_BR_CHAO) spell_damcalc_by_spellnum(MS_BR_CHAOS, GF_CHAOS, g_ptr->m_idx, &dam_max0);
6579- if (f4 & RF4_BR_DISE) spell_damcalc_by_spellnum(MS_BR_DISEN, GF_DISENCHANT, g_ptr->m_idx, &dam_max0);
6580- if (f4 & RF4_BR_NEXU) spell_damcalc_by_spellnum(MS_BR_NEXUS, GF_NEXUS, g_ptr->m_idx, &dam_max0);
6581- if (f4 & RF4_BR_TIME) spell_damcalc_by_spellnum(MS_BR_TIME, GF_TIME, g_ptr->m_idx, &dam_max0);
6582- if (f4 & RF4_BR_INER) spell_damcalc_by_spellnum(MS_BR_INERTIA, GF_INERTIAL, g_ptr->m_idx, &dam_max0);
6583- if (f4 & RF4_BR_GRAV) spell_damcalc_by_spellnum(MS_BR_GRAVITY, GF_GRAVITY, g_ptr->m_idx, &dam_max0);
6584- if (f4 & RF4_BR_SHAR) spell_damcalc_by_spellnum(MS_BR_SHARDS, GF_SHARDS, g_ptr->m_idx, &dam_max0);
6585- if (f4 & RF4_BR_PLAS) spell_damcalc_by_spellnum(MS_BR_PLASMA, GF_PLASMA, g_ptr->m_idx, &dam_max0);
6586- if (f4 & RF4_BR_WALL) spell_damcalc_by_spellnum(MS_BR_FORCE, GF_FORCE, g_ptr->m_idx, &dam_max0);
6587- if (f4 & RF4_BR_MANA) spell_damcalc_by_spellnum(MS_BR_MANA, GF_MANA, g_ptr->m_idx, &dam_max0);
6588- if (f4 & RF4_BR_NUKE) spell_damcalc_by_spellnum(MS_BR_NUKE, GF_NUKE, g_ptr->m_idx, &dam_max0);
6589- if (f4 & RF4_BR_DISI) spell_damcalc_by_spellnum(MS_BR_DISI, GF_DISINTEGRATE, g_ptr->m_idx, &dam_max0);
6590- }
6591-
6592- /* Monster melee attacks */
6593- if (!(r_ptr->flags1 & RF1_NEVER_BLOW) && !(d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_MELEE))
6594- {
6595- if (mx <= xx + 1 && mx >= xx - 1 && my <= yy + 1 && my >= yy - 1)
6596- {
6597- int m;
6598- int dam_melee = 0;
6599- for (m = 0; m < 4; m++)
6600- {
6601- /* Skip non-attacks */
6602- if (!r_ptr->blow[m].method || (r_ptr->blow[m].method == RBM_SHOOT)) continue;
6603-
6604- /* Extract the attack info */
6605- dam_melee += blow_damcalc(m_ptr, &r_ptr->blow[m]);
6606- if (r_ptr->blow[m].method == RBM_EXPLODE) break;
6607- }
6608- if (dam_melee > dam_max0) dam_max0 = dam_melee;
6609- }
6610- }
6611-
6612- /* Contribution from this monster */
6613- dam_max += dam_max0;
6614- }
6615- }
6616-
6617- /* Prevent excessive warning */
6618- if (dam_max > old_damage)
6619- {
6620- old_damage = dam_max * 3 / 2;
6621-
6622- if (dam_max > p_ptr->chp / 2)
6623- {
6624- object_type *o_ptr = choose_warning_item();
6625-
6626- if (o_ptr)
6627- object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
6628- else
6629- strcpy(o_name, _("体", "body")); /* Warning ability without item */
6630- msg_format(_("%sが鋭く震えた!", "Your %s pulsates sharply!"), o_name);
6631-
6632- disturb(FALSE, TRUE);
6633- return get_check(_("本当にこのまま進むか?", "Really want to go ahead? "));
6634- }
6635- }
6636- else old_damage = old_damage / 2;
6637-
6638- g_ptr = &current_floor_ptr->grid_array[yy][xx];
6639- if (((!easy_disarm && is_trap(g_ptr->feat))
6640- || (g_ptr->mimic && is_trap(g_ptr->feat))) && !one_in_(13))
6641- {
6642- object_type *o_ptr = choose_warning_item();
6643-
6644- if (o_ptr)
6645- object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
6646- else
6647- strcpy(o_name, _("体", "body")); /* Warning ability without item */
6648- msg_format(_("%sが鋭く震えた!", "Your %s pulsates sharply!"), o_name);
6649- disturb(FALSE, TRUE);
6650- return get_check(_("本当にこのまま進むか?", "Really want to go ahead? "));
6651- }
6652-
6653- return TRUE;
6654-}
6655-
66566142
66576143 /*!
66586144 * @brief 投擲時たいまつに投げやすい/焼棄/アンデッドスレイの特別効果を返す。
--- a/src/player-move.c
+++ b/src/player-move.c
@@ -150,6 +150,7 @@
150150 #include "player-status.h"
151151 #include "spells-floor.h"
152152 #include "feature.h"
153+#include "warning.h"
153154
154155
155156
--- /dev/null
+++ b/src/warning.c
@@ -0,0 +1,522 @@
1+
2+
3+#include "angband.h"
4+#include "artifact.h"
5+#include "player-move.h"
6+#include "feature.h"
7+#include "warning.h"
8+
9+/*!
10+ * @brief 警告を放つアイテムを選択する /
11+ * Choose one of items that have warning flag
12+ * Calculate spell damages
13+ * @return 警告を行う
14+ */
15+object_type *choose_warning_item(void)
16+{
17+ int i;
18+ int choices[INVEN_TOTAL - INVEN_RARM];
19+ int number = 0;
20+
21+ /* Paranoia -- Player has no warning ability */
22+ if (!p_ptr->warning) return NULL;
23+
24+ /* Search Inventory */
25+ for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
26+ {
27+ BIT_FLAGS flgs[TR_FLAG_SIZE];
28+ object_type *o_ptr = &inventory[i];
29+
30+ object_flags(o_ptr, flgs);
31+ if (have_flag(flgs, TR_WARNING))
32+ {
33+ choices[number] = i;
34+ number++;
35+ }
36+ }
37+
38+ /* Choice one of them */
39+ return number ? &inventory[choices[randint0(number)]] : NULL;
40+}
41+
42+/*!
43+ * @brief 警告基準を定めるために魔法の効果属性に基づいて最大魔法ダメージを計算する /
44+ * Calculate spell damages
45+ * @param m_ptr 魔法を行使するモンスターの構造体参照ポインタ
46+ * @param typ 効果属性のID
47+ * @param dam 基本ダメージ
48+ * @param max 算出した最大ダメージを返すポインタ
49+ * @return なし
50+ */
51+static void spell_damcalc(monster_type *m_ptr, EFFECT_ID typ, HIT_POINT dam, int *max)
52+{
53+ monster_race *r_ptr = &r_info[m_ptr->r_idx];
54+ int rlev = r_ptr->level;
55+ bool ignore_wraith_form = FALSE;
56+
57+ /* Vulnerability, resistance and immunity */
58+ switch (typ)
59+ {
60+ case GF_ELEC:
61+ if (p_ptr->immune_elec)
62+ {
63+ dam = 0;
64+ ignore_wraith_form = TRUE;
65+ }
66+ else
67+ {
68+ if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
69+ if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
70+ if (prace_is_(RACE_ANDROID)) dam += dam / 3;
71+ if (p_ptr->resist_elec) dam = (dam + 2) / 3;
72+ if (IS_OPPOSE_ELEC())
73+ dam = (dam + 2) / 3;
74+ }
75+ break;
76+
77+ case GF_POIS:
78+ if (p_ptr->resist_pois) dam = (dam + 2) / 3;
79+ if (IS_OPPOSE_POIS()) dam = (dam + 2) / 3;
80+ break;
81+
82+ case GF_ACID:
83+ if (p_ptr->immune_acid)
84+ {
85+ dam = 0;
86+ ignore_wraith_form = TRUE;
87+ }
88+ else
89+ {
90+ if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
91+ if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
92+ if (p_ptr->resist_acid) dam = (dam + 2) / 3;
93+ if (IS_OPPOSE_ACID()) dam = (dam + 2) / 3;
94+ }
95+ break;
96+
97+ case GF_COLD:
98+ case GF_ICE:
99+ if (p_ptr->immune_cold)
100+ {
101+ dam = 0;
102+ ignore_wraith_form = TRUE;
103+ }
104+ else
105+ {
106+ if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
107+ if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
108+ if (p_ptr->resist_cold) dam = (dam + 2) / 3;
109+ if (IS_OPPOSE_COLD()) dam = (dam + 2) / 3;
110+ }
111+ break;
112+
113+ case GF_FIRE:
114+ if (p_ptr->immune_fire)
115+ {
116+ dam = 0;
117+ ignore_wraith_form = TRUE;
118+ }
119+ else
120+ {
121+ if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
122+ if (prace_is_(RACE_ENT)) dam += dam / 3;
123+ if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
124+ if (p_ptr->resist_fire) dam = (dam + 2) / 3;
125+ if (IS_OPPOSE_FIRE()) dam = (dam + 2) / 3;
126+ }
127+ break;
128+
129+ case GF_PSY_SPEAR:
130+ ignore_wraith_form = TRUE;
131+ break;
132+
133+ case GF_ARROW:
134+ if (!p_ptr->blind &&
135+ ((inventory[INVEN_RARM].k_idx && (inventory[INVEN_RARM].name1 == ART_ZANTETSU)) ||
136+ (inventory[INVEN_LARM].k_idx && (inventory[INVEN_LARM].name1 == ART_ZANTETSU))))
137+ {
138+ dam = 0;
139+ ignore_wraith_form = TRUE;
140+ }
141+ break;
142+
143+ case GF_LITE:
144+ if (p_ptr->resist_lite) dam /= 2; /* Worst case of 4 / (d4 + 7) */
145+ if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE)) dam *= 2;
146+ else if (prace_is_(RACE_S_FAIRY)) dam = dam * 4 / 3;
147+
148+ /*
149+ * Cannot use "ignore_wraith_form" strictly (for "random one damage")
150+ * "dam *= 2;" for later "dam /= 2"
151+ */
152+ if (p_ptr->wraith_form) dam *= 2;
153+ break;
154+
155+ case GF_DARK:
156+ if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE) || p_ptr->wraith_form)
157+ {
158+ dam = 0;
159+ ignore_wraith_form = TRUE;
160+ }
161+ else if (p_ptr->resist_dark) dam /= 2; /* Worst case of 4 / (d4 + 7) */
162+ break;
163+
164+ case GF_SHARDS:
165+ if (p_ptr->resist_shard) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
166+ break;
167+
168+ case GF_SOUND:
169+ if (p_ptr->resist_sound) dam = dam * 5 / 8; /* Worst case of 5 / (d4 + 7) */
170+ break;
171+
172+ case GF_CONFUSION:
173+ if (p_ptr->resist_conf) dam = dam * 5 / 8; /* Worst case of 5 / (d4 + 7) */
174+ break;
175+
176+ case GF_CHAOS:
177+ if (p_ptr->resist_chaos) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
178+ break;
179+
180+ case GF_NETHER:
181+ if (prace_is_(RACE_SPECTRE))
182+ {
183+ dam = 0;
184+ ignore_wraith_form = TRUE;
185+ }
186+ else if (p_ptr->resist_neth) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
187+ break;
188+
189+ case GF_DISENCHANT:
190+ if (p_ptr->resist_disen) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
191+ break;
192+
193+ case GF_NEXUS:
194+ if (p_ptr->resist_nexus) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
195+ break;
196+
197+ case GF_TIME:
198+ if (p_ptr->resist_time) dam /= 2; /* Worst case of 4 / (d4 + 7) */
199+ break;
200+
201+ case GF_GRAVITY:
202+ if (p_ptr->levitation) dam = (dam * 2) / 3;
203+ break;
204+
205+ case GF_ROCKET:
206+ if (p_ptr->resist_shard) dam /= 2;
207+ break;
208+
209+ case GF_NUKE:
210+ if (p_ptr->resist_pois) dam = (2 * dam + 2) / 5;
211+ if (IS_OPPOSE_POIS()) dam = (2 * dam + 2) / 5;
212+ break;
213+
214+ case GF_DEATH_RAY:
215+ if (p_ptr->mimic_form)
216+ {
217+ if (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_NONLIVING)
218+ {
219+ dam = 0;
220+ ignore_wraith_form = TRUE;
221+ }
222+ }
223+ else
224+ {
225+ switch (p_ptr->prace)
226+ {
227+ case RACE_GOLEM:
228+ case RACE_SKELETON:
229+ case RACE_ZOMBIE:
230+ case RACE_VAMPIRE:
231+ case RACE_DEMON:
232+ case RACE_SPECTRE:
233+ dam = 0;
234+ ignore_wraith_form = TRUE;
235+ break;
236+ }
237+ }
238+ break;
239+
240+ case GF_HOLY_FIRE:
241+ if (p_ptr->align > 10) dam /= 2;
242+ else if (p_ptr->align < -10) dam *= 2;
243+ break;
244+
245+ case GF_HELL_FIRE:
246+ if (p_ptr->align > 10) dam *= 2;
247+ break;
248+
249+ case GF_MIND_BLAST:
250+ case GF_BRAIN_SMASH:
251+ if (100 + rlev / 2 <= MAX(5, p_ptr->skill_sav))
252+ {
253+ dam = 0;
254+ ignore_wraith_form = TRUE;
255+ }
256+ break;
257+
258+ case GF_CAUSE_1:
259+ case GF_CAUSE_2:
260+ case GF_CAUSE_3:
261+ case GF_HAND_DOOM:
262+ if (100 + rlev / 2 <= p_ptr->skill_sav)
263+ {
264+ dam = 0;
265+ ignore_wraith_form = TRUE;
266+ }
267+ break;
268+
269+ case GF_CAUSE_4:
270+ if ((100 + rlev / 2 <= p_ptr->skill_sav) && (m_ptr->r_idx != MON_KENSHIROU))
271+ {
272+ dam = 0;
273+ ignore_wraith_form = TRUE;
274+ }
275+ break;
276+ }
277+
278+ if (p_ptr->wraith_form && !ignore_wraith_form)
279+ {
280+ dam /= 2;
281+ if (!dam) dam = 1;
282+ }
283+
284+ if (dam > *max) *max = dam;
285+}
286+
287+/*!
288+* @brief 警告基準を定めるために魔法の効果属性に基づいて最大魔法ダメージを計算する。 /
289+* Calculate spell damages
290+* @param spell_num RF4ならRF4_SPELL_STARTのように32区切りのベースとなる数値
291+* @param typ 効果属性のID
292+* @param m_idx 魔法を行使するモンスターのID
293+* @param max 算出した最大ダメージを返すポインタ
294+* @return なし
295+*/
296+void spell_damcalc_by_spellnum(int spell_num, EFFECT_ID typ, MONSTER_IDX m_idx, int *max)
297+{
298+ monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
299+ HIT_POINT dam = monspell_damage((spell_num), m_idx, DAM_MAX);
300+ spell_damcalc(m_ptr, typ, dam, max);
301+}
302+
303+/*!
304+ * @brief 警告基準を定めるためにモンスターの打撃最大ダメージを算出する /
305+ * Calculate blow damages
306+ * @param m_ptr 打撃を行使するモンスターの構造体参照ポインタ
307+ * @param blow_ptr モンスターの打撃能力の構造体参照ポインタ
308+ * @return 算出された最大ダメージを返す。
309+ */
310+static int blow_damcalc(monster_type *m_ptr, monster_blow *blow_ptr)
311+{
312+ int dam = blow_ptr->d_dice * blow_ptr->d_side;
313+ int dummy_max = 0;
314+ bool check_wraith_form = TRUE;
315+
316+ if (blow_ptr->method != RBM_EXPLODE)
317+ {
318+ ARMOUR_CLASS ac = p_ptr->ac + p_ptr->to_a;
319+
320+ switch (blow_ptr->effect)
321+ {
322+ case RBE_SUPERHURT:
323+ {
324+ int tmp_dam = dam - (dam * ((ac < 150) ? ac : 150) / 250);
325+ dam = MAX(dam, tmp_dam * 2);
326+ break;
327+ }
328+
329+ case RBE_HURT:
330+ case RBE_SHATTER:
331+ dam -= (dam * ((ac < 150) ? ac : 150) / 250);
332+ break;
333+
334+ case RBE_ACID:
335+ spell_damcalc(m_ptr, GF_ACID, dam, &dummy_max);
336+ dam = dummy_max;
337+ check_wraith_form = FALSE;
338+ break;
339+
340+ case RBE_ELEC:
341+ spell_damcalc(m_ptr, GF_ELEC, dam, &dummy_max);
342+ dam = dummy_max;
343+ check_wraith_form = FALSE;
344+ break;
345+
346+ case RBE_FIRE:
347+ spell_damcalc(m_ptr, GF_FIRE, dam, &dummy_max);
348+ dam = dummy_max;
349+ check_wraith_form = FALSE;
350+ break;
351+
352+ case RBE_COLD:
353+ spell_damcalc(m_ptr, GF_COLD, dam, &dummy_max);
354+ dam = dummy_max;
355+ check_wraith_form = FALSE;
356+ break;
357+
358+ case RBE_DR_MANA:
359+ dam = 0;
360+ check_wraith_form = FALSE;
361+ break;
362+ }
363+
364+ if (check_wraith_form && p_ptr->wraith_form)
365+ {
366+ dam /= 2;
367+ if (!dam) dam = 1;
368+ }
369+ }
370+ else
371+ {
372+ dam = (dam + 1) / 2;
373+ spell_damcalc(m_ptr, mbe_info[blow_ptr->effect].explode_type, dam, &dummy_max);
374+ dam = dummy_max;
375+ }
376+
377+ return dam;
378+}
379+
380+/*!
381+ * @brief プレイヤーが特定地点へ移動した場合に警告を発する処理 /
382+ * Examine the grid (xx,yy) and warn the player if there are any danger
383+ * @param xx 危険性を調査するマスのX座標
384+ * @param yy 危険性を調査するマスのY座標
385+ * @return 警告を無視して進むことを選択するかか問題が無ければTRUE、警告に従ったならFALSEを返す。
386+ */
387+bool process_warning(POSITION xx, POSITION yy)
388+{
389+ POSITION mx, my;
390+ grid_type *g_ptr;
391+ GAME_TEXT o_name[MAX_NLEN];
392+
393+#define WARNING_AWARE_RANGE 12
394+ int dam_max = 0;
395+ static int old_damage = 0;
396+
397+ for (mx = xx - WARNING_AWARE_RANGE; mx < xx + WARNING_AWARE_RANGE + 1; mx++)
398+ {
399+ for (my = yy - WARNING_AWARE_RANGE; my < yy + WARNING_AWARE_RANGE + 1; my++)
400+ {
401+ int dam_max0 = 0;
402+ monster_type *m_ptr;
403+ monster_race *r_ptr;
404+
405+ if (!in_bounds(my, mx) || (distance(my, mx, yy, xx) > WARNING_AWARE_RANGE)) continue;
406+
407+ g_ptr = &current_floor_ptr->grid_array[my][mx];
408+
409+ if (!g_ptr->m_idx) continue;
410+
411+ m_ptr = &current_floor_ptr->m_list[g_ptr->m_idx];
412+
413+ if (MON_CSLEEP(m_ptr)) continue;
414+ if (!is_hostile(m_ptr)) continue;
415+
416+ r_ptr = &r_info[m_ptr->r_idx];
417+
418+ /* Monster spells (only powerful ones)*/
419+ if (projectable(my, mx, yy, xx))
420+ {
421+ BIT_FLAGS f4 = r_ptr->flags4;
422+ BIT_FLAGS f5 = r_ptr->a_ability_flags1;
423+ BIT_FLAGS f6 = r_ptr->a_ability_flags2;
424+
425+ if (!(d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_MAGIC))
426+ {
427+ if (f4 & RF4_BA_CHAO) spell_damcalc_by_spellnum(MS_BALL_CHAOS, GF_CHAOS, g_ptr->m_idx, &dam_max0);
428+ if (f5 & RF5_BA_MANA) spell_damcalc_by_spellnum(MS_BALL_MANA, GF_MANA, g_ptr->m_idx, &dam_max0);
429+ if (f5 & RF5_BA_DARK) spell_damcalc_by_spellnum(MS_BALL_DARK, GF_DARK, g_ptr->m_idx, &dam_max0);
430+ if (f5 & RF5_BA_LITE) spell_damcalc_by_spellnum(MS_STARBURST, GF_LITE, g_ptr->m_idx, &dam_max0);
431+ if (f6 & RF6_HAND_DOOM) spell_damcalc_by_spellnum(MS_HAND_DOOM, GF_HAND_DOOM, g_ptr->m_idx, &dam_max0);
432+ if (f6 & RF6_PSY_SPEAR) spell_damcalc_by_spellnum(MS_PSY_SPEAR, GF_PSY_SPEAR, g_ptr->m_idx, &dam_max0);
433+ }
434+ if (f4 & RF4_ROCKET) spell_damcalc_by_spellnum(MS_ROCKET, GF_ROCKET, g_ptr->m_idx, &dam_max0);
435+ if (f4 & RF4_BR_ACID) spell_damcalc_by_spellnum(MS_BR_ACID, GF_ACID, g_ptr->m_idx, &dam_max0);
436+ if (f4 & RF4_BR_ELEC) spell_damcalc_by_spellnum(MS_BR_ELEC, GF_ELEC, g_ptr->m_idx, &dam_max0);
437+ if (f4 & RF4_BR_FIRE) spell_damcalc_by_spellnum(MS_BR_FIRE, GF_FIRE, g_ptr->m_idx, &dam_max0);
438+ if (f4 & RF4_BR_COLD) spell_damcalc_by_spellnum(MS_BR_COLD, GF_COLD, g_ptr->m_idx, &dam_max0);
439+ if (f4 & RF4_BR_POIS) spell_damcalc_by_spellnum(MS_BR_POIS, GF_POIS, g_ptr->m_idx, &dam_max0);
440+ if (f4 & RF4_BR_NETH) spell_damcalc_by_spellnum(MS_BR_NETHER, GF_NETHER, g_ptr->m_idx, &dam_max0);
441+ if (f4 & RF4_BR_LITE) spell_damcalc_by_spellnum(MS_BR_LITE, GF_LITE, g_ptr->m_idx, &dam_max0);
442+ if (f4 & RF4_BR_DARK) spell_damcalc_by_spellnum(MS_BR_DARK, GF_DARK, g_ptr->m_idx, &dam_max0);
443+ if (f4 & RF4_BR_CONF) spell_damcalc_by_spellnum(MS_BR_CONF, GF_CONFUSION, g_ptr->m_idx, &dam_max0);
444+ if (f4 & RF4_BR_SOUN) spell_damcalc_by_spellnum(MS_BR_SOUND, GF_SOUND, g_ptr->m_idx, &dam_max0);
445+ if (f4 & RF4_BR_CHAO) spell_damcalc_by_spellnum(MS_BR_CHAOS, GF_CHAOS, g_ptr->m_idx, &dam_max0);
446+ if (f4 & RF4_BR_DISE) spell_damcalc_by_spellnum(MS_BR_DISEN, GF_DISENCHANT, g_ptr->m_idx, &dam_max0);
447+ if (f4 & RF4_BR_NEXU) spell_damcalc_by_spellnum(MS_BR_NEXUS, GF_NEXUS, g_ptr->m_idx, &dam_max0);
448+ if (f4 & RF4_BR_TIME) spell_damcalc_by_spellnum(MS_BR_TIME, GF_TIME, g_ptr->m_idx, &dam_max0);
449+ if (f4 & RF4_BR_INER) spell_damcalc_by_spellnum(MS_BR_INERTIA, GF_INERTIAL, g_ptr->m_idx, &dam_max0);
450+ if (f4 & RF4_BR_GRAV) spell_damcalc_by_spellnum(MS_BR_GRAVITY, GF_GRAVITY, g_ptr->m_idx, &dam_max0);
451+ if (f4 & RF4_BR_SHAR) spell_damcalc_by_spellnum(MS_BR_SHARDS, GF_SHARDS, g_ptr->m_idx, &dam_max0);
452+ if (f4 & RF4_BR_PLAS) spell_damcalc_by_spellnum(MS_BR_PLASMA, GF_PLASMA, g_ptr->m_idx, &dam_max0);
453+ if (f4 & RF4_BR_WALL) spell_damcalc_by_spellnum(MS_BR_FORCE, GF_FORCE, g_ptr->m_idx, &dam_max0);
454+ if (f4 & RF4_BR_MANA) spell_damcalc_by_spellnum(MS_BR_MANA, GF_MANA, g_ptr->m_idx, &dam_max0);
455+ if (f4 & RF4_BR_NUKE) spell_damcalc_by_spellnum(MS_BR_NUKE, GF_NUKE, g_ptr->m_idx, &dam_max0);
456+ if (f4 & RF4_BR_DISI) spell_damcalc_by_spellnum(MS_BR_DISI, GF_DISINTEGRATE, g_ptr->m_idx, &dam_max0);
457+ }
458+
459+ /* Monster melee attacks */
460+ if (!(r_ptr->flags1 & RF1_NEVER_BLOW) && !(d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_MELEE))
461+ {
462+ if (mx <= xx + 1 && mx >= xx - 1 && my <= yy + 1 && my >= yy - 1)
463+ {
464+ int m;
465+ int dam_melee = 0;
466+ for (m = 0; m < 4; m++)
467+ {
468+ /* Skip non-attacks */
469+ if (!r_ptr->blow[m].method || (r_ptr->blow[m].method == RBM_SHOOT)) continue;
470+
471+ /* Extract the attack info */
472+ dam_melee += blow_damcalc(m_ptr, &r_ptr->blow[m]);
473+ if (r_ptr->blow[m].method == RBM_EXPLODE) break;
474+ }
475+ if (dam_melee > dam_max0) dam_max0 = dam_melee;
476+ }
477+ }
478+
479+ /* Contribution from this monster */
480+ dam_max += dam_max0;
481+ }
482+ }
483+
484+ /* Prevent excessive warning */
485+ if (dam_max > old_damage)
486+ {
487+ old_damage = dam_max * 3 / 2;
488+
489+ if (dam_max > p_ptr->chp / 2)
490+ {
491+ object_type *o_ptr = choose_warning_item();
492+
493+ if (o_ptr)
494+ object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
495+ else
496+ strcpy(o_name, _("体", "body")); /* Warning ability without item */
497+ msg_format(_("%sが鋭く震えた!", "Your %s pulsates sharply!"), o_name);
498+
499+ disturb(FALSE, TRUE);
500+ return get_check(_("本当にこのまま進むか?", "Really want to go ahead? "));
501+ }
502+ }
503+ else old_damage = old_damage / 2;
504+
505+ g_ptr = &current_floor_ptr->grid_array[yy][xx];
506+ if (((!easy_disarm && is_trap(g_ptr->feat))
507+ || (g_ptr->mimic && is_trap(g_ptr->feat))) && !one_in_(13))
508+ {
509+ object_type *o_ptr = choose_warning_item();
510+
511+ if (o_ptr)
512+ object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
513+ else
514+ strcpy(o_name, _("体", "body")); /* Warning ability without item */
515+ msg_format(_("%sが鋭く震えた!", "Your %s pulsates sharply!"), o_name);
516+ disturb(FALSE, TRUE);
517+ return get_check(_("本当にこのまま進むか?", "Really want to go ahead? "));
518+ }
519+
520+ return TRUE;
521+}
522+
--- /dev/null
+++ b/src/warning.h
@@ -0,0 +1,4 @@
1+#pragma once
2+
3+extern object_type *choose_warning_item(void);
4+extern bool process_warning(POSITION xx, POSITION yy);
Show on old repository browser