Hello, I'm currently trying to implement a system into my battles for VX Ace that makes actors perform their actions as soon as the player selects them, instead of choosing all of the actors moves and then they perform them at once. This script seems to mostly do that, but I am struggling to understand how its settings work, for example I don't know what ticks are, nor why there are 32 clock-ticks per turn and 3 actions a turn.
Basically, I want to edit the script settings so that in battle every actor and enemy only has 1 move a turn no matter what action they perform, as normally my actor can move several times before my enemy can attack. I also encountered a problem where one of the enemies placed a state on my actor that was meant to stop them from moving for a turn, but instead prevented them from seemingly moving at all, allowing the enemy to just keep beating on them until they died and it was game over.
I'll post the raw script here so it's easily accessible for anyone that wants to help.
If anyone needs anymore information, please don't hesitate to ask and I will provide you with anything I can.
Basically, I want to edit the script settings so that in battle every actor and enemy only has 1 move a turn no matter what action they perform, as normally my actor can move several times before my enemy can attack. I also encountered a problem where one of the enemies placed a state on my actor that was meant to stop them from moving for a turn, but instead prevented them from seemingly moving at all, allowing the enemy to just keep beating on them until they died and it was game over.
I'll post the raw script here so it's easily accessible for anyone that wants to help.
Code:
#==============================================================================
#
# ▼ Yami Engine Symphony - Battle Mechanism
# -- Type: Charge Turn Battle
# -- Last Updated: 2012.11.01
# -- Level: Normal
# -- Requires: n/a
#
#==============================================================================
$imported = {} if $imported.nil?
$imported["YES-BattleCTB"] = true
#==============================================================================
# ▼ Updates
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 2012.11.01 - Bugfix for Instant-abusing.
# 2012.07.30 - Bugfix for Large Party.
# 2012.07.04 - Finished Script.
# 2012.06.22 - Started Script.
#
#==============================================================================
# ▼ Introduction
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script provides battle mechanism Charge Turn Battle (CTB). CTB is a
# version of ATB, which we don't have to wait time to fill up ATB Gauge.
#
#==============================================================================
# ▼ Instructions
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# To install this script, open up your script editor and copy/paste this script
# to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
#
# To change Battle Mechanism to CTB, use have to change DEFAULT_BATTLE_TYPE
# in Battle Control to :ctb or use script call ingame:
# BattleControl.change_btype(:ctb)
#
#==============================================================================
# ▼ Compatibility
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
# it will run with RPG Maker VX without adjusting.
# This script may not be compatible with other battle scripts. It is highly
# recommended putting this script above all other battle scripts, except YEA -
# Ace Battle Engine and other scripts that Author recommends putting above this.
#
#==============================================================================
module YES
module CTB
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# - Mechanism Settings -
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# These settings are adjusted for the threshold mechanism which related
# to battlers' actions and turn counting.
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
THRESHOLD_SETTINGS = { # Start.
:dynamic => true, # Enable Dynamic Threshold.
:offset => 400, # Default Threshold.
# End here if :dynamic is set to false.
:agi_multiplier => 4, # Add multiply of Agility to Threshold.
} # End.
TURN_SETTING = { # Start.
:type => :tick, # :tick for clockticks turn counting.
# :action for actions turn counting.
# Manage turn length.
:turn_ctr => 32, # Clockticks per turn.
:turn_action => 3, # Actions per turn.
# Common Events Options.
:end_turn => 12, # Common Event run when Turn End.
:end_action => 13, # Common Event run when End Action.
} # End.
START_SETTING = { # Start.
:preemptive => 0.5, # Clockticks filled if preemptive.
:surprise => 0.0, # Clockticks filled if surprise.
:normal => 0.2, # Clockticks filled normal.
} # End.
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# - Skills Settings -
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# These settings are adjusted for the skills which related to Agility and
# Turn Counting.
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
SKILLS_SETTING = { # Start.
:max_speed_fix => 100, # Max Speed fix for Skills.
:min_speed_fix => -100, # Min Speed fix for Skills.
:limit_instant => 3, # After X instant actions, Clockticks of
# that battler will be reset.
} # End.
end
end
#==============================================================================
# ▼ Editting anything past this point may potentially result in causing
# computer damage, incontinence, explosion of user's head, coma, death, and/or
# halitosis so edit at your own risk.
#==============================================================================
#==============================================================================
# ■ BattleControl
#==============================================================================
module BattleControl
#--------------------------------------------------------------------------
# CTB Clockticks
#--------------------------------------------------------------------------
@ctb_ct = Hash.new()
@ctb_limit_instant = Hash.new()
@ctb_temp_ct = Hash.new()
#--------------------------------------------------------------------------
# alias method: setup_battle
#--------------------------------------------------------------------------
class <<self; alias ctb_setup_battle setup_battle; end
def self.setup_battle
ctb_setup_battle
setup_ctb if battle_type == :ctb
end
#--------------------------------------------------------------------------
# alias method: turn_end?
#--------------------------------------------------------------------------
class <<self; alias ctb_turn_end? turn_end?; end
def self.turn_end?
return ctb_turn_end? unless battle_type == :ctb
return turn_end_ctb? if battle_type == :ctb
end
#--------------------------------------------------------------------------
# alias method: turn_end
#--------------------------------------------------------------------------
class <<self; alias ctb_turn_end turn_end; end
def self.turn_end
ctb_turn_end unless battle_type == :ctb
turn_end_ctb if battle_type == :ctb
end
#--------------------------------------------------------------------------
# new method: turn_end_ctb?
#--------------------------------------------------------------------------
def self.turn_end_ctb?
case YES::CTB::TURN_SETTING[:type]
when :tick
@counting >= YES::CTB::TURN_SETTING[:turn_ctr]
when :action
@counting >= YES::CTB::TURN_SETTING[:turn_action]
end
end
#--------------------------------------------------------------------------
# new method: turn_end_ctb?
#--------------------------------------------------------------------------
def self.turn_end_ctb
case YES::CTB::TURN_SETTING[:type]
when :tick
@counting -= YES::CTB::TURN_SETTING[:turn_ctr]
when :action
@counting -= YES::CTB::TURN_SETTING[:turn_action]
end
#---
common_event_id = YES::CTB::TURN_SETTING[:end_turn]
return if $data_common_events[common_event_id].nil?
$game_temp.reserve_common_event(common_event_id)
end
#--------------------------------------------------------------------------
# new method: setup_ctb
#--------------------------------------------------------------------------
def self.setup_ctb
@ctb_ct.clear
@ctb_temp_ct.clear
@ctb_limit_instant.clear
#---
@threshold = 0
@counting = 0
#---
ctb_init_threshold
ctb_init_ct
end
#--------------------------------------------------------------------------
# new method: ctb_init_threshold
#--------------------------------------------------------------------------
def self.ctb_init_threshold
@threshold = YES::CTB::THRESHOLD_SETTINGS[:offset]
return unless YES::CTB::THRESHOLD_SETTINGS[:dynamic]
rate = YES::CTB::THRESHOLD_SETTINGS[:agi_multiplier]
@battlers.each { |battler| @threshold += battler.agi * rate }
end
#--------------------------------------------------------------------------
# new method: ctb_init_ct
#--------------------------------------------------------------------------
def self.ctb_init_ct
@battlers.each { |battler|
rate = YES::CTB::START_SETTING[:normal]
case BattleManager.encounter_flag
when 1
rate = YES::CTB::START_SETTING[:preemptive] if battler.actor?
when 2
rate = YES::CTB::START_SETTING[:surprise] if battler.actor?
end
@ctb_ct[battler.name] = rate * @threshold
}
end
#--------------------------------------------------------------------------
# new method: ctb_temp_evaluate
#--------------------------------------------------------------------------
def self.ctb_temp_evaluate(battler, skill)
@ctb_temp_ct[battler.name] = ctb_evaluate_ct(battler, skill)
end
#--------------------------------------------------------------------------
# new method: ctb_clear_temp
#--------------------------------------------------------------------------
def self.ctb_clear_temp(battler)
@ctb_temp_ct.delete(battler.name)
end
#--------------------------------------------------------------------------
# new method: ctb_check_temp
#--------------------------------------------------------------------------
def self.ctb_check_temp(battler, check)
return @ctb_temp_ct[battler.name] == check
end
#--------------------------------------------------------------------------
# new method: ctb_evaluate_ct
#--------------------------------------------------------------------------
def self.ctb_evaluate_ct(battler, skill)
return @threshold if skill.nil?
limit = YES::CTB::SKILLS_SETTING[:limit_instant]
count_limit = @ctb_limit_instant[battler.name]
return @threshold if !count_limit.nil? && count_limit >= limit
evaluate = @threshold
max = YES::CTB::SKILLS_SETTING[:max_speed_fix]
min = YES::CTB::SKILLS_SETTING[:min_speed_fix]
rate = skill.speed >= 0 ? [skill.speed, max].min : [skill.speed, min].max
rate = 100 - rate
evaluate = evaluate * rate.to_f / 100
evaluate.round
end
#--------------------------------------------------------------------------
# new method: ctb_evaluate_action
#--------------------------------------------------------------------------
def self.ctb_evaluate_action(battler, skill)
evaluate = ctb_evaluate_ct(battler, skill)
#---
@ctb_limit_instant[battler.name] ||= 0
limit = YES::CTB::SKILLS_SETTING[:limit_instant]
if @ctb_limit_instant[battler.name] >= limit
evaluate = ctb_evaluate_ct(battler, nil)
@ctb_limit_instant[battler.name] = 0
end
if evaluate <= 0
@ctb_limit_instant[battler.name] += 1
else
# Fix Instant-abuse
#@ctb_limit_instant[battler.name] = 0
end
#---
@ctb_ct[battler.name] -= evaluate
#---
ctb_clear_temp(battler)
if YES::CTB::TURN_SETTING[:type] == :action; @counting += 1; end
#---
common_event_id = YES::CTB::TURN_SETTING[:end_action]
return if $data_common_events[common_event_id].nil?
$game_temp.reserve_common_event(common_event_id)
end
#--------------------------------------------------------------------------
# new method: ctb_add_ct
#--------------------------------------------------------------------------
def self.ctb_add_ct
while ctb_active_battlers.size == 0
@battlers.each { |battler|
next unless battler.movable?
@ctb_ct[battler.name] ||= 0
@ctb_ct[battler.name] += battler.agi
}
if YES::CTB::TURN_SETTING[:type] == :tick; @counting += 1; end
end
end
#--------------------------------------------------------------------------
# new method: ctb_active_battlers
#--------------------------------------------------------------------------
def self.ctb_active_battlers
result = []
@battlers.each { |battler|
next unless battler.movable?
result.push(battler) if @ctb_ct[battler.name] >= @threshold
}
result.sort! { |a, b|
if @ctb_ct[b.name] != @ctb_ct[a.name]
@ctb_ct[b.name] <=> @ctb_ct[a.name]
else
a.screen_x <=> b.screen_x
end
}
end
#--------------------------------------------------------------------------
# new method: counting
#--------------------------------------------------------------------------
def self.counting
@counting
end
#--------------------------------------------------------------------------
# new method: ctb_fix_ct
#--------------------------------------------------------------------------
def self.ctb_fix_ct
($game_party.battle_members + $game_troop.members).each { |battler|
@ctb_ct[battler.name] ||= 0 }
end
#--------------------------------------------------------------------------
# new method: ctb_reset_limit
#--------------------------------------------------------------------------
def self.ctb_reset_limit(battler)
@ctb_limit_instant[battler.name] = 0
end
end # BattleControl
#==============================================================================
# ■ BattleManager
#==============================================================================
module BattleManager
#--------------------------------------------------------------------------
# alias method: turn_start
#--------------------------------------------------------------------------
class <<self; alias ctb_turn_start turn_start; end
def self.turn_start
ctb_turn_start unless BattleControl.battle_type == :ctb
turn_start_ctb if BattleControl.battle_type == :ctb
end
#--------------------------------------------------------------------------
# alias method: turn_end
#--------------------------------------------------------------------------
class <<self; alias ctb_turn_end turn_end; end
def self.turn_end
ctb_turn_end unless BattleControl.battle_type == :ctb
turn_end_ctb if BattleControl.battle_type == :ctb
end
#--------------------------------------------------------------------------
# alias method: on_encounter
#--------------------------------------------------------------------------
class <<self; alias ctb_on_encounter on_encounter; end
def self.on_encounter
ctb_on_encounter
BattleControl.ctb_init_ct if BattleControl.battle_type == :ctb
end
#--------------------------------------------------------------------------
# new method: turn_start_ctb
#--------------------------------------------------------------------------
def self.turn_start_ctb
@phase = :turn
clear_actor
end
#--------------------------------------------------------------------------
# new method: turn_end_ctb
#--------------------------------------------------------------------------
def self.turn_end_ctb
@phase = :turn_end
@preemptive = false
@surprise = false
$game_troop.increase_turn
end
end # BattleManager
#==============================================================================
# ■ Game_Actor
#==============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# alias method: input
#--------------------------------------------------------------------------
alias ctb_input input
def input
if BattleControl.battle_type == :ctb
if @actions[@action_input_index] == nil
@actions[@action_input_index] = Game_Action.new(self)
end
end
return ctb_input
end
end # Game_Actor
#==============================================================================
# ■ Window_ActorCommand
#==============================================================================
class Window_ActorCommand < Window_Command
#--------------------------------------------------------------------------
# alias method: process_dir6
#--------------------------------------------------------------------------
if $imported["YEA-BattleEngine"]
alias ctb_process_dir6 process_dir6
def process_dir6
return if BattleControl.battle_type == :ctb
ctb_process_dir6
end
end
end # Window_ActorCommand
#==============================================================================
# ■ Scene_Battle
#==============================================================================
class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# alias method: create_all_windows
#--------------------------------------------------------------------------
alias ctb_create_all_windows create_all_windows
def create_all_windows
create_ctb_order_gauge if $imported["YES-CTBOrderGauge"]
create_ctb_debug if $imported["YES-CTBDebug"]
ctb_create_all_windows
end
#--------------------------------------------------------------------------
# new method: create_ctb_order_gauge
#--------------------------------------------------------------------------
def create_ctb_order_gauge
return unless BattleControl.battle_type == :ctb
@ctb_order_gauge = Window_OrderCTB.new
end
#--------------------------------------------------------------------------
# new method: create_ctb_debug
#--------------------------------------------------------------------------
def create_ctb_debug
return unless BattleControl.battle_type == :ctb
return unless $TEST
@ctb_debug_window = Window_CTBDebug.new()
end
#--------------------------------------------------------------------------
# alias method: process_condition
#--------------------------------------------------------------------------
alias ctb_process_condition process_condition
def process_condition
return ctb_process_condition unless BattleControl.battle_type == :ctb
return process_condition_ctb if BattleControl.battle_type == :ctb
end
#--------------------------------------------------------------------------
# alias method: process_in_turn
#--------------------------------------------------------------------------
alias ctb_process_in_turn process_in_turn
def process_in_turn
ctb_process_in_turn unless BattleControl.battle_type == :ctb
process_in_turn_ctb if BattleControl.battle_type == :ctb
end
#--------------------------------------------------------------------------
# alias method: update_info_viewport
#--------------------------------------------------------------------------
alias ctb_update_info_viewport update_info_viewport
def update_info_viewport
ctb_update_info_viewport unless BattleControl.battle_type == :ctb
update_info_viewport_ctb if BattleControl.battle_type == :ctb
end
#--------------------------------------------------------------------------
# alias method: next_command
#--------------------------------------------------------------------------
alias ctb_next_command next_command
def next_command
ctb_next_command unless BattleControl.battle_type == :ctb
next_command_ctb if BattleControl.battle_type == :ctb
end
#--------------------------------------------------------------------------
# alias method: prior_command
#--------------------------------------------------------------------------
alias ctb_prior_command prior_command
def prior_command
ctb_prior_command unless BattleControl.battle_type == :ctb
prior_command_ctb if BattleControl.battle_type == :ctb
end
#--------------------------------------------------------------------------
# alias method: command_fight
#--------------------------------------------------------------------------
alias ctb_command_fight command_fight
def command_fight
ctb_command_fight unless BattleControl.battle_type == :ctb
command_fight_ctb if BattleControl.battle_type == :ctb
end
#--------------------------------------------------------------------------
# alias method: execute_action
#--------------------------------------------------------------------------
alias ctb_execute_action execute_action
def execute_action
BattleControl.ctb_evaluate_action(@subject, @subject.current_action.item) if BattleControl.battle_type == :ctb
ctb_execute_action
end
#--------------------------------------------------------------------------
# alias method: command_escape
#--------------------------------------------------------------------------
alias ctb_command_escape command_escape
def command_escape
ctb_command_escape unless BattleControl.battle_type == :ctb
command_escape_ctb if BattleControl.battle_type == :ctb
end
#--------------------------------------------------------------------------
# new method: process_condition_ctb
#--------------------------------------------------------------------------
def process_condition_ctb
inputting = @actor_command_window.active || @skill_window.active ||
@item_window.active || @actor_window.active || @enemy_window.active
inputting = inputting || @summon_window.active if $imported["YES-GuardianSummon"]
return !inputting
end
#--------------------------------------------------------------------------
# new method: process_in_turn_ctb
#--------------------------------------------------------------------------
def process_in_turn_ctb
BattleControl.filter_battlers
if @status_window.close?
@status_window.open
end
@actor_command_window.close
@status_window.unselect
return if @subject
BattleControl.ctb_add_ct
#---
battler = BattleControl.ctb_active_battlers[0]
battler.make_actions
#--- Fix Instant-abuse ---
if battler != @subject && @subject
BattleControl.ctb_reset_limit(@subject)
end
#---
@subject = battler
#---
BattleControl.ctb_temp_evaluate(battler, nil)
@ctb_order_gauge.refresh if $imported["YES-CTBOrderGauge"]
#@ctb_debug_window.refresh if $imported["YES-CTBDebug"]
#---
if @subject.inputable? and battler.is_a?(Game_Actor)
@actor_command_window.setup(@subject)
BattleManager.set_actor(battler)
@status_window.select(BattleManager.actor.index)
end
end
#--------------------------------------------------------------------------
# new method: update_info_viewport_ctb
#--------------------------------------------------------------------------
def update_info_viewport_ctb
move_info_viewport(0) if @party_command_window.active
move_info_viewport(128) if @actor_command_window.active
move_info_viewport(64) if BattleManager.in_turn? && process_condition
end
#--------------------------------------------------------------------------
# new method: next_command_ctb
#--------------------------------------------------------------------------
def next_command_ctb
@status_window.show
@actor_command_window.show
@status_aid_window.hide if $imported["YEA-BattleEngine"]
end
#--------------------------------------------------------------------------
# new method: prior_command_ctb
#--------------------------------------------------------------------------
def prior_command_ctb
$imported["YEA-BattleEngine"] ? redraw_current_status : @status_window.refresh
start_party_command_selection
end
#--------------------------------------------------------------------------
# new method: command_fight_ctb
#--------------------------------------------------------------------------
def command_fight_ctb
turn_start
end
#--------------------------------------------------------------------------
# new method: command_escape_ctb
#--------------------------------------------------------------------------
def command_escape_ctb
unless BattleManager.process_escape
BattleControl.ctb_evaluate_action(@subject, nil)
turn_start
end
end
#--------------------------------------------------------------------------
# alias method: turn_end
#--------------------------------------------------------------------------
alias ctb_turn_end turn_end
def turn_end
ctb_turn_end
return unless BattleControl.battle_type == :ctb
@party_command_window.deactivate
end
end # Scene_Battle
#==============================================================================
#
# ▼ End of File
#
#==============================================================================