PAC Party Management
Version: 2.0 ?
Author: Pacman
Date: 27/10/2011
Version History
- <Version 2.0 ?> 2011.10.27 - Current release
- Some others
- <Version 1.0> 2011.07.03 - Original Release
Planned Future Versions
- Nothing is currently planned for this script. Suggest something!
Description
VX limits your party to having 4 members. Isn't that terrible? This script won't give you more members in your party, rather be able to change them throughout the game at the player's call. Read the instructions to find out more.
Features
- Party Management Scene
- Uses simple script calls
- Can lock characters into the party
- Can switch characters in and out of the party unless they are locked
- Displays equipment and status in the party scene
- Displays a small version of the character's face
ScreenshotsThe script working with Face/Sprites.
Instructions
Paste above main, below materials, in the script editor (F11). Remember to save upon exiting the editor.
PARTY_NAME is the name of the command that will be displayed if you are using this script with PAC Main Menu, which hasn't been released yet, so it's not really worth mentioning.
PARTY_SWITCH is an input constant that will change the character's display from equip mode to status mode in the party management scene.
The following script calls can be used for the script:
$data_actors[ID].found = true/false # Where ID is the ID of an actor in the database, places said actor in the reserves party where they can be selected by the player if true, and takes them out if false.
$data_actors[ID].unavailable = true/false # If true, makes the actor with the specified ID unavailable to the player in the reserves, if false makes them available.
$data_actors[ID].required = true/false # If true, locks an actor to the active party. If false, unlocks them.
For each of these calls, you may use $game_party.members[position].actor.found/unavailable/required = true/false to apply the call to the actor in the specified position in the party, not the database. Party indexes start at 0.
$game_party.party_menu_disabled = true/false # This will change the access of the command if PAC Main Menu is used. Which isn't very useful because it hasn't been released yet.
$scene = Scene_Party.new # Simply calls the party management scene. There is no command for the scene in the menu by default, but it is quite simple to add.
Script
#===============================================================================
#
# Pacman Advanced Creative (PAC) Engine - Party Management System (2.0 ?)
# 19/6/2011
# Type: Scene
# Installation: Script calls.
# Level: Average
# Thanks: Infinate X
#
#===============================================================================
#
# Description:
# VX limits your party to having 4 members. Isn't that terrible? This script
# won't give you more members in your party, rather be able to change them
# throughout the game at the player's call. Read the instructions to find out
# more.
#
#===============================================================================
#
# Instructions:
# INSTALLATION
# Paste above main, below materials, in the script editor (F11). Make sure you
# save upon exiting.
# SCRIPT CALLS
# $data_actors[ID].found = true/false
# Where ID is the ID of an actor in the database. This places an actor in the
# reserves party, ready for selection by the player if true, and takes them
# out if false.
# $data_actors[ID].unavailable = true/false
# Makes actor with the specified ID unavailable to the player in the reserves
# party if true. If false, makes them available.
# $data_actors[ID].required = true/false
# Locks actor with specified ID to the actual party, ergo mandatory to the
# player, if true. Unlocks the character if false.
# For each of these calls you can use, instead of $data_actors[ID],
# $game_party.members[position].actor.found/unavailable/required to perform
# the action for the actor in that position in the party, starting with 0 as
# the party leader.
# $game_system.party_menu_disabled = true/false
# This will change the access of the command if PAC Main Menu is being used.
# $scene = Scene_Party.new
# Simply calls the Party Management scene. By default, there is no menu option
# for the party scene, but it is simple to add if you are using PAC Main Menu,
# and still quite easy if you are using the default menu system.
#
#===============================================================================
#
# EDITING BEGINS AT LINE XX. DO NOT TOUCH LINES XX-XX.
#
#===============================================================================
module PAC
module MENU
module PARTY
#===============================================================================
#
# BEGIN EDITING
#
#===============================================================================
PARTY_SWITCH = Input::X # Button which will switch between equip and status
# display in the party scene.
PARTY_KILL = Input::Z # Button used to dispose of actors.
DISPOSE_TEXT = "Disband actor" # Text displayed on disband command.
KEEP_TEXT = "Leave alone" # Text displayed on the leave alone command.
PARTY_VARIABLE = 1 # Variable which stores the id of the last acted upon
# actor.
STATUS_WINDOW = Input::Y # Button to toggle status window existance.
START_NO_STATUS = false # false: status window at start. true: no status
# window at start.
MOVE_SPEED = 4 # Speed at which the windows move when opening the status
# window (pixels/second).
ACTOR_TEXT = "Actors"
#===============================================================================
#
# This script requires no editing. Do not edit anything in this script
# unless you are a compenent scripter. Should you edit without any scripting
# education, it may result in me tutting at you for getting it wrong.
#
#===============================================================================
end
end
end
$pac = {} unless $pac
$pac["Party Management"] = [2.0, :gamma]
#==============================================================================
# ** RPG::Actor
#------------------------------------------------------------------------------
# Data class for actors.
#==============================================================================
class RPG::Actor
#--------------------------------------------------------------------------
# Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :found
attr_accessor :unavailable
attr_accessor :required
attr_accessor :disband
#--------------------------------------------------------------------------
# * Setup
#--------------------------------------------------------------------------
def setup
@found = true
@unavailable = false
@required = false
@disband = false
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 :party_menu_disabled
#--------------------------------------------------------------------------
# alias listing
#--------------------------------------------------------------------------
alias pac_party_initialize initialize
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
pac_party_initialize
@party_menu_disabled = false
end
end
#==============================================================================
# ** Game_Actors
#------------------------------------------------------------------------------
# This class handles the actor array. The instance of this class is
# referenced by $game_actors.
#==============================================================================
class Game_Actors
#--------------------------------------------------------------------------
# Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :data
#--------------------------------------------------------------------------
# alias listing
#--------------------------------------------------------------------------
alias pac_pms_act_initialize initialize
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
pac_pms_act_initialize
$data_actors.each do |actor|
actor.setup if actor
@data[actor.id] = Game_Actor.new(actor.id) if actor
end
end
end
#==============================================================================
# ** Window_CurrentMember
#------------------------------------------------------------------------------
# This window displays the current party member in the party scene.
#==============================================================================
class Window_CurrentMember < Window_Base
#--------------------------------------------------------------------------
# Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :mode
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(member = nil, mode = 0)
super(304, 80, 192, 256)
create_contents
@member = member
@mode = 0
refresh
end
#--------------------------------------------------------------------------
# * Get member
#--------------------------------------------------------------------------
def member
return @member
end
#--------------------------------------------------------------------------
# * Set Member
#--------------------------------------------------------------------------
def set_member(member)
old_member = @member
@member = member
refresh if old_member != @member
end
#--------------------------------------------------------------------------
# * Set modes
#--------------------------------------------------------------------------
def mode=(n)
@mode = n if [0, 1].include?(n)
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
return unless @member
x, y = 0, 0
self.draw_actor_face(@member, x, y, 48)
self.draw_actor_name(@member, x + 52, y)
self.draw_actor_class(@member, x + 52, y + WLH)
self.draw_actor_level(@member, x, y + WLH*2)
case @mode
when 0
self.draw_icon(142, self.contents.width - 24, y + WLH*2)
self.contents.draw_text(x, y + WLH*2, self.contents.width - 12, WLH,
'Stat', 2)
self.draw_actor_hp(@member, x, y + WLH*3, 160)
self.draw_actor_mp(@member, x, y + WLH*4, 160)
self.draw_actor_parameter(@member, x, y + WLH*5, 0)
self.draw_actor_parameter(@member, x, y + WLH*6, 1)
self.draw_actor_parameter(@member, x, y + WLH*7, 2)
self.draw_actor_parameter(@member, x, y + WLH*8, 3)
when 1
self.draw_icon(143, self.contents.width - 24, y + WLH*2)
self.contents.draw_text(x, y + WLH*2, self.contents.width - 12, WLH,
'Equip', 2)
for i in 0...@member.equips.size
item = @member.equips[i]
self.draw_item_name(item, x, y + WLH*(3+i), true)
end
end
end
end
#==============================================================================
# ** Window_CurrentParty
#------------------------------------------------------------------------------
# This window displays the current party selected in the party scene.
#==============================================================================
class Window_CurrentParty < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(48, 80, 256, 64)
@item_max = 4
@column_max = @item_max
create_contents
self.index = 0
refresh
end
#--------------------------------------------------------------------------
# * Get member
#--------------------------------------------------------------------------
def member
return $game_party.members[self.index]
end
#--------------------------------------------------------------------------
# * Refresh window
#--------------------------------------------------------------------------
def refresh
for i in 0...@item_max
rect = item_rect(i)
self.contents.clear_rect(rect)
end
for i in 0...$game_party.members.size
rect = item_rect(i)
bitmap = Cache.character($game_party.members[i].character_name)
sign = $game_party.members[i].character_name[/^[\!\$]./]
if sign != nil and sign.include?('$')
cw = bitmap.width / 3
ch = bitmap.height / 4
else
cw = bitmap.width / 12
ch = bitmap.height / 8
end
n = $game_party.members[i].character_index
src_rect = Rect.new((n%4*3+1)*cw, (n/4*4)*ch, cw, ch)
if $game_party.members[i].actor.unavailable
self.contents.blt(rect.x, rect.y, bitmap, src_rect, 128)
else
self.contents.blt(rect.x, rect.y, bitmap, src_rect, 255)
end
if $game_party.members[i].actor.required
lock_bitmap = Cache.system("Locked")
self.contents.blt(rect.x + rect.width - lock_bitmap.width,
rect.y + rect.height - lock_bitmap.height,lock_bitmap,lock_bitmap.rect)
end
end
end
#--------------------------------------------------------------------------
# * Get rectangle for displaying items
# index : item number
#--------------------------------------------------------------------------
def item_rect(index)
rect = Rect.new(0, 0, 0, 0)
rect.width = (contents.width + @spacing) / @column_max - @spacing
rect.height = 32
rect.x = index % @column_max * (rect.width + @spacing)
rect.y = index / @column_max * 32
return rect
end
end
#==============================================================================
# ** Window_SelectMember
#------------------------------------------------------------------------------
# This window displays the currently selected member in the party scene.
#==============================================================================
class Window_SelectMember < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(48, 144, 256, 192)
calculate_actors
@item_max = [@actors.size, 20].min
@column_max = 4
self.index = -1
self.active = false
refresh
end
def page_row_max
return (self.height - 64) / WLH
end
#--------------------------------------------------------------------------
# * Calculate Actors
#--------------------------------------------------------------------------
def calculate_actors
@actors = []
for a in $game_actors.data
if a.is_a?(Game_Actor) and a.actor.found and
!$game_party.members.include?(a)
@actors << a unless $data_actors[a.id].disband
end
end
end
#--------------------------------------------------------------------------
# * Get member
#--------------------------------------------------------------------------
def member
return @actors[self.index]
end
#--------------------------------------------------------------------------
# * Refresh Window
#--------------------------------------------------------------------------
def refresh
self.contents.clear
calculate_actors
@item_max = @actors.size + 1
for i in 0...page_item_max
next if @actors[i].nil?
rect = item_rect(i)
bitmap = Cache.character(@actors[i].character_name)
sign = @actors[i].character_name[/^[\!\$]./]
if sign != nil and sign.include?('$')
cw = bitmap.width / 3
ch = bitmap.height / 4
else
cw = bitmap.width / 12
ch = bitmap.height / 8
end
n = @actors[i].character_index
src_rect = Rect.new((n%4*3+1)*cw, (n/4*4)*ch, cw, ch)
if @actors[i].actor.unavailable
self.contents.blt(rect.x, rect.y, bitmap, src_rect, 128)
else
self.contents.blt(rect.x, rect.y, bitmap, src_rect, 255)
end
if @actors[i].actor.required
lock_bitmap = Cache.system("Locked")
self.contents.blt(rect.x + rect.width - lock_bitmap.width,
rect.y + rect.height - lock_bitmap.height,lock_bitmap,lock_bitmap.rect)
end
end
end
#--------------------------------------------------------------------------
# * Get rectangle for displaying items
# index : item number
#--------------------------------------------------------------------------
def item_rect(index)
rect = Rect.new(0, 0, 0, 0)
rect.width = (contents.width + @spacing) / @column_max - @spacing
rect.height = 32
rect.x = index % @column_max * (rect.width + @spacing)
rect.y = index / @column_max * 32
return rect
end
def update_help
super
value1, value2 = self.actor_min, self.actor_max
text = sprintf("#{PAC::MENU::PARTY::ACTOR_TEXT} %d to %d", value1, value2)
@help_window.set_text(text)
end
def actor_min
return @page + 1
end
def actor_max
return [@page + 16, @actors.size, $data_actors.size].min
end
end
#==============================================================================
# ** Scene_File
#------------------------------------------------------------------------------
# This class performs the save and load screen processing.
#==============================================================================
class Scene_File < Scene_Base
#--------------------------------------------------------------------------
# alias listing
#--------------------------------------------------------------------------
alias pac_pms_file_write_save_data write_save_data
alias pac_pms_file_read_save_data read_save_data
#--------------------------------------------------------------------------
# * Write Save Data
# file : write file object (opened)
#--------------------------------------------------------------------------
def write_save_data(file)
pac_pms_file_write_save_data(file)
Marshal.dump($data_actors, file)
end
#--------------------------------------------------------------------------
# * Read Save Data
# file : file object for reading (opened)
#--------------------------------------------------------------------------
def read_save_data(file)
pac_pms_file_read_save_data(file)
$data_actors = Marshal.load(file)
end
end
#==============================================================================
# ** Scene_Title
#------------------------------------------------------------------------------
# This class performs the title screen processing.
#==============================================================================
class Scene_Title < Scene_Base
#--------------------------------------------------------------------------
# alias listing
#--------------------------------------------------------------------------
alias pac_pms_ttl_command_new_game command_new_game
#--------------------------------------------------------------------------
# * Command: New Game
#--------------------------------------------------------------------------
def command_new_game
pac_pms_ttl_command_new_game
$game_party.members.each {|s| s.actor.found = true if s}
end
end
#==============================================================================
# ** Scene_Party
#------------------------------------------------------------------------------
# This class performs the party screen processing.
#==============================================================================
class Scene_Party < Scene_Base
include PAC::MENU::PARTY
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(from_map = true, from_menu = false)
@from_map = from_map
@from_menu = from_menu
end
#--------------------------------------------------------------------------
# * Start processing
#--------------------------------------------------------------------------
def start
super
create_menu_background
create_windows
end
#--------------------------------------------------------------------------
# * Create windows
#--------------------------------------------------------------------------
def create_windows
@member_window = Window_CurrentMember.new
@member_window.visible = false if START_NO_STATUS
@member_window.openness = 0 if START_NO_STATUS
@party_window = Window_CurrentParty.new
@party_window.active = true
@party_window.x += 96 if START_NO_STATUS
@selectable_window = Window_SelectMember.new
@selectable_window.x += 96 if START_NO_STATUS
commands = [PAC::MENU::PARTY::DISPOSE_TEXT, PAC::MENU::PARTY::KEEP_TEXT]
@choice_window = Window_Command.new(160, commands)
@choice_window.x = (544 - @choice_window.width) / 2
@choice_window.y = (416 - @choice_window.height) / 2
@choice_window.openness = 0
end
#--------------------------------------------------------------------------
# * Open Member Window (now with awesomeness!)
#--------------------------------------------------------------------------
def open_member_window
begin
@party_window.x -= MOVE_SPEED
@selectable_window.x -= MOVE_SPEED
Graphics.update
end until @party_window.x == 48
@member_window.visible = true
@member_window.open
begin
@member_window.update
Graphics.update
end until @member_window.openness == 255
end
#--------------------------------------------------------------------------
# * Close Member Window (with equal awesomeness!)
#--------------------------------------------------------------------------
def close_member_window
@member_window.close
begin
@member_window.update
Graphics.update
end until @member_window.openness == 0
@member_window.visible = false
begin
@party_window.x += MOVE_SPEED
@selectable_window.x += MOVE_SPEED
Graphics.update
end until @party_window.x == 144
end
#--------------------------------------------------------------------------
# * Window update
#--------------------------------------------------------------------------
def update_windows
@member_window.update
@party_window.update
@selectable_window.update
@choice_window.update
if @party_window.active
@member_window.set_member(@party_window.member)
elsif @selectable_window.active
@member_window.set_member(@selectable_window.member)
end
end
#--------------------------------------------------------------------------
# * Open Choice Window
#--------------------------------------------------------------------------
def activate_choice_window
@previously_active = @selectable_window.active ?
@selectable_window : @party_window
@previously_active.active = false
@choice_window.active = true
@choice_window.open
begin
@choice_window.update
Graphics.update
end until @choice_window.openness == 255
end
#--------------------------------------------------------------------------
# * Close Choice Window
#--------------------------------------------------------------------------
def deactivate_choice_window
@choice_window.active = false
@party_window.active = true
@choice_window.close
@selectable_window.index = -1
begin
@choice_window.update
Graphics.update
end until @choice_window.openness == 0
end
#--------------------------------------------------------------------------
# * Update Party Window
#--------------------------------------------------------------------------
def update_party_window
if Input.trigger?(Input::B) # If you want to leave,
if $game_party.members.size == 0 # If party is empty,
Sound.play_buzzer # Bee-bow.
return # No soup for you
else
Sound.play_cancel # Bloop.
if @from_map
$scene = Scene_Map.new
elsif @from_menu
if $pac["Main Menu"]
$scene = Scene_Menu.new
else
$scene = Scene_Menu.new(4)
end
end
end
elsif Input.trigger?(Input::C) # If you want to do something,
member = @party_window.member # do stuff.
if member != nil
if member.actor.unavailable or member.actor.required
Sound.play_buzzer
return
end
end
Sound.play_decision
@party_window.active = false
@selectable_window.active = true
@selectable_window.index = 0
elsif Input.trigger?(PARTY_KILL)
Sound.play_buzzer
end
end
#--------------------------------------------------------------------------
# * Update Selectable Window
#--------------------------------------------------------------------------
def update_selectable_window
if Input.trigger?(Input::B)
Sound.play_cancel
@selectable_window.index = -1
@selectable_window.active = false
@party_window.active = true
elsif Input.trigger?(Input::C)
member = @selectable_window.member
if member != nil
if member.actor.unavailable
Sound.play_buzzer
return
end
end
Sound.play_decision
if @party_window.member != nil
member = @party_window.member
$game_party.remove_actor(member.id)
end
if @selectable_window.member != nil
member = @selectable_window.member
$game_party.add_actor(member.id)
end
$game_variables[PAC::MENU::PARTY::PARTY_VARIABLE] = member.id
@selectable_window.refresh
@party_window.refresh
@selectable_window.index = -1
@selectable_window.active = false
@party_window.active = true
elsif Input.trigger?(PAC::MENU::PARTY::PARTY_KILL)
activate_choice_window
end
end
#--------------------------------------------------------------------------
# * Update Choice Window
#--------------------------------------------------------------------------
def update_choice_window
if Input.trigger?(Input::B)
Sound.play_cancel
deactivate_choice_window
elsif Input.trigger?(Input::C)
case @choice_window.index
when 0 # Disband
member = @selectable_window.member
if member != nil
if member.actor.unavailable
Sound.play_buzzer
return
end
end
Sound.play_decision
if @party_window.member != nil
member = @party_window.member
end
if @selectable_window.member != nil
member = @selectable_window.member
end
$game_party.remove_actor(member.id)
$game_variables[PAC::MENU::PARTY::PARTY_VARIABLE] = member.id
$data_actors[member.id].disband = true
@selectable_window.refresh
@party_window.refresh
@selectable_window.index = -1
deactivate_choice_window
when 1 # Leave
Sound.play_cancel
deactivate_choice_window
end
end
end
#--------------------------------------------------------------------------
# * Termination Processing
#--------------------------------------------------------------------------
def terminate
super
@member_window.dispose
@party_window.dispose
@selectable_window.dispose
@choice_window.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
update_windows
update_input
end
#--------------------------------------------------------------------------
# * Update Command Input
#--------------------------------------------------------------------------
def update_input
if Input.trigger?(PARTY_SWITCH) # If the button is being pressed...
Sound.play_decision
@member_window.mode = @member_window.mode == 1 ? 0 : 1
elsif Input.trigger?(STATUS_WINDOW)
Sound.play_decision
if @member_window.visible
close_member_window
else
open_member_window
end
end
if @party_window.active # If the party member is active
update_party_window
elsif @selectable_window.active
update_selectable_window
elsif @choice_window.active
update_choice_window
end
end
end
#===============================================================================
#
# END OF SCRIPT
#
#===============================================================================
Credit
- Pacman
- Prexus for original script
Thanks
- Modern Algebra, Zeriab, Cozziekuns and LoganForrests for cradling me as a coding baby.
- Enterbrain for not including something like this in the first place, giving me reason to make it.
- InfinateX for suggestions.
Support
Post here, on this topic at RMRK. I live here.
Known Compatibility Issues
Should be very compatible with most scripts, depending on how well written they are. Again, just post here for support.
Demo
Not solely for this script, but this will be included in the next version of the
PAC Engine.
Author's Notes
Toe knee chest nut nose eye love you. Say that out loud.
Restrictions
Free for use in non-commercial games, with credit. If you wish to use this in a commercial game, contact me either on this topic or PM me.
PACMAN