Version: 1.0 Author: Vlue L. Release Date: 2/17/2012
Introduction Simple script to run Event Commands based on a true or false conditional branch call within events.
Features -Allow any Event Commands to run based on whether the player is within or not within range of the event, a specific event, or a set location on the map. -Recommended usage: Within an event or events running as parallel processes to check for proximity and run Event Commands as needed.
Script
Script:
CODE
#----TITLE-------------------------------------------------------------------# # A simple script to trigger events based on circular proximity from # the player. # Disclaimer? Give credit where credit is due #-------------------------Code by: Vlue L.
#----USE---------------------------------------------------------------------# # Used by inserting a conditional branch script call from within any event # (Usually one running by parallel process) or however you want # Script call: Proxy.inprox?(@event_id, distance) # -or- # Proxy.inprox?(nil, distance, x, y) # # $PROXYRANGE = distance # where: # -> "@event_id" is equal to the id of the event if not called from # within the event itself or nil if being called for a set position # -> "distance" is equal to the radius of the proximity range # -> "x" and "y" are equal to the location for proximity if being called # for a set position #-----------------------------------#
#----EXAMPLE-----------------------------------------------------------------# # Based on call within specific event with default range: # Proxy.inprox?(@event_id) # Based on a radius of 5, called within the specific event: # Proxy.inprox?(@event_id, 3) # Based on a radius of 3 called from Common Event or similar for Event 0003: # Proxy.inprox?(3, 3) # Based on a radius of 2 for specific point (7, 8) on map: # Proxy.inprox?(nil, 2, 7, 8) #-----------------------------------#
#Default radius of detection: $PROXYRANGE = 3 #----#
class Proxy def self.inprox?(id, distance = $PROXYRANGE, x = 0, y = 0) if id != nil x = $game_map.events[id].x y = $game_map.events[id].y end iter = x + distance + 1 #find max iterations iter2 = 0 half = x x = x - distance while x < iter ylow = y - iter2 #<>Define range yhigh = y + iter2 if $game_player.x == x and $game_player.y >= ylow and $game_player.y <= yhigh return true end x += 1 #change x iteration if x > half then iter2 -= 1 else iter2 += 1 end #change y iteration end return false end end
Customization Default detection radius can be changed with the scrip call "$PROXYRANGE = distance" where distance is any whole number
Compatibility No incompatibilities
Screenshot
Screenshot:
DEMO Will make if needed.
Installation Put below MATERIALS and above MAIN
FAQ TBA
Terms and Conditions Not to be used to take over the world or anything else equally sinister. Not recommended for ingestion or direct contact with skin. May be used in any commercial or individual work.
Credits Devon S.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.