Post-battle Events


This script allows you to set up troop event pages as “post battle” events. These events will run after the battle is over, but before the game leaves the battle scene. It allows you to run extra events that should occur after the victory/defeat messages.


Script: download here


Place this script below Materials and above Main


To set a post-battle event page, add one of the following comments

<post battle victory>  - runs after victory
<post battle defeat>   - runs after defeat

The page will automatically be run when the condition is met.


This script is very easy to customize. If you want the post-battle events to occur at a different place, simply move the two lines somewhere else:


Because this script overwrites the victory and defeat processing, it will be incompatible with any scripts that also overwrite them. The easiest way to make them compatible is to place this script above the other script and then copy the two lines into the appropriate places.


You may also like...

25 Responses

  1. Perry says:

    Hi, I’m new to RPG maker. Could you give an example implementation of this script somewhere? Thanks so much.

    • Hime says:

      In the screenshot there is an example of how you would set up the troop battle event.
      When you win the battle, you should see the event run.

  2. SjMorgan says:

    I’ve noticed a flaw with this script. It only allows a Post-Battle event to run once ever, and no times ever if you either escape a battle or are defeated in a battle that needed a victory. (Boss fight.) Just being in a battle in a clean project guarantees the post-battle event will never run in the same troop combat again.

    I get that deleting the battle may have been to avoid infinity loops in processing, but; is it possible to have an event run max 1 per battle, then set the ran count back to 0 after the battle processing finishes? If the game dev doesn’t want it to run again, they can easily conditional branch said event with an else, and have the else be nothing, or the event be nothing and the else something to negate it themselves.

    • Hime says:

      The pages aren't deleted, but rather stored in a separate set of variables. This way, those pages won't be checked by the engine every frame for activation conditions since they'll never run anyways. Granted, this may be premature optimization, but since the intention is to not have these events run until after battle, it didn’t really make sense to keep them around.

      The appropriate pages are then set up to run after the battle has finished, though if the defeat processing events aren't even running then there's a bug in the code.

      I have tried it in a new project and am able to run the post-battle victory and defeat events over and over again, so it doesn't seem to be an issue on my end.

      • Sjmorgan says:

        I also used a clean project. Let me step by step what I did and did not do.

        A post victory event but I did not need a post defeat one.
        Fought battle, worked perfect.
        Triggered battle and ran. Thrn fought battle, no event. Redid several times resetting, no.event for victory played.

        Once I get home I’ll retest adding a post battle defeat tag. I just didn’t need that function. I assumed defeat would yield the escape result but shouldn’t have assumed.

        Perhaps it’s not replaying the event because of not having a defeat tag, or perhaps because of being the same encounter twice without breaking up the repeating with a different battle. I’ll check it and post the results.

        • Hime says:

          No wait, I see the problem. When you said delete I thought you meant they were being deleted from the troop pages, but now I see that they were being deleted everytime the battle begins.

          For some reason the post battle defeat events remained intact, but the post battle victory event was lost.

        • Sjmorgan says:

          Apologies for double post, but I cannot edit.

          So, I cannot get the script to work as you describe in your reply. In a completely clean project, it will only display the once total, and not at all if Victory wasn’t achieved the first time.

          I added , but; it changed nothing. Usually these things are user error, so here’s an upload of my clean project not working as intended. I know it’s not your job to trouble shoot my crap, but; I’d sure like to be able to use this and I’d even prefer to hear I’m definitely wrong on the issue.

          I tried fighting a different battle between battles, and every combination of victory, defeat, escape I could. I just cannot get the event to repeat more than once ever per save file.

          • Hime says:

            I’ve updated the script. See if the problem has been resolved.

          • SJmorgan says:

            Success. Thank you very much. I’m using the script in my side project which will be done in roughly 2 weeks. 🙂

          • SJmorgan says:

            I came across a most unusual other bug Hime. Everything works now except for if I use a conditional branch requiring an item. Whether you have the item or not in the Post Battle Victory, it plays through that type of condition as if you have said item. It’s strange, as it respects other conditions normally.

            In my example, I’m requiring having item Beef Jerky. The defeated Red Baron is demanding Beef Jerky or he won’t join.
            Options are give him beef jerky or refuse.
            It should go if you have beef jerky after saying you’ll give it to him, then he says “Yum. I will serve your faithfully” -1 Beef Jerky, and joins. ELSE he says “Liar. You don’t have any Beef Jerky.” Instead, he joins either way ignoring the condition of having the item.

        • SJmorgan says:

          Nevermind Hime. It is an symptom being caused by another script, manifesting in this process. I checked an identical situation in a clean project with just your script and it didn’t happen.

  3. Fatalys93 says:

    Hi Hime, great script!
    I’ve a problem because i’m using Battle Result Script by Moghunter.
    I’ve tried to copy line 129: process_post_victory_event in Moghunter’s script ma it doesn’t work in the right module.
    I’ve also tried to customize your script by deleting some lines and let only the line process_post_victory_event but nothing.

    There is a way to integrate your script with Battle Result Script by Moghunter?
    Thanks, your scripts are awesome!

    • Hime says:

      process_post_victory_event only works for the default BattleManager. MogHunter has his own thing going on. Set up a demo and then create an issue on my issue tracker (hover over “Contact me”, it is in that menu)

  4. TiagoMS says:

    Hello hime! all good?
    So .. I have a problem because if during the "post-battle-events" is used a 'Battle Action Force ", an error occurs and the game closes.

    Error: Repeat 2 times the "gains" and closes.
    With the script yanfly it the error after submitting everything and closes.

    Is there any solution?

    Erro only use "Battle Action Force".

    • Hime says:

      Ya, you can't use force action during post-battle events, because the force action will try to run the end sequence, but then it will exit the game.

  5. TiagoMS says:

    Perfect. But a bug if I force an action bypasses during the period the event occurs and the game closes.

  6. rubydragon44 says:

    Didn't you make a pre-battle event script?

  7. RogueDeus says:

    Great script!

    I had to settle for regular event ‘Battle Processing…’ (if win) conditioning to trigger ‘after battle actions’ before your handy work. This has much more polished and professional appearance.

  8. Beniwa says:

    Awesome! It works now, thank you very much Tsukihime!

  9. Beniwa says:

    This is awesome! This allows me to remove the Main character from party at the beginning of the party and add him/her back in after the fight is over, but it’s a shame I can’t get this to work with Yanfly’s Aftermath.
    Also, is it possible for this script to run before it says “*insert name here*’s part is victorious” ?

    • Beniwa says:

      Actually to provide more accurate feedback, it doesn’t seem compatible with any other script which alter the victory screen (such as Yanfly’s Aftermath or Grade Victory Screen Script)

      • Tsukihime says:

        I have updated the script and the blog post. Look at the instructions under “customization”: you will need to place this script above yanfly’s victory screen, and then insert the following line somewhere into yanfly’s victory processing method


        If you don’t know where you can make a post on one of the forums asking where to put it.

Leave a Reply

Your email address will not be published. Required fields are marked *