Advertisement
ICF-Soft

ICF-Soft Element Core 1.04 RPG Maker MV

Jan 13th, 2017
60
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 = 104; // 1.04
  13.  
  14. //=============================================================================
  15.  /*:
  16.  * @plugindesc v1.04 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.  * @param Element Icons
  57.  * @desc Icons for elements separated by spaces.
  58.  * @default 0 75 64 65 66 67 68 69 70 71 72
  59.  *
  60.  * @param Weapon Type Icons
  61.  * @desc Icons for weapon types separated by spaces.
  62.  * @default 76 96 97 98 99 100 101 102 103 104 105 106 107 108
  63.  *
  64.  * @param Skill Type Icons
  65.  * @desc Icons for skill types separated by spaces.
  66.  * @default 0 78 77
  67.  *
  68.  * @param ItemDamage Type Icons
  69.  * @desc Icons for item types separated by spaces.
  70.  * @default
  71.  *
  72.  * @param Developer HaltJS
  73.  * @desc When true it throws an error if a custom rate javascript
  74.  * formula doesn't work.   NO - false     YES - true
  75.  * @default false
  76.  *
  77.  * @help
  78.  * ============================================================================
  79.  * Introduction
  80.  * ============================================================================
  81.  *
  82.  * Defalut element system in RPG Maker MV is limited and doesn't allow
  83.  * absorbtion.
  84.  *
  85.  * With this plugin you can use not only elements but skill, weapon types
  86.  * and item types plus element absorbtion. Also are element/skill/weapon/item
  87.  * enhaces and multiple elements added.
  88.  *
  89.  * This new formula makes more things important and gives extra depth in
  90.  * tactics.
  91.  *
  92.  * Now you can make magic resistance, bulletproof and so on.
  93.  *
  94.  * New element curse feature allows to change element absorbtion into
  95.  * weakness.
  96.  *
  97.  * You can add types for items like stone, magic stone, grenade, dart and
  98.  * so on with resist and enhace traits.
  99.  *
  100.  * ============================================================================
  101.  * How to use
  102.  * ============================================================================
  103.  *
  104.  * It works with notetags. These can be used in actors, classes, enemies,
  105.  * weapons, armors and states.
  106.  *
  107.  * <ELEMENT ABSORB: x>
  108.  * <ELEMENT ABSORB: x, x>
  109.  *
  110.  *  - Add all elements that can be absorbed in one line.
  111.  *
  112.  * <ELEMENT CURSES: x>
  113.  * <ELEMENT CURSES: x, x>
  114.  *  
  115.  *  - Add all element curses in one line.
  116.  *
  117.  * <WEAPON ELEMENTS: x>
  118.  * <WEAPON ELEMENTS: x, x>
  119.  *
  120.  *  - Add all weapon elements that are used in one line.
  121.  *    Usefull for enemies and for unarmed actors.
  122.  *    0 is barehands. Used for actors when need a weapontype but hasn't one.
  123.  *
  124.  * <WEAPON RESISTANCES: x rate>
  125.  * <WEAPON RESISTANCES: x rate, x rate>
  126.  *
  127.  *  - Add all weapon resistances needed in one line.
  128.  *    rate: can be decimal where 1 is normal, 0.5 is half,
  129.  *          2 is double, etc...
  130.  *
  131.  * <SKILL RESISTANCES: x rate>
  132.  * <SKILL RESISTANCES: x rate, x rate>
  133.  *
  134.  *  - Add all skill resistances needed in one line.
  135.  *    rate: can be decimal where 1 is normal, 0.5 is half,
  136.  *          2 is double, etc...
  137.  *
  138.  * <ITEM DAMAGE RESISTANCES: x rate>
  139.  * <ITEM DAMAGE RESISTANCES: x rate, x rate>
  140.  *
  141.  *  - Add all item-damage resistances needed in one line.
  142.  *    rate: can be decimal where 1 is normal, 0.5 is half,
  143.  *          2 is double, etc...
  144.  *
  145.  * Skill resistance triggers on every skill that came with skilltype.
  146.  *
  147.  * Weapon resistance triggers on physical skills and weapon using skills.
  148.  *
  149.  * Item resistance triggers on every item that came with item damage type.
  150.  * (See below).
  151.  *
  152.  * <ELEMENT ENHANCES: x rate>
  153.  * <ELEMENT ENHANCES: x rate, x rate>
  154.  * <SKILL ENHANCES: x rate>
  155.  * <SKILL ENHANCES: x rate, x rate>
  156.  * <WEAPON ENHANCES: x rate>
  157.  * <WEAPON ENHANCES: x rate, x rate>
  158.  * <ITEM DAMAGE ENHANCES: x rate>
  159.  * <ITEM DAMAGE ENHANCES: x rate, x rate>
  160.  *
  161.  *  - Add all element, skill, weapon and item enhacements needed in one line.
  162.  *    rate: can be decimal where 1 is normal, 0.5 is half,
  163.  *          2 is double, etc...
  164.  *
  165.  * Therer are new notetags for skills and items:
  166.  *
  167.  * <ELEMENTS: x>
  168.  * <ELEMENTS: x, x>
  169.  *
  170.  *  - Add all elements skill/item will use in one line.
  171.  *
  172.  * And for items only:
  173.  *
  174.  * <ITEM DAMAGE TYPE: x>
  175.  *
  176.  *  - Adds an item damage type.
  177.  *
  178.  * ============================================================================
  179.  * Lunatic Mode
  180.  * ============================================================================
  181.  *
  182.  * You can attach custom reactions to actors, classes, weapons, armors,
  183.  * enemies and states.
  184.  *
  185.  * <ELEMENT REACT: 2>
  186.  * this.gainMp(20);
  187.  * this.gainTp(15);
  188.  * </ELEMENT REACT>
  189.  *
  190.  * When an actor/enemy is hit with specified element runs the code of all
  191.  * pieces.
  192.  *
  193.  * <SKILL REACT: X>
  194.  * <WEAPON REACT: X>
  195.  * <ITEM REACT: X>
  196.  *
  197.  * When an actor/enemy is the target of specified skill/weapon/item type
  198.  * runs the code of all pieces even if evaded.
  199.  *
  200.  * Some variables are passed to customize reaction:
  201.  *   - subject: the subject of the action.
  202.  *   - item: the object used in the action. Can be an item or a skill.
  203.  *   - isSkill: check if is an skill.
  204.  *
  205.  * You can also customize actors and enemies element rates.
  206.  *
  207.  * <CUSTOM ELEMENT RATE: 2>
  208.  * result = 0;
  209.  * </CUSTOM ELEMENT RATE>
  210.  *
  211.  * Also for skill types, weapon types and item damage types.
  212.  *
  213.  * <CUSTOM SKILL RATE: X>
  214.  * <CUSTOM WEAPON RATE: X>
  215.  * <CUSTOM ITEM RATE: X>
  216.  *
  217.  * ============================================================================
  218.  * Params
  219.  * ============================================================================
  220.  *
  221.  * Elements Blend:
  222.  *
  223.  *  Behavior when more than one element are used.
  224.  *
  225.  *  0 - Average:      Calcs entire element average.
  226.  *  1 - Normal:       Strongest element takes priority.
  227.  *  2 - Absorb first: If there is an absorbing element will take priority.
  228.  *  3 - Minimun:      Weakest element takes priority.
  229.  *
  230.  * Absorbtion Mode:
  231.  *
  232.  *  How element absorbtion is treated changes the way players must choose
  233.  *  equipment.
  234.  *
  235.  *  0 - Absolute:     Element defense increase absorbtion.
  236.  *  1 - Relative:     Element defense reduces absorbtion same way as damage.
  237.  *
  238.  * There are some parameters for element curse.
  239.  *
  240.  * Curse Absorb Mode / Curse Normal Mode:
  241.  *  
  242.  *  When rate is different than cero, either for absorbtion, resistance,
  243.  *  normal or weak, it needs a calculation based on actual rate.
  244.  *  You can use a different mode for negative and positive values.
  245.  *
  246.  *  0 - Fixed:        Rate will be substituyed with factor.
  247.  *  1 - Additive:     Will increase rate with factor.
  248.  *  2 - Relative:     Will multiply rate with factor.
  249.  *
  250.  * Curse Absorb Factor / Curse Normal Factor:
  251.  *  
  252.  *  The factor that will be used to calc rate.
  253.  *
  254.  * Curse Absorb Min:
  255.  *
  256.  *  A min rate for absorb.
  257.  *
  258.  * Curse Neutral:
  259.  *
  260.  *  Neutral is when rate is equal to cero, inmunity.
  261.  *  This is a fixed rate so it needs to change to a another fixed rate.
  262.  *  It's also used as max rate when absorb and min rate for else.
  263.  *
  264.  * Element/WeapType/SkillType/ItemDamType Icons:
  265.  *
  266.  *  Allow to add icons for elements, weapon types, skill types and item
  267.  *  damage types. Separated by spaces it starts from id 0 and allow to use
  268.  *  ranges if they're consecutives (example 15 to 20).
  269.  *
  270.  * Developer HaltJS: This is a development variable usefull to check if there is
  271.  * a wrong javascript element rate.
  272.  * When true will throw an error when it found a wrong javascript.
  273.  * When false it will be ignored and game continues.
  274.  *
  275.  * ============================================================================
  276.  * Incompatibilities
  277.  * ============================================================================
  278.  *
  279.  * There's no known incompatible plugins yet.
  280.  *
  281.  * ============================================================================
  282.  * Known isues
  283.  * ============================================================================
  284.  *
  285.  * It overrides every other element system that comes after.
  286.  *
  287.  * ============================================================================
  288.  * Changelog
  289.  * ============================================================================
  290.  *
  291.  * Version 1.04:
  292.  * - Added element/skill/weapon/item icons.
  293.  * - Added custom element/skill/weapon/item rates.
  294.  *
  295.  * Version 1.03:
  296.  * - Added element/skill/weapon/item reaction.
  297.  *
  298.  * Version 1.02:
  299.  * - Use of ICF-Soft Main Utility.
  300.  * - Added multiple elements to skill and items.
  301.  * - Added item damage type with resistance and enhace.
  302.  * - Added lowest element rate.
  303.  *
  304.  * Version 1.01:
  305.  * - Improved formula.
  306.  * - Added element curse.
  307.  * - Added element/skill/weapon enhace.
  308.  * - Changed how rates must be used inside notetags.
  309.  *
  310.  * Version 1.00:
  311.  * - Finished plugin!
  312.  *
  313.  * ============================================================================
  314.  *
  315.  * For commercial and non-commercial games.
  316.  * Credit to ICF-Soft.
  317.  * This entire header must be included with plugin.
  318.  *
  319.  * ============================================================================
  320. */
  321. //=============================================================================
  322.  /*:es
  323.  * @plugindesc v1.04 Este complemento añade un sistema de elementos
  324.  * avanzado.
  325.  * @author ICF-Soft [http://icfsoft.blogspot.com.es/]
  326.  *
  327.  * @param Elements Blend
  328.  * @desc Qué hacer cuando se usa más de un elemento.
  329.  * 0 - Media  1 - Normal  2 - Absorbción primero  3 - Mínimo
  330.  * @default 2
  331.  *
  332.  * @param Absorbtion Mode
  333.  * @desc El modo en el que se absorben los elementos.
  334.  * 0 - Absoluto  1 - Relativo
  335.  * @default 1
  336.  *
  337.  * @param Curse Absorb Mode
  338.  * @desc Como tratar la maldición elemental ante la absorción.
  339.  * 0 - Fijo  1 - Aditivo  2 - Relativo
  340.  * @default 2
  341.  *
  342.  * @param Curse Absorb Factor
  343.  * @desc Factor a usar para calcular el daño.
  344.  * @default -0.1
  345.  *
  346.  * @param Curse Absorb Min
  347.  * @desc Valor mínimo.
  348.  * @default 0.1
  349.  *
  350.  * @param Curse Neutral
  351.  * @desc Valor fijo cuando se es inmune al elemento.
  352.  * Además valor máximo en la absorción y mínimo en el resto.
  353.  * @default 2
  354.  *
  355.  * @param Curse Normal Mode
  356.  * @desc Como tratar la maldición elemental normalmente.
  357.  * 0 - Fijo  1 - Aditivo  2 - Relativo
  358.  * @default 1
  359.  *
  360.  * @param Curse Normal Factor
  361.  * @desc Factor a usar para calcular el daño.
  362.  * @default 1
  363.  *
  364.  * @param Element Icons
  365.  * @desc Iconos para los elementos separados por espacios.
  366.  * @default 0 75 64 65 66 67 68 69 70 71 72
  367.  *
  368.  * @param Weapon Type Icons
  369.  * @desc Iconos para lostipos de arma separados por espacios.
  370.  * @default 76 96 97 98 99 100 101 102 103 104 105 106 107 108
  371.  *
  372.  * @param Skill Type Icons
  373.  * @desc Iconos para los tipos de habilidades separados por espacios.
  374.  * @default 0 78 77
  375.  *
  376.  * @param ItemDamage Type Icons
  377.  * @desc Iconos para los tipos de objetos separados por espacios.
  378.  * Sólo la categoría de daño.
  379.  * @default
  380.  *
  381.  * @param Developer HaltJS
  382.  * @desc Si está activado salta cuando una función personalizada
  383.  * da error.   No - false   Si - true
  384.  * @default false
  385.  *
  386.  * @help
  387.  * ============================================================================
  388.  * Introducción
  389.  * ============================================================================
  390.  *
  391.  * El sistema de elementos que viene predeterminado en RPG Maker MV es limitado
  392.  * y no permite la absorbción.
  393.  *
  394.  * Con este complemento puedes usar no sólo elementos sino también tipos de
  395.  * habilidades, armas y objetos además de la absorbción de elementos y
  396.  * la bonificación de elementos, habilidades, armas y objetos.
  397.  * Además puedes usar varios elementos en habilidades y objetos.
  398.  *
  399.  * Esta nueva fórmula da importancia a más opciones y da profundidad extra
  400.  * en las tácticas.
  401.  *
  402.  * Ahora puedes utilizar resistencia a la magia, antibalas y más cosas similares.
  403.  *
  404.  * La nueva maldición elemental permite volver debilidad cualquier elemento
  405.  * incluso cuando es absorbido.
  406.  *
  407.  * Puedes añadir tipos de objetos tales como piedra, piedra mágica, granada,
  408.  * daro y similares con sus características de resistencia y mejora.
  409.  *
  410.  * ============================================================================
  411.  * Uso
  412.  * ============================================================================
  413.  *
  414.  * Funciona con etiquetas en las notas. Pueden usarse en actores, clases,
  415.  * enemigos, armas, armaduras y estados alterados.
  416.  *
  417.  * <ELEMENT ABSORB: x>
  418.  * <ELEMENT ABSORB: x, x>
  419.  *
  420.  *  - Añade todos los elementos que puede absorber en una linea.
  421.  *
  422.  * <ELEMENT CURSES: x>
  423.  * <ELEMENT CURSES: x, x>
  424.  *  
  425.  *  - Añade todas las maldiciones elementales en una linea.
  426.  *
  427.  * <WEAPON ELEMENTS: x>
  428.  * <WEAPON ELEMENTS: x, x>
  429.  *
  430.  *  - Añade todos los tipos de arma que se utilizan en una linea.
  431.  *    Útil para enemigos y los actores que no lleven armas.
  432.  *    0 son los puños. Se utiliza cuando un actor necesita un tipo de arma
  433.  *    pero no está disponible ninguno.
  434.  *
  435.  * <WEAPON RESISTANCES: x rate>
  436.  * <WEAPON RESISTANCES: x rate, x rate>
  437.  *
  438.  *  - Añade todas las resistencias a las armas en una linea.
  439.  *    rate: puede ser decimal, 1 es normal, 0.5 es la mitad,
  440.  *          2 es el doble, etc...
  441.  *
  442.  * <SKILL RESISTANCES: x rate>
  443.  * <SKILL RESISTANCES: x rate, x rate>
  444.  *
  445.  *  - Añade todas las resistencias a las habilidades en una linea.
  446.  *    rate: puede ser decimal, 1 es normal, 0.5 es la mitad,
  447.  *          2 es el doble, etc...
  448.  *
  449.  * <ITEM DAMAGE RESISTANCES: x rate>
  450.  * <ITEM DAMAGE RESISTANCES: x rate, x rate>
  451.  *
  452.  *  - Añade todas las resistencias a objetos en una linea.
  453.  *    rate: puede ser decimal, 1 es normal, 0.5 es la mitad,
  454.  *          2 es el doble, etc...
  455.  *
  456.  * La resistencia a las habilidades se activa en las habilidades que incluyan
  457.  * categoría.
  458.  *
  459.  * La resistencia a las armas se activa en las habilidades físicas y las que
  460.  * utilizan arma.
  461.  *
  462.  * La resistencia a los objetos se activa en los objetos que incluyan un tipo
  463.  * de daño (ver más abajo).
  464.  *
  465.  * <ELEMENT ENHANCES: x rate>
  466.  * <ELEMENT ENHANCES: x rate, x rate>
  467.  * <SKILL ENHANCES: x rate>
  468.  * <SKILL ENHANCES: x rate, x rate>
  469.  * <WEAPON ENHANCES: x rate>
  470.  * <WEAPON ENHANCES: x rate, x rate>
  471.  * <ITEM DAMAGE ENHANCES: x rate>
  472.  * <ITEM DAMAGE ENHANCES: x rate, x rate>
  473.  *
  474.  *  - Añade todas las bonificaciones de elementos, habilidades, armas
  475.  *    y objetos necesarias en una linea.
  476.  *    rate: puede ser decimal, 1 es normal, 0.5 es la mitad,
  477.  *          2 es el doble, etc...
  478.  *
  479.  *
  480.  * Nuevas etiquetas para habilidades y objetos:
  481.  *
  482.  * <ELEMENTS: x>
  483.  * <ELEMENTS: x, x>
  484.  *
  485.  *  - Añade todos los elementos que la habilidad u objeto va a usar en una sola
  486.  *    linea.
  487.  *
  488.  * Y para objetos solo:
  489.  *
  490.  * <ITEM DAMAGE TYPE: x>
  491.  *
  492.  *  - Añade el tipo de daño específico del objeto.
  493.  *
  494.  * ============================================================================
  495.  * Modo Lunático
  496.  * ============================================================================
  497.  *
  498.  * Puedes añadir reacciones personalizadas a personajes, clases, armas,
  499.  * armaduras, enemigos y estados alterados.
  500.  *
  501.  * <ELEMENT REACT: 2>
  502.  * this.gainMp(20);
  503.  * this.gainTp(15);
  504.  * </ELEMENT REACT>
  505.  *
  506.  * Cuando un personaje o enemigo es afectado por el elemento específico se
  507.  * ejecutará el código de todas las piezas.
  508.  *
  509.  * <SKILL REACT: X>
  510.  * <WEAPON REACT: X>
  511.  * <ITEM REACT: X>
  512.  
  513.  * Cuando un personaje o enemigo es afectado por el tipo de habilidad, arma
  514.  * o objeto específico se ejecutará el código de todas las piezas aunque se
  515.  * evada.
  516.  *
  517.  * Se puede acceder a las siguientes variables en la reacción:
  518.  *   - subject: el sujeto de la acción.
  519.  *   - item: el objeto usado en la acción. Puede ser un objeto o habilidad.
  520.  *   - isSkill: comprueba si se trata de una habilidad.
  521.  *
  522.  * Además puedes personalizar las resistencias elementales para actores
  523.  * y enemigos.
  524.  *
  525.  * <CUSTOM ELEMENT RATE: 2>
  526.  * result = 0;
  527.  * </CUSTOM ELEMENT RATE>
  528.  *
  529.  * Siendo aplicable también para tipos de habilidad, arma y objeto.
  530.  *
  531.  * <CUSTOM SKILL RATE: X>
  532.  * <CUSTOM WEAPON RATE: X>
  533.  * <CUSTOM ITEM RATE: X>
  534.  *
  535.  * ============================================================================
  536.  * Parámetros
  537.  * ============================================================================
  538.  *
  539.  * Elements Blend:
  540.  *
  541.  *  El comportamiento cuando se usan más de un elemento.
  542.  *
  543.  *  0 - Media:             Calcula la media.
  544.  *  1 - Normal:            El elemento más dañino toma prioridad.
  545.  *  2 - Absorción primero: Si un elemento es absorbible tendrá prioridad.
  546.  *  3 - Mínimo:            El elemento menos dañino toma prioridad.
  547.  *
  548.  * Absorbtion Mode:
  549.  *
  550.  *  El modo en el que los elementos son absorbidos cambia el modo en el que
  551.  *  el jugador debe seleccionar el equipamiento.
  552.  *
  553.  *  0 - Absoluto:     La defensa elemental incrementa la absorbción.
  554.  *  1 - Relativo:     La defensa elemental reduce tanto la absorbción
  555.  *                    como el daño.
  556.  *
  557.  * Para la maldición elemental se usan los siguientes parámetros:
  558.  *
  559.  * Curse Absorb Mode / Curse Normal Mode:
  560.  *  
  561.  *  Para daño negativo (absorción) y daño positivo (normal, débil o resistente)
  562.  *  se usan calculos distintos basado en el valor actual y un factor.
  563.  *
  564.  *  0 - Fijo:         El factor será el nuevo valor.
  565.  *  1 - Aditivo:      Al valor se le añade el factor.
  566.  *  2 - Relativo:     El valor se multiplica por el factor.
  567.  *
  568.  * Curse Absorb Factor / Curse Normal Factor:
  569.  *  
  570.  *  El factor usado para calcular.
  571.  *
  572.  * Curse Absorb Min:
  573.  *
  574.  *  El valor mínimo para el elemento absorbido.
  575.  *
  576.  * Curse Neutral:
  577.  *
  578.  *  El valor que tomará cuando se es inmune. Al ser fijo se sustituye por
  579.  *  otro valor fijo.
  580.  *  Además se usa como término medio entre absorción y daño.
  581.  *
  582.  * Element/WeapType/SkillType/ItemDamType Icons:
  583.  *
  584.  *  Permite añadir iconos para las distintas resistencias. Separados por
  585.  *  espacios y permite el uso de rangos si son consecutivos (ejemplo 15 a 20).
  586.  *
  587.  * Developer HaltJS: Esta es una variable de uso durante el desarrollo del juego
  588.  * útil cuando quieres comprobar si hay alguna función personalizada incorrecta.
  589.  * Cuando está activado al encontrar un error el juego se para y muestra
  590.  * el error. Cuando está desactivado ignora el error y el juego continúa.
  591.  *
  592.  * ============================================================================
  593.  * Incompatibilidades
  594.  * ============================================================================
  595.  *
  596.  * No se conocen complementos que sean incompatibles hasta la fecha.
  597.  *
  598.  * ============================================================================
  599.  * Problemas conocidos
  600.  * ============================================================================
  601.  *
  602.  * Se sobreescribe cualquier sistema de elementos que se haya puesto antes.
  603.  *
  604.  * ============================================================================
  605.  * Historial de versiones
  606.  * ============================================================================
  607.  *
  608.  * Version 1.04:
  609.  * - Se han añadido iconos para las distintas resistencias.
  610.  * - Se ha añadido resistencias personalizadas.
  611.  *
  612.  * Version 1.03:
  613.  * - Se ha añadido la reacción a elementos y tipos de armas, habilidades
  614.  *   y objetos.
  615.  *
  616.  * Version 1.02:
  617.  * - Se empieza a utilizar el ICF-Soft Main Utility.
  618.  * - Se usan múltiples elementos para habilidades y objetos.
  619.  * - Se ha añadido tipos de daño de objeto con resistencias y bonificación.
  620.  * - Se ha añadido el poder usar el elemento menos dañino.
  621.  *
  622.  * Versión 1.01:
  623.  * - Se ha mejorado la fórmula de cálculo.
  624.  * - Se ha añadido la maldición elemental.
  625.  * - Se ha añadido bonificación de elemento/habilidad/arma.
  626.  * - Se ha cambiado el modo en que se usan las etiquetas de las notas.
  627.  *
  628.  * Versión 1.00:
  629.  * - Complemento terminado.
  630.  *
  631.  * ============================================================================
  632.  *
  633.  * Para juegos comerciales y no comerciales.
  634.  * Se debe incluir a ICF-Soft en los créditos.
  635.  * Esta cabecera debe incluirse íntegramente con el plugin.
  636.  *
  637.  * ============================================================================
  638. */
  639. //=============================================================================
  640.  
  641. //=============================================================================
  642. // Parameter Variables
  643. //=============================================================================
  644.  
  645. ICF.Parameters = PluginManager.parameters('ICFSoft_ElementCore');
  646. ICF.Param = ICF.Param || {};
  647.  
  648. ICF.Param.ElementBlend = Number(ICF.Parameters['Elements Blend']);
  649. ICF.Param.ElementAbsorbM = Number(ICF.Parameters['Absorbtion Mode']);
  650.  
  651. ICF.Param.ElementCurseAbsM = Number(ICF.Parameters['Curse Absorb Mode']);
  652. ICF.Param.ElementCurseAbsF = Number(ICF.Parameters['Curse Absorb Factor']);
  653. ICF.Param.ElementCurseAbsMin = Number(ICF.Parameters['Curse Absorb Min']);
  654. ICF.Param.ElementCurseNeutral = Number(ICF.Parameters['Curse Neutral']);
  655. ICF.Param.ElementCurseMode = Number(ICF.Parameters['Curse Normal Mode']);
  656. ICF.Param.ElementCurseFactor = Number(ICF.Parameters['Curse Normal Factor']);
  657.  
  658. ICF.Param.ElementIcons = ICF.Parameters['Element Icons'].split(/\s+/).extend().leaveNumbers();
  659. ICF.Param.WeaponTypeIcons = ICF.Parameters['Weapon Type Icons'].split(/\s+/).extend().leaveNumbers();
  660. ICF.Param.SkillTypeIcons = ICF.Parameters['Skill Type Icons'].split(/\s+/).extend().leaveNumbers();
  661. ICF.Param.ItemDamageIcons = ICF.Parameters['ItemDamage Type Icons'].split(/\s+/).extend().leaveNumbers();
  662.  
  663. ICF.Param.ElemCoreHalt = ICF.Parameters['Developer HaltJS'].toLowerCase() === "true";
  664.  
  665. 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.');}
  666. 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.');}
  667.  
  668. //=============================================================================
  669. // Constants
  670. //=============================================================================
  671.  
  672. Game_BattlerBase.TRAIT_SK_ELEMENT_RATE    = 15;
  673. Game_BattlerBase.TRAIT_WP_ELEMENT_RATE    = 16;
  674. Game_BattlerBase.TRAIT_ELEMENT_ABSORB     = 17;
  675. Game_BattlerBase.TRAIT_ELEMENT_CURSE      = 18;
  676. Game_BattlerBase.TRAIT_ATTACK_WP_ELEMENT  = 35;
  677. Game_BattlerBase.TRAIT_ATTACK_EL_ENHACE   = 36;
  678.  
  679. //=============================================================================
  680. // DataManager
  681. //=============================================================================
  682.  
  683. ICF.ElementCore.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded;
  684. DataManager.isDatabaseLoaded = function() {
  685.     if (!ICF.ElementCore.DataManager_isDatabaseLoaded.call(this)) return false;
  686.     if (!ICF.ElementCore.Procesed) {
  687.     DataManager.processEleCoreNotetagsB($dataActors);
  688.     DataManager.processEleCoreNotetagsA($dataClasses);
  689.     DataManager.processEleCoreNotetagsB($dataEnemies);
  690.     DataManager.processEleCoreNotetagsA($dataWeapons);
  691.     DataManager.processEleCoreNotetagsA($dataArmors);
  692.     DataManager.processEleCoreNotetagsA($dataStates);
  693.     DataManager.processEleCoreNotetagsC($dataSkills);
  694.     DataManager.processEleCoreNotetagsC($dataItems);
  695.     ICF.ElementCore.Procesed = true;
  696.     }
  697.     return true;
  698. };
  699.  
  700. DataManager.processEleCoreNotetagsA = function(group) {
  701.     var note1 = /<(?:ELEMENT ABSORB):[ ]*(\d+(?:\s*,\s*\d+)*)>/i;
  702.     var note2 = /<(?:WEAPON ELEMENTS):[ ]*(\d+(?:\s*,\s*\d+)*)>/i;
  703.     var note3 = /<(?:SKILL RESISTANCES):[ ]*(\d+\s+\d+(?:\.\d+)?(?:\s*,\s*\d+\s+\d+(?:\.\d+)?)*)>/i;
  704.     var note4 = /<(?:WEAPON RESISTANCES):[ ]*(\d+\s+\d+(?:\.\d+)?(?:\s*,\s*\d+\s+\d+(?:\.\d+)?)*)>/i;
  705.     var note5 = /<(?:ELEMENT CURSES):[ ]*(\d+(?:\s*,\s*\d+)*)>/i;
  706.     var note6 = /<(?:ELEMENT ENHANCES):[ ]*(\d+\s+\d+(?:\.\d+)?(?:\s*,\s*\d+\s+\d+(?:\.\d+)?)*)>/i;
  707.     var note7 = /<(?:SKILL ENHANCES):[ ]*(\d+\s+\d+(?:\.\d+)?(?:\s*,\s*\d+\s+\d+(?:\.\d+)?)*)>/i;
  708.     var note8 = /<(?:WEAPON ENHANCES):[ ]*(\d+\s+\d+(?:\.\d+)?(?:\s*,\s*\d+\s+\d+(?:\.\d+)?)*)>/i;
  709.     var note9 = /<(?:ITEM DAMAGE RESISTANCES):[ ]*(\d+\s+\d+(?:\.\d+)?(?:\s*,\s*\d+\s+\d+(?:\.\d+)?)*)>/i;
  710.     var note10 = /<(?:ITEM DAMAGE ENHANCES):[ ]*(\d+\s+\d+(?:\.\d+)?(?:\s*,\s*\d+\s+\d+(?:\.\d+)?)*)>/i;
  711.     var note11 = /<((?:ELEMENT)|(?:SKILL)|(?:WEAPON)|(?:ITEM)) (?:REACT):[ ]*(\d+)[ ]*>/i;
  712.     var note12 = /<\/((?:ELEMENT)|(?:SKILL)|(?:WEAPON)|(?:ITEM)) (?:REACT)>/i;
  713.  
  714.     var flag1 = false;
  715.     var key = '';
  716.  
  717.     for (var n = 1; n < group.length; n++) {
  718.     var obj = group[n];
  719.     var notedata = obj.note.split(/[\r\n]+/);
  720.  
  721.     for (var i = 0; i < notedata.length; i++) {
  722.         var line = notedata[i];
  723.         if (line.match(note1)) {
  724.             var array = JSON.parse('[' + RegExp.$1.match(/\d+/g) + ']');
  725.             for (var il = 0; il < array.length; il++) {
  726.                 obj.traits.push({code:17, dataId:array[il], value:0});
  727.             }
  728.         } else if (line.match(note2)) {
  729.             var array = JSON.parse('[' + RegExp.$1.match(/\d+/g) + ']');
  730.             for (var il = 0; il < array.length; il++) {
  731.                 obj.traits.push({code:35, dataId:array[il], value:0});
  732.             }
  733.         } else if (line.match(note3)) {
  734.             var array = JSON.parse('[' + RegExp.$1.match(/\d+(?:\.\d+)?/g) + ']');
  735.             for (var il = 0; il < (array.length - 1); il += 2) {
  736.                 obj.traits.push({code:15, dataId:array[il], value:array[il + 1]});
  737.             }
  738.         } else if (line.match(note4)) {
  739.             var array = JSON.parse('[' + RegExp.$1.match(/\d+(?:\.\d+)?/g) + ']');
  740.             for (var il = 0; il < (array.length - 1); il += 2) {
  741.                 obj.traits.push({code:16, dataId:array[il], value:array[il + 1]});
  742.             }
  743.         } else if (line.match(note5)) {
  744.             var array = JSON.parse('[' + RegExp.$1.match(/\d+/g) + ']');
  745.             for (var il = 0; il < array.length; il++) {
  746.                 obj.traits.push({code:18, dataId:array[il], value:0});
  747.             }
  748.         } else if (line.match(note6)) {
  749.             var array = JSON.parse('[' + RegExp.$1.match(/\d+(?:\.\d+)?/g) + ']');
  750.             for (var il = 0; il < (array.length - 1); il += 2) {
  751.                 obj.traits.push({code:36, dataId:array[il], value:array[il + 1]});
  752.             }
  753.         } else if (line.match(note7)) {
  754.             var array = JSON.parse('[' + RegExp.$1.match(/\d+(?:\.\d+)?/g) + ']');
  755.             for (var il = 0; il < (array.length - 1); il += 2) {
  756.                 obj.traits.push({code:36, dataId:array[il] + 2000, value:array[il + 1]});
  757.             }
  758.         } else if (line.match(note8)) {
  759.             var array = JSON.parse('[' + RegExp.$1.match(/\d+(?:\.\d+)?/g) + ']');
  760.             for (var il = 0; il < (array.length - 1); il += 2) {
  761.                 obj.traits.push({code:36, dataId:array[il] + 4000, value:array[il + 1]});
  762.             }
  763.         } else if (line.match(note9)) {
  764.             var array = JSON.parse('[' + RegExp.$1.match(/\d+(?:\.\d+)?/g) + ']');
  765.             for (var il = 0; il < (array.length - 1); il += 2) {
  766.                 obj.traits.push({code:15, dataId:array[il] + 2000, value:array[il + 1]});
  767.             }
  768.         } else if (line.match(note10)) {
  769.             var array = JSON.parse('[' + RegExp.$1.match(/\d+(?:\.\d+)?/g) + ']');
  770.             for (var il = 0; il < (array.length - 1); il += 2) {
  771.                 obj.traits.push({code:36, dataId:array[il] + 6000, value:array[il + 1]});
  772.             }
  773.         } else if (line.match(note11)) {
  774.             flag1 = true;
  775.             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];
  776.             obj.jsreactions[key] = obj.jsreactions[key] || '';
  777.         } else if (line.match(note12)) {
  778.             flag1 = false;
  779.             key = '';
  780.         } else if (flag1) {
  781.             obj.jsreactions[key] = obj.jsreactions[key] + line + '\n';
  782.         }
  783.     }
  784.     }
  785. };
  786.  
  787. DataManager.processEleCoreNotetagsB = function(group) {
  788.     var note1 = /<(?:ELEMENT ABSORB):[ ]*(\d+(?:\s*,\s*\d+)*)>/i;
  789.     var note2 = /<(?:WEAPON ELEMENTS):[ ]*(\d+(?:\s*,\s*\d+)*)>/i;
  790.     var note3 = /<(?:SKILL RESISTANCES):[ ]*(\d+\s+\d+(?:\.\d+)?(?:\s*,\s*\d+\s+\d+(?:\.\d+)?)*)>/i;
  791.     var note4 = /<(?:WEAPON RESISTANCES):[ ]*(\d+\s+\d+(?:\.\d+)?(?:\s*,\s*\d+\s+\d+(?:\.\d+)?)*)>/i;
  792.     var note5 = /<(?:ELEMENT CURSES):[ ]*(\d+(?:\s*,\s*\d+)*)>/i;
  793.     var note6 = /<(?:ELEMENT ENHANCES):[ ]*(\d+\s+\d+(?:\.\d+)?(?:\s*,\s*\d+\s+\d+(?:\.\d+)?)*)>/i;
  794.     var note7 = /<(?:SKILL ENHANCES):[ ]*(\d+\s+\d+(?:\.\d+)?(?:\s*,\s*\d+\s+\d+(?:\.\d+)?)*)>/i;
  795.     var note8 = /<(?:WEAPON ENHANCES):[ ]*(\d+\s+\d+(?:\.\d+)?(?:\s*,\s*\d+\s+\d+(?:\.\d+)?)*)>/i;
  796.     var note9 = /<(?:ITEM DAMAGE RESISTANCES):[ ]*(\d+\s+\d+(?:\.\d+)?(?:\s*,\s*\d+\s+\d+(?:\.\d+)?)*)>/i;
  797.     var note10 = /<(?:ITEM DAMAGE ENHANCES):[ ]*(\d+\s+\d+(?:\.\d+)?(?:\s*,\s*\d+\s+\d+(?:\.\d+)?)*)>/i;
  798.     var note11 = /<((?:ELEMENT)|(?:SKILL)|(?:WEAPON)|(?:ITEM)) (?:REACT):[ ]*(\d+)[ ]*>/i;
  799.     var note12 = /<\/((?:ELEMENT)|(?:SKILL)|(?:WEAPON)|(?:ITEM)) (?:REACT)>/i;
  800.     var note13 = /<(?:CUSTOM )((?:ELEMENT)|(?:SKILL)|(?:WEAPON)|(?:ITEM)) (?:RATE):[ ]*(\d+)[ ]*>/i;
  801.     var note14 = /<\/(?:CUSTOM )((?:ELEMENT)|(?:SKILL)|(?:WEAPON)|(?:ITEM)) (?:RATE)>/i;
  802.  
  803.     var flag1 = false;
  804.     var key = '';
  805.  
  806.     var flagC = -1;
  807.     var key2 = 0;
  808.  
  809.     for (var n = 1; n < group.length; n++) {
  810.     var obj = group[n];
  811.     var notedata = obj.note.split(/[\r\n]+/);
  812.  
  813.     obj.customElementRates = [{},{},{},{}]; //Element, Weapon, Skill, ItemDamage
  814.  
  815.     for (var i = 0; i < notedata.length; i++) {
  816.         var line = notedata[i];
  817.         if (line.match(note1)) {
  818.             var array = JSON.parse('[' + RegExp.$1.match(/\d+/g) + ']');
  819.             for (var il = 0; il < array.length; il++) {
  820.                 obj.traits.push({code:17, dataId:array[il], value:0});
  821.             }
  822.         } else if (line.match(note2)) {
  823.             var array = JSON.parse('[' + RegExp.$1.match(/\d+/g) + ']');
  824.             for (var il = 0; il < array.length; il++) {
  825.                 obj.traits.push({code:35, dataId:array[il], value:0});
  826.             }
  827.         } else if (line.match(note3)) {
  828.             var array = JSON.parse('[' + RegExp.$1.match(/\d+(?:\.\d+)?/g) + ']');
  829.             for (var il = 0; il < (array.length - 1); il += 2) {
  830.                 obj.traits.push({code:15, dataId:array[il], value:array[il + 1]});
  831.             }
  832.         } else if (line.match(note4)) {
  833.             var array = JSON.parse('[' + RegExp.$1.match(/\d+(?:\.\d+)?/g) + ']');
  834.             for (var il = 0; il < (array.length - 1); il += 2) {
  835.                 obj.traits.push({code:16, dataId:array[il], value:array[il + 1]});
  836.             }
  837.         } else if (line.match(note5)) {
  838.             var array = JSON.parse('[' + RegExp.$1.match(/\d+/g) + ']');
  839.             for (var il = 0; il < array.length; il++) {
  840.                 obj.traits.push({code:18, dataId:array[il], value:0});
  841.             }
  842.         } else if (line.match(note6)) {
  843.             var array = JSON.parse('[' + RegExp.$1.match(/\d+(?:\.\d+)?/g) + ']');
  844.             for (var il = 0; il < (array.length - 1); il += 2) {
  845.                 obj.traits.push({code:36, dataId:array[il], value:array[il + 1]});
  846.             }
  847.         } else if (line.match(note7)) {
  848.             var array = JSON.parse('[' + RegExp.$1.match(/\d+(?:\.\d+)?/g) + ']');
  849.             for (var il = 0; il < (array.length - 1); il += 2) {
  850.                 obj.traits.push({code:36, dataId:array[il] + 2000, value:array[il + 1]});
  851.             }
  852.         } else if (line.match(note8)) {
  853.             var array = JSON.parse('[' + RegExp.$1.match(/\d+(?:\.\d+)?/g) + ']');
  854.             for (var il = 0; il < (array.length - 1); il += 2) {
  855.                 obj.traits.push({code:36, dataId:array[il] + 4000, value:array[il + 1]});
  856.             }
  857.         } else if (line.match(note9)) {
  858.             var array = JSON.parse('[' + RegExp.$1.match(/\d+(?:\.\d+)?/g) + ']');
  859.             for (var il = 0; il < (array.length - 1); il += 2) {
  860.                 obj.traits.push({code:15, dataId:array[il] + 2000, value:array[il + 1]});
  861.             }
  862.         } else if (line.match(note10)) {
  863.             var array = JSON.parse('[' + RegExp.$1.match(/\d+(?:\.\d+)?/g) + ']');
  864.             for (var il = 0; il < (array.length - 1); il += 2) {
  865.                 obj.traits.push({code:36, dataId:array[il] + 6000, value:array[il + 1]});
  866.             }
  867.         } else if (line.match(note11)) {
  868.             flag1 = true;
  869.             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];
  870.             obj.jsreactions[key] = obj.jsreactions[key] || '';
  871.         } else if (line.match(note12)) {
  872.             flag1 = false;
  873.             key = '';
  874.         } else if (line.match(note13)) {
  875.             flagC = (RegExp.$1.toLowerCase() == "element")? 0 : (RegExp.$1.toLowerCase() == "skill")? 2 : (RegExp.$1.toLowerCase() == "weapon")? 1 : 3;
  876.             key2 = Number(RegExp.$2);
  877.             obj.customElementRates[flagC][key2] = obj.customElementRates[flagC][key2] || '';
  878.         } else if (line.match(note14)) {
  879.             flagC = -1;
  880.             key2 = 0;
  881.         } else if (flag1) {
  882.             obj.jsreactions[key] = obj.jsreactions[key] + line + '\n';
  883.         } else if (flagC > -1) {
  884.             obj.customElementRates[flagC][key2] = obj.customElementRates[flagC][key2] + line + '\n';
  885.         }
  886.     }
  887.     }
  888. };
  889.  
  890. DataManager.processEleCoreNotetagsC = function(group) {
  891.     var note1 = /<(?:ELEMENTS):[ ]*(\d+(?:\s*,\s*\d+)*)>/i;
  892.     var note2 = /<(?:ITEM DAMAGE TYPE):[ ]*(\d+)>/i;
  893.  
  894.     for (var n = 1; n < group.length; n++) {
  895.     var obj = group[n];
  896.     var notedata = obj.note.split(/[\r\n]+/);
  897.  
  898.     obj.damage.elements = (obj.damage.elementId < 0)? [] : [obj.damage.elementId];
  899.     obj.damage.itype = 0;
  900.  
  901.     for (var i = 0; i < notedata.length; i++) {
  902.         var line = notedata[i];
  903.         if (line.match(note1)) {
  904.             var array = JSON.parse('[' + RegExp.$1.match(/\d+/g) + ']');
  905.             obj.damage.elements = obj.damage.elements.concat(array);
  906.         } else if (line.match(note2)) {
  907.             obj.damage.itype = Number(RegExp.$1);
  908.         }
  909.     }
  910.     }
  911. };
  912.  
  913. //=============================================================================
  914. // Game_BattlerBase
  915. //=============================================================================
  916.  
  917. Game_BattlerBase.prototype.elementEnhace = function(elementId) {
  918.     return this.traitsPi(Game_BattlerBase.TRAIT_ATTACK_EL_ENHACE, elementId);
  919. };
  920.  
  921. Game_BattlerBase.prototype.skillEnhace = function(stypeId) {
  922.     return this.traitsPi(Game_BattlerBase.TRAIT_ATTACK_EL_ENHACE, stypeId + 2000);
  923. };
  924.  
  925. Game_BattlerBase.prototype.weaponEnhace = function(wtypeId) {
  926.     return this.traitsPi(Game_BattlerBase.TRAIT_ATTACK_EL_ENHACE, wtypeId + 4000);
  927. };
  928.  
  929. Game_BattlerBase.prototype.atItemEnhace = function(itypeId) {
  930.     return this.traitsPi(Game_BattlerBase.TRAIT_ATTACK_EL_ENHACE, itypeId + 6000);
  931. };
  932.  
  933. Game_BattlerBase.prototype.elementAbsorb = function(elementId) {
  934.     return (this.traitsWithId(Game_BattlerBase.TRAIT_ELEMENT_ABSORB, elementId).length > 0);
  935. };
  936.  
  937. Game_BattlerBase.prototype.elementCurse = function(elementId) {
  938.     return (this.traitsWithId(Game_BattlerBase.TRAIT_ELEMENT_CURSE, elementId).length > 0);
  939. };
  940.  
  941. Game_BattlerBase.prototype.customElementRates = function(data) {
  942.     return {};
  943. };
  944.  
  945. ICF.ElementCore.Game_BtlrBase_elementRate = Game_BattlerBase.prototype.elementRate;
  946. Game_BattlerBase.prototype.elementRate = function(elementId) {
  947.     var result = ICF.ElementCore.Game_BtlrBase_elementRate.call(this, elementId);
  948.     if (this.elementAbsorb(elementId)) {
  949.     if (ICF.Param.ElementAbsorbM == 0) {result = Math.min(result - 2.0, -0.01);}
  950.     else if (result > 0) {result *= -1}
  951.     }
  952.     var customrates = this.customElementRates(0);
  953.     if ((customrates[elementId]) && (customrates[elementId] != '')) {
  954.     try {   eval(customrates[elementId]);
  955.     } catch (e) {if(ICF.Param.ElemCoreHalt){throw new Error('Error in custom element rate #' + elementId + ' for battler');}}
  956.     }
  957.     if (this.elementCurse(elementId)) {
  958.     if (result < 0) {
  959.         if (ICF.Param.ElementCurseAbsM == 0) return ICF.Param.ElementCurseAbsF;
  960.         else if (ICF.Param.ElementCurseAbsM == 1) {
  961.             result += ICF.Param.ElementCurseAbsF;
  962.             return result.clamp(ICF.Param.ElementCurseAbsMin, ICF.Param.ElementCurseNeutral);
  963.         } else {
  964.             result *= ICF.Param.ElementCurseAbsF;
  965.             return result.clamp(ICF.Param.ElementCurseAbsMin, ICF.Param.ElementCurseNeutral);
  966.         }
  967.     } else if (result == 0) {
  968.         return ICF.Param.ElementCurseNeutral;
  969.     } else {
  970.         if (ICF.Param.ElementCurseMode == 0) return Math.max(result, ICF.Param.ElementCurseFactor);
  971.         else if (ICF.Param.ElementCurseMode == 1) {
  972.             result += ICF.Param.ElementCurseFactor;
  973.             return Math.max(result, ICF.Param.ElementCurseNeutral);
  974.         } else {
  975.             result *= ICF.Param.ElementCurseFactor;
  976.             return Math.max(result, ICF.Param.ElementCurseNeutral);
  977.         }
  978.     }
  979.     }
  980.     return result;
  981. };
  982.  
  983. Game_BattlerBase.prototype.elSkillRate = function(stypeId) {
  984.     var customrates = this.customElementRates(2);
  985.     if ((customrates[stypeId]) && (customrates[stypeId] != '')) {
  986.     try {   var result = this.traitsPi(Game_BattlerBase.TRAIT_SK_ELEMENT_RATE, stypeId);
  987.         eval(customrates[stypeId]);
  988.         return result;
  989.         }
  990.     catch (e) {if(ICF.Param.ElemCoreHalt){throw new Error('Error in custom skill rate #' + stypeId + ' for battler');}}
  991.     }
  992.     return this.traitsPi(Game_BattlerBase.TRAIT_SK_ELEMENT_RATE, stypeId);
  993. };
  994.  
  995. Game_BattlerBase.prototype.elItemRate = function(itypeId) {
  996.     var customrates = this.customElementRates(3);
  997.     if ((customrates[itypeId]) && (customrates[itypeId] != '')) {
  998.     try {   var result = this.traitsPi(Game_BattlerBase.TRAIT_SK_ELEMENT_RATE + 2000, itypeId);
  999.         eval(customrates[itypeId]);
  1000.         return result;
  1001.         }
  1002.     catch (e) {if(ICF.Param.ElemCoreHalt){throw new Error('Error in custom item damage rate #' + itypeId + ' for battler');}}
  1003.     }
  1004.     return this.traitsPi(Game_BattlerBase.TRAIT_SK_ELEMENT_RATE + 2000, itypeId);
  1005. };
  1006.  
  1007. Game_BattlerBase.prototype.elWeaponRate = function(wtypeId) {
  1008.     var customrates = this.customElementRates(1);
  1009.     if ((customrates[wtypeId]) && (customrates[wtypeId] != '')) {
  1010.     try {   var result = this.traitsPi(Game_BattlerBase.TRAIT_WP_ELEMENT_RATE, wtypeId);
  1011.         eval(customrates[wtypeId]);
  1012.         return result;
  1013.         }
  1014.     catch (e) {if(ICF.Param.ElemCoreHalt){throw new Error('Error in custom weapon rate #' + wtypeId + ' for battler');}}
  1015.     }
  1016.     return this.traitsPi(Game_BattlerBase.TRAIT_WP_ELEMENT_RATE, wtypeId);
  1017. };
  1018.  
  1019. Game_BattlerBase.prototype.wpAttackElements = function() {
  1020.     var wpns = this.traitsSet(Game_BattlerBase.TRAIT_ATTACK_WP_ELEMENT);
  1021.     wpns.removeRepeated();
  1022.     return wpns;
  1023. };
  1024.  
  1025. Game_BattlerBase.prototype.ADVelementRate = function(elementId, subject) {
  1026.     return this.elementRate(elementId) * (subject == undefined)? 1 : subject.elementEnhace(elementId);
  1027. };
  1028.  
  1029. Game_BattlerBase.prototype.ADVelSkillRate = function(stypeId, subject) {
  1030.     return this.elSkillRate(stypeId) * (subject == undefined)? 1 : subject.skillEnhace(stypeId);
  1031. };
  1032.  
  1033. Game_BattlerBase.prototype.ADVelItemRate = function(itypeId, subject) {
  1034.     return this.elItemRate(itypeId) * (subject == undefined)? 1 : subject.atItemEnhace(itypeId);
  1035. };
  1036.  
  1037. Game_BattlerBase.prototype.ADVelWeaponRate = function(wtypeId, subject) {
  1038.     return this.elWeaponRate(wtypeId) * (subject == undefined)? 1 : subject.weaponEnhace(wtypeId);
  1039. };
  1040.  
  1041. //=============================================================================
  1042. // Game_Actor
  1043. //=============================================================================
  1044.  
  1045. Game_Actor.prototype.wpAttackElements = function() {
  1046.     var wpns = [];
  1047.     if (this.weapons().length > 0) {
  1048.     wpns = this.weapons().reduce(function(r, obj) {
  1049.         return r.concat([obj.wtypeId]);
  1050.     }, []);
  1051.     wpns.removeRepeated();
  1052.     return wpns;
  1053.     }
  1054.  
  1055.     wpns = Game_BattlerBase.prototype.wpAttackElements.call(this);
  1056.     if (wpns.length == 0) wpns[0] = 0;
  1057.  
  1058.     return wpns;
  1059. };
  1060.  
  1061. Game_Actor.prototype.customElementRates = function(data) {
  1062.     return $dataActors[this._actorId].customElementRates[data];
  1063. };
  1064.  
  1065. //=============================================================================
  1066. // Game_Enemy
  1067. //=============================================================================
  1068.  
  1069. Game_Enemy.prototype.customElementRates = function(data) {
  1070.     return $dataEnemies[this._enemyId].customElementRates[data];
  1071. };
  1072.  
  1073. //=============================================================================
  1074. // Game_Action
  1075. //=============================================================================
  1076.  
  1077. ICF.ElementCore.gameaction_init = Game_Action.prototype.initialize;
  1078. Game_Action.prototype.initialize = function(subject, forcing) {
  1079.     ICF.ElementCore.gameaction_init.call(this, subject, forcing);
  1080.     this.elementReact = [];
  1081. };
  1082.  
  1083. Game_Action.prototype.elementsMaxRate = function(target, elements, subject) {
  1084.     if (elements.length > 0) {
  1085.         return Math.max.apply(null, elements.map(function(elementId) {
  1086.             return target.ADVelementRate(elementId, subject);
  1087.         }, this));
  1088.     } else {
  1089.         return 1;
  1090.     }
  1091. };
  1092.  
  1093. Game_Action.prototype.elementsMinRate = function(target, elements, subject) {
  1094.     if (elements.length > 0) {
  1095.         return Math.min.apply(null, elements.map(function(elementId) {
  1096.             return target.ADVelementRate(elementId, subject);
  1097.         }, this));
  1098.     } else {
  1099.         return 1;
  1100.     }
  1101. };
  1102.  
  1103. Game_Action.prototype.elementsAverageRate = function(target, elements, subject) {
  1104.     if (elements.length > 0) {
  1105.         return elements.reduce(function(r, element) {
  1106.             return r + target.ADVelementRate(element, subject);
  1107.         }, 0) / elements.length;
  1108.     } else {
  1109.         return 1;
  1110.     }
  1111. };
  1112.  
  1113. Game_Action.prototype.wpElementsMaxRate = function(target, wpelements, subject) {
  1114.     if (wpelements.length > 0) {
  1115.         return Math.max.apply(null, wpelements.map(function(wpelementId) {
  1116.             return target.ADVelWeaponRate(wpelementId, subject);
  1117.         }, this));
  1118.     } else {
  1119.         return 1;
  1120.     }
  1121. };
  1122.  
  1123. Game_Action.prototype.wpElementsMinRate = function(target, wpelements, subject) {
  1124.     if (wpelements.length > 0) {
  1125.         return Math.min.apply(null, wpelements.map(function(wpelementId) {
  1126.             return target.ADVelWeaponRate(wpelementId, subject);
  1127.         }, this));
  1128.     } else {
  1129.         return 1;
  1130.     }
  1131. };
  1132.  
  1133. Game_Action.prototype.wpElementsAverageRate = function(target, wpelements, subject) {
  1134.     if (wpelements.length > 0) {
  1135.         return wpelements.reduce(function(r, wpelement) {
  1136.             return r + target.ADVelWeaponRate(wpelement, subject);
  1137.         }, 0) / wpelements.length;
  1138.     } else {
  1139.         return 1;
  1140.     }
  1141. };
  1142.  
  1143. Game_Action.prototype.calcWeaponElementRate = function(target) {
  1144.     var rate = 1;
  1145.     var wpns = this.subject().wpAttackElements();
  1146.     if (wpns.length > 0) {
  1147.     if (ICF.Param.ElementBlend == 0) {
  1148.         rate = this.wpElementsAverageRate(target, wpns, this.subject());
  1149.     } else if (ICF.Param.ElementBlend == 3) {
  1150.         rate = this.wpElementsMinRate(target, wpns, this.subject());
  1151.     } else {
  1152.         rate = this.wpElementsMaxRate(target, wpns, this.subject());
  1153.     }
  1154.     }
  1155.  
  1156.     if (wpns.length > 0) this.elementReact.push(["weapreact",wpns]);
  1157.  
  1158.     return rate;
  1159. };
  1160.  
  1161. Game_Action.prototype.calcElementRate = function(target) {
  1162.     var rate = 1;
  1163.     var rate2 = 0;
  1164.     var elements = this.item().damage.elements;
  1165.  
  1166.     if (this.item().damage.elementId < 0) {
  1167.     elements = elements.concat(this.subject().attackElements());
  1168.     }
  1169.  
  1170.     elements.removeRepeated();
  1171.  
  1172.     if (elements.length > 0) this.elementReact.push(["elemreact",elements]);
  1173.  
  1174.     if (ICF.Param.ElementBlend == 0) {
  1175.     rate = this.elementsAverageRate(target, elements, this.subject());
  1176.     } else if (ICF.Param.ElementBlend == 3) {
  1177.     rate = this.elementsMinRate(target, elements, this.subject());
  1178.     } else {
  1179.     rate = this.elementsMaxRate(target, elements, this.subject());
  1180.     rate2 = this.elementsMinRate(target, elements, this.subject());
  1181.     if (ICF.Param.ElementBlend == 2 && rate2 < 0) rate = rate2;
  1182.     }
  1183.  
  1184.     if (this.isSkill()) {
  1185.     if (this.item().stypeId > 0) this.elementReact.push(["skillreact",[this.item().stypeId]]);
  1186.     if ((this.item().stypeId > 0)&&(this.isMagical())) {
  1187.         rate2 = target.ADVelSkillRate(this.item().stypeId, this.subject());
  1188.         if ((rate < 0)||(rate2 < 1)) {rate = rate * rate2;}
  1189.         else {rate += rate2 - 1;}
  1190.     }
  1191.     if ((this.isPhysical())||(this.item().damage.elementId < 0)) {
  1192.         rate2 = this.calcWeaponElementRate(target) + rate;
  1193.         if (rate2 > 2) {rate = rate2 - 1;}
  1194.         else {rate = rate2 / 2;}
  1195.     }
  1196.     if ((this.item().stypeId > 0)&&(!this.isMagical())) {
  1197.         rate2 = target.ADVelSkillRate(this.item().stypeId, this.subject());
  1198.         if ((rate < 0)||(rate2 < 1)) {rate = rate * rate2;}
  1199.         else {rate += rate2 - 1;}
  1200.     }
  1201.     } else if (this.isItem()) {
  1202.     if (this.item().damage.itype > 0) this.elementReact.push(["itemdamreact",[this.item().damage.itype]]);
  1203.     if ((this.item().damage.itype > 0)&&(this.isMagical())) {
  1204.         rate2 = target.ADVelItemRate(this.item().damage.itype, this.subject());
  1205.         if ((rate < 0)||(rate2 < 1)) {rate = rate * rate2;}
  1206.         else {rate += rate2 - 1;}
  1207.     }
  1208.     if ((this.isPhysical())||(this.item().damage.elementId < 0)) {
  1209.         rate2 = this.calcWeaponElementRate(target) + rate;
  1210.         if (rate2 > 2) {rate = rate2 - 1;}
  1211.         else {rate = rate2 / 2;}
  1212.     }
  1213.     if ((this.item().damage.itype > 0)&&(!this.isMagical())) {
  1214.         rate2 = target.ADVelItemRate(this.item().damage.itype, this.subject());
  1215.         if ((rate < 0)||(rate2 < 1)) {rate = rate * rate2;}
  1216.         else {rate += rate2 - 1;}
  1217.     }
  1218.     }
  1219.  
  1220.     return rate;
  1221. };
  1222.  
  1223. ICF.ElementCore.gameaction_apply = Game_Action.prototype.apply;
  1224. Game_Action.prototype.apply = function(target) {
  1225.     ICF.ElementCore.gameaction_apply.call(this, target);
  1226.     if ((!target.result().isHit()) && (this.elementReact.length > 0) && (this.elementReact[0][0] == "elemreact")) this.elementReact.splice(0, 1);
  1227.     if ((target.hp > 0) && (this.elementReact.length > 0)) target.jsevalBulkReactions(this.subject(), this.item(), this.isSkill(), this.elementReact);
  1228. }
  1229.  
  1230. //=============================================================================
  1231. // Game_Item
  1232. //=============================================================================
  1233.  
  1234. Game_Item.prototype.absorbingElements = function() {
  1235.     return this.traitDataTypes(17);
  1236. };
  1237.  
  1238. Game_Item.prototype.cursingElements = function() {
  1239.     return this.traitDataTypes(18);
  1240. };
  1241.  
  1242. Game_Item.prototype.resistingElements = function() {
  1243.     return this.traitDataTypes(11);
  1244. };
  1245.  
  1246. Game_Item.prototype.resistingSkills = function() {
  1247.     return this.traitDataTypesOffset(15, 0, 1999);
  1248. };
  1249.  
  1250. Game_Item.prototype.resistingWeapons = function() {
  1251.     return this.traitDataTypes(16);
  1252. };
  1253.  
  1254. Game_Item.prototype.resistingItemDamages = function() {
  1255.     return this.traitDataTypesOffset(15, 2000, 3999);
  1256. };
  1257.  
  1258. Game_Item.prototype.attackingElements = function() {
  1259.     return this.traitDataTypes(35);
  1260. };
  1261.  
  1262. Game_Item.prototype.enhaceTypes = function() {
  1263.     return this.traitDataTypes(36);
  1264. };
  1265.  
  1266. Game_Item.prototype.elementEnhaceTypes = function() {
  1267.     return this.traitDataTypesOffset(36, 0, 1999);
  1268. };
  1269.  
  1270. Game_Item.prototype.skillEnhaceTypes = function() {
  1271.     return this.traitDataTypesOffset(36, 2000, 3999);
  1272. };
  1273.  
  1274. Game_Item.prototype.weaponEnhaceTypes = function() {
  1275.     return this.traitDataTypesOffset(36, 4000, 5999);
  1276. };
  1277.  
  1278. Game_Item.prototype.itemDamageEnhaceTypes = function() {
  1279.     return this.traitDataTypesOffset(36, 6000, 7999);
  1280. };
  1281.  
  1282. Game_Item.prototype.elements = function() {
  1283.     if (this.isSkill() || this.isItem()) return this.object().damage.elements;
  1284.     if (this.isWeapon() || this.isArmor()) return this.attackingElements();
  1285.     return [];
  1286. };
  1287.  
  1288. //=============================================================================
  1289. // End of File
  1290. //=============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement