Advertisement
ICF-Soft

ICF-Soft Element Core 1.03b RPG Maker MV

Oct 15th, 2016
128
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 = 103; // 1.03
  13.  
  14. //=============================================================================
  15.  /*:
  16.  * @plugindesc v1.03b 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.  * Lunatic Mode
  159.  * ============================================================================
  160.  *
  161.  * You can attach custom reactions to actors, classes, weapons, armors,
  162.  * enemies and states.
  163.  *
  164.  * <ELEMENT REACT: 2>
  165.  * this.gainMp(20);
  166.  * this.gainTp(15);
  167.  * </ELEMENT REACT>
  168.  *
  169.  * When an actor/enemy is hit with specified element runs the code of all
  170.  * pieces.
  171.  *
  172.  * <SKILL REACT: X>
  173.  * <WEAPON REACT: X>
  174.  * <ITEM REACT: X>
  175.  
  176.  * When an actor/enemy is the target of specified skill/weapon/item type
  177.  * runs the code of all pieces even if evaded.
  178.  *
  179.  * Some variables are passed to customize reaction:
  180.  *   - subject: the subject of the action.
  181.  *   - item: the object used in the action. Can be an item or a skill.
  182.  *   - isSkill: check if is an skill.
  183.  *
  184.  * ============================================================================
  185.  * Params
  186.  * ============================================================================
  187.  *
  188.  * Elements Blend:
  189.  *
  190.  *  Behavior when more than one element are used.
  191.  *
  192.  *  0 - Average:      Calcs entire element average.
  193.  *  1 - Normal:       Strongest element takes priority.
  194.  *  2 - Absorb first: If there is an absorbing element will take priority.
  195.  *  3 - Minimun:      Weakest element takes priority.
  196.  *
  197.  * Absorbtion Mode:
  198.  *
  199.  *  How element absorbtion is treated changes the way players must choose
  200.  *  equipment.
  201.  *
  202.  *  0 - Absolute:     Element defense increase absorbtion.
  203.  *  1 - Relative:     Element defense reduces absorbtion same way as damage.
  204.  *
  205.  * There are some parameters for element curse.
  206.  *
  207.  * Curse Absorb Mode / Curse Normal Mode:
  208.  *  
  209.  *  When rate is different than cero, either for absorbtion, resistance,
  210.  *  normal or weak, it needs a calculation based on actual rate.
  211.  *  You can use a different mode for negative and positive values.
  212.  *
  213.  *  0 - Fixed:        Rate will be substituyed with factor.
  214.  *  1 - Additive:     Will increase rate with factor.
  215.  *  2 - Relative:     Will multiply rate with factor.
  216.  *
  217.  * Curse Absorb Factor / Curse Normal Factor:
  218.  *  
  219.  *  The factor that will be used to calc rate.
  220.  *
  221.  * Curse Absorb Min:
  222.  *
  223.  *  A min rate for absorb.
  224.  *
  225.  * Curse Neutral:
  226.  *
  227.  *  Neutral is when rate is equal to cero, inmunity.
  228.  *  This is a fixed rate so it needs to change to a another fixed rate.
  229.  *  It's also used as max rate when absorb and min rate for else.
  230.  *
  231.  * ============================================================================
  232.  * Incompatibilities
  233.  * ============================================================================
  234.  *
  235.  * There's no known incompatible plugins yet.
  236.  *
  237.  * ============================================================================
  238.  * Known isues
  239.  * ============================================================================
  240.  *
  241.  * It overrides every other element system that comes after.
  242.  *
  243.  * ============================================================================
  244.  * Changelog
  245.  * ============================================================================
  246.  *
  247.  * Version 1.03:
  248.  * - Added element/skill/weapon/item reaction.
  249.  *
  250.  * Version 1.02:
  251.  * - Use of ICF-Soft Main Utility.
  252.  * - Added multiple elements to skill and items.
  253.  * - Added item damage type with resistance and enhace.
  254.  * - Added lowest element rate.
  255.  *
  256.  * Version 1.01:
  257.  * - Improved formula.
  258.  * - Added element curse.
  259.  * - Added element/skill/weapon enhace.
  260.  * - Changed how rates must be used inside notetags.
  261.  *
  262.  * Version 1.00:
  263.  * - Finished plugin!
  264.  *
  265.  * ============================================================================
  266.  *
  267.  * For commercial and non-commercial games.
  268.  * Credit to ICF-Soft.
  269.  * This entire header must be included with plugin.
  270.  *
  271.  * ============================================================================
  272. */
  273. //=============================================================================
  274.  /*:es
  275.  * @plugindesc v1.03b Este complemento añade un sistema de elementos
  276.  * avanzado.
  277.  * @author ICF-Soft [http://icfsoft.blogspot.com.es/]
  278.  *
  279.  * @param Elements Blend
  280.  * @desc Qué hacer cuando se usa más de un elemento.
  281.  * 0 - Media  1 - Normal  2 - Absorbción primero  3 - Mínimo
  282.  * @default 2
  283.  *
  284.  * @param Absorbtion Mode
  285.  * @desc El modo en el que se absorben los elementos.
  286.  * 0 - Absoluto  1 - Relativo
  287.  * @default 1
  288.  *
  289.  * @param Curse Absorb Mode
  290.  * @desc Como tratar la maldición elemental ante la absorción.
  291.  * 0 - Fijo  1 - Aditivo  2 - Relativo
  292.  * @default 2
  293.  *
  294.  * @param Curse Absorb Factor
  295.  * @desc Factor a usar para calcular el daño.
  296.  * @default -0.1
  297.  *
  298.  * @param Curse Absorb Min
  299.  * @desc Valor mínimo.
  300.  * @default 0.1
  301.  *
  302.  * @param Curse Neutral
  303.  * @desc Valor fijo cuando se es inmune al elemento.
  304.  * Además valor máximo en la absorción y mínimo en el resto.
  305.  * @default 2
  306.  *
  307.  * @param Curse Normal Mode
  308.  * @desc Como tratar la maldición elemental normalmente.
  309.  * 0 - Fijo  1 - Aditivo  2 - Relativo
  310.  * @default 1
  311.  *
  312.  * @param Curse Normal Factor
  313.  * @desc Factor a usar para calcular el daño.
  314.  * @default 1
  315.  *
  316.  * @help
  317.  * ============================================================================
  318.  * Introducción
  319.  * ============================================================================
  320.  *
  321.  * El sistema de elementos que viene predeterminado en RPG Maker MV es limitado
  322.  * y no permite la absorbción.
  323.  *
  324.  * Con este complemento puedes usar no sólo elementos sino también tipos de
  325.  * habilidades, armas y objetos además de la absorbción de elementos y
  326.  * la bonificación de elementos, habilidades, armas y objetos.
  327.  * Además puedes usar varios elementos en habilidades y objetos.
  328.  *
  329.  * Esta nueva fórmula da importancia a más opciones y da profundidad extra
  330.  * en las tácticas.
  331.  *
  332.  * Ahora puedes utilizar resistencia a la magia, antibalas y más cosas similares.
  333.  *
  334.  * La nueva maldición elemental permite volver debilidad cualquier elemento
  335.  * incluso cuando es absorbido.
  336.  *
  337.  * Puedes añadir tipos de objetos tales como piedra, piedra mágica, granada,
  338.  * daro y similares con sus características de resistencia y mejora.
  339.  *
  340.  * ============================================================================
  341.  * Uso
  342.  * ============================================================================
  343.  *
  344.  * Funciona con etiquetas en las notas. Pueden usarse en actores, clases,
  345.  * enemigos, armas, armaduras y estados alterados.
  346.  *
  347.  * <ELEMENT ABSORB: x>
  348.  * <ELEMENT ABSORB: x, x>
  349.  *
  350.  *  - Añade todos los elementos que puede absorber en una linea.
  351.  *
  352.  * <ELEMENT CURSES: x>
  353.  * <ELEMENT CURSES: x, x>
  354.  *  
  355.  *  - Añade todas las maldiciones elementales en una linea.
  356.  *
  357.  * <WEAPON ELEMENTS: x>
  358.  * <WEAPON ELEMENTS: x, x>
  359.  *
  360.  *  - Añade todos los tipos de arma que se utilizan en una linea.
  361.  *    Útil para enemigos y los actores que no lleven armas.
  362.  *    0 son los puños. Se utiliza cuando un actor necesita un tipo de arma
  363.  *    pero no está disponible ninguno.
  364.  *
  365.  * <WEAPON RESISTANCES: x rate>
  366.  * <WEAPON RESISTANCES: x rate, x rate>
  367.  *
  368.  *  - Añade todas las resistencias a las armas en una linea.
  369.  *    rate: puede ser decimal, 1 es normal, 0.5 es la mitad,
  370.  *          2 es el doble, etc...
  371.  *
  372.  * <SKILL RESISTANCES: x rate>
  373.  * <SKILL RESISTANCES: x rate, x rate>
  374.  *
  375.  *  - Añade todas las resistencias a las habilidades en una linea.
  376.  *    rate: puede ser decimal, 1 es normal, 0.5 es la mitad,
  377.  *          2 es el doble, etc...
  378.  *
  379.  * <ITEM DAMAGE RESISTANCES: x rate>
  380.  * <ITEM DAMAGE RESISTANCES: x rate, x rate>
  381.  *
  382.  *  - Añade todas las resistencias a objetos en una linea.
  383.  *    rate: puede ser decimal, 1 es normal, 0.5 es la mitad,
  384.  *          2 es el doble, etc...
  385.  *
  386.  * La resistencia a las habilidades se activa en las habilidades que incluyan
  387.  * categoría.
  388.  *
  389.  * La resistencia a las armas se activa en las habilidades físicas y las que
  390.  * utilizan arma.
  391.  *
  392.  * La resistencia a los objetos se activa en los objetos que incluyan un tipo
  393.  * de daño (ver más abajo).
  394.  *
  395.  * <ELEMENT ENHANCES: x rate>
  396.  * <ELEMENT ENHANCES: x rate, x rate>
  397.  * <SKILL ENHANCES: x rate>
  398.  * <SKILL ENHANCES: x rate, x rate>
  399.  * <WEAPON ENHANCES: x rate>
  400.  * <WEAPON ENHANCES: x rate, x rate>
  401.  * <ITEM DAMAGE ENHANCES: x rate>
  402.  * <ITEM DAMAGE ENHANCES: x rate, x rate>
  403.  *
  404.  *  - Añade todas las bonificaciones de elementos, habilidades, armas
  405.  *    y objetos necesarias en una linea.
  406.  *    rate: puede ser decimal, 1 es normal, 0.5 es la mitad,
  407.  *          2 es el doble, etc...
  408.  *
  409.  *
  410.  * Nuevas etiquetas para habilidades y objetos:
  411.  *
  412.  * <ELEMENTS: x>
  413.  * <ELEMENTS: x, x>
  414.  *
  415.  *  - Añade todos los elementos que la habilidad u objeto va a usar en una sola
  416.  *    linea.
  417.  *
  418.  * Y para objetos solo:
  419.  *
  420.  * <ITEM DAMAGE TYPE: x>
  421.  *
  422.  *  - Añade el tipo de daño específico del objeto.
  423.  *
  424.  * ============================================================================
  425.  * Modo Lunático
  426.  * ============================================================================
  427.  *
  428.  * Puedes añadir reacciones personalizadas a personajes, clases, armas,
  429.  * armaduras, enemigos y estados alterados.
  430.  *
  431.  * <ELEMENT REACT: 2>
  432.  * this.gainMp(20);
  433.  * this.gainTp(15);
  434.  * </ELEMENT REACT>
  435.  *
  436.  * Cuando un personaje o enemigo es afectado por el elemento específico se
  437.  * ejecutará el código de todas las piezas.
  438.  *
  439.  * <SKILL REACT: X>
  440.  * <WEAPON REACT: X>
  441.  * <ITEM REACT: X>
  442.  
  443.  * Cuando un personaje o enemigo es afectado por el tipo de habilidad, arma
  444.  * o objeto específico se ejecutará el código de todas las piezas aunque se
  445.  * evada.
  446.  *
  447.  * Se puede acceder a las siguientes variables en la reacción:
  448.  *   - subject: el sujeto de la acción.
  449.  *   - item: el objeto usado en la acción. Puede ser un objeto o habilidad.
  450.  *   - isSkill: comprueba si se trata de una habilidad.
  451.  *
  452.  * ============================================================================
  453.  * Parámetros
  454.  * ============================================================================
  455.  *
  456.  * Elements Blend:
  457.  *
  458.  *  El comportamiento cuando se usan más de un elemento.
  459.  *
  460.  *  0 - Media:             Calcula la media.
  461.  *  1 - Normal:            El elemento más dañino toma prioridad.
  462.  *  2 - Absorción primero: Si un elemento es absorbible tendrá prioridad.
  463.  *  3 - Mínimo:            El elemento menos dañino toma prioridad.
  464.  *
  465.  * Absorbtion Mode:
  466.  *
  467.  *  El modo en el que los elementos son absorbidos cambia el modo en el que
  468.  *  el jugador debe seleccionar el equipamiento.
  469.  *
  470.  *  0 - Absoluto:     La defensa elemental incrementa la absorbción.
  471.  *  1 - Relativo:     La defensa elemental reduce tanto la absorbción
  472.  *                    como el daño.
  473.  *
  474.  * Para la maldición elemental se usan los siguientes parámetros:
  475.  *
  476.  * Curse Absorb Mode / Curse Normal Mode:
  477.  *  
  478.  *  Para daño negativo (absorción) y daño positivo (normal, débil o resistente)
  479.  *  se usan calculos distintos basado en el valor actual y un factor.
  480.  *
  481.  *  0 - Fijo:         El factor será el nuevo valor.
  482.  *  1 - Aditivo:      Al valor se le añade el factor.
  483.  *  2 - Relativo:     El valor se multiplica por el factor.
  484.  *
  485.  * Curse Absorb Factor / Curse Normal Factor:
  486.  *  
  487.  *  El factor usado para calcular.
  488.  *
  489.  * Curse Absorb Min:
  490.  *
  491.  *  El valor mínimo para el elemento absorbido.
  492.  *
  493.  * Curse Neutral:
  494.  *
  495.  *  El valor que tomará cuando se es inmune. Al ser fijo se sustituye por
  496.  *  otro valor fijo.
  497.  *  Además se usa como término medio entre absorción y daño.
  498.  *
  499.  * ============================================================================
  500.  * Incompatibilidades
  501.  * ============================================================================
  502.  *
  503.  * No se conocen complementos que sean incompatibles hasta la fecha.
  504.  *
  505.  * ============================================================================
  506.  * Problemas conocidos
  507.  * ============================================================================
  508.  *
  509.  * Se sobreescribe cualquier sistema de elementos que se haya puesto antes.
  510.  *
  511.  * ============================================================================
  512.  * Historial de versiones
  513.  * ============================================================================
  514.  *
  515.  * Version 1.03:
  516.  * - Se ha añadido la reacción a elementos y tipos de armas, habilidades
  517.  *   y objetos.
  518.  *
  519.  * Version 1.02:
  520.  * - Se empieza a utilizar el ICF-Soft Main Utility.
  521.  * - Se usan múltiples elementos para habilidades y objetos.
  522.  * - Se ha añadido tipos de daño de objeto con resistencias y bonificación.
  523.  * - Se ha añadido el poder usar el elemento menos dañino.
  524.  *
  525.  * Versión 1.01:
  526.  * - Se ha mejorado la fórmula de cálculo.
  527.  * - Se ha añadido la maldición elemental.
  528.  * - Se ha añadido bonificación de elemento/habilidad/arma.
  529.  * - Se ha cambiado el modo en que se usan las etiquetas de las notas.
  530.  *
  531.  * Versión 1.00:
  532.  * - Complemento terminado.
  533.  *
  534.  * ============================================================================
  535.  *
  536.  * Para juegos comerciales y no comerciales.
  537.  * Se debe incluir a ICF-Soft en los créditos.
  538.  * Esta cabecera debe incluirse íntegramente con el plugin.
  539.  *
  540.  * ============================================================================
  541. */
  542. //=============================================================================
  543.  
  544. //=============================================================================
  545. // Parameter Variables
  546. //=============================================================================
  547.  
  548. ICF.Parameters = PluginManager.parameters('ICFSoft_ElementCore');
  549. ICF.Param = ICF.Param || {};
  550.  
  551. ICF.Param.ElementBlend = Number(ICF.Parameters['Elements Blend']);
  552. ICF.Param.ElementAbsorbM = Number(ICF.Parameters['Absorbtion Mode']);
  553.  
  554. ICF.Param.ElementCurseAbsM = Number(ICF.Parameters['Curse Absorb Mode']);
  555. ICF.Param.ElementCurseAbsF = Number(ICF.Parameters['Curse Absorb Factor']);
  556. ICF.Param.ElementCurseAbsMin = Number(ICF.Parameters['Curse Absorb Min']);
  557. ICF.Param.ElementCurseNeutral = Number(ICF.Parameters['Curse Neutral']);
  558. ICF.Param.ElementCurseMode = Number(ICF.Parameters['Curse Normal Mode']);
  559. ICF.Param.ElementCurseFactor = Number(ICF.Parameters['Curse Normal Factor']);
  560.  
  561. if (!Imported.ICFSoft_MainUtility) {throw new Error('This plugin requires ICF-Soft Main Utility plugin version 1.01 to work.\nYou can download it at icfsoft.blogspot.com inside plugins section.');}
  562. if (ICF.MainUtility.Version < 101) {throw new Error('This plugin requires ICF-Soft Main Utility plugin version 1.01 to work.\nYou can download it at icfsoft.blogspot.com inside plugins section.');}
  563.  
  564. //=============================================================================
  565. // Constants
  566. //=============================================================================
  567.  
  568. Game_BattlerBase.TRAIT_SK_ELEMENT_RATE    = 15;
  569. Game_BattlerBase.TRAIT_WP_ELEMENT_RATE    = 16;
  570. Game_BattlerBase.TRAIT_ELEMENT_ABSORB     = 17;
  571. Game_BattlerBase.TRAIT_ELEMENT_CURSE      = 18;
  572. Game_BattlerBase.TRAIT_ATTACK_WP_ELEMENT  = 35;
  573. Game_BattlerBase.TRAIT_ATTACK_EL_ENHACE   = 36;
  574.  
  575. //=============================================================================
  576. // DataManager
  577. //=============================================================================
  578.  
  579. ICF.ElementCore.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded;
  580. DataManager.isDatabaseLoaded = function() {
  581.     if (!ICF.ElementCore.DataManager_isDatabaseLoaded.call(this)) return false;
  582.     if (!ICF.ElementCore.Procesed) {
  583.     DataManager.processEleCoreNotetags($dataActors);
  584.     DataManager.processEleCoreNotetags($dataClasses);
  585.     DataManager.processEleCoreNotetags($dataEnemies);
  586.     DataManager.processEleCoreNotetags($dataWeapons);
  587.     DataManager.processEleCoreNotetags($dataArmors);
  588.     DataManager.processEleCoreNotetags($dataStates);
  589.     DataManager.processEleCoreNotetagsB($dataSkills);
  590.     DataManager.processEleCoreNotetagsB($dataItems);
  591.     ICF.ElementCore.Procesed = true;
  592.     }
  593.     return true;
  594. };
  595.  
  596. DataManager.processEleCoreNotetags = function(group) {
  597.     var note1 = /<(?:ELEMENT ABSORB):[ ]*(\d+(?:\s*,\s*\d+)*)>/i;
  598.     var note2 = /<(?:WEAPON ELEMENTS):[ ]*(\d+(?:\s*,\s*\d+)*)>/i;
  599.     var note3 = /<(?:SKILL RESISTANCES):[ ]*(\d+\s+\d+(?:\.\d+)?(?:\s*,\s*\d+\s+\d+(?:\.\d+)?)*)>/i;
  600.     var note4 = /<(?:WEAPON RESISTANCES):[ ]*(\d+\s+\d+(?:\.\d+)?(?:\s*,\s*\d+\s+\d+(?:\.\d+)?)*)>/i;
  601.     var note5 = /<(?:ELEMENT CURSES):[ ]*(\d+(?:\s*,\s*\d+)*)>/i;
  602.     var note6 = /<(?:ELEMENT ENHANCES):[ ]*(\d+\s+\d+(?:\.\d+)?(?:\s*,\s*\d+\s+\d+(?:\.\d+)?)*)>/i;
  603.     var note7 = /<(?:SKILL ENHANCES):[ ]*(\d+\s+\d+(?:\.\d+)?(?:\s*,\s*\d+\s+\d+(?:\.\d+)?)*)>/i;
  604.     var note8 = /<(?:WEAPON ENHANCES):[ ]*(\d+\s+\d+(?:\.\d+)?(?:\s*,\s*\d+\s+\d+(?:\.\d+)?)*)>/i;
  605.     var note9 = /<(?:ITEM DAMAGE RESISTANCES):[ ]*(\d+\s+\d+(?:\.\d+)?(?:\s*,\s*\d+\s+\d+(?:\.\d+)?)*)>/i;
  606.     var note10 = /<(?:ITEM DAMAGE ENHANCES):[ ]*(\d+\s+\d+(?:\.\d+)?(?:\s*,\s*\d+\s+\d+(?:\.\d+)?)*)>/i;
  607.     var note11 = /<((?:ELEMENT)|(?:SKILL)|(?:WEAPON)|(?:ITEM)) (?:REACT):[ ]*(\d+)[ ]*>/i;
  608.     var note12 = /<\/((?:ELEMENT)|(?:SKILL)|(?:WEAPON)|(?:ITEM)) (?:REACT)>/i;
  609.  
  610.     var flag1 = false;
  611.     var key = '';
  612.  
  613.     for (var n = 1; n < group.length; n++) {
  614.     var obj = group[n];
  615.     var notedata = obj.note.split(/[\r\n]+/);
  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.             for (var il = 0; il < array.length; il++) {
  622.                 obj.traits.push({code:17, dataId:array[il], value:0});
  623.             }
  624.         } else if (line.match(note2)) {
  625.             var array = JSON.parse('[' + RegExp.$1.match(/\d+/g) + ']');
  626.             for (var il = 0; il < array.length; il++) {
  627.                 obj.traits.push({code:35, dataId:array[il], value:0});
  628.             }
  629.         } else if (line.match(note3)) {
  630.             var array = JSON.parse('[' + RegExp.$1.match(/\d+(?:\.\d+)?/g) + ']');
  631.             for (var il = 0; il < (array.length - 1); il += 2) {
  632.                 obj.traits.push({code:15, dataId:array[il], value:array[il + 1]});
  633.             }
  634.         } else if (line.match(note4)) {
  635.             var array = JSON.parse('[' + RegExp.$1.match(/\d+(?:\.\d+)?/g) + ']');
  636.             for (var il = 0; il < (array.length - 1); il += 2) {
  637.                 obj.traits.push({code:16, dataId:array[il], value:array[il + 1]});
  638.             }
  639.         } else if (line.match(note5)) {
  640.             var array = JSON.parse('[' + RegExp.$1.match(/\d+/g) + ']');
  641.             for (var il = 0; il < array.length; il++) {
  642.                 obj.traits.push({code:18, dataId:array[il], value:0});
  643.             }
  644.         } else if (line.match(note6)) {
  645.             var array = JSON.parse('[' + RegExp.$1.match(/\d+(?:\.\d+)?/g) + ']');
  646.             for (var il = 0; il < (array.length - 1); il += 2) {
  647.                 obj.traits.push({code:36, dataId:array[il], value:array[il + 1]});
  648.             }
  649.         } else if (line.match(note7)) {
  650.             var array = JSON.parse('[' + RegExp.$1.match(/\d+(?:\.\d+)?/g) + ']');
  651.             for (var il = 0; il < (array.length - 1); il += 2) {
  652.                 obj.traits.push({code:36, dataId:array[il] + 2000, value:array[il + 1]});
  653.             }
  654.         } else if (line.match(note8)) {
  655.             var array = JSON.parse('[' + RegExp.$1.match(/\d+(?:\.\d+)?/g) + ']');
  656.             for (var il = 0; il < (array.length - 1); il += 2) {
  657.                 obj.traits.push({code:36, dataId:array[il] + 4000, value:array[il + 1]});
  658.             }
  659.         } else if (line.match(note9)) {
  660.             var array = JSON.parse('[' + RegExp.$1.match(/\d+(?:\.\d+)?/g) + ']');
  661.             for (var il = 0; il < (array.length - 1); il += 2) {
  662.                 obj.traits.push({code:15, dataId:array[il] + 2000, value:array[il + 1]});
  663.             }
  664.         } else if (line.match(note10)) {
  665.             var array = JSON.parse('[' + RegExp.$1.match(/\d+(?:\.\d+)?/g) + ']');
  666.             for (var il = 0; il < (array.length - 1); il += 2) {
  667.                 obj.traits.push({code:36, dataId:array[il] + 6000, value:array[il + 1]});
  668.             }
  669.         } else if (line.match(note11)) {
  670.             flag1 = true;
  671.             key = (RegExp.$1.toLowerCase() == "element")? ["elemreact",RegExp.$2] : (RegExp.$1.toLowerCase() == "skill")? ["skillreact",RegExp.$2] : (RegExp.$1.toLowerCase() == "weapon")? ["weapreact",RegExp.$2] : ["itemdamreact",RegExp.$2];
  672.             obj.jsreactions[key] = obj.jsreactions[key] || '';
  673.         } else if (line.match(note12)) {
  674.             flag1 = false;
  675.             key = '';
  676.         } else if (flag1) {
  677.             obj.jsreactions[key] = obj.jsreactions[key] + line + '\n';
  678.         }
  679.     }
  680.     }
  681. };
  682.  
  683. DataManager.processEleCoreNotetagsB = function(group) {
  684.     var note1 = /<(?:ELEMENTS):[ ]*(\d+(?:\s*,\s*\d+)*)>/i;
  685.     var note2 = /<(?:ITEM DAMAGE TYPE):[ ]*(\d+)>/i;
  686.  
  687.     for (var n = 1; n < group.length; n++) {
  688.     var obj = group[n];
  689.     var notedata = obj.note.split(/[\r\n]+/);
  690.  
  691.     obj.damage.elements = (obj.damage.elementId < 0)? [] : [obj.damage.elementId];
  692.     obj.damage.itype = 0;
  693.  
  694.     for (var i = 0; i < notedata.length; i++) {
  695.         var line = notedata[i];
  696.         if (line.match(note1)) {
  697.             var array = JSON.parse('[' + RegExp.$1.match(/\d+/g) + ']');
  698.             obj.damage.elements = obj.damage.elements.concat(array);
  699.         } else if (line.match(note2)) {
  700.             obj.damage.itype = Number(RegExp.$1);
  701.         }
  702.     }
  703.     }
  704. };
  705.  
  706. //=============================================================================
  707. // Game_BattlerBase
  708. //=============================================================================
  709.  
  710. Game_BattlerBase.prototype.elementEnhace = function(elementId) {
  711.     return this.traitsPi(Game_BattlerBase.TRAIT_ATTACK_EL_ENHACE, elementId);
  712. };
  713.  
  714. Game_BattlerBase.prototype.skillEnhace = function(stypeId) {
  715.     return this.traitsPi(Game_BattlerBase.TRAIT_ATTACK_EL_ENHACE, stypeId + 2000);
  716. };
  717.  
  718. Game_BattlerBase.prototype.weaponEnhace = function(wtypeId) {
  719.     return this.traitsPi(Game_BattlerBase.TRAIT_ATTACK_EL_ENHACE, wtypeId + 4000);
  720. };
  721.  
  722. Game_BattlerBase.prototype.atItemEnhace = function(itypeId) {
  723.     return this.traitsPi(Game_BattlerBase.TRAIT_ATTACK_EL_ENHACE, itypeId + 6000);
  724. };
  725.  
  726. Game_BattlerBase.prototype.elementAbsorb = function(elementId) {
  727.     return (this.traitsWithId(Game_BattlerBase.TRAIT_ELEMENT_ABSORB, elementId).length > 0);
  728. };
  729.  
  730. Game_BattlerBase.prototype.elementCurse = function(elementId) {
  731.     return (this.traitsWithId(Game_BattlerBase.TRAIT_ELEMENT_CURSE, elementId).length > 0);
  732. };
  733.  
  734. ICF.ElementCore.Game_BtlrBase_elementRate = Game_BattlerBase.prototype.elementRate;
  735. Game_BattlerBase.prototype.elementRate = function(elementId) {
  736.     var result = ICF.ElementCore.Game_BtlrBase_elementRate.call(this, elementId);
  737.     if (this.elementAbsorb(elementId)) {
  738.     if (ICF.Param.ElementAbsorbM == 0) {result = Math.min(result - 2.0, -0.01);}
  739.     else {result *= -1}
  740.     }
  741.     if (this.elementCurse(elementId)) {
  742.     if (result < 0) {
  743.         if (ICF.Param.ElementCurseAbsM == 0) return ICF.Param.ElementCurseAbsF;
  744.         else if (ICF.Param.ElementCurseAbsM == 1) {
  745.             result += ICF.Param.ElementCurseAbsF;
  746.             return result.clamp(ICF.Param.ElementCurseAbsMin, ICF.Param.ElementCurseNeutral);
  747.         } else {
  748.             result *= ICF.Param.ElementCurseAbsF;
  749.             return result.clamp(ICF.Param.ElementCurseAbsMin, ICF.Param.ElementCurseNeutral);
  750.         }
  751.     } else if (result == 0) {
  752.         return ICF.Param.ElementCurseNeutral;
  753.     } else {
  754.         if (ICF.Param.ElementCurseMode == 0) return Math.max(result, ICF.Param.ElementCurseFactor);
  755.         else if (ICF.Param.ElementCurseMode == 1) {
  756.             result += ICF.Param.ElementCurseFactor;
  757.             return Math.max(result, ICF.Param.ElementCurseNeutral);
  758.         } else {
  759.             result *= ICF.Param.ElementCurseFactor;
  760.             return Math.max(result, ICF.Param.ElementCurseNeutral);
  761.         }
  762.     }
  763.     }
  764.     return result;
  765. };
  766.  
  767. Game_BattlerBase.prototype.elSkillRate = function(stypeId) {
  768.     return this.traitsPi(Game_BattlerBase.TRAIT_SK_ELEMENT_RATE, stypeId);
  769. };
  770.  
  771. Game_BattlerBase.prototype.elItemRate = function(itypeId) {
  772.     return this.traitsPi(Game_BattlerBase.TRAIT_SK_ELEMENT_RATE + 2000, itypeId);
  773. };
  774.  
  775. Game_BattlerBase.prototype.elWeaponRate = function(wtypeId) {
  776.     return this.traitsPi(Game_BattlerBase.TRAIT_WP_ELEMENT_RATE, wtypeId);
  777. };
  778.  
  779. Game_BattlerBase.prototype.wpAttackElements = function() {
  780.     var wpns = this.traitsSet(Game_BattlerBase.TRAIT_ATTACK_WP_ELEMENT);
  781.     wpns.removeRepeated();
  782.     return wpns;
  783. };
  784.  
  785. Game_BattlerBase.prototype.ADVelementRate = function(elementId, subject) {
  786.     return this.elementRate(elementId) * (subject == undefined)? 1 : subject.elementEnhace(elementId);
  787. };
  788.  
  789. Game_BattlerBase.prototype.ADVelSkillRate = function(stypeId, subject) {
  790.     return this.elSkillRate(stypeId) * (subject == undefined)? 1 : subject.skillEnhace(stypeId);
  791. };
  792.  
  793. Game_BattlerBase.prototype.ADVelItemRate = function(itypeId, subject) {
  794.     return this.elItemRate(itypeId) * (subject == undefined)? 1 : subject.atItemEnhace(itypeId);
  795. };
  796.  
  797. Game_BattlerBase.prototype.ADVelWeaponRate = function(wtypeId, subject) {
  798.     return this.elWeaponRate(wtypeId) * (subject == undefined)? 1 : subject.weaponEnhace(wtypeId);
  799. };
  800.  
  801. //=============================================================================
  802. // Game_Actor
  803. //=============================================================================
  804.  
  805. Game_Actor.prototype.wpAttackElements = function() {
  806.     var wpns = [];
  807.     if (this.weapons().length > 0) {
  808.     wpns = this.weapons().reduce(function(r, obj) {
  809.         return r.concat([obj.wtypeId]);
  810.     }, []);
  811.     wpns.removeRepeated();
  812.     return wpns;
  813.     }
  814.  
  815.     wpns = Game_BattlerBase.prototype.wpAttackElements.call(this);
  816.     if (wpns.length == 0) wpns[0] = 0;
  817.  
  818.     return wpns;
  819. };
  820.  
  821. //=============================================================================
  822. // Game_Action
  823. //=============================================================================
  824.  
  825. ICF.ElementCore.gameaction_init = Game_Action.prototype.initialize;
  826. Game_Action.prototype.initialize = function(subject, forcing) {
  827.     ICF.ElementCore.gameaction_init.call(this, subject, forcing);
  828.     this.elementReact = [];
  829. };
  830.  
  831. Game_Action.prototype.elementsMaxRate = function(target, elements, subject) {
  832.     if (elements.length > 0) {
  833.         return Math.max.apply(null, elements.map(function(elementId) {
  834.             return target.ADVelementRate(elementId, subject);
  835.         }, this));
  836.     } else {
  837.         return 1;
  838.     }
  839. };
  840.  
  841. Game_Action.prototype.elementsMinRate = function(target, elements, subject) {
  842.     if (elements.length > 0) {
  843.         return Math.min.apply(null, elements.map(function(elementId) {
  844.             return target.ADVelementRate(elementId, subject);
  845.         }, this));
  846.     } else {
  847.         return 1;
  848.     }
  849. };
  850.  
  851. Game_Action.prototype.elementsAverageRate = function(target, elements, subject) {
  852.     if (elements.length > 0) {
  853.         return elements.reduce(function(r, element) {
  854.             return r + target.ADVelementRate(element, subject);
  855.         }, 0) / elements.length;
  856.     } else {
  857.         return 1;
  858.     }
  859. };
  860.  
  861. Game_Action.prototype.wpElementsMaxRate = function(target, wpelements, subject) {
  862.     if (wpelements.length > 0) {
  863.         return Math.max.apply(null, wpelements.map(function(wpelementId) {
  864.             return target.ADVelWeaponRate(wpelementId, subject);
  865.         }, this));
  866.     } else {
  867.         return 1;
  868.     }
  869. };
  870.  
  871. Game_Action.prototype.wpElementsMinRate = function(target, wpelements, subject) {
  872.     if (wpelements.length > 0) {
  873.         return Math.min.apply(null, wpelements.map(function(wpelementId) {
  874.             return target.ADVelWeaponRate(wpelementId, subject);
  875.         }, this));
  876.     } else {
  877.         return 1;
  878.     }
  879. };
  880.  
  881. Game_Action.prototype.wpElementsAverageRate = function(target, wpelements, subject) {
  882.     if (wpelements.length > 0) {
  883.         return wpelements.reduce(function(r, wpelement) {
  884.             return r + target.ADVelWeaponRate(wpelement, subject);
  885.         }, 0) / wpelements.length;
  886.     } else {
  887.         return 1;
  888.     }
  889. };
  890.  
  891. Game_Action.prototype.calcWeaponElementRate = function(target) {
  892.     var rate = 1;
  893.     var wpns = this.subject().wpAttackElements();
  894.     if (wpns.length > 0) {
  895.     if (ICF.Param.ElementBlend == 0) {
  896.         rate = this.wpElementsAverageRate(target, wpns, this.subject());
  897.     } else if (ICF.Param.ElementBlend == 3) {
  898.         rate = this.wpElementsMinRate(target, wpns, this.subject());
  899.     } else {
  900.         rate = this.wpElementsMaxRate(target, wpns, this.subject());
  901.     }
  902.     }
  903.  
  904.     if (wpns.length > 0) this.elementReact.push(["weapreact",wpns]);
  905.  
  906.     return rate;
  907. };
  908.  
  909. Game_Action.prototype.calcElementRate = function(target) {
  910.     var rate = 1;
  911.     var rate2 = 0;
  912.     var elements = this.item().damage.elements;
  913.  
  914.     if (this.item().damage.elementId < 0) {
  915.     elements = elements.concat(this.subject().attackElements());
  916.     }
  917.  
  918.     elements.removeRepeated();
  919.  
  920.     if (elements.length > 0) this.elementReact.push(["elemreact",elements]);
  921.  
  922.     if (ICF.Param.ElementBlend == 0) {
  923.     rate = this.elementsAverageRate(target, elements, this.subject());
  924.     } else if (ICF.Param.ElementBlend == 3) {
  925.     rate = this.elementsMinRate(target, elements, this.subject());
  926.     } else {
  927.     rate = this.elementsMaxRate(target, elements, this.subject());
  928.     rate2 = this.elementsMinRate(target, elements, this.subject());
  929.     if (ICF.Param.ElementBlend == 2 && rate2 < 0) rate = rate2;
  930.     }
  931.  
  932.     if (this.isSkill()) {
  933.     if (this.item().stypeId > 0) this.elementReact.push(["skillreact",[this.item().stypeId]]);
  934.     if ((this.item().stypeId > 0)&&(this.isMagical())) {
  935.         rate2 = target.ADVelSkillRate(this.item().stypeId, this.subject());
  936.         if ((rate < 0)||(rate2 < 1)) {rate = rate * rate2;}
  937.         else {rate += rate2 - 1;}
  938.     }
  939.     if ((this.isPhysical())||(this.item().damage.elementId < 0)) {
  940.         rate2 = this.calcWeaponElementRate(target) + rate;
  941.         if (rate2 > 2) {rate = rate2 - 1;}
  942.         else {rate = rate2 / 2;}
  943.     }
  944.     if ((this.item().stypeId > 0)&&(!this.isMagical())) {
  945.         rate2 = target.ADVelSkillRate(this.item().stypeId, this.subject());
  946.         if ((rate < 0)||(rate2 < 1)) {rate = rate * rate2;}
  947.         else {rate += rate2 - 1;}
  948.     }
  949.     } else if (this.isItem()) {
  950.     if (this.item().damage.itype > 0) this.elementReact.push(["itemdamreact",[this.item().damage.itype]]);
  951.     if ((this.item().damage.itype > 0)&&(this.isMagical())) {
  952.         rate2 = target.ADVelItemRate(this.item().damage.itype, this.subject());
  953.         if ((rate < 0)||(rate2 < 1)) {rate = rate * rate2;}
  954.         else {rate += rate2 - 1;}
  955.     }
  956.     if ((this.isPhysical())||(this.item().damage.elementId < 0)) {
  957.         rate2 = this.calcWeaponElementRate(target) + rate;
  958.         if (rate2 > 2) {rate = rate2 - 1;}
  959.         else {rate = rate2 / 2;}
  960.     }
  961.     if ((this.item().damage.itype > 0)&&(!this.isMagical())) {
  962.         rate2 = target.ADVelItemRate(this.item().damage.itype, this.subject());
  963.         if ((rate < 0)||(rate2 < 1)) {rate = rate * rate2;}
  964.         else {rate += rate2 - 1;}
  965.     }
  966.     }
  967.  
  968.     return rate;
  969. };
  970.  
  971. ICF.ElementCore.gameaction_apply = Game_Action.prototype.apply;
  972. Game_Action.prototype.apply = function(target) {
  973.     ICF.ElementCore.gameaction_apply.call(this, target);
  974.     if ((!target.result().isHit()) && (this.elementReact.length > 0) && (this.elementReact[0][0] == "elemreact")) this.elementReact.splice(0, 1);
  975.     if ((target.hp > 0) && (this.elementReact.length > 0)) target.jsevalBulkReactions(this.subject(), this.item(), this.isSkill(), this.elementReact);
  976. }
  977.  
  978. //=============================================================================
  979. // Game_Item
  980. //=============================================================================
  981.  
  982. Game_Item.prototype.absorbingElements = function() {
  983.     return this.traitDataTypes(17);
  984. };
  985.  
  986. Game_Item.prototype.cursingElements = function() {
  987.     return this.traitDataTypes(18);
  988. };
  989.  
  990. Game_Item.prototype.resistingElements = function() {
  991.     return this.traitDataTypes(11);
  992. };
  993.  
  994. Game_Item.prototype.resistingSkills = function() {
  995.     return this.traitDataTypesOffset(15, 0, 1999);
  996. };
  997.  
  998. Game_Item.prototype.resistingWeapons = function() {
  999.     return this.traitDataTypes(16);
  1000. };
  1001.  
  1002. Game_Item.prototype.resistingItemDamages = function() {
  1003.     return this.traitDataTypesOffset(15, 2000, 3999);
  1004. };
  1005.  
  1006. Game_Item.prototype.attackingElements = function() {
  1007.     return this.traitDataTypes(35);
  1008. };
  1009.  
  1010. Game_Item.prototype.enhaceTypes = function() {
  1011.     return this.traitDataTypes(36);
  1012. };
  1013.  
  1014. Game_Item.prototype.elementEnhaceTypes = function() {
  1015.     return this.traitDataTypesOffset(36, 0, 1999);
  1016. };
  1017.  
  1018. Game_Item.prototype.skillEnhaceTypes = function() {
  1019.     return this.traitDataTypesOffset(36, 2000, 3999);
  1020. };
  1021.  
  1022. Game_Item.prototype.weaponEnhaceTypes = function() {
  1023.     return this.traitDataTypesOffset(36, 4000, 5999);
  1024. };
  1025.  
  1026. Game_Item.prototype.itemDamageEnhaceTypes = function() {
  1027.     return this.traitDataTypesOffset(36, 6000, 7999);
  1028. };
  1029.  
  1030. Game_Item.prototype.elements = function() {
  1031.     if (this.isSkill() || this.isItem()) return this.object().damage.elements;
  1032.     if (this.isWeapon() || this.isArmor()) return this.attackingElements();
  1033.     return [];
  1034. };
  1035.  
  1036. //=============================================================================
  1037. // End of File
  1038. //=============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement