The RPG Maker Resource Kit

RMRK RPG Maker Creation => VX => VX Scripts Database => Topic started by: modern algebra on February 20, 2008, 05:26:55 AM

Title: Change Party Order
Post by: modern algebra on February 20, 2008, 05:26:55 AM
Change Party Order
Version: 1.0
Author: modern algebra
Date: February 20th, 2008


Description


This script allows the player to change party order through the use of the L and R buttons

Features


Instructions

Simple. Press L and R (Q and W by default) to switch between the actors in your party and have them as leader. If the party is composed of 4 actors A B C D, where A is the current leader, then pressing R would change the order to B C D A and pressing L would change the order to D A B C. You can disallow the player from doing this by first setting ORDER_FREEZE_SWITCH_ID to a Switch ID of your choosing, and then setting that switch in game with a Control Switch command. Turning the switch ON will disable the ability, and so the player will not be able to switch party order, while turning it off enables the feature.


Script


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

Credit


No credit is necessary for such a simple script, but it was written by me

Support


Please post your questions here if you run into problems

Author's Notes


This, when I made it for RMXP, was just released as a scriptlet. But, I figure I will test releasing them independently to see what happens. Once the VX database gets more scripts I will probably merge them all back into the Useful Scriptlets topic. It was slightly more annoying than the RMXP version since you don't have access to the actors array directly. I could have merely done that, made actors an instance variable, but I figured I would restrict myself within the default as much as possible


Creative Commons License
This script by modern algebra is licensed under a Creative Commons Attribution-Non-Commercial-Share Alike 2.5 Canada License.
Title: Re: Change Party Order
Post by: GasparXR on February 20, 2008, 09:35:40 PM
This sounds pretty nifty. I could make a use out of this in my game! It works perfectly. Great job, I must say.
Title: Re: Change Party Order
Post by: BloodyChaos on February 21, 2008, 11:54:47 PM
Thnx this will come in handy I'll definatly use it  :)
Title: Re: Change Party Order
Post by: moejoeman on August 22, 2008, 03:11:51 AM
thanx mate im definately using it in my game
Title: Re: Change Party Order
Post by: moidi on February 15, 2009, 09:26:18 AM
Is this compatible with a caterpillar script?




I'm a big fan of Breath of Fire.
Title: Re: Change Party Order
Post by: Sakura Martinez on February 15, 2009, 12:58:59 PM
Modern Algebra, is this compatible with the Kaduki version of the Tankentai SBS?
Title: Re: Change Party Order
Post by: modern algebra on February 16, 2009, 01:53:06 AM
I'm not familiar with that script, but I don't see why it wouldn't be.
Title: Re: Change Party Order
Post by: jick6 on March 01, 2009, 07:56:11 PM
Oh alrite. So it's kind of like Wild ARMs 3 or FF4? Pretty handy.
Title: Re: Change Party Order
Post by: mordicon on May 16, 2010, 01:09:36 PM
This script sounds pretty good - reminds me of the breath of fires series, each character had it's own important functions that could only be preformed if he/she was the 'main' actor.
Title: Re: Change Party Order
Post by: jyoji on May 21, 2010, 03:41:31 PM
Is it possible to have it done in a demo? Because it keeps saying a error on practacly every line.
Title: Re: Change Party Order
Post by: modern algebra on May 22, 2010, 02:01:45 PM
If it's giving an error anywhere it's likely an incompatibility between some script you're using. Try it in a new project and you'll see it works, so there's really no need for a demo.

My guess if it's giving an error on practically every line is that you have some script that calls it before $game_party is initialized. Maybe a skip title screen or title screen on map script? Or you're trying to use it in XP when it's a VX script. There is an XP version of it in the XP Scripts Database if that's what's happening.
Title: Re: Change Party Order
Post by: user3k on May 26, 2010, 01:18:12 AM
There's a way to check the leading actor, like in a conditional branch? This is perfect to make events that need a specific leading actor.
Title: Re: Change Party Order
Post by: modern algebra on May 26, 2010, 11:14:01 AM
Um, use this in a script call:

Code: [Select]
$game_variables[x] = $game_party.members.empty? ? 0 : $game_party.members[0].id

That make it so Variable X is the ID of the lead actor, unless there are no party members, in which case it will be 0. You can use regular conditional branches to check the value of that variable once it is set.
Title: Re: Change Party Order
Post by: user3k on May 29, 2010, 01:22:16 AM
Work, thanks.
Using the same method, can i check the class (paladin, knight etc) ?
Title: Re: Change Party Order
Post by: modern algebra on May 29, 2010, 01:36:55 AM
yeah, just put class_id instead of id.
Title: Re: Change Party Order
Post by: KleinKiessling on June 06, 2010, 03:53:43 AM
Hey, I put your script in my game--thanks for making it!
But I have a question-
How do I change the triggers for changing the order?
(It works when I hit Q and W, but I use the Vampyr battle system, and the item/spell menus are hotkeyed to Q and W, so whenever I try to bring up those interfaces, I switch the order.)
Title: Re: Change Party Order
Post by: modern algebra on June 06, 2010, 11:41:57 AM
In sthe script, find where Input::L and Input::R are. Change them to whatever buttons you want to use.