Is there a script call to check an enemies position during battle?

Groundon3

Villager
Member
Joined
Aug 5, 2017
Messages
9
Reaction score
6
First Language
English
Primarily Uses
RMMV
I've been using Yanflys battle sequences and one problem that has appeared for me (and a few other people) is trying to position the user based on the targets position, mainly further away than the standard choices. I've managed to figure out a workaround this problem but I can't execute it without one thing. So the one thing that I need to know is if there are script calls to find the position of a targeted enemies sprite on screen during a battle. If anyone knows what the script calls are that would be fantastic.

Edit:

Okay, I have made some progress on this.
Based on what I have found, I can use $gameTroop.members. But now I am stuck at a brick wall. According to RPG Maker MV help file, one of the properties is the x and y coordinates of enemies, the problem is where do I put x or y in the string of code?

Here's a link to the page: https://rmmv.neocities.org/page/03_58.html
 
Last edited:

KingKraken

Veteran
Veteran
Joined
Apr 2, 2015
Messages
155
Reaction score
60
First Language
English
Primarily Uses
RMMV
Sorry for the late reply, but I'm trying to get a full understanding of your question. Are you trying to find the coordinates so you can place your characters standard starting positions in different areas depending on the enemies OR are you trying to change where characters end up during animation sequences compared to the enemies?
 

Groundon3

Villager
Member
Joined
Aug 5, 2017
Messages
9
Reaction score
6
First Language
English
Primarily Uses
RMMV
@KingKraken

I'll provide some images to help make this easier to understand.

Key for Images:
Red = Location I want to go to
Blue = Target
Green = User

AAzFuuU.png
What I am trying to do is I need to get the targets screen location. If I can get that, I can use Yanflys battle sequence move point command to place my character relative to my target (indicated by the red dot).

CCpvnjU.png
CCpvnjU.png
But I also want it to work the opposite way to. Instead of just getting the enemies location I can get the actors too. I have managed to slightly figure this out, however...

5LvcBA7.png
5LvcBA7.png
I am getting the targets home location which is [0, 0] causing my battlers to move to [0, 0] (Upper Left) of the screen.
SRDude was able to get the location of the actors and enemies when he was making the zone battle system for his "Lets create (the greatest) game" series.

Here is a link to the video:
I tried to use the code that gets the distance between the battlers but it failed to work.

I hope this makes it clearer.
 

KingKraken

Veteran
Veteran
Joined
Apr 2, 2015
Messages
155
Reaction score
60
First Language
English
Primarily Uses
RMMV
Oh okay! But then that leads me to the next question: Do you want the position to be unique for each battler/enemy? I only ask because you can already make your battlers/enemies move to a specific area/distance of your exact choosing with yanflys action battlers plugin. The only drawback being that the distance is uniform, for each skill.

So if "fires" distance is like 2 spaces in front of an enemy, it will be like that for all enemies. And if "slash" is .5 spaces in front, it will always be .5 The dependent on the sprites actual size as well. So if one sprite has a lot of blank space, "2 spaces" may appear much farther than on sprites with very little blank space.

Assuming you didn't know that of course. There may be a plugin that's overwriting the positioning of your battlers though. If you have any plugins that effect game size or battles, try turning them off and then searching for those coordinates.
 

Groundon3

Villager
Member
Joined
Aug 5, 2017
Messages
9
Reaction score
6
First Language
English
Primarily Uses
RMMV
Oh okay! But then that leads me to the next question: Do you want the position to be unique for each battler/enemy? I only ask because you can already make your battlers/enemies move to a specific area/distance of your exact choosing with yanflys action battlers plugin. The only drawback being that the distance is uniform, for each skill.

So if "fires" distance is like 2 spaces in front of an enemy, it will be like that for all enemies. And if "slash" is .5 spaces in front, it will always be .5 The dependent on the sprites actual size as well. So if one sprite has a lot of blank space, "2 spaces" may appear much farther than on sprites with very little blank space.

Assuming you didn't know that of course. There may be a plugin that's overwriting the positioning of your battlers though. If you have any plugins that effect game size or battles, try turning them off and then searching for those coordinates.

Wait, where is that in the plugin? From what I have seen, you can only go to certain areas of the battler like base, back center, front head, etc. To get the intended effect that I want (from what I understood from the plugin commands) I would have to move my character to the front base of the target then use the backward movement command to get the user to the right spot, then play the animation and effects. If you are a mage, getting close to the enemy then backing off seems like a rather bad idea and makes the start of the attack seem weird.

Anyway, to fully answer the question lets say I have a skill that is a beam, when the skill is used the user moves to the same y level as the target but the user is, lets say, 300 pixels away on the x coordinate (right of target for actors, left of target for enemies). So no matter who uses the skill or who the target is, the user is at the same y level as the target but 300 pixels away on the x level. So yes, uniform location for the skill is fine. Also, I have not implemented any unique sprites yet for my battlers other than yanflys animated battlers and will use the dragonbones plugin once I have the resources made.

Hope that answered your question.
 

KingKraken

Veteran
Veteran
Joined
Apr 2, 2015
Messages
155
Reaction score
60
First Language
English
Primarily Uses
RMMV
After trying a few things with my own project, I see I was mistaken(haven't done an action sequence in awhile). Although it does beg the question why a mage would need to be in a specific area to cast a ranged spell unless that attack had an animation with a straight line motion. Cause that seems perfectly fine for a melee character.

I spent a good 20 mins trying to find a workaround and there doesn't seem to be an exact science with it. I know for sure you can "break" the plugin and make it do all sorts of different things for for you depending on the words and orders of actions that you use.

For instance, one thing I tried was to use the Move user: Front base and set the speed to something like 30(or anything. Followed by a wait command that was half or even less than the 30 frames, in this case I chose 15. This during the movement it action it only as 15 frames to follow through with, which means it can only go half the distance before moving onto the next action. You can definitely play with the frames and waits to find a good spot. Only issue with this method depending on the location of the enemy on the screen, the location can vary in distance. But all of them are still pretty distant.

If you plan on using the classic battle sprites for your actors, you could also just increase the width of their frames in an image editor.

For SRDudes system he made, have you tried getting those coordinates while simultaneous turning plugins on/off to see which is giving you 0,0?
 

Groundon3

Villager
Member
Joined
Aug 5, 2017
Messages
9
Reaction score
6
First Language
English
Primarily Uses
RMMV
I've got it! I have finally got it!
This is the one piece of code that I have needed and all I needed to do was to dig in Yanflys Battle Core code!

target.spritePosX() and target.spritePosY()

I saved these as separate variables during an action sequence and my characters position moved to the exact position of the target when using the Move Point command! All I now have to do is add an amount (or subtract if the user is an enemy) to the X position and the user will move accordingly! I was going to make a plugin using some of SRDudes code (which failed to work for me) but this is perfect!

For SRDudes system he made, have you tried getting those coordinates while simultaneous turning plugins on/off to see which is giving you 0,0?
Thank you for telling me to look into the plugins, I never would have though to do so (granted you said turn them off and on, but still)! You are seriously a life saver!
 

KingKraken

Veteran
Veteran
Joined
Apr 2, 2015
Messages
155
Reaction score
60
First Language
English
Primarily Uses
RMMV
I give 100% credit to you for that one! But glad there was a solution. hopefully this thread will help some other people out looking for the same effect!
 

Latest Threads

Latest Posts

Latest Profile Posts

This is Ralph from VX!
index.php

Always be consistent with your project.
Making backups regularly is good for the soul.
The worst text you can get from a friend "You left your webcam on!!!

Forum statistics

Threads
121,850
Messages
1,144,659
Members
160,102
Latest member
ZeroDie
Top