Yami's PCTB and Order Battlers

Status
Not open for further replies.

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
I am using Yami's Order Battlers script (which can be found in this post) together with their Predicted Charge Turn Battle script which can be found here.

When the Order Battlers script is used on its own, there is an animation which shows the player exactly whereabouts in the order the selected enemy occurs. Like this:

upload_2019-2-26_21-12-57.png

However, when the PCTB script is enabled, that animation no longer happens - which severely reduces the usefulness of the script.

Would someone be able to look at the PCTB script and suggest a way of re-enabling that function?

Thank you.
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
@Archeia I am already using Battle Symphony with the Holder Add-on. It does indeed support the Order Battlers, as that is what produced the screenshot in my opening post. However, unless there is an option that I've missed, it doesn't do CTB. In the demo I still have to select the whole party's actions before anything is initiated.
 

Archeia

Level 99 Demi-fiend
Developer
Joined
Mar 1, 2012
Messages
15,141
Reaction score
15,473
First Language
Filipino
Primarily Uses
RMMZ
@Archeia I am already using Battle Symphony with the Holder Add-on. It does indeed support the Order Battlers, as that is what produced the screenshot in my opening post. However, unless there is an option that I've missed, it doesn't do CTB. In the demo I still have to select the whole party's actions before anything is initiated.
I think my post is misread but I'll put a screenshot just in case.

upload_2019-2-27_17-38-34.png
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
@Archeia That's not in the demo you linked me to. What it has is this:

upload_2019-2-27_11-4-15.png
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
2,660
Reaction score
563
First Language
English
Primarily Uses
RMVXA
@Archeia
I do not have this script either.
I have the
# ▼ Yami Engine Symphony - Battle Mechanism
# -- Type: Press Turn Battle (SMT: Nocturne)
# -- Last Updated: 04/01/2015
which doesn't fully work in my game, incompatible with other scripts.

I found the script in my list.

BTW.. @Kes thanks for linking the order script. I apparently did not have that one. And it works in my game.
 
Last edited:

Archeia

Level 99 Demi-fiend
Developer
Joined
Mar 1, 2012
Messages
15,141
Reaction score
15,473
First Language
Filipino
Primarily Uses
RMMZ
@Kes ah ...it's probably a private one of mines that I forgot lmao.

CTB
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
# 
#==============================================================================

Order Gauge
Code:
#==============================================================================
# 
# ▼ 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]
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
@Archeia Thanks for looking this up.
I put both scripts in, with Order Gauge under the CTB as shown in your screen shot, but when I load the game I get this error message.

upload_2019-2-27_18-59-4.png

I followed the instruction in lines 34 - 36 to change the setting to ctb. I assumed that this was in Yanfly's Battle Engine.

Is there something else I need?
Thanks
 

Archeia

Level 99 Demi-fiend
Developer
Joined
Mar 1, 2012
Messages
15,141
Reaction score
15,473
First Language
Filipino
Primarily Uses
RMMZ
From the error it seems Symphony related.
I'm currently logged in at work so I can't help right now but i can set up a demo later.
 
  • Like
Reactions: Kes

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
@Archeia Have you had time yet to work out what causes the error message?
Thanks.
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
[mod]Closing as I now have a way of making the original combination work.[/mod]
 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,862
Messages
1,017,050
Members
137,571
Latest member
grr
Top