MV Get Enemy Location on map

Hello Everybody!

I was wondering if it's possible to get the distance between the player's position and the selected enemy on the map. Right now I am using Alpha ABS plugin, and I am trying to find the distance between the player and the enemy.

I was wondering how you would do that? The enemy on the screenshot is event 2 so I had this:

$gameMap.distance($gamePlayer._x,$gamePlayer._y,$gameMap._events[2]._x,$gameMap._events[2]._y)<15

It works, but this is only for one specific event. I was wondering if there is a more universal way to do it and get the targeted enemy's distance regardless of it's event name. This condition branch will be used in a common event, so I don't think I can use this.eventId, maybe use the enemyId?

Thanks in advance for your help!

Cheers XD
I was wondering if there is a more universal way to do it and get the targeted enemy's distance regardless of it's event name. This condition branch will be used in a common event, so I don't think I can use this.eventId, maybe use the enemyId?
No, because your event is not actually an enemy - an enemy ID is a reference for its information in your database, it has nothing to do with an event on your map.

You can make a common event that's generic, referencing variables that you've stored the event's location in, but at some point you're going to have to set those variables.

I'm not familiar with the ABS plugin you're using, but if it has some way to target the event on the map (you click on it or hit a key or whatever), then inside of that function you could make it store the targeted event's coordinates into two game variables.
No, because your event is not actually an enemy - an enemy ID is a reference for its information in your database, it has nothing to do with an event on your map.

You can make a common event that's generic, referencing variables that you've stored the event's location in, but at some point you're going to have to set those variables.

I'm not familiar with the ABS plugin you're using, but if it has some way to target the event on the map (you click on it or hit a key or whatever), then inside of that function you could make it store the targeted event's coordinates into two game variables.
Hello! Thanks for the insight! Yes exactly what I was thinking 🙂

When the enemy is selected (either by mouse clicking or key), if it is possible to have it's map location with a variable or a script I don't mind. I am still trying to figure it out but no results so far :/
No, because your event is not actually an enemy - an enemy ID is a reference for its information in your database, it has nothing to do with an event on your map.

You can make a common event that's generic, referencing variables that you've stored the event's location in, but at some point you're going to have to set those variables.

I'm not familiar with the ABS plugin you're using, but if it has some way to target the event on the map (you click on it or hit a key or whatever), then inside of that function you could make it store the targeted event's coordinates into two game variables.
Ahh but, this event does reference an enemy in my database (in that case enemy id 3), but I need a more generic way get the enemy's id location w/o saying explicitly which one it is.
1663772073199.png
Ahh but, this event does reference an enemy in my database (in that case enemy id 3)
Okay, but I don't see the difference between extracting the enemy ID from that notetag and simply referencing the event ID - you need the latter in order to do the former. If anything, it's more steps.

I maintain the simplest solution is to store the coordinates in a pair of variables upon targeting. Is the author of the plugin active on these forums or elsewhere? It should be a pretty trivial request to add. If the author isn't available, one of us here could probably do it (if it's a free plugin for us to grab).
Do you have a Link to the Plugin you are using?
Yeah as you guys said it's the simplest thing to do!

Yes here is the link!:

You need to find the distance between the player and the event, using the event ID. I've seen a script call for that in the past, but I don't know what it is. I'll do a quick search, if I find it, I'll let you know.


Edit: check this topic, might do the trick: https://forums.rpgmakerweb.com/inde...d-a-distance-between-player-and-event.116023/

Original thread: https://forums.rpgmakerweb.com/threads/get-enemy-location-on-map.151461/