Main Menu
  • Welcome to The RPG Maker Resource Kit.

Change Party Order

Started by modern algebra, February 20, 2008, 05:26:55 AM

0 Members and 1 Guest are viewing this topic.

modern algebra

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


  • Allows the player to switch party order on the map
  • Can be disabled and reenabled at any time


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



#==============================================================================
#  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




GasparXR

This sounds pretty nifty. I could make a use out of this in my game! It works perfectly. Great job, I must say.

BloodyChaos

Thnx this will come in handy I'll definatly use it  :)

moejoeman

thanx mate im definately using it in my game

moidi

Is this compatible with a caterpillar script?




I'm a big fan of Breath of Fire.
"DONT JUDGE THE GAME BY IT'S TITLE SCREEN"

Sakura Martinez

Modern Algebra, is this compatible with the Kaduki version of the Tankentai SBS?
Courage is the magic that turns dreams into reality.

My Blogsite

modern algebra

I'm not familiar with that script, but I don't see why it wouldn't be.

jick6

Oh alrite. So it's kind of like Wild ARMs 3 or FF4? Pretty handy.
You've just been obliteraped!

Currently Working On: One Day Salesman
http://rmrk.net/index.php/topic,33234.0.html

mordicon

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.

jyoji

Is it possible to have it done in a demo? Because it keeps saying a error on practacly every line.

modern algebra

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.

user3k

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.

modern algebra

Um, use this in a script call:

$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.

user3k

Work, thanks.
Using the same method, can i check the class (paladin, knight etc) ?

modern algebra

yeah, just put class_id instead of id.

KleinKiessling

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.)
People who are organized are just too lazy to organize their stuff.

modern algebra

In sthe script, find where Input::L and Input::R are. Change them to whatever buttons you want to use.