Help - Search - Members - Calendar
Full Version: Party Switcher/Changer
RPG RPG Revolution Forums > Scripting > Script Development and Support > RGSS2
gsorby
Party Switcher/Changer V 1.1

Version
1.1

Author
Prexus (For the actual script, and I have full permission from Prexus to post it here)
GSorby (for the few edits and additions)

Release Date
1/1/2010


Exclusive Script at Rpgmakervx.net


Introduction
Creates a scene to rearrange your party. There are a variety of things to do in this system. You can remove and add characters from being available in the Reserves (non-party members), lock characters so you can't add or remove them, and make characters "Unavailable", which does about the same thing as Locking. The reasoning behind having two things like this is for representation purposes. A character who isn't in your party, but is temporarily unavailable COULD show up as being "Locked" (lock icon) but I didn't feel it looked as good as being "Unavailable" (greyed out.) But a character who IS in your party, but can't be removed, obviously wouldn't make sense as being Unavailable.

You can also see the statistics of the character, as well as the face graphic, in a small window to the right of the Party/Reserves.

What's the difference?
GSorby's edit of the script

Prexus' default script



Script
Party Switcher/Changer
CODE
#===============================================================================
# ● [VX] ◦ Party Manager/Switcher ◦
#-------------------------------------------------------------------------------
# ◦ By Prexus
# ◦ Edit by GSorby [george_sorby@hotmail.co.uk]
# ◦ RPG Revolution
# ◦ Released on: 27/12/2009
# ◦ Version: 1.1
#-------------------------------------------------------------------------------
# This is a Party Manager/Switcher which allows the player to switch current
# party member with ones that are on standby. You can also make a Party Member
# unavailible or locked. There is also a function so that you can show and hide
# party members in the manager.
#===============================================================================
#  To open the party manager, use the code below:
#
#  $scene = Scene_Party.new
#-------------------------------------------------------------------------------
#  To make an actor visible in the Party Window, use the code below:
#
#  $data_actors[ID].found = true                
#-------------------------------------------------------------------------------  
#  To make an actor unavailable (Grayed out)/unmoveable, use the code below:
#  
#  $data_actors[ID].unavailable = true            
#-------------------------------------------------------------------------------
#  To lock the leader, use the code below:                                  
#                                                                              
#  $game_party.members[0].actor.required = true              
#-------------------------------------------------------------------------------
#  To unlock the leader, use the code below:
#
#  $game_party.members[0].actor.required = false
#-------------------------------------------------------------------------------
#  To remove an actor from your reserves, use the code below:
#  
#  $data_actors[ID].found = false    
#===============================================================================
# Credits to Prexus for the main script.
# Credits to GSorby for the edit of the script.
# *Don't edit anything past this point unless you know what you're doing.*
#===============================================================================

module RPG
  class Actor
    def setup
      @found = false
      @unavailable = false
      @required = false
    end
    attr_accessor :found
    attr_accessor :unavailable
    attr_accessor :required
  end
end

class Game_Actors
  attr_reader :data
  alias prex_party_g_actors_initialize initialize
  def initialize
    prex_party_g_actors_initialize
    $data_actors.each do |actor|
      actor.setup if actor
      @data[actor.id] = Game_Actor.new(actor.id) if actor
    end
  end
end

class Scene_File < Scene_Base
  alias prex_party_s_file_write_save_data write_save_data
  alias prex_party_s_file_read_save_data read_save_data
  def write_save_data(file)
    prex_party_s_file_write_save_data(file)
    Marshal.dump($data_actors, file)
  end
  def read_save_data(file)
    prex_party_s_file_read_save_data(file)
    $data_actors = Marshal.load(file)
  end
end

class Scene_Title < Scene_Base
  alias prex_party_s_title_command_new_game command_new_game
  def command_new_game
    prex_party_s_title_command_new_game
    $game_party.members.each {|s| s.actor.found = true if s}
  end
end

class Window_Base < Window
  def draw_item_name(item, x, y, enabled = true, width = 172)
    if item != nil
      draw_icon(item.icon_index, x, y, enabled)
      self.contents.font.color = normal_color
      self.contents.font.color.alpha = enabled ? 255 : 128
      self.contents.draw_text(x + 24, y, width, WLH, item.name)
    end
  end
end

class Scene_Party < Scene_Base
  def start
    super
    create_menu_background
    create_windows
  end
  def create_windows
    @member_window = Window_CurrentMember.new
    @party_window = Window_CurrentParty.new
    @party_window.active = true
    @selectable_window = Window_SelectMember.new
  end
  def update_windows
    @member_window.update
    @party_window.update
    @selectable_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
  def terminate
    super
    @member_window.dispose
    @party_window.dispose
    @selectable_window.dispose
  end
  def update
    super
    update_windows
    update_input
  end
  def update_input
    if Input.trigger?(Input::A)
      if @member_window.mode == 1
        @member_window.set_mode(0)
      elsif @member_window.mode == 0
        @member_window.set_mode(1)
      end
    end
    if @party_window.active
      if Input.trigger?(Input::B)
        Sound.play_cancel
        $scene = Scene_Menu.new
      elsif Input.trigger?(Input::C)
        member = @party_window.member
        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
      end
    elsif @selectable_window.active
      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
        $game_party.remove_actor(@party_window.member.id) if @party_window.member != nil
        $game_party.add_actor(@selectable_window.member.id) if @selectable_window.member != nil
        @selectable_window.refresh
        @party_window.refresh
        @selectable_window.index = -1
        @selectable_window.active = false
        @party_window.active = true
      end
    end
  end
end

class Window_CurrentMember < Window_Base
  attr_reader :mode
  def initialize(member = nil, mode = 0)
    super(284, 47, 242, 306)
    create_contents
    @member = member
    @mode = 0
    refresh
  end
  def member
    return @member
  end
  def set_member(member)
    old_member = @member
    @member = member
    refresh if old_member != @member
  end
  def set_mode(mode)
    @mode = mode if [0, 1].include?(mode)
    refresh
  end
  def refresh
    self.contents.clear
    return unless @member
    x, y = 0, 0
    self.draw_actor_face(@member, x, y, 96)
    self.draw_actor_name(@member, x + 102, y)
    self.draw_actor_class(@member, x + 102, y + WLH)
    self.draw_actor_level(@member, x + 102, y + WLH*2)
    case @mode
    when 0
      self.draw_icon(0, self.contents.width - 24, y + WLH*2)
      self.draw_actor_hp(@member, x, y + WLH*5, 160)
      self.draw_actor_mp(@member, x, y + WLH*6, 160)
      self.draw_actor_parameter(@member, x, y + WLH*7, 0)
      self.draw_actor_parameter(@member, x, y + WLH*8, 1)
      self.draw_actor_parameter(@member, x, y + WLH*9, 2)
      self.draw_actor_parameter(@member, x, y + WLH*10, 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, 'Stat', 2)
      for i in 0...@member.equips.size
        item = @member.equips[i]
        self.draw_item_name(item, x, y + WLH*(3+i), true, self.contents.width - 24)
      end
    end
  end
end

class Window_CurrentParty < Window_Selectable
  def initialize
    super(18, 60, 256, 64)
    @item_max = 4
    @column_max = @item_max
    create_contents
    self.index = 0
    refresh
  end
  def member
    return $game_party.members[self.index]
  end
  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
  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

class Window_SelectMember < Window_Selectable
  def initialize
    super(18, 144, 256, 192)
    calculate_actors
    @item_max = @actors.size + 1
    @column_max = 4
    self.index = -1
    self.active = false
    refresh
  end
  def calculate_actors
    @actors = []
    for a in $game_actors.data
      @actors << a if a != nil and a.actor.found and !$game_party.members.include?(a)
    end
  end
  def member
    return @actors[self.index]
  end
  def refresh
    self.contents.clear
    calculate_actors
    @item_max = @actors.size + 1
    for i in 0...@actors.size
      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
  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


Compatibility
Only works on VX.

Screenshot

Screenshots
GSorby's edit of the script:

Prexus' default script:


DEMO

Latest Norton 360 Scanned = OK.

Installation

Below Scenes and above main, in the material section.
Copy the "Locked.png" file from the Graphics\System\ directory into your own project, or create your own.
Locked.png


