Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
In Battle Switching & Summoning
#1
In Battle Switching & Summoning (Version 2) - Last Updated: 12.20.05
SephirothSpawn
Dec 10 2005

This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given. If you are the owner of the thread, please contact administration.


The Demo:

.zip   In_Battle_Switching.zip (Size: 209.33 KB / Downloads: 5)


Description:
Allows you to switch in reserve actors and summon creatures to make battle easier.

Instructions:

Making a summon monster:
In the Actors Tab in the database, make a Actor as you normally would. Then, add * at the end of there name.

All monster will then be moved into a reserve_summons array. To active then, use

Code:
$game_party.summon_active(actor_id) #The Actor ID in the Database


To deactivate them, use

Code:
$game_party.summon_deactive(actor_id) #The Actor ID in the Database


Only active Summons are selectable in battle.

Installation
This Code Requires the Standard Development Kit Version 1.3. You Can Find it in the Demo, or the link in my signature. Insert the Code below the SDK, and above Main.

The Code

Code:
#==============================================================================
# Battle Switching & Summoning
#==============================================================================
# SephirothSpawn
# Version 2
# 20.12.05
#==============================================================================

#------------------------------------------------------------------------------
# * SDK Log Script
#------------------------------------------------------------------------------
SDK.log("Battle Switching & Summoning", "SephirothSpawn", 2, "12.18.05")

#------------------------------------------------------------------------------
# * Begin SDK Enable Test
#------------------------------------------------------------------------------
if SDK.state("Battle Switching & Summoning") == true

#==============================================================================
# ** 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 seph_battleswitch_gameparty_initialize initialize
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
seph_battleswitch_gameparty_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_Command
#==============================================================================
class Window_Command < Window_Selectable
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :commands
#--------------------------------------------------------------------------
# * Refresh Contents
#--------------------------------------------------------------------------
def refresh_contents
self.contents.dispose
@item_max = @commands.size
self.contents = Bitmap.new(width - 32, @item_max * 32)
refresh
end
end

#==============================================================================
# ** Window_BattleSwitching
#==============================================================================

class Window_BattleSwitching < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
# width : window width
# commands : command text string array
#--------------------------------------------------------------------------
def initialize(actors)
# Compute window height from command quantity
super(0, 0, 480, [actors.size * 32, 32].max + 32)
@item_max = actors.size
@actors = actors.dup
self.contents = Bitmap.new(width - 32, [@item_max * 32, 32].max)
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...@item_max
draw_item(i)
end
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
#--------------------------------------------------------------------------
def draw_item(index)
actor = @actors[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(140, index * 32, 140, 18, "#{actor.hp} / #{actor.maxhp}", 1)
draw_slant_bar(140, index * 32 + 22, actor.hp, actor.maxhp.to_f, 140)
# 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(290, index * 32, 140, 18, "#{actor.sp} / #{actor.maxsp}", 1)
draw_slant_bar(290, index * 32 + 22, actor.sp, actor.maxsp.to_f, 140)
end
#--------------------------------------------------------------------------
# Draw Slant Bar
#--------------------------------------------------------------------------
def draw_slant_bar(x, y, min, max, width = 152, height = 6, bar_color = Color.new(150, 0, 0, 255))
# Draw Border
for i in 0..height
self.contents.fill_rect(x + i, y + height - i, width + 1, 1, Color.new(50, 50, 50, 255))
end
# Draw Background
for i in 1..(height - 1)
r = 100 * (height - i) / height + 0 * i / height
g = 100 * (height - i) / height + 0 * i / height
b = 100 * (height - i) / height + 0 * i / height
a = 255 * (height - i) / height + 255 * i / height
self.contents.fill_rect(x + i, y + height - i, width, 1, Color.new(r, b, g, a))
end
# Color Values
if min == max
bar_color = Color.new(200, 0, 0, 255)
end
# Draws Bar
for i in 1..( (min / max) * width - 1)
for j in 1..(height - 1)
r = bar_color.red * (width - i) / width + 255 * i / width
g = bar_color.green * (width - i) / width + 255 * i / width
b = bar_color.blue * (width - i) / width + 60 * i / width
a = bar_color.alpha * (width - i) / width + 255 * i / width
self.contents.fill_rect(x + i + j, y + height - j, 1, 1, Color.new(r, g, b, a))
end
end
end
end

#==============================================================================
# ** Scene Title
#==============================================================================
class Scene_Title
#--------------------------------------------------------------------------
# * Alias' New Game Method
#--------------------------------------------------------------------------
alias seph_battleswitch_scenetitle_commandnewgame command_new_game
#--------------------------------------------------------------------------
# * Adds Base Stats For Enemies
#--------------------------------------------------------------------------
def command_new_game
# SDK Command: Command New Game
seph_battleswitch_scenetitle_commandnewgame
# 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

#==============================================================================
# ** Scene_Battle
#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias seph_battleswitch_scenebattle_commandsinit commands_init
alias seph_battleswitch_scenebattle_updatesceneexit update_scene_exit
alias seph_battleswitch_scenebattle_updatephase3 update_phase3
alias seph_battleswitch_scenebattle_checkcommands check_commands
#--------------------------------------------------------------------------
# * Set Commands
#--------------------------------------------------------------------------
def commands_init
# SDK Commands Initialization
seph_battleswitch_scenebattle_commandsinit
# Adds Commands
@commands.push('Switch', 'Summon')
end
#--------------------------------------------------------------------------
# * Scene Exit Update
#--------------------------------------------------------------------------
def update_scene_exit
# SDK Scene Exit
seph_battleswitch_scenebattle_updatesceneexit
unless $scene == self
# Replace Active Members
unless @temp_actors == nil
unless @temp_actors.empty?
$game_party.actors.push(@temp_actors.dup).flatten!.delete_at(0)
end
end
end
end
#--------------------------------------------------------------------------
# * Frame Update (actor command phase)
#--------------------------------------------------------------------------
def update_phase3
seph_battleswitch_scenebattle_updatephase3
# If Party Switch is enabled
if @party_switch_window != nil
update_phase3_party_switch_select
end
# If Summon Switch skill is enabled
if @summon_switch_window != nil
update_phase3_summon_switch_select
end
end
#--------------------------------------------------------------------------
# * Check Commands
#--------------------------------------------------------------------------
def check_commands
seph_battleswitch_scenebattle_checkcommands
# Loads Current Command
command = @commands[@actor_command_window.index]
# Party Switch
if command == 'Switch'
update_phase3_command_switch
end
# Summon Switch
if command == 'Summon'
update_phase3_command_summon
end
# Unsummon Switch
if command == 'Unsummon'
update_phase3_command_unsummon
end
end
#--------------------------------------------------------------------------
# * Start Command: Switch
#--------------------------------------------------------------------------
def update_phase3_command_switch
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Party Switch Window
@party_switch_window = Window_BattleSwitching.new($game_party.reserve_actors)
@party_switch_window.height = 160 if @party_switch_window.height > 160
@party_switch_window.x = 320 - @party_switch_window.width / 2
@party_switch_window.y = 192 - @party_switch_window.height / 2
@party_switch_window.back_opacity = 225
# Actives Switch Window
@party_switch_window.active = true
# Disable actor command window
@actor_command_window.active = false
@actor_command_window.visible = false
end
#--------------------------------------------------------------------------
# * Start Command: Summon
#--------------------------------------------------------------------------
def update_phase3_command_summon
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Summon Switch Window
@summon_switch_window = Window_BattleSwitching.new($game_party.summon_actors)
@summon_switch_window.height = 160 if @summon_switch_window.height > 160
@summon_switch_window.x = 320 - @summon_switch_window.width / 2
@summon_switch_window.y = 192 - @summon_switch_window.height / 2
@summon_switch_window.back_opacity = 225
# Actives Switch Window
@summon_switch_window.active = true
# Disable actor command window
@actor_command_window.active = false
@actor_command_window.visible = false
end
#--------------------------------------------------------------------------
# * Start Command: Unsummon
#--------------------------------------------------------------------------
def update_phase3_command_unsummon
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Replace Active Members & Delete Summon
$game_party.actors.push(@temp_actors.dup).flatten!.delete_at(0)
# Refreshes
$game_party.refresh
# Clears Temp Actors
@temp_actors.clear
# Creates New Commands
@commands = @temp_commands
# Recreates Command Window
@actor_command_window.commands = @commands
# Refresh Window Contents
@actor_command_window.refresh_contents
# Refreshes Status Window
@status_window.refresh
# Deletes Spriteset
@spriteset.dispose
# Recreates Spriteset
@spriteset = Spriteset_Battle.new
for actor in $game_party.actors
@active_battler = actor
# Set action
@active_battler.current_action.kind = 0
@active_battler.current_action.basic = 1
@active_battler.blink = false
end
# Go to Battle Processing
start_phase4
end
#--------------------------------------------------------------------------
# * Command: Switch
#--------------------------------------------------------------------------
def update_phase3_party_switch_select
# Make Party Switch window visible
@party_switch_window.visible = true
# Update window
@party_switch_window.update
# If B button was pressed
if Input.trigger?(Input::[img]http://www.creationasylum.net/style_emoticons/dubealex/cool.gif[/img]
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# End skill selection
end_party_switch_select
return
end
# If A button was pressed
if Input.trigger?(Input::A)
if $game_party.reserve_actors[@party_switch_window.index] == nil
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
else
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Store Index of Current Battler
index = $game_party.actors.index(@active_battler)
# Move Active Battler to Reserve
$game_party.move_to_reserve(@active_battler.id)
# Set Active Battler
@active_battler = $game_party.reserve_actors[@party_switch_window.index]
# Move Reserve Actor to Active Party
$game_party.move_to_party(@active_battler.id, index)
# Refreshes
$game_party.refresh
# Refresh Status Window
@status_window.refresh
# Set actor as unselectable
@actor_index -= 1
@active_battler = nil
# End skill selection
end_party_switch_select
# Go to command input for next actor
phase3_next_actor
return
end
end
end
#--------------------------------------------------------------------------
# * Command: Summon
#--------------------------------------------------------------------------
def update_phase3_summon_switch_select
# Make summon window visible
@summon_switch_window.visible = true
# Update summon window
@summon_switch_window.update
# If B button was pressed
if Input.trigger?(Input::[img]http://www.creationasylum.net/style_emoticons/dubealex/cool.gif[/img]
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# End skill selection
end_summon_switch_select
return
end
# If A button was pressed
if Input.trigger?(Input::A)
if $game_party.summon_actors[@summon_switch_window.index] == nil
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
else
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Stores Current Actors
@temp_actors = $game_party.actors.dup
# Store Current Commands
@temp_commands = @commands.dup
# Make New Commands
@actor_command_window.commands = [$data_system.words.attack,
$data_system.words.skill, $data_system.words.guard, $data_system.words.item]
# Adds Limit Break if Limit Break Enabled
if SDK.state("Advanced Limit Break") == true
index = @actor_command_window.commands.index($data_system.words.skill) + 1
@actor_command_window.commands.insert(index, 'Limit Break')
end
# Adds Unsummon Command
@actor_command_window.commands.push('Unsummon')
# Creates New Commands
@commands = @actor_command_window.commands.dup
# Refresh Window Contents
@actor_command_window.refresh_contents
# Clear Game Party
$game_party.actors.clear
# Gets Active Battler
@active_battler = $game_party.summon_actors[@summon_switch_window.index]
# Add Summon to Party
$game_party.actors = [@active_battler]
# Refresh Status Window
@status_window.refresh
# Set action
@active_battler.current_action.kind = 0
@active_battler.current_action.basic = 1
@active_battler.blink = false
# End skill selection
end_summon_switch_select
# Go to Battle Processing
start_phase4
return
end
end
end
#--------------------------------------------------------------------------
# * End Party Switch Selection
#--------------------------------------------------------------------------
def end_party_switch_select
# Delete Party Switch Window
@party_switch_window.dispose
@party_switch_window = nil
# Hide help window
@help_window.visible = false
# Enable actor command window
@actor_command_window.active = true
@actor_command_window.visible = true
end
#--------------------------------------------------------------------------
# * End Summon Switch Selection
#--------------------------------------------------------------------------
def end_summon_switch_select
# Delete Summon Switch Window
@summon_switch_window.dispose
@summon_switch_window = nil
# Hide help window
@help_window.visible = false
# Enable actor command window
@actor_command_window.active = true
@actor_command_window.visible = true
end
end

#--------------------------------------------------------------------------
# * End SDK Enable Test
#--------------------------------------------------------------------------
end
}


Possibly Related Threads…
Thread Author Replies Views Last Post
  Weapon/Battle Graphic Change Edit Skyboar 0 2,241 04-12-2008, 01:00 PM
Last Post: Skyboar
  BOF battle system azrith001 0 2,404 03-06-2008, 01:00 PM
Last Post: azrith001
  Wild Arms 4 Hex Battle System ShockWave 0 2,526 05-15-2007, 01:00 PM
Last Post: ShockWave
  Tactical Battle System Nick 0 2,448 01-07-2007, 01:00 PM
Last Post: Nick
  Kingdom Hearts Battle System SephirothSpawn 0 2,432 12-02-2005, 01:00 PM
Last Post: SephirothSpawn
  Star Ocean Battle System CrushD 0 2,359 03-06-2005, 01:00 PM
Last Post: CrushD



Users browsing this thread: