Pokemon Mystery Dungeon-Esque Battle System

I'm currently trying to replicate a system of battle alike to Pokemon Mystery Dungeon.

The player is in a dungeon with multiple enemies which when close enough, starts to follow the main character.
However I have came across an issue that I can't seem to solve.

Whilst I have created the system in which the enemy follows the main character and waits for your input before they move I can't initiate another trigger loop which activates as soon as the enemy touches you.

As soon as the enemy touches me it needs to trigger a new event.

Is there any way to have another conditional if, inside my loop which escapes when that current event touches the player?

[IMG]http://i.imgur.com/hZdxicC.png[/IMG]

P.S
I have tried tracking the X, Y co-ordinates of both the enemy and the player however I'm unsure of a way to use that as a means of escape for my loop.
I've moved this thread to MV Support (this is an event, not a script, and you posted in the XP/VX/Ace script forum). Please be sure to post your threads in the correct forum next time. Thank you.

So you want, as soon as your event touches the player, for the loop to break and to be able to do something else?

I would do this:

Conditional Branch: Script: p = $gamePlayer; e = $gameMap.event(this._eventId); (Math.abs(p.x - e.x) + Math.abs(p.y - e.y)) === 1  # enemy is on a tile next to the player, and is facing the player - this can be considered 'touching' the playerBranch End

That's getting the distance between the event and the player horizontally and vertically and adding them together.  If the result is 1, that means the event is on a tile next to the player.  And because they've just done a Move Toward Player, you know they're facing the player.
Thanks for the quick reply!

Sorry about the misplacement of the thread. I wasn't sure of where it would be placed because I wasn't sure if it was script/version specific.

Where/How would I apply this custom script?

I can't seem to create an open-ended conditional branch.

Also regarding the API of the scripting, is there a list of all RPGMaker Specific objects and instances?

Thanks
 

Original thread: https://forums.rpgmakerweb.com/threads/pokemon-mystery-dungeon-esque-battle-system.52552/