The initial starting party is automatically made available in your Reserves/Party. However, when adding a party member using the regular Event command, it doesn't automatically add the character to your Reserves. The reason being for temporary characters and such.



Terms and Conditions
Credit Prexus for the script and credit GSorby for the edits.

Credits
Prexus: For his amazing Party Switcher script.
Xzygon
You haven't exactly told us what you edited. And did you even ask Prexus if you could post it here? You say it's exclusive, but I'm pretty sure it's on rpgmakervx.net as well.
gsorby
QUOTE (Xzygon @ Jan 1 2010, 11:22 PM) *
You haven't exactly told us what you edited. And did you even ask Prexus if you could post it here? You say it's exclusive, but I'm pretty sure it's on rpgmakervx.net as well.

Yes I got warned the first time for stealing. So I asked Prexus and he said back to me: Go for it, I don't care. And sorry about the exclusive thing. I'll change that now.
Shanghai
So if all you do is change the size of a few windows, add a few gauges, throw in one or two term changes, that's enough to say you made the script? And yes, I realize you mentioned Prexus, but honestly, do better than that... This leaves a very bad aftertaste in my mouth...
Xzygon
What's with the extra gauges? Those aren't needed (Except for looks, MAYBE.)
The only thing I like is that the full picture shows up.
gsorby
QUOTE (Shanghai @ Jan 2 2010, 08:14 AM) *
So if all you do is change the size of a few windows, add a few gauges, throw in one or two term changes, that's enough to say you made the script? And yes, I realize you mentioned Prexus, but honestly, do better than that... This leaves a very bad aftertaste in my mouth...

For a start, where did I say that I made the script. If you look hard enough right the beginning, it says Prexus (for the actual script) and GSorby (for the edits and additions).
rcGingerNinja
Now now children no need to be snotty.

The OP has as far as we know permissions and has made what appears to be a positive change even if it is only visual that he/she has made (probably for personal use aswell) and has decided to share the results with others, so calm the hell down lol.
draken29
I want to remove a character in my reserve but how ?
(The initial member is not the MC)
gsorby
QUOTE (draken29 @ Jan 3 2010, 04:42 PM) *
I want to remove a character in my reserve but how ?
(The initial member is not the MC)

Just call a script:

$data_actors[ID].found = false

Change ID to the ID of the actor you want to remove.

Hope this helps GSorby smile.gif
draken29
Thanks

I'm only asking but can you post which part of the script that made the initial party automatically in the reserve ?

Thanks once more biggrin.gif
gsorby
QUOTE (draken29 @ Jan 3 2010, 04:53 PM) *
Thanks

I'm only asking but can you post which part of the script that made the initial party automatically in the reserve ?

Thanks once more biggrin.gif

OK, youve lost me. What do you mean? When you use the command 'Add Party Member', you can just remove the actor you want to swap and then add the replacement, then add the actor you removed again and he/she should be in the reserves. If this is not what you mean, try to be more specific. Thanks. GSorby smile.gif
draken29
ooh sorry about that i mean when you say
QUOTE
"The initial starting party is automatically made available in your Reserves/Party. "

in your first post

Which line in the script that made this ?

And I try to use $data_actors[ID].found = false
but the character doesn't disappear from the party windows

so please help me
i'm not that good at scripting
gsorby
QUOTE (draken29 @ Jan 3 2010, 05:05 PM) *
ooh sorry about that i mean when you say
QUOTE
"The initial starting party is automatically made available in your Reserves/Party. "

in your first post

Which line in the script that made this ?

And I try to use $data_actors[ID].found = false
but the character doesn't disappear from the party windows

so please help me
i'm not that good at scripting

Be aware that a party member has to be on STANDBY to use $data_actors[ID].found = false. Otherwise it messes up. So a member should disappear when he/she is on standby.
draken29
I have founded the mistake
my mistake tongue.gif

Thanks gscorby
gsorby
QUOTE (draken29 @ Jan 3 2010, 05:15 PM) *
I have founded the mistake
my mistake tongue.gif

Thanks gscorby

GSorby actually! lol smile.gif
draken29
QUOTE (gsorby @ Jan 4 2010, 12:50 AM) *
QUOTE (draken29 @ Jan 3 2010, 05:15 PM) *
I have founded the mistake
my mistake tongue.gif

Thanks gscorby

GSorby actually! lol smile.gif


Sorry another mistyping by me tongue.gif

So I make it proper this time
thanks GSorby
gsorby
QUOTE (draken29 @ Jan 3 2010, 05:55 PM) *
QUOTE (gsorby @ Jan 4 2010, 12:50 AM) *
QUOTE (draken29 @ Jan 3 2010, 05:15 PM) *
I have founded the mistake
my mistake tongue.gif

Thanks gscorby

GSorby actually! lol smile.gif


Sorry another mistyping by me tongue.gif

So I make it proper this time
thanks GSorby

Thanks! haha tongue.gif
ItchMyController
can u put it on the menu? >.> i dont relly want to command the people who play it to see if they want to change a character and then they dont and then later they want to but they cant bring it up
Xzygon
@Controller
That's pretty easy to do.
Just make a common event calling the script,
and use puppeto4's Comment Event Menu Script and call the common event from there.
puppeto4's script can be found here.
gsorby
QUOTE (ItchMyController @ Jan 6 2010, 01:24 AM) *
can u put it on the menu? >.> i dont relly want to command the people who play it to see if they want to change a character and then they dont and then later they want to but they cant bring it up

OR (as it says in the demo), you can get yanfly's menu scene redux. You can call any .new commands from there and the menu doesnt close when you want to open it like puppetos. The script can be found here..
Plus its cool for a lot of other things biggrin.gif
romeboy109


nice
Legacy
romeboy109, please do not spam and necropost.
ichiruki
can you please make a shortcut when changing party example when you press "C" you can access the thing
tdbnz
THat script is very good I give that script a A++++++

IT's a good script

Thanks
Tdbnz
MicCloud
I'm not very good with scripts so I came to a problem that left me hopeless.
While switching characters between reserved and active some of my characters just disappeared completely when they were swapped to reserved.


---- Never mind, I found the solution. Great script btw.
Noah123
help when i try to make an actor found, it says:

NoMethodError occured while running script.

unidentified method 'found=' for nil:NilClass
gsorby
QUOTE (Noah123 @ Nov 5 2010, 01:21 AM) *
help when i try to make an actor found, it says:

NoMethodError occured while running script.

unidentified method 'found=' for nil:NilClass

Then you;ve done something wrong, look carefully.
Noah123
QUOTE (gsorby @ Nov 5 2010, 02:22 PM) *
QUOTE (Noah123 @ Nov 5 2010, 01:21 AM) *
help when i try to make an actor found, it says:

NoMethodError occured while running script.

unidentified method 'found=' for nil:NilClass

Then you;ve done something wrong, look carefully.


thanks I found the problem but now when I take a member out of my party, it removes them permanently and they don't show up in reserved.
orcywoo6
Is there a way to make it so only one character can be added to the party before the window is closed or before making the others unavaliable?
InfinateX
I was just viewing the other script ( laugh.gif ) and this one i WAAAAAAAAY better by what I've read and seen in the screenshots...

EDIT:orcywoo6 if you wanna do that you could use common events (parrallel process) or if you want them to still be swapable (still available though) just go to the script Game_Party line 12 and change MAX_MEMBERS = 4 to the ammount you would like!

POSSIBLE BUG!!!!

I went to remove someone from my party(the same way you swap people) and he dissappeared...I couldn't make him reappear either...

Do you know what's wrong? huh.gif

EDIT:Sorry...I double posted... sad.gif

Merged double posts. ~Kread
Adrien.
I am posting this here along with in the FF13 menu systm

I have found a incompatibility with the yanfly equipment overhaul system.

Such that:

Click to view attachment

Is thrown when the equipment overhaul script is placed any where either above or below this script.

The line its blowing out on is this:

CODE
$game_party.gain_item(last_item, 1)


Is there a fix for this?

What I am assuming its doing its not being able to register the icons in the proper place upon refreshing the equipment scene for any player be they in or out of the party. How ever Ruby is not my area. If this was Java....well...

Any ways. Any ideas?

Possible fix:

Comment out these lines in Game_Actor


#$game_party.gain_item(last_item, 1)
#$game_party.lose_item(item, 1)


And the scripts will work together
GwydionSilas
Hey, thanks for the script, man; I had tried to develop something that ran with eighty-billion conditional branches before thinking, "Oh, my goodness, there has GOT to be a better way." I then found this. Awesome.

Now, because I try to think like the most ridiculous individual might, I experimented with removing all party members from the party and exiting the dialogue box. The result was a happy little screen with no player-character and no way to re-select the dialogue to add characters back to the party. (I decided I didn't want to use the menu shortcut.) I was wondering if there was a way to lock it so that there has to be at least ONE party member before exiting the dialogue?

Thanks in advance!
redm
QUOTE (Adrien. @ Jan 5 2011, 03:53 PM) *
I have found a incompatibility with the yanfly equipment overhaul system.

Is there a fix for this?

Regarding the Script 'Game_Actor' line 443: NoMethodError Occurred. Undefined method 'gain item' for nil:NilClass

I ran into this same issue. First, I tested your fix and while it gets rid of the error, it creates a problem where if you equip an item, it doesn't leave your inventory (so it basically lets you create duplicate items).

If you comment out this line in the Prexus/GSorby script
# @data[actor.id] = Game_Actor.new(actor.id) if actor
It appears to get rid of the error, and the script appears to still work. I only tested slightly and and I'm level 0 scripter, so I make no guarantees.
tuti05
Hi I have a small problem
The Charsets I'm Using are bigger than the normal overworld sprites. They are all mostly this big:


so in game you will see



Do you know How to fix this besides resizing the actual sprites? Maybe theres a small zoom script to zoom out and make the sprite in the menu appear smaller or something? Or you could maybe make an alternative with people who have too huge of sprites to use the actors in game name to display an icon for them.

[the game im working on will either be "pokemon hunter" like monster hunter or the closest pokemon game you could get with rmvx for pc. i will make it kind of like the fire emblem storyline or the dragon ball z snes rpg game] [im only letting the hero catch evented pokemon because i cant script, i'll tie some storyline into it] [and they will evolve with events also] [annddd my maps are all parallax so i could maybe change the look of the map in photoshop for day and night or even seasons]
tuti05
nvm i gave up on the whole project :/ i rather just play pokemon black
Shadowhawke
When I try to run my game while using your script I get an error message as it starts up which says

undefined superclass 'Scene Base'

Any ideas as to why this is happening?
Kread-EX
You probably put it at a wrong place. Put it below Materials.
Uindo_Ookami
really really nice script but...is there a way so A: this can be opene in the menu. and B: actors in the Reserves stll gain exp like everyone else?
Kread-EX
A. The easiest way is to use Nightshade's Menu Common Event and shove the script call inside a common event.

B. Depends of your battle system. If you're using the default, try this:
CODE
class Scene_Battle < Scene_Base
  #--------------------------------------------------------------------------
  # * Display Level Up
  #--------------------------------------------------------------------------
  def display_level_up
    exp = $game_troop.exp_total
    for actor in $data_actors
      next if actor == nil || !actor.found
      last_level = actor.level
      last_skills = actor.skills
      actor.gain_exp(exp, true)
    end
    wait_for_message
  end
end
Uindo_Ookami
ok and i use the Tankentai Side-view Battle system i think?
dotsonface
biggrin.gif nice edit!
luigi400000
Great script! Love it, im gonna try to put it on, hopefully it wont crash...
luigi400000
And.................. Crash, what did I do to make it crash? I put the script in the right place.
It only seems to crash when I try to lock actors 1, 2, and 3 as well as adding actors 5 and 10 to the roster, uh, help?

Here's the crash report thing.



Sorry about double posting.

EDIT: AH HA! Ok, so it crashes when I try to add actor 3! So I took off
"$game_party.members[3].actor.required = true"
It worked, but then only actor 2 and 3 are locked, but not 1, this confuses me because i took off actor 3's script thing. Someone know whats going on here?
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2013 Invision Power Services, Inc.