So I've come across what I believe to be the biggest logic disaster in this thing and that's with the main frame update.
I have two frame updates here, one that is aliased within the ATB script, and one that is utilized by my battle system (it's actually the RMXP default)
What jumped out at me is the ATB alias calls the original method in the middle of the script. How exactly does that work? Does it run the original method, then return back to the aliased method?
If that's the case, I see some conflicts with the phase processing, because if the update_phase# is called by the main update method before the aliased one, then the aliased one will not continue, correct?
Any thoughts on how I would restructure this to be compatible? Would I just call the original method at the end of the aliased one?
Main frame update:
#---------------------------------------------------------------------------
# * Main battle frame update
#---------------------------------------------------------------------------
def update
# If battle event is running
if $game_system.battle_interpreter.running?
# Update interpreter
$game_system.battle_interpreter.update
# If a battler which is forcing actions doesn't exist
if $game_temp.forcing_battler == nil
# If battle event has finished running
unless $game_system.battle_interpreter.running?
# Rerun battle event set up if battle continues
unless judge
setup_battle_event
end
end
# If not after battle phase
if @phase != 5
# Refresh status window
@status_window.refresh
end
end
end
# Update system (timer) and screen
$game_system.update
$game_screen.update
# If timer has reached 0
if $game_system.timer_working and $game_system.timer == 0
# Abort battle
$game_temp.battle_abort = true
end
# Update windows
@help_window.update
@party_command_window.update
@actor_command_window.update
@active_battler_window.update
@status_window.update
@message_window.update
# Update sprite set
@spriteset.update
# If transition is processing
if $game_temp.transition_processing
# Clear transition processing flag
$game_temp.transition_processing = false
# Execute transition
if $game_temp.transition_name == ""
Graphics.transition(20)
else
Graphics.transition(40, "Graphics/Transitions/" +
$game_temp.transition_name)
end
end
# If message window is showing
if $game_temp.message_window_showing
return
end
# If effect is showing
if @spriteset.effect?
return
end
# If game over
if $game_temp.gameover
# Switch to game over screen
$scene = Scene_Gameover.new
return
end
# If returning to title screen
if $game_temp.to_title
# Switch to title screen
$scene = Scene_Title.new
return
end
# If battle is aborted
if $game_temp.battle_abort
# Return to BGM used before battle started
$game_system.bgm_play($game_temp.map_bgm)
# Battle ends
battle_end(1)
return
end
# If waiting
if @wait_count > 0
# Decrease wait count
@wait_count -= 1
return
end
# If battler forcing an action doesn't exist,
# and battle event is running
if $game_temp.forcing_battler == nil and
$game_system.battle_interpreter.running?
return
end
# Branch according to phase
case @phase
when 1 # pre-battle phase
update_phase1
when 2 # party command phase
update_phase2
when 3 # actor command phase
update_phase3
when 4 # main phase
update_phase4
when 5 # after battle phase
update_phase5
end
end
Aliased one:
Quote#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
alias acbs_update_atb update
def update
#Update the battle phases
if @phase == 1
$game_temp.battle_main_phase = true
@actor_command_window.opacity = 0
@phase = 0
elsif @phase != 5
@phase = 0
end
#Check if an event is running
@event_running = true if $game_system.battle_interpreter.running?
#Check for game over
return $scene = Scene_Gameover.new if $game_temp.gameover
#Call the original method
acbs_update_atb
#...Check if an event is running again??
if $game_system.battle_interpreter.running?
return
elsif @event_running
@status_window.refresh
@event_running = false
end
#Check if we're on the post-battle phase
return update_phase5 if @phase == 5
#??????EVENT RUNNING????????
@event_running = true if $game_system.battle_interpreter.running?
if @update_turn_end
turn_ending
@update_turn_end = false
end
#Update escape
if Input.press?(Escape_Input) and @escape_type > 0
if $game_temp.battle_can_escape
$game_temp.max_escape_count = update_phase2_escape_rate
$game_temp.escape_count += 2 unless @wait_on
@escaping = true
if !@help_window.visible and @escape_type == 1
@help_window.set_text('')
@help_window.set_text(Escape_Message, 1)
end
if @escape_type == 2
if @escape_atb_meters.nil?
@escape_atb_meters = Escape_Meters.new
@escape_meter_opacity = 0
@escape_atb_meters.visible = true
else @escape_atb_meters != nil
@escape_atb_meters.opacity = 15 * @escape_meter_opacity
@escape_meter_opacity = [@escape_meter_opacity + 1, 17].min
@escape_atb_meters.refresh
end
end
if $game_temp.escape_count >= $game_temp.max_escape_count
$game_temp.escape_count = 0
update_phase2_escape unless $game_party.all_dead?
end
else
@help_window.set_text(Cant_Escape_Message, 1) if @escape_type == 1
if @escape_type == 2
if @escape_atb_meters.nil?
@escape_atb_meters = Escape_Meters.new
@escape_meter_opacity = 0
@escape_atb_meters.visible = true
else @escape_atb_meters != nil
@escape_atb_meters.opacity = 15 * @escape_meter_opacity
@escape_meter_opacity = [@escape_meter_opacity + 1, 17].min
@escape_atb_meters.refresh
end
end
end
elsif @escape_type > 0
if @escaping
@escaping = false
@help_window.visible = false
end
$game_temp.escape_count = [$game_temp.escape_count - 1, 0].max unless @wait_on
if @escape_atb_meters != nil and $game_temp.escape_count == 0
@escape_atb_meters.opacity = 15 * @escape_meter_opacity
@escape_meter_opacity = [@escape_meter_opacity - 1, 0].max
if @escape_meter_opacity == 0
@escape_atb_meters.dispose
@escape_atb_meters = nil
end
end
@escape_atb_meters.refresh if @escape_atb_meters != nil
end
#Exit method if escape was successful
return if @escaped
#Perform the basic ATB update
atb_update
#Update the battler input
input_battler_update(false)
if @action_battlers[0] != nil && @action_battler.nil?
@action_battlers.flatten!
@action_battler = @action_battlers[0]
if @action_battler.dead?
@action_battler.atb = 0
@action_battler = nil
else
start_phase4
end
end
#Update the action battler
if @action_battler != nil && !@spriteset.effect?
@active_battler = @action_battler
update_phase4
end
end
Also, this aliased one looks like it's checking the interpreter like 10 times, can't quite understand why.
This is in reference the demo in my OP, if more context is needed.