RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
[XP] Help with Vehicle Party Switcher Script. No Method error

0 Members and 1 Guest are viewing this topic.

**
Rep: +0/-0Level 78
RMRK Junior
Hi, this is my first script and I think I'm doing it wrong. First let me explain what the script does, then I'll explain the errors and post the scripts. The whole point of this script is to save the formation of the character's party, switch out that party for a special Actor that acts as the party's ship or vehicle. This way, in battle you use the vehicle's stats, skills, weapons, battler, etc. instead of the party. My game is kind of like Star Trek online or something where you have your Captain and his crew, which choose your formation, and then when you teleport to your ship, it saves your current party, removes them, and adds the current ship actor based on a variable which holds the id of the current vehicle you own.

Here's the party changer script I'm using to change the formation of the party, so that you can choose your officers or crew that come with you.

Spoiler for:
Code: [Select]
#===================================
#  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.
#    And Leon Westbrooke for making it.
#
#
#  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.
#     $scene = Scene_Party_Change.new
#       -to activate party changer scene   
#
#
#  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

Here's the script I made to save the current formation of the party and switch to the ship and then switch back to the party when you teleport back down to a planet.

Spoiler for:
Code: [Select]
#===================================
#  Switch Party to Vehicle Add On for Party Changing System
#  by Outlandish, based on the Party Changing System by Leon_Westbrooke
#   -v 0.1
#----------------------------------------------------------------------
#  Instructions:  Place above main, but below all other default scripts.

#  Features:
#  This system is designed to use an actor as a vehicle so that in battle
#  You fight with your vehicle and it's stats, weapons, skills, etc. and not
#  The character party's.
#  Chose a game variable that will hold the id of the "ship" actor
#  This variable should contain the actor index id of the ship or vehicle you currently own
#  This way, when entering battle while in a ship, you use the ship's battler and weapons, skills, etc.

CURRENT_SHIP_VAR = 14  # Change this to what ever variable you are using to track current ship
MAIN_CAPTAIN = 0 #Change this to the actor id of whichever actor is your Captain
  #  This way we can lock the captain


#==================================================
#   Party_Ship
#==================================================
class Party_Ship
 
  def switch_to_ship
    @party_size = $game_party.actors.size # Save the current size of the party for later
    for i in 0...$game_party.actors.size
      $current_party[i] = $game_actors[$game_party.party_members[i]] #First save actor into an array
      $game_party.remove_actor_from_party($game_actors[$game_party.party_members[i]])
      #Now remove that actor and put him in reserve
    end
    # This uses a game variable to tell which ship you have and makes that the only party member.
    # It also locks the party ship and makes the max size of the party to one so other characters cant be added
    ship = $game_variables[CURRENT_SHIP_VAR]
    $game_party.add_actor(ship)
    $game_party.locked.push(ship)
    $game_party.min_size = 1
    $game_party.max_size = 1 # Make sure you can't add other party members
    $game_player.refresh
  end


  def switch_to_party
    # First remove the ship or vehicle actor from the party
    ship = $game_variables[CURRENT_SHIP_VAR]
    $game_party.remove_actor(ship)
    $game_party.min_size = 1
    $game_party.max_size = 4 # Make sure you can add other party members
    for i in 0...@party_size
      $game_party.add_actor_to_party( $current_party[i]) # Add the actors to the party
    end
    $game_party.locked.push(MAIN_CAPTAIN) # Lock the main character as he's the captain.
    $game_player.refresh
  end
end

Now the script probably has some problems with it, but the biggest problem I'm having is trying to call the methods in the script. I'm not sure how to do that. I've been using this code in an event to call the script:

Code: [Select]
$Party_Ship.switch_to_ship

When I do I get this error:


I know I must be going about it the wrong way. This is my first attempt at a script, as I said, and I'd like to get it working. Any help would be very much appreciated. Also if you need more info please let me know.
« Last Edit: June 18, 2010, 03:50:56 PM by outlandish »

*****
Rep:
Level 84
This text is way too personal.
Bronze - GIAW 11 (Hard)Silver - GIAW Halloween
Think you'd call it with Party_Ship.switch_to_ship instead of $Party, but I haven't tried it yet.

**
Rep: +0/-0Level 78
RMRK Junior
Thanks for the quick reply! I tried it but now I got a different error, which may be something wrong with the script itself? I don't know.

Here's the code I used in the event to call the method in my script:
Code: [Select]
Party_Ship.switch_to_ship

But then I got this error. It says the method is undefined. I'm not sure what I'm doing wrong.


*****
Rep:
Level 84
This text is way too personal.
Bronze - GIAW 11 (Hard)Silver - GIAW Halloween
Try adding:

Code: [Select]
  def initialize(switching_to_ship = true)
    if switching_to_ship
      switch_to_ship
    else
      switch_to_party
    end
  end

And calling it with Party_Ship.new(true)

**
Rep: +0/-0Level 78
RMRK Junior
Thanks very much for your help. I can call the script now and that part works. That's one part down!  ;D

But I'm hoping someone can help me with the switch_to_ship method of my script and possibly the second method too. The first method keeps crashing on me and I keep trying different variations but I'm not getting it right.

The whole point of the switch_to_ship method is to save the current actor ids of the members in the party into a variable so I can restore them later. Then remove them all using the command in the Party Switcher script which removes them from the active party and puts them in reserve. Then it checks a game variable to see which actor is representing the party's current ship and then adds that actor "vehicle" to the party. Then it locks that character so that the player can't remove the ship while flying and sets the max party size to 1 so that no other characters can be added. I want to use an actor as the vehicle so that I can use it's battler, stats, weapons, skills, etc. in battle as that's part of the point of my game is having starship battles.

The problem I'm having is I'm using a for loop to run through each character in the party, but I'm not sure what variable holds the id of the members of the party. I think that's where I'm getting the errors. Here's the script so far.

Spoiler for:
Code: [Select]
#===================================
#  Switch Party to Vehicle Add On for Party Changing System
#  by Outlandish, based on the Party Changing System by Leon_Westbrooke
#   -v 0.1
#----------------------------------------------------------------------
#  Instructions:  Place above main, but below all other default scripts.

#  Features:
#  This system is designed to use an actor as a vehicle so that in battle
#  You fight with your vehicle and it's stats, weapons, skills, etc. and not
#  The character party's.
#  Chose a game variable that will hold the id of the "ship" actor
#  This variable should contain the actor index id of the ship or vehicle you currently own
#  This way, when entering battle while in a ship, you use the ship's battler and weapons, skills, etc.

CURRENT_SHIP_VAR = 14  # Change this to what ever variable you are using to track current ship
MAIN_CAPTAIN = 0 #Change this to the actor id of whichever actor is your Captain
                 #This way we can lock the captain

# Try calling the script with:
# Party_Ship.new(true) # For when you want to enter the ship.
 
#==================================================
#   Party_Ship
#==================================================
class Party_Ship
 

 
  def initialize(switching_to_ship = true)
    if switching_to_ship
      switch_to_ship
    else
      switch_to_party
    end
  end

 
  def switch_to_ship
     @party_size = $game_party.actors.size # Save the current size of the party for later
     for i in 1..$game_party.actors.size
       @actors[i] = $Game_Party.actors(i)
       #Trying to save actor in party to an array to restore him later in order of formation
       #I want to use the for loop to save the actor id of each member of the party in order
       #so that I can restore him later.
       #Now remove that actor and put him in reserve using the Party Changer script
       $game_party.remove_actor_from_party($game_party.actors[i])
     end
     # This uses a game variable to tell which ship you have and makes that the only party member.
     # It also locks the party ship and makes the max size of the party to one so other characters cant be added
     ship = $game_variables[CURRENT_SHIP_VAR]
     $game_party.add_actor(ship)
     $game_party.locked.push(ship)
     $game_party.min_size = 1
     $game_party.max_size = 1 # Make sure you can't add other party members
     $game_player.refresh
  end


  def switch_to_party
    # First remove the ship or vehicle actor from the party
    ship = $game_variables[CURRENT_SHIP_VAR]
    $game_party.remove_actor(ship)
    $game_party.min_size = 1
    $game_party.max_size = 4 # Make sure you can add other party members
    for i in 1..@party_size
      $game_party.add_actor_to_party( @actors[i]) # Add the actors to the party
    end
    $game_party.locked.push(MAIN_CAPTAIN) # Lock the main character as he's the captain.
    $game_player.refresh
  end
end

And here's the cool formation script that I'm using:

Spoiler for:
Code: [Select]
#===================================
#  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.
#    And Leon Westbrooke for making it.
#
#
#  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.
#     $scene = Scene_Party_Change.new
#       -to activate party changer scene   
#
#
#  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

This is my first attempt at making a script and I really want to make it work. I suppose I could have just requested it, but I really wanted to get it right. But I'm too much of a noob to figure it out.

Sorry, I almost forgot to post the current error I'm getting.



Thanks so much.

*****
Rep:
Level 84
This text is way too personal.
Bronze - GIAW 11 (Hard)Silver - GIAW Halloween
Uh, if your using XP, I think you should be replacing "actors" with members. Haven't tested it though.

EDIT: Mixed it up with VX...
« Last Edit: June 19, 2010, 08:58:49 PM by cozziekuns »

**
Rep: +0/-0Level 78
RMRK Junior
Thanks for the quick reply. I think I figured out how to get the id of the members of the party. I tested it with this:

Code: [Select]
     for i in 0...4
       print $game_party.actors[i].id
     end

And it printed the id of each actor in the party. But what I think my biggest problem is trying to store those id numbers in a variable. I've tried to use this:

Code: [Select]
    for i in 0...$game_party.actors.size
       @party[i] = $game_party.actors[i].id

but I always get this error:



I think I'm not using the @party right. I was trying to make it an array that saved the id of each actor in the party with each iteration of the for loop. I'd appreciate it so much if you could correct me on how I should store those ids. Thanks so much.

*****
Rep:
Level 84
This text is way too personal.
Bronze - GIAW 11 (Hard)Silver - GIAW Halloween
Could I see your whole script?

**
Rep: +0/-0Level 78
RMRK Junior
Sure. Sorry about that. Here's the current script.
Spoiler for:
Code: [Select]
#===================================
#  Switch Party to Vehicle Add On for Party Changing System
#  by Outlandish, based on the Party Changing System by Leon_Westbrooke
#   -v 0.1
#----------------------------------------------------------------------
#  Instructions:  Place above main, but below all other default scripts.

#  Features:
#  This system is designed to use an actor as a vehicle so that in battle
#  You fight with your vehicle and it's stats, weapons, skills, etc. and not
#  The character party's.
#  Chose a game variable that will hold the id of the "ship" actor
#  This variable should contain the actor index id of the ship or vehicle you currently own
#  This way, when entering battle while in a ship, you use the ship's battler and weapons, skills, etc.

CURRENT_SHIP_VAR = 14  # Change this to what ever variable you are using to track current ship
MAIN_CAPTAIN = 0 #Change this to the actor id of whichever actor is your Captain
                 #This way we can lock the captain

# Try calling the script with:
# Party_Ship.new(true) # For when you want to enter the ship.
 
#==================================================
#   Party_Ship
#==================================================
class Party_Ship
 

 
  def initialize(switching_to_ship = true)
    if switching_to_ship
      switch_to_ship
 
    else
      switch_to_party
    end
  end

 
  def switch_to_ship
     @party = []
     @party_size = $game_party.actors.size
     for i in 0...@party_size
       @party[i] = $game_party.actors[i].id
       $game_party.remove_actor_from_party($game_party.actors[i].id)
     end
     ship = $game_variables[CURRENT_SHIP_VAR]
     $game_party.add_actor(ship)
     $game_party.locked.push(ship)
     $game_party.max_size = 1 # Make sure you can't add other party members
     $game_player.refresh
  end


  def switch_to_party
    # First remove the ship or vehicle actor from the party
    ship = $game_variables[CURRENT_SHIP_VAR]
    $game_party.remove_actor(ship)
    $game_party.max_size = 4 # Make sure you can add other party members
    for i in 0...@party_size
      $game_party.add_actor_to_party(@party[i]) # Add the actors to the party
    end
    $game_party.locked.push(MAIN_CAPTAIN) # Lock the main character as he's the captain.
    $game_player.refresh
  end
end



*****
Rep:
Level 84
This text is way too personal.
Bronze - GIAW 11 (Hard)Silver - GIAW Halloween
Weird because I get a different error, but an error nonetheless. Have you tried putting the formation script above your switch party to vehicle script?

**
Rep: +0/-0Level 78
RMRK Junior
yeah, the formation script is above it. I'm not getting errors anymore but now what it does is remove two of the party members but not the other two. Here's the script as is now. I've been messing with it.

Spoiler for:
Code: [Select]
#===================================
#  Switch Party to Vehicle Add On for Party Changing System
#  by Outlandish, based on the Party Changing System by Leon_Westbrooke
#   -v 0.1
#----------------------------------------------------------------------
#  Instructions:  Place above main, but below all other default scripts.

#  Features:
#  This system is designed to use an actor as a vehicle so that in battle
#  You fight with your vehicle and it's stats, weapons, skills, etc. and not
#  The character party's.
#  Chose a game variable that will hold the id of the "ship" actor
#  This variable should contain the actor index id of the ship or vehicle you currently own
#  This way, when entering battle while in a ship, you use the ship's battler and weapons, skills, etc.

CURRENT_SHIP_VAR = 14  # Change this to what ever variable you are using to track current ship
MAIN_CAPTAIN = 0 #Change this to the actor id of whichever actor is your Captain
                 #This way we can lock the captain

# Try calling the script with:
# Party_Ship.new(true) # For when you want to enter the ship.
 
#==================================================
#   Party_Ship
#==================================================
class Party_Ship
 

 
  def initialize(switching_to_ship = true)
    if switching_to_ship
      switch_to_ship
     else
      switch_to_party
    end
  end

 
  def switch_to_ship
     $party = []
     $party_size = $game_party.actors.size
     for i in 0...$party_size
       p $game_party.actors[i].id
       $party[i] = $game_party.actors[i].id
       $game_party.remove_actor_from_party($game_party.actors[i].id)
     end
     ship = $game_variables[CURRENT_SHIP_VAR]
     $game_party.add_actor(ship)
     $game_party.locked.push(ship)
     $game_party.max_size = 1 # Make sure you can't add other party members
     $game_player.refresh
  end


  def switch_to_party
    # First remove the ship or vehicle actor from the party
    ship = $game_variables[CURRENT_SHIP_VAR]
    $game_party.remove_actor(ship)
    $game_party.max_size = 4 # Make sure you can add other party members
    for i in 0...$party_size
      $game_party.add_actor_to_party($party[i]) # Add the actors to the party
    end
    $game_party.locked.push(MAIN_CAPTAIN) # Lock the main character as he's the captain.
    $game_player.refresh
  end
end



My starting party is Aluxes, Basil, Gloria, and Hilda. What it's doing at the moment is removing Aluxes and Gloria, then removing Dorthy (id 4) twice, even though she's not in the party. Then adds index 9 which is my spaceship character. Oh, one thing that I had to do to avoid an error, is create or choose an actor to be the ship, and then use an event to set Game Variable 14 to the id of that actor. That will add the vehicle and take it away. The weird thing is, that if I comment out line 45:

Code: [Select]
      $game_party.remove_actor_from_party($game_party.actors[i].id)

then this line 43:

Code: [Select]
p $game_party.actors[i].id

prints out the correct ids in order of the actual members of my party. But when line 45 is there it prints the wrong sequence of actor ids. I can't figure out why.


**
Rep: +0/-0Level 78
RMRK Junior
Ok, I think I got it working.  :D  Here's the latest version.

Spoiler for:
Code: [Select]
#===================================
#  Switch Party to Vehicle Add On for Party Changing System
#  by Outlandish, based on the Party Changing System by Leon_Westbrooke
#   -v 0.1
#----------------------------------------------------------------------
#  Instructions:  Place above main, but below all other default scripts and
#  below the Party Changing System script. This add on is designed to work with
#  Leon Westbrookes Party Changing System v 1.2
#
#  Features:
#  This system is designed to use an actor as a vehicle so that in battle
#  You fight with your vehicle and it's battler, stats, weapons, skills, etc.
#  and not the character party's.
#  Chose a game variable that will hold the id of the "ship" actor
#  This variable should contain the actor index id of the ship or vehicle you currently own
#  This way, when entering battle while in a ship, you use the ship's battler and weapons, skills, etc.

CURRENT_SHIP_VAR = 14 
# Change this to what ever variable you are using to track current ship
# To set this up you need to create at least one actor that is a "vehicle" or ship
# Then use an event to set game variable 14 (or which ever one you choose above
# To the actor id of whichever actor is your current ship. Vehicle actors can
# have special classes like: Light Cruiser, Destroyer, Heavy Fighter, etc.
# The player could upgrade his ship, just use an event to change the current ship
# variable to the actor id of a different "vehicle" actor

MAIN_CAPTAIN = 1 #Change this to the actor id of whichever actor is your Captain
                 #This way we can lock the captain

# Try calling the script with:
# Party_Ship.new(true) # For when you want to enter the ship.
 
#==================================================
#   Party_Ship
#==================================================
class Party_Ship
 

 
  def initialize(switching_to_ship = true)
    if switching_to_ship
      switch_to_ship
     else
      switch_to_party
    end
  end

 
  def switch_to_ship
     $party = []
     $party_size = $game_party.actors.size
     for i in 0...$party_size
       #p $game_party.actors[i].id
       $party[i] = $game_party.actors[i].id
     end
     for i in 0...$data_actors.size
       $game_party.remove_actor_from_party(i)
     end
     ship = $game_variables[CURRENT_SHIP_VAR]
     $game_party.add_actor(ship)
     $game_party.locked.push(ship)
     $game_party.max_size = 1 # Make sure you can't add other party members
     $game_player.refresh
  end


  def switch_to_party
    # First remove the ship or vehicle actor from the party
    ship = $game_variables[CURRENT_SHIP_VAR]
    $game_party.remove_actor(ship)
    $game_party.max_size = 4 # Make sure you can add other party members
    for i in 0...$party_size
      $game_party.add_actor_to_party($party[i]) # Add the actors to the party
    end
    $game_party.locked.push(MAIN_CAPTAIN) # Lock the main character as he's the captain.
    $game_player.refresh
  end
end



*****
Rep:
Level 84
This text is way too personal.
Bronze - GIAW 11 (Hard)Silver - GIAW Halloween
Glad you got it working. Have you tried switching to party yet?

Also, you might want to replace your global variables with class variables. That way you don't have to take up a global variable (unless that's intentional).

**
Rep: +0/-0Level 78
RMRK Junior
Thanks. Yes switching to party seems to work too. It seems like it's working well. That's a good idea about using class variables. How would I do that. I tried before but just got errors so I must not have been doing it right. Thanks for all your help too.  ;D

*****
Rep:
Level 84
This text is way too personal.
Bronze - GIAW 11 (Hard)Silver - GIAW Halloween
Basically just do a quick find and replace for $party. Replace $party with @@party. Alternatively, you could have created the variable through the initialize method, and you probably only would have had to use @party.

This is a good tutorial on variables.
« Last Edit: June 19, 2010, 11:41:03 PM by cozziekuns »

**
Rep: +0/-0Level 78
RMRK Junior
Thanks so much!  :) I fixed it.

Here's the final script.

Spoiler for:
Code: [Select]
#===================================
#  Switch Party to Vehicle Add On for Party Changing System
#  by Outlandish, based on the Party Changing System by Leon_Westbrooke
#   -v 0.1
#----------------------------------------------------------------------
#  Instructions:  Place above main, but below all other default scripts and
#  below the Party Changing System script. This add on is designed to work with
#  Leon Westbrookes Party Changing System v 1.2
#
#  Features:
#  This system is designed to use an actor as a vehicle so that in battle
#  You fight with your vehicle and it's battler, stats, weapons, skills, etc.
#  and not the character party's.
#  Chose a game variable that will hold the id of the "ship" actor
#  This variable should contain the actor index id of the ship or vehicle you currently own
#  This way, when entering battle while in a ship, you use the ship's battler and weapons, skills, etc.

CURRENT_SHIP_VAR = 14 
# Change this to what ever variable you are using to track current ship
# To set this up you need to create at least one actor that is a "vehicle" or ship
# Then use an event to set game variable 14 (or which ever one you choose above
# To the actor id of whichever actor is your current ship. Vehicle actors can
# have special classes like: Light Cruiser, Destroyer, Heavy Fighter, etc.
# The player could upgrade his ship, just use an event to change the current ship
# variable to the actor id of a different "vehicle" actor

MAIN_CAPTAIN = 1
#Change this to the actor id of whichever actor is your Captain
#This way we can lock the captain

IN_SHIP = 12
# This is the switch that lets the game know you are in a ship. Used for events.

# Try calling the script with:
# Party_Ship.new(true) # For when you want to enter the ship.
 
#==================================================
#   Party_Ship
#==================================================
class Party_Ship
 

 
  def initialize(switching_to_ship = true)
    if switching_to_ship
      switch_to_ship
     else
      switch_to_party
    end
  end

 
  def switch_to_ship
     @@party = []
     @@party_size = $game_party.actors.size
     for i in 0...@@party_size
       #p $game_party.actors[i].id
       @@party[i] = $game_party.actors[i].id
     end
     for i in 0...$data_actors.size
       $game_party.remove_actor_from_party(i)
     end
     ship = $game_variables[CURRENT_SHIP_VAR]
     $game_party.add_actor(ship)
     $game_party.locked.push(ship)
     $game_party.max_size = 1 # Make sure you can't add other party members
     $game_switches[IN_SHIP] = true #Lets the game know you're in a ship
     $game_player.refresh
  end


  def switch_to_party
    # First remove the ship or vehicle actor from the party
    ship = $game_variables[CURRENT_SHIP_VAR]
    $game_party.remove_actor(ship)
    $game_party.max_size = 4 # Make sure you can add other party members
    for i in 0...@@party_size
      $game_party.add_actor_to_party(@@party[i]) # Add the actors to the party
    end
    $game_party.locked.push(MAIN_CAPTAIN) # Lock the main character as he's the captain.
    $game_switches[IN_SHIP] = false #Lets the game know you're not in a ship
    $game_player.refresh
  end
end