From 53dad4c496a78bcf5bec35d3326fa9d927eaa4d7 Mon Sep 17 00:00:00 2001 From: Hourier Date: Mon, 13 Jan 2020 15:21:39 +0900 Subject: [PATCH] =?utf8?q?[Refactor]=20#38997=20get=5Ffear=5Fmoves=5Faux()?= =?utf8?q?=20=E3=81=ABplayer=5Ftype=20*=20=E5=BC=95=E6=95=B0=E3=82=92?= =?utf8?q?=E8=BF=BD=E5=8A=A0=20/=20Added=20player=5Ftype=20*=20argument=20?= =?utf8?q?to=20get=5Ffear=5Fmoves=5Faux()?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/monster-process.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/monster-process.c b/src/monster-process.c index 171d39da9..b32c41fa6 100644 --- a/src/monster-process.c +++ b/src/monster-process.c @@ -522,13 +522,13 @@ static bool get_moves_aux(player_type *target_ptr, MONSTER_IDX m_idx, POSITION * * but instead of heading directly for it, the monster should "swerve"\n * around the player so that he has a smaller chance of getting hit.\n */ -static bool get_fear_moves_aux(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp) +static bool get_fear_moves_aux(floor_type *floor_ptr, MONSTER_IDX m_idx, POSITION *yp, POSITION *xp) { POSITION y, x, y1, x1, fy, fx, gy = 0, gx = 0; int score = -1; int i; - monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[m_idx]; + monster_type *m_ptr = &floor_ptr->m_list[m_idx]; /* Monster location */ fy = m_ptr->fy; @@ -547,13 +547,13 @@ static bool get_fear_moves_aux(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp) x = fx + ddx_ddd[i]; /* Ignore locations off of edge */ - if (!in_bounds2(p_ptr->current_floor_ptr, y, x)) continue; + if (!in_bounds2(floor_ptr, y, x)) continue; /* Calculate distance of this grid from our destination */ dis = distance(y, x, y1, x1); /* Score this grid */ - s = 5000 / (dis + 3) - 500 / (p_ptr->current_floor_ptr->grid_array[y][x].dist + 1); + s = 5000 / (dis + 3) - 500 / (floor_ptr->grid_array[y][x].dist + 1); /* No negative scores */ if (s < 0) s = 0; @@ -1030,7 +1030,7 @@ static bool get_moves(player_type *target_ptr, MONSTER_IDX m_idx, DIRECTION *mm) if (!no_flow) { /* Adjust movement */ - if (get_fear_moves_aux(m_idx, &y, &x)) done = TRUE; + if (get_fear_moves_aux(target_ptr->current_floor_ptr, m_idx, &y, &x)) done = TRUE; } } -- 2.11.0