09-18-2012, 11:26 PM
Hi,
I'm having a problem with a party selector script. The script is based of Dargor Version 3.3 script and works fine except for the part where you can organise your party.
The cursor when selecting party members to organise does not appear. You can still swap and select characters but you can't see which is being selected due to the missing cursor. This was working in version 2.5 of the script but I had to use 3.3 due to the extra features it offered.
I've added the script I am using. If someone is able to help I'd appreciate it.
I'm having a problem with a party selector script. The script is based of Dargor Version 3.3 script and works fine except for the part where you can organise your party.
The cursor when selecting party members to organise does not appear. You can still swap and select characters but you can't see which is being selected due to the missing cursor. This was working in version 2.5 of the script but I had to use 3.3 due to the extra features it offered.
I've added the script I am using. If someone is able to help I'd appreciate it.
Code:
#==============================================================================
# ** Party Changer
#------------------------------------------------------------------------------
# Author: Dargor
# Version 3.3
# 16/12/2007
#==============================================================================
#==============================================================================
# ** Game_Temp
#------------------------------------------------------------------------------
# This class handles temporary data that is not included with save data.
# Refer to "$game_temp" for the instance of this class.
#==============================================================================
class Game_Temp
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :selected_members # selected members
attr_accessor :party_members # party members
attr_accessor :members_gain_exp # members can gain exp
attr_accessor :members_exp_rate # exp % gained
attr_accessor :party_changer_in_battle # party changer in battle
attr_accessor :battle_party_args # in-battle party changer arguments
attr_accessor :menu_party_args # in-menu party changer arguments
attr_accessor :multiple_party_battle # open party changer when all actors collapse
attr_accessor :multiple_teams_args
attr_accessor :multiple_teams
attr_accessor :teams_destination
attr_accessor :current_team
attr_accessor :use_custom_graphic
#--------------------------------------------------------------------------
# * Alias Listing
#--------------------------------------------------------------------------
alias party_changer_initialize initialize
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
@selected_members = []
@party_members = []
@members_gain_exp = true
@members_exp_rate = 30
@party_changer_in_battle = true
@battle_party_args = [1, 4,[],[]]
@menu_party_args = [1, 4,[],[]]
@multiple_teams = false
@multiple_teams_args = [
[1, 2,[2],[2]],
[1, 2,[5],[5]],
[1, 4,[3],[3]]
]
@teams_destination = [
[10,7,1,2],
[9,8,1,2],
[11,8,1,2]
]
@current_team = [0, []]
@multiple_party_battle = true
@use_custom_graphic = true
party_changer_initialize
end
end
#==============================================================================
# ** Window_Base
#------------------------------------------------------------------------------
# This class is for all in-game windows.
#==============================================================================
class Window_Base
#--------------------------------------------------------------------------
# * Draw Graphic
# actor : actor
# x : draw spot x-coordinate
# y : draw spot y-coordinate
#--------------------------------------------------------------------------
def draw_actor_graphic(actor, x, y, selected = false)
bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
cw = bitmap.width / 4
ch = bitmap.height / 4
src_rect = Rect.new(0, 0, cw, ch)
opacity = selected ? 160 : 255
self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect,opacity)
end
end
#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
# This class handles the actor. It's used within the Game_Actors class
# ($game_actors) and refers to the Game_Party class ($game_party).
#==============================================================================
class Game_Actor
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :position # position
attr_accessor :locked # locked in the reserve
#--------------------------------------------------------------------------
# * Alias Listing
#--------------------------------------------------------------------------
alias party_changer_setup setup
#--------------------------------------------------------------------------
# * Setup (actor_id)
#--------------------------------------------------------------------------
def setup(actor_id)
party_changer_setup(actor_id)
actor = $data_actors[actor_id]
@position = $data_classes[actor.class_id].position
@locked = false
end
end
#==============================================================================
# ** Window_Command
#------------------------------------------------------------------------------
# This window deals with general command choices.
#==============================================================================
class Window_Command
#--------------------------------------------------------------------------
# * Enable Item
# index : item number
#--------------------------------------------------------------------------
def enable_item(index)
draw_item(index, normal_color)
end
end
#==============================================================================
# ** Game_Party
#------------------------------------------------------------------------------
# This class handles the party. It includes information on amount of gold
# and items. Refer to "$game_party" for the instance of this class.
#==============================================================================
class Game_Party
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :members # members
attr_accessor :team_members
attr_accessor :team_location
#--------------------------------------------------------------------------
# * Alias Listing
#--------------------------------------------------------------------------
alias party_changer_initialize initialize
alias party_changer_refresh refresh
alias party_changer_add_actor add_actor
alias party_changer_remove_actor remove_actor
alias party_changer_setup_starting_members setup_starting_members
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
party_changer_initialize
@members = []
@team_members = []
@team_gold = []
@team_items = []
@team_armors = []
@team_weapons = []
@team_location = []
end
def setup_teams(id, members, location)
@team_members[id] = members
if @team_location[id].nil?
@team_location[id] = []
end
@team_location[id][0] = location[0]
@team_location[id][1] = location[1]
@team_location[id][2] = location[2]
@team_location[id][3] = location[3]
end
def save_team_data
team_id = $game_temp.current_team[0]
@team_members[team_id] = $game_party.actors.dup
if @team_location[team_id].nil?
@team_location[team_id] = []
end
@team_location[team_id][0] = $game_player.x
@team_location[team_id][1] = $game_player.y
@team_location[team_id][2] = $game_map.map_id
@team_location[team_id][3] = $game_player.direction
end
def switch(team_id)
if $scene.is_a?(Scene_Map)
$game_party.actors.clear
for i in 0...@team_members[team_id].size
$game_party.add_actor(@team_members[team_id][i].id)
end
$game_temp.player_new_x = @team_location[team_id][0]
$game_temp.player_new_y = @team_location[team_id][1]
$game_temp.player_new_map_id = @team_location[team_id][2]
$game_temp.player_new_direction = @team_location[team_id][3]
end
end
#--------------------------------------------------------------------------
# * Initial Party Setup
#--------------------------------------------------------------------------
def setup_starting_members
party_changer_setup_starting_members
for i in $data_system.party_members
actor = $game_actors[i]
if not @members.include?(actor)
@members.push(actor)
end
end
end
#--------------------------------------------------------------------------
# * Refresh Party Members
#--------------------------------------------------------------------------
def refresh
# Actor objects split from $game_actors right after loading game data
# Avoid this problem by resetting the actors each time data is loaded.
party_changer_refresh
new_members = []
for i in 0...@members.size
if $data_actors[@members[i].id] != nil
new_members.push($game_actors[@members[i].id])
end
end
@members = new_members
end
#--------------------------------------------------------------------------
# * Add Actor
# actor_id : actor ID
#--------------------------------------------------------------------------
def add_actor(actor_id)
party_changer_add_actor(actor_id)
add_member(actor_id)
end
#--------------------------------------------------------------------------
# * Remove Actor
# actor_id : actor ID
#--------------------------------------------------------------------------
def remove_actor(actor_id)
party_changer_remove_actor(actor_id)
remove_member(actor_id)
end
#--------------------------------------------------------------------------
# * Add a Member
# actor_id : actor ID
#--------------------------------------------------------------------------
def add_member(actor_id)
# Get actor
actor = $game_actors[actor_id]
# If this actor is not in the party
if not @members.include?(actor)
# Add member
@members.push(actor)
# Refresh player
$game_player.refresh
end
#--------------------------------------------------------------------------
# * Determine Every Members are Dead
#--------------------------------------------------------------------------
def members_all_dead?
available_members = []
for i in 0...@members.size
next if @members[i].locked
available_members << @members[i]
end
# If number of party members is 0
if $game_party.members.size == 0
return false
end
# If an actor is in the party with 0 or more HP
for member in available_members
if member.hp > 0
return false
end
end
# All members dead
return true
end
end
#--------------------------------------------------------------------------
# * Remove Member
# actor_id : actor ID
#--------------------------------------------------------------------------
def remove_member(actor_id)
# Delete member
@members.delete($game_actors[actor_id])
# Refresh player
$game_player.refresh
end
end
#==============================================================================
# ** Window_Base
#------------------------------------------------------------------------------
# This class is for all in-game windows.
#==============================================================================
class Window_Base < Window
#--------------------------------------------------------------------------
# * Draw Actor Position
# actor : actor
# x : draw spot x-coordinate
# y : draw spot y-coordinate
#--------------------------------------------------------------------------
def draw_actor_position(actor, x, y)
position = actor.position
case position
when 0
text = 'Front'
when 1
text = 'Middle'
when 2
text = 'Back'
end
cx = contents.text_size(text).width
self.contents.draw_text(x,y,cx,32,text)
end
end
#==============================================================================
# ** Window_MemberStatus
#------------------------------------------------------------------------------
# This window displays a member's status on the party screen.
#==============================================================================
class Window_MemberStatus < Window_Base
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :actor # actor
#--------------------------------------------------------------------------
# * Object Initialization
# actor : actor
#--------------------------------------------------------------------------
def initialize(actor)
super(0, 64, 640, 160)
self.contents = Bitmap.new(width - 32, height - 32)
if $game_temp.in_battle
self.back_opacity = 160
end
@actor = actor
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh(current = 1, max = 1)
self.contents.clear
return if @actor.nil?
draw_actor_name(@actor, 0, 0)
draw_actor_class(@actor, 144, 0)
draw_actor_position(@actor, 300, 0)
draw_actor_level(@actor, 0, 32)
draw_actor_state(@actor, 90, 32)
draw_actor_exp(@actor, 0, 64)
draw_actor_hp(@actor, 236, 32)
draw_actor_sp(@actor, 236, 64)
draw_actor_parameter(@actor, 396, 0, 0)
draw_actor_parameter(@actor, 396, 32, 1)
draw_actor_parameter(@actor, 396, 64, 2)
if $game_temp.selected_members.include?(@actor)
self.contents.draw_text(0,96,640,32,"- #{@actor.name} is already in your party.")
elsif $game_actors[@actor.id].locked
self.contents.draw_text(0,96,640,32,"- #{@actor.name} is not available.")
else
self.contents.draw_text(0,96,640,32,"- #{@actor.name} is available.")
end
self.contents.draw_text(480,96,160,32,"Page #{current} of #{max}")
end
end
#==============================================================================
# ** Window_PartyMembers
#------------------------------------------------------------------------------
# This window displays the party members on the party screen.
#==============================================================================
class Window_PartyMembers < Window_Selectable
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :members # members
attr_accessor :selected_members # selected members
attr_accessor :forced_members # forced members
#--------------------------------------------------------------------------
# * Oject Initialization
#--------------------------------------------------------------------------
def initialize(forced_members=[])
@members = $game_party.members
height = 78 + (@members.size/4) * 50
super(0,224,640,height)
self.contents = Bitmap.new(width - 32, height - 32)
self.active = true
if $game_temp.in_battle
self.back_opacity = 160
end
@index = 0
@item_max = @members.size
@column_max = 4
@row_max = @members.size / 4
@selected_members = []
@forced_members = forced_members
reset
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...@members.size
x = (i % 4) * 160
y = (i/4) * 50
actor = @members[i]
selected = @selected_members[i]
# A1
opacity = selected == true ? 128 : 255
if $game_temp.use_custom_graphic
bitmap = RPG::Cache.picture("Actor_#{actor.name}")
src_rect = bitmap.rect
dest_rect = Rect.new(x+2, y+2, 124, 46)
self.contents.stretch_blt(dest_rect, bitmap, src_rect, opacity)
else
draw_actor_graphic($game_actors[actor.id], x+60, y+48, selected)
end
end
end
#--------------------------------------------------------------------------
# * Reset
#--------------------------------------------------------------------------
def reset
if $game_temp.multiple_teams
team_id = $game_temp.current_team[0]
members = $game_temp.current_team[1]
forced_members = []
for i in 0...$game_temp.multiple_teams_args.size
forced_members += $game_temp.multiple_teams_args[i][2]
end
for i in 0...@members.size
if members.include?(@members[i])
@selected_members[i] = false
end
if forced_members.include?(@members[i].id)
@selected_members[i] = true
end
if @members[i].locked
@selected_members[i] = true
end
end
else
for i in 0...@members.size
@selected_members[i] = false
if @forced_members.include?(@members[i])
@selected_members[i] = true
end
if @members[i].locked
@selected_members[i] = true
end
end
end
refresh
end
#--------------------------------------------------------------------------
# * Cursor Rectangle Update
#--------------------------------------------------------------------------
def update_cursor_rect
self.oy = (@index/8) * 100
x = (@index % 4) * 160
y = ((@index/4)% 2) * 50
self.cursor_rect.set(x, y, 128, 50)
end
end
#==============================================================================
# ** Window_Party
#------------------------------------------------------------------------------
# This window displays the current party on the party screen.
#==============================================================================
class Window_Party < Window_Selectable
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :item_max # item max
attr_accessor :members # members
attr_accessor :forced_members # forces members
attr_accessor :selected_members # selected members
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(forced_members=[])
super(0,352,320,128)
self.contents = Bitmap.new(width - 32, height - 32)
self.active = false
@index = 0
@column_max = 2
@row_max = 2
@members = []
@forced_members = forced_members
@selected_members = []
@item_max = @members.size
reset_selection
reset_members
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
height = 128 + ((@members.size-1)/4) * 100
self.contents = Bitmap.new(width - 32, height - 32)
self.height = 128
for i in 0...@members.size
x = (i % 2) * 160
y = (i/2) * 50
actor = @members[i]
next if actor.nil?
# A2
if $game_temp.use_custom_graphic
opacity = @selected_members[i] == true ? 128 : 255
bitmap = RPG::Cache.picture("Actor_#{actor.name}")
src_rect = bitmap.rect
dest_rect = Rect.new(x+2, y+2, 124, 46)
self.contents.stretch_blt(dest_rect, bitmap, src_rect, opacity)
else
opacity = @selected_members[i]
draw_actor_graphic($game_actors[actor.id], x+60, y+48,opacity)
end
end
end
#--------------------------------------------------------------------------
# * Reset Selection
#--------------------------------------------------------------------------
def reset_selection
for i in 0...@members.size
@selected_members[i] = false
end
refresh
end
#--------------------------------------------------------------------------
# * Reset Members
#--------------------------------------------------------------------------
def reset_members
@members = []
@forced_members.each do |member|
# NIL M
#next if member.nil?
@members << member
end
refresh
end
#--------------------------------------------------------------------------
# * Cursor Rectangle Update
#--------------------------------------------------------------------------
def update_cursor_rect
return unless self.active
self.oy = (@index/4) * 100
x = (@index % 2) * 160
y = ((@index/2)% 2) * 50
self.cursor_rect.set(x, y, 128, 50)
end
end
#==============================================================================
# ** Window_PartyCommand
#------------------------------------------------------------------------------
# This window is used to select whether to fight or escape on the battle
# screen.
#==============================================================================
class Window_PartyCommand < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0, 640, 64)
self.contents = Bitmap.new(width - 32, height - 32)
self.back_opacity = 160
if $game_temp.party_changer_in_battle
@commands = ["Fight", "Escape", "Party"]
@item_max = 3
@column_max = 3
else
@commands = ["Fight", "Escape"]
@item_max = 2
@column_max = 2
end
# Draw Fight and Escape
draw_item(0, normal_color)
draw_item(1, $game_temp.battle_can_escape ? normal_color : disabled_color)
# Draw Party if $game_temp.party_changer_in_battle is true
draw_item(2, normal_color) if $game_temp.party_changer_in_battle
self.active = false
self.visible = false
self.index = 0
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
# color : text character color
#--------------------------------------------------------------------------
def draw_item(index, color)
self.contents.font.color = color
if $game_temp.party_changer_in_battle
rect = Rect.new(106 + index * 106 + 4, 0, 128 - 10, 32)
else
rect = Rect.new(160 + index * 160 + 4, 0, 128 - 10, 32)
end
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.draw_text(rect, @commands[index], 1)
end
#--------------------------------------------------------------------------
# * Cursor Rectangle Update
#--------------------------------------------------------------------------
def update_cursor_rect
if $game_temp.party_changer_in_battle
self.cursor_rect.set(106 + index * 106, 0, 128, 32)
else
self.cursor_rect.set(160 + index * 160, 0, 128, 32)
end
end
end
#==============================================================================
# ** Scene_Battle (part 2)
#------------------------------------------------------------------------------
# This class performs battle screen processing.
#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
# * Alias Listing
#--------------------------------------------------------------------------
alias party_changer_update_phase2 update_phase2
alias party_changer_start_phase5 start_phase5
alias party_changer_update update
#--------------------------------------------------------------------------
# * Frame Update (party command phase)
#--------------------------------------------------------------------------
def update_phase2
party_changer_update_phase2
# If C button was pressed
if Input.trigger?(Input::C)
# Branch by party command window cursor position
case @party_command_window.index
when 2 # escape
# If it's not possible to escape
if $game_temp.party_changer_in_battle == false
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Escape processing
start_party_changer
end
return
end
end
#--------------------------------------------------------------------------
# * Start After Battle Phase
#--------------------------------------------------------------------------
def start_phase5
party_changer_start_phase5
exp = 0
# Loop
for enemy in $game_troop.enemies
# If enemy is not hidden
unless enemy.hidden
# Add EXP obtained
exp += enemy.exp
end
end
# Obtaining EXP
for i in 0...$game_party.members.size
return if $game_temp.members_gain_exp == false
member = $game_party.members[i]
next if $game_party.actors.include?(member)
if member.cant_get_exp? == false
member.exp += (exp/100) * $game_temp.members_exp_rate
end
end
end
#--------------------------------------------------------------------------
# * Start Party Changer Phase
#--------------------------------------------------------------------------
def start_party_changer
# Get actor
@actor = $game_party.members[0]
@min_actors = $game_temp.battle_party_args[0]
@max_actors = $game_temp.battle_party_args[1]
@forced_members = []
forced_members = $game_temp.battle_party_args[2]
for i in 0...$game_temp.battle_party_args[2].size
member = $game_temp.battle_party_args[2][i]
if member.nil?
@forced_members << member
else
@forced_members << $game_actors[member]
end
end
@lock_members = $game_temp.battle_party_args[3]
# Make windows
@party_status_window = Window_MemberStatus.new(@actor)
@members_window = Window_PartyMembers.new(@forced_members)
page_id = ((@members_window.index/8)+1).round
max_page = (@members_window.members.size.to_f/8.0)
max_page = 1 if max_page == 0
@party_status_window.refresh(page_id, max_page.ceil)
# Defined the height to make the window scroll
@members_window.height = 128
@party_window = Window_Party.new(@forced_members)
@party_command_window2 = Window_Command.new(320,['Reset','Confirm','Organise'])
@party_command_window2 .active = false
@party_command_window2.x = 320
@party_command_window2.y = 352
# Hide @status_window contents
@status_window.hide_battlers = true
for i in @spriteset.actor_sprites
i.visible = false
end
@members_window.active = true
@party_command_window.active = false
@party_command_window.visible = false
# Shift phase
@phase = 6
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Original method
party_changer_update
case @phase
when 6
update_party_changer
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (Party Changer)
#--------------------------------------------------------------------------
def update_party_changer
@party_window.update
@members_window.update
@party_command_window2.update
$game_temp.selected_members = @party_window.members.dup
if @party_window.members.size == 0
@party_command_window2.disable_item(1)
@party_command_window2.disable_item(2)
else
@party_command_window2.enable_item(1)
@party_command_window2.enable_item(2)
end
if @party_command_window2.active
update_party_changer_command
end
if @party_window.active
update_party
end
if @members_window.active
update_members
end
end
#--------------------------------------------------------------------------
# * Frame Update (if party changer's command window is active)
#--------------------------------------------------------------------------
def update_party_changer_command
@party_window.cursor_rect.empty
case @party_command_window2.index
when 0
@help_window.set_text('Reselect Team Selection')
when 1
@help_window.set_text('Accept Team Selection')
when 2
@help_window.set_text('Organise Team Selection')
end
if Input.trigger?(Input::C)
case @party_command_window2.index
when 0
@members_window.reset
@party_window.reset_selection
@party_window.reset_members
@party_command_window2.active = false
@members_window.active = true
$game_temp.selected_members.clear
@reset = true
return
when 1
if @party_window.members.size < @min_actors
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
$game_party.actors.clear
@party_window.members.each do |actor|
$game_party.add_actor(actor.id)
end
@members_window.active = false
@party_command_window2.active = false
@party_status_window.active = false
@party_window.active = false
@members_window.visible = false
@party_command_window2.visible = false
@party_status_window.visible = false
@party_window.visible = false
@party_command_window.visible = true
@party_command_window.active = true
for i in 0...$game_party.actors.size
@spriteset.actor_sprites[i].visible = true
end
@help_window.visible = false
@status_window.hide_battlers = false
@status_window.refresh
@phase = 2
return
when 2
if @party_window.members.size == 0
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
@party_command_window2.active = false
@party_window.active = true
@party_window.index = 0
@reset = true
return
end
end
end
#--------------------------------------------------------------------------
# * Frame Update (if party window is active)
#--------------------------------------------------------------------------
def update_party
@party_window.item_max = @party_window.members.size
if @reset
@reset = false
return
end
if Input.trigger?(Input::B)
@party_command_window2.active = true
@party_window.active = false
@party_window.index = -3
@change1 = nil
@change2 = nil
@party_window.reset_selection
return
end
@help_window.set_text('Change the position of your Sailor Scouts.')
if @party_status_window.actor != @party_window.members[@party_window.index]
@party_status_window.actor = @party_window.members[@party_window.index]
@party_status_window.refresh
end
if Input.trigger?(Input::C) and @change1 == nil
@temp_change1 = @party_window.members[@party_window.index]
if @lock_members.include?(@temp_change1.id)# and @party_window.index == 0
$game_system.se_play($data_system.buzzer_se)
return
end
@change1 = @party_window.members[@party_window.index]
@old_index = @party_window.index
@party_window.selected_members[@party_window.index] = true
@party_window.refresh
elsif Input.trigger?(Input::C) and @change1 != nil
@temp_change2 = @party_window.members[@party_window.index]
if @lock_members.include?(@temp_change2.id)# and @party_window.index == 0
$game_system.se_play($data_system.buzzer_se)
return
end
@change2 = @party_window.members[@party_window.index]
@party_window.members[@party_window.index] = @change1
@party_window.members[@old_index] = @change2
@change1 = nil
@change2 = nil
@party_window.reset_selection
end
end
#--------------------------------------------------------------------------
# * Frame Update (party members)
#--------------------------------------------------------------------------
def update_members
@party_window.cursor_rect.empty
if @reset
@reset = false
return
end
@help_window.set_text('Choose your Sailor Scout party members.')
if @party_status_window.actor != @members_window.members[@members_window.index]
@party_status_window.actor = @members_window.members[@members_window.index]
page_id = ((@members_window.index/8)+1).round
max_page = (@members_window.members.size.to_f/8.0)
max_page = 1 if max_page == 0
@party_status_window.refresh(page_id, max_page.ceil)
end
if @party_window.members.size == @max_actors
@party_command_window2.active = true
@members_window.active = false
return
end
if Input.trigger?(Input::B)
@party_command_window2.active = true
@members_window.active = false
return
end
if Input.trigger?(Input::C)
return if @members_window.members[@members_window.index].locked
if @party_window.members.size < @max_actors and
not @party_window.members.include?(@members_window.members[@members_window.index])
for i in 0...@max_actors
actor = @members_window.members[@members_window.index]
next if @party_window.members[i] != nil
next if @party_window.members.include?(actor)
@members_window.selected_members[@members_window.index] = true
@members_window.refresh
@status_window.refresh
@party_window.members[i] = actor
@party_window.refresh
end
return
end
end
end
end
#==============================================================================
# ** Window_BattleStatus
#------------------------------------------------------------------------------
# This window displays the status of all party members on the battle screen.
#==============================================================================
class Window_BattleStatus < Window_Base
attr_accessor :hide_battlers
alias hide_battlers_initialize initialize
def initialize
@hide_battlers = false
hide_battlers_initialize
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
if @hide_battlers
self.contents_opacity = 0
return
else
self.contents_opacity = 255
end
# Slightly lower opacity level during main phase
if $game_temp.battle_main_phase
self.contents_opacity -= 4 if self.contents_opacity > 191
else
self.contents_opacity += 4 if self.contents_opacity < 255
end
end
end
#==============================================================================
# ** Spriteset_Battle
#------------------------------------------------------------------------------
# This class brings together battle screen sprites. It's used within
# the Scene_Battle class.
#==============================================================================
class Spriteset_Battle
attr_accessor :actor_sprites
end
#==============================================================================
# ** Scene_Party
#------------------------------------------------------------------------------
# This class performs party menu screen processing.
#==============================================================================
class Scene_Party
#--------------------------------------------------------------------------
# * Object Initialization
# actor_index : command cursor's initial position
# forced_members : members forced to be in the party
#--------------------------------------------------------------------------
def initialize(min_actors = 1, max_actors = 5, forced_members = [], lock_members = [1], from_menu=false)
@min_actors = []
@max_actors = []
@forced_members = []
@lock_members = [1]
@from_menu = from_menu
if $game_temp.multiple_teams and not @from_menu
for i in 0...$game_temp.multiple_teams_args.size
@forced_members[i] = []
@min_actors[i] = $game_temp.multiple_teams_args[i][0]
@max_actors[i] = $game_temp.multiple_teams_args[i][1]
forced_members = $game_temp.multiple_teams_args[i][2]
@lock_members[i] = $game_temp.multiple_teams_args[i][3]
forced_members.each do |member|
if member.nil?
@forced_members[i] << member
else
$game_party.add_member(member)
@forced_members[i] << $game_actors[member]
end
end
end
else
@min_actors[0] = min_actors
@max_actors[0] = max_actors
@forced_members[0] = []
@lock_members[0] = lock_members
forced_members.each do |member|
if member.nil?
@forced_members[0] << member
else
$game_party.add_member(member)
@forced_members[0] << $game_actors[member]
end
end
end
end
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Get actor
@actor = $game_party.members[0]
# Make help window, status window, and skill window
@help_window = Window_Help.new
@status_window = Window_MemberStatus.new(@actor)
@members_window = Window_PartyMembers.new(@forced_members[0])
page_id = ((@members_window.index/8)+1).round
max_page = (@members_window.members.size.to_f/8.0)
max_page = 1 if max_page == 0
@status_window.refresh(page_id, max_page.ceil)
teams = []
for i in 0...$game_temp.multiple_teams_args.size
teams << "Team #{i+1}"
end
# Defined the height to make the window scroll
@members_window.height = 128
@team_windows = []
@team_windows << Window_Party.new(@forced_members[0])
if $game_temp.multiple_teams and not @from_menu
for i in 1...$game_temp.multiple_teams_args.size
@team_windows << Window_Party.new(@forced_members[i])
@team_windows[i].visible = false
end
end
commands = ['Reset','Confirm','Organise']
commands << 'Change Team' if $game_temp.multiple_teams and not @from_menu
@command_window = Window_Command.new(320,commands)
@command_window.x = 320
@command_window.y = 352
@command_window.height = 3 * 32 + 32
@command_window.active = false
@reset = false
teams = [''] if teams.empty?
@team_selection_window = Window_Command.new(160, teams)
@team_selection_window.x = 480
@team_selection_window.height = 64
@team_selection_window.active = false
@team_selection_window.visible = $game_temp.multiple_teams
# Execute transition
Graphics.transition
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
if $scene != self
break
end
end
# Prepare for transition
Graphics.freeze
# Dispose of windows
@help_window.dispose
@status_window.dispose
@members_window.dispose
@command_window.dispose
@team_selection_window.dispose
for window in @team_windows
window.dispose
end
end
def active_team_window
return @team_windows[team_index]
end
def team_index
return @team_selection_window.index
end
def confirmation_enabled?
i = 0
for team_window in @team_windows
temp_members = team_window.members.dup
temp_members.delete(nil)
if temp_members.size < @min_actors[i]
return false
end
if temp_members[0].nil?
return false
end
if temp_members.empty?
return false
else
i += 1
next
end
return true
end
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
@party_window = active_team_window
@members_window.update
@command_window.update
@team_selection_window.update
for i in 0...@team_windows.size
@team_windows[i].update
@team_windows[i].visible = false
if i == team_index
@team_windows[i].visible = true
end
end
$game_temp.current_team = [team_index, active_team_window.members]
$game_temp.selected_members = []
for team_window in @team_windows
$game_temp.selected_members += team_window.members.dup
end
if $game_temp.multiple_teams and not @from_menu
if confirmation_enabled?
@command_window.enable_item(1)
else
@command_window.disable_item(1)
end
else
if @party_window.members.size == 0
@command_window.disable_item(1)
@command_window.disable_item(2)
else
@command_window.enable_item(1)
@command_window.enable_item(2)
end
end
if @team_selection_window.active
update_teams
return
end
if @command_window.active
update_command
return
end
if @party_window.active
update_party
return
end
if @members_window.active
update_members
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (if command team is active)
#--------------------------------------------------------------------------
def update_teams
@help_window.set_text('Choose a team.')
if Input.trigger?(Input::C)
@team_selection_window.active = false
@members_window.active = true
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (if command window is active)
#--------------------------------------------------------------------------
def update_command
@party_window.cursor_rect.empty
case @command_window.index
when 0
@help_window.set_text('Reset party members')
when 1
@help_window.set_text('Confirm party selection')
when 2
@help_window.set_text('Arrange party members')
when 3
@help_window.set_text('Choose another team')
end
if Input.trigger?(Input::C)
case @command_window.index
when 0
@members_window.reset
@party_window.reset_selection
@party_window.reset_members
@command_window.active = false
@members_window.active = true
$game_temp.selected_members.clear
@reset = true
return
when 1
if @party_window.members.size < @min_actors[team_index]
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
for team_window in @team_windows
temp_members = team_window.members.dup
temp_members.delete(nil)
if temp_members.empty?
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
@help_window.set_text("You must form #{@team_windows.size} teams!")
return
end
end
unless confirmation_enabled?
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
$game_party.actors.clear
if $game_temp.multiple_teams and not @from_menu
@team_windows[0].members.each do |actor|
$game_party.add_actor(actor.id)
end
for i in 0...@team_windows.size
location = $game_temp.teams_destination[i]
members = @team_windows[i].members.dup
$game_party.setup_teams(i, members, location)
end
$game_temp.current_team = [0, @team_windows[0].members]
else
@party_window.members.each do |actor|
$game_party.add_actor(actor.id)
end
$game_temp.current_team = [0, @party_window.members]
end
if $game_temp.multiple_teams
$game_map.setup($game_map.map_id)
$game_player.center($game_player.x, $game_player.y)
end
if @from_menu
$scene = Scene_Menu.new
else
$scene = Scene_Map.new
end
return
when 2
if @party_window.members.size == 0
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
@command_window.active = false
@party_window.active = true
@party_window.index = 0
@reset = true
return
when 3
@command_window.active = false
@team_selection_window.active = true
return
end
end
end
#--------------------------------------------------------------------------
# * Frame Update (if party window is active)
#--------------------------------------------------------------------------
def update_party
@party_window.item_max = @party_window.members.size
if @reset
@reset = false
return
end
if Input.trigger?(Input::B)
@command_window.active = true
@party_window.active = false
@party_window.index = -1
@party_window.oy = 0
@change1 = nil
@change2 = nil
@party_window.reset_selection
return
end
@help_window.set_text('Change members position')
if @status_window.actor != @party_window.members[@party_window.index]
@status_window.actor = @party_window.members[@party_window.index]
@status_window.refresh
end
if Input.trigger?(Input::C) and @change1 == nil
@temp_change1 = @party_window.members[@party_window.index]
if @lock_members[team_index].include?(@temp_change1.id)# and @party_window.index == 0
$game_system.se_play($data_system.buzzer_se)
return
end
@change1 = @party_window.members[@party_window.index]
@old_index = @party_window.index
@party_window.selected_members[@party_window.index] = true
@party_window.refresh
elsif Input.trigger?(Input::C) and @change1 != nil
@temp_change2 = @party_window.members[@party_window.index]
if @lock_members[team_index].include?(@temp_change2.id)# and @party_window.index == 0
$game_system.se_play($data_system.buzzer_se)
return
end
@change2 = @party_window.members[@party_window.index]
@party_window.members[@party_window.index] = @change1
@party_window.members[@old_index] = @change2
@change1 = nil
@change2 = nil
@party_window.reset_selection
end
end
#--------------------------------------------------------------------------
# * Frame Update (party members)
#--------------------------------------------------------------------------
def update_members
@party_window.cursor_rect.empty
if @reset
@reset = false
return
end
@help_window.set_text('Form your party')
if @status_window.actor != @members_window.members[@members_window.index]
@status_window.actor = @members_window.members[@members_window.index]
page_id = ((@members_window.index/8)+1).round
max_page = (@members_window.members.size.to_f/8.0)
max_page = 1 if max_page == 0
@status_window.refresh(page_id, max_page.ceil)
end
if @party_window.members.size == @max_actors[team_index]
@command_window.active = true
@members_window.active = false
return
end
if Input.trigger?(Input::B)
@command_window.active = true
@members_window.active = false
return
end
if Input.trigger?(Input::C)
member = @members_window.members[@members_window.index]
return if member.locked
if @party_window.members.size < @max_actors[team_index] and
not @party_window.members.include?(member) and
not $game_temp.selected_members.include?(member)
for i in 0...@max_actors[team_index]
actor = @members_window.members[@members_window.index]
next if @party_window.members[i] != nil
next if @party_window.members.include?(actor)
@members_window.selected_members[@members_window.index] = true
@members_window.refresh
@status_window.refresh
@party_window.members[i] = actor
@party_window.refresh
end
return
end
end
end
end
#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
# This class performs map screen processing.
#==============================================================================
class Scene_Map
alias multiple_teams_update update
def update
multiple_teams_update
if $game_temp.multiple_teams
if Input.trigger?(Input::L)
$game_party.save_team_data
$game_temp.current_team[0] += 1
$game_temp.current_team[0] %= $game_temp.multiple_teams_args.size
$game_party.switch($game_temp.current_team[0])
# Prepare for transition
Graphics.freeze
# Set transition processing flag
$game_temp.transition_processing = true
$game_temp.transition_name = ""
transfer_player
elsif Input.trigger?(Input::R)
$game_party.save_team_data
$game_temp.current_team[0] += $game_temp.multiple_teams_args.size - 1
$game_temp.current_team[0] %= $game_temp.multiple_teams_args.size
$game_party.switch($game_temp.current_team[0])
# Prepare for transition
Graphics.freeze
# Set transition processing flag
$game_temp.transition_processing = true
$game_temp.transition_name = ""
transfer_player
end
end
end
#--------------------------------------------------------------------------
# * Player Place Move
#--------------------------------------------------------------------------
alias mp_transfer_player transfer_player
def transfer_player
if $game_map.map_id == $game_temp.player_new_map_id
# Set up a new map
$game_map.setup_parties
end
$game_map.setup_parties
mp_transfer_player
end
end
#==============================================================================
# ** Game_Character (part 1)
#------------------------------------------------------------------------------
# This class deals with characters. It's used as a superclass for the
# Game_Player and Game_Event classes.
#==============================================================================
class Game_Character
alias dargor_multiple_parties_passable? passable?
#--------------------------------------------------------------------------
# * Determine if Passable
# x : x-coordinate
# y : y-coordinate
# d : direction (0,2,4,6,8)
# * 0 = Determines if all directions are impassable (for jumping)
#--------------------------------------------------------------------------
def passable?(x, y, d)
# Get new coordinates
new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
# Loop all events
for event in $game_map.party_leaders
next if event.nil?
# If event coordinates are consistent with move destination
if event.x == new_x and event.y == new_y
# If through is OFF
unless event.through
# If self is event
if self != $game_player
# impassable
return false
end
# With self as the player and partner graphic as character
if event.character_name != ""
# impassable
return false
end
end
end
end
dargor_multiple_parties_passable?(x, y, d)
end
end
#============================================================================
# ** Game_Character
#----------------------------------------------------------------------------
# This class deals with characters. It's used as a superclass for the
# Game_Player and Game_Event classes.
#============================================================================
class Game_PartyLeader < Game_Character
def initialize(team_id)
super()
@team_id = team_id
# Get lead actor
actor = $game_party.team_members[@team_id][0]
x = $game_party.team_location[@team_id][0]
y = $game_party.team_location[@team_id][1]
# Set character file name and hue
@character_name = actor.character_name
@character_hue = actor.character_hue
moveto(x,y)
end
def update
@direction = $game_party.team_location[@team_id][3]
super
end
end
#==============================================================================
# ** Game_Map
#------------------------------------------------------------------------------
# This class handles the map. It includes scrolling and passable determining
# functions. Refer to "$game_map" for the instance of this class.
#==============================================================================
class Game_Map
attr_accessor :party_leaders
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias dargor_multiple_parties_setup setup
#--------------------------------------------------------------------------
# * Setup
# map_id : map ID
#--------------------------------------------------------------------------
def setup(map_id)
dargor_multiple_parties_setup(map_id)
setup_parties
end
def setup_parties
# Set map parties data
@party_leaders = []
for i in 0...$game_temp.multiple_teams_args.size
next if i == $game_temp.current_team[0]
next if $game_party.team_location[i].nil?
unless $game_party.team_location.empty?
if $game_party.team_location[i][2] == @map_id
@party_leaders[i] = Game_PartyLeader.new(i)
end
end
end
end
end
#==============================================================================
# ** Spriteset_Map
#------------------------------------------------------------------------------
# This class brings together map screen sprites, tilemaps, etc.
# It's used within the Scene_Map class.
#==============================================================================
class Spriteset_Map
alias dargor_multiple_parties_initialize initialize
alias dargor_multiple_parties_update update
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
@initialized = false
dargor_multiple_parties_initialize
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
unless @initialized
@new_character_sprites = []
# Make viewports
for i in 0...$game_map.party_leaders.size
next if $game_map.party_leaders[i].nil?
sprite = Sprite_Character.new(@viewport1, $game_map.party_leaders[i])
@new_character_sprites.push(sprite)
end
@initialized = true
end
dargor_multiple_parties_update
for sprite in @new_character_sprites
sprite.update
end
end
end