The RPG Maker Resource Kit

RMRK RPG Maker Creation => Requests => Script Request => Topic started by: AeghtyAteKees on July 22, 2011, 11:04:11 PM

Title: Switch Party Leader
Post by: AeghtyAteKees on July 22, 2011, 11:04:11 PM
So I've found all these complex Party Management scripts floating around with millions of effects and customizations that redraw the menu and every other crazy thing you can imagine. But I just have three party members, not eight-hundred and seventeen, and need a way to switch out which one leads the party. Sweet and simple. If anyone knows where to find this or can whip it up, I would greatly appreciate the help. :)
Title: Re: Switch Party Leader
Post by: DoctorTodd on July 22, 2011, 11:39:53 PM
Can be done with events  ???
Title: Re: Switch Party Leader
Post by: AeghtyAteKees on July 22, 2011, 11:45:59 PM
Well, yes. Is it possible to make it work from the menu?
Title: Re: Switch Party Leader
Post by: DoctorTodd on July 22, 2011, 11:52:19 PM
Here, credit goes to Modern Algebra  :)
Code: [Select]
#==============================================================================
#  Change Party Order
#  Author: modern algebra (rmrk.net)
#  Date: February 20, 2008
#==============================================================================

class Scene_Map
  #  ORDER_FREEZE_SWITCH_ID :: This constant is for you to set to a switch ID
  # that controls whether the player is allowed to change party order. If it is
  # set to 1 for example, then turning Switch 1 ON will disallow the player
  # from changing party order, and turning it OFF will allow the player to.
  ORDER_FREEZE_SWITCH_ID = 1
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Frame Update
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias modern_algebra_change_leader_modification_updt update
  def update
    modern_algebra_change_leader_modification_updt
    return if $game_switches[ORDER_FREEZE_SWITCH_ID]
    # If Button R is being pressed
    if Input.trigger? (Input::R)
      # Remove the Lead Actor
      old_lead = $game_party.members.shift.id
      $game_party.remove_actor (old_lead)
      # Add the old leader back into the party
      $game_party.add_actor (old_lead)
    end
    # If Button L is being pressed
    if Input.trigger? (Input::L)
      # Recreate the actors array from the members array
      actors = []
      $game_party.members.each {|actor| actors.push (actor.id)}
      # Reorder the array to the new order
      actors.unshift (actors.pop)
      actors.each {|id|
        # Remove each actor and add them in the new order
        $game_party.remove_actor (id)
        $game_party.add_actor (id)
      }
    end
  end
end

 
Title: Re: Switch Party Leader
Post by: AeghtyAteKees on July 23, 2011, 01:01:55 AM
Works just as well. :) Thanks.