Advertisement
Maliki79

Mal_StateCategories_Ext_add_debuff

Jan 26th, 2019 (edited)
340
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // Maliki's State Categories EX
  3. // Mal_StateCategories_Ext_add_debuff.js
  4. // version 1.0
  5. //=============================================================================
  6. /*:  
  7. * @plugindesc This plugin allows debuffs to be included when removing State Categories
  8.  * @author Maliki79
  9.  
  10.  *
  11.  * @help Version 1.0
  12.  * You will need YanFly's State Categories Plugin as well as any accompanying plugins.
  13.  * This plugin is plug and play.
  14.  * Just put it right under the State Categories one and you're go to go!
  15.  *
  16.  * To use, add battler.removeStateDebuffCategory('text', x);
  17.  * with text being the category name (dont forget the quote marks (' ')) and x being
  18.  * the number of states or debuffs to remove.
  19.  * The plugin will pick x number of states/debuffs and remove them.
  20.  * YF's plugin removed them in a specific order, but this one will remove a random state/debuff.
  21.  * (By the way, if you want to only remove a Debuff, do the call with a category name you
  22.  * are NOT using.)
  23.  */
  24.  
  25. Game_Battler.prototype.removeStateDebuffCategory = function(category, count) {
  26.     category = category.toUpperCase().trim();
  27.     count = count || 0;
  28.     var states = JsonEx.makeDeepCopy(this._states);
  29.     var buffs = JsonEx.makeDeepCopy(this._buffs);
  30.     var states2 = [];
  31.     var length = states.length;
  32.     var value = 0;
  33.     for (var i = 0; i < length; ++i) {
  34.       var id = states[i];
  35.       var state = $dataStates[id];
  36.       if (!state) continue;
  37.       if (state.category.contains(category)) states2.push("s," + id);
  38.     }
  39.     for (var i = 0; i < buffs.lenght; i++) {
  40.         if (buffs[i] < 0) states2.push("b," + i);
  41.     }
  42.     for (var i = 0; i < count; i++) {
  43.         if (states2 === [] ) continue;
  44.         var pick2 = Math.randomInt(states2.length);
  45.         var pick = states2[pick2].split(",");
  46.         if (pick[0] === "s") {
  47.             this.removeState(pick[1]);
  48.         } else {
  49.             this.removeBuff(pick[1]);
  50.         }
  51.         states2.splice(pick2, 1);      
  52.     }
  53. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement