Erasing event after on-map encounter.

I'm trying to set on-map encounters and can't make the event erases itself properly with common events.

If the player wins, I want to have a common event that plays an animation on the event, then have it erases itself.
If the player chooses to escape, I want to have a different common event run instead.

Spoiler: Screenshot
1a.png

The comment event for Battle End is like this (with none trigger):
- Play Animation: This Event
- Wait: 30 Frames
- Erase Event
Battle Escape is just Erase Event.

If I put either comment even underneath the first End, then it works, but that common event plays regardless of whether the player wins or escapes the battle. I also tried using VS's (MZ BattleCore) comment events on map (post-battle/victory/successful escape) but it didn't work, either. However, VS's plugin works if I use a different comment event. So, what am I missing here?

Thanks in advance for any help!
51.gif
It should work the way you have it set up. Try it in a new project without any plugins and see if it works. If it does, then it means one of your plugins is interfering.
If I put either comment even underneath the first End, then it works, but that common event plays regardless of whether the player wins or escapes the battle.
That's the wrong place to put it. The first End is for "If win/if Escape", so going after it will trigger after those checks, regardless of what happens.

The place you have in your screenshot is the correct place for the commands.

I think the problem is with what you are doing, versus what you think you're doing.

What do you mean by:
I'm trying to set on-map encounters and can't make the event erases itself properly with common events.
The Erase Event event command removes an event for the rest of the time you're on the map. It won't do anything in a common event that you call from another event, because that common event can't be erased.

If you want this event to disappear from the map, you need to make a second page that is blank except for the condition of Self Switch A being ON. Then, on the line after you call your common events, use the event command Self Switch A ON.
@ATT_Turan @Shaz
If you want this event to disappear from the map, you need to make a second page that is blank except for the condition of Self Switch A being ON. Then, on the line after you call your common events, use the event command Self Switch A ON.

No. Doing that will make the event disappear completely and that's not what I want. I use Erase Event because I want the enemy to respawn when the player leaves and comes back to the map.

Apparently, the problem lies in the variable line at the beginning.

Spoiler: Screenshot
1a.png

I want the battle to be randomly chosen from the list of troops, so I used variable. I was only testing so I put 1 as the value. I created another event with the same contents, but without the control variable and used a specific battle. That one works the way I want, using common event or not.

So, what's wrong with my control variable setting? Is this how people set random battle for on-map encounter?
Upanhso.tk-30.gif
No. Doing that will make the event disappear completely and that's not what I want. I use Erase Event because I want the enemy to respawn when the player leaves and comes back to the map.
In your new screenshot, where you added erase event into this event, that will work.
Apparently, the problem lies in the variable line at the beginning.
It can't, setting a variable doesn't affect anything lower down. Since you have made changes to the event, please explain what is actually happening now, because we no longer know what the problem is.

You get into battle, and then...it doesn't show the animation and go away? Just one of those? What?
im questioning the purpose of the variable to begin with.

in battle process theres "same as random encounter" which just uses the troops you set for that map.
does this game have both random encounters and visual encounters?
does different visual encounters on the same map have different possible troops lineup?

if both those answers are "no" then theres no need for the variable
In your new screenshot, where you added erase event into this event, that will work.

Tested that. The event didn't respawn after I leave the map.

It can't, setting a variable doesn't affect anything lower down. Since you have made changes to the event, please explain what is actually happening now, because we no longer know what the problem is.

You get into battle, and then...it doesn't show the animation and go away? Just one of those? What?

I don't get it, either. But let me explain again. This is the common event I have that's supposed to play after a battle ends:

1a.png


This is event 1, with variable that randomizes battle.

1a.png


For unknown reason, this event does not disappear, regardless of whether I choose to fight or escape. It'll just stay there. This is a duplicated event with no variable setting.

1a.png


This one works the way I want. If I fight and win the battle, the common event activates (animation plays on this event), and it disappears. If I escape, it plays no animation, and simply disappears. If I leave the map and come back, it respawns.

Now, the question is: how do I make the first event to work like this one? Obviously that variable is the root of the problem because everything works fine when I remove it.

in battle process theres "same as random encounter" which just uses the troops you set for that map.
does this game have both random encounters and visual encounters?
does different visual encounters on the same map have different possible troops lineup?

It only has visual encounters. I want the encounters to be randomly chosen from the troops lineup, which is why I used variable.
you can turn off encounters and still have visual encounters.
this lets you set troops for that map which battle process "same as random encounter" event can use to have random troop selection.
the only time you'd need the variable is if event 1-7 use map troop list but event 8 on the same map has a different random troop lineup (more likely it would only be a set troop though)
Did you try it in a brand new project with no plugins?
@Shaz I should have done this earlier.
88.gif
Sorry.

So I just tested this in a blank project, and it worked, with variable. I also pinned down the culprit: Visustella's Battlecore plugin. After I disabled it, the event worked just like I wanted. In the Mechanics Settings, I have all on-map common events set to 0. Except for pre-battle event, which triggers a common event, but that's before battle...

But then, now what...? Guess I should just not use variable at all?

you can turn off encounters and still have visual encounters.

I set the weight of the encounters to 0. Does that disable random encounter completely?
No, you need to troubleshoot more than that.

What variable are you using? Is it one that's also being used as a default variable by that plugin? If you use a different variable, does it work?
@Shaz I have a variable named "Battle", number 10. You can see it in the screenshot in my second post. The plugin doesn't use variable at all. If I use a different variable, like 13, it still doesn't work.
event > page 3 'system settings > change encounter > disable.

the weight for troop events is for making some encounters more common then others.
(6 troops, weights of 5,5,4,3,2,1. add those all together (20) a 5 weight troop has a 5/20 or (25%) encounter rate while 2/20 troop is only a 10% encounter rate)
Thanks. That seems to be the best approach at the moment, so I'll go with that. I also tried to have different animations play after battle, chosen randomly by variable. But I couldn't get that to work, either. So I can only play one specific animation at the moment. No idea what the hell could have caused this, but it's not a major issue. I don't want to spend too much time and effort over what is a trivial cosmetic effect.
81.gif


Thanks everyone for responding.

Original thread: https://forums.rpgmakerweb.com/threads/erasing-event-after-on-map-encounter.142145/