by how the request is worded, I assume the author wants to stop *the processing* of the turn, not *the selection* of actions.
pre-select the actions, run the turn, and if and/or when a timer runs out, stop that turn mid-way.
that's what you can't do by default, because the processing of the turn runs in it's own loop and has no watch for the player's input.
I believe this request comes up from the fact that if the timer stops it won't alter the scene until a running turn has finished, OR, from the fact that battle-event-driven processes *tied* to that timer also won't happen mid-turn.
Code:
class Game_Timer
def on_expire
BattleManager.abort
end
end
module BattleManager
def self.abort
@phase = :aborting
end
def self.aborting?
@phase == :aborting
end
def self.judge_win_loss
if @phase
return process_abort if $game_party.members.empty?
return process_defeat if $game_party.all_dead?
return process_victory if $game_troop.all_dead?
return process_abort if aborting?
end
return false
end
end
class Scene_Battle
def update
super
if BattleManager.in_turn?
process_event
process_action
end
BattleManager.judge_win_loss
end
end
timer runs out, raises flag for abort, battle manager checks for abort through win/loss check, which happens right at the end of the process.
Code:
def process_action
return if scene_changing?
if !@subject || [email protected]_action
@subject = BattleManager.next_subject
end
return turn_end unless @subject
if @subject.current_action
@subject.current_action.prepare
if @subject.current_action.valid?
@status_window.open
execute_action
end
@subject.remove_current_action
end
process_action_end unless @subject.current_action
end
battler.clear_actions drops subject.current_action, since current_action is actions[0], and by dropping actions[] clean, current_action drops, which drops process_action, which drops the turn, which drops the whole loop.
(hopefully without dropping the whole game in the process
😀 )