From: Hourier Date: Wed, 22 Jul 2020 12:33:59 +0000 (+0900) Subject: [Refactor] #40480 Separated check_melee_spell_rocket() from monst_spell_monst() X-Git-Tag: vmacos3.0.0-alpha52~782^2~13 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=0ee2b742ab7c8e3442216aab91af92ba2a1565d1;p=hengbandforosx%2Fhengbandosx.git [Refactor] #40480 Separated check_melee_spell_rocket() from monst_spell_monst() --- diff --git a/src/melee/melee-spell.c b/src/melee/melee-spell.c index 4b3cc1f4e..788092657 100644 --- a/src/melee/melee-spell.c +++ b/src/melee/melee-spell.c @@ -171,6 +171,18 @@ 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_rocket(player_type *target_ptr, melee_spell_type *ms_ptr) +{ + if ((ms_ptr->f4 & RF4_ROCKET) == 0) + return; + + POSITION real_y = ms_ptr->y; + POSITION real_x = ms_ptr->x; + get_project_point(target_ptr, ms_ptr->m_ptr->fy, ms_ptr->m_ptr->fx, &real_y, &real_x, PROJECT_STOP); + if (projectable(target_ptr, real_y, real_x, target_ptr->y, target_ptr->x) && (distance(real_y, real_x, target_ptr->y, target_ptr->x) <= 2)) + ms_ptr->f4 &= ~(RF4_ROCKET); +} + 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)) @@ -269,14 +281,7 @@ bool monst_spell_monst(player_type *target_ptr, MONSTER_IDX m_idx) if (!(target_ptr->pet_extra_flags & PF_BALL_SPELL) && (m_idx != target_ptr->riding)) { check_melee_spell_distance(target_ptr, ms_ptr); - if (ms_ptr->f4 & RF4_ROCKET) { - POSITION real_y = ms_ptr->y; - POSITION real_x = ms_ptr->x; - get_project_point(target_ptr, ms_ptr->m_ptr->fy, ms_ptr->m_ptr->fx, &real_y, &real_x, PROJECT_STOP); - if (projectable(target_ptr, real_y, real_x, target_ptr->y, target_ptr->x) && (distance(real_y, real_x, target_ptr->y, target_ptr->x) <= 2)) - ms_ptr->f4 &= ~(RF4_ROCKET); - } - + check_melee_spell_rocket(target_ptr, ms_ptr); if (((ms_ptr->f4 & RF4_BEAM_MASK) || (ms_ptr->f5 & RF5_BEAM_MASK) || (ms_ptr->f6 & RF6_BEAM_MASK)) && !direct_beam(target_ptr, ms_ptr->m_ptr->fy, ms_ptr->m_ptr->fx, ms_ptr->t_ptr->fy, ms_ptr->t_ptr->fx, ms_ptr->m_ptr)) { ms_ptr->f4 &= ~(RF4_BEAM_MASK);