#==============================================================================
# In Battle Party & Summon Switching System
#--------------------------------------------------------------------------
# Created By SephirothSpawn (12.10.05)
# Last Updated: 12.10.05
#==============================================================================
#==============================================================================
# Class Scene Title
#==============================================================================
class Scene_Title
#--------------------------------------------------------------------------
# * Alias' New Game Method
#--------------------------------------------------------------------------
alias summon_new_game command_new_game
#--------------------------------------------------------------------------
# * Adds Base Stats For Enemies
#--------------------------------------------------------------------------
def command_new_game
summon_new_game
# Sets Summon Actors Requirements
for actor in $data_actors
unless actor == nil
$game_party.reserve_summon_actors.push($game_actors[actor.id]) if actor.name.delete!('*')
end
end
end
end
#==============================================================================
# ** Class Game_Party
#==============================================================================
class Game_Party
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :actors
attr_accessor :reserve_actors
attr_accessor :summon_actors
attr_accessor :reserve_summon_actors
#--------------------------------------------------------------------------
# * Alias Initialization
#--------------------------------------------------------------------------
alias switching_initialize initialize
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
switching_initialize
@reserve_actors = []
@summon_actors = []
@reserve_summon_actors = []
end
#--------------------------------------------------------------------------
# * Add an Actor
# actor_id : actor ID
#--------------------------------------------------------------------------
def add_actor(actor_id)
# Get actor
actor = $game_actors[actor_id]
# If the party has less than 4 members and this actor is not in the party
if @actors.size < 4 and not @actors.include?(actor)
# Add actor
@actors.push(actor)
# Refresh player
$game_player.refresh
elsif @actors.size >= 4 and not @actors.include?(actor) and not @reserve_actors.include?(actor)
# Add actor
@reserve_actors.push(actor)
# Refresh player
$game_player.refresh
end
end
#--------------------------------------------------------------------------
# * Move To Reserve
# actor_id : actor ID
#--------------------------------------------------------------------------
def move_to_reserve(actor_id)
# Get actor
actor = $game_actors[actor_id]
if @actors.include?(actor)
@actors.delete(actor)
@reserve_actors.push(actor)
end
# Refresh player
$game_player.refresh
end
#--------------------------------------------------------------------------
# * Move To Party
# actor_id : actor ID
#--------------------------------------------------------------------------
def move_to_party(actor_id, index = -1)
# Get actor
actor = $game_actors[actor_id]
if @reserve_actors.include?(actor)
@reserve_actors.delete(actor)
@actors.insert(index, actor)
end
# Refresh player
$game_player.refresh
end
#--------------------------------------------------------------------------
# * Activate Summon
# actor_id : actor ID
#--------------------------------------------------------------------------
def summon_active(actor_id)
# Get actor
actor = $game_actors[actor_id]
if @reserve_summon_actors.include?(actor)
@reserve_summon_actors.delete(actor)
@summon_actors.push(actor)
end
# Refresh player
$game_player.refresh
end
#--------------------------------------------------------------------------
# * Deactivate Summon
# actor_id : actor ID
#--------------------------------------------------------------------------
def summon_deactive(actor_id)
# Get actor
actor = $game_actors[actor_id]
if @summon_actors.include?(actor)
@summon_actors.delete(actor)
@reserve_summon_actors.push(actor)
end
# Refresh player
$game_player.refresh
end
end
#==============================================================================
# ** Window_BattleSwitching
#==============================================================================
class Window_BattleSwitching < Window_Selectable
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :commands
#--------------------------------------------------------------------------
# * Object Initialization
# width : window width
# commands : command text string array
#--------------------------------------------------------------------------
def initialize(width, commands)
# Compute window height from command quantity
super(0, 0, width, commands.size * 32 + 32)
@item_max = commands.size
@commands = commands
self.contents = Bitmap.new(width - 32, @item_max * 32)
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh(commands = @commands)
unless commands == @commands
@item_max = commands.size
@commands = commands
self.contents.dispose
self.contents = Bitmap.new(width - 32, @item_max * 32)
end
self.contents.clear
for i in 0...@item_max
draw_item(i)
end
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
#--------------------------------------------------------------------------
def draw_item(index)
actor = @commands[index]
# Draws Name
contents.font.size = 22
contents.font.color = normal_color
contents.draw_text(4, index * 32, contents.width, 32, actor.name)
# Draws HP
contents.font.size = 16
color = actor.hp == 0 ? knockout_color : actor.hp < actor.maxhp / 2 ? crisis_color : normal_color
contents.font.color = color
contents.draw_text(contents.width / 3, index * 32, contents.width / 3, 18, "#{actor.hp} / #{actor.maxhp}", 1)
draw_bar(contents.width / 3 + 4, index * 32 + 22, actor.hp, actor.maxhp, contents.width / 3 - 8)
# Draws SP
contents.font.size = 16
color = actor.sp == 0 ? knockout_color : actor.sp < actor.maxsp / 2 ? crisis_color : normal_color
contents.font.color = color
contents.draw_text(contents.width / 3 * 2, index * 32, contents.width / 3, 18, "#{actor.sp} / #{actor.maxsp}", 1)
draw_bar(contents.width / 3 * 2 + 4, index * 32 + 22, actor.sp, actor.maxsp, contents.width / 3 - 8)
end
#--------------------------------------------------------------------------
# * Draw Bar
#--------------------------------------------------------------------------
def draw_bar(x, y, min, max, width, height = 6)
# Gets Bar Colors
color = min == 0 ? knockout_color : min < max / 2 ? crisis_color : normal_color
# Draws Background Bar
self.contents.fill_rect(x, y, width , height, Color.new(50, 50, 0, 200))
# Draws Colored Bar
w = width * min / max
for i in 0..height
r = color.red * (height - i) / height + i / height
g = color.green * (height - i) / height + i / height
b = color.blue * (height - i) / height + i / height
a = color.alpha * (height - i) / height + 255 * i / height
self.contents.fill_rect(x, y + i, w , 1, Color.new(r, g, b, a))
end
end
end
#==============================================================================
# ** Scene_Battle
#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias switching_main main
alias switching_update update
alias switching_update_phase3 update_phase3
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
@switching_avialable, @summoning = true, true
@temp_actors = []
# Creates Reserve Actors Window
if $game_party.reserve_actors.size == 0
@switching_avialable = false
else
@reserve_actors_window = Window_BattleSwitching.new(width = 360, $game_party.reserve_actors)
@reserve_actors_window.height = 160 if @reserve_actors_window.height > 160
@reserve_actors_window.x = 320 - width / 2
@reserve_actors_window.y = 192 - @reserve_actors_window.height / 2
@reserve_actors_window.back_opacity = 225
@reserve_actors_window.active = @reserve_actors_window.visible = false
end
# Creates Summon Actors Window
if $game_party.summon_actors.size == 0
@summoning = false
else
@summon_actors_window = Window_BattleSwitching.new(width = 360, $game_party.summon_actors)
@summon_actors_window.height = 160 if @summon_actors_window.height > 160
@summon_actors_window.x = 320 - width / 2
@summon_actors_window.y = 192 - @summon_actors_window.height / 2
@summon_actors_window.z = 9999
@summon_actors_window.active = @summon_actors_window.visible = false
end
# Creates Summon Command Window
commands = [$data_system.words.attack, $data_system.words.skill, $data_system.words.guard, "Unsummon"]
@summon_command_window = Window_Command.new(160, commands)
@summon_command_window.y = 160
@summon_command_window.active = @summon_command_window.visible = false
# Default Main
switching_main
# Replace Active Members
unless @temp_actors.empty?
$game_party.actors.push(@temp_actors.dup).flatten!.delete_at(0)
end
# Disposes Window
[@reserve_actors_window, @summon_actors_window, @summon_command_window].each {|x| x.dispose unless x == nil}
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
unless @reserve_actors_window == nil
@reserve_actors_window.update if @reserve_actors_window.active
end
unless @summon_actors_window == nil
@summon_actors_window.update if @summon_actors_window.active
end
unless @summon_command_window == nil
@summon_command_window.update if @summon_command_window.active
end
@help_window.visible = false if @party_command_window.active
switching_update
end
#--------------------------------------------------------------------------
# * Frame Update (actor command phase)
#--------------------------------------------------------------------------
def update_phase3
switching_update_phase3
unless @reserve_actors_window == nil
update_phase3_reserve_selection if @reserve_actors_window.active
end
unless @summon_actors_window == nil
update_phase3_summon_selection if @summon_actors_window.active
end
if @summon_command_window.active
update_phase3_basic_command
end
end
#--------------------------------------------------------------------------
# * Actor Command Window Setup
#--------------------------------------------------------------------------
def phase3_setup_command_window
# Disable party command window
@party_command_window.active = false
@party_command_window.visible = false
if $game_party.actors.size == 1 && $game_party.summon_actors.include?($game_party.actors[0])
@summon_command_window.active = @summon_command_window.visible = true
@summon_command_window.x = 640 - @summon_command_window.width
@summon_command_window.y = 320
@summon_command_window.index = 0
else
# Enable actor command window
@actor_command_window.active = true
@actor_command_window.visible = true
# Set actor command window position
@actor_command_window.x = @actor_index * 160
# Set index to 0
@actor_command_window.index = 0
end
end
#--------------------------------------------------------------------------
# * Frame Update (actor command phase)
#--------------------------------------------------------------------------
def update_phase3
switching_update_phase3
unless @reserve_actors_window == nil
update_phase3_reserve_selection if @reserve_actors_window.active
end
unless @summon_actors_window == nil
update_phase3_summon_selection if @summon_actors_window.active
end
if @summon_command_window.active
update_phase3_basic_command
end
end
#--------------------------------------------------------------------------
# * Actor Command Window Setup
#--------------------------------------------------------------------------
def phase3_setup_command_window
# Disable party command window
@party_command_window.active = false
@party_command_window.visible = false
if $game_party.actors.size == 1 && $game_party.summon_actors.include?($game_party.actors[0])
@summon_command_window.active = @summon_command_window.visible = true
@summon_command_window.x = 640 - @summon_command_window.width
@summon_command_window.y = 320
@summon_command_window.index = 0
else
# Enable actor command window
@actor_command_window.active = true
@actor_command_window.visible = true
# Set actor command window position
@actor_command_window.x = @actor_index * 160
# Set index to 0
@actor_command_window.index = 0
end
end
#--------------------------------------------------------------------------
# * Frame Update (actor command phase : basic command)
#--------------------------------------------------------------------------
def update_phase3_basic_command
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Go to command input for previous actor
phase3_prior_actor
return
end
# If C button was pressed
if Input.trigger?(Input::C)
if @actor_command_window.active
# Branch by actor command window cursor position
case @actor_command_window.index
when 0 # attack
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Set action
@active_battler.current_action.kind = 0
@active_battler.current_action.basic = 0
# Start enemy selection
start_enemy_select
when 1 # skill
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Set action
@active_battler.current_action.kind = 1
# Start skill selection
start_skill_select
when 2 # guard
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Set action
@active_battler.current_action.kind = 0
@active_battler.current_action.basic = 1
# Go to command input for next actor
phase3_next_actor
when 3 # item
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Set action
@active_battler.current_action.kind = 2
# Start item selection
start_item_select
when 4 # Switch
if $game_party.reserve_actors.size == 0
$game_system.se_play($data_system.buzzer_se)
@help_window.set_text("No Reserve Actors to Switch With", 1)
else
$game_system.se_play($data_system.decision_se)
@help_window.set_text("Select Actor to Switch Out", 1)
@reserve_actors_window.refresh($game_party.reserve_actors)
@actor_command_window.visible = @actor_command_window.active = false
@reserve_actors_window.visible = @reserve_actors_window.active = true
@reserve_actors_window.index = 0
end
when 5 # Summon
if $game_party.summon_actors.size == 0
$game_system.se_play($data_system.buzzer_se)
@help_window.set_text("No Summons to Switch With", 1)
else
$game_system.se_play($data_system.decision_se)
@help_window.set_text("Select Summon to Bring In", 1)
@summon_actors_window.refresh($game_party.summon_actors)
@actor_command_window.visible = @actor_command_window.active = false
@summon_actors_window.visible = @summon_actors_window.active = true
@summon_actors_window.index = 0
end
end
return
else
@summon_command_window.visible = @summon_command_window.active = false
case @summon_command_window.index
when 0 # attack
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Set action
@active_battler.current_action.kind = 0
@active_battler.current_action.basic = 0
# Start enemy selection
start_enemy_select
when 1 # skill
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Set action
@active_battler.current_action.kind = 1
# Start skill selection
start_skill_select
when 2 # guard
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Set action
@active_battler.current_action.kind = 0
@active_battler.current_action.basic = 1
# Go to command input for next actor
phase3_next_actor
when 3 # unsummon
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Replace Active Members
$game_party.actors.push(@temp_actors.dup).flatten!.delete_at(0)
@temp_actors.clear
@status_window.refresh
@spriteset.dispose
@spriteset = Spriteset_Battle.new
# Set actor as unselectable
@active_battler = nil
@actor_index = $game_party.actors.size - 1
# Go to command input for next actor
phase3_next_actor
end
end
end
end
#--------------------------------------------------------------------------
# * Frame Update (actor command phase : reserve switch selection)
#--------------------------------------------------------------------------
def update_phase3_reserve_selection
# If B button was pressed
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@reserve_actors_window.visible = @reserve_actors_window.active = false
@actor_command_window.visible = @actor_command_window.active = true
end
# If A button was pressed
if Input.trigger?(Input::A)
$game_system.se_play($data_system.decision_se)
index = $game_party.actors.index(@active_battler)
$game_party.move_to_reserve(@active_battler.id)
$game_party.move_to_party($game_party.reserve_actors[@reserve_actors_window.index].id, index)
@status_window.refresh
@reserve_actors_window.visible = @reserve_actors_window.active = false
# Set actor as unselectable
@actor_index -= 1
@active_battler = nil
# Go to command input for next actor
phase3_next_actor
end
end
#--------------------------------------------------------------------------
# * Frame Update (actor command phase : summon swith selection)
#--------------------------------------------------------------------------
def update_phase3_summon_selection
# If B button was pressed
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@summon_actors_window.visible = @summon_actors_window.active = false
@actor_command_window.visible = @actor_command_window.active = true
return
end
# If A button was pressed
if Input.trigger?(Input::A)
$game_system.se_play($data_system.decision_se)
@temp_actors = $game_party.actors.dup
$game_party.actors.clear
$game_party.actors.push($game_party.summon_actors[@summon_actors_window.index])
@status_window.refresh
@summon_actors_window.visible = @summon_actors_window.active = false
@actor_command_window.visible = @actor_command_window.active = true
# Set Active battler
@active_battler = $game_party.actors[0]
# Set action
@active_battler.current_action.kind = 0
@active_battler.current_action.basic = 1
# Go to command input for next actor
phase3_next_actor
end
end
end