Throwing together a basic evented ATB... Help?

I'm trying to mess around with making a basic ATB system and I was hoping someone might be able to look at my current event and tell me why it's only occasionally working. It seems to work on stationary enemies but not on moving ones.

Essentially I'm figuring, player presses the OK button to attack. I play an animation and then I grab the player's location, then add to that location to grab the X,Y of the tile in front of the player. I use Get Location Info to put the Event ID of whatever event might be on that location into Variable 5 (HitEnemy), and then if there is one, (HitEnemy =/= 0), I play an animation on that event and then erase it. Then I reset the HitEnemy variable to 0 to start over.

Tell me what it looks like it's missing! Any help is appreciated. Thanks!
atbquestion.png
It seems to work on stationary enemies but not on moving ones.
Is this always the case or does it sometimes also work on moving ones?
Is this always the case or does it sometimes also work on moving ones?
It's not always the case. Every now and then it does work on a moving enemy.
It's not always the case. Every now and then it does work on a moving enemy.
Have you tried to turn the event upside down, i.e. have the target checking come first and the button press later?

Is enemy event in front of player?
If yes is the action button pressed?
If yes delete enemy event.
Have you tried to turn the event upside down, i.e. have the target checking come first and the button press later?

Is enemy event in front of player?
If yes is the action button pressed?
If yes delete enemy event.
would you just do that as a parallel event that's constantly checking?
I believe the core source of this is that when an event starts moving to a new tile, it's not considered to be at the original one any more. So technically even though visually there's an enemy in front of you, it's actually a tile over.
I believe the core source of this is that when an event starts moving to a new tile, it's not considered to be at the original one any more. So technically even though visually there's an enemy in front of you, it's actually a tile over.
I definitely ran into that problem recently with another thing I was trying to do, I'm not sure why I didn't think of it again. But for this, it sounds like rectifying that could get really complicated unless I want to deal with telling the player they just have to be really really precise. 🙁
Probably the approach I would take would be to check what direction the player is facing, and then check the tiles to the left/right or above/below the target one for an enemy too depending on whether they're facing the horizontal or vertical axis.
And if you check the tiles that are 2 away from the player, I think you could run an .isMoving script check for the event that is 2 tiles away. That way you will not hit a stationary event that is 2 tiles away, only an event that seems 1 tile away from you, but already moving to the new tile (so registered 2 tiles away)...I think LOL.

Original thread: https://forums.rpgmakerweb.com/threads/throwing-together-a-basic-evented-atb-help.160074/