Calling Common Event on Defeat?

So I've noticed that there's an option in the RM2k3 battle settings to run a common event instead of an automatic game over. I'm attempting to use this option to create a sort of slap-on-the-wrist for losing battles: if it's a regular enemy encounter, then the player gets ejected from the area, loses some of their money, and gets healed to try again, but if it's a "dangerous" enemy (read: a boss battle), it's a game over. The common event uses a simple conditional branch: if the boss-battle switch is on, run the game over, otherwise the player just gets yeeted out.

Problem is, every time I try testing this with two test fights (a slime with elevated stats that does not have the boss battle switch, and a dragon that does), it causes a game over. I tried the conditional branch option on the battle processing event window, but it causes a really weird double transition where the game returns to the map, then transitions back, and it looks just really bad.

Am I missing something stupidly obvious, or is it something a little more convoluted than what I thought it is?
Can you show me screenshots of your current setup for this?
Can you show me screenshots of your current setup for this?
Sure thing. Here's the event. (It doesn't have the loss of money yet, I had that idea after I wrote the event.)

1617577941485.png
Okay, and what about the common event call setting and turning the switch on/off?
The "Game Over" of the "Common Event" has a text message that doesn't happen either, right?

This system in the "Battle Screen" menu only works for encounter battles, battles against NPCs have to change the settings of the event that calls the battle.
The "Game Over" of the "Common Event" has a text message that doesn't happen either, right?

This system in the "Battle Screen" menu only works for encounter battles, battles against NPCs have to change the settings of the event that calls the battle.
Okay, and what about the common event call setting and turning the switch on/off?

Unfortunately I'm not at my computer at the moment so I can't get a screenshot of it, but the test battle for the boss enemy sets the switch to ON immediately before processing the battle, and then OFF after processing. Would I have to use the conditional branch option for each battle (since I plan for the encounters to be on the overworld map, not randomized) and then run the event through that?

Also, I noticed the text failing to show as well. I guess the "hide screen" option also hides the text boxes; I'm guessing I'll have to transfer to an empty map, show the screen, then transfer to the intended destination?
Yeah, if your encounters are event-based you'll have to add your stuff to the battle loss branch in the events.
Try pressing the F9 key before the battle to make sure the Switch is off.

The Big Boss does not need a Switch, as he will call the default "Game Over" because it is an event-created battle.

If the enemies are events on the map, you were not clear about it, I asked before to find out exactly the cause of the problem... and you didn’t confirm that.
If so, this system of calling a "Common Event" will not work.

See the image in the attachment, it explains what you need to do to create battles of this type without "Game Over":
Rm2k3-StartBattle.png


Good Luck
I was able to work it out! Thank you very much, everyone!
And what was the problem ??
And what was the problem ??
1) The need to use a common event for each of the encounters means I had to use the conditional branch option for each battle, and just have bosses use the game over handler. The only downside is I won't be able to use fancy encounters, unless I check different stats or something, but that's not a big deal to me.

2) Unfortunately I couldn't quite figure out how to skip the transition back to the map before running the common event, but that's not too big a deal, really; I could probably implement a mini animation of the character collapsing before it fades out. The hidden text was solved by just turning on transparency after the fade-out, transferring to a blank map, fading in, running the text, then fading back out, turning off transparency, and transferring. And I was able to use a pretty simple variable check on the money for the idea of losing it (set the current amount to a variable, divide the variable, then decrease the money by the new variable amount).
1) "Fancy encounters", so the question you didn't answer, whether it was map battles or "Player versus NPC" was finally answered ...
Well, what can I tell you, this is not difficult to do with events using variables, using a step counting system:
Code:
@> Control Variables: [0001:StepX-Last] = Player's X Coordinate
@> Control Variables: [0002:StepY-Last] = Player's Y Coordinate
@> Conditional Branch: Variable [0003:StepX-Now]  != Variable [0001:StepX-Last]
  @> Control Variables: [0005:Step-Counter] += 1
  @>
 : Branch End
@> Conditional Branch: Variable [0002:StepY-Last]  != Variable [0004:StepY-Now]
  @> Control Variables: [0005:Step-Counter] += 1
  @>
 : Branch End
@> Control Variables: [0003:StepX-Now] = Player's X Coordinate
@> Control Variables: [0004:StepY-Now] = Player's Y Coordinate


2) You can continue to use the common event, the problem with transition has nothing to do with the battle, you are probably doing it in a way that the events do not combine.

Good luck
I think there may have been another issue too: If I remember correctly, you'll get a game over if all your characters are dead, and this is checked every frame. So if you heal your party *before* the "hide screen" command so that it happens on the same frame on which the common event got called, it should prevent the game over.
1) "Fancy encounters", so the question you didn't answer, whether it was map battles or "Player versus NPC" was finally answered ...
Well, what can I tell you, this is not difficult to do with events using variables, using a step counting system:
Code:
@> Control Variables: [0001:StepX-Last] = Player's X Coordinate
@> Control Variables: [0002:StepY-Last] = Player's Y Coordinate
@> Conditional Branch: Variable [0003:StepX-Now]  != Variable [0001:StepX-Last]
  @> Control Variables: [0005:Step-Counter] += 1
  @>
: Branch End
@> Conditional Branch: Variable [0002:StepY-Last]  != Variable [0004:StepY-Now]
  @> Control Variables: [0005:Step-Counter] += 1
  @>
: Branch End
@> Control Variables: [0003:StepX-Now] = Player's X Coordinate
@> Control Variables: [0004:StepY-Now] = Player's Y Coordinate


2) You can continue to use the common event, the problem with transition has nothing to do with the battle, you are probably doing it in a way that the events do not combine.

Good luck

I think there may have been another issue too: If I remember correctly, you'll get a game over if all your characters are dead, and this is checked every frame. So if you heal your party *before* the "hide screen" command so that it happens on the same frame on which the common event got called, it should prevent the game over.

Sorry, by "fancy encounters" I meant things like pincer encounters, ambushes, things like that. There's no random encounters in the game, every enemy has a token on the map. That's why I was in need of a solution for the "run this custom death handler" thing.

As for the getting a game over deal, thankfully I checked the event using the slime enemy and there aren't any conflicts; maybe it's the way I timed it or maybe it's just luck, but each time the event runs as intended (screen fades out, plays the text, heals the party, reduces the money, and fades back in at the intended location). But I'll move the recovery to the first line of the event just to be safe.
To make the job easier, you could create a single common event that starts the battle and to define the troop you would use a variable:
Code:
@> Control Variables: [0011:Enemy-Troops ] = 3
@> Call Event: [Start-Battle]
(3 = Troop Grassland 3 on "New Project 2k3")

Common Event: Start-Battle
Code:
@> Battle Processing: Normal, Variable [0011]
: If Won
  @>
: If Defeated
  @>
: Branch End

Within the "Defeat" condition you can create the conditions for each type of troop using the same variable, you would not need to place the type of defeat in each event.
Remember, do not activate the "Option" in these IFs, as there is no need for an exception (! =):
Spoiler: Example Complete
Code:
@> Battle Processing: Normal, Variable [0011]
 : If Won
  @>
 : If Defeated
  @> Recover All: Entire Party
  @> Conditional Branch: Variable [0011:Enemy-Troops ] == 1
    @> Change Gold: - 5
    @>
   : Branch End
  @> Conditional Branch: Variable [0011:Enemy-Troops ] == 2
    @> Change Gold: - 7
    @>
   : Branch End
  @> Conditional Branch: Variable [0011:Enemy-Troops ] == 3
    @> Change Gold: - 12
    @>
   : Branch End
  @> Conditional Branch: Variable [0011:Enemy-Troops ] == 4
    @> Change Gold: - 12
    @>
   : Branch End
  @> Conditional Branch: Variable [0011:Enemy-Troops ] == 5
    @> Change Gold: - 8
    @>
   : Branch End
  @>
 : Branch End

A suggestion:
With this you could take an enemy from the map and make it have 2 or 3 different formation:
  • Troop -> ID 1: 2x Slime
  • Troop -> ID 2: 3x Slime
  • Troop -> ID 3: 1x Slime, 1x Spider
Code:
@> Control Variables: [0011:Enemy-Troops ] = Random No. (1...3)
@> Call Event: [Start-Battle]

This is the basis that I saw in some SuperNES JRPGs.
To make the job easier, you could create a single common event that starts the battle and to define the troop you would use a variable:
Code:
@> Control Variables: [0011:Enemy-Troops ] = 3
@> Call Event: [Start-Battle]
(3 = Troop Grassland 3 on "New Project 2k3")

Common Event: Start-Battle
Code:
@> Battle Processing: Normal, Variable [0011]
: If Won
  @>
: If Defeated
  @>
: Branch End

Within the "Defeat" condition you can create the conditions for each type of troop using the same variable, you would not need to place the type of defeat in each event.
Remember, do not activate the "Option" in these IFs, as there is no need for an exception (! =):
Spoiler: Example Complete
Code:
@> Battle Processing: Normal, Variable [0011]
: If Won
  @>
: If Defeated
  @> Recover All: Entire Party
  @> Conditional Branch: Variable [0011:Enemy-Troops ] == 1
    @> Change Gold: - 5
    @>
   : Branch End
  @> Conditional Branch: Variable [0011:Enemy-Troops ] == 2
    @> Change Gold: - 7
    @>
   : Branch End
  @> Conditional Branch: Variable [0011:Enemy-Troops ] == 3
    @> Change Gold: - 12
    @>
   : Branch End
  @> Conditional Branch: Variable [0011:Enemy-Troops ] == 4
    @> Change Gold: - 12
    @>
   : Branch End
  @> Conditional Branch: Variable [0011:Enemy-Troops ] == 5
    @> Change Gold: - 8
    @>
   : Branch End
  @>
: Branch End

A suggestion:
With this you could take an enemy from the map and make it have 2 or 3 different formation:
  • Troop -> ID 1: 2x Slime
  • Troop -> ID 2: 3x Slime
  • Troop -> ID 3: 1x Slime, 1x Spider
Code:
@> Control Variables: [0011:Enemy-Troops ] = Random No. (1...3)
@> Call Event: [Start-Battle]

This is the basis that I saw in some SuperNES JRPGs.
Huh, that actually sounds pretty simple. Especially the suggestion for the last bit, I could use that to randomize what the encounters are on each of the tokens. Thanks for the tips!

Original thread: https://forums.rpgmakerweb.com/threads/calling-common-event-on-defeat.135169/