Replace party member if party is full

My game features a maximum party size of 4 actors, although you can very easily gain new ones. However, I don't want any additional party members to be placed into reserve.

What I would like is if the game tries to add a new party member, and detects that your party is full, it asks you if you want to replace an existing member in your party. If you accept, you decide whichever party member you want to permanently remove from your party (EXCEPT the party leader) and then adds the new party member.

I would greatly appreciate if someone could find a script that does this for me.
no need for a script, this can be done with events.

first, control variable to get the ID of party member #4

if the result is 0, the slot is empty otherwise the party is full.

if the party is full show choices with the option to not leave a member or to replace members #2 to #4 (with their names by text code)

Then remove the selected member before adding the new one.

One problem: I do not remember if the Ace event command allows to remove actors by ID. If not, look at the VXA forums, one of them contains a pinned topic about the script equivalents to event commands. you'll have to use that if the command does not allow IDs.
if the party is full show choices with the option to not leave a member or to replace members #2 to #4 (with their names by text code)
Sorry, I probably should have worded that differently. There's a specific party member which I don't want to allow the player to replace in this scenario, but they can be in any position in the party.
OK, that is more complex to handle.

It should still be possible to event, but with that optionI agree it is really better to use a script.

I think yanfly's Party System script should be able to do the job.

The descriptions and manuals are on his old website,

but the scripts themselves have been moved to archeia's github a long time ago:
I think yanfly's Party System script should be able to do the job.
not directly. He wants the party limit to be fixed. No reserve. So yanfly party manager doesn't do that.
A script that does this would seem to be the solution.
Not a new concept, seen this in a few games.
I think yanfly's Party System script should be able to do the job.
I tried using that. Unfortunately, the script isn't compatible with Galv's Animated Battlers, which is what I'm using for my project.
Just finished this. Let me know if it is also incompatible.
Spoiler: Party Full Member Swap
Ruby:
# ╔═══════════════════════════════════════════════╦════════════════════╗
# ║ Title: Party Full Member Swap                 ║  Version: 1.00     ║
# ║ Author: Roninator2                            ║                    ║
# ╠═══════════════════════════════════════════════╬════════════════════╣
# ║ Function:                                     ║   Date Created     ║
# ║                                               ╠════════════════════╣
# ║   Script Function                             ║    04 Apr 2025     ║
# ╚═══════════════════════════════════════════════╩════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Requires: nil                                                      ║
# ║                                                                    ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Brief Description:                                                 ║
# ║       Swap actor when party is full                                ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Instructions:                                                      ║
# ║   Change options below                                             ║
# ║   Scene is called when using the change party event command        ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Updates:                                                           ║
# ║ 1.00 - 04 Apr 2025 - Script finished                               ║
# ║                                                                    ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Credits and Thanks:                                                ║
# ║   Roninator2                                                       ║
# ║   Yanfly                                                           ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Terms of use:                                                      ║
# ║  Follow the original Authors terms of use where applicable         ║
# ║    - When not made by me (Roninator2)                              ║
# ║  Free for all uses in RPG Maker except nudity                      ║
# ║  Anyone using this script in their project before these terms      ║
# ║  were changed are allowed to use this script even if it conflicts  ║
# ║  with these new terms. New terms effective 03 Apr 2024             ║
# ║  No part of this code can be used with AI programs or tools        ║
# ║  Credit must be given                                              ║
# ╚════════════════════════════════════════════════════════════════════╝

module R2_PARTY_SWAP_ACTOR
  # Maximum members in party, also max battle members
  MAX_PARTY_MEMBERS = 4
  # Show the actor face and or sprite graphic
  DISPLAY_FACE = false
  # Size of font in stat window
  STATUS_FONT_SIZE = 20
  # size of actor name in select window
  ACTOR_NAME_FONT_SIZE = 20
  # Text to show for Actor Equipment
  EQUIP_TITLE_TEXT = "Equipment"
  # Draw text for scene
  SWAP_TEXT = "Party Full. Select Actor to remove or cancel"
end

# ╔════════════════════════════════════════════════════════════════════╗
# ║                      End of editable region                        ║
# ╚════════════════════════════════════════════════════════════════════╝

