Skip to content

Instantly share code, notes, and snippets.

@suppayami

suppayami/fixed_ctb.rb Secret

Last active Aug 29, 2015
Embed
What would you like to do?
module BattleManager
def self.make_action_orders
@turn_end_tick ||= 0
all = $game_party.battle_members + $game_troop.members
all.each do |battler|
battler.ctb_ticks -= global_ticks * (1.0 - battler.ctb_speed)
battler.ctb_speed = 1.0
end
@action_battlers ||= []
return if @action_battlers.size > 0
until @action_battlers.size >= 1
add_tick = 0
all.each do |battler|
add_tick = [add_tick, battler.agi].max
battler.ctb_ticks += battler.agi
if battler.ctb_ticks >= global_ticks
if battler.movable?
@action_battlers.push(battler)
else
battler.on_action_end
end
end
end
@turn_end_tick += add_tick
end
@action_battlers.sort! { |a,b| b.ctb_ticks - a.ctb_ticks }
@action_battlers.each { |a| a.ctb_ticks -= global_ticks }
end
def self.ctb_turn_end?
all = $game_party.battle_members + $game_troop.members
flag = @turn_end_tick >= global_ticks * all.size
@turn_end_tick -= global_ticks * all.size if flag
flag
end
def self.next_subject
loop do
battler = @action_battlers.shift
return nil unless battler
next unless battler.index && battler.alive?
unless battler.movable?
battler.on_action_end
next
end
return battler
end
end
end
class Game_Temp
attr_accessor(:forcing)
end
class Game_Battler < Game_BattlerBase
#--------------------------------------------------------------------------
# * Processing at Start of Action
#--------------------------------------------------------------------------
def on_action_begin
# Do nothing
end
end
class Scene_Battle < Scene_Base
def process_action
BattleManager.make_action_orders
return if scene_changing? || !BattleManager.actor.nil?
if !@subject || !@subject.current_action
@subject = BattleManager.next_subject
@subject.on_action_begin if @subject
@order_window.refresh
@status_window.refresh
end
if @subject.is_a?(Game_Actor) and !@subject.current_action
next_command
return
elsif @subject.is_a?(Game_Enemy)
@subject.make_actions
elsif @subject.nil?
refresh_status
BattleManager.judge_win_loss
($game_party.battle_members + $game_troop.members).each do |battler|
next if !battler.movable? ||battler.nil?
battler.result.clear
end
return
end
if @subject.current_action
if $imported["YEL-BattleLuna"]
@actor_command_window.close if @actor_command_window.open?
end
@subject.current_action.prepare
if @subject.current_action.valid?
@status_window.open
execute_action
end
@subject.make_speed
@subject.remove_current_action
end
process_action_end unless @subject.current_action
while BattleManager.ctb_turn_end?
$game_troop.increase_turn
all_battle_members.each do |battler|
battler.on_turn_end
refresh_status
@log_window.display_auto_affected_status(battler)
@log_window.wait_and_clear
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.