Acccidentally Created Area of Effect Attacks, help me fix it

Weird title I know. Thanks for all your help lately folks, it's been great.

Anywho, here's what's happening:

I've got an enemy who is a giant fist, designed to chase the player around the map, and when the enemy event is on the same tile as the player, it flashes for a few frames and then jumps (0,0) to crush the player if they're still on that tile when the jump completes.

The event, however, as it currently is, seems to also kill the player if they are within 1 tile in any of the 4 directions. I was hoping to only make it kill them if they're in the exact same spot where the jump originated.

First off, here's the event page for the Fist enemy, as well as his custom move route. I prefer repeated "Move Toward Player" over the "Approach" type because it behaves better... for some reason when I previously had it set to "Approach", it would ONLY kill the player when they were a tile away, but not when they were in the correct space. Since I changed it to "Move Toward," it now includes the correct space.

fistquestion1.png


The rest of this enemy's programming is in a common event, so that I can have more than one of them operating at a time and easily modify all of their behavior at once.

So here's the common event. The Script in the conditional branch at the top there checks whether the enemy is on the same tile as the player. (Variables 5 and 6 are constantly refreshed with the Player's X and Y location, respectively).

Here it is in full:

Spoiler: Location Comparison Script
($gameMap.event(this._eventId).x == $gameVariables.value(5)) && ($gameMap.event(this._eventId).y == $gameVariables.value(6));

I'm also choosing not to load the enemy's X,Y into variables because again, I want to have more than one operating on a single map and that would lead to either a lot of crossover or a ton of reserved variables that would have to be specified per enemy and that's just way too potentially messy.

Anywho, once the location check is confirmed, the Move Route that you see first causes the Fist enemy to flash for a moment...

fistquestion2.png



fistquestion3.png


...then after the flashing animation, the Fist jumps in place.

It plays a sound effect on landing, and then I run my tracker event again just to make sure the player's location is as accurate as possible. (The Clinky Tracker common event just loads the player's X and Y into variables 5 and 6 as mentioned before. Normally it's refreshing all the time, but I figured a double check within this event couldn't hurt.)

After that, I run the exact same Conditional Branch script line again to check for whether the player is still on the tile that should kill them, since I want them to have the opportunity to run away once the flashing animation begins.

This time, if they ARE on the tile, I run a common event that kills the player by squashing.

(The Else field pictured will enact another common event for other purposes, such as crushing other events. I have not implemented this yet because I'm just trying to make it work as a hazard first.)


Anyway, that is what's SUPPOSED to happen. Instead, as I said before, it's killing the player not only on the RIGHT spot, but also one tile away in any direction.

Thanks for reading. Any thoughts?
ALWAYS update variables in the event where you need them, no matter what.

so the control variable commands for variable 5 and 6 should be directly above the conditional branch, below the wait(1).

it's most likely a timing problem that the check comes before the variables are updated.
If you want more on the why, I suggest you follow the "bughunting" link in my signature.
Like Andar said, you're using a script call to reference the event's X/Y coordinates but you're using variables to reference the player's coordinates.

And those variables aren't being set in the common event you posted.

So, logically, those variables are being set someplace else before this event is triggered, and don't reflect the player's current location.
ALWAYS update variables in the event where you need them, no matter what.

so the control variable commands for variable 5 and 6 should be directly above the conditional branch, below the wait(1).

it's most likely a timing problem that the check comes before the variables are updated.
If you want more on the why, I suggest you follow the "bughunting" link in my signature.

I added in another check and it didn't fix the issue.

The reason I don't think that was likely the problem is because the first check works exactly correctly: the flashing/smashing animation doesn't happen unless the enemy and the player are on the exact same tile, and that was already fine. Those variables are being set in an Always On/Parallel Common Event that checks the player's location every frame, which SHOULD be enough, but I had the same doubts as you which is why I added another check in the middle of the event.

The problem comes from that second check, which seems to accept too many potential player locations.


The good news is, I think I fixed it, and it has something to do with when the enemy's Movement is resumed.

I would appreciate any help with understanding WHY, after I tell you what I did, in case my understanding of it doesn't sound correct.


So as I show it above, the entire event ends with a Wait 120. I expected that to halt the Move Route of the enemy for 120 frames so that it would sit there for a moment, then give chase again if it didn't successfully kill the player.

But I noticed that the wait was ineffectual and the Move Route was resuming immediately after the smash. Which means that, more than likely, as soon as the smashing animation was done, the enemy was already planning to give chase again, and since its speed is set to Slowest, its location was updating even if we couldn't see the sprite already on the tile the player had moved to.

So I broke things up into a second event page and now I'm running a Parallel Page 1 (which has the "Move Toward Player" Custom move route) and using that same location checking Conditional Branch script to turn on a Self Switch to go to Page 2, which has NO move route set, where I'm having all the aforementioned action take place. Then, I've put the 120 frame Wait on THAT page, after which the Self Switch is turned off and the behavioral loop begins again.

That's what I did to fix it, and hopefully I'm actually right about why it happened.
yes, you completely misinterpreted what the wait command does.

It basically says "skip processing the process I'm in for x frames of the main game loop".

And now please look more carefully at the naming of some commands, likie "set movement route".
It does not say "move event" because that is not what it does - it creates a new process to handle the moveroute for the targeted event (which does not automatically mean the same, you can remote control other events). And that other process of course has nothing to do with the waits in the current process, not unless you set that moveroute to wait for completion (which means the event with the set command waits until the move process is complete) - which has other effects and disadvantages.

you really should take the time to read or play some of the tutorials on eventing, and especially read about parallel processes and their problems in the bughunting tutorial in my signature.
This thread is being closed due to being solved. If you need it reopened, report it to let us know why. Thank you!

Original thread: https://forums.rpgmakerweb.com/threads/acccidentally-created-area-of-effect-attacks-help-me-fix-it.159719/