Heres a script from foreverzero called event range conditions... only problem with this one is it only checks players distance to events... does not check distance from event to event and thats what im looking for
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
# Event Range Conditions
# Author: ForeverZer0
# Date: 5.1.2011
# Version: 1.1
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
#
# Explanation:
#
# Allows you to set up conditional branches in events that will be based off
# the event's coordinates in relation to the player's coordinates without
# having to create any variables for the X and Y of each.
#
# Here are the new features you can use a conditional branch. Just type these
# into the script box for the branch.
#
# range?(RANGE, EVENT_ID) - Will be true if player is anywhere in the radius
# defined by RANGE from the event with EVENT_ID
#
# on_screen?(EVENT_ID) - Will be true if the event with EVENT_ID is within
# the visible screen
#
# x_dist?(DIST, EVENT_ID) - Returns true if the player's x/y is within DIST
# OR of event's x/y with EVENT_ID. These are absolute
# y_dist?(DIST, EVENT_ID) values, meaning it doesn't matter which direction,
# it just uses the total distance in tiles for that
# axis. Use a DIST of 0 to check if that axis is
# equal.
#
# player_above?(EVENT_ID) - Returns true when player is above event.
# player_below?(EVENT_ID) - Returns true when player is below event.
# player_right?(EVENT_ID) - Returns true when player is right of the event.
# player_left?(EVENT_ID) - Returns true when player is left of the event.
#
# For all of these, if the conditional branch that is using them is within
# the event that it applies to, you do not have to include the EVENT_ID, it
# is assumed to be that event's ID unless otherwise defined.
#
# You can use these as a condition for just about anything, such as having
# an event say something, run away, or run toward the player if it is within a
# specific distance, and it's much easier than using multiple branches and
# game variables to set it up.
#
# Remember that if you use a range condition with a parallel trigger, it will
# continue to execute as long as the condition is met and if the player cannot
# move during the event's code, the game will effectively be stuck.
#
# Compatability:
#
# - You may encounter issues if using a Pixel Movement script, though it
# should still work fine with an 8-Way Movement script. (Not tested)
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
class Interpreter
def range?(range = 4, id = @event_id)
e = $game_
map.events[id]
radius = (Math.hypot((e.x - $game_player.x), (e.y - $game_player.y))).abs
return (radius <= range)
end
def on_screen?(id = @event_id)
x, y = $game_
map.events[id].real_x, $game_
map.events[id].real_y
return ((x - $game_map.display_x + 64) / 4).between?(0, 640) &&
((y - $game_map.display_y) / 4).between?(0, 480)
end
def x_dist?(distance = 0, id = @event_id)
x_dif = ($game_
map.events[id].x - $game_player.x).abs
return (x_dif <= distance)
end
def y_dist?(distance = 0, id = @event_id)
y_dif = ($game_
map.events[id].y - $game_player.y).abs
return (y_dif <= distance)
end
def player_above?(id = @event_id)
return ($game_
map.events[id].y > $game_player.y)
end
def player_below?(id = @event_id)
return ($game_
map.events[id].y < $game_player.y)
end
def player_right?(id = @event_id)
return ($game_
map.events[id].x < $game_player.x)
end
def player_left?(id = @event_id)
return ($game_
map.events[id].x > $game_player.x)
end
end