Escape event when using random encounters

I can't seem to figure this out, how can I tell when the player has escaped from a random encounter? Without a plugin if possible.

It's really easy when you force the encounter with battle event but lost when it comes to the random step encounter.

Thanks!
I can't seem to figure this out, how can I tell when the player has escaped from a random encounter? Without a plugin if possible.

It's really easy when you force the encounter with battle event but lost when it comes to the random step encounter.

Thanks!
maybe combination of switches...
ex:
1. at the map... have parallel process event that check a switch ex: RandomBattle...
do your event if come from random battle there and turn the RandomBattle switch OFF after that... (to reset it)

2. if you have evented battle... before that battle turn on a switch ex: EventedBattle

3. at the battle in troop event... at turn 0 do some check to check if the EventedBattle is ON...
if yes turn EventedBattle OFF... (to reset it)
if not turn RandomBattle ON...

maybe like that... hope this help.

edit: wait did not see the ESCAPE part...
i guess it will be hard without plugins...

edit2: wait... maybe you can combine those above with checking
Code:
BattleManager.isEscaped();
the escape can be detected without plugins, but it is a convoluted sequence of troop events that is needed for this.
1) have a troop event on turn zero do the following:
control switch "after battle" ON (that is the switch from above)
control variable "enemy number" to set to the number of enemies (this needs to be manually counted unless you want to add scripts
give all enemies an immortal state
2) have one troop event for each enemy checking for HP=0
if yes, control "enemy number" minus one and remove immortal state
3) have a parallel process common event conditioned by the switch "after battle"
in that common event, do whatever you want to do after battle, plus
check if "enemy number" is greater than zero - if there were enemies left then they escaped, if zero they had won
control switch "after battle" off to prevent the event from running again until the next battle
In Variable Operation you can get the number of Escapes, so you can easily check if this number has been changed in e.g. parallel process.


Code:
Variable Escapes (old) = 0
Variable Escapes (now) = GameData.Escape Count

Condition Escapes (old) != Escapes (new)
    Variable Escapes (old) = Escapes (new)

    // your event here
To condense what's already been said: I'd suggest making a Common Event with either Parallel or Autorun trigger, assigned to a switch. Turn on that switch in a troop event with Condition: Turn 0, Span: Battle. This will cause the event to activate as soon as you return to the map (by default Autorun/Parallel events only run on the map, not in battle).

In that common event you can check whether the number of escapes has increased by comparing it against a running tally: Control Variables > Game Data > Other > Escape Count; if it's changed, do the things! Then turn the switch off at the end of the common event so that it only runs once. 😮‍💨

Common event example:
Code:
◆Comment:Check difference in escape count
◆Control Variables:#0008 escapes -= Escape Count
◆If:escapes ≠ 0
  ◆Comment:Escape count has changed!
  ◆Text:None, None, Window, Bottom
  :    :You got away!
  ◆
:End
◆Comment:Update escape count variable for next time
◆Control Variables:#0008 escapes = Escape Count
◆Comment:Turn off switch so event only runs once per battle
◆Control Switches:#0011 battle end = OFF
@Andar, @caethyril, @Aerosys: that also count for escaping evented battle though... of course we can always set to "not allowing escape" on evented battle... 😀.
@Andar, @caethyril, @Aerosys: that also count for escaping evented battle though... of course we can always set to "not allowing escape" on evented battle... 😀.
With some adjustments my solution will still work, as you always check the GameData.Escapes with a Variable that you can manually adjust if escaping from a scripted battle.
Or, if scripted and random battles use separate troops, just don't turn on the switch in scripted battles~
Thanks for all the help and quick response.
This is what I came up with, I'm sure its not the best but I can't seem to find a direct compare to the gamedata - escape count under conditional branch. So used a temp variable.

I probably could have done it in script but then I would still need to pass back a variable to the event for a compare.

Code:
Battle Event
◆Comment:Battle started
:       :Set switch Battled to on and save current escape count
◆Control Switches:#0014 Battled = ON
◆Control Variables:#0014 EscapeCount = Escape Count

Code:
Common Event with switch of Battled
◆Comment:Turn Battled off
◆Control Switches:#0014 Battled = OFF
◆Comment:Save Game variable to temp for compare
◆Control Variables:#0015 TEMP = Escape Count
◆If:EscapeCount < TEMP
  ◆Text:None, None, Window, Bottom
  :    :Player ran away!
  ◆
:End
◆Comment:Reset Temp
◆Control Variables:#0015 TEMP = 0


Thanks again!

Original thread: https://forums.rpgmakerweb.com/threads/escape-event-when-using-random-encounters.130885/