From 34849268b2adc315d71b1674fe3ce765ce50221e Mon Sep 17 00:00:00 2001 From: nothere Date: Fri, 13 Jun 2003 17:27:07 +0000 Subject: [PATCH] =?utf8?q?get=5Fmoves()=E5=86=85=E3=81=A7,=20get=5Fmoves?= =?utf8?q?=5Faux()=E3=82=92=E5=BF=85=E8=A6=81=E3=81=A8=E3=81=9B=E3=81=9A?= =?utf8?q?=E3=81=AB=E6=96=B9=E5=90=91=E3=81=8C=E6=B1=BA=E3=81=BE=E3=82=8B?= =?utf8?q?=E5=A0=B4=E5=90=88=E3=81=AF=20get=5Fmoves=5Faux()=E3=82=92?= =?utf8?q?=E5=91=BC=E3=81=B0=E3=81=AA=E3=81=84=E3=82=88=E3=81=86=E3=81=AB?= =?utf8?q?=E5=A4=89=E6=9B=B4.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/melee2.c | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/src/melee2.c b/src/melee2.c index 2efd8ba19..dee1e7bf9 100644 --- a/src/melee2.c +++ b/src/melee2.c @@ -1097,18 +1097,9 @@ static bool get_moves(int m_idx, int *mm) int x2 = px; bool done = FALSE; bool will_run = mon_will_run(m_idx); - cave_type *c_ptr; + cave_type *c_ptr; bool no_flow = ((m_ptr->mflag2 & MFLAG2_NOFLOW) && (cave[m_ptr->fy][m_ptr->fx].cost > 2)); - bool can_pass_wall; - - /* Flow towards the player */ - (void)get_moves_aux(m_idx, &y2, &x2, no_flow); - - can_pass_wall = ((r_ptr->flags2 & RF2_PASS_WALL) && ((m_idx != p_ptr->riding) || (p_ptr->pass_wall))); - - /* Extract the "pseudo-direction" */ - y = m_ptr->fy - y2; - x = m_ptr->fx - x2; + bool can_pass_wall = ((r_ptr->flags2 & RF2_PASS_WALL) && ((m_idx != p_ptr->riding) || (p_ptr->pass_wall))); /* Counter attack to an enemy monster */ if (!will_run && m_ptr->target_y) @@ -1120,7 +1111,7 @@ static bool get_moves(int m_idx, int *mm) are_enemies(m_ptr, &m_list[t_m_idx]) && los(m_ptr->fy, m_ptr->fx, m_ptr->target_y, m_ptr->target_x)) { - /* Re-extract the "pseudo-direction" */ + /* Extract the "pseudo-direction" */ y = m_ptr->fy - m_ptr->target_y; x = m_ptr->fx - m_ptr->target_x; done = TRUE; @@ -1144,14 +1135,12 @@ static bool get_moves(int m_idx, int *mm) /* Count room grids next to player */ for (i = 0; i < 8; i++) { - int x = px + ddx_ddd[i]; - int y = py + ddy_ddd[i]; - - cave_type *c_ptr; + int xx = px + ddx_ddd[i]; + int yy = py + ddy_ddd[i]; - if (!in_bounds2(y, x)) continue; - - c_ptr = &cave[y][x]; + if (!in_bounds2(yy, xx)) continue; + + c_ptr = &cave[yy][xx]; /* Check grid */ if (((cave_floor_grid(c_ptr)) || ((c_ptr->feat & 0x60) == 0x60)) && @@ -1214,6 +1203,18 @@ static bool get_moves(int m_idx, int *mm) } } + if (!done) + { + /* Flow towards the player */ + (void)get_moves_aux(m_idx, &y2, &x2, no_flow); + + /* Extract the "pseudo-direction" */ + y = m_ptr->fy - y2; + x = m_ptr->fx - x2; + + /* Not done */ + } + /* Apply fear if possible and necessary */ if (is_pet(m_ptr) && will_run) { -- 2.11.0