Advertisement
ICF-Soft

ICF-Soft Element Core 1.02 RPG Maker MV

Aug 27th, 2016
145
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. ICF.ElementCore.Version = 102; // 1.02
  13.  
  14. //=============================================================================
  15.  /*:
  16.  * @plugindesc v1.02b This plugin adds an advanced element system.
  17.  * @author ICF-Soft [http://icfsoft.blogspot.com.es/]
  18.  *
  19.  * @param Elements Blend
  20.  * @desc How to apply when there are more than one element.
  21.  * 0 - Average  1 - Normal  2 - Absorb first  3 - Lowest
  22.  * @default 2
  23.  *
  24.  * @param Absorbtion Mode
  25.  * @desc How to treat element absorbtion.
  26.  * 0 - Absolute  1 - Relative
  27.  * @default 1
  28.  *
  29.  * @param Curse Absorb Mode
  30.  * @desc How to treat element curse for absorbing elements.
  31.  * 0 - Fixed  1 - Additive  2 - Relative
  32.  * @default 2
  33.  *
  34.  * @param Curse Absorb Factor
  35.  * @desc Used factor to treat element curse for absorbing elements.
  36.  * @default -0.1
  37.  *
  38.  * @param Curse Absorb Min
  39.  * @desc Minimun rate.
  40.  * @default 0.1
  41.  *
  42.  * @param Curse Neutral
  43.  * @desc Fixed rate for element curse on neutral elements.
  44.  * Also max rate for absorbtion and nin rate for normal.
  45.  * @default 2
  46.  *
  47.  * @param Curse Normal Mode
  48.  * @desc How to treat element curse for normal elements.
  49.  * 0 - Fixed  1 - Additive  2 - Relative
  50.  * @default 1
  51.  *
  52.  * @param Curse Normal Factor
  53.  * @desc Used factor to treat element curse for normal elements.
  54.  * @default 1
  55.  *
  56.  * @help
  57.  * ============================================================================
  58.  * Introduction
  59.  * ============================================================================
  60.  *
  61.  * Defalut element system in RPG Maker MV is limited and doesn't allow
  62.  * absorbtion.
  63.  *
  64.  * With this plugin you can use not only elements but skill, weapon types
  65.  * and item types plus element absorbtion. Also are element/skill/weapon/item
  66.  * enhaces and multiple elements added.
  67.  *
  68.  * This new formula makes more things important and gives extra depth in
  69.  * tactics.
  70.  *
  71.  * Now you can make magic resistance, bulletproof and so on.
  72.  *
  73.  * New element curse feature allows to change element absorbtion into
  74.  * weakness.
  75.  *
  76.  * You can add types for items like stone, magic stone, grenade, dart and
  77.  * so on with resist and enhace traits.
  78.  *
  79.  * ============================================================================
  80.  * How to use
  81.  * ============================================================================
  82.  *
  83.  * It works with notetags. These can be used in actors, classes, enemies,
  84.  * weapons, armors and states.
  85.  *
  86.  * <ELEMENT ABSORB: x>
  87.  * <ELEMENT ABSORB: x, x>
  88.  *
  89.  *  - Add all elements that can be absorbed in one line.
  90.  *
  91.  * <ELEMENT CURSES: x>
  92.  * <ELEMENT CURSES: x, x>
  93.  *  
  94.  *  - Add all element curses in one line.
  95.  *
  96.  * <WEAPON ELEMENTS: x>
  97.  * <WEAPON ELEMENTS: x, x>
  98.  *
  99.  *  - Add all weapon elements that are used in one line.
  100.  *    Usefull for enemies and for unarmed actors.
  101.  *    0 is barehands. Used for actors when need a weapontype but hasn't one.
  102.  *
  103.  * <WEAPON RESISTANCES: x rate>
  104.  * <WEAPON RESISTANCES: x rate, x rate>
  105.  *
  106.  *  - Add all weapon resistances needed in one line.
  107.  *    rate: can be decimal where 1 is normal, 0.5 is half,
  108.  *          2 is double, etc...
  109.  *
  110.  * <SKILL RESISTANCES: x rate>
  111.  * <SKILL RESISTANCES: x rate, x rate>
  112.  *
  113.  *  - Add all skill resistances needed in one line.
  114.  *    rate: can be decimal where 1 is normal, 0.5 is half,
  115.  *          2 is double, etc...
  116.  *
  117.  * <ITEM DAMAGE RESISTANCES: x rate>
  118.  * <ITEM DAMAGE RESISTANCES: x rate, x rate>
  119.  *
  120.  *  - Add all item-damage resistances needed in one line.
  121.  *    rate: can be decimal where 1 is normal, 0.5 is half,
  122.  *          2 is double, etc...
  123.  *
  124.  * Skill resistance triggers on every skill that came with skilltype.
  125.  *
  126.  * Weapon resistance triggers on physical skills and weapon using skills.
  127.  *
  128.  * Item resistance triggers on every item that came with item damage type.
  129.  * (See below).
  130.  *
  131.  * <ELEMENT ENHANCES: x rate>
  132.  * <ELEMENT ENHANCES: x rate, x rate>
  133.  * <SKILL ENHANCES: x rate>
  134.  * <SKILL ENHANCES: x rate, x rate>
  135.  * <WEAPON ENHANCES: x rate>
  136.  * <WEAPON ENHANCES: x rate, x rate>
  137.  * <ITEM DAMAGE ENHANCES: x rate>
  138.  * <ITEM DAMAGE ENHANCES: x rate, x rate>
  139.  *
  140.  *  - Add all element, skill, weapon and item enhacements needed in one line.
  141.  *    rate: can be decimal where 1 is normal, 0.5 is half,
  142.  *          2 is double, etc...
  143.  *
  144.  * Therer are new notetags for skills and items:
  145.  *
  146.  * <ELEMENTS: x>
  147.  * <ELEMENTS: x, x>
  148.  *
  149.  *  - Add all elements skill/item will use in one line.
  150.  *
  151.  * And for items only:
  152.  *
  153.  * <ITEM DAMAGE TYPE: x>
  154.  *
  155.  *  - Adds an item damage type.
  156.  *
  157.  * ============================================================================
  158.  * Params
  159.  * ============================================================================
  160.  *
  161.  * Elements Blend:
  162.  *
  163.  *  Behavior when more than one element are used.
  164.  *
  165.  *  0 - Average:      Calcs entire element average.
  166.  *  1 - Normal:       Strongest element takes priority.
  167.  *  2 - Absorb first: If there is an absorbing element will take priority.
  168.  *  3 - Minimun:      Weakest element takes priority.
  169.  *
  170.  * Absorbtion Mode:
  171.  *
  172.  *  How element absorbtion is treated changes the way players must choose
  173.  *  equipment.
  174.  *
  175.  *  0 - Absolute:     Element defense increase absorbtion.
  176.  *  1 - Relative:     Element defense reduces absorbtion same way as damage.
  177.  *
  178.  * There are some parameters for element curse.
  179.  *
  180.  * Curse Absorb Mode / Curse Normal Mode:
  181.  *  
  182.  *  When rate is different than cero, either for absorbtion, resistance,
  183.  *  normal or weak, it needs a calculation based on actual rate.
  184.  *  You can use a different mode for negative and positive values.
  185.  *
  186.  *  0 - Fixed:        Rate will be substituyed with factor.
  187.  *  1 - Additive:     Will increase rate with factor.
  188.  *  2 - Relative:     Will multiply rate with factor.
  189.  *
  190.  * Curse Absorb Factor / Curse Normal Factor:
  191.  *  
  192.  *  The factor that will be used to calc rate.
  193.  *
  194.  * Curse Absorb Min:
  195.  *
  196.  *  A min rate for absorb.
  197.  *
  198.  * Curse Neutral:
  199.  *
  200.  *  Neutral is when rate is equal to cero, inmunity.
  201.  *  This is a fixed rate so it needs to change to a another fixed rate.
  202.  *  It's also used as max rate when absorb and min rate for else.
  203.  *
  204.  * ============================================================================
  205.  * Incompatibilities
  206.  * ============================================================================
  207.  *
  208.  * There's no known incompatible plugins yet.
  209.  *
  210.  * ============================================================================
  211.  * Known isues
  212.  * ============================================================================
  213.  *
  214.  * It overrides every other element system that comes after.
  215.  *
  216.  * ============================================================================
  217.  * Changelog
  218.  * ============================================================================
  219.  *
  220.  * Version 1.02:
  221.  * - Use of ICF-Soft Main Utility.
  222.  * - Added multiple elements to skill and items.
  223.  * - Added item damage type with resistance and enhace.
  224.  * - Added lowest element rate.
  225.  *
  226.  * Version 1.01:
  227.  * - Improved formula.
  228.  * - Added element curse.
  229.  * - Added element/skill/weapon enhace.
  230.  * - Changed how rates must be used inside notetags.
  231.  *
  232.  * Version 1.00:
  233.  * - Finished plugin!
  234.  *
  235.  * ============================================================================
  236.  *
  237.  * For commercial and non-commercial games.
  238.  * Credit to ICF-Soft.
  239.  * This entire header must be included with plugin.
  240.  *
  241.  * ============================================================================
  242. */
  243. //=============================================================================
  244.  /*:es
  245.  * @plugindesc v1.02b Este complemento añade un sistema de elementos
  246.  * avanzado.
  247.  * @author ICF-Soft [http://icfsoft.blogspot.com.es/]
  248.  *
  249.  * @param Elements Blend
  250.  * @desc Qué hacer cuando se usa más de un elemento.
  251.  * 0 - Media  1 - Normal  2 - Absorbción primero  3 - Mínimo
  252.  * @default 2
  253.  *
  254.  * @param Absorbtion Mode
  255.  * @desc El modo en el que se absorben los elementos.
  256.  * 0 - Absoluto  1 - Relativo
  257.  * @default 1
  258.  *
  259.  * @param Curse Absorb Mode
  260.  * @desc Como tratar la maldición elemental ante la absorción.
  261.  * 0 - Fijo  1 - Aditivo  2 - Relativo
  262.  * @default 2
  263.  *
  264.  * @param Curse Absorb Factor
  265.  * @desc Factor a usar para calcular el daño.
  266.  * @default -0.1
  267.  *
  268.  * @param Curse Absorb Min
  269.  * @desc Valor mínimo.
  270.  * @default 0.1
  271.  *
  272.  * @param Curse Neutral
  273.  * @desc Valor fijo cuando se es inmune al elemento.
  274.  * Además valor máximo en la absorción y mínimo en el resto.
  275.  * @default 2
  276.  *
  277.  * @param Curse Normal Mode
  278.  * @desc Como tratar la maldición elemental normalmente.
  279.  * 0 - Fijo  1 - Aditivo  2 - Relativo
  280.  * @default 1
  281.  *
  282.  * @param Curse Normal Factor
  283.  * @desc Factor a usar para calcular el daño.
  284.  * @default 1
  285.  *
  286.  * @help
  287.  * ============================================================================
  288.  * Introducción
  289.  * ============================================================================
  290.  *
  291.  * El sistema de elementos que viene predeterminado en RPG Maker MV es limitado
  292.  * y no permite la absorbción.
  293.  *
  294.  * Con este complemento puedes usar no sólo elementos sino también tipos de
  295.  * habilidades, armas y objetos además de la absorbción de elementos y
  296.  * la bonificación de elementos, habilidades, armas y objetos.
  297.  * Además puedes usar varios elementos en habilidades y objetos.
  298.  *
  299.  * Esta nueva fórmula da importancia a más opciones y da profundidad extra
  300.  * en las tácticas.
  301.  *
  302.  * Ahora puedes utilizar resistencia a la magia, antibalas y más cosas similares.
  303.  *
  304.  * La nueva maldición elemental permite volver debilidad cualquier elemento
  305.  * incluso cuando es absorbido.
  306.  *
  307.  * Puedes añadir tipos de objetos tales como piedra, piedra mágica, granada,
  308.  * daro y similares con sus características de resistencia y mejora.
  309.  *
  310.  * ============================================================================
  311.  * Uso
  312.  * ============================================================================
  313.  *
  314.  * Funciona con etiquetas en las notas. Pueden usarse en actores, clases,
  315.  * enemigos, armas, armaduras y estados alterados.
  316.  *
  317.  * <ELEMENT ABSORB: x>
  318.  * <ELEMENT ABSORB: x, x>
  319.  *
  320.  *  - Añade todos los elementos que puede absorber en una linea.
  321.  *
  322.  * <ELEMENT CURSES: x>
  323.  * <ELEMENT CURSES: x, x>
  324.  *  
  325.  *  - Añade todas las maldiciones elementales en una linea.
  326.  *
  327.  * <WEAPON ELEMENTS: x>
  328.  * <WEAPON ELEMENTS: x, x>
  329.  *
  330.  *  - Añade todos los tipos de arma que se utilizan en una linea.
  331.  *    Útil para enemigos y los actores que no lleven armas.
  332.  *    0 son los puños. Se utiliza cuando un actor necesita un tipo de arma
  333.  *    pero no está disponible ninguno.
  334.  *
  335.  * <WEAPON RESISTANCES: x rate>
  336.  * <WEAPON RESISTANCES: x rate, x rate>
  337.  *
  338.  *  - Añade todas las resistencias a las armas en una linea.
  339.  *    rate: puede ser decimal, 1 es normal, 0.5 es la mitad,
  340.  *          2 es el doble, etc...
  341.  *
  342.  * <SKILL RESISTANCES: x rate>
  343.  * <SKILL RESISTANCES: x rate, x rate>
  344.  *
  345.  *  - Añade todas las resistencias a las habilidades en una linea.
  346.  *    rate: puede ser decimal, 1 es normal, 0.5 es la mitad,
  347.  *          2 es el doble, etc...
  348.  *
  349.  * <ITEM DAMAGE RESISTANCES: x rate>
  350.  * <ITEM DAMAGE RESISTANCES: x rate, x rate>
  351.  *
  352.  *  - Añade todas las resistencias a objetos en una linea.
  353.  *    rate: puede ser decimal, 1 es normal, 0.5 es la mitad,
  354.  *          2 es el doble, etc...
  355.  *
  356.  * La resistencia a las habilidades se activa en las habilidades que incluyan
  357.  * categoría.
  358.  *
  359.  * La resistencia a las armas se activa en las habilidades físicas y las que
  360.  * utilizan arma.
  361.  *
  362.  * La resistencia a los objetos se activa en los objetos que incluyan un tipo
  363.  * de daño (ver más abajo).
  364.  *
  365.  * <ELEMENT ENHANCES: x rate>
  366.  * <ELEMENT ENHANCES: x rate, x rate>
  367.  * <SKILL ENHANCES: x rate>
  368.  * <SKILL ENHANCES: x rate, x rate>
  369.  * <WEAPON ENHANCES: x rate>
  370.  * <WEAPON ENHANCES: x rate, x rate>
  371.  * <ITEM DAMAGE ENHANCES: x rate>
  372.  * <ITEM DAMAGE ENHANCES: x rate, x rate>
  373.  *
  374.  *  - Añade todas las bonificaciones de elementos, habilidades, armas
  375.  *    y objetos necesarias en una linea.
  376.  *    rate: puede ser decimal, 1 es normal, 0.5 es la mitad,
  377.  *          2 es el doble, etc...
  378.  *
  379.  *
  380.  * Nuevas etiquetas para habilidades y objetos:
  381.  *
  382.  * <ELEMENTS: x>
  383.  * <ELEMENTS: x, x>
  384.  *
  385.  *  - Añade todos los elementos que la habilidad u objeto va a usar en una sola
  386.  *    linea.
  387.  *
  388.  * Y para objetos solo:
  389.  *
  390.  * <ITEM DAMAGE TYPE: x>
  391.  *
  392.  *  - Añade el tipo de daño específico del objeto.
  393.  *
  394.  * ============================================================================
  395.  * Parámetros
  396.  * ============================================================================
  397.  *
  398.  * Elements Blend:
  399.  *
  400.  *  El comportamiento cuando se usan más de un elemento.
  401.  *
  402.  *  0 - Media:             Calcula la media.
  403.  *  1 - Normal:            El elemento más dañino toma prioridad.
  404.  *  2 - Absorción primero: Si un elemento es absorbible tendrá prioridad.
  405.  *  3 - Mínimo:            El elemento menos dañino toma prioridad.
  406.  *
  407.  * Absorbtion Mode:
  408.  *
  409.  *  El modo en el que los elementos son absorbidos cambia el modo en el que
  410.  *  el jugador debe seleccionar el equipamiento.
  411.  *
  412.  *  0 - Absoluto:     La defensa elemental incrementa la absorbción.
  413.  *  1 - Relativo:     La defensa elemental reduce tanto la absorbción
  414.  *                    como el daño.
  415.  *
  416.  * Para la maldición elemental se usan los siguientes parámetros:
  417.  *
  418.  * Curse Absorb Mode / Curse Normal Mode:
  419.  *  
  420.  *  Para daño negativo (absorción) y daño positivo (normal, débil o resistente)
  421.  *  se usan calculos distintos basado en el valor actual y un factor.
  422.  *
  423.  *  0 - Fijo:         El factor será el nuevo valor.
  424.  *  1 - Aditivo:      Al valor se le añade el factor.
  425.  *  2 - Relativo:     El valor se multiplica por el factor.
  426.  *
  427.  * Curse Absorb Factor / Curse Normal Factor:
  428.  *  
  429.  *  El factor usado para calcular.
  430.  *
  431.  * Curse Absorb Min:
  432.  *
  433.  *  El valor mínimo para el elemento absorbido.
  434.  *
  435.  * Curse Neutral:
  436.  *
  437.  *  El valor que tomará cuando se es inmune. Al ser fijo se sustituye por
  438.  *  otro valor fijo.
  439.  *  Además se usa como término medio entre absorción y daño.
  440.  *
  441.  * ============================================================================
  442.  * Incompatibilidades
  443.  * ============================================================================
  444.  *
  445.  * No se conocen complementos que sean incompatibles hasta la fecha.
  446.  *
  447.  * ============================================================================
  448.  * Problemas conocidos
  449.  * ============================================================================
  450.  *
  451.  * Se sobreescribe cualquier sistema de elementos que se haya puesto antes.
  452.  *
  453.  * ============================================================================
  454.  * Historial de versiones
  455.  * ============================================================================
  456.  *
  457.  * Version 1.02:
  458.  * - Se epieza a utilizar el ICF-Soft Main Utility.
  459.  * - Se usan múltiples elementos para habilidades y objetos.
  460.  * - Se ha añadido tipos de daño de objeto con resistencias y bonificación.
  461.  * - Se ha añadido el poder usar el elemento menos dañino.
  462.  *
  463.  * Versión 1.01:
  464.  * - Se ha mejorado la fórmula de cálculo.
  465.  * - Se ha añadido la maldición elemental.
  466.  * - Se ha añadido bonificación de elemento/habilidad/arma.
  467.  * - Se ha cambiado el modo en que se usan las etiquetas de las notas.
  468.  *
  469.  * Versión 1.00:
  470.  * - Complemento terminado.
  471.  *
  472.  * ============================================================================
  473.  *
  474.  * Para juegos comerciales y no comerciales.
  475.  * Se debe incluir a ICF-Soft en los créditos.
  476.  * Esta cabecera debe incluirse íntegramente con el plugin.
  477.  *
  478.  * ============================================================================
  479. */
  480. //=============================================================================
  481.  
  482. //=============================================================================
  483. // Parameter Variables
  484. //=============================================================================
  485.  
  486. ICF.Parameters = PluginManager.parameters('ICFSoft_ElementCore');
  487. ICF.Param = ICF.Param || {};
  488.  
  489. ICF.Param.ElementBlend = Number(ICF.Parameters['Elements Blend']);
  490. ICF.Param.ElementAbsorbM = Number(ICF.Parameters['Absorbtion Mode']);
  491.  
  492. ICF.Param.ElementCurseAbsM = Number(ICF.Parameters['Curse Absorb Mode']);
  493. ICF.Param.ElementCurseAbsF = Number(ICF.Parameters['Curse Absorb Factor']);
  494. ICF.Param.ElementCurseAbsMin = Number(ICF.Parameters['Curse Absorb Min']);
  495. ICF.Param.ElementCurseNeutral = Number(ICF.Parameters['Curse Neutral']);
  496. ICF.Param.ElementCurseMode = Number(ICF.Parameters['Curse Normal Mode']);
  497. ICF.Param.ElementCurseFactor = Number(ICF.Parameters['Curse Normal Factor']);
  498.  
  499. if (!Imported.ICFSoft_MainUtility) {throw new Error('This plugin requires ICF-Soft Main Utility plugin to work.\nYou can download it at icfsoft.blogspot.com inside plugins section.');}
  500.  
  501. //=============================================================================
  502. // Constants
  503. //=============================================================================
  504.  
  505. Game_BattlerBase.TRAIT_SK_ELEMENT_RATE    = 15;
  506. Game_BattlerBase.TRAIT_WP_ELEMENT_RATE    = 16;
  507. Game_BattlerBase.TRAIT_ELEMENT_ABSORB     = 17;
  508. Game_BattlerBase.TRAIT_ELEMENT_CURSE      = 18;
  509. Game_BattlerBase.TRAIT_ATTACK_WP_ELEMENT  = 35;
  510. Game_BattlerBase.TRAIT_ATTACK_EL_ENHACE   = 36;
  511.  
  512. //=============================================================================
  513. // DataManager
  514. //=============================================================================
  515.  
  516. ICF.ElementCore.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded;
  517. DataManager.isDatabaseLoaded = function() {
  518.     if (!ICF.ElementCore.DataManager_isDatabaseLoaded.call(this)) return false;
  519.     if (!ICF.ElementCore.Procesed) {
  520.     DataManager.processEleCoreNotetags($dataActors);
  521.     DataManager.processEleCoreNotetags($dataClasses);
  522.     DataManager.processEleCoreNotetags($dataEnemies);
  523.     DataManager.processEleCoreNotetags($dataWeapons);
  524.     DataManager.processEleCoreNotetags($dataArmors);
  525.     DataManager.processEleCoreNotetags($dataStates);
  526.     DataManager.processEleCoreNotetagsB($dataSkills);
  527.     DataManager.processEleCoreNotetagsB($dataItems);
  528.     ICF.ElementCore.Procesed = true;
  529.     }
  530.     return true;
  531. };
  532.  
  533. DataManager.processEleCoreNotetags = function(group) {
  534.     var note1 = /<(?:ELEMENT ABSORB):[ ]*(\d+(?:\s*,\s*\d+)*)>/i;
  535.     var note2 = /<(?:WEAPON ELEMENTS):[ ]*(\d+(?:\s*,\s*\d+)*)>/i;
  536.     var note3 = /<(?:SKILL RESISTANCES):[ ]*(\d+\s+\d+(?:\.\d+)?(?:\s*,\s*\d+\s+\d+(?:\.\d+)?)*)>/i;
  537.     var note4 = /<(?:WEAPON RESISTANCES):[ ]*(\d+\s+\d+(?:\.\d+)?(?:\s*,\s*\d+\s+\d+(?:\.\d+)?)*)>/i;
  538.     var note5 = /<(?:ELEMENT CURSES):[ ]*(\d+(?:\s*,\s*\d+)*)>/i;
  539.     var note6 = /<(?:ELEMENT ENHANCES):[ ]*(\d+\s+\d+(?:\.\d+)?(?:\s*,\s*\d+\s+\d+(?:\.\d+)?)*)>/i;
  540.     var note7 = /<(?:SKILL ENHANCES):[ ]*(\d+\s+\d+(?:\.\d+)?(?:\s*,\s*\d+\s+\d+(?:\.\d+)?)*)>/i;
  541.     var note8 = /<(?:WEAPON ENHANCES):[ ]*(\d+\s+\d+(?:\.\d+)?(?:\s*,\s*\d+\s+\d+(?:\.\d+)?)*)>/i;
  542.     var note9 = /<(?:ITEM DAMAGE RESISTANCES):[ ]*(\d+\s+\d+(?:\.\d+)?(?:\s*,\s*\d+\s+\d+(?:\.\d+)?)*)>/i;
  543.     var note10 = /<(?:ITEM DAMAGE ENHANCES):[ ]*(\d+\s+\d+(?:\.\d+)?(?:\s*,\s*\d+\s+\d+(?:\.\d+)?)*)>/i;
  544.  
  545.     for (var n = 1; n < group.length; n++) {
  546.     var obj = group[n];
  547.     var notedata = obj.note.split(/[\r\n]+/);
  548.  
  549.     for (var i = 0; i < notedata.length; i++) {
  550.         var line = notedata[i];
  551.         if (line.match(note1)) {
  552.             var array = JSON.parse('[' + RegExp.$1.match(/\d+/g) + ']');
  553.             for (var il = 0; il < array.length; il++) {
  554.                 obj.traits.push({code:17, dataId:array[il], value:0});
  555.             }
  556.         } else if (line.match(note2)) {
  557.             var array = JSON.parse('[' + RegExp.$1.match(/\d+/g) + ']');
  558.             for (var il = 0; il < array.length; il++) {
  559.                 obj.traits.push({code:35, dataId:array[il], value:0});
  560.             }
  561.         } else if (line.match(note3)) {
  562.             var array = JSON.parse('[' + RegExp.$1.match(/\d+(?:\.\d+)?/g) + ']');
  563.             for (var il = 0; il < (array.length - 1); il += 2) {
  564.                 obj.traits.push({code:15, dataId:array[il], value:array[il + 1]});
  565.             }
  566.         } else if (line.match(note4)) {
  567.             var array = JSON.parse('[' + RegExp.$1.match(/\d+(?:\.\d+)?/g) + ']');
  568.             for (var il = 0; il < (array.length - 1); il += 2) {
  569.                 obj.traits.push({code:16, dataId:array[il], value:array[il + 1]});
  570.             }
  571.         } else if (line.match(note5)) {
  572.             var array = JSON.parse('[' + RegExp.$1.match(/\d+/g) + ']');
  573.             for (var il = 0; il < array.length; il++) {
  574.                 obj.traits.push({code:18, dataId:array[il], value:0});
  575.             }
  576.         } else if (line.match(note6)) {
  577.             var array = JSON.parse('[' + RegExp.$1.match(/\d+(?:\.\d+)?/g) + ']');
  578.             for (var il = 0; il < (array.length - 1); il += 2) {
  579.                 obj.traits.push({code:36, dataId:array[il], value:array[il + 1]});
  580.             }
  581.         } else if (line.match(note7)) {
  582.             var array = JSON.parse('[' + RegExp.$1.match(/\d+(?:\.\d+)?/g) + ']');
  583.             for (var il = 0; il < (array.length - 1); il += 2) {
  584.                 obj.traits.push({code:36, dataId:array[il] + 2000, value:array[il + 1]});
  585.             }
  586.         } else if (line.match(note8)) {
  587.             var array = JSON.parse('[' + RegExp.$1.match(/\d+(?:\.\d+)?/g) + ']');
  588.             for (var il = 0; il < (array.length - 1); il += 2) {
  589.                 obj.traits.push({code:36, dataId:array[il] + 4000, value:array[il + 1]});
  590.             }
  591.         } else if (line.match(note9)) {
  592.             var array = JSON.parse('[' + RegExp.$1.match(/\d+(?:\.\d+)?/g) + ']');
  593.             for (var il = 0; il < (array.length - 1); il += 2) {
  594.                 obj.traits.push({code:15, dataId:array[il] + 2000, value:array[il + 1]});
  595.             }
  596.         } else if (line.match(note10)) {
  597.             var array = JSON.parse('[' + RegExp.$1.match(/\d+(?:\.\d+)?/g) + ']');
  598.             for (var il = 0; il < (array.length - 1); il += 2) {
  599.                 obj.traits.push({code:36, dataId:array[il] + 6000, value:array[il + 1]});
  600.             }
  601.         }
  602.     }
  603.     }
  604. };
  605.  
  606. DataManager.processEleCoreNotetagsB = function(group) {
  607.     var note1 = /<(?:ELEMENTS):[ ]*(\d+(?:\s*,\s*\d+)*)>/i;
  608.     var note2 = /<(?:ITEM DAMAGE TYPE):[ ]*(\d+)>/i;
  609.  
  610.     for (var n = 1; n < group.length; n++) {
  611.     var obj = group[n];
  612.     var notedata = obj.note.split(/[\r\n]+/);
  613.  
  614.     obj.damage.elements = (obj.damage.elementId < 0)? [] : [obj.damage.elementId];
  615.     obj.damage.itype = 0;
  616.  
  617.     for (var i = 0; i < notedata.length; i++) {
  618.         var line = notedata[i];
  619.         if (line.match(note1)) {
  620.             var array = JSON.parse('[' + RegExp.$1.match(/\d+/g) + ']');
  621.             obj.damage.elements = obj.damage.elements.concat(array);
  622.         } else if (line.match(note2)) {
  623.             obj.damage.itype = Number(RegExp.$1);
  624.         }
  625.     }
  626.     }
  627. };
  628.  
  629. //=============================================================================
  630. // Game_BattlerBase
  631. //=============================================================================
  632.  
  633. Game_BattlerBase.prototype.elementEnhace = function(elementId) {
  634.     return this.traitsPi(Game_BattlerBase.TRAIT_ATTACK_EL_ENHACE, elementId);
  635. };
  636.  
  637. Game_BattlerBase.prototype.skillEnhace = function(stypeId) {
  638.     return this.traitsPi(Game_BattlerBase.TRAIT_ATTACK_EL_ENHACE, stypeId + 2000);
  639. };
  640.  
  641. Game_BattlerBase.prototype.weaponEnhace = function(wtypeId) {
  642.     return this.traitsPi(Game_BattlerBase.TRAIT_ATTACK_EL_ENHACE, wtypeId + 4000);
  643. };
  644.  
  645. Game_BattlerBase.prototype.atItemEnhace = function(itypeId) {
  646.     return this.traitsPi(Game_BattlerBase.TRAIT_ATTACK_EL_ENHACE, itypeId + 6000);
  647. };
  648.  
  649. Game_BattlerBase.prototype.elementAbsorb = function(elementId) {
  650.     return (this.traitsWithId(Game_BattlerBase.TRAIT_ELEMENT_ABSORB, elementId).length > 0);
  651. };
  652.  
  653. Game_BattlerBase.prototype.elementCurse = function(elementId) {
  654.     return (this.traitsWithId(Game_BattlerBase.TRAIT_ELEMENT_CURSE, elementId).length > 0);
  655. };
  656.  
  657. ICF.ElementCore.Game_BtlrBase_elementRate = Game_BattlerBase.prototype.elementRate;
  658. Game_BattlerBase.prototype.elementRate = function(elementId) {
  659.     var result = ICF.ElementCore.Game_BtlrBase_elementRate.call(this, elementId);
  660.     if (this.elementAbsorb(elementId)) {
  661.     if (ICF.Param.ElementAbsorbM == 0) {result = Math.min(result - 2.0, -0.01);}
  662.     else {result *= -1}
  663.     }
  664.     if (this.elementCurse(elementId)) {
  665.     if (result < 0) {
  666.         if (ICF.Param.ElementCurseAbsM == 0) return ICF.Param.ElementCurseAbsF;
  667.         else if (ICF.Param.ElementCurseAbsM == 1) {
  668.             result += ICF.Param.ElementCurseAbsF;
  669.             return result.clamp(ICF.Param.ElementCurseAbsMin, ICF.Param.ElementCurseNeutral);
  670.         } else {
  671.             result *= ICF.Param.ElementCurseAbsF;
  672.             return result.clamp(ICF.Param.ElementCurseAbsMin, ICF.Param.ElementCurseNeutral);
  673.         }
  674.     } else if (result == 0) {
  675.         return ICF.Param.ElementCurseNeutral;
  676.     } else {
  677.         if (ICF.Param.ElementCurseMode == 0) return Math.max(result, ICF.Param.ElementCurseFactor);
  678.         else if (ICF.Param.ElementCurseMode == 1) {
  679.             result += ICF.Param.ElementCurseFactor;
  680.             return Math.max(result, ICF.Param.ElementCurseNeutral);
  681.         } else {
  682.             result *= ICF.Param.ElementCurseFactor;
  683.             return Math.max(result, ICF.Param.ElementCurseNeutral);
  684.         }
  685.     }
  686.     }
  687.     return result;
  688. };
  689.  
  690. Game_BattlerBase.prototype.elSkillRate = function(stypeId) {
  691.     return this.traitsPi(Game_BattlerBase.TRAIT_SK_ELEMENT_RATE, stypeId);
  692. };
  693.  
  694. Game_BattlerBase.prototype.elItemRate = function(itypeId) {
  695.     return this.traitsPi(Game_BattlerBase.TRAIT_SK_ELEMENT_RATE + 2000, itypeId);
  696. };
  697.  
  698. Game_BattlerBase.prototype.elWeaponRate = function(wtypeId) {
  699.     return this.traitsPi(Game_BattlerBase.TRAIT_WP_ELEMENT_RATE, wtypeId);
  700. };
  701.  
  702. Game_BattlerBase.prototype.wpAttackElements = function() {
  703.     var wpns = this.traitsSet(Game_BattlerBase.TRAIT_ATTACK_WP_ELEMENT);
  704.     wpns.removeRepeated();
  705.     return wpns;
  706. };
  707.  
  708. Game_BattlerBase.prototype.ADVelementRate = function(elementId, subject) {
  709.     return this.elementRate(elementId) * (subject == undefined)? 1 : subject.elementEnhace(elementId);
  710. };
  711.  
  712. Game_BattlerBase.prototype.ADVelSkillRate = function(stypeId, subject) {
  713.     return this.elSkillRate(stypeId) * (subject == undefined)? 1 : subject.skillEnhace(stypeId);
  714. };
  715.  
  716. Game_BattlerBase.prototype.ADVelItemRate = function(itypeId, subject) {
  717.     return this.elItemRate(itypeId) * (subject == undefined)? 1 : subject.atItemEnhace(itypeId);
  718. };
  719.  
  720. Game_BattlerBase.prototype.ADVelWeaponRate = function(wtypeId, subject) {
  721.     return this.elWeaponRate(wtypeId) * (subject == undefined)? 1 : subject.weaponEnhace(wtypeId);
  722. };
  723.  
  724. //=============================================================================
  725. // Game_Actor
  726. //=============================================================================
  727.  
  728. Game_Actor.prototype.wpAttackElements = function() {
  729.     var wpns = [];
  730.     if (this.weapons().length > 0) {
  731.     wpns = this.weapons().reduce(function(r, obj) {
  732.         return r.concat([obj.wtypeId]);
  733.     }, []);
  734.     wpns.removeRepeated();
  735.     return wpns;
  736.     }
  737.  
  738.     wpns = Game_BattlerBase.prototype.wpAttackElements.call(this);
  739.     if (wpns.length == 0) wpns[0] = 0;
  740.  
  741.     return wpns;
  742. };
  743.  
  744. //=============================================================================
  745. // Game_Action
  746. //=============================================================================
  747.  
  748. Game_Action.prototype.elementsMaxRate = function(target, elements, subject) {
  749.     if (elements.length > 0) {
  750.         return Math.max.apply(null, elements.map(function(elementId) {
  751.             return target.ADVelementRate(elementId, subject);
  752.         }, this));
  753.     } else {
  754.         return 1;
  755.     }
  756. };
  757.  
  758. Game_Action.prototype.elementsMinRate = function(target, elements, subject) {
  759.     if (elements.length > 0) {
  760.         return Math.min.apply(null, elements.map(function(elementId) {
  761.             return target.ADVelementRate(elementId, subject);
  762.         }, this));
  763.     } else {
  764.         return 1;
  765.     }
  766. };
  767.  
  768. Game_Action.prototype.elementsAverageRate = function(target, elements, subject) {
  769.     if (elements.length > 0) {
  770.         return elements.reduce(function(r, element) {
  771.             return r + target.ADVelementRate(element, subject);
  772.         }, 0) / elements.length;
  773.     } else {
  774.         return 1;
  775.     }
  776. };
  777.  
  778. Game_Action.prototype.wpElementsMaxRate = function(target, wpelements, subject) {
  779.     if (wpelements.length > 0) {
  780.         return Math.max.apply(null, wpelements.map(function(wpelementId) {
  781.             return target.ADVelWeaponRate(wpelementId, subject);
  782.         }, this));
  783.     } else {
  784.         return 1;
  785.     }
  786. };
  787.  
  788. Game_Action.prototype.wpElementsMinRate = function(target, wpelements, subject) {
  789.     if (wpelements.length > 0) {
  790.         return Math.min.apply(null, wpelements.map(function(wpelementId) {
  791.             return target.ADVelWeaponRate(wpelementId, subject);
  792.         }, this));
  793.     } else {
  794.         return 1;
  795.     }
  796. };
  797.  
  798. Game_Action.prototype.wpElementsAverageRate = function(target, wpelements, subject) {
  799.     if (wpelements.length > 0) {
  800.         return wpelements.reduce(function(r, wpelement) {
  801.             return r + target.ADVelWeaponRate(wpelement, subject);
  802.         }, 0) / wpelements.length;
  803.     } else {
  804.         return 1;
  805.     }
  806. };
  807.  
  808. Game_Action.prototype.calcWeaponElementRate = function(target) {
  809.     var rate = 1;
  810.     var wpns = this.subject().wpAttackElements();
  811.     if (wpns.length > 0) {
  812.     if (ICF.Param.ElementBlend == 0) {
  813.         rate = this.wpElementsAverageRate(target, wpns, this.subject());
  814.     } else if (ICF.Param.ElementBlend == 3) {
  815.         rate = this.wpElementsMinRate(target, wpns, this.subject());
  816.     } else {
  817.         rate = this.wpElementsMaxRate(target, wpns, this.subject());
  818.     }
  819.     }
  820.     return rate;
  821. };
  822.  
  823. Game_Action.prototype.calcElementRate = function(target) {
  824.     var rate = 1;
  825.     var rate2 = 0;
  826.     var elements = this.item().damage.elements;
  827.  
  828.     if (this.item().damage.elementId < 0) {
  829.     elements = elements.concat(this.subject().attackElements());
  830.     }
  831.  
  832.     elements.removeRepeated();
  833.  
  834.     if (ICF.Param.ElementBlend == 0) {
  835.     rate = this.elementsAverageRate(target, elements, this.subject());
  836.     } else if (ICF.Param.ElementBlend == 3) {
  837.     rate = this.elementsMinRate(target, elements, this.subject());
  838.     } else {
  839.     rate = this.elementsMaxRate(target, elements, this.subject());
  840.     rate2 = this.elementsMinRate(target, elements, this.subject());
  841.     if (ICF.Param.ElementBlend == 2 && rate2 < 0) rate = rate2;
  842.     }
  843.  
  844.     if (this.isSkill()) {
  845.     if ((this.item().stypeId > 0)&&(this.isMagical())) {
  846.         rate2 = target.ADVelSkillRate(this.item().stypeId, this.subject());
  847.         if ((rate < 0)||(rate2 < 1)) {rate = rate * rate2;}
  848.         else {rate += rate2 - 1;}
  849.     }
  850.     if ((this.isPhysical())||(this.item().damage.elementId < 0)) {
  851.         rate2 = this.calcWeaponElementRate(target) + rate;
  852.         if (rate2 > 2) {rate = rate2 - 1;}
  853.         else {rate = rate2 / 2;}
  854.     }
  855.     if ((this.item().stypeId > 0)&&(!this.isMagical())) {
  856.         rate2 = target.ADVelSkillRate(this.item().stypeId, this.subject());
  857.         if ((rate < 0)||(rate2 < 1)) {rate = rate * rate2;}
  858.         else {rate += rate2 - 1;}
  859.     }
  860.     } else if (this.isItem()) {
  861.     if ((this.item().damage.itype > 0)&&(this.isMagical())) {
  862.         rate2 = target.ADVelItemRate(this.item().damage.itype, this.subject());
  863.         if ((rate < 0)||(rate2 < 1)) {rate = rate * rate2;}
  864.         else {rate += rate2 - 1;}
  865.     }
  866.     if ((this.isPhysical())||(this.item().damage.elementId < 0)) {
  867.         rate2 = this.calcWeaponElementRate(target) + rate;
  868.         if (rate2 > 2) {rate = rate2 - 1;}
  869.         else {rate = rate2 / 2;}
  870.     }
  871.     if ((this.item().damage.itype > 0)&&(!this.isMagical())) {
  872.         rate2 = target.ADVelItemRate(this.item().damage.itype, this.subject());
  873.         if ((rate < 0)||(rate2 < 1)) {rate = rate * rate2;}
  874.         else {rate += rate2 - 1;}
  875.     }
  876.     }
  877.  
  878.     return rate;
  879. };
  880.  
  881. //=============================================================================
  882. // Game_Item
  883. //=============================================================================
  884.  
  885. Game_Item.prototype.absorbingElements = function() {
  886.     return this.traitDataTypes(17);
  887. };
  888.  
  889. Game_Item.prototype.cursingElements = function() {
  890.     return this.traitDataTypes(18);
  891. };
  892.  
  893. Game_Item.prototype.resistingElements = function() {
  894.     return this.traitDataTypes(11);
  895. };
  896.  
  897. Game_Item.prototype.resistingSkills = function() {
  898.     return this.traitDataTypesOffset(15, 0, 1999);
  899. };
  900.  
  901. Game_Item.prototype.resistingWeapons = function() {
  902.     return this.traitDataTypes(16);
  903. };
  904.  
  905. Game_Item.prototype.resistingItemDamages = function() {
  906.     return this.traitDataTypesOffset(15, 2000, 3999);
  907. };
  908.  
  909. Game_Item.prototype.attackingElements = function() {
  910.     return this.traitDataTypes(35);
  911. };
  912.  
  913. Game_Item.prototype.enhaceTypes = function() {
  914.     return this.traitDataTypes(36);
  915. };
  916.  
  917. Game_Item.prototype.elementEnhaceTypes = function() {
  918.     return this.traitDataTypesOffset(36, 0, 1999);
  919. };
  920.  
  921. Game_Item.prototype.skillEnhaceTypes = function() {
  922.     return this.traitDataTypesOffset(36, 2000, 3999);
  923. };
  924.  
  925. Game_Item.prototype.weaponEnhaceTypes = function() {
  926.     return this.traitDataTypesOffset(36, 4000, 5999);
  927. };
  928.  
  929. Game_Item.prototype.itemDamageEnhaceTypes = function() {
  930.     return this.traitDataTypesOffset(36, 6000, 7999);
  931. };
  932.  
  933. Game_Item.prototype.elements = function() {
  934.     if (this.isSkill() || this.isItem()) return this.object().damage.elements;
  935.     if (this.isWeapon() || this.isArmor()) return this.attackingElements();
  936.     return [];
  937. };
  938.  
  939. //=============================================================================
  940. // End of File
  941. //=============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement