[solved] Enemies attacking on wrong "level"

The screenshot shows an "arena" I created for the last room of my tutorial dungeon. You have to avoid the evil eye, and fight the other enemies first to level up; all of them are moving. Both the player and the enemies can ascend the stairs and walk on top of the walls of the middle structure. Fine so far.

The problem is that the enemies on top of the walls can attack the player when she's at ground level, which doesn't make sense. I can live with it, but I wonder: is there a simple way to prevent this happening?

arena.png
Use a variable or switch to track the player's altitude. When they set foot on the higher sections after ascending the stairs, put an event to set altitude = 1 / ON / whatever, put events that set it to 0 / OFF / whatever after they step off the stairs.

Then, inside the enemy events, you can either use a second event page or just an if statement around their "attack" code to disable them if the altitude is wrong.

This is the same basic structure you can use do make overpass / underpass structures and bridges, and could potentially make interesting flying enemies- one page set to "above player" normally, with a "same as player" page if altitude is 1, for example.

EDIT:
Just noticed you mentioned the enemies can climb the stairs, woops. Tracking altitude that way doesn't play very nicely with enemies who can change altitude like that, so you might need to improvise something using Region IDs, and a bunch of loose variables to store data. Sample event I wrote up quickly:
WKZDthb.png

On your map, you'd paint the raised sections with region 1, and leave the lower sections blank.
Then, in your event, any time you want to know if the player and an event are on the same level of the area, just call that common event and check "Same Altitude" before doing whatever the thing is. You could also compare Enemy altitude and Player Altitude directly in your event to make some things easier on yourself.

You can probably improve on the design, but that's just what I could mock up offhand.
Thanks, seems to work perfectly!

Original thread: https://forums.rpgmakerweb.com/threads/solved-enemies-attacking-on-wrong-level.83338/