#=============================================================================
# Active Time Battle v.2.58
# Script by ParaDog
#
http://2d6.parasite.jp/#------------------------------------------------------------------------------
# When the CT Gauge becomes filled, the battler which it controls will then be
# able to perform his/her battle action.
# The system can also adjust the positioning of the BattleStatus window which
# works well with Sideview System scripts.
#------------------------------------------------------------------------------
# INSTALLING:
# When using this system, it is recommended that this script be placed above
# all other 'Custom' scripts... directly below Scene_Debug if possible.
#------------------------------------------------------------------------------
# ESCAPE:
# While a battler's command window is active, pressing the [ESC] button will
# activate the 'Fight / Escape' window at the top of the screen. The more
# actors you have with full CT, the better your chances are of a successful
# escape, while fewer actors results in a lower chance to flee.
#
# NEXT/PREVIOUS BATTLER:
# When two or more actors can act, you can toggle between the actors with full
# CT gauges with the [R] button or the [PageDown] key, or in reverse order with
# the [L] button or the [PageUp] key.
#==============================================================================
module PARA_CTB
# CT gauge pauses while command window is open
COMMAND_WAIT = false
# CT gauge pauses when Skill and Item windows are open, and while targeting
SELECT_WAIT = false
# CT gauge pauses when battlers perform actions
ANIMATION_WAIT = true
# CT Gauge fill / Battle system speed
BATTLE_SPEED = 2
# Maximum size in your Battle Party
PARTY_SIZE = 3
# CT Cost in percentages for each action
ACT_ATTACK_CT = 100 # Normal attack
ACT_GUARD_CT = 100 # Defense
ACT_ESCAPE_CT = 100 # Escape
ACT_SKILL_CT = 100 # Skill
ACT_ITEM_CT = 100 # Item
# Message when failed to escape
UNESCAPE_MES = "Escape failed"
# Sound effect played when the CT Gauge is full (if "", plays no sound)
# Sound effect stored in the project's "Audio/SE" folder
FULL_CT_SE = "015-Jump01"
# Sound Volume
FULL_CT_SE_VOL = 80
# Tone effect of the battler when the CT Gauge is full
# A value of (0,0,0) performs no tone change
FULL_CT_COLOR = Tone.new(32,0,0)
# Color of HP gauge (gradation left edge)
HP_COLOR_LEFT = Color.new(128, 0, 0, 255)
# Color of HP gauge (gradation right edge)
HP_COLOR_RIGHT= Color.new(255, 0, 0, 255)
# Color of SP gauge (gradation left edge)
SP_COLOR_LEFT = Color.new(0, 0, 128, 255)
# Color of SP gauge (gradation right edge)
SP_COLOR_RIGHT= Color.new(0, 0, 255, 255)
# Color of CT gauge (gradation left edge)
COLOR_LEFT = Color.new(128, 128, 64, 255)
# Color of CT gauge (gradation left edge)
COLOR_RIGHT= Color.new(255, 255, 128, 255)
# Color of CT gauge (filled gauge)
COLOR_FULL = Color.new(255, 225, 128, 255)
# Gauge Frame Color
FRAME_COLOR = Color.new(192, 192, 192, 255)
# Gauge Frame Width
FRAME_BORDER = 1
# Gauge Frame Background Color
BACK_COLOR = Color.new(128, 128, 128, 128)
# Font Size of Actor Names
NAME_FONT_SIZE = 16
# Font Size of Actor HP/SP
HPSP_FONT_SIZE = 18
# Font Size of Enemy Names
ENEMY_FONT_SIZE = 16
# Draw maximum values for HP/SP
MAX_DRAW = false
# Group Enemy Names
# Ex: Instead of "Ghost Ghost" it will say "Ghost2"
ENEMY_GROUPING = true
# Draw Bars for Enemies (0: None / 1: HP / 2: CT)
# If ENEMY_GROUPING is used, then this setting is ignored
ENEMY_DRAWING_MATER = 0
# Draw Actor HP/SP bars in the help window
HELP_DRAWING_MATER_ACTOR = false
# Draw Enemy HP/SP bars in the help window
HELP_DRAWING_MATER_ENEMY = false
# Command Window Position System (true/false)
# (Useful with side-view scripts if the position of the Actor Command Window
# appears unnatural). The default setting is false, while true allows you to
# adjust the x/y position of the window.
WINDOWPOS_CHANGE = false
WINDOWPOS_X = 100 # X coordinates of the Actor Command Window
WINDOWPOS_Y = 320 # Y coordinates of the Actor Command Window
# Opacity of the Actor Command Window
WINDOW_OPACITY = 100
# Sets the intervals of the CT bar updates
# The lower a setting, the smoother the CT Bar fill will appear (0 Minimum).
# The higher a setting, the faster the CT Bar refreshes (Useful if lagging).
CT_SKIP = 0
# End of the config section
#------------------------------------------------------------------------------
end
#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
# This class performs battle screen processing.
#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
# * CT Update
#--------------------------------------------------------------------------
def update_ct
# When count rise is permitted
if @countup
for actor in $game_party.actors
# If you can act?
if actor.movable? == false and actor.ct_visible and @phase4_step != 5
# In invisibility state count rise
actor.ct_visible = false
actor.countup = true
actor.full_ct = false
elsif actor.movable? and actor.ct_visible == false
# Cancelling invisibility count rise
clear_ct(actor)
actor.ct_visible = true
end
# It corresponds to the replacement of the actor
if actor.max_ct == 0
actor.max_ct = @max_ct
end
# Count rise of actor
if actor.countup
# If the CT Gauge is filled and the actor is not in action
if actor.now_ct >= @max_ct and !(@pre_action_battlers.include?(actor))
# Adds the actor to the command input list
@pre_action_battlers.push(actor)
@action_count += 1
# Play the CG Gauge SE
if PARA_CTB::FULL_CT_SE != "" and actor.ct_visible
Audio.se_play("Audio/SE/" + PARA_CTB::FULL_CT_SE,PARA_CTB::FULL_CT_SE_VOL)
end
# Stop filling the CT Gauge
actor.countup = false
actor.full_ct = true
else
# Count rise
actor.make_action_speed
ct_skip = PARA_CTB::CT_SKIP != 0 ? PARA_CTB::CT_SKIP : 1
actor.now_ct += actor.current_action.speed * PARA_CTB::BATTLE_SPEED * ct_skip
end
end
end
for enemy in $game_troop.enemies
# If you can act
if enemy.movable? == false and enemy.ct_visible and @phase4_step == 5
# In invisibility state count rise
enemy.ct_visible = false
enemy.countup = true
enemy.full_ct = false
elsif enemy.movable? and enemy.ct_visible == false
# Clear the invisible CT
clear_ct(enemy)
enemy.ct_visible = true
end
# Count rise of enemy
if enemy.countup
# if the enemy CT Gauge is full and the enemy is not in action
if enemy.now_ct >= @max_ct and ! @pre_action_battlers.include?(enemy)
# Adds the enemy to the command input list
@pre_action_battlers.push(enemy)
@action_count += 1
# Stop filling the CT Gauge
enemy.countup = false
enemy.full_ct = true
else
# Count rise
enemy.make_action_speed
enemy.now_ct += enemy.current_action.speed * PARA_CTB::BATTLE_SPEED
end
end
end
# Redrawing CT gauge
@status_window.refresh_ct
@status_window2.refresh_ct
end
end
#--------------------------------------------------------------------------
# * Clear the battler CT
#--------------------------------------------------------------------------
def clear_ct(battler)
battler.countup = true
battler.now_ct = 0
battler.full_ct = false
end
#--------------------------------------------------------------------------
# * Percentage of battler CT
#--------------------------------------------------------------------------
def declease_ct(battler,percent)
battler.countup = true
battler.now_ct = battler.now_ct * percent / 100
battler.full_ct = false
end
#--------------------------------------------------------------------------
# * CT Initialization
#--------------------------------------------------------------------------
def initialize_ct
# Deciding the reference level of CT
max_ct
for battler in $game_party.actors + $game_troop.enemies
if battler.movable?
n = $game_party.actors.size + $game_troop.enemies.size
# Set the CT starting level
battler.now_ct = battler.agi * 60 * n
battler.ct_visible = true
else
clear_ct(battler)
battler.ct_visible = false
end
battler.countup = true
battler.full_ct = false
battler.max_ct = @max_ct
end
end
#--------------------------------------------------------------------------
# * Set the reference level of empty CT based on the Battler's speed
#--------------------------------------------------------------------------
def max_ct
for battler in $game_party.actors + $game_troop.enemies
@max_ct += battler.agi
end
@max_ct *= 100
end
#--------------------------------------------------------------------------
# * Modify the Battler's order of performance
#--------------------------------------------------------------------------
def shift_activer(shift)
# When one shifting, the actor of rear 2 or more
if @pre_action_battlers != nil
if shift == 1 and @pre_action_battlers.size >= @actor_array_index + 3
# Acquiring the present actor
act = @pre_action_battlers[@actor_array_index]
# Inserting the present actor in two rear
@pre_action_battlers.insert(@actor_array_index+2, act)
# Presently eliminating position
@pre_action_battlers.delete_at(@actor_array_index)
@actor_array_index -= 1
phase3_next_actor
else
act = @pre_action_battlers[@actor_array_index]
# Most adding the present actor to rear
@pre_action_battlers.push(act)
# Presently eliminating position
@pre_action_battlers.delete_at(@actor_array_index)
@actor_array_index -= 1
phase3_next_actor
end
end
end
#--------------------------------------------------------------------------
# * Main processing
#--------------------------------------------------------------------------
alias main_ctb main
def main
# Drawing up the enemy name window
@status_window2 = Window_BattleStatus_enemy.new
@action_battlers = []
@pre_action_battlers = []
@max_ct = 0
@countup = false
@ct_wait = 0
@action_count = 0
main_ctb
# Dispose the enemy name window
@status_window2.dispose
end
#--------------------------------------------------------------------------
# * Frame renewal
#--------------------------------------------------------------------------
alias ctb_update 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
# Refresh enemy status window
@status_window2.refresh
end
end
else
if PARA_CTB::CT_SKIP == 0
update_ct
else
if @ct_wait > 0
@ct_wait -= 1
else
update_ct
@ct_wait = PARA_CTB::CT_SKIP
end
end
end
ctb_update
end
#--------------------------------------------------------------------------
# * Start Pre-Battle Phase
#--------------------------------------------------------------------------
alias ctb_start_phase1 start_phase1
def start_phase1
# CT Initialization
initialize_ct
# Start of Count Rise
@countup = true
# Run original call
ctb_start_phase1
end
#--------------------------------------------------------------------------
# * Frame Update (pre-battle phase)
#--------------------------------------------------------------------------
def update_phase1
# Renew the enemy name list
@status_window2.refresh
# Determine win/loss situation
if judge
# If won or lost: end method
return
end
# Start actor command phase
start_phase3
end
#--------------------------------------------------------------------------
# * Start Party Command Phase
#--------------------------------------------------------------------------
def start_phase2
# Shift to phase 2
@phase = 2
# Set actor to non-selecting
@actor_index = -1
@active_battler = nil
# Enable party command window
@party_command_window.active = true
@party_command_window.visible = true
# Disable actor command window
@actor_command_window.active = false
@actor_command_window.visible = false
# Clear main phase flag
$game_temp.battle_main_phase = false
# If impossible to input command
unless $game_party.inputable?
# Start main phase
start_phase4
end
end
#--------------------------------------------------------------------------
# * Frame Update (party command phase: escape)
#--------------------------------------------------------------------------
def update_phase2_escape
# Calculate enemy agility average
enemies_agi = 0
for enemy in $game_troop.enemies
if enemy.exist?
enemies_agi += enemy.agi
end
end
# Calculate actor agility average
actors_agi = 0
for actor in @pre_action_battlers
if actor.is_a?(Game_Actor) and actor.exist?
actors_agi += actor.agi
end
end
# Determine if escape is successful
success = rand(100) < 50 * actors_agi / enemies_agi
# If escape is successful
if success
# Play escape SE
$game_system.se_play($data_system.escape_se)
# Return to BGM before battle started
$game_system.bgm_play($game_temp.map_bgm)
# Clear the Battlers' CT
for battler in $game_party.actors
clear_ct(battler)
end
# Battle ends
battle_end(1)
# If escape is failure
else