RPG Maker Forums

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.

      

[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
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:

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

Latest Threads

Latest Posts

Latest Profile Posts

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.

Forum statistics

Threads
106,035
Messages
1,018,455
Members
137,821
Latest member
Capterson
Top