#==============================================================================
# ■ Game_Party
#==============================================================================

class Game_Party < Game_Unit
  attr_accessor :max_party_actors
 
  alias :r2_game_party_initialize_var :initialize
  def initialize
    r2_game_party_initialize_var
    @max_party_actors = nil
  end
 
  def max_battle_members
    return R2_PARTY_SWAP_ACTOR::MAX_PARTY_MEMBERS
  end
 
  alias :r2_setup_starting_members_data :setup_starting_members
  def setup_starting_members
    r2_setup_starting_members_data
    initialize_max_members
  end
 
  def initialize_max_members
    @max_party_actors = []
    for i in 0...max_battle_members
      @max_party_actors.push(@actors[i]) unless @actors[i].nil?
      @max_party_actors.push(0) if @actors[i].nil?
    end
    $game_player.refresh
  end
 
  # change add actor method
  alias :r2_add_actor_full_party   :add_actor
  def add_actor(actor_id)
    return if @max_party_actors.include?(actor_id)
    if @actors.size == 4
      SceneManager.call(Scene_Party_Full)
      SceneManager.scene.prepare(actor_id)
      return
    end
    r2_add_actor_full_party(actor_id)
    update_actor_array
  end
 
  def update_actor_array
    @max_party_actors = []
    for actor_id in @actors
      @max_party_actors.push(actor_id)
    end
  end
end

#==============================================================================
# ■ Window_ActorSwapTitle
#==============================================================================

class Window_ActorSwapTitle < Window_Base
 
  #--------------------------------------------------------------------------
  # * Initialization of the object
  #--------------------------------------------------------------------------
  def initialize
    super(0,0,window_width,window_height)
    refresh
  end
  #--------------------------------------------------------------------------
  # window_width
  #--------------------------------------------------------------------------
  def window_width; Graphics.width; end
 
  #--------------------------------------------------------------------------
  # window_height
  #--------------------------------------------------------------------------
  def window_height; fitting_height(1); end
  #--------------------------------------------------------------------------
  # * Renew content
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    draw_text(0,0,self.width,24,R2_PARTY_SWAP_ACTOR::SWAP_TEXT,1)
  end
 
end

#==============================================================================
# ■ Window_ActorSelectDrop
#==============================================================================

