Group: Member
Posts: 7
Type: None
RM Skill: Undisclosed
Hello,
I am using a Battle Retry Script in my current project and it really comes in handy during boss fights. What it does is giving you a new option on the Game Over Screen that lets you immediately retry the battle again without having to go back to your last save point (no need seeing long cutscenes over and over again anymore).
All of this basically works, but there's a rather small problem that is REALLY bothering me: If you choose "Retry" on the Game Over Screen and it takes you right back to the start of the battle, the Game Over music still keeps playing until the song's over, only then the Battle BGM kicks in. How can I modify this script so it force-stops the Game Over ME as soon as you click on "Retry"?
Here's the script
Battle Retry Script
CODE
#========================================================================== # * Battle Retry #========================================================================== # by sandgolem # Tradução by:NaRuToMaKeR # www.reinorpg.com # Versão 1 [VX] # Janeiro 26th, 2008 #========================================================================== # INSTRU‡•ES: # # 1- Ponha acima do main # 2- Edite no Battle_Retry Module #==========================================================================
module GameBaker BattleRetryCommands = ['Retry','Title Screen'] # As frases que irão aparecer. BattleRetryDisableSwitch = 0 #Switch que desativa o battle retry. 0 para nenhuma end
#========================================================================== # Game Interpreter #==========================================================================
class Game_Interpreter alias_method :gamebaker_battleretry_interp601, :command_601 def command_601 if $gamebaker_retrywon @branch[@list[@index].indent] = 0 $gamebaker_retrywon = nil end return gamebaker_battleretry_interp601 end
alias_method :gamebaker_battleretry_interp602, :command_602 def command_602 if $gamebaker_retryescaped @branch[@list[@index].indent] = 1 $gamebaker_retryescaped = nil end return gamebaker_battleretry_interp602 end end
class Scene_File def gamebaker_write_retrysave_data file = File.open('Data/retry.gb', 'wb') write_save_data(file) file.close end
def gamebaker_read_retrysave_data file = File.open('Data/retry.gb', 'rb') read_save_data(file) file.close end end
class Scene_Battle alias_method :gamebaker_battleretry_main, :main def main $gamebaker_retryescaped = nil $gamebaker_retrywon = nil if !$game_switches[GameBaker::BattleRetryDisableSwitch] if !$gamebaker_battleretry_inbattle & !$game_troop.can_lose $gamebaker_battleretry_inbattle = $game_troop gamebaker_scene_save_temp = Scene_File.new(true,true,true) gamebaker_scene_save_temp.gamebaker_write_retrysave_data gamebaker_scene_save_temp = nil end end gamebaker_battleretry_main if !$scene.is_a?(Scene_Gameover) File.delete('Data/retry.gb') if FileTest.exist?('Data/retry.gb') $gamebaker_battleretry_inbattle = nil end end
alias_method :gamebaker_battleretry_battleend, :battle_end def battle_end(result) $gamebaker_retrywon = true if result == 0 $gamebaker_retryescaped = true if result == 1 gamebaker_battleretry_battleend(result) end end
class Scene_Gameover
class Scene_Gameover alias_method :gamebaker_battleretry_gameovermain, :main def main if $gamebaker_battleretry_inbattle $data_system.gameover_me.play @sprite = Sprite.new @sprite.bitmap = Cache.system("GameOver") Graphics.transition(60) @command_window = Window_Command.new(146,GameBaker::BattleRetryCommands) @command_window.back_opacity = 160 @command_window.x = 288 - @command_window.width / 2 @command_window.y = 248 loop do Graphics.update Input.update gamebaker_retry_update break if $scene != self end @command_window.dispose Graphics.freeze @sprite.bitmap.dispose @sprite.dispose Graphics.transition(30) Graphics.freeze else gamebaker_battleretry_gameovermain end end
def gamebaker_retry_update @command_window.update if Input.trigger?(Input::C) case @command_window.index when 0 $game_system.battle_bgm.play gamebaker_scene_save_temp = Scene_File.new(true,true,true) gamebaker_scene_save_temp.gamebaker_read_retrysave_data gamebaker_scene_save_temp = nil $game_troop = $gamebaker_battleretry_inbattle $scene = Scene_Battle.new when 1 File.delete('Data/retry.gb') if FileTest.exist?('Data/retry.gb') $gamebaker_battleretry_inbattle = nil $scene = Scene_Title.new end end end end
I tried using Woratana's Battle Retry Script before, but there's a sound bug that's even worse: after you choose "retry", there's no music at all!
I am also using this snippet here which force-stops the Game Over ME on "normal" game over screens (where you do not get a retry option) once you go back to the title screen. This one works fine. Unortunately, I am much too inexperienced with Ruby, so I don't know how to change or implement this in a way so it would also affect the Battle Retry script, nor do I know whether this is actually possible.
ForceStop Game Over ME Snippet
CODE
class Scene_Gameover alias start_me start def start $data_system.gameover_me.volume = 100 start_me @secunde = 0 @daten = [ "Audio/" + "ME" + "/" + $data_system.gameover_me.name, $data_system.gameover_me.volume, $data_system.gameover_me.pitch ] $data_system.gameover_me.volume = 0 Audio.me_play(@daten[0],@daten[1],@daten[2]) end alias update_me update def update update_me @secunde += 1 if (Graphics.frame_count / (Graphics.frame_rate / 60)) % 60 == 0 if @secunde >= 9 Audio.me_play(@daten[0],@daten[1],@daten[2]) @secunde = 0 end end alias terminate_me terminate def terminate terminate_me Audio.me_stop end end
I would REALLY appreciate if you could help me with this and of course you'll be mentioned in the credits once this project is finished!
Thanks for your time!
This post has been edited by VeluCherry: Jan 27 2012, 01:04 AM
module GameBaker BattleRetryCommands = ['Retry','Title Screen'] # As frases que irão aparecer. BattleRetryDisableSwitch = 0 #Switch que desativa o battle retry. 0 para nenhuma end
#========================================================================== # Game Interpreter #==========================================================================
class Game_Interpreter alias_method :gamebaker_battleretry_interp601, :command_601 def command_601 if $gamebaker_retrywon @branch[@list[@index].indent] = 0 $gamebaker_retrywon = nil end return gamebaker_battleretry_interp601 end
alias_method :gamebaker_battleretry_interp602, :command_602 def command_602 if $gamebaker_retryescaped @branch[@list[@index].indent] = 1 $gamebaker_retryescaped = nil end return gamebaker_battleretry_interp602 end end
class Scene_File def gamebaker_write_retrysave_data file = File.open('Data/retry.gb', 'wb') write_save_data(file) file.close end
def gamebaker_read_retrysave_data file = File.open('Data/retry.gb', 'rb') read_save_data(file) file.close end end
class Scene_Battle alias_method :gamebaker_battleretry_main, :main def main $gamebaker_retryescaped = nil $gamebaker_retrywon = nil if !$game_switches[GameBaker::BattleRetryDisableSwitch] if !$gamebaker_battleretry_inbattle & !$game_troop.can_lose $gamebaker_battleretry_inbattle = $game_troop gamebaker_scene_save_temp = Scene_File.new(true,true,true) gamebaker_scene_save_temp.gamebaker_write_retrysave_data gamebaker_scene_save_temp = nil end end gamebaker_battleretry_main if !$scene.is_a?(Scene_Gameover) File.delete('Data/retry.gb') if FileTest.exist?('Data/retry.gb') $gamebaker_battleretry_inbattle = nil end end
alias_method :gamebaker_battleretry_battleend, :battle_end def battle_end(result) $gamebaker_retrywon = true if result == 0 $gamebaker_retryescaped = true if result == 1 gamebaker_battleretry_battleend(result) end end
class Scene_Gameover
class Scene_Gameover alias_method :gamebaker_battleretry_gameovermain, :main def main if $gamebaker_battleretry_inbattle $data_system.gameover_me.play @sprite = Sprite.new @sprite.bitmap = Cache.system("GameOver") Graphics.transition(60) @command_window = Window_Command.new(146,GameBaker::BattleRetryCommands) @command_window.back_opacity = 160 @command_window.x = 288 - @command_window.width / 2 @command_window.y = 248 loop do Graphics.update Input.update gamebaker_retry_update break if $scene != self end @command_window.dispose Graphics.freeze @sprite.bitmap.dispose @sprite.dispose Graphics.transition(30) Graphics.freeze else gamebaker_battleretry_gameovermain end end
def gamebaker_retry_update @command_window.update if Input.trigger?(Input::C) case @command_window.index when 0 RPG::ME.stop RPG::BGS.stop $game_system.battle_bgm.play gamebaker_scene_save_temp = Scene_File.new(true,true,true) gamebaker_scene_save_temp.gamebaker_read_retrysave_data gamebaker_scene_save_temp = nil $game_troop = $gamebaker_battleretry_inbattle $scene = Scene_Battle.new when 1 File.delete('Data/retry.gb') if FileTest.exist?('Data/retry.gb') $gamebaker_battleretry_inbattle = nil $scene = Scene_Title.new end end end end
Wasn't too hard. All I did was add RPG::BGS.stop and RPG::ME.stop into it. Yeah. Tell me if it works, I edited it my game, and I am using my own modified version of Wora's retry, so...
This post has been edited by Storm237: Jan 27 2012, 08:43 AM
__________________________
Darkness Tales! That is my current project.[hide] The sig link is dead. Please do not touch it until further notice. I support:
Group: Member
Posts: 7
Type: None
RM Skill: Undisclosed
Yeah, the script seems a bit messy, so thanks for taking a look at it and for the quick reply! Unfortunately, it's giving me all sorts of errors now, just can't seem to get this to work...
It would be really great if you could share your edited version of Woratana's script - would that be ok for you?
This thing is really driving me nuts - and I definitely need to learn a lot about scripting with Ruby...
Group: Member
Posts: 49
Type: None
RM Skill: Beginner
Ohh sure, it is public anyways, somewhere. Uhh, the thing is, there is an added feature, so if you don't like it, tell me, and I will do away with that for you.
CODE
#=============================================================== # — [VX] — Battle Retry — – With an added Checkpoint System by Adon237 # * Enable player to retry the battle after losing * # ** Note: Read the setup part before using this script ** #-------------------------------------------------------------- # — by Woratana [woratana@hotmail.com] # — Thaiware RPG Maker Community # — Released on: 29/02/2009 # — Version: 1.0 #-------------------------------------------------------------- # — Update: #-------------------------------------------------------------- # – Version 1.0 (29/02/2009) # - Set switch ID to enable/disable battle retry during the game # - Editable command's text, command's window width and Y-coordinate # - You can choose to record party actors stat (HP/MP/States) before battle # #-------------------------------------------------------------- # — Compatibility: #-------------------------------------------------------------- # – This script will rewrite 0 method(s): # # # – This script will alias 5 method(s): # Scene_Gameover.perform_transition # Scene_Gameover.terminate # Scene_Gameover.update # Scene_Battle.battle_end # Game_Interpreter.command_301 # # – This script should work with most scripts, except for some modifications # of Scene_Gameover # #-------------------------------------------------------------- # — Installation: #-------------------------------------------------------------- # 1) This script should be placed JUST BEFORE – Main Process. # # – Like this: # – Materials # ... # ... # * Battle Retry # – Main Process # Main # # 2) Setup this script in Setup Part below. # #-------------------------------------------------------------- # — How to use: #-------------------------------------------------------------- # – Place this script and setup in the setup part. # #================================================================= # ALL ABOUT >>> THE CHECKPOINT SYSTEM #================================================================= =begin Checkpoints are areas a player can decide to return to by selecting the 'Return to Last Checkpoint' option in the game over screen. Checkpoints can be handled by events. You will need to set the variable you chose for "LASTCHECKPOINT_VAR" to the map ID the player is currently on, "CHECKX" to the current X, "CHECKY" to the current Y. For example, if you have 'save points' you would set so each time they use the savepoint, the variable for "LASTCHECKPOINT_VAR" to the current MAP ID. Then the variable for "CHECKX" to the player's current X position, and "CHECKY", to the player's current Y position. Then next time they "GAME OVER", if they select the "RETURN TO LAST CHECKPOINT" option, they will be transferred to that save point. =end # #================================================================= class Scene_Gameover < Scene_Base
#================================================================= # ++ Setup Part #----------------------------------------------------------------- BATRETRY_SWITCH_ID = 998 # Enable Battle Retry if this switch ID is ON # Disable Battle Retry if this switch ID is OFF #Retry Battle # Return to Last Checkpoint #Return to Title Screen BATRETRY_COMMANDS = ['Retry Battle', 'Return to Last Checkpoint', 'Return to Title Screen'] # Text on command window asking for Battle Retry # E.g. ['Go back to battle', 'Exit to title screen']
BATRETRY_RECORD_PARTY_STAT = false LASTCHECKPOINT_VAR = 101 # Variable that keeps track of the map ID that you transfer to when # selecting the 'Return to Last Checkpoint' option. CHECKX = 102 # The ID of the variable that decides the X location to transfer to on that # specific map. CHECKY = 103 # The ID of the variable that decides the Y location to transfer to on that # specific map.
# Record party members' HP/MP/status before going to battle? (true/false) # # - If this set to true, if Ralph has HP 30 before battle and got poisoned. # When player retry the battle, Ralph will still has HP 30 and poisoned. # # - If this set to false, all the members will get full HP/MP and no bad status # after retry the battle. #=================================================================
alias wora_batretry_scego_pertran perform_transition alias wora_batretry_scego_term terminate alias wora_batretry_scego_upd update #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update(*args) if $game_temp.battle_retry? super @command_window.update if Input.trigger?(Input::C) case @command_window.index when 0 # Battle Retry # If recorded party stat, load recorded data $game_system.remembered_bgm.play unless $game_temp.last_troop_actor.nil? $game_temp.last_troop_actor.each_key do |id| data = $game_temp.last_troop_actor[id] $game_actors[id].hp = data[0] $game_actors[id].mp = data[1] $game_actors[id].real_states = data[2] end else # If not, recover party members $game_party.members.each {|actor| actor.recover_all } end # Setup battle last_troop = $game_temp.last_troop_id $game_troop.setup(last_troop[0]) $game_troop.can_escape = last_troop[1] $game_troop.can_lose = false $game_temp.next_scene = "battle" $scene = Scene_Battle.new
when 1 # Return to last checkpoint Sound.play_decision $game_map.setup($game_variables[LASTCHECKPOINT_VAR]) $game_player.moveto($game_variables[CHECKX], $game_variables[CHECKY]) $game_player.refresh $scene = Scene_Map.new RPG::BGM.fade(1500) close_command_window Graphics.fadeout(60) Graphics.wait(40) Graphics.frame_count = 0 RPG::BGM.stop $game_map.autoplay when 2 # Go to Title Screen $scene = Scene_Title.new Graphics.fadeout(120) end end else # Normal Gameover scene wora_batretry_scego_upd(*args) end end #-------------------------------------------------------------------------- # * Execute Transition #-------------------------------------------------------------------------- def perform_transition(*args) if $game_temp.battle_retry? # Add command window if need battle retry @command_window = Window_Command.new(BATRETRY_WINDOW_WIDTH, BATRETRY_COMMANDS) # Show battle retry window in the middle @command_window.x = (Graphics.width - @command_window.width) / 2 @command_window.y = BATRETRY_WINDOW_Y @command_window.openness = 0 @command_window.open # Perform transition wora_batretry_scego_pertran(*args) # Open command window until @command_window.openness == 255 @command_window.update Graphics.update end @command_window.active = true else # Normal Gameover scene wora_batretry_scego_pertran(*args) end end #-------------------------------------------------------------------------- # * Termination Processing #-------------------------------------------------------------------------- def terminate(*args) @command_window.dispose unless @command_window.nil? wora_batretry_scego_term(*args) end end
class Scene_Battle < Scene_Base alias wora_batretry_scebat_batend battle_end #-------------------------------------------------------------------------- # * End Battle #-------------------------------------------------------------------------- def battle_end(*args) unless (args[0] == 2 and !$game_troop.can_lose) # Remove last troop data if won battle $game_temp.last_troop_id = nil $game_temp.last_troop_actor = nil end wora_batretry_scebat_batend(*args) end
end
class Game_Temp #-------------------------------------------------------------------------- # * Public Instance Variables #-------------------------------------------------------------------------- attr_accessor :last_troop_id, :last_troop_actor
#-------------------------------------------------------------------------- # * Check if battle can be retry #-------------------------------------------------------------------------- def battle_retry? return ($game_switches[Scene_Gameover::BATRETRY_SWITCH_ID] and !@last_troop_id.nil?) end end
class Game_Interpreter alias wora_batretry_gamint_com301 command_301 #-------------------------------------------------------------------------- # * Battle Processing #-------------------------------------------------------------------------- def command_301(*args) # If enable to record party stat before battle.. if Scene_Gameover::BATRETRY_RECORD_PARTY_STAT $game_temp.last_troop_actor = {} $game_party.members.each do |actor| $game_temp.last_troop_actor[actor.id] = [actor.hp, actor.mp, actor.real_states] end end # Store last troop ID in Game_System troop_id = @params[0] == 0 ? @params[1] : $game_variables[@params[1]] $game_temp.last_troop_id = [troop_id, @params[2]] unless $game_temp.in_battle wora_batretry_gamint_com301(*args) end end
class Game_Battler #-------------------------------------------------------------------------- # * Return real states #-------------------------------------------------------------------------- def real_states return @states.clone end
#-------------------------------------------------------------------------- # * Set states with states ID array #-------------------------------------------------------------------------- def real_states=(states_id_array) @states = states_id_array end end
This post has been edited by Storm237: Jan 27 2012, 10:36 AM
__________________________
Darkness Tales! That is my current project.[hide] The sig link is dead. Please do not touch it until further notice. I support:
Group: Member
Posts: 7
Type: None
RM Skill: Undisclosed
QUOTE (Storm237 @ Jan 27 2012, 10:57 AM)
Umm, tell me if it gives you any problems, because their might be with the close command window. It really depends though.
Checkpoint system works fine, but now I've encountered an "undefined method" error when choosing 'battle retry' because of line 120 $game_system.remembered_bgm.play
Group: Member
Posts: 49
Type: None
RM Skill: Beginner
QUOTE (VeluCherry @ Jan 27 2012, 12:13 PM)
QUOTE (Storm237 @ Jan 27 2012, 10:57 AM)
Umm, tell me if it gives you any problems, because their might be with the close command window. It really depends though.
Checkpoint system works fine, but now I've encountered an "undefined method" error when choosing 'battle retry' because of line 120 $game_system.remembered_bgm.play
Hmm... this is odd.
I am so sorry for all of the errors, I am a rather novice scripter, so... If you could provide more detail, like exactly what it said, that would be nice! OR you can just remove that line from the script. It seems to have no correlation with any other parts of the script.
This post has been edited by Storm237: Jan 27 2012, 11:27 AM
__________________________
Darkness Tales! That is my current project.[hide] The sig link is dead. Please do not touch it until further notice. I support:
Group: Member
Posts: 7
Type: None
RM Skill: Undisclosed
QUOTE (Storm237 @ Jan 27 2012, 11:25 AM)
QUOTE (VeluCherry @ Jan 27 2012, 12:13 PM)
QUOTE (Storm237 @ Jan 27 2012, 10:57 AM)
Umm, tell me if it gives you any problems, because their might be with the close command window. It really depends though.
Checkpoint system works fine, but now I've encountered an "undefined method" error when choosing 'battle retry' because of line 120 $game_system.remembered_bgm.play
Hmm... this is odd.
I am so sorry for all of the errors, I am a rather novice scripter, so... If you could provide more detail, like exactly what it said, that would be nice! OR you can just remove that line from the script. It seems to have no correlation with any other parts of the script.
No problem, I'm so glad someone is helping me with this at all
Unfortunately, if I delete this line, the old problem returns where there's no BGM playing during a battle retry
Here's the error that occurs when I leave the line in:
This post has been edited by VeluCherry: Jan 27 2012, 11:34 AM
Group: Member
Posts: 49
Type: None
RM Skill: Beginner
CODE
#=============================================================== # — [VX] — Battle Retry — – With an added Checkpoint System by Adon237 # * Enable player to retry the battle after losing * # ** Note: Read the setup part before using this script ** #-------------------------------------------------------------- # — by Woratana [woratana@hotmail.com] # — Thaiware RPG Maker Community # — Released on: 29/02/2009 # — Version: 1.0 #-------------------------------------------------------------- # — Update: #-------------------------------------------------------------- # – Version 1.0 (29/02/2009) # - Set switch ID to enable/disable battle retry during the game # - Editable command's text, command's window width and Y-coordinate # - You can choose to record party actors stat (HP/MP/States) before battle # - Use Variables to keep track of what map to transfer to for Checkpoints. # - Controlling can be done from any old change variable command. # #-------------------------------------------------------------- # — Compatibility: #-------------------------------------------------------------- # – This script will rewrite 0 method(s): # # # – This script will alias 5 method(s): # Scene_Gameover.perform_transition # Scene_Gameover.terminate # Scene_Gameover.update # Scene_Battle.battle_end # Game_Interpreter.command_301 # # – This script should work with most scripts, except for some modifications # of Scene_Gameover # #-------------------------------------------------------------- # — Installation: #-------------------------------------------------------------- # 1) This script should be placed JUST BEFORE – Main Process. # # – Like this: # – Materials # ... # ... # * Battle Retry # – Main Process # Main # # 2) Setup this script in Setup Part below. # #-------------------------------------------------------------- # — How to use: #-------------------------------------------------------------- # – Place this script and setup in the setup part. # #================================================================= # ALL ABOUT >>> THE CHECKPOINT SYSTEM #================================================================= =begin Checkpoints are areas a player can decide to return to by selecting the 'Return to Last Checkpoint' option in the game over screen. Checkpoints can be handled by events. You will need to set the variable you chose for "LASTCHECKPOINT_VAR" to the map ID the player is currently on, "CHECKX" to the current X, "CHECKY" to the current Y. For example, if you have 'save points' you would set so each time they use the savepoint, the variable for "LASTCHECKPOINT_VAR" to the current MAP ID. Then the variable for "CHECKX" to the player's current X position, and "CHECKY", to the player's current Y position. Then next time they "GAME OVER", if they select the "RETURN TO LAST CHECKPOINT" option, they will be transferred to that save point. =end # #================================================================= class Scene_Gameover < Scene_Base
#================================================================= # ++ Setup Part #----------------------------------------------------------------- BATRETRY_SWITCH_ID = 998 # Enable Battle Retry if this switch ID is ON # Disable Battle Retry if this switch ID is OFF #Retry Battle # Return to Last Checkpoint #Return to Title Screen BATRETRY_COMMANDS = ['Retry Battle', 'Return to Last Checkpoint', 'Return to Title Screen'] # Text on command window asking for Battle Retry # E.g. ['Go back to battle', 'Exit to title screen']
BATRETRY_RECORD_PARTY_STAT = false LASTCHECKPOINT_VAR = 101 # Variable that keeps track of the map ID that you transfer to when # selecting the 'Return to Last Checkpoint' option. CHECKX = 102 # The ID of the variable that decides the X location to transfer to on that # specific map. CHECKY = 103 # The ID of the variable that decides the Y location to transfer to on that # specific map.
# Record party members' HP/MP/status before going to battle? (true/false) # # - If this set to true, if Ralph has HP 30 before battle and got poisoned. # When player retry the battle, Ralph will still has HP 30 and poisoned. # # - If this set to false, all the members will get full HP/MP and no bad status # after retry the battle. #=================================================================
alias wora_batretry_scego_pertran perform_transition alias wora_batretry_scego_term terminate alias wora_batretry_scego_upd update # QUICK DEFINE CLOSE COMMAND WINDOW def close_command_window @command_window.close begin @command_window.update Graphics.update end until @command_window.openness == 0 end def play_remembered_bgm if $game_system.remembered_bgm != nil $game_system.remembered_bgm.play end end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update(*args) if $game_temp.battle_retry? super @command_window.update if Input.trigger?(Input::C) case @command_window.index when 0 # Battle Retry # If recorded party stat, load recorded data RPG::ME.stop $game_system.remembered_bgm.play unless $game_temp.last_troop_actor.nil? $game_temp.last_troop_actor.each_key do |id| data = $game_temp.last_troop_actor[id] $game_actors[id].hp = data[0] $game_actors[id].mp = data[1] $game_actors[id].real_states = data[2] end else # If not, recover party members $game_party.members.each {|actor| actor.recover_all } end # Setup battle last_troop = $game_temp.last_troop_id $game_troop.setup(last_troop[0]) $game_troop.can_escape = last_troop[1] $game_troop.can_lose = false $game_temp.next_scene = "battle" $scene = Scene_Battle.new
when 1 # Return to last checkpoint Sound.play_decision RPG::ME.stop $game_map.setup($game_variables[LASTCHECKPOINT_VAR]) $game_player.moveto($game_variables[CHECKX], $game_variables[CHECKY]) $game_player.refresh $scene = Scene_Map.new RPG::BGM.fade(1500) close_command_window Graphics.fadeout(60) Graphics.wait(40) Graphics.frame_count = 0 RPG::BGM.stop $game_map.autoplay when 2 # Go to Title Screen $scene = Scene_Title.new Graphics.fadeout(120) end end else # Normal Gameover scene wora_batretry_scego_upd(*args) end end #-------------------------------------------------------------------------- # * Execute Transition #-------------------------------------------------------------------------- def perform_transition(*args) if $game_temp.battle_retry? # Add command window if need battle retry @command_window = Window_Command.new(BATRETRY_WINDOW_WIDTH, BATRETRY_COMMANDS) # Show battle retry window in the middle @command_window.x = (Graphics.width - @command_window.width) / 2 @command_window.y = BATRETRY_WINDOW_Y @command_window.openness = 0 @command_window.open # Perform transition wora_batretry_scego_pertran(*args) # Open command window until @command_window.openness == 255 @command_window.update Graphics.update end @command_window.active = true else # Normal Gameover scene wora_batretry_scego_pertran(*args) end end #-------------------------------------------------------------------------- # * Termination Processing #-------------------------------------------------------------------------- def terminate(*args) @command_window.dispose unless @command_window.nil? wora_batretry_scego_term(*args) end end
class Scene_Battle < Scene_Base alias wora_batretry_scebat_batend battle_end #-------------------------------------------------------------------------- # * End Battle #-------------------------------------------------------------------------- def battle_end(*args) unless (args[0] == 2 and !$game_troop.can_lose) # Remove last troop data if won battle $game_temp.last_troop_id = nil $game_temp.last_troop_actor = nil end wora_batretry_scebat_batend(*args) end
end
class Game_Temp #-------------------------------------------------------------------------- # * Public Instance Variables #-------------------------------------------------------------------------- attr_accessor :last_troop_id, :last_troop_actor
#-------------------------------------------------------------------------- # * Check if battle can be retry #-------------------------------------------------------------------------- def battle_retry? return ($game_switches[Scene_Gameover::BATRETRY_SWITCH_ID] and !@last_troop_id.nil?) end end
class Game_Interpreter alias wora_batretry_gamint_com301 command_301 #-------------------------------------------------------------------------- # * Battle Processing #-------------------------------------------------------------------------- def command_301(*args) # If enable to record party stat before battle.. if Scene_Gameover::BATRETRY_RECORD_PARTY_STAT $game_temp.last_troop_actor = {} $game_party.members.each do |actor| $game_temp.last_troop_actor[actor.id] = [actor.hp, actor.mp, actor.real_states] end end # Store last troop ID in Game_System troop_id = @params[0] == 0 ? @params[1] : $game_variables[@params[1]] $game_temp.last_troop_id = [troop_id, @params[2]] unless $game_temp.in_battle wora_batretry_gamint_com301(*args) end end
class Game_Battler #-------------------------------------------------------------------------- # * Return real states #-------------------------------------------------------------------------- def real_states return @states.clone end
#-------------------------------------------------------------------------- # * Set states with states ID array #-------------------------------------------------------------------------- def real_states=(states_id_array) @states = states_id_array end end
try this
This post has been edited by Storm237: Jan 27 2012, 11:41 AM
__________________________
Darkness Tales! That is my current project.[hide] The sig link is dead. Please do not touch it until further notice. I support:
Group: Member
Posts: 49
Type: None
RM Skill: Beginner
CODE
#=============================================================== # ● [VX] ◦ Battle Retry ◦ □ With an added Checkpoint System by Adon237 # * Enable player to retry the battle after losing * # ** Note: Read the setup part before using this script ** #-------------------------------------------------------------- # ◦ by Woratana [woratana@hotmail.com] # ◦ Thaiware RPG Maker Community # ◦ Released on: 29/02/2009 # ◦ Version: 1.0 #-------------------------------------------------------------- # ◦ Update: #-------------------------------------------------------------- # □ Version 1.0 (29/02/2009) # - Set switch ID to enable/disable battle retry during the game # - Editable command's text, command's window width and Y-coordinate # - You can choose to record party actors stat (HP/MP/States) before battle # - Use Variables to keep track of what map to transfer to for Checkpoints. # - Controlling can be done from any old change variable command. # #-------------------------------------------------------------- # ◦ Compatibility: #-------------------------------------------------------------- # □ This script will rewrite 0 method(s): # # # □ This script will alias 5 method(s): # Scene_Gameover.perform_transition # Scene_Gameover.terminate # Scene_Gameover.update # Scene_Battle.battle_end # Game_Interpreter.command_301 # # □ This script should work with most scripts, except for some modifications # of Scene_Gameover # #-------------------------------------------------------------- # ◦ Installation: #-------------------------------------------------------------- # 1) This script should be placed JUST BEFORE ▼ Main Process. # # □ Like this: # ▼ Materials # ... # ... # * Battle Retry # ▼ Main Process # Main # # 2) Setup this script in Setup Part below. # #-------------------------------------------------------------- # ◦ How to use: #-------------------------------------------------------------- # □ Place this script and setup in the setup part. # #================================================================= # ALL ABOUT >>> THE CHECKPOINT SYSTEM #================================================================= =begin Checkpoints are areas a player can decide to return to by selecting the 'Return to Last Checkpoint' option in the game over screen. Checkpoints can be handled by events. You will need to set the variable you chose for "LASTCHECKPOINT_VAR" to the map ID the player is currently on, "CHECKX" to the current X, "CHECKY" to the current Y. For example, if you have 'save points' you would set so each time they use the savepoint, the variable for "LASTCHECKPOINT_VAR" to the current MAP ID. Then the variable for "CHECKX" to the player's current X position, and "CHECKY", to the player's current Y position. Then next time they "GAME OVER", if they select the "RETURN TO LAST CHECKPOINT" option, they will be transferred to that save point. =end # #================================================================= class Scene_Gameover < Scene_Base
#================================================================= # ++ Setup Part #----------------------------------------------------------------- BATRETRY_SWITCH_ID = 998 # Enable Battle Retry if this switch ID is ON # Disable Battle Retry if this switch ID is OFF #Retry Battle # Return to Last Checkpoint #Return to Title Screen BATRETRY_COMMANDS = ['Retry Battle', 'Return to Last Checkpoint', 'Return to Title Screen'] # Text on command window asking for Battle Retry # E.g. ['Go back to battle', 'Exit to title screen']
BATRETRY_RECORD_PARTY_STAT = false LASTCHECKPOINT_VAR = 101 # Variable that keeps track of the map ID that you transfer to when # selecting the 'Return to Last Checkpoint' option. CHECKX = 102 # The ID of the variable that decides the X location to transfer to on that # specific map. CHECKY = 103 # The ID of the variable that decides the Y location to transfer to on that # specific map.
# Record party members' HP/MP/status before going to battle? (true/false) # # - If this set to true, if Ralph has HP 30 before battle and got poisoned. # When player retry the battle, Ralph will still has HP 30 and poisoned. # # - If this set to false, all the members will get full HP/MP and no bad status # after retry the battle. #=================================================================
alias wora_batretry_scego_pertran perform_transition alias wora_batretry_scego_term terminate alias wora_batretry_scego_upd update # QUICK DEFINE CLOSE COMMAND WINDOW def close_command_window @command_window.close begin @command_window.update Graphics.update end until @command_window.openness == 0 end def play_remembered_bgm if $game_system.remembered_bgm != nil $game_system.remembered_bgm.play end end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update(*args) if $game_temp.battle_retry? super @command_window.update if Input.trigger?(Input::C) case @command_window.index when 0 # Battle Retry # If recorded party stat, load recorded data RPG::ME.stop $game_system.remembered_bgm.play unless $game_temp.last_troop_actor.nil? $game_temp.last_troop_actor.each_key do |id| data = $game_temp.last_troop_actor[id] $game_actors[id].hp = data[0] $game_actors[id].mp = data[1] $game_actors[id].real_states = data[2] end else # If not, recover party members $game_party.members.each {|actor| actor.recover_all } end # Setup battle last_troop = $game_temp.last_troop_id $game_troop.setup(last_troop[0]) $game_troop.can_escape = last_troop[1] $game_troop.can_lose = false $game_temp.next_scene = "battle" $scene = Scene_Battle.new
when 1 # Return to last checkpoint Sound.play_decision RPG::ME.stop $game_map.setup($game_variables[LASTCHECKPOINT_VAR]) $game_player.moveto($game_variables[CHECKX], $game_variables[CHECKY]) $game_player.refresh $scene = Scene_Map.new RPG::BGM.fade(1500) close_command_window Graphics.fadeout(60) Graphics.wait(40) Graphics.frame_count = 0 RPG::BGM.stop $game_map.autoplay when 2 # Go to Title Screen $scene = Scene_Title.new Graphics.fadeout(120) end end else # Normal Gameover scene wora_batretry_scego_upd(*args) end end #-------------------------------------------------------------------------- # * Execute Transition #-------------------------------------------------------------------------- def perform_transition(*args) if $game_temp.battle_retry? # Add command window if need battle retry @command_window = Window_Command.new(BATRETRY_WINDOW_WIDTH, BATRETRY_COMMANDS) # Show battle retry window in the middle @command_window.x = (Graphics.width - @command_window.width) / 2 @command_window.y = BATRETRY_WINDOW_Y @command_window.openness = 0 @command_window.open # Perform transition wora_batretry_scego_pertran(*args) # Open command window until @command_window.openness == 255 @command_window.update Graphics.update end @command_window.active = true else # Normal Gameover scene wora_batretry_scego_pertran(*args) end end #-------------------------------------------------------------------------- # * Termination Processing #-------------------------------------------------------------------------- def terminate(*args) @command_window.dispose unless @command_window.nil? wora_batretry_scego_term(*args) end end
class Scene_Battle < Scene_Base alias wora_batretry_scebat_batend battle_end #-------------------------------------------------------------------------- # * End Battle #-------------------------------------------------------------------------- def battle_end(*args) unless (args[0] == 2 and !$game_troop.can_lose) # Remove last troop data if won battle $game_temp.last_troop_id = nil $game_temp.last_troop_actor = nil end wora_batretry_scebat_batend(*args) end
end
class Game_Temp #-------------------------------------------------------------------------- # * Public Instance Variables #-------------------------------------------------------------------------- attr_accessor :last_troop_id, :last_troop_actor
#-------------------------------------------------------------------------- # * Check if battle can be retry #-------------------------------------------------------------------------- def battle_retry? return ($game_switches[Scene_Gameover::BATRETRY_SWITCH_ID] and !@last_troop_id.nil?) end end
class Game_Interpreter alias wora_batretry_gamint_com301 command_301 #-------------------------------------------------------------------------- # * Battle Processing #-------------------------------------------------------------------------- def command_301(*args) # If enable to record party stat before battle.. if Scene_Gameover::BATRETRY_RECORD_PARTY_STAT $game_temp.last_troop_actor = {} $game_party.members.each do |actor| $game_temp.last_troop_actor[actor.id] = [actor.hp, actor.mp, actor.real_states] end end # Store last troop ID in Game_System troop_id = @params[0] == 0 ? @params[1] : $game_variables[@params[1]] $game_temp.last_troop_id = [troop_id, @params[2]] unless $game_temp.in_battle wora_batretry_gamint_com301(*args) end end
class Game_Battler #-------------------------------------------------------------------------- # * Return real states #-------------------------------------------------------------------------- def real_states return @states.clone end
#-------------------------------------------------------------------------- # * Set states with states ID array #-------------------------------------------------------------------------- def real_states=(states_id_array) @states = states_id_array end end
class Game_System #============================================================================== # ** Game_System #------------------------------------------------------------------------------ # This class handles system-related data. Also manages vehicles and BGM, etc. # The instance of this class is referenced by $game_system. #==============================================================================
class Game_System #-------------------------------------------------------------------------- # * Public Instance Variables #-------------------------------------------------------------------------- attr_accessor :timer # timer attr_accessor :timer_working # timer working flag attr_accessor :save_disabled # save forbidden attr_accessor :menu_disabled # menu forbidden attr_accessor :encounter_disabled # encounter forbidden attr_accessor :save_count # save count attr_accessor :version_id # game version ID #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize @timer = 0 @timer_working = false @save_disabled = false @menu_disabled = false @encounter_disabled = false @save_count = 0 @version_id = 0 end #-------------------------------------------------------------------------- # * Get Battle BGM #-------------------------------------------------------------------------- def battle_bgm if @battle_bgm == nil return $data_system.battle_bgm else return @battle_bgm end end #-------------------------------------------------------------------------- # * Set Battle BGM # battle_bgm : new battle BGM #-------------------------------------------------------------------------- def battle_bgm=(battle_bgm) @battle_bgm = battle_bgm end #-------------------------------------------------------------------------- # * Get Battle End ME #-------------------------------------------------------------------------- def battle_end_me if @battle_end_me == nil return $data_system.battle_end_me else return @battle_end_me end end #-------------------------------------------------------------------------- # * Set Battle End ME # battle_end_me : new battle end ME #-------------------------------------------------------------------------- def battle_end_me=(battle_end_me) @battle_end_me = battle_end_me end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update if @timer_working and @timer > 0 @timer -= 1 if @timer == 0 and $game_temp.in_battle # If the timer 0 in battle $game_temp.next_scene = "map" # interrupt the battle end end end end def play_remembered_bgm if $game_system.remembered_bgm != nil $game_system.remembered_bgm.play end end end
So, umm... yeah. If this doesn't work, I don't know if I can help or not, knowing I am a novice. *Waits for a hero/scripter to help*
__________________________
Darkness Tales! That is my current project.[hide] The sig link is dead. Please do not touch it until further notice. I support: