Aborting Battle Not Working As Intended

Hi all, it's been a really, really long time since I've been here and this may be something I've just overlooked on the forums, but it's frustrating to no end.

So, the idea I have for my game is that outside of boss battles, if the player fails in battle, it's not a game over; they'll get transported out of the area back to a medic who heals them and they can try again. If it's a boss battle, however, no such luck. I'm also using this in tandem with Yanfly's "Common Event on Death" script, to call a common event that aborts the battle when the main character gets knocked out (with the party all freaking out accordingly).

Herein lies the problem. I'm not sure if I've misplaced a call or what, but it just...doesn't work. I've set up an unwinnable test enemy and an invisible aggro state that makes sure the enemy attacks the main character to kill him first, and the party appropriately panics.

WHAT I WANTED TO HAPPEN:
- Screen fades to black
- Battle aborts while screen is faded out
- Party gets teleported back to the healer
- Screen fades back in after party is healed

WHAT ACTUALLY HAPPENS:
- Screen flashes black for a moment
- Dialogue continues but battle does not abort

Here's the setup of the common event. Like I said, I could have just missed something in arranging the calls, or it's just something not feasible with this particular script.

1726978543857.png


It just completely skips the "Abort Battle" call and keeps the battle going. I've tried it with "Can Lose" and "Can Escape" set up, but it seems that the event runs before the actual loss processes.

Should I just set up the common event to run as a troop event for every troop instead, or is this something that can be accomplished the way I'm intending?
Without taking a look at the script you mentioned, it sounds like you were missing a detail like making sure there's no battle result interfering with the Common Event on Death mechanism or the abort battle call doesn't work outside the battle processing call.

The following scriptlet should let you see a popup window show up telling you the system is aborting the battle right then. If you don't see anything, it clearly means the process_abort call is getting ignored on purpose. The next step would be to find out where in your custom scripts you can find the culprit code.

Ruby:
module BattleManager
  def self.process_abort
    msgbox "Aborting..."
    replay_bgm_and_bgs
    SceneManager.return
    battle_end(1)
    return true
  end
end

I'm about to fall asleep so don't take it personal if this suggestion doesn't help you somehow.
Without taking a look at the script you mentioned, it sounds like you were missing a detail like making sure there's no battle result interfering with the Common Event on Death mechanism or the abort battle call doesn't work outside the battle processing call.

The following scriptlet should let you see a popup window show up telling you the system is aborting the battle right then. If you don't see anything, it clearly means the process_abort call is getting ignored on purpose. The next step would be to find out where in your custom scripts you can find the culprit code.

Ruby:
module BattleManager
  def self.process_abort
    msgbox "Aborting..."
    replay_bgm_and_bgs
    SceneManager.return
    battle_end(1)
    return true
  end
end

I'm about to fall asleep so don't take it personal if this suggestion doesn't help you somehow.
So it looks like it was that Abort Battle doesn't work outside of battle processing. I used this scriptlet to test my common event and it just flat ignored Abort Battle. I tested it in the actual troop events though and it works fine, so I just cobbled together a troop event that runs as soon as the character is killed and aborts the battle, and a parallel process that only triggers if the character is dead and performs the transport as I wanted.

Not a perfect or ideal means of doing this, but I guess if it gets the job done I can't be picky.

Original thread: https://forums.rpgmakerweb.com/threads/aborting-battle-not-working-as-intended.172063/