class Window_ActorSelectDrop < Window_Selectable
 
  #--------------------------------------------------------------------------
  # initialize
  #-------------------------------------------------------------------------
  def initialize
    super(160, fitting_height(1), window_width, fitting_height(visible_line_number))
    select(0)
    refresh
  end
 
  #--------------------------------------------------------------------------
  # col_max
  #--------------------------------------------------------------------------
  def col_max; return $game_party.max_battle_members; end
 
  #--------------------------------------------------------------------------
  # item_max
  #--------------------------------------------------------------------------
  def item_max; return $game_party.max_battle_members; end
 
  #--------------------------------------------------------------------------
  # window_width
  #--------------------------------------------------------------------------
  def window_width; return Graphics.width - 160; end
 
  #--------------------------------------------------------------------------
  # visible_line_number
  #--------------------------------------------------------------------------
  def visible_line_number; 3; end
 
  #--------------------------------------------------------------------------
  # item_rect
  #--------------------------------------------------------------------------
  def item_rect(index)
    rect = Rect.new
    rect.width = contents.width / item_max
    rect.height = contents.height
    rect.x = index * rect.width
    rect.y = 0
    return rect
  end
 
  #--------------------------------------------------------------------------
  # refresh
  #--------------------------------------------------------------------------
  def refresh
    make_item_list
    create_contents
    draw_all_items
  end
 
  #--------------------------------------------------------------------------
  # make_item_list
  #--------------------------------------------------------------------------
  def make_item_list
    @data = $game_party.max_party_actors.clone
  end
 
  #--------------------------------------------------------------------------
  # draw_item
  #--------------------------------------------------------------------------
  def draw_item(index)
    actor = $game_actors[@data[index]]
    rect = item_rect(index)
    dx = rect.width / 2
    dy = rect.height - 16
    draw_actor_face(actor, rect.x, rect.y) if display_face?
    draw_actor_graphic(actor, rect.x + dx, rect.y + dy) unless display_face?
    draw_actor_name(actor, rect)
  end
 
  #--------------------------------------------------------------------------
  # display_face?
  #--------------------------------------------------------------------------
  def display_face?
    return R2_PARTY_SWAP_ACTOR::DISPLAY_FACE
  end
 
  #--------------------------------------------------------------------------
  # draw_actor_name
  #--------------------------------------------------------------------------
  def draw_actor_name(actor, rect)
    contents.font.size = R2_PARTY_SWAP_ACTOR::ACTOR_NAME_FONT_SIZE
    change_color(normal_color, actor.exist?)
    draw_text(rect.x+4, rect.y, rect.width-8, line_height, actor.name, 1)
  end
 
  #--------------------------------------------------------------------------
  # draw_face
  #--------------------------------------------------------------------------
  def draw_face(face_name, face_index, dx, dy, enabled = true)
    bitmap = Cache.face(face_name)
    dw = [96, item_rect(0).width-4].min
    rect = Rect.new(face_index % 4 * 96, face_index / 4 * 96, dw, 92)
    contents.blt(dx+2, dy+2, bitmap, rect, enabled ? 255 : translucent_alpha)
    bitmap.dispose
  end
 
  #--------------------------------------------------------------------------
  # process_handling
  #--------------------------------------------------------------------------
  def process_handling
    return unless open? && active
    return process_ok       if ok_enabled?        && Input.trigger?(:C)
    return process_cancel   if cancel_enabled?    && Input.trigger?(:B)
    return process_pagedown if handle?(:pagedown) && Input.repeat?(:R)
    return process_pageup   if handle?(:pageup)   && Input.repeat?(:L)
  end
 
  #--------------------------------------------------------------------------
  # cur_actor
  #--------------------------------------------------------------------------
  def cur_actor
    actor_id = @data[index]
    return $game_actors[actor_id]
  end
 
  #--------------------------------------------------------------------------
  # prev_actor
  #--------------------------------------------------------------------------
  def prev_actor
    id = index == 0 ? @data.size - 1 : index - 1
    actor_id = @data[id]
    return $game_actors[actor_id]
  end
 
  #--------------------------------------------------------------------------
  # next_actor
  #--------------------------------------------------------------------------
  def next_actor
    id = index == @data.size - 1 ? 0 : index + 1
    actor_id = @data[id]
    return $game_actors[actor_id]
  end
 
  #--------------------------------------------------------------------------
  # process_pageup
  #--------------------------------------------------------------------------
  def process_pageup
    allow = true
    allow = false if !prev_actor.nil? && prev_actor.locked
    allow = false if !cur_actor.nil? && cur_actor.locked
    Sound.play_buzzer unless allow
    if allow
      super
      activate
      select(index == 0 ? @data.size - 1 : index - 1)
    end
  end
 
  #--------------------------------------------------------------------------
  # process_pagedown
  #--------------------------------------------------------------------------
  def process_pagedown
    allow = true
    allow = false if !next_actor.nil? && next_actor.locked
    allow = false if !cur_actor.nil? && cur_actor.locked
    Sound.play_buzzer unless allow
    if allow
      super
      activate
      select(index == @data.size - 1 ? 0 : index + 1)
    end
  end
 
  #--------------------------------------------------------------------------
  # item
  #--------------------------------------------------------------------------
  def item; return @data[index]; end
 
end # Window_ActorSelectDrop

#==============================================================================
# ** Window_ActorSelectDropStatus
#==============================================================================

class Window_ActorSelectDropStatus < Window_Base
 
  #--------------------------------------------------------------------------
  # initialize
  #--------------------------------------------------------------------------
  def initialize(actors_window)
    super(window_x, fitting_height(5), window_width, window_height)
    @select_window = actors_window
    @actor = active_actor
    refresh
  end
 
  #--------------------------------------------------------------------------
  # window_x
  #--------------------------------------------------------------------------
  def window_x; 160; end
    
  #--------------------------------------------------------------------------
  # window_width
  #--------------------------------------------------------------------------
  def window_width; Graphics.width - window_x; end
 
  #--------------------------------------------------------------------------
  # window_height
  #--------------------------------------------------------------------------
  def window_height; Graphics.height - fitting_height(5); end
 
  #--------------------------------------------------------------------------
  # update
  #--------------------------------------------------------------------------
  def update
    super
    refresh if @actor != active_actor
  end
 
  #--------------------------------------------------------------------------
  # active_actor
  #--------------------------------------------------------------------------
  def active_actor
    return @select_window.item
  end
 
  #--------------------------------------------------------------------------
  # refresh
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    @actor = active_actor
    reset_font_settings
    actor = $game_actors[@actor]
    draw_actor_face(actor, 0, 0)
    draw_actor_name(actor, 108, 0)
    draw_actor_class(actor, 228, 0, contents.width-232)
    draw_actor_level(actor, 108, line_height)
    draw_actor_icons(actor, 228, line_height, contents.width-232)
    draw_actor_hp(actor, 108, line_height*2, contents.width-112)
    draw_actor_mp(actor, 108, line_height*3, contents.width-112)
    draw_actor_parameters(actor, 0, line_height*4 + line_height/2)
    draw_equipments(actor, contents.width/2, line_height*4 + line_height/2)
  end
 
  #--------------------------------------------------------------------------
  # draw_actor_parameters
  #--------------------------------------------------------------------------
  def draw_actor_parameters(actor, dx, dy)
    dw = contents.width/2 - 4
    rect = Rect.new(dx+1, dy+1, dw - 2, line_height - 2)
    contents.font.size = R2_PARTY_SWAP_ACTOR::STATUS_FONT_SIZE
    colour = Color.new(0, 0, 0, translucent_alpha/2)
    array = [:atk, :def, :mat, :mdf, :agi, :luk]
    cx = 4
    for stat in array
      case stat
      when :atk
        param = Vocab::param(2)
        value = actor.atk.group
      when :def
        param = Vocab::param(3)
        value = actor.def.group
      when :mat
        param = Vocab::param(4)
        value = actor.mat.group
      when :mdf
        param = Vocab::param(5)
        value = actor.mdf.group
      when :agi
        param = Vocab::param(6)
        value = actor.agi.group
      when :luk
        param = Vocab::param(7)
        value = actor.luk.group
      else; next
      end
      contents.fill_rect(rect, colour)
      change_color(system_color)
      draw_text(rect.x + cx, rect.y, rect.width-cx*2, line_height, param, 0)
      change_color(normal_color)
      draw_text(rect.x + cx, rect.y, rect.width-cx*2, line_height, value, 2)
      rect.y += line_height
    end
    reset_font_settings
  end
 
  #--------------------------------------------------------------------------
  # draw_equipments
  #--------------------------------------------------------------------------
  def draw_equipments(actor, dx, dy)
    text = R2_PARTY_SWAP_ACTOR::EQUIP_TITLE_TEXT
    change_color(system_color)
    draw_text(dx, dy, contents.width - dx, line_height, text, 1)
    dy += line_height
    if actor.equips.size <= 5
      actor.equips.each_with_index do |item, i|
        draw_item_name(item, dx, dy + line_height * i)
      end
    else
      orig_x = dx
      actor.equips.each_with_index do |item, i|
        next if item.nil?
        draw_icon(item.icon_index, dx, dy)
        dy += line_height if dx + 48 > contents.width
        dx = dx + 48 > contents.width ? orig_x : dx + 24
      end
    end
  end
 
end # Window_ActorSelectDropStatus

#==============================================================================
# ■ Window_ActorSelectGain
#==============================================================================

class Window_ActorSelectGain < Window_Base
 
  #--------------------------------------------------------------------------
  # initialize
  #-------------------------------------------------------------------------
  def initialize
    super(0, fitting_height(1), window_width, fitting_height(visible_line_number))
  end
 
  #--------------------------------------------------------------------------
  # col_max
  #--------------------------------------------------------------------------
  def col_max; return 1; end
 
  #--------------------------------------------------------------------------
  # item_max
  #--------------------------------------------------------------------------
  def item_max; return 1; end
 
  #--------------------------------------------------------------------------
  # window_width
  #--------------------------------------------------------------------------
  def window_width; return 160; end
 
  #--------------------------------------------------------------------------
  # visible_line_number
  #--------------------------------------------------------------------------
  def visible_line_number; 3; end
 
  #--------------------------------------------------------------------------
  # item_rect
  #--------------------------------------------------------------------------
  def item_rect(index)
    rect = Rect.new
    rect.width = contents.width / item_max
    rect.height = contents.height
    rect.x = index * rect.width
    rect.y = 0
    return rect
  end
 
  #--------------------------------------------------------------------------
  # Actor
  #--------------------------------------------------------------------------
  def actor=(act_id)
    @act_id = act_id
    refresh
  end
 
  #--------------------------------------------------------------------------
  # refresh
  #--------------------------------------------------------------------------
  def refresh
    actor = Game_Actor.new(@act_id)
    rect = item_rect(0)
    dx = rect.width / 2
    dy = rect.height - 16
    draw_actor_face(actor, rect.x, rect.y) if display_face?
    draw_actor_graphic(actor, rect.x + dx, rect.y + dy) unless display_face?
    draw_actor_name(actor, rect)
  end
 
  #--------------------------------------------------------------------------
  # display_face?
  #--------------------------------------------------------------------------
  def display_face?
    return R2_PARTY_SWAP_ACTOR::DISPLAY_FACE
  end
 
  #--------------------------------------------------------------------------
  # draw_actor_name
  #--------------------------------------------------------------------------
  def draw_actor_name(actor, rect)
    contents.font.size = R2_PARTY_SWAP_ACTOR::ACTOR_NAME_FONT_SIZE
    change_color(normal_color)
    draw_text(rect.x+4, rect.y, rect.width-8, line_height, actor.name, 1)
  end
 
  #--------------------------------------------------------------------------
  # draw_face
  #--------------------------------------------------------------------------
  def draw_face(face_name, face_index, dx, dy, enabled = true)
    bitmap = Cache.face(face_name)
    dw = [96, item_rect(0).width-4].min
    rect = Rect.new(face_index % 4 * 96, face_index / 4 * 96, dw, 92)
    contents.blt(dx+2, dy+2, bitmap, rect, 255)
    bitmap.dispose
  end
 
end # Window_ActorSelectGain
 
#==============================================================================
# ** Window_ActorGainStatus
#==============================================================================

class Window_ActorGainStatus < Window_Base
 
  #--------------------------------------------------------------------------
  # initialize
  #--------------------------------------------------------------------------
  def initialize
    super(0, fitting_height(5), window_width, window_height)
  end
 
  #--------------------------------------------------------------------------
  # window_width
  #--------------------------------------------------------------------------
  def window_width; 160; end
 
  #--------------------------------------------------------------------------
  # window_height
  #--------------------------------------------------------------------------
  def window_height; Graphics.height - fitting_height(5); end
 
  #--------------------------------------------------------------------------
  # Actor
  #--------------------------------------------------------------------------
  def actor=(act_id)
    @act_id = act_id
    refresh
  end
 
  #--------------------------------------------------------------------------
  # refresh
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    reset_font_settings
    actor = Game_Actor.new(@act_id)
    draw_actor_face(actor, 0, 0)
    draw_actor_name(actor, 0, line_height * 3)
    draw_actor_class(actor, 0, line_height * 4, contents.width)
    draw_actor_hp(actor, 0, line_height*5, contents.width)
    draw_actor_mp(actor, 0, line_height*6, contents.width)
    draw_actor_parameters(actor, 0, line_height*7 + line_height/2)
  end
 
  #--------------------------------------------------------------------------
  # draw_actor_parameters
  #--------------------------------------------------------------------------
  def draw_actor_parameters(actor, dx, dy)
    dw = contents.width/2 - 4
    dx2 = dw + 4
    rect = Rect.new(dx+1, dy+1, dw - 2, line_height - 2)
    contents.font.size = R2_PARTY_SWAP_ACTOR::STATUS_FONT_SIZE
    colour = Color.new(0, 0, 0, translucent_alpha/2)
    array = [:atk, :def, :mat, :mdf, :agi, :luk]
    cx = 4
    for stat in array
      case stat
      when :atk
        param = Vocab::param(2)
        value = actor.atk.group
        rect.x = dx+1
        rect.y = dy+1
      when :def
        param = Vocab::param(3)
        value = actor.def.group
        rect.x = dx2
        rect.y = dy+1
      when :mat
        param = Vocab::param(4)
        value = actor.mat.group
        rect.x = dx+1
        rect.y = dy+1
        rect.y = dy+1 + line_height
      when :mdf
        param = Vocab::param(5)
        value = actor.mdf.group
        rect.x = dx2
        rect.y = dy+1
        rect.y = dy+1 + line_height
      when :agi
        param = Vocab::param(6)
        value = actor.agi.group
        rect.x = dx+1
        rect.y = dy+1
        rect.y = dy+1 + line_height * 2
      when :luk
        param = Vocab::param(7)
        value = actor.luk.group
        rect.x = dx2
        rect.y = dy+1 + line_height * 2
      else; next
      end
      contents.fill_rect(rect, colour)
      change_color(system_color)
      draw_text(rect.x + cx, rect.y, rect.width-cx*2, line_height, param, 0)
      change_color(normal_color)
      draw_text(rect.x + cx, rect.y, rect.width-cx*2, line_height, value, 2)
    end
    reset_font_settings
  end
 
end # Window_ActorSelectDropStatus

#==============================================================================
# ■ Scene_Party
#==============================================================================

class Scene_Party_Full < Scene_MenuBase
 
  #--------------------------------------------------------------------------
  # start
  #--------------------------------------------------------------------------
  def start
    super
    create_title_text
    create_actorgain_window
    create_actorgainstatus_window
    create_party_window
    create_status_window
    set_actor
  end
 
  #--------------------------------------------------------------------------
  # prepare
  #--------------------------------------------------------------------------
  def prepare(act)
    @act_id = act
  end
 
  #--------------------------------------------------------------------------
  # set actor data
  #--------------------------------------------------------------------------
  def set_actor
    @actor_gain_window.actor = @act_id
    @actor_gain_status_window.actor = @act_id
  end
 
  #--------------------------------------------------------------------------
  # create_title_window
  #--------------------------------------------------------------------------
  def create_title_text
    @title_window = Window_ActorSwapTitle.new
  end
 
 
  #--------------------------------------------------------------------------
  # create_party_window
  #--------------------------------------------------------------------------
  def create_actorgain_window
    @actor_gain_window = Window_ActorSelectGain.new
  end
 
  #--------------------------------------------------------------------------
  # create_status_window
  #--------------------------------------------------------------------------
  def create_actorgainstatus_window
    @actor_gain_status_window = Window_ActorGainStatus.new
  end
 
  #--------------------------------------------------------------------------
  # create_party_window
  #--------------------------------------------------------------------------
  def create_party_window
    @actor_drop_window = Window_ActorSelectDrop.new
    @actor_drop_window.set_handler(:ok,       method(:on_party_ok))
    @actor_drop_window.set_handler(:cancel,   method(:on_party_cancel))
    @actor_drop_window.activate
  end
 
  #--------------------------------------------------------------------------
  # create_status_window
  #--------------------------------------------------------------------------
  def create_status_window
    @status_window = Window_ActorSelectDropStatus.new(@actor_drop_window)
  end
 
  #--------------------------------------------------------------------------
  # on_party_ok
  #--------------------------------------------------------------------------
  def on_party_ok
    actor = $game_party.members[@actor_drop_window.index]
    $game_party.remove_actor(actor.id)
    $game_party.add_actor(@act_id)
    return_scene
  end
 
  #--------------------------------------------------------------------------
  # on_party_cancel
  #--------------------------------------------------------------------------
  def on_party_cancel
    return_scene
  end
    
end # Scene_Party
Just finished this. Let me know if it is also incompatible.
This works. Thanks.

Original thread: https://forums.rpgmakerweb.com/threads/replace-party-member-if-party-is-full.176716/