What about this revised version of the script?
Code:
#===============================================================
# ● [VX] ◦ Battle Retry ◦ □
# * Enable player to retry the battle after losing *
# ** Note: Read the setup part before using this script **
#--------------------------------------------------------------
# ◦ by Woratana [[email hidden]]
# ◦ Thaiware RPG Maker Community
# * Modified by Kyonides Arkanthes
# ◦ Released on: 19/08/2021
# ◦ Version: 1.1
#--------------------------------------------------------------
# ◦ Update:
#--------------------------------------------------------------
# □ Version 1.1 (19/08/2021)
# - Created the BattleRetry module
# - Added enemy's first move before the start of first turn - Retry Mode Only!
#
# □ 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 alias 5 method(s):
# Scene_Gameover#perform_transition
# Scene_Gameover#terminate
# Scene_Gameover#update
# Scene_Battle#process_battle_start
# 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.
# □ Set a troop's battle condition to the FIRST_MOVE_SWITCH_ID switch
#=================================================================
# * Setup * #
module BattleRetry
ACTIVATION_SUCCESS_RATE = 100 # 0% through 100%
ENABLE_SWITCH_ID = 70 # Enable Battle Retry only if this switch ID is ON
FIRST_MOVE_SWITCH_ID = 71
# Use this switch as troop battle condition to allow enemies to hit you at the
# very beginning of the battle, even before you can even see your stats!
COMMANDS = ['Retry!', 'Give Up...']
# Text on command window asking for Battle Retry
# E.g. ['Go back to battle', 'Exit to title screen']
WINDOW_Y = 288 # Command window's Y-coordinate (Top: 0, Bottom: 416)
WINDOW_WIDTH = 200 # Command windows' width
RECORD_PARTY_STAT = true
# 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.
#
# * End of Setup * #
def self.active?
$game_switches[FIRST_MOVE_SWITCH_ID] and rand(100) < ACTIVATION_SUCCESS_RATE
end
end
class Scene_Gameover < Scene_Base
alias wora_batretry_scego_pertran perform_transition
alias wora_batretry_scego_term terminate
alias wora_batretry_scego_upd update
def update(*args)
return wora_batretry_scego_upd(*args) unless $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
unless $game_temp.last_troop_actor.nil?
actors = $game_temp.last_troop_actor
actors.each_key do |id|
data = actors[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
$game_switches[BattleRetry::FIRST_MOVE_SWITCH_ID] = true
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 # Go to Title Screen
RPG::BGM.fade(100)
$scene = Scene_Title.new
Graphics.fadeout(30)
end
end
end
def perform_transition(*args)
if $game_temp.battle_retry?
# Add command window if need battle retry
commands = BattleRetry::COMMANDS
@command_window = Window_Command.new(BattleRetry::WINDOW_WIDTH, commands)
# Show battle retry window in the middle
@command_window.x = (Graphics.width - @command_window.width) / 2
@command_window.y = BattleRetry::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
def terminate(*args)
@command_window.dispose unless @command_window.nil?
wora_batretry_scego_term(*args)
end
end
class Scene_Battle < Scene_Base
alias :kyon_batretry_scn_bat_pro_bat_st :process_battle_start
alias wora_batretry_scebat_batend battle_end
def process_battle_start
kyon_batretry_scn_bat_pro_bat_st
start_main if BattleRetry.active?
end
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
$game_switches[BattleRetry::FIRST_MOVE_SWITCH_ID] = false
end
wora_batretry_scebat_batend(*args)
end
end
class Game_Temp
attr_accessor :last_troop_id, :last_troop_actor
def battle_retry?
($game_switches[BattleRetry::ENABLE_SWITCH_ID] and !@last_troop_id.nil?)
end
end
class Game_Interpreter
alias wora_batretry_gamint_com301 command_301
def command_301(*args)
# If enable to record party stat before battle..
if BattleRetry::RECORD_PARTY_STAT
$game_temp.last_troop_actor = {}
$game_party.members.each do |a|
$game_temp.last_troop_actor[a.id] = [a.hp, a.mp, a.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]] if !$game_temp.in_battle
wora_batretry_gamint_com301(*args)
end
end
class Game_Battler
def real_states() @states.clone end
def real_states=(states_id_array) @states = states_id_array end
end
Unfortunately it didn't work.
I'm not sure how the First_Move_Switch was meant to be used, but I assume it would have made it so that the enemy would've immediently attacked me with something random.
I went ahead and made a little Project with all my scripts so that the process goes by quicker:
▶ Google Drive file
In there you can fight a boss and just get beaten. I set up all the necessary switches for the retry script as well. The script itself is also located all the way at the bottom in the editor. (And I assume you have the VX RTP installed)
My goal is to have these little icons show up right after you retry battle:
They are the clear indicator that will show you that the turn thing has been fixed.
As it stands, they only appear after a single action (from enemy or ally) and I want them to show up immediently after pressing retry battle.