Made for a request here.
This script acts like a radar/scanner to check the distance of the player from the enemy events on the map.
Features:
[1] Able to check the nearest enemy and return the event's id.
[2] Able to list down a list of enemy event's ids and their distance from the player.
[3] Able to check any event's distance from player.
How to Use:
[1] Script itself is plug and play, simply paste it below Material and above Main.
[2] To make an event scan-able by the radar, you will need to add <enemy> tag to the event's name.
[IMG]http://s30.postimg.org/79ddzbvhp/enemytag.png[/IMG]
[3] Script calls for scanning:
Pair these with Control Variables' Script box to output the result to game variable.
eg. Control Variables: [0001] = nearest_enemy
Compatibility:
Should be compatible with other custom scripts.
Terms of Use:
Free for both Commercial and Non-commercial
Script:
This script acts like a radar/scanner to check the distance of the player from the enemy events on the map.
Features:
[1] Able to check the nearest enemy and return the event's id.
[2] Able to list down a list of enemy event's ids and their distance from the player.
[3] Able to check any event's distance from player.
How to Use:
[1] Script itself is plug and play, simply paste it below Material and above Main.
[2] To make an event scan-able by the radar, you will need to add <enemy> tag to the event's name.
[IMG]http://s30.postimg.org/79ddzbvhp/enemytag.png[/IMG]
[3] Script calls for scanning:
Get distance value of Event X from Player
$game_map.distance_from(id)id = any event's id (works for event without name tag)
Get distance of all Enemies from Player
$game_map.scan_targetThis will list all the enemy event's id and their distance from the player
Get the nearest enemy event's id
nearest_enemythis will return the event's id of the nearest enemy
$game_map.distance_from(id)id = any event's id (works for event without name tag)
Get distance of all Enemies from Player
$game_map.scan_targetThis will list all the enemy event's id and their distance from the player
Get the nearest enemy event's id
nearest_enemythis will return the event's id of the nearest enemy
eg. Control Variables: [0001] = nearest_enemy
Compatibility:
Should be compatible with other custom scripts.
Terms of Use:
Free for both Commercial and Non-commercial
Script:
Code:
#==============================================================================# ■ Meow Face Enemy Scanner#------------------------------------------------------------------------------# Return the ID of the nearest Event (from player position)#==============================================================================# How to Use:# [1] Put this script below Material and above Main# [2] Put this name tag on events you want to scan: <enemy># [3] Use Script Calls "nearest" to get the nearest enemy#==============================================================================class Game_Map def distance_from(id) $game_player.distance_x_from($game_map.events[id].x).abs + $game_player.distance_y_from($game_map.events[id].y).abs end def scan_target meowradar = {} @events.values.each do |meow| if meow.enemy? meowscan = distance_from(meow.id) meowtarget = (meow.id).to_s meowradar[meowtarget] = meowscan end end meowradar end def scan_nearest scan_target.min_by{|k,v| v}[0] if !scan_target.empty? endendclass Game_Event < Game_Character def enemy? @event.name.include?('<enemy>') endendclass Game_Interpreter def nearest_enemy $game_map.scan_nearest endend