Battle Retry
Publicado em 8 de novembro de 2011.Battle Retry é um script para o RPG Maker XP que, ao ser instalado num projeto, ele dá a opção ao jogador de tentar a batalha em que morreu, na tela do Game Over.
O autor do código é o sandgolem, e para funcionar, basta inserir o projeto em cima do “Main”, na janela de scripts do RMXP.
#==========================================================================
# ** SG Battle Retry
#==========================================================================
# sandgolem
# Version 5
# 16.06.06
#==========================================================================
Scene_Battle::SG_CantRetryBattle = 0
#==========================================================================
#
# To check for updates or find more scripts, visit:
# http://www.gamebaker.com/rmxp/scripts/
#
# To use this script, copy it and insert it in a new section above "Main",
# but under the default scripts and the SDK if you're using it.
#
# Have problems? Official topic:
# http://forums.gamebaker.com/showthread.php?t=8
#
#==========================================================================
begin
SDK.log('SG Battle Retry', 'sandgolem', 5, '16.06.06')
if SDK.state('SG Battle Retry') != true
@sg_battleretry_disabled = true
end
rescue
end
if !@sg_battleretry_disabled
#--------------------------------------------------------------------------
class Interpreter
alias sandgolem_battleretry_interp_601 command_601
def command_601
if $sg_retrywon
@branch[@list[@index].indent] = 0
$sg_retrywon = nil
end
return sandgolem_battleretry_interp_601
end
alias sandgolem_battleretry_interp_602 command_602
def command_602
if $game_temp.battle_can_escape && $sg_retryescaped
@branch[@list[@index].indent] = 1
$sg_retryescaped = nil
end
return sandgolem_battleretry_interp_602
end
end
class Game_System
attr_accessor :playing_bgm
end
class Game_Temp
attr_accessor :battle_music_playing
end
class Scene_Map
alias sandgolem_bretry_map_callbattle call_battle
def call_battle
sandgolem_bretry_map_callbattle
$game_temp.battle_music_playing = $game_system.playing_bgm.clone
end
end
class Scene_Save < Scene_File
def sg_write_retrysave_data
file = File.open('Data/retry.sg', 'wb')
write_save_data(file)
file.close
end
end
class Scene_Load < Scene_File
def sg_read_retrysave_data
file = File.open('Data/retry.sg', 'rb')
read_save_data(file)
file.close
end
end
class Scene_Battle
alias sandgolem_battleretry_battle_main main
def main
$sg_retryescaped = nil
$sg_retrywon = nil
if $game_switches[SG_CantRetryBattle] == 0 or
!$game_switches[SG_CantRetryBattle]
if !$sg_battleretry_inbattle && !$game_temp.battle_can_lose
$sg_battleretry_inbattle = $game_temp
sg_scene_save_temp = Scene_Save.new
sg_scene_save_temp.sg_write_retrysave_data
sg_scene_save_temp = nil
end
end
sandgolem_battleretry_battle_main
if !$scene.is_a?(Scene_Gameover)
if FileTest.exist?('Data/retry.sg')
File.delete('Data/retry.sg')
end
$sg_battleretry_inbattle = nil
end
end
alias sandgolem_battleretry_battle_batend battle_end
def battle_end(result)
case result
when 0
$sg_retrywon = true
when 1
$sg_retryescaped = true
end
sandgolem_battleretry_battle_batend(result)
end
end
class Scene_Gameover
alias sandgolem_battleretry_gameover_main main
def main
if $sg_battleretry_inbattle
@sprite = Sprite.new
@sprite.bitmap = RPG::Cache.gameover($data_system.gameover_name)
$game_system.bgm_stop
$game_system.me_play($data_system.gameover_me)
Graphics.transition(90)
@command_window = Window_Command.new(192,['Retry Battle','Title Screen'])
@command_window.back_opacity = 160
@command_window.x = 320 - @command_window.width / 2
@command_window.y = 288
loop do
Graphics.update
Input.update
sg_retry_update
if $scene != self
break
end
end
@command_window.dispose
Graphics.freeze
@sprite.bitmap.dispose
@sprite.dispose
Graphics.transition(30)
Graphics.freeze
else
sandgolem_battleretry_gameover_main
end
end
def sg_retry_update
@command_window.update
if Input.trigger?(Input::C)
case @command_window.index
when 0
sg_scene_save_temp = Scene_Load.new
sg_scene_save_temp.sg_read_retrysave_data
sg_scene_save_temp = nil
$game_temp = $sg_battleretry_inbattle
$game_temp.gameover = nil
$game_system.bgm_play($game_temp.battle_music_playing)
$scene = Scene_Battle.new
when 1
if FileTest.exist?('Data/retry.sg')
File.delete('Data/retry.sg')
end
$sg_battleretry_inbattle = nil
$scene = Scene_Title.new
end
end
end
end
#--------------------------------------------------------------------------
end
Informações adicionais
- Categoria: Programação XP
- Tags: Em revisão, RPG Maker XP
- Adicionado por: LichKing
- Acessos: 46
Link deste post:
Observação: se você gostou deste post ou ele lhe foi útil de alguma forma, por favor considere apoiar financeiramente a Gaming Room. Fico feliz só de ajudar, mas a contribuição do visitante é muito importante para que este site continua existindo e para que eu possa continuar provendo este tipo de conteúdo e melhorar cada vez mais. Acesse aqui e saiba como. Obrigado!
