From 3ca98d1ca15618e23eaec9f172338b1cc86afa3b Mon Sep 17 00:00:00 2001 From: Hourier Date: Wed, 22 Jul 2020 21:32:53 +0900 Subject: [PATCH] [Refactor] #40480 Separated check_melee_spell_breath() from monst_spell_monst() --- src/melee/melee-spell.c | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/src/melee/melee-spell.c b/src/melee/melee-spell.c index 4198a7cc2..4b3cc1f4e 100644 --- a/src/melee/melee-spell.c +++ b/src/melee/melee-spell.c @@ -162,7 +162,7 @@ static void check_melee_spell_distance(player_type *target_ptr, melee_spell_type ms_ptr->f6 &= ~(RF6_BALL_MASK); return; } - + if (dist > 4) return; @@ -171,6 +171,31 @@ static void check_melee_spell_distance(player_type *target_ptr, melee_spell_type ms_ptr->f6 &= ~(RF6_BIG_BALL_MASK); } +static void check_melee_spell_breath(player_type *target_ptr, melee_spell_type *ms_ptr) +{ + if (((ms_ptr->f4 & RF4_BREATH_MASK) == 0) && ((ms_ptr->f5 & RF5_BREATH_MASK) == 0) && ((ms_ptr->f6 & RF6_BREATH_MASK) == 0)) + return; + + POSITION rad = (ms_ptr->r_ptr->flags2 & RF2_POWERFUL) ? 3 : 2; + if (!breath_direct(target_ptr, ms_ptr->m_ptr->fy, ms_ptr->m_ptr->fx, ms_ptr->t_ptr->fy, ms_ptr->t_ptr->fx, rad, 0, TRUE)) { + ms_ptr->f4 &= ~(RF4_BREATH_MASK); + ms_ptr->f5 &= ~(RF5_BREATH_MASK); + ms_ptr->f6 &= ~(RF6_BREATH_MASK); + return; + } + + if ((ms_ptr->f4 & RF4_BR_LITE) + && !breath_direct(target_ptr, ms_ptr->m_ptr->fy, ms_ptr->m_ptr->fx, ms_ptr->t_ptr->fy, ms_ptr->t_ptr->fx, rad, GF_LITE, TRUE)) { + ms_ptr->f4 &= ~(RF4_BR_LITE); + return; + } + + if ((ms_ptr->f4 & RF4_BR_DISI) + && !breath_direct(target_ptr, ms_ptr->m_ptr->fy, ms_ptr->m_ptr->fx, ms_ptr->t_ptr->fy, ms_ptr->t_ptr->fx, rad, GF_DISINTEGRATE, TRUE)) { + ms_ptr->f4 &= ~(RF4_BR_DISI); + } +} + /*! * @brief モンスターが敵モンスターに特殊能力を使う処理のメインルーチン / * Monster tries to 'cast a spell' (or breath, etc) at another monster. @@ -259,20 +284,7 @@ bool monst_spell_monst(player_type *target_ptr, MONSTER_IDX m_idx) ms_ptr->f6 &= ~(RF6_BEAM_MASK); } - if ((ms_ptr->f4 & RF4_BREATH_MASK) || (ms_ptr->f5 & RF5_BREATH_MASK) || (ms_ptr->f6 & RF6_BREATH_MASK)) { - POSITION rad = (ms_ptr->r_ptr->flags2 & RF2_POWERFUL) ? 3 : 2; - if (!breath_direct(target_ptr, ms_ptr->m_ptr->fy, ms_ptr->m_ptr->fx, ms_ptr->t_ptr->fy, ms_ptr->t_ptr->fx, rad, 0, TRUE)) { - ms_ptr->f4 &= ~(RF4_BREATH_MASK); - ms_ptr->f5 &= ~(RF5_BREATH_MASK); - ms_ptr->f6 &= ~(RF6_BREATH_MASK); - } else if ((ms_ptr->f4 & RF4_BR_LITE) - && !breath_direct(target_ptr, ms_ptr->m_ptr->fy, ms_ptr->m_ptr->fx, ms_ptr->t_ptr->fy, ms_ptr->t_ptr->fx, rad, GF_LITE, TRUE)) { - ms_ptr->f4 &= ~(RF4_BR_LITE); - } else if ((ms_ptr->f4 & RF4_BR_DISI) - && !breath_direct(target_ptr, ms_ptr->m_ptr->fy, ms_ptr->m_ptr->fx, ms_ptr->t_ptr->fy, ms_ptr->t_ptr->fx, rad, GF_DISINTEGRATE, TRUE)) { - ms_ptr->f4 &= ~(RF4_BR_DISI); - } - } + check_melee_spell_breath(target_ptr, ms_ptr); } if (ms_ptr->f6 & RF6_SPECIAL) { -- 2.11.0