+- Save-Point (https://www.save-point.org)
+-- Forum: Material Development (https://www.save-point.org/forum-8.html)
+--- Forum: Scripts Database (https://www.save-point.org/forum-39.html)
+---- Forum: RPGMaker XP (RGSS) Engine (https://www.save-point.org/forum-116.html)
+---- Thread: Multiple Parties (/thread-2455.html)
Multiple Parties - Dargor - 03-07-2008
Multiple Parties by Dargor Version 1.1
Introduction
This script let you have as many parties as you want. Parties have their own inventory, gold, steps, members, etc. It can be used to make special dungeons that requires more parties like in Final Fantasy 6. Also, this script is independent from the Custom Commands and Party Changer scripts. However, this script will gain features when used with the latest version of my Party Changer (version 3.1).
Features
You can have as many parties as you want
Parties have their own inventory, gold, steps, members, etc.
#==============================================================================
# ** Large Party Configuration Module
#==============================================================================
module Multiple_Parties
Next_Party_Key = Input::F5
Prior_Party_Key = Input::F6
end
#==============================================================================
# ** Game_Parties
#------------------------------------------------------------------------------
# This class handles the party array. The instance of this class is
# referenced by $game_parties.
#==============================================================================
class Game_Parties
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :data
attr_accessor :temp_actors
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
@data = [$game_party]
@actors = []
@reserve_actors = []
@temp_actors = []
end
#--------------------------------------------------------------------------
# * Get Party
#--------------------------------------------------------------------------
def [](party_id)
@data[party_id] = Game_Party.new if @data[party_id].nil?
return @data[party_id]
end
#--------------------------------------------------------------------------
# * Set Party
#--------------------------------------------------------------------------
def []=(party_id, party)
return if party_id == 0
@data[party_id] = party
end
#--------------------------------------------------------------------------
# * Set Party
#--------------------------------------------------------------------------
def size
return @data.size
end
#--------------------------------------------------------------------------
# * Delete
#--------------------------------------------------------------------------
def delete(party_id)
return if party_id == 0
@data.delete(@data[party_id])
@data.compact!
end
#--------------------------------------------------------------------------
# * Create Parties
#--------------------------------------------------------------------------
def create_parties(max, delete=true)
for i in 1..max
if delete
@data[i] = Game_Party.new
end
end
end
#--------------------------------------------------------------------------
# * Clear Parties
#--------------------------------------------------------------------------
def clear_parties
for party in @data
next if @data.index(party) == 0
@data.delete(party)
end
end
#--------------------------------------------------------------------------
# * Next Party
#--------------------------------------------------------------------------
def next_party
return if @data.size <= 1
$game_party.set_position
new_index = $game_party.index
# Find the next party
loop do
new_index = (new_index - 1) % @data.size
break if @data[new_index] != nil
end
new_party = @data[new_index]
# Update party location & Graphics
map_id = new_party.map_id
map_x = new_party.map_x
map_y = new_party.map_y
direction = new_party.direction
$game_party = new_party
$game_player.reserve_transfer(map_id, map_x, map_y, direction)
end
#--------------------------------------------------------------------------
# * Prior Party
#--------------------------------------------------------------------------
def prior_party
return if @data.size <= 1
$game_party.set_position
new_index = $game_party.index
# Find the previous party
loop do
new_index = (new_index + 1)
new_index %= @data.size
break if @data[new_index] != nil
end
new_party = @data[new_index]
# Update party location & Graphics
map_id = new_party.map_id
map_x = new_party.map_x
map_y = new_party.map_y
direction = new_party.direction
$game_party = new_party
$game_player.reserve_transfer(map_id, map_x, map_y, direction)
end
#--------------------------------------------------------------------------
# * Add Actor
#--------------------------------------------------------------------------
def add_actor(actor_id)
add_reserve_actor(actor_id)
return if @actors.include?(actor_id)
@actors << actor_id
@actors.sort
end
#--------------------------------------------------------------------------
# * Remove Actor
#--------------------------------------------------------------------------
def remove_actor(actor_id)
@actors.delete(actor_id)
@actors.sort
end
#--------------------------------------------------------------------------
# * Get Members
#--------------------------------------------------------------------------
def members
result = []
for actor_id in @actors
result << $game_actors[actor_id]
end
return result.uniq
end
#--------------------------------------------------------------------------
# * Add Reserve Actor
#--------------------------------------------------------------------------
def add_reserve_actor(actor_id)
return if @reserve_actors.include?(actor_id)
@reserve_actors << actor_id
@reserve_actors.sort
end
#--------------------------------------------------------------------------
# * Remove Reserve Actor
#--------------------------------------------------------------------------
def remove_reserve_actor(actor_id)
@reserve_actors.delete(actor_id)
@reserve_actors.sort
end
#--------------------------------------------------------------------------
# * Get Reserve Members
#--------------------------------------------------------------------------
def reserve_members
result = []
for actor_id in @reserve_actors
result << $game_actors[actor_id]
end
return result.uniq
end
#--------------------------------------------------------------------------
# * Get All Members
#--------------------------------------------------------------------------
def all_members
all_actors = (@actors + @reserve_actors).sort
result = []
for i in all_actors
result << $game_actors[i]
end
return result.uniq
end
#--------------------------------------------------------------------------
# * Clear Temporary Actors Array
#--------------------------------------------------------------------------
def clear_temp_actors
@temp_actors = []
end
end
#==============================================================================
# ** Game_System
#------------------------------------------------------------------------------
# This class handles system-related data. Also manages vehicles and BGM, etc.
# The instance of this class is referenced by $game_system.
#==============================================================================
class Game_System
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :multiple_parties
#--------------------------------------------------------------------------
# * Alias Listing
#--------------------------------------------------------------------------
alias dargor_vx_multiple_parties_system_initialize initialize
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
dargor_vx_multiple_parties_system_initialize
@multiple_parties = false
end
end
#==============================================================================
# ** Game_Player
#------------------------------------------------------------------------------
# This class handles maps. It includes event starting determinants and map
# scrolling functions. The instance of this class is referenced by $game_map.
#==============================================================================
class Game_Player < Game_Character
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :direction
end
#==============================================================================
# ** Game_Party
#------------------------------------------------------------------------------
# This class handles the party. It includes information on amount of gold
# and items. The instance of this class is referenced by $game_party.
#==============================================================================
class Game_Party
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :map_id
attr_reader :map_x
attr_reader :map_y
attr_reader :direction
#--------------------------------------------------------------------------
# * Alias Listing
#--------------------------------------------------------------------------
alias dargor_vx_multiple_parties_party_initialize initialize
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
@map_id = 23
@map_x = 1
@map_y = 1
@direction = 2
dargor_vx_multiple_parties_party_initialize
end
#--------------------------------------------------------------------------
# * Index
#--------------------------------------------------------------------------
def index
return $game_parties.data.index(self)
end
#--------------------------------------------------------------------------
# * Set Position
#--------------------------------------------------------------------------
def set_position
@map_id = $game_map.map_id
@map_x = $game_player.x
@map_y = $game_player.y
@direction = $game_player.direction
end
#--------------------------------------------------------------------------
# * Set New Position
#--------------------------------------------------------------------------
def set_new_position(map_id, x, y, direction)
@map_id = map_id
@map_x = x
@map_y = y
@direction = direction
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 Listing
#--------------------------------------------------------------------------
alias dargor_vx_multiple_parties_spriteset_map_create_characters create_characters
#--------------------------------------------------------------------------
# * Create Character Sprite
#--------------------------------------------------------------------------
def create_characters
dargor_vx_multiple_parties_spriteset_map_create_characters
for party in $game_parties.data
next if $game_party == party
if party.map_id == $game_map.map_id
member = party.members[0]
unless member.nil?
character = Game_Character.new
character.moveto(party.map_x, party.map_y)
character.set_direction(party.direction)
character.set_graphic(member.character_name, member.character_index)
@character_sprites.push(Sprite_Character.new(@viewport1, character))
end
end
end
end
end
#==============================================================================
# ** Game_Character
#------------------------------------------------------------------------------
# This class deals with characters. It's used as a superclass of the
# Game_Player and Game_Event classes.
#==============================================================================
class Game_Character
#--------------------------------------------------------------------------
# * Alias Listing
#--------------------------------------------------------------------------
alias dargor_multiple_parties_character_collide_with_characters? collide_with_characters?
#--------------------------------------------------------------------------
# * Determine Character Collision
# x : x-coordinate
# y : y-coordinate
# Detects normal character collision, including the player and vehicles.
#--------------------------------------------------------------------------
def collide_with_characters?(x, y)
for party in $game_parties.data # Matches event position
if party.map_id == $game_map.map_id
if party.map_x == x && party.map_y == y && party != $game_party
return true
end
end
end
dargor_multiple_parties_character_collide_with_characters?(x, y)
end
end
#==============================================================================
# ** Window_SaveFile
#------------------------------------------------------------------------------
# This window displays save files on the save and load screens.
#==============================================================================
class Window_Party < Window_Base
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :selected # selected
#--------------------------------------------------------------------------
# * Object Initialization
# party_index : party index
#--------------------------------------------------------------------------
def initialize(party_index)
super(0, 112 + party_index % 4 * 76, 544, 76)
@party_index = party_index
@party = $game_parties[party_index]
refresh
@selected = false
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = normal_color
name = sprintf(Vocab::Parties, @party_index + 1)
self.contents.draw_text(4, 0, 200, WLH, name)
@name_width = contents.text_size(name).width
draw_party_characters(152, 38)
end
#--------------------------------------------------------------------------
# * Draw Party Characters
# x : Draw spot X coordinate
# y : Draw spot Y coordinate
#--------------------------------------------------------------------------
def draw_party_characters(x, y)
for i in 0...@party.actors.size
member = @party.members[i]
name = member.character_name
index = member.character_index
draw_character(name, index, x + i * 48, y)
end
end
#--------------------------------------------------------------------------
# * Set Selected
# selected : new selected (true = selected, false = unselected)
#--------------------------------------------------------------------------
def selected=(selected)
@selected = selected
update_cursor
end
#--------------------------------------------------------------------------
# * Update cursor
#--------------------------------------------------------------------------
def update_cursor
if @selected
self.cursor_rect.set(0, 0, @name_width + 8, WLH)
else
self.cursor_rect.empty
end
end
end
#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
# This class performs the map screen processing.
#==============================================================================
class Scene_Map < Scene_Base
#--------------------------------------------------------------------------
# * Alias Listing
#--------------------------------------------------------------------------
alias dargor_vx_parties_scene_map_update update
alias dargor_vx_parties_scene_map_fadeout fadeout
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
if Input.trigger?(Multiple_Parties::Next_Party_Key)
$game_parties.next_party
elsif Input.trigger?(Multiple_Parties::Prior_Party_Key)
$game_parties.prior_party
end
dargor_vx_parties_scene_map_update
end
#--------------------------------------------------------------------------
# * Fade Out Screen
# duration : time
#--------------------------------------------------------------------------
def fadeout(duration)
dargor_vx_parties_scene_map_fadeout(duration)
$game_player.refresh
end
end
#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
# This class performs the multiple party changer screen processing.
#==============================================================================
class Scene_Parties < Scene_Base
#--------------------------------------------------------------------------
# * Start Processing
#--------------------------------------------------------------------------
def start
super
@index = 0
@last_party_index = 0
@item_max = $game_parties.size
create_menu_background
create_help_window
create_command_window
create_party_windows
end
#--------------------------------------------------------------------------
# * Create Help Window
#--------------------------------------------------------------------------
def create_help_window
@help_window = Window_Help.new
multiple = $game_parties.size == 1 ? '' : 's'
text = sprintf(Vocab::FormParties, $game_parties.size, multiple)
@help_window.set_text(text)
end
#--------------------------------------------------------------------------
# * Create Command Window
#--------------------------------------------------------------------------
def create_command_window
s1 = Vocab::PartiesConfirm
s2 = Vocab::PartiesReset
@command_window = Window_Command.new(544, [s1, s2], 2)
@command_window.y = 56
@command_window.active = false
end
#--------------------------------------------------------------------------
# * Start Processing
#--------------------------------------------------------------------------
def create_party_windows
@party_windows = []
for i in 0...$game_parties.size
@party_windows << Window_Party.new(i)
end
@party_windows[0].selected = true
end
#--------------------------------------------------------------------------
# * Terminate Processing
#--------------------------------------------------------------------------
def terminate
super
dispose_menu_background
for window in @party_windows
window.dispose
end
@help_window.dispose
@command_window.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
@command_window.update
if @command_window.active
update_command_selection
else
update_party_selection
for window in @party_windows
window.update
end
end
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def confirmation_enabled?
result = true
for party in $game_parties.data
result &&= party.members.size >= 1
end
return result
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update_command_selection
if Input.trigger?(Input::B)
Sound.play_cancel
@command_window.active = false
return
end
if Input.trigger?(Input::C)
case @command_window.index
when 0
if confirmation_enabled?
Sound.play_decision
$game_party = $game_parties[0]
#$game_player.refresh
$scene = Scene_Map.new
else
Sound.play_buzzer
return
end
when 1
Sound.play_decision
$game_parties.clear_temp_actors
for party in $game_parties.data
party.actors.clear
end
for window in @party_windows
window.refresh
end
end
end
end
#--------------------------------------------------------------------------
# * Update Save File Selection
#--------------------------------------------------------------------------
def update_party_selection
if Input.trigger?(Input::C)
Sound.play_decision
$game_party = $game_parties[@index]
$scene = Scene_PartyChanger.new(false, true)
return
elsif Input.trigger?(Input::B)
Sound.play_cancel
@last_party_index = @index
@command_window.active = true
return
else
last_index = @index
if Input.repeat?(Input::DOWN)
cursor_down(Input.trigger?(Input::DOWN))
end
if Input.repeat?(Input::UP)
cursor_up(Input.trigger?(Input::UP))
end
if @index != last_index
Sound.play_cursor
@party_windows[last_index].selected = false
@party_windows[@index].selected = true
end
end
end
#--------------------------------------------------------------------------
# * Move cursor down
# wrap : Wraparound allowed
#--------------------------------------------------------------------------
def cursor_down(wrap)
if @index < @item_max - 1 or wrap
@index = (@index + 1) % @item_max
end
end
#--------------------------------------------------------------------------
# * Move cursor up
# wrap : Wraparound allowed
#--------------------------------------------------------------------------
def cursor_up(wrap)
if @index > 0 or wrap
@index = (@index - 1 + @item_max) % @item_max
end
end
end
#==============================================================================
# ** Scene_Title
#------------------------------------------------------------------------------
# This class performs the title screen processing.
#==============================================================================
class Scene_Title < Scene_Base
#--------------------------------------------------------------------------
# * Alias Listing
#--------------------------------------------------------------------------
alias dargor_vx_multiple_parties_title_start start
alias dargor_vx_multiple_parties_title_command_new_game command_new_game
#--------------------------------------------------------------------------
# * Start processing
#--------------------------------------------------------------------------
def start
$game_party = Game_Party.new
$game_parties = Game_Parties.new
dargor_vx_multiple_parties_title_start
end
#--------------------------------------------------------------------------
# * Command: New Game
#--------------------------------------------------------------------------
def command_new_game
$game_parties = Game_Parties.new
dargor_vx_multiple_parties_title_command_new_game
end
end