Advertisement
Maliki79

MalElementsEX

Nov 11th, 2015 (edited)
1,119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // MalElementEX
  3. // MalElementsEX.js
  4. // version 1.6
  5. //=============================================================================
  6. /*:
  7.  * @plugindesc Allows Actors, enemies, weapons, classes, armors and states to affect elements boosting skill effects by a set amount.
  8.  * Also allows elements to be lessened and further to allow element absorption.
  9.  *
  10.  * @author Maliki79
  11.  *
  12.  * @help
  13.  * Actor, Enemy, Class, Weapon, Armor and State Notetags :
  14.  * <element_boost: elementID boost >
  15.  * <element_Dboost: elementID boost >
  16.  * <object_element: number >
  17.  *  Note1: Do not forget the spaces near the end of the expressions!
  18.  *  Note2: The <Object_element> tag can be applied to skills and items as well.
  19.  *  
  20.  *
  21.  *  When battler uses a skill or item given an Object Element #, the raw damage/healing of the attack will
  22.  *  be multiplied by the boost amount. (This only applies to damage formula values.)
  23.  *  You can give Object Elements to pretty much anything in your game.
  24.  *
  25.  *     Repeats of the tags on weapons, armors, states, classes will have a cumulative effect.
  26.  *     Examples:
  27.  *     Notetag: <element_boost: 1 2>
  28.  *     Result: If the attack normally does 100 damage, this tag will raise the damage to 300.  (100 + 200 bonus)
  29.  *             If this tag were used on a state applied first, the damage would become 500.
  30.  *
  31.  *     Notetag: <element_Dboost: 1 0.25>
  32.  *     Result: If the attack normally does 100 damage, this tag would lower the damage to 75. (100 - 25)
  33.  *
  34.  *     Notetag: <element_Dboost: 1 1>  
  35.  *     Result: If the attack normally does 100 damage, this tag would lower the damage to 0. (100 - 100)
  36.  *             If this tag were used on a state applied first, the damage would become -100. (100 - 200)
  37.  *             This damage would be converted to healing and absorbed.
  38.  *
  39.  *   You can assign multiple elements to objects as well, and if subjects and/or targets are affected by multiple elements,
  40.  *   the results will be added to the appropriate boost multiplier.
  41.  *  
  42.  *   You can tag Skills or Items with the tag <priorityObj> and that skill/item will NOT gain additional object elements
  43.  *   from any other sources. (Element boosts will still work.)
  44.  *  
  45.  *   You can also tag Skills/Items with <ignoreEquipElementObjects> ant those skills/item will NOT gain additional object
  46.  *   elements from equipment. (Element boosts will still work.)
  47.  */
  48.  
  49.  var MalElementsRefresh = Game_Battler.prototype.refresh;
  50.  Game_Battler.prototype.refresh = function()
  51.  {
  52.  MalElementsRefresh.call(this);
  53.  this.setElementRates();
  54.  };
  55.  
  56. Game_Actor.prototype.setElementRates = function()
  57. {
  58.     this.elementA = [];
  59.     this.elementD = [];
  60.     this.setElements($dataActors[this.actorId()].note);
  61.     this.setElements(this.currentClass().note);
  62.     for(var i = 0; i < this.equips().length; ++i) if(this.equips()[i])this.setElements(this.equips()[i].note);
  63.     for(var i = 0; i < this.states().length; ++i) if(this.states()[i]) this.setElements(this.states()[i].note);    
  64. };
  65.  
  66. Game_Enemy.prototype.setElementRates = function()
  67. {
  68.     this.elementA = [];
  69.     this.elementD = [];
  70.     this.setElements($dataEnemies[this.enemyId()].note);
  71.     for(var i = 0; i < this.states().length; ++i) if(this.states()[i]) this.setElements(this.states()[i].note);    
  72. };
  73.  
  74. Game_Battler.prototype.setElements = function(note)
  75. {
  76.     var noteread = note;
  77.     while(noteread.indexOf("element_boost") > -1)
  78.     {
  79.         var notereg = noteread.split("<element_boost: ");
  80.         var match = notereg[1].split(" ");
  81.         var bonuselem = Number(match[0]);
  82.         var bonusvalue = Number(match[1]);
  83.         noteread = noteread.replace("element_boost", " ");
  84.         if (this.elementA[bonuselem]){
  85.             this.elementA[bonuselem] += bonusvalue;
  86.         } else {
  87.             this.elementA[bonuselem] = bonusvalue;
  88.         }
  89.     }
  90.     while(noteread.indexOf("element_Dboost") > -1)
  91.     {
  92.         var notereg = noteread.split("<element_Dboost: ");
  93.         var match = notereg[1].split(" ");
  94.         var bonuselem = Number(match[0]);
  95.         var bonusvalue = Number(match[1]);
  96.         noteread = noteread.replace("element_Dboost", " ");
  97.         if (this.elementD[bonuselem]){
  98.             this.elementD[bonuselem] += bonusvalue;
  99.         } else {
  100.             this.elementD[bonuselem] = bonusvalue;
  101.         }
  102.     }
  103. };
  104.  
  105. Game_Action.prototype.setObjEle = function() {
  106.    
  107.     this._objectE = [];
  108.     this.subject().setObjects(this.item(), this);
  109. };
  110.  
  111. Game_Actor.prototype.setObjects = function(item, action)
  112. {
  113.     this.setElementObjects(item.note, action);
  114.     if(!item.meta.priorityObj)
  115.     {
  116.         this.setElementObjects($dataActors[this.actorId()].note, action);
  117.         this.setElementObjects(this.currentClass().note, action);
  118.         if(!item.meta.ignoreEquipElementObjects) for(var i = 0; i < this.equips().length; ++i) if(this.equips()[i])this.setElementObjects(this.equips()[i].note, action);
  119.         for(var i = 0; i < this.states().length; ++i) if(this.states()[i]) this.setElementObjects(this.states()[i].note, action);  
  120.     }
  121. };
  122.  
  123. Game_Enemy.prototype.setObjects = function(item, action)
  124. {
  125.     this.setElementObjects(item.note, action);
  126.     if(!item.meta.priorityObj)
  127.     {
  128.         this.setElementObjects($dataEnemies[this.enemyId()].note, action);
  129.         for(var i = 0; i < this.states().length; ++i) if(this.states()[i]) this.setElementObjects(this.states()[i].note, action);      
  130.     }
  131. };
  132.  
  133. Game_Battler.prototype.setElementObjects = function(note, action)
  134. {
  135. var noteread = note;
  136.  
  137.     while(noteread.indexOf("object_element") > -1)
  138.     {
  139.     var notereg = noteread.split("<object_element: ");
  140.     var match = notereg[1].split(" ");
  141.     var elem2 = Number(match[0]);
  142.     noteread = noteread.replace("object_element", " ");
  143.     if(action._objectE.indexOf(elem2) == -1) action._objectE.push(elem2);
  144.     }
  145. };
  146.  
  147. var MalElements = Game_Action.prototype.makeDamageValue
  148. Game_Action.prototype.makeDamageValue = function(target, critical)
  149. {
  150.     var EleA = 1;
  151.     var EleD = 1;
  152.     var item = this.item();
  153.     this.setObjEle();
  154.     var baseValue = this.evalDamageFormula(target);
  155.     value = Math.round(value);
  156.     var value = baseValue; //var value = baseValue * this.calcElementRate(target);
  157.     if (this.isPhysical()) value *= target.pdr;
  158.     if (this.isMagical()) value *= target.mdr;
  159.     if (baseValue < 0) value *= target.rec;
  160.     if (critical) value = this.applyCritical(value);
  161.     //Element attack bonus
  162.     EleA += this.ElementAttackBoost(this.subject().elementA);
  163.     //Element Defence bonus
  164.     EleD -= this.ElementDefBoost(target.elementD);
  165.     value = this.applyVariance(value, item.damage.variance);
  166.     value = this.applyGuard(value, target);
  167.     value *= EleA;
  168.     value *= EleD;
  169.     value = Math.round(value);
  170.     this.calcElementRate(EleD);
  171.     return value;
  172. };
  173.  
  174. Game_Action.prototype.ElementAttackBoost = function(atkE){
  175.  
  176.     var num = 0;
  177.     var objele = this._objectE;
  178.     for(var i = 0; i < objele.length; ++i){
  179.         if(atkE[objele[i]]) num += atkE[objele[i]];
  180.     }
  181.     return num;
  182. };
  183.  
  184. Game_Action.prototype.ElementDefBoost = function(defE){
  185.  
  186.     var num = 0;
  187.     var objele = this._objectE;
  188.     for(var i = 0; i < objele.length; ++i){
  189.         if(defE[objele[i]]) num += defE[objele[i]];
  190.     }
  191.     return num;
  192. };
  193.  
  194. //Compatability overwrite for Victor's Damage Popups
  195. Game_Action.prototype.calcElementRate = function(target) {
  196.     var result = target;
  197.     if (result > 1) {
  198.         this._resist = 'weak';
  199.     } else if (result > 0 && result < 1) {
  200.         this._resist = 'resist';
  201.     } else if (result === 0) {
  202.         this._resist = 'immune';
  203.     } else if (result < 0) {
  204.         this._resist = 'absorb';
  205.     } else {
  206.         this._resist = ''
  207.     }
  208.     //return result;
  209. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement