daily pastebin goal
39%
SHARE
TWEET

LudoSwap

ludovicodes Dec 10th, 2017 (edited) 149 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //==
  2. //LudoSwap.js
  3. //==
  4.  
  5.  
  6. /*:
  7.  * @plugindesc plugin that swaps out dead party members with alive backup members.
  8.  * @author Alessio De Santis
  9.  *
  10.  * @help This plugin does not provide plugin commands.
  11.  *
  12.  * @param Number of turns till swap
  13.  * @desc Number of turns until a dead character is swapped out with a character from the reserve
  14.  *
  15.  * Default : 3
  16.  * @default 3
  17.  */
  18.  
  19. var $turns = 1;
  20. var $maxTurns = Number(PluginManager.parameters("LudoSwap")["Number of turns till swap"]) || 3;
  21.  
  22. (function(){
  23.  
  24.     var _BattleManager_updateTurnEnd = BattleManager.prototype.updateTurnEnd;
  25.     var _BattleManager_startBattle = BattleManager.prototype.startBattle;
  26.  
  27.  
  28.     BattleManager.updateTurnEnd = function() {
  29.         var i;
  30.         //Checks for dead actor;
  31.         for(i = 0; i < $gameParty.battleMembers().length; i++){
  32.             var member = $gameParty.battleMembers()[i];
  33.             if(member.isDead()){
  34.                 //console.log(member.name() + " is dead.");
  35.                 //checks if there are more party members than fighting party members
  36.                 if($gameParty.allMembers().length > $gameParty.battleMembers().length){
  37.                     //console.log("there are more party members");
  38.                     $gameParty.allMembers().forEach(function(actor){
  39.                         if($gameParty.battleMembers().indexOf(actor) == -1 && !actor.isDead() && $turns == $maxTurns) {
  40.                             console.log(actor.name() + " is not in party" + " and is alive");
  41.                             index1 = $gameParty.allMembers().indexOf(actor);
  42.                             index2 = $gameParty.members().indexOf(member);
  43.                             console.log(index1 + " " + index2);
  44.                             $gameParty.swapOrder(index1, index2);
  45.                             $turns = 0;                  
  46.                         } else if($gameParty.battleMembers().indexOf(actor) == -1 && !actor.isDead() && $turns < $maxTurns){
  47.                             console.log($turns);
  48.                             $turns++;}
  49.                     });
  50.                 }
  51.             }
  52.         }
  53.         this.startInput();
  54.     };
  55.  
  56.     BattleManager.startBattle = function() {
  57.         this._phase = 'start';
  58.         $gameSystem.onBattleStart();
  59.         $gameParty.onBattleStart();
  60.         $gameTroop.onBattleStart();
  61.         this.displayStartMessages();
  62.         $turns = 1;
  63.     };
  64.  
  65.  
  66. })();
RAW Paste Data
Top