Save-Point
Kuick Leader Swap XP - Printable Version

+- Save-Point (https://www.save-point.org)
+-- Forum: Material Development (https://www.save-point.org/forum-8.html)
+--- Forum: Scripts Database (https://www.save-point.org/forum-39.html)
+---- Forum: RPGMaker XP (RGSS) Engine (https://www.save-point.org/forum-116.html)
+---- Thread: Kuick Leader Swap XP (/thread-12791.html)



Kuick Leader Swap XP - kyonides - 09-07-2025

Kuick Leader Swap XP

by Kyonides
Introduction

Once upon a gaming time, some forumer, who might have recently escaped from Minecraft for unknown reasons, wanted to easily swap the current party leader, not just by pressing the L or R button but also via direct assignment.

Happy with a sweat Well, we don't know how accurate this legend might be, but this is the final outcome of that ancient story.

Script Calls

Set a Temporary Leader:
- RememberLeaderIndex? stands for a boolean value: true or false.
- This new leader becomes permanent if RememberLeaderIndex? is false.
Code:
$game_party.temp_leader(PartyIndex, RememberLeaderIndex?)

Restore the Previous Leader (If Any):
Code:
$game_party.restore_leader

Set a Leader by Actor's ID:
Code:
$game_party.set_leader_by_id(ActorID)

The Script

Code:
# * Kuick Leader Swap XP * #
#   Scripter : Kyonides
#   v1.0.2 - 2025-09-06

# * Script Calls * #

# - Set a Temporary Leader!
#  RememberLeaderIndex? stands for a boolean value: true or false.
#  This new leader becomes permanent if RememberLeaderIndex? is false.
# $game_party.temp_leader(PartyIndex, RememberLeaderIndex?)

# - Restore the Previous Leader! (If Any!)
# $game_party.restore_leader

# - Set a Leader by Actor's ID!
# $game_party.set_leader_by_id(ActorID)

class Game_Party
  def change_leader(n)
    if n < 0
      @actors.unshift @actors.pop
    else
      @actors << @actors.shift
    end
  end

  def set_leader_by_id(actor_id)
    actor = $game_actors[actor_id]
    n = @actors.index(actor)
    swap_leader(n) if n and n != 0
  end

  def temp_leader(n, remember)
    @temp_leader_index = n if remember
    swap_leader(n)
  end

  def restore_leader
    return unless @temp_leader_index
    n = @temp_leader_index
    swap_leader(@temp_leader_index)
    @temp_leader_index = nil
  end

  def leader
    @actors[0]
  end
  private
  def swap_leader(n)
    @actors[0], @actors[n] = @actors[n], @actors[0]
    $game_player.refresh
  end
end

class Game_Player
  alias :kyon_kuick_leader_swap_gm_plyr_up :update
  def update
    kyon_kuick_leader_swap_gm_plyr_up
    if Input.trigger?(Input::L)
      $game_party.change_leader(-1)
      refresh
      return
    elsif Input.trigger?(Input::R)
      $game_party.change_leader(1)
      refresh
    end
  end
end

Terms & Conditions

Free as in Beer beer for any kind of Gamer games.
Include my nickname in your game credits.
Thank Ace_V for unwillingly inspiring me to Sculptor craft the script. (Just don't or else his PM box will get full any time soon. Confused )
That's it! Tongue sticking out


RE: Kuick Leader Swap XP - Ace_V - 09-08-2025

This really is useful and very light and easy to implement! Thanks again, kyonides! I spent the better part of a day going through all my previously-finished quest lines to implement the script call to ensure the correct character is in the lead to further enhance some cutscenes.

(I've never played Minecraft, though!)  Laughing