Maliki79

MalCharTP

Oct 7th, 2016 (edited)
1,836
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // Maliki's Character Specific TP
  3. // MalCharTP.js
  4. // version 1.3
  5. //=============================================================================
  6. /*:  
  7.  * @plugindesc Version 1.2 Allows you to manipulate individual Actor TP
  8.  * @author Maliki79
  9.  *
  10.  * @param TPMax
  11.  * @desc The highest ANY actor or enemy MAX TP can be raised to.
  12.  * Default: 100
  13.  * @default 100
  14.  *
  15.  * @help
  16.  * All Actors will start with TP not visible in battles.
  17.  * To show an actor's TP, make the following Script Call:
  18.  * $gameSystem.showCharTP(x);
  19.  * with x being the ID of the actor. Make sure you first turn on TP in the database!
  20.  * To hide an actor's TP, make the following Script Call:
  21.  * $gameSystem.hideCharTP(x);
  22.  * Note that TP will still be present on actors whether visible or not.
  23.  *
  24.  * Individual Actor and Enemy TP can also be set to a number other than 100.
  25.  * To do this, you must set the amount of Max TP the actor/enemy will gain.
  26.  * Using the notetag
  27.  * <tpChange: x>
  28.  * in Actor and Enemy notes will change the amount of Max TP using 100 as the base number.
  29.  * For example, If Actor 1 has the tag <tpChange: 25> , then he will start battles with a max TP of 125.
  30.  * You can also use the tags on Equip items and States to allow temporary changes.
  31.  * The values can also be negative numbers, but the lowest Max TP can be is 1.
  32.  */
  33.  
  34. var Mal = Mal || {};
  35.  
  36. Mal.Parameters = PluginManager.parameters('MalCharTp');
  37. Mal.CharTp = {};
  38. Mal.CharTp.max = Mal.Parameters['TPMax'];
  39.  
  40. //begin database setup
  41. var MalTPDatabaseLoad = DataManager.isDatabaseLoaded;
  42. DataManager.isDatabaseLoaded = function() {
  43.   if (!MalTPDatabaseLoad.call(this)) return false;
  44.   if (!DataManager._malTP_DatabaseLoaded) {
  45.     this.processTPNotetags($dataActors);
  46.     this.processTPNotetags2($dataActors);
  47.     this.processTPNotetags($dataEnemies);
  48.     this.processTPNotetags($dataWeapons);
  49.     this.processTPNotetags($dataArmors);
  50.     this.processTPNotetags($dataStates);
  51.     this.processTPNotetags($dataItems);
  52.     this.processTPNotetags($dataSkills);
  53.     DataManager._malTP_DatabaseLoaded = true;
  54.   }
  55.   return true;
  56. };
  57.  
  58.  
  59. DataManager.processTPNotetags = function(group) {
  60.     for (var n = 1; n < group.length; n++) {
  61.         var obj = group[n];
  62.         obj.tpChange = 0;
  63.         this.createTpValues(obj);
  64.     }
  65. };
  66.  
  67. DataManager.processTPNotetags2 = function(group) {
  68.     for (var n = 1; n < group.length; n++) {
  69.         var obj = group[n];
  70.         obj.showTP = false;
  71.     }
  72. };
  73.  
  74. DataManager.createTpValues = function(object) {
  75.     var noteread = object.note;
  76.     while(noteread.indexOf("tpChange") > -1)
  77.     {
  78.         var notereg = noteread.split("<tpChange: ");
  79.         var match = notereg[1].split(" ");
  80.         match = notereg[1].split(">");
  81.         var tpChange = Number(match[0]);
  82.         noteread = noteread.replace("tpChange", " ");
  83.         object.tpChange += tpChange;
  84.     }
  85. };
  86. //End Database setup
  87.  
  88. var malTPActorSetup = Game_Actor.prototype.setup;
  89. Game_Actor.prototype.setup = function(actorId) {
  90.     malTPActorSetup.call(this, actorId);
  91.     this.tpChange = $dataActors[actorId].tpChange;
  92.     this.showTP = $dataActors[actorId].showTP;
  93. };
  94.  
  95. Game_System.prototype.showCharTP = function(actorId) {
  96.     var actor = $gameActors.actor(actorId);
  97.     actor.showTP = true;
  98. };
  99.  
  100. Game_System.prototype.hideCharTP = function(actorId) {
  101.     var actor = $gameActors.actor(actorId);
  102.     actor.showTP = false;
  103. };
  104.  
  105. var malTPEnemySetup = Game_Enemy.prototype.setup;
  106. Game_Enemy.prototype.setup = function(enemyId, x, y) {
  107.     malTPEnemySetup.call(this, enemyId, x, y);
  108.     this.tpChange = $dataEnemies[this._enemyId].tpChange;
  109. };
  110.  
  111. Game_BattlerBase.prototype.maxTp = function() {
  112.     var max = Number(Mal.CharTp.max);
  113.     var pretp = max;
  114.     if (this.isActor() ) {
  115.         for(var i = 0; i < this.equips().length; ++i) {
  116.             if (this.equips()[i]) {
  117.                 pretp += this.equips()[i].tpChange;
  118.             }
  119.         }
  120.     pretp += Number(this.actor().tpChange);
  121.     }
  122.     for(var i = 0; i < this.states().length; ++i) {
  123.         pretp += Number(this.states()[i].tpChange);
  124.     }
  125.     if (this.isEnemy() ) pretp += Number(this.enemy().tpChange);
  126.     return pretp.clamp(0, max);
  127. };
  128.  
  129. var malTPsetTP = Game_BattlerBase.prototype.setTp;
  130. Game_BattlerBase.prototype.setTp = function(tp) {
  131.     var max = Mal.CharTp.max;
  132.     malTPsetTP.call(this, tp);
  133.     this._tp = Math.max(tp, 0);
  134.     this.refresh();
  135. };
  136. Window_BattleStatus.prototype.drawGaugeArea = function(rect, actor) {
  137.     if ($dataSystem.optDisplayTp && actor.showTP) {
  138.         this.drawGaugeAreaWithTp(rect, actor);
  139.     } else {
  140.         this.drawGaugeAreaWithoutTp(rect, actor);
  141.     }
  142. };
Add Comment
Please, Sign In to add comment