Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //=============================================================================
- // Protagonist Request
- // by Astfgl
- // Date: 02/11/2016
- // At battle end the actor that has spent the most tp will be made party leader
- // Free to use both commercially and non commercially. Free to edit and repost.
- // Don't claim as your own, credits not required.
- //=============================================================================
- /*:
- * @plugindesc At battle end the actor that has spent the most tp will be made party leader
- * @author Astfgl
- * @help On battle end, the plugin will return the value of max tp spent inside
- * the variable defined in the parameter. Leave to 0 if you don't have a use for it.
- *
- * @param VariableId
- * @default 0
- *
- */
- (function() {
- var parameters = PluginManager.parameters('ProtagonistRequest');
- var varId = Number(parameters.VariableId)
- var _Astfgl_newGAS = Game_Actor.prototype.setup
- Game_Actor.prototype.setup = function(actorId) {
- _Astfgl_newGAS.call(this,actorId);
- this._spentTp = 0;
- }
- var _Astfgl_newGBBCPSC = Game_BattlerBase.prototype.paySkillCost
- Game_BattlerBase.prototype.paySkillCost = function(skill) {
- _Astfgl_newGBBCPSC.call(this,skill);
- if (this instanceof Game_Actor) {
- this._spentTp += this.skillTpCost(skill);
- }
- };
- var _Astfgl_newBMEB = BattleManager.endBattle
- BattleManager.endBattle = function(result) {
- _Astfgl_newBMEB.call(this,result);
- var maxValue = $gameParty.members()[0]._spentTp;
- var maxIndex = 0;
- for (var i = 0; i < $gameParty.members().length; i++) {
- if ($gameParty.members()[i]._spentTp > maxValue) {
- maxValue = $gameParty.members()[i]._spentTp;
- maxIndex = i;
- }
- }
- var actor = $gameParty.members()[maxIndex];
- if (varId !== 0) {
- $gameVariables.setValue(varId, maxValue);
- };
- $gameParty.swapOrder(0,maxIndex)
- };
- var _Astgfl_newBMBS = BattleManager.startBattle
- BattleManager.startBattle = function() {
- _Astgfl_newBMBS.call(this)
- for (var i = 0; i < $gameParty.members().length; i++) {
- $gameParty.members()[i]._spentTp = 0;
- }
- };
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement