Return SV Battlers' (Actors and Enemies) X and Y Coordinates?

Apologies for the bombardment of questions today. I've actually held on to  this one for some time and tried to figure it out on my own, with not much success sadly.


I want to be able to store each actor and enemy X and Y coordinates in a battle in variables, to be accessed later by common events. The variables will be updated with every battle.


I have read about the Sprite_Actor.prototype.setActorHome. Is there a function that would have the effect of "getActorHomeX" and "getActorHomeY"?


Thanks,
Hi @Yoraee!


This is one way to get the actor coordinates:


SceneManager._scene._spriteset._actorSprites[index]._homeX
SceneManager._scene._spriteset._actorSprites[index]._homeY


Indexes start at 0 for the first party member.


And you can get enemy coordinates with these:


$gameTroop.members()[enemyIndex]._screenX
$gameTroop.members()[enemyIndex]._screenY




To note: there are likely other ways to get those coordinates. I just shared the one I use.
@Astfgl66 These worked for me! Thank you very much! 😀


I actually tried looking through the console (like you taught me in a previous post), and looked through $gameActor, $gameSystem and Sprite_Actor, but didn't go further. Now I know where to look next time! 

Original thread: https://forums.rpgmakerweb.com/threads/return-sv-battlers-actors-and-enemies-x-and-y-coordinates.69686/