RPG Maker MV

RPG Maker MV

MAKAIROSI Aug 23, 2018 @ 6:10am
Conditional event if battle ended
So i'm trying to get down the mechanics of the game i want to make. And i'm trying to make an event that happens each time a battle ends (any encounter at all).

At first i tried doing conditiotional events of enemy knockout states in the troops section. So basically i did "if 1 is dead (if 2 is dead (if 3 is dead)) etc, then event happens. However it doesn't.

Then i thought that maybe i should put a switch instead of the event, and then add the event at the common events so that the event happens as long as the switch is on. So then, after the event does what i want it to do, it turns the switch off. Still, it doesn't happen.

Then i thought that maybe it's because it only checks once if all the enemies are dead, so i should loop the checks of the conditions (of the enemy knockout states) so if all them occur at the same time then it would break the loop and do the event. The game freezes at that point.

Now i managed to do it with a fixed battle event, if i put the wanted event after "battle processing" (so then it happens right after the battle) however i've no idea if this will happen with random encounters (i haven't got around to that yet)

What i'm trying to achieve is an "if victorious" condition. Or "if battle has ended" or something like that. Any battle.
< >
Showing 1-15 of 18 comments
JohnDoeNews Aug 23, 2018 @ 6:28am 
I think I know what goes wrong...

When you habe the condition where ane nemy is dead, you have it run at "end of turn"? (In troop page)

If so, it will not run at the very last enemy kill per battle, cause the battle will be over before the condition is met. Uncheck "end turn" in the condition, to turn on the switch.
Caethyril Aug 23, 2018 @ 6:39am 
For the "if victorious" condition, try Conditional Branch > Script:
$gameTroop.isAllDead()
Be sure to use Scope: Battle or Scope: Turn so it doesn't repeat endlessly. I think you'll also need to be using a plugin that permits troop events to run after all enemies are defeated, e.g. Battle Engine Core by Yanfly or End Phase Triggers by Himeworks.
[Edit: actually this is nonsense, no wonder the OP couldn't get it to work...see next paragraph. >_>]

If you'd prefer it to happen when you're back on the map, you can instead make a troop event with Trigger: Turn 0 and Scope: Battle. In this troop event, simply turn on a switch. Then make a common event with Trigger: Autorun and Switch set to the switch you chose in your troop event. Lastly, turn the switch off again at the end of the common event. If done correctly, this will make the common event run once after returning to the map from battle.

In either case, you'll need to copy the troop event to every troop manually, or use a utility plugin like this one by Yanfly: http://yanfly.moe/2015/10/18/yep-15-base-troop-events/
Last edited by Caethyril; Aug 24, 2018 @ 12:16am
MAKAIROSI Aug 23, 2018 @ 6:54am 
Ok, so with Base Troop Events, can i still edit specific events for specific battles? Like say, this will always happen, but on battle #4316 i also want another thing to happen.
Caethyril Aug 23, 2018 @ 7:02am 
Originally posted by MAKAIROSI:
Ok, so with Base Troop Events, can i still edit specific events for specific battles? Like say, this will always happen, but on battle #4316 i also want another thing to happen.
I think in that case I'd recommend just adding a branch (one per "special" troop) to your troop event that checks the troop ID. I think this'd work with Conditional Branch > Script:
$gameTroop._troopId === 4316
MAKAIROSI Aug 23, 2018 @ 7:36am 
I think i'm going to use what you said in your previous post. Turn 0 scope battle means the event will happen when we return to the map? So "show text" will show a text similarly to how it would if it was a map event?
Caethyril Aug 23, 2018 @ 7:39am 
Originally posted by MAKAIROSI:
I think i'm going to use what you said in your previous post. Turn 0 scope battle means the event will happen when we return to the map? So "show text" will show a text similarly to how it would if it was a map event?
The Turn 0 troop event is just to turn on a switch so the actual event, the common event, runs when you get back to the map. =)

To put it another way: Autorun & Parallel events only run on the map, the troop event is just to say "the party has entered battle, run the event when they return to the map".
Last edited by Caethyril; Aug 23, 2018 @ 7:40am
JohnDoeNews Aug 23, 2018 @ 7:40am 
Originally posted by Caethyril:
$gameTroop.isAllDead()

Stuff like this, is soooooooooooooo freaking handy to know.
There should be a clear guide with all the script calls like this.

I know about the google docs sheet. That can be handy, but it only shows the easy stuff, the stuff you can do without scripts in the editor too. (So, to me only handy for making plugins)
Last edited by JohnDoeNews; Aug 23, 2018 @ 8:13am
MAKAIROSI Aug 23, 2018 @ 7:48am 
Ok, just tested it and the turn 0 thingie works as i wanted it to. Thanks a TON you just saved a mechanic from being changed to something other than what i intended - and messing the balance in the process. Thanks a ton
Caethyril Aug 23, 2018 @ 8:04am 
You're welcome, happy RPG Making! ^_^

Originally posted by BigFatX:
Stuff like this, is soooooooooooooo freaking handy to know.
For reference, I just searched the base code files for "victory" and found a processVictory call under checkBattleEnd in rpg_managers.js:
... if ($gameTroop.isAllDead()) { this.processVictory(); ...
Last edited by Caethyril; Aug 23, 2018 @ 8:05am
JohnDoeNews Aug 23, 2018 @ 8:15am 
Okay, cool. But all I know about javascript is what I learned from plugin tutorials.
So I only understand half (or less) of what I see. :p Till something gets pointed out like now.

I will look into the .js files more often when looking for a certain answer. Maybe one day, I'll figure it all out.
Caethyril Aug 23, 2018 @ 8:41am 
Originally posted by BigFatX:
I will look into the .js files more often when looking for a certain answer. Maybe one day, I'll figure it all out.
I just remembered seeing API-like documentation for RMMV, luckily the link was still in my browser history. Don't know whether you'll find it helpful and I'm unsure how complete it is, but I may as well leave the link here: https://kinoar.github.io/rmmv-doc-web/globals.html =)
JohnDoeNews Aug 23, 2018 @ 9:24am 
At first glance, I don't understand any of it. :p Whaha. I am not sure what I am looking at.
Winter's Embers Aug 23, 2018 @ 10:05am 
It's like reading Greek, or Roman, or Cyrillic, or some other foreign language... oh, wait... it IS a foreign language... so that's why I suck at javascript so much, huh?
Iguana Guy Aug 23, 2018 @ 4:56pm 
When all enemies are dead (knockout status) the battle ends. Anything you have set up to trigger after they all knockout status is basically ignored as the battle scene ends and transports you back to map screen. I got around this by making conditions that make the enemy immortal status when battle starts. This still allows you to dimish its HP but it wont be affected by knockout. Now on the page you want the event things to happen after they enemies all "die" you make the condition that enemy's hp less than or equal to 0. After all the other event items are done on this page then remove use a command to remove enemies immortal status and it will die and end the battle. Caethyrils idea works too, but this can be done without using script calls. Just another alternative.
Caethyril Aug 24, 2018 @ 12:19am 
Originally posted by IguanaGuy:
Caethyrils idea works too, but this can be done without using script calls.
My script call idea works? I just had another look and frankly, I'm not sure what I was thinking. The calls themselves return the appropriate values, but I don't think they're applicable in the right ways in the editor. o_o
< >
Showing 1-15 of 18 comments
Per page: 1530 50

Date Posted: Aug 23, 2018 @ 6:10am
Posts: 18