Advertisement
Astfgl

ProtagonistRequest

Nov 2nd, 2016
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // Protagonist Request
  3. // by Astfgl
  4. // Date: 02/11/2016  
  5. // At battle end the actor that has spent the most tp will be made party leader
  6. // Free to use both commercially and non commercially. Free to edit and repost.
  7. // Don't claim as your own, credits not required.
  8. //=============================================================================
  9.  
  10.  
  11. /*:
  12.  * @plugindesc  At battle end the actor that has spent the most tp will be made party leader
  13.  * @author Astfgl
  14.  * @help On battle end, the plugin will return the value of max tp spent inside
  15.  * the variable defined in the parameter. Leave to 0 if you don't have a use for it.
  16.  *
  17.  * @param VariableId
  18.  * @default 0
  19.  *
  20.  */
  21.  (function() {
  22.  
  23.   var parameters = PluginManager.parameters('ProtagonistRequest');
  24.   var varId = Number(parameters.VariableId)
  25.  
  26.     var _Astfgl_newGAS = Game_Actor.prototype.setup
  27.     Game_Actor.prototype.setup = function(actorId) {
  28.         _Astfgl_newGAS.call(this,actorId);
  29.         this._spentTp = 0;
  30.     }
  31.  
  32.     var _Astfgl_newGBBCPSC = Game_BattlerBase.prototype.paySkillCost
  33.     Game_BattlerBase.prototype.paySkillCost = function(skill) {
  34.         _Astfgl_newGBBCPSC.call(this,skill);
  35.         if (this instanceof Game_Actor) {
  36.             this._spentTp += this.skillTpCost(skill);
  37.         }
  38.     };
  39.    
  40.     var _Astfgl_newBMEB = BattleManager.endBattle
  41.     BattleManager.endBattle = function(result) {
  42.         _Astfgl_newBMEB.call(this,result);
  43.         var maxValue = $gameParty.members()[0]._spentTp;
  44.         var maxIndex = 0;
  45.         for (var i = 0; i < $gameParty.members().length; i++) {
  46.             if ($gameParty.members()[i]._spentTp > maxValue) {
  47.                 maxValue = $gameParty.members()[i]._spentTp;
  48.                 maxIndex = i;
  49.             }
  50.         }
  51.         var actor = $gameParty.members()[maxIndex];
  52.         if (varId !== 0) {
  53.             $gameVariables.setValue(varId, maxValue);
  54.         };
  55.         $gameParty.swapOrder(0,maxIndex)
  56.     };
  57.  
  58.     var _Astgfl_newBMBS = BattleManager.startBattle
  59.     BattleManager.startBattle = function() {
  60.         _Astgfl_newBMBS.call(this)
  61.         for (var i = 0; i < $gameParty.members().length; i++) {
  62.             $gameParty.members()[i]._spentTp = 0;
  63.         }
  64.     };
  65.  
  66.  })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement