Jump to content

miniet

Member
  • Content Count

    3
  • Joined

  • Last visited

  • Days Won

    1

miniet last won the day on July 21

miniet had the most liked content!

About miniet

  • Rank
    Newbie
  1. miniet

    Find nearest Event ID with nametag script

    Oh. and I found distance formula calculated by pythagoras theorem Distance = sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2)) I will adapt a new formula to script then watch it can gives.
  2. miniet

    Find nearest Event ID with nametag script

    I've changed script like this $game_map.events[$game_variables[1]].distance_x_from($game_map.events[id].x).abs + $game_map.events[$game_variables[1]].distance_y_from($game_map.events[id].y).abs and in the game for event(1) - self $game_variables[1] == event_id and use script call like below $game_variables[2] == nearest_enemy when playing it, game doesn't crash but i'm not sure this solves the problem perfectly. and Shaz said this formula doesn't get nearest distance. so i'm little bit confused. How to get nearest distance? Is there any other formula? so far changing player to event based is solved i guess.
  3. Does anybody knows how to check nearest Event ID from this Event(@event_id)? ex) This Event(1) -> Event(2) is nearest distance from event(1) need to know Event(2)'s ID with script down below or another script can run this. I use meawface's script but it is player based so wanna change "player" part to "this_event". but changing "$game_player" to "$game_map.events[@event_id]" doesn't seem to work. and nametag based searching event ID could be more helpful. attached meawface's full script and link below https://forums.rpgmakerweb.com/index.php?threads/enemy-distance-scanner-radar.46115/ ==================================================================== # ■ Meow Face Enemy Distance 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 this Script Call to get the closest enemy's id (in Control Variables Script box) # closest # eg. # Control Variables 1 = closest #=================================================================== 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? end end class Game_Event < Game_Character def enemy? @event.name.include?('<enemy>') end end class Game_Interpreter def nearest_enemy $game_map.scan_nearest end end
×