This script is just a simple party member switch script. It allows 1-4 members in a party, and an arbitrary amount of additional players. It allows you to add/remove characters from the party using the event commands, but also gives an extra command to remove them from the active party and put them in the inactive party. To call, use: $scene = Scene_Party_Change.new
Screenshot:
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi50.photobucket.com%2Falbums%2Ff310%2Fvirtuouspaladin9%2FPartyChange.png&hash=998be77fef66f3a13c8c51b7552fce5773125c38)
Script:
[spoiler=Code]
#===================================
# Party Changing System by Leon_Westbrooke
# -v 1.2
#----------------------------------------------------------------------
# Instructions: Place above main, but below all other default scripts.
#
# Features:
# -Allows the player to make a party from the minimum to maximum size.
# -Extra members are limitless.
# -You can remove a person from the party and put it into reserve using:
# $game_party.remove_actor_to_party(actor_id)
# -You can remove a person from the reserve if they exist, and them into
# the party:
# $game_party.add_actor_to_party(actor_id)
# -You can lock a character in reserve or active party by using:
# $game_party.locked.push(actor_id)
# -You can set the maximum and minimum number of the party in-game using:
# $game_party.min_size = x
# $game_party.max_size = x
# (NOTE: Do NOT make the max size lower than the minimum size.)
# -Allows you to use the default add/remove actors command.
# (NOTE: If you remove an actor with this method, he is gone from both
# the party and the reserve members.)
#
# Credits:
# This setup uses SephirothSpawn's coding to simplify the cursor's position.
#
#
# Command Quick-list:
# $game_party.remove_actor_from_party(actor_id)
# -Removes an actor from the party, and puts them in reserve.
# $game_party.add_actor_to_party(actor_id)
# -Replaces the last actor in the party with the actor in reserve.
# $game_party.locked.push(actor_id)
# -Locks the actor in place.
# $game_party.min_size = x
# $game_party.max_size = x
# -Sets the minimum and maximum party size.
#
#
# Notes:
# This script rewrites these methods from Game_Party:
# add_actor
# remove_actor
#===================================
#==================================================
# Game_Party
#==================================================
class Game_Party
attr_accessor :party_members
attr_accessor :move
attr_accessor :locked
attr_accessor :min_size
attr_accessor :max_size
alias leon_partyswitch_gameactor_initialize initialize
def initialize
leon_partyswitch_gameactor_initialize
@party_members = []
# Edit :This is to change if an actor is locked or not. To lock them, add
# their id to the array below.
@locked = [1]
@min_size = 1
@max_size = 4
end
def add_actor(actor_id)
actor = $game_actors[actor_id]
if @actors.size < @max_size
unless @actors.include?(actor)
unless @party_members.include?(actor.id)
@actors.push(actor)
$game_player.refresh
end
end
else
unless @party_members.include?(actor.id)
unless @actors.include?(actor)
@party_members.push(actor.id)
$game_player.refresh
end
end
end
end
def remove_actor(actor_id)
@actors.delete($game_actors[actor_id])
@party_members.delete(actor_id)
$game_player.refresh
end
def remove_actor_from_party(actor_id)
if @actors.include?($game_actors[actor_id])
unless @party_members.include?(actor_id)
@party_members.push(actor_id)
@party_members.sort!
end
end
@actors.delete($game_actors[actor_id])
$game_player.refresh
end
def add_actor_to_party(actor_id)
if @party_members.include?(actor_id)
if @actors[@max_size - 1] != nil
@party_members.push(@actors[@max_size - 1].id)
@actors.delete_at(@max_size - 1)
end
@actors.push($game_actors[actor_id])
@party_members.delete(actor_id)
end
end
end
#==================================================
# END Game_Party
#==================================================
#==============================================================================
# ** Window_Selectable
#==============================================================================
class Window_Selectable < Window_Base
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :cursor_height
#--------------------------------------------------------------------------
# * Alias Initialization
#--------------------------------------------------------------------------
alias custom_int initialize
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(x, y, width, height)
custom_int(x, y, width, height)
@cursor_height = 32
end
#--------------------------------------------------------------------------
# * Get Top Row
#--------------------------------------------------------------------------
def top_row
# Divide y-coordinate of window contents transfer origin by 1 row
# height of @cursor_height
return self.oy / @cursor_height
end
#--------------------------------------------------------------------------
# * Set Top Row
# row : row shown on top
#--------------------------------------------------------------------------
def top_row=(row)
# If row is less than 0, change it to 0
if row < 0
row = 0
end
# If row exceeds row_max - 1, change it to row_max - 1
if row > row_max - 1
row = row_max - 1
end
# Multiply 1 row height by 32 for y-coordinate of window contents
# transfer origin
self.oy = row * @cursor_height
end
#--------------------------------------------------------------------------
# * Get Number of Rows Displayable on 1 Page
#--------------------------------------------------------------------------
def page_row_max
# Subtract a frame height of 32 from the window height, and divide it by
# 1 row height of @cursor_height
return (self.height - 32) / @cursor_height
end
#--------------------------------------------------------------------------
# * Update Cursor Rectangle
#--------------------------------------------------------------------------
def update_cursor_rect
# If cursor position is less than 0
if @index < 0
self.cursor_rect.empty
return
end
# Get current row
row = @index / @column_max
# If current row is before top row
if row < self.top_row
# Scroll so that current row becomes top row
self.top_row = row
end
# If current row is more to back than back row
if row > self.top_row + (self.page_row_max - 1)
# Scroll so that current row becomes back row
self.top_row = row - (self.page_row_max - 1)
end
# Calculate cursor width
cursor_width = self.width / @column_max - 32
# Calculate cursor coordinates
x = @index % @column_max * (cursor_width + 32)
y = @index / @column_max * @cursor_height - self.oy
if self.active == true
# Update cursor rectangle
self.cursor_rect.set(x, y, cursor_width, @cursor_height)
end
end
end
#==============================================================================
# ** Window_Command
#==============================================================================
class Window_Command < Window_Selectable
#--------------------------------------------------------------------------
# * Unisable Item
# index : item number
#--------------------------------------------------------------------------
def undisable_item(index)
draw_item(index, normal_color)
end
end
#============================================================
#==================================================
# Window_Party_Info
#==================================================
class Window_Party_Info < Window_Base
def initialize
super(0, 0, 640, 64)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
end
def refresh
self.contents.clear
self.contents.draw_text(0, 0, 614, 32, "Please make a party of #{$game_party.min_size.to_s} to #{$game_party.max_size.to_s} members.", 1)
end
end
#==================================================
# END Window_Party_Info
#==================================================
#==================================================
# Window_Party_Slots
#==================================================
class Window_Party_Slots < Window_Selectable
def initialize
super(0, 64, 320, 416)
@item_max = 4
self.contents = Bitmap.new(width - 32, height - 32)
self.index = 0
self.active = true
refresh
end
def actors
if @data[index] != nil
return @data[index]
end
end
def refresh
@data = []
if self.contents != nil
self.contents.dispose
self.contents = nil
end
for i in 0...$game_party.actors.size
@data.push($game_party.actors[i])
end
@item_max = (@data.size + 1)
if @item_max > 0
if @item_max > 4
@item_max = 4
end
self.contents = Bitmap.new(width - 32, row_max * 96)
for i in 0...@item_max
draw_item(i)
end
end
end
def draw_item(index)
@actor = @data[index]
y = index * 96
x = 4
if $game_party.locked.include?(@actor.id)
self.contents.font.color = disabled_color
opacity = 128
else
self.contents.font.color = normal_color
opacity = 255
end
if @actor != nil
self.contents.draw_text(x + 100, y, 192, 32, @actor.name)
draw_actor_hp(@actor, x + 100, y + 32)
draw_actor_sp(@actor, x + 100, y + 64)
bitmap = RPG::Cache.character(@actor.character_name, @actor.character_hue)
cw = bitmap.width / 4
ch = bitmap.height / 4
facing = 0
src_rect = Rect.new(0, facing * ch, cw, ch)
self.contents.blt(x + 24, y + 32, bitmap, src_rect, opacity)
end
end
def update_cursor_rect
if @index > -1
x = 0
y = index * 96
self.cursor_rect.set(x, y, (self.width - 32), 96)
else
self.cursor_rect.empty
end
end
end
#==================================================
# END Window_Party_Slots
#==================================================
#==================================================
# Window_Party_Extras
#==================================================
class Window_Party_Extras < Window_Selectable
def initialize
super(320, 64, 320, 416)
self.cursor_height = 96
self.contents = Bitmap.new(width - 32, height - 32)
self.index = -1
self.active = false
refresh
end
def actors
if @data != nil
return @data[index]
end
end
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
for i in 0...$game_party.party_members.size
@data.push($game_actors[$game_party.party_members[i]])
end
@data.push(nil)
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 96)
for i in 0...@item_max
draw_item(i)
end
end
end
def draw_item(index)
@actor = @data[index]
y = index * 96
x = 4
if $game_party.locked.include?(@actor.id)
self.contents.font.color = disabled_color
opacity = 128
else
self.contents.font.color = normal_color
opacity = 255
end
if @actor != nil
self.contents.draw_text(x + 100, y, 192, 32, @actor.name)
draw_actor_hp(@actor, x + 100, y + 32)
draw_actor_sp(@actor, x + 100, y + 64)
bitmap = RPG::Cache.character(@actor.character_name, @actor.character_hue)
cw = bitmap.width / 4
ch = bitmap.height / 4
facing = 0
src_rect = Rect.new(0, facing * ch, cw, ch)
self.contents.blt(x + 24, y + 32, bitmap, src_rect, opacity)
end
end
end
#===================================
# END Window_Party_Extras
#===================================
#===================================
# Scene_Party_Change
#===================================
class Scene_Party_Change
def main
@info_window = Window_Party_Info.new
@slot_window = Window_Party_Slots.new
@extra_window = Window_Party_Extras.new
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@info_window.dispose
@slot_window.dispose
@extra_window.dispose
end
def update
@slot_window.update
if @slot_window.active
update_slot
return
end
if @extra_window.active
update_extra
return
end
end
def update_slot
if Input.trigger?(Input::B)
if $game_party.actors.size >= $game_party.min_size and $game_party.actors.size <= $game_party.max_size
$game_player.refresh
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
else
$game_system.se_play($data_system.buzzer_se)
end
end
if Input.trigger?(Input::C)
if $game_party.locked.include?(@slot_window.actors.id) == true
$game_system.se_play($data_system.buzzer_se)
else
$game_system.se_play($data_system.decision_se)
@slot_window.active = false
@extra_window.active = true
@extra_window.index = 0
end
end
end
def update_extra
@extra_window.update
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@slot_window.active = true
@extra_window.active = false
@extra_window.index = -1
end
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
if $game_party.locked.include?(@extra_window.actors.id)
$game_system.se_play($data_system.buzzer_se)
return
end
if @extra_window.actors == nil
if $game_party.actors[@slot_window.index] != nil
$game_party.party_members.push($game_party.actors[@slot_window.index].id)
$game_party.remove_actor_from_party($game_party.actors[@slot_window.index].id)
$game_party.party_members.sort!
@slot_window.refresh
@extra_window.refresh
@slot_window.active = true
@extra_window.active = false
@extra_window.index = -1
else
@slot_window.active = true
@extra_window.active = false
@extra_window.index = -1
end
else
if $game_party.actors[@slot_window.index] != nil
hold = @extra_window.actors
$game_party.party_members.push($game_party.actors[@slot_window.index].id)
$game_party.actors[@slot_window.index] = hold
$game_party.party_members.delete_at(@extra_window.index)
$game_party.party_members.sort!
@slot_window.refresh
@extra_window.refresh
@slot_window.active = true
@extra_window.active = false
@extra_window.index = -1
else
$game_party.actors[@slot_window.index] = @extra_window.actors
$game_party.party_members.delete_at(@extra_window.index)
$game_party.party_members.sort!
@slot_window.refresh
@extra_window.refresh
@slot_window.active = true
@extra_window.active = false
@extra_window.index = -1
end
end
end
end
end
[/spoiler]
Well done, looks a lot like a ToS style party changer.
Nice script. A question thought. How do I open this menu in game?
You use: $scene = Scene_Party_Change.new
I should edit the first post, I apologize for leaving that out.
I got a problem then. I have 3 characters in the team, and 2 reserve.
I got this error.
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi94.photobucket.com%2Falbums%2Fl104%2FDennis88_2006%2FDragon.png&hash=c0b5b841c078d288b9b7244bbb561e8d69e9d64a)
Ok, I believe i know why. where it has (actor), after the .include?, change it to (actor_id). I believe that is the problem. Also, if you are using this in a pre-existing game, and you are loading up an old save file, that too can cause this error.
I tried to not load my save file, and now, it works.
Im gonna use this. Thx.
Nice, leon.
It looks good but I got some questions wich I really need to ask for God knows why.
1. Are those HP/MP bars included? Or just the default ones?
2. What do you mean with inactive party and additional players? You mean you can have more members in your party, just not in battle? Or do you mean the party members currently not in your party? Or do you mean the party member is in events, just not in your menu, battles, and maybe a caterpillar system, and in cutscenes? Or is it just a character that's not in your party currently?
1. The bars are not included. It is indeed a separate script.
2. By inactive party, I mean you have the 4 that are in your party, and then the others aren't in battles, don't show up in the menu, stuff like that. They are not currently in your party.
In that case, I might use this, thanks.
Okay... I'm like a complete noob when it comes to scripting and such. ._.;; I know how to put it in the script, but... how would I go about using $scene = Scene_Party_Change.new x_X?? Someone's gonna make fun of me for being a nub, I just know it. >_>;;
Call script (Event commands page 3, lower-right)
Paste: $scene = Scene_Party_Change.new
That's how you would do it through an event ^_^
Oooh, thanks! :D I get it to open up now, but... it always says:
[5 ?s] 'Party Changer' ? 67 [3 ?s] NameError [8 ?s] (It keeps showing the ??? face -.-;)
undefined local variable or method `actor' for # <Game_Party:0x47d8e38>
D: I dun get it... ;-;
I fixed the script itself in the first post. to fix your copy, on line 67, it should say:
unless @party_members.include?(actor)
in your copy.
Change the (actor) to (actor_id)
and that will fix your problem
Oh, yay! Thank you so very much! :tpg: You're one of the best-est! XD
Stop Necroposting/gravedigging!
i'm trying to get this to work in the game i'm working on and i can't figure out what i need to do to either set it up as a button or have it work from the menu
am haveing a error on line 60 can you give me a hand please
don't think that member is still active. Try posting a topic in SCRIPTS HELP (http://rmrk.net/index.php/board,25.0.html), and be sure to include more detail about the error and maybe a screenshot of it.
I think i found a bug, when I ad one actor more times than 1, I get a mirror of that actor.
How do I make it so that you can only have a party of three?
Updated with a couple new features, including an easy way to set minimum and maximum size, you can lock actors in either the party or reserve.
Cool. Nice addition.
This is a rate before test: 10/10
Rate after test: 11/10
this script couldnt work better!
and its te first script i have ever properly installed! damn keyboard kees bugering up
I don't get how I gonna lock actor in party, when I use $game_party.locked.push(actor_id) then it is possebole if the actor I locked is in party then I can change it to extra members and if it is there I can't move it at all.
So my question is: How do I lock an actor in party?
Ok, a glitch was fixed when it comes to locking a person in-party. As for your question, BK, you use:
$game_party.add_actor_to_party(2)
$game_party.locked.push(2)
in a Script call.
thx ;D
ps. can you make the script so that it allows faces?
I hvave Blizzards Easy Party Changer, but I cant figure it out...I want it to work from the Main Menu in Party Section, like in Aveyond 2. Could this be done somehow? I used the Call Script Command in his instructions in an event, the problem is the player has to step on the event toactivate it and it doesnt appear in the Main Menu. Can someone please help me?
THANX
Hey guys and gals , Im very much lovin the look of this party changer but i have one problem..Im a complete noob. This is my first time so i have no idea how to get it to worl..If you could give me a step by step guide of how to get this working it would be a great help.
Quote
#===================================
# Party Changing System by Leon_Westbrooke
# -v 1.2
#----------------------------------------------------------------------
# Instructions: Place above main, but below all other default scripts.
#
# Features:
# -Allows the player to make a party from the minimum to maximum size.
# -Extra members are limitless.
# -You can remove a person from the party and put it into reserve using:
# $game_party.remove_actor_to_party(actor_id)
# -You can remove a person from the reserve if they exist, and them into
# the party:
# $game_party.add_actor_to_party(actor_id)
# -You can lock a character in reserve or active party by using:
# $game_party.locked.push(actor_id)
# -You can set the maximum and minimum number of the party in-game using:
# $game_party.min_size = x
# $game_party.max_size = x
# (NOTE: Do NOT make the max size lower than the minimum size.)
# -Allows you to use the default add/remove actors command.
# (NOTE: If you remove an actor with this method, he is gone from both
# the party and the reserve members.)
#
# Credits:
# This setup uses SephirothSpawn's coding to simplify the cursor's position.
#
#
# Command Quick-list:
# $game_party.remove_actor_from_party(actor_id)
# -Removes an actor from the party, and puts them in reserve.
# $game_party.add_actor_to_party(actor_id)
# -Replaces the last actor in the party with the actor in reserve.
# $game_party.locked.push(actor_id)
# -Locks the actor in place.
# $game_party.min_size = x
# $game_party.max_size = x
# -Sets the minimum and maximum party size.
#
#
# Notes:
# This script rewrites these methods from Game_Party:
# add_actor
# remove_actor
#===================================
these are the instructions and these bits:
QuoteCommand Quick-list:
# $game_party.remove_actor_from_party(actor_id)
# -Removes an actor from the party, and puts them in reserve.
# $game_party.add_actor_to_party(actor_id)
# -Replaces the last actor in the party with the actor in reserve.
# $game_party.locked.push(actor_id)
# -Locks the actor in place.
# $game_party.min_size = x
# $game_party.max_size = x
# -Sets the minimum and maximum party size.
are how you edit the script ingame to make it do what you want. call any of these with a "call script" event command. where it says "actor id" insert the number acociated with that actor. this starts at 0 and then incremenets by 1. x is where you put a number could be anything :D
Hey guys and gals again, I sorry but in really confused..Ive made done the script but im not sure if ive done it right, When i try to start the game it says this
Script 'party changer' line 1:nameerror occured
undefined local variable or method 'actor_id' for nil:nilclass
So im completly up the duff...If anyone can give me a step by step guide..literally baby steps at a time i woule greatly appreciate it.
;D
can you give me the line number for that and also anything you entered in a call script event command
If you are loading an old save file, it will mess with it as well.
What do you mean by line number lol, see im a noob, basicly ive messedaround with makin a few characters and items but thats it so everything is standard still.
If you can give me steps as to how you would do it and get it workin that would be great.
line numbers appear in the error dialog. however i noticed you included it :(. these tell me/leon exactly where to check to see where its going wrong.
here put the three following commands into 3 seperate "callscript" event options one after the other. Replace x with a number the first one is the MININIMUM size eg. 1 the second one is the max size eg.4 the final line calls the party changer
$game_party.min_size = x
$game_party.max_size = x
$scene = Scene_Party_Change.new
Umm...
I want to know how I can customize this....
So, I managed to make it 5 people in one battle, but it can't scroll down, how can I make it scroll down?
The 5th member can't be seen...
uhhh ummm i got a sorta unrelated issue. well, after adding this script... i got an error in my "Main"... says Line 11 has an incorrect number of arguments... jesus, i never even touched that damn line =\ can anyone help?
double post: gah looks like this page is dead =(
triple post: meh couldnt fix it so i replaced my entire srcipt with the original one that comes with rpg maker xp lol to anyone else with that problem, good luck xP
NAMedit: compressed stupid triple post into one post.
dude, wow, holy shit, you waited all of 2 minutes for a reply and decided it was dead.
seriously.
don't double post, much less triple post.
and give it time for someone to respond, everyone isn't online 24/7 and just waiting for someone to help or fix a problem for.
One: Never EVER do something as stupid as a triple post like that. It just pisses us off.
Two: I tested it out by taking the script and adding it where I'm supposed to, and it works just fine. That means you just did something stupid by either changing something, not copying all of the script, or by putting it in the wrong place.
I'm like it. very nice. lol
alright, the script seems to be working beautifully. However, how does one unlock a
character once they've been locked? Is there a way to do that with this script, because I feel like I'm missing something.
Try:
$game_party.locked.delete (actor_id)
yup that worked. Thanks for the hand.
Hey, cool script.
Is there a way to add a player straight into the reserve..?
Hi! i'm new to this, and my problem is how to add actors in the reserves. I manage to open the party change list but there are no other characters which i can change from my main party.. thnx 4 d help...
Hello! :) First of all, GREAT script, I love it.
Second I just have one question. I know this may be stupid but I really don't understand...
I'm attempting to make certain characters unavailable as they will be unlocked later on in the story, and I know I have to insert the actor ID somewhere...What exactly IS the actor ID? Is it just the actor's name? Because I tried that in all the following formats and I got errors.
Actor Name
ActorName
Actor_Name
Please help!