def pbMoveRivalInPlace
dest_x = 69 # Change this!
dest_y = 420 # Change this!
rival_event_id = 0 # Change this! 0 if the event calling this script IS the rival event
#====================================
# No need to change below here!
#====================================
rival = get_character(rival_event_id)
is_west = rival.x > dest_x
is_north = rival.y > dest_y
dirs = []
# Establishes which directions the rival should go in
if is_north
if is_west # Rival has to move NW
# If player faces down, go W, N. Otherwise, go W, N
dirs = $game_player.direction == 2 ? [:W, :N] : [:N, :W] works
else # Rival may have to move NE
# If player faces down, go E, N. Otherwise, go N, E
dirs = $game_player.direction == 2 ? [:E, :N] : [:N, :E] works
end
else
if is_west # Rival has to move NW
# If player faces up, go W, S. Otherwise, go W, S
dirs = $game_player.direction == 8 ? [:W, :S] : [:S, :W] works
else # Rival may have to move SE
# If player faces up, go E, S. Otherwise, go S, E
dirs = $game_player.direction == 8 ? [:E, :S] : [:S, :E] works
end
end
move_route = []
# Works out steps to do
for dir in dirs
case dir
when :N
(rival.y - dest_y).times do
move_route.push(PBMoveRoute::Up)
end
when :S
(dest_y - rival.y).times do
move_route.push(PBMoveRoute::Down)
end
when :W
(rival.x - dest_x).times do
move_route.push(PBMoveRoute::Left)
end
when :E
(dest_x - rival.x).times do
move_route.push(PBMoveRoute::Right)
end
end
end
# Actual Movement
return if move_route.empty?
pbMoveRoute(mover, move_route)
# Below line allows movement to take place!
to_wait = 0.5 * move_route.length
pbWait(to_wait) if to_wait > 0
end