Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

A modified party switcher

Hi,

I've browsed the forums and the internets, and I found Dargor's awesome party changer.
However; I need a few things to be changed with the script, I'll put them in a list, and maybe you could tackle the problems one by one?
Ok, the list:
  • I need actor one to stay fixed in the party unless I specify that he should leave
  • I need for the party to only hold three members at a time
  • I need to be able to activate and de-activate the changer menu access at will

Four individual problems, maybe not worthy of a list but I made a list so the problems are specified individually.

I have Dargor's scripts just in case:
Code:
#==============================================================================
# ** Commands Manager
#------------------------------------------------------------------------------
#  Author: Dargor
#  Version 1.2
#  20/09/2007
#==============================================================================
# * Instructions
#------------------------------------------------------------------------------
# - To add a command to the command window use:
#               @command_window.add_command("command")
# - To remove a command to the command window use:
#               @command_window.remove_command("command")
# - To rearrange the commands in the command window use:
#               @command_window.set_commands(["cmd1","cmd2","cmd3"...])
# - You can also rearrange the default menu commands using:
#               $game_system.menu_commands = ["cmd1","cmd2","cmd3"...]
#------------------------------------------------------------------------------
# * Note
#------------------------------------------------------------------------------
# - This script rewrites the update_command and update_status methods
#   in Scene_Menu.
#==============================================================================

#==============================================================================
# ** Game_System
#------------------------------------------------------------------------------
#  This class handles data surrounding the system. Backround music, etc.
#  is managed here as well. Refer to "$game_system" for the instance of 
#  this class.
#==============================================================================

class Game_System
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :default_commands     # default commands
  attr_accessor :menu_commands        # menu commands
  attr_accessor :commands_max         # commands max
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  alias dargor_menu_commands_initialize initialize
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    @default_commands = ["Item","Skill","Equip","Status","Save","End Game"]
    @menu_commands = ["Item","Skill","Equip","Status","Save","End Game"]
    @commands_max = 6
    dargor_menu_commands_initialize
  end
end

#==============================================================================
# ** Window_Command
#------------------------------------------------------------------------------
#  This window deals with general command choices.
#==============================================================================

class Window_Command < Window_Selectable
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :commands       # commands
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  alias dargor_index_update update
  alias dargor_disable_item disable_item
  alias dargor_draw_item draw_item
  #--------------------------------------------------------------------------
  # * Add Command (command)
  #--------------------------------------------------------------------------
  def add_command(command)
    return if @commands.include?(command)
    @commands.push(command)
    set_commands(@commands)
  end
  #--------------------------------------------------------------------------
  # * Remove Command (command)
  #--------------------------------------------------------------------------
  def remove_command(command)
    @commands.delete(command)
    set_commands(@commands)
  end
  #--------------------------------------------------------------------------
  # * Set Commands (commands)
  #--------------------------------------------------------------------------
  def set_commands(commands)
    return if commands == [] or commands == nil
    @commands = commands
    @item_max = @commands.size
    self.contents = Bitmap.new(width - 32, @item_max * 32)
    refresh
    self.height = 32 + (32 * $game_system.commands_max)
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #     color : text color
  #--------------------------------------------------------------------------
  def draw_item(index, color)
    return if index.nil?
    dargor_draw_item(index, color)
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    dargor_index_update
    update_index
  end
  #--------------------------------------------------------------------------
  # * Frame Update (index)
  #--------------------------------------------------------------------------
  def update_index
    if self.index >= @commands.size
      self.index = @commands.size-1
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Disable Item
  #     index : item number / item string
  #--------------------------------------------------------------------------
  def disable_item(index)
    if index.is_a?(String)
      new_index = @commands.index(index)
      draw_item(new_index, disabled_color)
    else
      draw_item(index, disabled_color)
    end
  end
  #--------------------------------------------------------------------------
  # * Enable Item
  #     index : item number
  #--------------------------------------------------------------------------
  def enable_item(index)
    draw_item(index, normal_color)
  end
end

#==============================================================================
# ** Scene_Menu
#------------------------------------------------------------------------------
#  This class performs menu screen processing.
#==============================================================================

