Advertisement
Maliki79

MalDamageTypeChange

Aug 28th, 2021
1,417
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // Maliki's Damage Type Changer
  3. // MalDamageTypeChange.js
  4. // version 1.0
  5. //=============================================================================
  6. /*:  
  7.  * @plugindesc Version 1.0 Allows States to temporarily alter damage types in battle
  8.  * @author Maliki79
  9.  * @help
  10.  * To change a battler's damage type, place the following tag onto state notes:
  11.  * <typeChange_c>
  12.  * <typeChange_p>
  13.  * <typeChange_m>
  14.  *
  15.  * with <typeChange_m> changing ALL attacks to Magical.
  16.  * <typeChange_p> changing them to physical
  17.  * and <typeChange_c> changing them to certain hit type.
  18.  *
  19.  * Note that this alone will NOT alter damage formulas.
  20.  * In other words, if you want a magical skill to ignore magic defence, you'll
  21.  * need to do more than just apply this tag.
  22.  *
  23.  * Note also that there is a preferential order if you have multiple tags active.
  24.  * Certain Hit - Physical - Magical
  25.  */
  26.  
  27. //begin database setup
  28. var MalTChDatabaseLoad = DataManager.isDatabaseLoaded;
  29. DataManager.isDatabaseLoaded = function() {
  30.   if (!MalTChDatabaseLoad.call(this)) return false;
  31.   if (!DataManager._malTCh_DatabaseLoaded) {
  32.     this.processTChNotetags($dataWeapons);
  33.     this.processTChNotetags($dataArmors);
  34.     this.processTChNotetags($dataStates);
  35.     DataManager._malTCh_DatabaseLoaded = true;
  36.   }
  37.   return true;
  38. };
  39.  
  40.  
  41. DataManager.processTChNotetags = function(group) {
  42.     for (var n = 1; n < group.length; n++) {
  43.         var obj = group[n];
  44.         obj.c_change = false;
  45.         obj.p_change = false;
  46.         obj.m_change = false;
  47.         this.createTChValues(obj);
  48.     }
  49. };
  50.  
  51. DataManager.createTChValues = function(object) {
  52.     var noteread = object.note;
  53.     if(noteread.indexOf("typeChange_c") > -1) object.c_change = true;
  54.     if(noteread.indexOf("typeChange_p") > -1) object.p_change = true;
  55.     if(noteread.indexOf("typeChange_m") > -1) object.m_change = true;
  56. };
  57. //End Database setup
  58.  
  59. var mal_TCh_isCertainHit = Game_Action.prototype.isCertainHit;
  60. Game_Action.prototype.isCertainHit = function() {
  61.     if(this.typeCheck("a")) return this.typeCheck("c");
  62.     return mal_TCh_isCertainHit.call(this);
  63. };
  64.  
  65. var mal_TCh_isPhysical = Game_Action.prototype.isPhysical;
  66. Game_Action.prototype.isPhysical = function() {
  67.     if(this.typeCheck("a")) return this.typeCheck("p");
  68.     return mal_TCh_isPhysical.call(this);
  69. };
  70.  
  71. var mal_TCh_isMagical = Game_Action.prototype.isMagical;
  72. Game_Action.prototype.isMagical = function() {
  73.     if(this.typeCheck("a")) return this.typeCheck("m");
  74.     return mal_TCh_isMagical.call(this);
  75. };
  76.  
  77. Game_Action.prototype.typeCheck = function(key) {
  78.     var key = key;
  79.     var states = this.subject().states();
  80.     for(var i = 0; i < states.length; ++i) {
  81.         if(states[i].c_change == true && (key === "c" || key === 'a')) return true;
  82.         if(states[i].p_change == true && (key === "p" || key === 'a')) return true;
  83.         if(states[i].m_change == true && (key === "m" || key === 'a')) return true;
  84.     }
  85.     return false;
  86. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement