#==============================================================================
#
# ▼ Yami Engine Symphony - Charge Turn Battle Add-on
# -- Script: Order Gauge
# -- Last Updated: 2012.07.04
# -- Level: Normal
# -- Requires: n/a
#
#==============================================================================
$imported = {} if $imported.nil?
$imported["YES-CTBOrderGauge"] = true
#==============================================================================
# ▼ Updates
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 2012.07.04 - Started and Finished Script.
#
#==============================================================================
# ▼ Introduction
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script provides a visual for Turn Order of CTB.
#
#==============================================================================
# ▼ Instructions
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# To install this script, open up your script editor and copy/paste this script
# to an open slot below YES - Battle CTB but above ▼ Main. Remember to save.
#
#==============================================================================
# ▼ 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 only works with YES - Battle CTB.
#
#==============================================================================
module YES
module CTB
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# - Order Gauge Settings -
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# These settings are adjusted for the Order Gauge of CTB.
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
ORDER_GAUGE = { # Start.
:pending => 8, # Number of Pending Turns on Order Gauge.
# Order Gauge Position.
:x => 0,
:y => 0,
# Order Gauge Type.
:type => :horizontal, # :horizontal for horizontal Gauge.
# :vertical for vertical Gauge.
} # End.
end # CTB
end # YES
#==============================================================================
# ▼ 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.
#==============================================================================
#==============================================================================
# ■ Cache
#==============================================================================
module Cache
#--------------------------------------------------------------------------
# new method: ctb
#--------------------------------------------------------------------------
def self.ctb(filename)
begin
load_bitmap("Graphics/CTB/", filename)
rescue
empty_bitmap
end
end
end # Cache
#==============================================================================
# ■ YES::CTB
#==============================================================================
module YES
module CTB
SPRITE_WIDTH = Cache.ctb("BGActor").width
SPRITE_HEIGHT = Cache.ctb("BGEnemy").height
RECT = Rect.new(0, 0, SPRITE_WIDTH, SPRITE_HEIGHT)
end
end
#==============================================================================
# ■ BattleControl
#==============================================================================
module BattleControl
#--------------------------------------------------------------------------
# new method: ctb_ct
#--------------------------------------------------------------------------
def self.ctb_ct
result = @ctb_ct.dup
result
end
#--------------------------------------------------------------------------
# new method: ctb_temp_ct
#--------------------------------------------------------------------------
def self.ctb_temp_ct
result = @ctb_temp_ct.dup
result
end
#--------------------------------------------------------------------------
# new method: ctb_time
#--------------------------------------------------------------------------
def self.ctb_time(battler, real_ct)
return 0 if real_ct >= @threshold
return ((@threshold - real_ct) / battler.agi).ceil
end
end # BattleControl
#==============================================================================
# ■ Window_OrderCTB
#==============================================================================
class Window_OrderCTB < Window_Base
#--------------------------------------------------------------------------
# initialize
#--------------------------------------------------------------------------
def initialize
x = YES::CTB::ORDER_GAUGE[:x]
y = YES::CTB::ORDER_GAUGE[:y]
super(x, y, Graphics.width, Graphics.height)
self.opacity = 0
@data = []
@battlers = []
end
#--------------------------------------------------------------------------
# item_rect
#--------------------------------------------------------------------------
def item_rect(index)
width = YES::CTB::SPRITE_WIDTH
height = YES::CTB::SPRITE_HEIGHT
x = YES::CTB::ORDER_GAUGE[:type] == :horizontal ? (YES::CTB::ORDER_GAUGE[:pending] - index - 1) * width : 0
y = YES::CTB::ORDER_GAUGE[:type] == :vertical ? index * height : 0
x += (width.to_f / 4).floor if index == 0
rect = Rect.new(x, y, width, height)
rect
end
#--------------------------------------------------------------------------
# refresh
#--------------------------------------------------------------------------
def refresh
filter_battlers
get_data
contents.clear
#---
for i in 0...YES::CTB::ORDER_GAUGE[:pending]
draw_item(i)
end
end
#--------------------------------------------------------------------------
# draw_item
#--------------------------------------------------------------------------
def draw_item(index)
contents.font.size = 18
contents.font.color.set(Color.new(255,255,255))
contents.font.out_color = Color.new(0,0,0)
data = @data[index]
rect = item_rect(index)
#---
border = data[0].actor? ? "BorderActor" : "BorderEnemy"
#---
if data[0].actor?
bg = "BGActor"
letter = ""
else
bg = "BGEnemy"
letter = data[0].letter
end
#---
face = data[0].actor? ? data[0].name : data[0].enemy.name
#---
contents.blt(rect.x, rect.y, Cache.ctb(bg), YES::CTB::RECT)
contents.blt(rect.x, rect.y, Cache.ctb(face), YES::CTB::RECT)
contents.blt(rect.x, rect.y, Cache.ctb(border), YES::CTB::RECT)
#---
rect.y += 12
draw_text(rect, letter, 2)
end
#--------------------------------------------------------------------------
# filter_battlers
#--------------------------------------------------------------------------
def filter_battlers
BattleControl.ctb_fix_ct
@battlers.clear
($game_party.battle_members + $game_troop.members).each { |battler|
next unless battler.movable?
@battlers.push(battler)
}
end
#--------------------------------------------------------------------------
# filter_battlers
#--------------------------------------------------------------------------
def sort_battlers
@battlers.sort! { |a, b|
if BattleControl.ctb_time(a, @ct[a.name]) != BattleControl.ctb_time(b, @ct[b.name])
BattleControl.ctb_time(a, @ct[a.name]) <=> BattleControl.ctb_time(b, @ct[b.name])
elsif (@ct[a.name] + BattleControl.ctb_time(a, @ct[a.name]) * a.agi) != (@ct[b.name] + BattleControl.ctb_time(b, @ct[b.name]) * b.agi)
(@ct[b.name] + BattleControl.ctb_time(b, @ct[b.name]) * b.agi) <=> (@ct[a.name] + BattleControl.ctb_time(a, @ct[a.name]) * a.agi)
else
a.screen_x <=> b.screen_x
end
}
end
#--------------------------------------------------------------------------
# get_data
#--------------------------------------------------------------------------
def get_data
@ct = BattleControl.ctb_ct
@temp_ct = BattleControl.ctb_temp_ct
@data.clear
#---
active_battler = BattleControl.ctb_active_battlers[0]
if active_battler
@data.push([active_battler, @ct[active_battler.name]])
if @temp_ct.has_key?(active_battler.name)
@ct[active_battler.name] -= @temp_ct[active_battler.name]
else
@ct[active_battler.name] -= BattleControl.ctb_evaluate_ct(active_battler, nil)
end
end
#---
while @data.size < YES::CTB::ORDER_GAUGE[:pending]
sort_battlers
battler = @battlers[0]
@data.push([battler, @ct[battler.name]])
@ct[battler.name] -= BattleControl.ctb_evaluate_ct(battler, nil)
end
end
end # Window_OrderCTB
#==============================================================================
# ■ Scene_Battle
#==============================================================================
class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# alias method: update_basic
#--------------------------------------------------------------------------
alias order_ctb_update_basic update_basic
def update_basic
order_ctb_update_basic
return unless BattleControl.battle_type == :ctb
if $game_party.all_dead? || $game_troop.all_dead?
@ctb_order_gauge.contents_opacity -= 25
end
end
#--------------------------------------------------------------------------
# alias method: update
#--------------------------------------------------------------------------
alias order_ctb_update update
def update
order_ctb_update
#---
return unless BattleControl.battle_type == :ctb
return unless @subject
return unless @subject.actor?
if @actor_command_window.active
if @actor_command_window.current_symbol == :attack
skill = $data_skills[1]
end
if @actor_command_window.current_symbol == :guard
skill = $data_skills[2]
end
if $imported["YEA-BattleCommandList"]
if @actor_command_window.current_symbol == :use_skill
skill = $data_skills[@actor_command_window.current_ext]
end
end
end
if @skill_window.active && BattleManager.actor
skill = @skill_window.item
end
if @item_window.active && BattleManager.actor
skill = @item_window.item
end
#---
temp_ct = BattleControl.ctb_evaluate_ct(@subject, skill)
unless BattleControl.ctb_check_temp((@subject), temp_ct)
BattleControl.ctb_temp_evaluate(@subject, skill)
@ctb_order_gauge.refresh
end
end
end # Scene_Battle
#==============================================================================
#
# ▼ End of File
#
#==============================================================================[code][/spoiler]