class Scene_Menu
  #--------------------------------------------------------------------------
  # * Alias listing
  #--------------------------------------------------------------------------
  alias add_remove_command_main main
  alias add_remove_command_update update
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Default menu commands
    @default_commands = $game_system.default_commands
    # Create an empty array of command
    @commands = []
    # Call the original main method
    add_remove_command_main
  end
  #--------------------------------------------------------------------------
  # * Set Commands Access
  #--------------------------------------------------------------------------
  def set_commands_access
    # Reinitialize menu commands
    unless @command_window.commands == @commands
      @command_window.set_commands($game_system.menu_commands)
    end
    # Se basic commands name
    s1 = @default_commands[0]
    s2 = @default_commands[1]
    s3 = @default_commands[2]
    s4 = @default_commands[3]
    s5 = @default_commands[4]
    # If number of party members is 0
    if $game_party.actors.size == 0
      # Disable items, skills, equipment, and status
      @command_window.disable_item(s1)
      @command_window.disable_item(s2)
      @command_window.disable_item(s3)
      @command_window.disable_item(s4)
    end
    # If save is forbidden
    if $game_system.save_disabled
      # Disable save
      @command_window.disable_item(s5)
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Set commands access
    set_commands_access
    # Set the array equal to the current commands
    @commands = @command_window.commands
    # Set commands access
    # Call the original update method
    add_remove_command_update
  end
  #--------------------------------------------------------------------------
  # * Frame Update (when command window is active)
  #--------------------------------------------------------------------------
  def update_command
    # Assign @command_window.index to its strings
    command = @commands[@command_window.index]
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Switch to map screen
      $scene = Scene_Map.new
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # If command other than save or end game, and party members = 0
      if $game_party.actors.size == 0 and @command_window.index < 4
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # Branch by command window cursor position
      case command
      when @default_commands[0]
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to item screen
        $scene = Scene_Item.new
      when @default_commands[1]
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Make status window active
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when @default_commands[2]
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Make status window active
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when @default_commands[3]
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Make status window active
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when @default_commands[4]
        # If saving is forbidden
        if $game_system.save_disabled
          # Play buzzer SE
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to save screen
        $scene = Scene_Save.new
      when @default_commands[5]
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to end game screen
        $scene = Scene_End.new
      end
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (when status window is active)
  #--------------------------------------------------------------------------
  def update_status
    # Assign @command_window.index to its strings
    command = @commands[@command_window.index]
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Make command window active
      @command_window.active = true
      @status_window.active = false
      @status_window.index = -1
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Branch by command window cursor position
      case command
      when @default_commands[1]
        # If this actor's action limit is 2 or more
        if $game_party.actors[@status_window.index].restriction >= 2
          # Play buzzer SE
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to skill screen
        $scene = Scene_Skill.new(@status_window.index)
      when @default_commands[2]
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to equipment screen
        $scene = Scene_Equip.new(@status_window.index)
      when @default_commands[3]
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to status screen
        $scene = Scene_Status.new(@status_window.index)
      end
      return
    end
  end
end
Code:
#==============================================================================
# ** Party Changer
#------------------------------------------------------------------------------
#  Author: Dargor
#  Version 3.3
#  16/12/2007
#==============================================================================
#==============================================================================
# ** Game_Temp
#------------------------------------------------------------------------------
#  This class handles temporary data that is not included with save data.
#  Refer to "$game_temp" for the instance of this class.
#==============================================================================
class Game_Temp
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :selected_members         # selected members
  attr_accessor :party_members            # party members
  attr_accessor :members_gain_exp         # members can gain exp
  attr_accessor :members_exp_rate         # exp % gained
  attr_accessor :party_changer_in_battle  # party changer in battle
  attr_accessor :battle_party_args        # in-battle party changer arguments
  attr_accessor :menu_party_args          # in-menu party changer arguments
  attr_accessor :multiple_party_battle    # open party changer when all actors collapse
  attr_accessor :multiple_teams_args
  attr_accessor :multiple_teams
  attr_accessor :teams_destination
  attr_accessor :current_team
  attr_accessor :use_custom_graphic
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  alias party_changer_initialize initialize
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    @selected_members = []
    @party_members = []
    @members_gain_exp = true
    @members_exp_rate = 30
    @party_changer_in_battle = true
    @battle_party_args = [1, 4,[],[]]
    @menu_party_args = [1, 4,[],[]]
    @multiple_teams = false
    @multiple_teams_args = [
                            [1, 2,[2],[2]],
                            [1, 2,[5],[5]],
                            [1, 4,[3],[3]]
                            ]
    @teams_destination = [
                          [10,7,1,2],
                          [9,8,1,2],
                          [11,8,1,2]
                         ]
    @current_team = [0, []]
    @multiple_party_battle = true
    @use_custom_graphic = true
    party_changer_initialize
  end
end
#==============================================================================
# ** Window_Base
#------------------------------------------------------------------------------
#  This class is for all in-game windows.
#==============================================================================
class Window_Base
  #--------------------------------------------------------------------------
  # * Draw Graphic
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #--------------------------------------------------------------------------
  def draw_actor_graphic(actor, x, y, selected = false)
    bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
    cw = bitmap.width / 4
    ch = bitmap.height / 4
    src_rect = Rect.new(0, 0, cw, ch)
    opacity = selected ? 160 : 255
    self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect,opacity)
  end
end
#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
#  This class handles the actor. It's used within the Game_Actors class
#  ($game_actors) and refers to the Game_Party class ($game_party).
#==============================================================================
class Game_Actor
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :position       # position
  attr_accessor :locked         # locked in the reserve
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  alias party_changer_setup setup
  #--------------------------------------------------------------------------
  # * Setup (actor_id)
  #--------------------------------------------------------------------------
  def setup(actor_id)
    party_changer_setup(actor_id)
    actor = $data_actors[actor_id]
    @position = $data_classes[actor.class_id].position
    @locked = false
  end
end

#==============================================================================
# ** Window_Command
#------------------------------------------------------------------------------
#  This window deals with general command choices.
#==============================================================================
class Window_Command
  #--------------------------------------------------------------------------
  # * Enable Item
  #     index : item number
  #--------------------------------------------------------------------------
  def enable_item(index)
    draw_item(index, normal_color)
  end
end

#==============================================================================
# ** Game_Party
#------------------------------------------------------------------------------
#  This class handles the party. It includes information on amount of gold 
#  and items. Refer to "$game_party" for the instance of this class.
#==============================================================================
class Game_Party
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :members          # members
  attr_accessor :team_members
  attr_accessor :team_location
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  alias party_changer_initialize initialize
  alias party_changer_refresh refresh
  alias party_changer_add_actor add_actor
  alias party_changer_remove_actor remove_actor
  alias party_changer_setup_starting_members setup_starting_members
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    party_changer_initialize
    @members = []
    @team_members = []
    @team_gold = []
    @team_items = []
    @team_armors = []
    @team_weapons = []
    @team_location = []
  end
  def setup_teams(id, members, location)
    @team_members[id] = members
    if @team_location[id].nil?
      @team_location[id] = []
    end
    @team_location[id][0] = location[0]
    @team_location[id][1] = location[1]
    @team_location[id][2] = location[2]
    @team_location[id][3] = location[3]
  end
  def save_team_data
    team_id = $game_temp.current_team[0]
    @team_members[team_id] = $game_party.actors.dup
    if @team_location[team_id].nil?
      @team_location[team_id] = []
    end
    @team_location[team_id][0] = $game_player.x
    @team_location[team_id][1] = $game_player.y
    @team_location[team_id][2] = $game_map.map_id
    @team_location[team_id][3] = $game_player.direction
  end
  def switch(team_id)
    if $scene.is_a?(Scene_Map)
      $game_party.actors.clear
      for i in 0...@team_members[team_id].size
        $game_party.add_actor(@team_members[team_id][i].id)
      end
      $game_temp.player_new_x = @team_location[team_id][0]
      $game_temp.player_new_y = @team_location[team_id][1]
      $game_temp.player_new_map_id = @team_location[team_id][2]
      $game_temp.player_new_direction = @team_location[team_id][3]
    end
  end
  #--------------------------------------------------------------------------
  # * Initial Party Setup
  #--------------------------------------------------------------------------
  def setup_starting_members
    party_changer_setup_starting_members
    for i in $data_system.party_members
      actor = $game_actors[i]
      if not @members.include?(actor)
        @members.push(actor)
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Refresh Party Members
  #--------------------------------------------------------------------------
  def refresh
    # Actor objects split from $game_actors right after loading game data
    # Avoid this problem by resetting the actors each time data is loaded.
    party_changer_refresh
    new_members = []
    for i in [email=0...@members.size]0...@members.size[/email]
      if $data_actors[@members[i].id] != nil
        new_members.push($game_actors[@members[i].id])
      end
    end
    @members = new_members
  end
  #--------------------------------------------------------------------------
  # * Add Actor
  #     actor_id : actor ID
  #--------------------------------------------------------------------------
  def add_actor(actor_id)
    party_changer_add_actor(actor_id)
    add_member(actor_id)
  end
  #--------------------------------------------------------------------------
  # * Remove Actor
  #     actor_id : actor ID
  #--------------------------------------------------------------------------
  def remove_actor(actor_id)
    party_changer_remove_actor(actor_id)
    remove_member(actor_id)
  end
  #--------------------------------------------------------------------------
  # * Add a Member
  #     actor_id : actor ID
  #--------------------------------------------------------------------------
  def add_member(actor_id)
    # Get actor
    actor = $game_actors[actor_id]
    # If this actor is not in the party
    if not @members.include?(actor)
      # Add member
      @members.push(actor)
      # Refresh player
      $game_player.refresh
    end
  #--------------------------------------------------------------------------
  # * Determine Every Members are Dead
  #--------------------------------------------------------------------------
  def members_all_dead?
    available_members = []
    for i in [email=0...@members.size]0...@members.size[/email]
      next if @members[i].locked
      available_members << @members[i]
    end
    # If number of party members is 0
    if $game_party.members.size == 0
      return false
    end
    # If an actor is in the party with 0 or more HP
    for member in available_members
      if member.hp > 0
        return false
      end
    end
    # All members dead
    return true
  end
  end
  #--------------------------------------------------------------------------
  # * Remove Member
  #     actor_id : actor ID
  #--------------------------------------------------------------------------
  def remove_member(actor_id)
    # Delete member
    @members.delete($game_actors[actor_id])
    # Refresh player
    $game_player.refresh
  end
end

#==============================================================================
# ** Window_Base
#------------------------------------------------------------------------------
#  This class is for all in-game windows.
#==============================================================================
class Window_Base < Window
  #--------------------------------------------------------------------------
  # * Draw Actor Position
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #--------------------------------------------------------------------------
  def draw_actor_position(actor, x, y)
    position = actor.position
    case position
    when 0
      text = 'Front'
    when 1
      text = 'Middle'
    when 2
      text = 'Rear'
    end
    cx = contents.text_size(text).width
    self.contents.draw_text(x,y,cx,32,text)
  end
end

#==============================================================================
# ** Window_MemberStatus
#------------------------------------------------------------------------------
#  This window displays a member's status on the party screen.
#==============================================================================
class Window_MemberStatus < Window_Base
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :actor      # actor
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor : actor
  #--------------------------------------------------------------------------
  def initialize(actor)
    super(0, 64, 640, 160)
    self.contents = Bitmap.new(width - 32, height - 32)
    if $game_temp.in_battle 
      self.back_opacity = 160
    end
    @actor = actor
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh(current = 1, max = 1)
    self.contents.clear
    return if @actor.nil?
    draw_actor_name(@actor, 0, 0)
    draw_actor_class(@actor, 144, 0)
    draw_actor_position(@actor, 300, 0)
    draw_actor_level(@actor, 0, 32)
    draw_actor_state(@actor, 90, 32)
    draw_actor_exp(@actor, 0, 64)
    draw_actor_hp(@actor, 236, 32)
    draw_actor_sp(@actor, 236, 64)
    draw_actor_parameter(@actor, 396, 0, 0)
    draw_actor_parameter(@actor, 396, 32, 1)
    draw_actor_parameter(@actor, 396, 64, 2)
    if $game_temp.selected_members.include?(@actor)
      self.contents.draw_text(0,96,640,32,"- #{@actor.name} is already in the party")
    elsif $game_actors[@actor.id].locked
      self.contents.draw_text(0,96,640,32,"- #{@actor.name} is not available")  
    else
      self.contents.draw_text(0,96,640,32,"- #{@actor.name} is available")
    end
    self.contents.draw_text(480,96,160,32,"Page #{current} of #{max}")
  end
end

#==============================================================================
# ** Window_PartyMembers
#------------------------------------------------------------------------------
#  This window displays the party members on the party screen.
#==============================================================================
class Window_PartyMembers < Window_Selectable
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :members              # members
  attr_accessor :selected_members     # selected members
  attr_accessor :forced_members       # forced members
  #--------------------------------------------------------------------------
  # * Oject Initialization
  #--------------------------------------------------------------------------
  def initialize(forced_members=[])
    @members = $game_party.members
    height = 78 + (@members.size/4) * 50
    super(0,224,640,height)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.active = true
    if $game_temp.in_battle 
      self.back_opacity = 160
    end
    @index = 0
    @item_max = @members.size
    @column_max = 4
    @row_max = @members.size / 4
    @selected_members = []
    @forced_members = forced_members
    reset
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    for i in [email=0...@members.size]0...@members.size[/email]
      x = (i % 4) * 160
      y = (i/4) * 50
      actor = @members[i]
      selected = @selected_members[i]
      # A1
      opacity = selected == true ? 128 : 255
      if $game_temp.use_custom_graphic
        bitmap = RPG::Cache.picture("Actor_#{actor.name}")
        src_rect = bitmap.rect
        dest_rect = Rect.new(x+2, y+2, 124, 46)
        self.contents.stretch_blt(dest_rect, bitmap, src_rect, opacity) 
      else
        draw_actor_graphic($game_actors[actor.id], x+60, y+48, selected)
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Reset
  #--------------------------------------------------------------------------
  def reset
    if $game_temp.multiple_teams
      team_id = $game_temp.current_team[0]
      members = $game_temp.current_team[1]
      forced_members = []
      for i in 0...$game_temp.multiple_teams_args.size
        forced_members += $game_temp.multiple_teams_args[i][2]
      end
      for i in [email=0...@members.size]0...@members.size[/email]
        if members.include?(@members[i])
          @selected_members[i] = false
        end
        if forced_members.include?(@members[i].id)
          @selected_members[i] = true
        end
        if @members[i].locked
          @selected_members[i] = true
        end
      end
    else
      for i in [email=0...@members.size]0...@members.size[/email]
        @selected_members[i] = false
        if @forced_members.include?(@members[i])
          @selected_members[i] = true
        end
        if @members[i].locked
          @selected_members[i] = true
        end
      end
    end
    refresh
  end
  #--------------------------------------------------------------------------
  # * Cursor Rectangle Update
  #--------------------------------------------------------------------------
  def update_cursor_rect
    self.oy = (@index/8) * 100
    x = (@index % 4) * 160
    y = ((@index/4)% 2) * 50
    self.cursor_rect.set(x, y, 128, 50)
  end
end

#==============================================================================
# ** Window_Party
#------------------------------------------------------------------------------
#  This window displays the current party on the party screen.
#==============================================================================
class Window_Party < Window_Selectable
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :item_max             # item max
  attr_accessor :members              # members
  attr_accessor :forced_members       # forces members
  attr_accessor :selected_members     # selected members
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(forced_members=[])
    super(0,352,320,128)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.active = false
    @index = 0
    @column_max = 2
    @row_max = 2
    @members = []
    @forced_members = forced_members
    @selected_members = []
    @item_max = @members.size
    reset_selection
    reset_members
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    height = 128 + ((@members.size-1)/4) * 100
    self.contents = Bitmap.new(width - 32, height - 32)
    self.height = 128
    for i in [email=0...@members.size]0...@members.size[/email]
      x = (i % 2) * 160
      y = (i/2) * 50
      actor = @members[i]
      next if actor.nil?
      # A2
      if $game_temp.use_custom_graphic
        opacity = @selected_members[i] == true ? 128 : 255
        bitmap = RPG::Cache.picture("Actor_#{actor.name}")
        src_rect = bitmap.rect
        dest_rect = Rect.new(x+2, y+2, 124, 46)
        self.contents.stretch_blt(dest_rect, bitmap, src_rect, opacity) 
      else
        opacity = @selected_members[i]
        draw_actor_graphic($game_actors[actor.id], x+60, y+48,opacity)
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Reset Selection
  #--------------------------------------------------------------------------
  def reset_selection
    for i in [email=0...@members.size]0...@members.size[/email]
      @selected_members[i] = false
    end
    refresh
  end
  #--------------------------------------------------------------------------
  # * Reset Members
  #--------------------------------------------------------------------------
  def reset_members
    @members = []
    @forced_members.each do |member|
      # NIL M
      #next if member.nil?
      @members << member
    end
    refresh
  end
  #--------------------------------------------------------------------------
  # * Cursor Rectangle Update
  #--------------------------------------------------------------------------
  def update_cursor_rect
    return unless self.active
    self.oy = (@index/4) * 100
    x = (@index % 2) * 160
    y = ((@index/2)% 2) * 50
    self.cursor_rect.set(x, y, 128, 50)
  end
end
#==============================================================================
# ** Window_PartyCommand
#------------------------------------------------------------------------------
#  This window is used to select whether to fight or escape on the battle
#  screen.
#==============================================================================
class Window_PartyCommand < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, 640, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.back_opacity = 160
    if $game_temp.party_changer_in_battle
      @commands = ["Fight", "Escape", "Party"]
      @item_max = 3
      @column_max = 3
    else
      @commands = ["Fight", "Escape"]
      @item_max = 2
      @column_max = 2
    end
    # Draw Fight and Escape
    draw_item(0, normal_color)
    draw_item(1, $game_temp.battle_can_escape ? normal_color : disabled_color)
    # Draw Party if $game_temp.party_changer_in_battle is true
    draw_item(2, normal_color) if $game_temp.party_changer_in_battle
    self.active = false
    self.visible = false
    self.index = 0
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #     color : text character color
  #--------------------------------------------------------------------------
  def draw_item(index, color)
    self.contents.font.color = color
    if $game_temp.party_changer_in_battle
      rect = Rect.new(106 + index * 106 + 4, 0, 128 - 10, 32)
    else
      rect = Rect.new(160 + index * 160 + 4, 0, 128 - 10, 32)
    end
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.draw_text(rect, @commands[index], 1)
  end
  #--------------------------------------------------------------------------
  # * Cursor Rectangle Update
  #--------------------------------------------------------------------------
  def update_cursor_rect
    if $game_temp.party_changer_in_battle
      self.cursor_rect.set(106 + index * 106, 0, 128, 32)
    else
      self.cursor_rect.set(160 + index * 160, 0, 128, 32)
    end
  end
end
#==============================================================================
# ** Scene_Battle (part 2)
#------------------------------------------------------------------------------
#  This class performs battle screen processing.
#==============================================================================
class Scene_Battle
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  alias party_changer_update_phase2 update_phase2
  alias party_changer_start_phase5 start_phase5
  alias party_changer_update update
  #--------------------------------------------------------------------------
  # * Determine Battle Win/Loss Results
  #--------------------------------------------------------------------------
  def judge
    # If all dead determinant is true, or number of members in party is 0
    if $game_party.all_dead? or $game_party.actors.size == 0
      if $game_party.members_all_dead?
        # If possible to lose
        if $game_temp.battle_can_lose
          # Return to BGM before battle starts
          $game_system.bgm_play($game_temp.map_bgm)
          # Battle ends
          battle_end(2)
          # Return true
          return true
        end
        # Set game over flag
        $game_temp.gameover = true
        # Return true
        return true
      else
        if $game_temp.party_changer_in_battle
          start_party_changer 
          return false
        else
          # Set game over flag
          $game_temp.gameover = true
          # Return true
          return true
        end
      end
    end
    # Return false if even 1 enemy exists
    for enemy in $game_troop.enemies
      if enemy.exist?
        return false
      end
    end
    # Start after battle phase (win)
    start_phase5
    # Return true
    return true
  end
  #--------------------------------------------------------------------------
  # * Frame Update (party command phase)
  #--------------------------------------------------------------------------
  def update_phase2
    party_changer_update_phase2
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Branch by party command window cursor position
      case @party_command_window.index
      when 2  # escape
        # If it's not possible to escape
        if $game_temp.party_changer_in_battle == false
          # Play buzzer SE
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Escape processing
        start_party_changer
      end
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Start After Battle Phase
  #--------------------------------------------------------------------------
  def start_phase5
    party_changer_start_phase5
    exp = 0
    # Loop
    for enemy in $game_troop.enemies
      # If enemy is not hidden
      unless enemy.hidden
        # Add EXP obtained
        exp += enemy.exp
      end
    end
    # Obtaining EXP
    for i in 0...$game_party.members.size
      return if $game_temp.members_gain_exp == false
      member = $game_party.members[i]
      next if $game_party.actors.include?(member)
      if member.cant_get_exp? == false
        member.exp += (exp/100) * $game_temp.members_exp_rate
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Start Party Changer Phase
  #--------------------------------------------------------------------------
  def start_party_changer
    # Get actor
    @actor = $game_party.members[0]
    @min_actors = $game_temp.battle_party_args[0]
    @max_actors = $game_temp.battle_party_args[1]
    @forced_members = []
    forced_members = $game_temp.battle_party_args[2]
    for i in 0...$game_temp.battle_party_args[2].size
      member = $game_temp.battle_party_args[2][i]
      if member.nil?
        @forced_members << member
      else
        @forced_members << $game_actors[member]
      end
    end
    @lock_members = $game_temp.battle_party_args[3]
    # Make windows
    @party_status_window = Window_MemberStatus.new(@actor)
    @members_window = Window_PartyMembers.new(@forced_members)
    page_id = ((@members_window.index/8)+1).round
    max_page = (@members_window.members.size.to_f/8.0)
    max_page = 1 if max_page == 0
    @party_status_window.refresh(page_id, max_page.ceil)
    # Defined the height to make the window scroll
    @members_window.height = 128
    @party_window = Window_Party.new(@forced_members)
    @party_command_window2 = Window_Command.new(320,['Reset','Confirm','Arrange'])
    @party_command_window2 .active = false
    @party_command_window2.x = 320
    @party_command_window2.y = 352
    # Hide @status_window contents
    @status_window.hide_battlers = true
    for i in @spriteset.actor_sprites
      i.visible = false
    end
    @members_window.active = true
    @party_command_window.active = false
    @party_command_window.visible = false
    # Shift phase
    @phase = 6
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Original method
    party_changer_update
    case @phase
    when 6
      update_party_changer
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (Party Changer)
  #--------------------------------------------------------------------------
  def update_party_changer
    @party_window.update
    @members_window.update
    @party_command_window2.update
    $game_temp.selected_members = @party_window.members.dup
    if @party_window.members.size == 0
      @party_command_window2.disable_item(1)
      @party_command_window2.disable_item(2)
    else
      @party_command_window2.enable_item(1)
      @party_command_window2.enable_item(2)
    end
    if @party_command_window2.active
      update_party_changer_command
    end
    if @party_window.active
      update_party
    end
    if @members_window.active
      update_members
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (if party changer's command window is active)
  #--------------------------------------------------------------------------
  def update_party_changer_command
    @party_window.cursor_rect.empty
    case @party_command_window2.index
    when 0
      @help_window.set_text('Reset party members')
    when 1
      @help_window.set_text('Confirm party selection')
    when 2
      @help_window.set_text('Arrange party members')
    end
    if Input.trigger?(Input::C)
      case @party_command_window2.index
      when 0 
        @members_window.reset
        @party_window.reset_selection
        @party_window.reset_members
        @party_command_window2.active = false
        @members_window.active = true
        $game_temp.selected_members.clear
        @reset = true
        return
      when 1
        if @party_window.members.size < @min_actors
          # Play buzzer SE
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        $game_party.actors.clear
        @party_window.members.each do |actor|
          $game_party.add_actor(actor.id)
        end
        @members_window.active = false
        @party_command_window2.active = false
        @party_status_window.active = false
        @party_window.active = false
        @members_window.visible = false
        @party_command_window2.visible = false
        @party_status_window.visible = false
        @party_window.visible = false
        @party_command_window.visible = true
        @party_command_window.active = true
        for i in 0...$game_party.actors.size
        &nb
 
The script is too big to be posted in a single post.
Here's a link to versino 4.0: http://www.freewebs.com/rmxp-ff/partychanger40.htm
And a link to the thread: http://www.rmxp.org/forums/index.php?topic=23508.0

Everything you have mentioned is actually doable in my script.
You need to call the Scene_Party with at least 4 arguments to do it.
- min_actors
- max_actors
- forced_members
- lock_members
The initialize method looks like
Code:
initialize(min_actors = 1, max_actors = 4, forced_members = [], lock_members = [])
So to do what you want to do (max 3 actors and locked actor 1), you should call the Scene_Party like that:
Code:
$scene = Scene_Party.new(1, 3,[1],[1])
By doing this, you will need a minimum of 1 actor in your party [argument #1] and a maximum of 3 [argument #2]. Actor 1 will be forced to be in the party [argument #3] and will also be locked in the first position [argument #4].

To toggle the party menu access, simply use a call script and write
Code:
$game_system.party_disabled = true/false

Tell me if it isn't clear enough.
Take care!
-Dargor
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top