VXAce Issue with TheoAllen's Gameover Choice + Battle Retry Script

Hello all.

I'm using TheoAllen's "Gameover Choice + Battle Retry" script in my game, which gives the player an option to retry a battle from where it started, go to their last save point, or quit the game every time they get a game over (the ability to start a battle over is only available if the player died in a battle, of course).

Apparently, if the battle has multiple branches to it (aka if "can lose" and/or "can escape" are enabled) and the player selects the Retry Battle command at least once during a battle attempt, anything within the "If Win", "If Lose", or "If Escape" battle processing branches skips over/doesn't process, only the things after the branch's end. For example, say the player dies in a battle they can either win or escape from, and then they try the battle again. By doing this, for some reason, anything in the "If Win" part of the branch doesn't process, like any switch triggers and text boxes. And yes, this does happen even if I use a new save file or if I use the script in a new project.

Does anyone know what could be causing this issue? Below is the script (the only modification to it is a game variable that determines whether the show battle retry option appears, but I removed that, and that didn't solve the issue):

Ruby:
# =============================================================================
# TheoAllen - Gameover Choice + Battle Retry
# Version : 2.1
# Contact : www.rpgmakerid.com (or) http://theolized.blogspot.com
# Requester : Darken (RMID) / Agus Widhiantara (FB)
# (This script documentation is written in informal indonesian language)
# =============================================================================
($imported ||= {})[:Theo_GChoice] = true
# =============================================================================
# Change Logs:
# -----------------------------------------------------------------------------
# 2014.02.11 - Compatibility with TSBS
# 2013.11.29 - Finished version 2.0
# 2013.02.26 - Finished version 1.0
# =============================================================================
=begin

  Perkenalan :
  This script adds options during gameover in the form of Battle Retry and
  returns to the game last checkpoint
 
  Cara penggunaan :
  Put this script under material but above main.
  To use checkpoint, use script call:
 
  $game_system.save_checkpoint
  $game_system.load_checkpoint
 
  From the name, you can see which one to save the checkpoint and which one to
  load.
 
  Terms of use :
  Credit gw, TheoAllen. Kalo semisal u bisa ngedit2 script gw trus jadi lebih
  keren, terserah. Ane bebasin. Asal ngga ngeklaim aja. Kalo semisal mau
  dipake buat komersil, jangan lupa, gw dibagi gratisannya.       

=end
# =============================================================================
# Konfigurasi
# =============================================================================
module Theo
  module GC
  # ---------------------------------------------------------------------------
  # Vocab untuk command di dalam window
  # ---------------------------------------------------------------------------
    VocabRetry  = "[Retry Battle]"      # Untuk battle retry
    VocabCP     = "[Last Timestamp]"   # Untuk checkpoint
    VocabTitle  = "[To Title Screen]"          # Untuk ke title
  # ---------------------------------------------------------------------------
    Width       = 200  # Lebar window gameover choice
  # ---------------------------------------------------------------------------
  end
end
# =============================================================================
# Akhir dari konfigurasi
# =============================================================================
class Game_System
  class CheckPoint
    attr_accessor :x
    attr_accessor :y
    attr_accessor :map_id
    attr_accessor :d
    attr_accessor :dumped_party
    attr_accessor :dumped_actors
    
    def initialize
      @x = $data_system.start_x
      @y = $data_system.start_y
      @map_id = $data_system.start_map_id
      @d = 2
      @dumped_party = nil
      @dumped_actors = []
    end
  end
 
  attr_reader :checkpoint
 
  alias theo_gchoice_init initialize
  def initialize
    theo_gchoice_init
    @checkpoint = CheckPoint.new
  end
 
  def save_checkpoint
    if $game_party.in_battle
      return
    end
    checkpoint.x = $game_player.x
    checkpoint.y = $game_player.y
    checkpoint.map_id = $game_map.map_id
    checkpoint.d = $game_player.direction
    checkpoint.dumped_party = copy($game_party)
    $game_party.members.each do |member|
      checkpoint.dumped_actors[member.id] = copy(member)
    end
  end
 
  def load_checkpoint
    $game_map.setup(checkpoint.map_id)
    $game_player.moveto(checkpoint.x, checkpoint.y)
    $game_player.set_direction(checkpoint.d)
    $game_party = checkpoint.dumped_party if checkpoint.dumped_party
    checkpoint.dumped_actors.each_with_index do |dump_actor, id|
      next if dump_actor.nil?
      $game_actors[id] = dump_actor
    end
    SceneManager.clear
    SceneManager.goto(Scene_Map)
  end
 
end

class Game_Temp
  class Last_Troop
    attr_accessor :id
    attr_accessor :can_lose
    attr_accessor :can_escape
    def initialize
      @id = 0
      @can_lose = false
      @can_escape = true
    end
  end
 
  attr_accessor :dumped_party
  attr_accessor :battle_retry
  attr_accessor :actor_fibers
  attr_reader :dumped_actors
  attr_reader :last_troop
 
  alias theo_gchoice_init initialize
  def initialize
    theo_gchoice_init
    @battle_retry = false
    @last_troop = Last_Troop.new
    @dumped_actors = []
    @dumped_party = nil
  end
end

class Game_Actor < Game_Battler
 
  def save_actor
    $game_temp.dumped_actors[id] = copy(self)
  end
 
  def load_actor
    $game_actors[id] = copy($game_temp.dumped_actors[id])
  end
 
  alias theo_gchoice_bstart on_battle_start
  def on_battle_start
    theo_gchoice_bstart
    $game_temp.battle_retry ? load_actor : save_actor
  end
 
end

class Game_Actors
 
  def []=(id, actor)
    @data[id] = actor
  end
 
end

class Game_Party < Game_Unit
 
  def save_party
    $game_temp.dumped_party = copy(self)
  end
 
  def load_party
    $game_party = copy($game_temp.dumped_party)
  end
 
  alias theo_gchoice_bstart on_battle_start
  def on_battle_start
    theo_gchoice_bstart
    $game_temp.battle_retry ? load_party : save_party
  end
 
end

class << BattleManager
 
  alias theo_gchoice_setup setup
  def setup(troop_id, can_escape = true, can_lose = false)
    @stored_variables = []
    @stored_switches = []
    (1..$data_system.variables.size).each do |i|
      @stored_variables[i] = $game_variables[i]
    end
    (1..$data_system.switches.size).each do |i|
      @stored_switches[i] = $game_switches[i]
    end
    theo_gchoice_setup(troop_id, can_escape, can_lose)
    $game_temp.last_troop.id = troop_id
    $game_temp.last_troop.can_escape = can_escape
    $game_temp.last_troop.can_lose = can_lose
  end
 
  def battle_retry
    troop_id = $game_temp.last_troop.id
    can_escape = $game_temp.last_troop.can_escape
    can_lose = $game_temp.last_troop.can_lose
    theo_gchoice_setup(troop_id, can_escape, can_lose)
    (1..$data_system.variables.size).each do |i|
      $game_variables[i] = @stored_variables[i]
    end
    (1..$data_system.switches.size).each do |i|
      $game_switches[i] = @stored_switches[i]
    end
    Sound.play_battle_start
    play_battle_bgm
  end
 
  alias theo_gchoice_replay_music replay_bgm_and_bgs
  def replay_bgm_and_bgs
    begin
      theo_gchoice_replay_music
    rescue
      $game_map.autoplay
    end
  end
 
end

class Window_GOChoice < Window_Command
 
  def initialize
    super(0,0)
    update_placement
    self.openness = 0
    activate
  end
 
  def make_command_list
    add_retry_command_if_lost_battle
    add_command(Theo::GC::VocabCP, :checkpoint)
    add_command(Theo::GC::VocabTitle, :title)
  end
 
  def add_retry_command_if_lost_battle
    add_command(Theo::GC::VocabRetry, :retry) if $game_variables[4800] == 1
  end
 
  def update_placement
    self.x = (Graphics.width - width)/2
    self.y = (Graphics.height * 1.6 - height) / 2
  end
 
  def window_width
    Theo::GC::Width
  end
 
end

class Scene_Gameover < Scene_Base
 
  alias theo_gchoice_start start
  def start
    theo_gchoice_start
    @command_window = Window_GOChoice.new
    @command_window.set_handler(:retry, method(:battle_retry))
    @command_window.set_handler(:checkpoint, method(:goto_checkpoint))
    @command_window.set_handler(:title, method(:goto_title))
    @command_window.open
  end
 
  def battle_retry
    RPG::ME.stop
    fadeout_all
    BattleManager.battle_retry
    $game_temp.battle_retry = true
    SceneManager.goto(Scene_Battle)
    close_command
  end
 
  def goto_checkpoint
    RPG::ME.stop
    file_index = DataManager.latest_savefile_index
    DataManager.load_game(file_index)
    SceneManager.goto(Scene_Map)
    SceneManager.scene.fadeout_all
    $game_system.on_after_load
    close_command
  end
 
  def close_command
    @command_window.close
    update_basic until @command_window.close?
  end
  # ----------------------------------------
  # Overwrites
  # ----------------------------------------
  def update
    super
  end
 
end

class Scene_Battle
 
  alias theo_gchoice_bt_start battle_start
  def battle_start
    theo_gchoice_bt_start
    if $game_temp.battle_retry && $imported[:TSBS]
      recreate_spriteset
    else
      $game_temp.battle_retry = false
    end
  end
 
  def recreate_spriteset
    @spriteset.dispose
    create_spriteset
    $game_temp.battle_retry = false
  end
 
end

def copy(object)
  Marshal.load(Marshal.dump(object))
end
Hi! This reminds me of an issue highlighted by @Another Fen in this thread (a working solution is available in his post that I link) where the Game_Interpreter's index will continue to advance when loading a save file, maybe this script can fix your issue?
Nope, it's not as simple as keeping the event's index safe. Actually, that happens because the battle retry script ignored a key component of the battle setup only found in Game_Interpreter. But don't worry! Here's a fix!

Ruby:
# * Others' BattleRetry Fix * #
#   Scripter : Kyonides
#   2025-09-30

module OthersBRFix
  extend self
  attr_accessor :event_data
end

class Game_Temp
  attr_accessor :battle_retry
end

class Game_Interpreter
  def reset_setup(ary)
    @depth = ary.shift
    @map_id = ary.shift
    @event_id = ary.shift
    @list = ary.shift
    @index = ary.shift
    @branch = ary.shift
    create_fiber
  end

  def add_battle_proc
    Proc.new {|n| @branch[@indent] = n }
  end
end

class Scene_Battle
  alias :kyon_battles_n_gm_inter_scn_battle_pst_strt :post_start
  def post_start
    if $game_temp.battle_retry
      add_missing_retry_battle_setup
    else
      store_battle_retry_map_event_data
    end
    kyon_battles_n_gm_inter_scn_battle_pst_strt
  end

  def add_missing_retry_battle_setup
    BattleManager.event_proc = $game_map.interpreter.add_battle_proc
    $game_map.interpreter.reset_setup(OthersBRFix.event_data)
    $game_player.make_encounter_count
  end

  def store_battle_retry_map_event_data
    OthersBRFix.event_data = $game_map.interpreter.marshal_dump
  end
end
Moved to RGSSx Script Support.
Nope, it's not as simple as keeping the event's index safe. Actually, that happens because the battle retry script ignored a key component of the battle setup only found in Game_Interpreter. But don't worry! Here's a fix!

Ruby:
# * Others' BattleRetry Fix * #
#   Scripter : Kyonides
#   2025-09-30

module OthersBRFix
  extend self
  attr_accessor :event_data
end

class Game_Temp
  attr_accessor :battle_retry
end

class Game_Interpreter
  def reset_setup(ary)
    @depth = ary.shift
    @map_id = ary.shift
    @event_id = ary.shift
    @list = ary.shift
    @index = ary.shift
    @branch = ary.shift
    create_fiber
  end

  def add_battle_proc
    Proc.new {|n| @branch[@indent] = n }
  end
end

class Scene_Battle
  alias :kyon_battles_n_gm_inter_scn_battle_pst_strt :post_start
  def post_start
    if $game_temp.battle_retry
      add_missing_retry_battle_setup
    else
      store_battle_retry_map_event_data
    end
    kyon_battles_n_gm_inter_scn_battle_pst_strt
  end

  def add_missing_retry_battle_setup
    BattleManager.event_proc = $game_map.interpreter.add_battle_proc
    $game_map.interpreter.reset_setup(OthersBRFix.event_data)
    $game_player.make_encounter_count
  end

  def store_battle_retry_map_event_data
    OthersBRFix.event_data = $game_map.interpreter.marshal_dump
  end
end
Yep, this worked, even on old save files! Thanks so much!

Original thread: https://forums.rpgmakerweb.com/threads/issue-with-theoallens-gameover-choice-battle-retry-script.180360/