Advertisement
ICF-Soft

ICF-Soft Element Core 1.01 RPG Maker MV

Jul 16th, 2016
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // ICF-Soft Plugins - Element Core
  3. // ICFSoft_ElementCore.js
  4. //=============================================================================
  5.  
  6. var Imported = Imported || {};
  7. Imported.ICFSoft_ElementCore = true;
  8.  
  9. var ICF = ICF || {};
  10. ICF.ElementCore = ICF.ElementCore || {};
  11.  
  12. //=============================================================================
  13.  /*:
  14.  * @plugindesc v1.01b This plugin adds an advanced element system.
  15.  * @author ICF-Soft [http://icfsoft.blogspot.com.es/]
  16.  *
  17.  * @param Elements Blend
  18.  * @desc How to apply when there are more than one element.
  19.  * 0 - Average  1 - Normal  2 - Absorb first
  20.  * @default 2
  21.  *
  22.  * @param Absorbtion Mode
  23.  * @desc How to treat element absorbtion.
  24.  * 0 - Absolute  1 - Relative
  25.  * @default 1
  26.  *
  27.  * @param Curse Absorb Mode
  28.  * @desc How to treat element curse for absorbing elements.
  29.  * 0 - Fixed  1 - Additive  2 - Relative
  30.  * @default 2
  31.  *
  32.  * @param Curse Absorb Factor
  33.  * @desc Used factor to treat element curse for absorbing elements.
  34.  * @default -0.1
  35.  *
  36.  * @param Curse Absorb Min
  37.  * @desc Minimun rate.
  38.  * @default 0.1
  39.  *
  40.  * @param Curse Neutral
  41.  * @desc Fixed rate for element curse on neutral elements.
  42.  * Also max rate for absorbtion and nin rate for normal.
  43.  * @default 2
  44.  *
  45.  * @param Curse Normal Mode
  46.  * @desc How to treat element curse for normal elements.
  47.  * 0 - Fixed  1 - Additive  2 - Relative
  48.  * @default 1
  49.  *
  50.  * @param Curse Normal Factor
  51.  * @desc Used factor to treat element curse for normal elements.
  52.  * @default 1
  53.  *
  54.  * @help
  55.  * ============================================================================
  56.  * Introduction
  57.  * ============================================================================
  58.  *
  59.  * Defalut element system in RPG Maker MV is limited and doesn't allow
  60.  * absorbtion.
  61.  *
  62.  * With this plugin you can use not only elements but skill and weapon types
  63.  * plus element absorbtion. Also is element/skill/weapon enhaces added.
  64.  *
  65.  * This new formula makes more things important and gives extra depth in
  66.  * tactics.
  67.  *
  68.  * Now you can make magic resistance, bulletproof and so on.
  69.  *
  70.  * New element curse feature allows to change element absorbtion into
  71.  * weakness.
  72.  *
  73.  * ============================================================================
  74.  * How to use
  75.  * ============================================================================
  76.  *
  77.  * It works with notetags. These can be used in actors, classes, enemies,
  78.  * weapons, armors and states.
  79.  *
  80.  * <ELEMENT ABSORB: x>
  81.  * <ELEMENT ABSORB: x, x>
  82.  *
  83.  *  - Add all elements that can be absorbed in one line.
  84.  *
  85.  * <ELEMENT CURSES: x>
  86.  * <ELEMENT CURSES: x, x>
  87.  *  
  88.  *  - Add all element curses in one line.
  89.  *
  90.  * <WEAPON ELEMENTS: x>
  91.  * <WEAPON ELEMENTS: x, x>
  92.  *
  93.  *  - Add all weapon elements that are used in one line.
  94.  *    Usefull for enemies and for unarmed actors.
  95.  *    0 is barehands. Used for actors when need a weapontype but hasn't one.
  96.  *
  97.  * <WEAPON RESISTANCES: x rate>
  98.  * <WEAPON RESISTANCES: x rate, x rate>
  99.  *
  100.  *  - Add all weapon resistances needed in one line.
  101.  *    rate: can be decimal where 1 is normal, 0.5 is half,
  102.  *          2 is double, etc...
  103.  *
  104.  * <SKILL RESISTANCES: x rate>
  105.  * <SKILL RESISTANCES: x rate, x rate>
  106.  *
  107.  *  - Add all skill resistances needed in one line.
  108.  *    rate: can be decimal where 1 is normal, 0.5 is half,
  109.  *          2 is double, etc...
  110.  *
  111.  * Skill resistance triggers on every skill that came with skilltype.
  112.  *
  113.  * Weapon resistance triggers on physical skills and weapon using skills.
  114.  *
  115.  * <ELEMENT ENHANCES: x rate>
  116.  * <ELEMENT ENHANCES: x rate, x rate>
  117.  * <SKILL ENHANCES: x rate>
  118.  * <SKILL ENHANCES: x rate, x rate>
  119.  * <WEAPON ENHANCES: x rate>
  120.  * <WEAPON ENHANCES: x rate, x rate>
  121.  *
  122.  *  - Add all element, skill and weapon enhacements needed in one line.
  123.  *    rate: can be decimal where 1 is normal, 0.5 is half,
  124.  *          2 is double, etc...
  125.  *
  126.  * ============================================================================
  127.  * Params
  128.  * ============================================================================
  129.  *
  130.  * Elements Blend:
  131.  *
  132.  *  Behavior when more than one element are used.
  133.  *
  134.  *  0 - Average:      Calcs entire element average.
  135.  *  1 - Normal:       Strongest element takes priority.
  136.  *  2 - Absorb first: If there is an absorbing element will take priority.
  137.  *
  138.  * Absorbtion Mode:
  139.  *
  140.  *  How element absorbtion is treated changes the way players must choose
  141.  *  equipment.
  142.  *
  143.  *  0 - Absolute:     Element defense increase absorbtion.
  144.  *  1 - Relative:     Element defense reduces absorbtion same way as damage.
  145.  *
  146.  * There are some parameters for element curse.
  147.  *
  148.  * Curse Absorb Mode / Curse Normal Mode:
  149.  *  
  150.  *  When rate is different than cero, either for absorbtion, resistance,
  151.  *  normal or weak, it needs a calculation based on actual rate.
  152.  *  You can use a different mode for negative and positive values.
  153.  *
  154.  *  0 - Fixed:        Rate will be substituyed with factor.
  155.  *  1 - Additive:     Will increase rate with factor.
  156.  *  2 - Relative:     Will multiply rate with factor.
  157.  *
  158.  * Curse Absorb Factor / Curse Normal Factor:
  159.  *  
  160.  *  The factor that will be used to calc rate.
  161.  *
  162.  * Curse Absorb Min:
  163.  *
  164.  *  A min rate for absorb.
  165.  *
  166.  * Curse Neutral:
  167.  *
  168.  *  Neutral is when rate is equal to cero, inmunity.
  169.  *  This is a fixed rate so it needs to change to a another fixed rate.
  170.  *  It's also used as max rate when absorb and min rate for else.
  171.  *
  172.  * ============================================================================
  173.  * Incompatibilities
  174.  * ============================================================================
  175.  *
  176.  * There's no known incompatible plugins yet.
  177.  *
  178.  * ============================================================================
  179.  * Known isues
  180.  * ============================================================================
  181.  *
  182.  * It overrides every other element system that comes after.
  183.  *
  184.  * ============================================================================
  185.  * Changelog
  186.  * ============================================================================
  187.  *
  188.  * Version 1.01:
  189.  * - Improved formula.
  190.  * - Added element curse.
  191.  * - Added element/skill/weapon enhace.
  192.  * - Changed how rates must be used inside notetags.
  193.  *
  194.  * Version 1.00:
  195.  * - Finished plugin!
  196.  *
  197.  * ============================================================================
  198.  *
  199.  * For commercial and non-commercial games.
  200.  * Credit to ICF-Soft.
  201.  * This entire header must be included with plugin.
  202.  *
  203.  * ============================================================================
  204. */
  205. //=============================================================================
  206.  /*:es
  207.  * @plugindesc v1.01b Este complemento añade un sistema de elementos
  208.  * avanzado.
  209.  * @author ICF-Soft [http://icfsoft.blogspot.com.es/]
  210.  *
  211.  * @param Elements Blend
  212.  * @desc Qué hacer cuando se usa más de un elemento.
  213.  * 0 - Media  1 - Normal  2 - Absorbción primero
  214.  * @default 2
  215.  *
  216.  * @param Absorbtion Mode
  217.  * @desc El modo en el que se absorben los elementos.
  218.  * 0 - Absoluto  1 - Relativo
  219.  * @default 1
  220.  *
  221.  * @param Curse Absorb Mode
  222.  * @desc Como tratar la maldición elemental ante la absorción.
  223.  * 0 - Fijo  1 - Aditivo  2 - Relativo
  224.  * @default 2
  225.  *
  226.  * @param Curse Absorb Factor
  227.  * @desc Factor a usar para calcular el daño.
  228.  * @default -0.1
  229.  *
  230.  * @param Curse Absorb Min
  231.  * @desc Valor mínimo.
  232.  * @default 0.1
  233.  *
  234.  * @param Curse Neutral
  235.  * @desc Valor fijo cuando se es inmune al elemento.
  236.  * Además valor máximo en la absorción y mínimo en el resto.
  237.  * @default 2
  238.  *
  239.  * @param Curse Normal Mode
  240.  * @desc Como tratar la maldición elemental normalmente.
  241.  * 0 - Fijo  1 - Aditivo  2 - Relativo
  242.  * @default 1
  243.  *
  244.  * @param Curse Normal Factor
  245.  * @desc Factor a usar para calcular el daño.
  246.  * @default 1
  247.  *
  248.  * @help
  249.  * ============================================================================
  250.  * Introducción
  251.  * ============================================================================
  252.  *
  253.  * El sistema de elementos que viene predeterminado en RPG Maker MV es limitado
  254.  * y no permite la absorbción.
  255.  *
  256.  * Con este complemento puedes usar no sólo elementos sino también tipos de
  257.  * habilidades y armas además de la absorbción de elementos y la bonificación
  258.  * de elementos, habilidades y armas.
  259.  *
  260.  * Esta nueva fórmula da importancia a más opciones y da profundidad extra
  261.  * en las tácticas.
  262.  *
  263.  * Ahora puedes utilizar resistencia a la magia, antibalas y más cosas similares.
  264.  *
  265.  * La nueva maldición elemental permite volver debilidad cualquier elemento
  266.  * incluso cuando es absorbido.
  267.  *
  268.  * ============================================================================
  269.  * Uso
  270.  * ============================================================================
  271.  *
  272.  * Funciona con etiquetas en las notas. Pueden usarse en actores, clases,
  273.  * enemigos, armas, armaduras y estados alterados.
  274.  *
  275.  * <ELEMENT ABSORB: x>
  276.  * <ELEMENT ABSORB: x, x>
  277.  *
  278.  *  - Añade todos los elementos que puede absorber en una linea.
  279.  *
  280.  * <ELEMENT CURSES: x>
  281.  * <ELEMENT CURSES: x, x>
  282.  *  
  283.  *  - Añade todas las maldiciones elementales en una linea.
  284.  *
  285.  * <WEAPON ELEMENTS: x>
  286.  * <WEAPON ELEMENTS: x, x>
  287.  *
  288.  *  - Añade todos los tipos de arma que se utilizan en una linea.
  289.  *    Útil para enemigos y los actores que no lleven armas.
  290.  *    0 son los puños. Se utiliza cuando un actor necesita un tipo de arma
  291.  *    pero no está disponible ninguno.
  292.  *
  293.  * <WEAPON RESISTANCES: x rate>
  294.  * <WEAPON RESISTANCES: x rate, x rate>
  295.  *
  296.  *  - Añade todas las resistencias a las armas en una linea.
  297.  *    rate: puede ser decimal, 1 es normal, 0.5 es la mitad,
  298.  *          2 es el doble, etc...
  299.  *
  300.  * <SKILL RESISTANCES: x rate>
  301.  * <SKILL RESISTANCES: x rate, x rate>
  302.  *
  303.  *  - Añade todas las resistencias a las habilidades en una linea.
  304.  *    rate: puede ser decimal, 1 es normal, 0.5 es la mitad,
  305.  *          2 es el doble, etc...
  306.  *
  307.  * La resistencia a las habilidades se activa en las habilidades que incluyan
  308.  * categoría.
  309.  *
  310.  * La resistencia a las armas se activa en las habilidades físicas y las que
  311.  * utilizan arma.
  312.  *
  313.  * <ELEMENT ENHANCES: x rate>
  314.  * <ELEMENT ENHANCES: x rate, x rate>
  315.  * <SKILL ENHANCES: x rate>
  316.  * <SKILL ENHANCES: x rate, x rate>
  317.  * <WEAPON ENHANCES: x rate>
  318.  * <WEAPON ENHANCES: x rate, x rate>
  319.  *
  320.  *  - Añade todas las bonificaciones de elementos, habilidades y armas
  321.  *    necesarias en una linea.
  322.  *    rate: puede ser decimal, 1 es normal, 0.5 es la mitad,
  323.  *          2 es el doble, etc...
  324.  *
  325.  * ============================================================================
  326.  * Parámetros
  327.  * ============================================================================
  328.  *
  329.  * Elements Blend:
  330.  *
  331.  *  El comportamiento cuando se usan más de un elemento.
  332.  *
  333.  *  0 - Media:             Calcula la media.
  334.  *  1 - Normal:            El elemento más dañino toma prioridad.
  335.  *  2 - Absorción primero: Si un elemento es absorbible tendrá prioridad.
  336.  *
  337.  * Absorbtion Mode:
  338.  *
  339.  *  El modo en el que los elementos son absorbidos cambia el modo en el que
  340.  *  el jugador debe seleccionar el equipamiento.
  341.  *
  342.  *  0 - Absoluto:     La defensa elemental incrementa la absorbción.
  343.  *  1 - Relativo:     La defensa elemental reduce tanto la absorbción
  344.  *                    como el daño.
  345.  *
  346.  * Para la maldición elemental se usan los siguientes parámetros:
  347.  *
  348.  * Curse Absorb Mode / Curse Normal Mode:
  349.  *  
  350.  *  Para daño negativo (absorción) y daño positivo (normal, débil o resistente)
  351.  *  se usan calculos distintos basado en el valor actual y un factor.
  352.  *
  353.  *  0 - Fijo:         El factor será el nuevo valor.
  354.  *  1 - Aditivo:      Al valor se le añade el factor.
  355.  *  2 - Relativo:     El valor se multiplica por el factor.
  356.  *
  357.  * Curse Absorb Factor / Curse Normal Factor:
  358.  *  
  359.  *  El factor usado para calcular.
  360.  *
  361.  * Curse Absorb Min:
  362.  *
  363.  *  El valor mínimo para el elemento absorbido.
  364.  *
  365.  * Curse Neutral:
  366.  *
  367.  *  El valor que tomará cuando se es inmune. Al ser fijo se sustituye por
  368.  *  otro valor fijo.
  369.  *  Además se usa como término medio entre absorción y daño.
  370.  *
  371.  * ============================================================================
  372.  * Incompatibilidades
  373.  * ============================================================================
  374.  *
  375.  * No se conocen complementos que sean incompatibles hasta la fecha.
  376.  *
  377.  * ============================================================================
  378.  * Problemas conocidos
  379.  * ============================================================================
  380.  *
  381.  * Se sobreescribe cualquier sistema de elementos que se haya puesto antes.
  382.  *
  383.  * ============================================================================
  384.  * Historial de versiones
  385.  * ============================================================================
  386.  *
  387.  * Versión 1.01:
  388.  * - Se ha mejorado la fórmula de cálculo.
  389.  * - Se ha añadido la maldición elemental.
  390.  * - Se ha añadido bonificación de elemento/habilidad/arma.
  391.  * - Se ha cambiado el modo en que se usan las etiquetas de las notas.
  392.  *
  393.  * Versión 1.00:
  394.  * - Complemento terminado.
  395.  *
  396.  * ============================================================================
  397.  *
  398.  * Para juegos comerciales y no comerciales.
  399.  * Se debe incluir a ICF-Soft en los créditos.
  400.  * Esta cabecera debe incluirse íntegramente con el plugin.
  401.  *
  402.  * ============================================================================
  403. */
  404. //=============================================================================
  405.  
  406. //=============================================================================
  407. // Parameter Variables
  408. //=============================================================================
  409.  
  410. ICF.Parameters = PluginManager.parameters('ICFSoft_ElementCore');
  411. ICF.Param = ICF.Param || {};
  412.  
  413. ICF.Param.ElementBlend = Number(ICF.Parameters['Elements Blend']);
  414. ICF.Param.ElementAbsorbM = Number(ICF.Parameters['Absorbtion Mode']);
  415.  
  416. ICF.Param.ElementCurseAbsM = Number(ICF.Parameters['Curse Absorb Mode']);
  417. ICF.Param.ElementCurseAbsF = Number(ICF.Parameters['Curse Absorb Factor']);
  418. ICF.Param.ElementCurseAbsMin = Number(ICF.Parameters['Curse Absorb Min']);
  419. ICF.Param.ElementCurseNeutral = Number(ICF.Parameters['Curse Neutral']);
  420. ICF.Param.ElementCurseMode = Number(ICF.Parameters['Curse Normal Mode']);
  421. ICF.Param.ElementCurseFactor = Number(ICF.Parameters['Curse Normal Factor']);
  422.  
  423. //=============================================================================
  424. // Constants
  425. //=============================================================================
  426.  
  427. Game_BattlerBase.TRAIT_SK_ELEMENT_RATE    = 15;
  428. Game_BattlerBase.TRAIT_WP_ELEMENT_RATE    = 16;
  429. Game_BattlerBase.TRAIT_ELEMENT_ABSORB     = 17;
  430. Game_BattlerBase.TRAIT_ELEMENT_CURSE      = 18;
  431. Game_BattlerBase.TRAIT_ATTACK_WP_ELEMENT  = 35;
  432. Game_BattlerBase.TRAIT_ATTACK_EL_ENHACE   = 36;
  433.  
  434. //=============================================================================
  435. // DataManager
  436. //=============================================================================
  437.  
  438. ICF.ElementCore.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded;
  439. DataManager.isDatabaseLoaded = function() {
  440.     if (!ICF.ElementCore.DataManager_isDatabaseLoaded.call(this)) return false;
  441.     if (!ICF.ElementCore.Procesed) {
  442.     DataManager.processEleCoreNotetags($dataActors);
  443.     DataManager.processEleCoreNotetags($dataClasses);
  444.     DataManager.processEleCoreNotetags($dataEnemies);
  445.     DataManager.processEleCoreNotetags($dataWeapons);
  446.     DataManager.processEleCoreNotetags($dataArmors);
  447.     DataManager.processEleCoreNotetags($dataStates);
  448.     ICF.ElementCore.Procesed = true;
  449.     }
  450.     return true;
  451. };
  452.  
  453. DataManager.processEleCoreNotetags = function(group) {
  454.     var note1 = /<(?:ELEMENT ABSORB):[ ]*(\d+(?:\s*,\s*\d+)*)>/i;
  455.     var note2 = /<(?:WEAPON ELEMENTS):[ ]*(\d+(?:\s*,\s*\d+)*)>/i;
  456.     var note3 = /<(?:SKILL RESISTANCES):[ ]*(\d+\s+\d+(?:\.\d+)?(?:\s*,\s*\d+\s+\d+(?:\.\d+)?)*)>/i;
  457.     var note4 = /<(?:WEAPON RESISTANCES):[ ]*(\d+\s+\d+(?:\.\d+)?(?:\s*,\s*\d+\s+\d+(?:\.\d+)?)*)>/i;
  458.     var note5 = /<(?:ELEMENT CURSES):[ ]*(\d+(?:\s*,\s*\d+)*)>/i;
  459.     var note6 = /<(?:ELEMENT ENHANCES):[ ]*(\d+\s+\d+(?:\.\d+)?(?:\s*,\s*\d+\s+\d+(?:\.\d+)?)*)>/i;
  460.     var note7 = /<(?:SKILL ENHANCES):[ ]*(\d+\s+\d+(?:\.\d+)?(?:\s*,\s*\d+\s+\d+(?:\.\d+)?)*)>/i;
  461.     var note8 = /<(?:WEAPON ENHANCES):[ ]*(\d+\s+\d+(?:\.\d+)?(?:\s*,\s*\d+\s+\d+(?:\.\d+)?)*)>/i;
  462.  
  463.     for (var n = 1; n < group.length; n++) {
  464.     var obj = group[n];
  465.     var notedata = obj.note.split(/[\r\n]+/);
  466.  
  467.     for (var i = 0; i < notedata.length; i++) {
  468.         var line = notedata[i];
  469.         if (line.match(note1)) {
  470.             var array = JSON.parse('[' + RegExp.$1.match(/\d+/g) + ']');
  471.             for (var il = 0; il < array.length; il++) {
  472.                 obj.traits.push({code:17, dataId:array[il], value:0});
  473.             }
  474.         } else if (line.match(note2)) {
  475.             var array = JSON.parse('[' + RegExp.$1.match(/\d+/g) + ']');
  476.             for (var il = 0; il < array.length; il++) {
  477.                 obj.traits.push({code:35, dataId:array[il], value:0});
  478.             }
  479.         } else if (line.match(note3)) {
  480.             var array = JSON.parse('[' + RegExp.$1.match(/\d+(?:\.\d+)?/g) + ']');
  481.             for (var il = 0; il < (array.length - 1); il += 2) {
  482.                 obj.traits.push({code:15, dataId:array[il], value:array[il + 1]});
  483.             }
  484.         } else if (line.match(note4)) {
  485.             var array = JSON.parse('[' + RegExp.$1.match(/\d+(?:\.\d+)?/g) + ']');
  486.             for (var il = 0; il < (array.length - 1); il += 2) {
  487.                 obj.traits.push({code:16, dataId:array[il], value:array[il + 1]});
  488.             }
  489.         } else if (line.match(note5)) {
  490.             var array = JSON.parse('[' + RegExp.$1.match(/\d+/g) + ']');
  491.             for (var il = 0; il < array.length; il++) {
  492.                 obj.traits.push({code:18, dataId:array[il], value:0});
  493.             }
  494.         } else if (line.match(note6)) {
  495.             var array = JSON.parse('[' + RegExp.$1.match(/\d+(?:\.\d+)?/g) + ']');
  496.             for (var il = 0; il < (array.length - 1); il += 2) {
  497.                 obj.traits.push({code:36, dataId:array[il], value:array[il + 1]});
  498.             }
  499.         } else if (line.match(note7)) {
  500.             var array = JSON.parse('[' + RegExp.$1.match(/\d+(?:\.\d+)?/g) + ']');
  501.             for (var il = 0; il < (array.length - 1); il += 2) {
  502.                 obj.traits.push({code:36, dataId:array[il] + 2000, value:array[il + 1]});
  503.             }
  504.         } else if (line.match(note8)) {
  505.             var array = JSON.parse('[' + RegExp.$1.match(/\d+(?:\.\d+)?/g) + ']');
  506.             for (var il = 0; il < (array.length - 1); il += 2) {
  507.                 obj.traits.push({code:36, dataId:array[il] + 4000, value:array[il + 1]});
  508.             }
  509.         }
  510.     }
  511.     }
  512. };
  513.  
  514. //=============================================================================
  515. // Game_BattlerBase
  516. //=============================================================================
  517.  
  518. Game_BattlerBase.prototype.elementEnhace = function(elementId) {
  519.     return this.traitsPi(Game_BattlerBase.TRAIT_ATTACK_EL_ENHACE, elementId);
  520. };
  521.  
  522. Game_BattlerBase.prototype.skillEnhace = function(stypeId) {
  523.     return this.traitsPi(Game_BattlerBase.TRAIT_ATTACK_EL_ENHACE, stypeId + 2000);
  524. };
  525.  
  526. Game_BattlerBase.prototype.weaponEnhace = function(wtypeId) {
  527.     return this.traitsPi(Game_BattlerBase.TRAIT_ATTACK_EL_ENHACE, wtypeId + 4000);
  528. };
  529.  
  530. Game_BattlerBase.prototype.elementAbsorb = function(elementId) {
  531.     return (this.traitsWithId(Game_BattlerBase.TRAIT_ELEMENT_ABSORB, elementId).length > 0);
  532. };
  533.  
  534. Game_BattlerBase.prototype.elementCurse = function(elementId) {
  535.     return (this.traitsWithId(Game_BattlerBase.TRAIT_ELEMENT_CURSE, elementId).length > 0);
  536. };
  537.  
  538. ICF.ElementCore.Game_BtlrBase_elementRate = Game_BattlerBase.prototype.elementRate;
  539. Game_BattlerBase.prototype.elementRate = function(elementId) {
  540.     var result = ICF.ElementCore.Game_BtlrBase_elementRate.call(this, elementId);
  541.     if (this.elementAbsorb(elementId)) {
  542.     if (ICF.Param.ElementAbsorbM == 0) {result = Math.min(result - 2.0, -0.01);}
  543.     else {result *= -1}
  544.     }
  545.     if (this.elementCurse(elementId)) {
  546.     if (result < 0) {
  547.         if (ICF.Param.ElementCurseAbsM == 0) return ICF.Param.ElementCurseAbsF;
  548.         else if (ICF.Param.ElementCurseAbsM == 1) {
  549.             result += ICF.Param.ElementCurseAbsF;
  550.             return result.clamp(ICF.Param.ElementCurseAbsMin, ICF.Param.ElementCurseNeutral);
  551.         } else {
  552.             result *= ICF.Param.ElementCurseAbsF;
  553.             return result.clamp(ICF.Param.ElementCurseAbsMin, ICF.Param.ElementCurseNeutral);
  554.         }
  555.     } else if (result == 0) {
  556.         return ICF.Param.ElementCurseNeutral;
  557.     } else {
  558.         if (ICF.Param.ElementCurseMode == 0) return Math.max(result, ICF.Param.ElementCurseFactor);
  559.         else if (ICF.Param.ElementCurseMode == 1) {
  560.             result += ICF.Param.ElementCurseFactor;
  561.             return Math.max(result, ICF.Param.ElementCurseNeutral);
  562.         } else {
  563.             result *= ICF.Param.ElementCurseFactor;
  564.             return Math.max(result, ICF.Param.ElementCurseNeutral);
  565.         }
  566.     }
  567.     }
  568.     return result;
  569. };
  570.  
  571. Game_BattlerBase.prototype.elSkillRate = function(stypeId) {
  572.     return this.traitsPi(Game_BattlerBase.TRAIT_SK_ELEMENT_RATE, stypeId);
  573. };
  574.  
  575. Game_BattlerBase.prototype.elWeaponRate = function(wtypeId) {
  576.     return this.traitsPi(Game_BattlerBase.TRAIT_WP_ELEMENT_RATE, wtypeId);
  577. };
  578.  
  579. Game_BattlerBase.prototype.wpAttackElements = function() {
  580.     var wpns = this.traitsSet(Game_BattlerBase.TRAIT_ATTACK_WP_ELEMENT);
  581.     wpns.sort(function(a, b){return a-b});
  582.     for (i = wpns.length - 1; i > 0; i -= 1) {
  583.     if (wpns[i] == wpns[i - 1]) wpns.splice(i,1);
  584.     }
  585.     return wpns;
  586. };
  587.  
  588. Game_BattlerBase.prototype.ADVelementRate = function(elementId, subject) {
  589.     return this.elementRate(elementId) * (subject == undefined)? 1 : subject.elementEnhace(elementId);
  590. };
  591.  
  592. Game_BattlerBase.prototype.ADVelSkillRate = function(stypeId, subject) {
  593.     return this.elSkillRate(stypeId) * (subject == undefined)? 1 : subject.skillEnhace(stypeId);
  594. };
  595.  
  596. Game_BattlerBase.prototype.ADVelWeaponRate = function(wtypeId, subject) {
  597.     return this.elWeaponRate(wtypeId) * (subject == undefined)? 1 : subject.weaponEnhace(wtypeId);
  598. };
  599.  
  600. //=============================================================================
  601. // Game_Actor
  602. //=============================================================================
  603.  
  604. Game_Actor.prototype.wpAttackElements = function() {
  605.     var wpns = [];
  606.     if (this.weapons().length > 0) {
  607.     wpns = this.weapons().reduce(function(r, obj) {
  608.         return r.concat([obj.wtypeId]);
  609.     }, []);
  610.     wpns.sort(function(a, b){return a-b});
  611.     for (i = wpns.length - 1; i > 0; i -= 1) {
  612.         if (wpns[i] == wpns[i - 1]) wpns.splice(i,1);
  613.     }
  614.     return wpns;
  615.     }
  616.  
  617.     wpns = Game_BattlerBase.prototype.wpAttackElements.call(this);
  618.     if (wpns.length == 0) wpns[0] = 0;
  619.  
  620.     return wpns;
  621. };
  622.  
  623. //=============================================================================
  624. // Game_Action
  625. //=============================================================================
  626.  
  627. Game_Action.prototype.elementsMaxRate = function(target, elements, subject) {
  628.     if (elements.length > 0) {
  629.         return Math.max.apply(null, elements.map(function(elementId) {
  630.             return target.ADVelementRate(elementId, subject);
  631.         }, this));
  632.     } else {
  633.         return 1;
  634.     }
  635. };
  636.  
  637. Game_Action.prototype.elementsMinRate = function(target, elements, subject) {
  638.     if (elements.length > 0) {
  639.         return Math.min.apply(null, elements.map(function(elementId) {
  640.             return target.ADVelementRate(elementId, subject);
  641.         }, this));
  642.     } else {
  643.         return 1;
  644.     }
  645. };
  646.  
  647. Game_Action.prototype.elementsAverageRate = function(target, elements, subject) {
  648.     if (elements.length > 0) {
  649.         return elements.reduce(function(r, element) {
  650.             return r + target.ADVelementRate(element, subject);
  651.         }, 0) / elements.length;
  652.     } else {
  653.         return 1;
  654.     }
  655. };
  656.  
  657. Game_Action.prototype.wpElementsMaxRate = function(target, wpelements, subject) {
  658.     if (wpelements.length > 0) {
  659.         return Math.max.apply(null, wpelements.map(function(wpelementId) {
  660.             return target.ADVelWeaponRate(wpelementId, subject);
  661.         }, this));
  662.     } else {
  663.         return 1;
  664.     }
  665. };
  666.  
  667. Game_Action.prototype.wpElementsAverageRate = function(target, wpelements, subject) {
  668.     if (wpelements.length > 0) {
  669.         return wpelements.reduce(function(r, wpelement) {
  670.             return r + target.ADVelWeaponRate(wpelement, subject);
  671.         }, 0) / wpelements.length;
  672.     } else {
  673.         return 1;
  674.     }
  675. };
  676.  
  677. Game_Action.prototype.calcWeaponElementRate = function(target) {
  678.     var rate = 1;
  679.     var wpns = this.subject().wpAttackElements();
  680.     if (wpns.length > 0) {
  681.     if (ICF.Param.ElementBlend == 0) {
  682.         rate = this.wpElementsAverageRate(target, wpns, this.subject());
  683.     } else {
  684.         rate = this.wpElementsMaxRate(target, wpns, this.subject());
  685.     }
  686.     }
  687.     return rate;
  688. };
  689.  
  690. Game_Action.prototype.calcElementRate = function(target) {
  691.     var rate = 1;
  692.     var rate2 = 0;
  693.     if (this.item().damage.elementId < 0) {
  694.     if (ICF.Param.ElementBlend == 0) {
  695.         rate = this.elementsAverageRate(target, this.subject().attackElements(), this.subject());
  696.     } else {
  697.         rate = this.elementsMaxRate(target, this.subject().attackElements(), this.subject());
  698.         rate2 = this.elementsMinRate(target, this.subject().attackElements(), this.subject());
  699.         if (ICF.Param.ElementBlend == 2 && rate2 < 0) rate = rate2;
  700.     }
  701.     } else {
  702.         rate = target.ADVelementRate(this.item().damage.elementId, this.subject());
  703.     }
  704.     if (this.isSkill()) {
  705.     if ((this.item().stypeId > 0)&&(this.isMagical())) {
  706.         rate2 = target.ADVelSkillRate(this.item().stypeId, this.subject());
  707.         if ((rate < 0)||(rate2 < 1)) {rate = rate * rate2;}
  708.         else {rate += rate2 - 1;}
  709.     }
  710.     if ((this.isPhysical())||(this.item().damage.elementId < 0)) {
  711.         rate2 = this.calcWeaponElementRate(target) + rate;
  712.         if (rate2 > 2) {rate = rate2 - 1;}
  713.         else {rate = rate2 / 2;}
  714.     }
  715.     if ((this.item().stypeId > 0)&&(!this.isMagical())) {
  716.         rate2 = target.ADVelSkillRate(this.item().stypeId, this.subject());
  717.         if ((rate < 0)||(rate2 < 1)) {rate = rate * rate2;}
  718.         else {rate += rate2 - 1;}
  719.     }
  720.     }
  721.  
  722.     return rate;
  723. };
  724.  
  725. //=============================================================================
  726. // End of File
  727. //=============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement