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):
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