How to run an event after battle completion?

I want to run an event at the end of a random battle but it doesn't seem to be possible. All I want to do is increment a variable for every type of enemy killed. For example, if I won a battle against two slimes, the variable SlimeKills would increase by two.

The end of a battle doesn't seem to count as the end of a turn so checking if they are both knocked out at the end of each turn does not work. Any ideas would be appreciated.
I want to run an event at the end of a random battle but it doesn't seem to be possible. All I want to do is increment a variable for every type of enemy killed. For example, if I won a battle against two slimes, the variable SlimeKills would increase by two.

The end of a battle doesn't seem to count as the end of a turn so checking if they are both knocked out at the end of each turn does not work. Any ideas would be appreciated.
What i do is set the troop to an immortal state then abort the battle manually using event commands in the battle event.

As an example you can set up a page condition like this:

Condition: Enemy HP (Slime) <= 0% - Span: Moment

Control Variable: SlimeKills += 1

Abort Battle

That should activate the page when the enemy loses all its HP, add +1 to your variable and then end the battle.   
What i do is set the troop to an immortal state then abort the battle manually using event commands in the battle event.

As an example you can set up a page condition like this:

Condition: Enemy HP (Slime) <= 0% - Span: Moment

Control Variable: SlimeKills += 1

Abort Battle

That should activate the page when the enemy loses all its HP, add +1 to your variable and then end the battle.   
That does not account for multiple enemies though. In this case the second the first slime dies the battle ends even though the second enemy has not been killed. Even if I added another event page it would only trigger one of them. I also don't beleive the characters would be awarded any gold or EXP if the battle ends with the Abort Battle command.
I'm interested in this too. I have a system where your equipment can produce items by chance, so a common event that played after every battle would be nice. Seems like it'd take a plugin.
no need to be immortal...

http://himeworks.com/2015/10/end-phase-triggers-mv/

just use that plug in and your end of turn event can work at battle end.
Oh, well that's pretty helpful.

Is there an easy way to have the battle check for no more enemies? The only way I can think is having it so at the beginning of the battle, it tallies up all the enemies, then you have a battle event run each turn (1+1*X) to check if the number of dead enemies = total enemies.
Thanks, this solved my problem perfectly.
Oh, well that's pretty helpful.

Is there an easy way to have the battle check for no more enemies? The only way I can think is having it so at the beginning of the battle, it tallies up all the enemies, then you have a battle event run each turn (1+1*X) to check if the number of dead enemies = total enemies.
for check no more enemy...

conditional branch. > script:

$gameTroop.aliveMembers().length == 0;
if true

do something you want there...
Er, what would be the Battle Event page's Conditions?
That does not account for multiple enemies though. In this case the second the first slime dies the battle ends even though the second enemy has not been killed. Even if I added another event page it would only trigger one of them. I also don't beleive the characters would be awarded any gold or EXP if the battle ends with the Abort Battle command.
Sorry my game hasn't progressed past the point of single enemies yet so that's why I gave you a single enemy example.  I was being lazy and was hoping my example would give you enough to work on.

There are easier ways to do this with plugins as subsequent posters have pointed out.  But if you ever wish to do this with just event commands alone here are some additional steps you could take for a troop with two enemies. 

Conditions: Enemy HP (1)  <=  0% - Span:Battle

Control Variable: #0001 += 1

Control Switches #0001 = ON

If Switch #0001 is ON

If Switch #0002 is ON

Control Switches #0003 = ON

End

End

Conditions: Enemy HP (2)  <=  0% - Span:Battle

Control Variable: #0001 += 1

Control Switches #0002 = ON

If Switch #0001 is ON

If Switch #0002 is ON

Control Switches #0003 = ON

End

End

Conditions: Switch#0003 = ON - Span:Moment

Abort Battle

I just tested this and it seems to work.  You will  have to design your own death state though and apply it during the battle.   You will also have to adjust what skills the enemies use after they die so they don't continue to attack the player when they are dead.  And yes: you will also have to create your own battle victory event and apply experience and gold manually as you pointed out.  So I am guessing you will just be using the plugin. 🙂

Original thread: https://forums.rpgmakerweb.com/threads/how-to-run-an-event-after-battle-completion.49340/