In RPG Maker, you have something called “actors” which are the characters that the player controls.
All actors are grouped into a “unit” called a “party”. Actors can be added or removed from parties at anytime during the game. You can potentially have multiple parties in your game, depending on how your project is set up.
Each party has a leader. The leader is the actor that will be displayed while you’re traveling on the map. By default, the leader is the actor that is in the first position of the party. So for example if you switched the positions of the first and second members of the party, the leader will change.
Similar to actors, enemies are also grouped into their own unit called a “troop”. Enemy troops by default do not have a leader.
Now, what happens if you wanted the party leader to be someone other than the first person in the party? Maybe you want the leader to be a specific actor, but that actor doesn’t participate in battle.
Or perhaps you wanted enemy troops to have a leader, and make it so that when the leader dies, the enemies will scatter and run away?
With this plugin, you can set up who will be the leaders of parties and troops, and build additional plugins on top of it that allow you to use these leaders to implement new game mechanics.
Plugin: download here (right-click, save as)
Download ths plugin and place it in the “plugins” folder in your project’s “js” folder. Then open your Plugin Manager (F10), double-click an empty row, and select the HIME_CustomPartyLeader plugin.
Once it is in your list of plugins, turn the plugin on.
When your party is first set up when you start a new game, it assumes the leader is the actor in the first position of the party.
Similarly, when the enemy troop is set up, the first enemy will be selected as the leader.
It is intended that you will change the leaders through events during the game.
Checking Who is the Leader
You can ask who is the leader in script calls like this:
It is possible that a unit does not have a leader. It will return `null` in that case.
Changing Party Leaders
You can change leaders during the game. To change the party leader, use the following plugin command
change_party_leader to actor ID
Where ID is the Id of the actor you wish to set as the leader. For example, if you wanted to choose actor 4 to be the leader, you can write
change_party_leader to actor 4
The actor does not need to be in the party.
Changing Enemy Troop leaders
Similarly, you can change enemy troop leaders as well. Use the following plugin command
change_troop_leader to enemy MEMBER_ID
Where the MEMBER_ID is the position of a particular enemy in the current troop. This is based on the order that they were added into the troop. If you look at the image above, you’ll see that the second slime is on the right, whereas the third slime is in the middle. This is because I added the blue slime before the gold slime.
For example, to set the third enemy as the leader, you would write
change_troop_leader to enemy 3
Working with Custom Units
If you have other units aside from parties and troops that is added through other plugins, you would need to use script calls to set the leaders.
All units must inherit from Game_Unit, and the leader must inherit from Game_BattlerBase.