Advertisement
ICF-Soft

ICF-Soft Main Utility 1.02 RPG Maker MV

Jan 13th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // ICF-Soft Plugins - Main Utility
  3. // ICFSoft_MainUtility.js
  4. //=============================================================================
  5.  
  6. var Imported = Imported || {};
  7. Imported.ICFSoft_MainUtility = true;
  8.  
  9. var ICF = ICF || {};
  10. ICF.MainUtility = ICF.MainUtility || {};
  11.  
  12. ICF.MainUtility.Version = 102; // 1.02
  13.  
  14. //=============================================================================
  15.  /*:
  16.  * @plugindesc v1.02 A sdk plugin with a lot of utilities for game
  17.  * and plugin developers.
  18.  * @author ICF-Soft [http://icfsoft.blogspot.com.es/]
  19.  *
  20.  * @help
  21.  * ============================================================================
  22.  * Introduction
  23.  *
  24.  * This is a sdk plugin with a lot of utilities to script easier.
  25.  * It's needed for the mayority of my plugins to work.
  26.  *
  27.  * It includes:
  28.  *  -Special json feature to edit/add data fields.
  29.  *  -Special trait system allowing to add traits to non-trait data (skills
  30.  *      and items), add actor/enemy traits ingame plus a subtraits system.
  31.  *  -Special effects system allowing to add effects to non-effect data (actors,
  32.  *      classes, enemies...) plus a subeffects system.
  33.  *  -Self and battle switchs/variables system.
  34.  *  -Javascript runing system.
  35.  *  -Extended features for some js built-in objects.
  36.  *
  37.  * ============================================================================
  38.  * How to use
  39.  * ============================================================================
  40.  *
  41.  * It uses notetags to add/alter data.
  42.  * For plugin developers it's recommended to show how to use these tags
  43.  * inside your plugins.
  44.  *
  45.  *
  46.  * Json master tag allow to alter data in a particular way. You
  47.  * can add new fields or edit out of field limits, it works in
  48.  * json notation, better than just meta-tags.
  49.  *
  50.  * Use every line between open and close tags to edit a field, first
  51.  * field name followed by a two dots symbol, then one space and the
  52.  * code in json format.
  53.  *
  54.  * Example:
  55.  *
  56.  * <JSON MASTER>
  57.  * gold: 50000000
  58.  * hands_power: [50,100]
  59.  * grade: 'F'
  60.  * </JSON MASTER>
  61.  *
  62.  *
  63.  * Traits master tag allow to add traits througth notebox.
  64.  * Every line between open and close tags are three numbers separated
  65.  * by spaces. It is recomended to use the three numbers even if specified
  66.  * trait uses only two, next inline place can be used for comments.
  67.  * You can use a name instead of first number (see readme for all names).
  68.  *
  69.  * Example:
  70.  *
  71.  * <TRAITS MASTER>
  72.  * elem_rate 1 1.5
  73.  * 21 1 2
  74.  * 31 2 0 -Attack element
  75.  * </TRAITS MASTER>
  76.  *
  77.  *
  78.  * Subtraits master tag allow to add more trait setups for different
  79.  * uses like subclass traits, random enemy/item/equipment traits,
  80.  * alter states tiers and so on. It works like traits master but you
  81.  * dont't need to close tag every time you open a new subtrait setup.
  82.  *
  83.  * Example:
  84.  *
  85.  * <SUBTRAITS MASTER> -Fire slime
  86.  * elem_rate 1 1.5
  87.  * 11 2 0.5
  88.  * 31 2 0 -Fire attack element
  89.  * <SUBTRAITS MASTER> -Cold slime
  90.  * elem_rate 1 1.5
  91.  * 11 2 2.1
  92.  * 31 3 0 -Cold attack element
  93.  * </SUBTRAITS MASTER>
  94.  *
  95.  * Note: More than one plugin can use subtraits in same data for different
  96.  * purposes so you must provide a way to use specific blocks, something
  97.  * like "<MyAmacingPluginSubtraits first last>" can be usefull.
  98.  *
  99.  * To access a subtrait setup use 'item.subtraits[i].traits' instead of
  100.  * 'item.traits', where 'i' is the index.
  101.  * And for trait items use 'item.subtraits[i]' instead of 'item'.
  102.  *
  103.  * Effects master and Subeffects master tags work like traits/subtraits
  104.  * ones but are used for effects and effect setups, and need four numbers.
  105.  * You can use a name instead of first number (see readme for all names
  106.  * and how to use).
  107.  *
  108.  * Examples:
  109.  *
  110.  * <EFFECTS MASTER>
  111.  * recover_hp 0 0.5 50
  112.  * gain_tp 0 10 0
  113.  * </EFFECTS MASTER>
  114.  *
  115.  * <SUBEFFECTS MASTER>
  116.  * recover_mp 0 0.5 50
  117.  * gain_tp 0 5 0
  118.  * <SUBEFFECTS MASTER>
  119.  * recover_hp 0 0.5 50
  120.  * gain_tp 0 10 0
  121.  * </SUBEFFECTS MASTER>
  122.  *
  123.  *
  124.  * JSEval master tag allow to add javascript code that can be run
  125.  * when a condition is given or diverse pourposes.
  126.  * You can give single key, double key or more, and you dont't need
  127.  * to close tag every time you open a new code.
  128.  *
  129.  * Example:
  130.  *
  131.  * <JSEVAL MASTER A>
  132.  * this.gainTp(15);
  133.  * <JSEVAL MASTER A B>
  134.  * if (this == subject) this.gainMp(-10);
  135.  * v.setValue(10, v.value(10) + 2);
  136.  * </JSEVAL MASTER>
  137.  *
  138.  * Some variables are passed and can be used inside code:
  139.  *   - subject: the subject of the action.
  140.  *   - item: the object used in the action. Can be an item or a skill.
  141.  *   - isSkill: check if is an skill.
  142.  *
  143.  * ============================================================================
  144.  * Battle Switches and Variables
  145.  * ============================================================================
  146.  *
  147.  * These are new reciclable switches an variables that are reset every
  148.  * battle. Are usefull in battle and help making battle steps without
  149.  * touching persistent switches or variables.
  150.  *
  151.  * Can be usefull for plugins that affect battles.
  152.  *
  153.  * See readme file for more info.
  154.  *
  155.  * ============================================================================
  156.  * Plugin Commands
  157.  * ============================================================================
  158.  *
  159.  * selfswitch x true/false
  160.  * mapswitch x true/false
  161.  * actorswitch actorid x true/false
  162.  * enemyswitch enemyid x true/false
  163.  * battleswitch x true/false
  164.  * actorbattleswitch actorid x true/false
  165.  * enemybattleswitch enemyposition x true/false
  166.  *
  167.  *  - Turns on/off specified selfswitch or mapswitch.
  168.  *    You can also use an actorswitch and battle ones.
  169.  *
  170.  * remoteswitch mapid eventid x true/false
  171.  *
  172.  *  - Turns on/off specified selfswitch or mapswitch remotely.
  173.  *    Use eventid 0 for a mapswitch.
  174.  *
  175.  * selfvariable x value
  176.  * mapvariable x value
  177.  * actorvariable actorid x value
  178.  * enemyvariable enemyid x value
  179.  * battlevariable x value
  180.  * actorbattlevariable actorid x value
  181.  * enemybattlevariable enemyposition x value
  182.  *
  183.  *  - Changes value of specified selfvariable or mapvariable.
  184.  *    You can also use an actorvariable.
  185.  *    You can put increase/multiply/divide/mod prefix.
  186.  *
  187.  * remotevariable mapid eventid x value
  188.  *
  189.  *  - Changes value of specified selfvariable or mapvariable remotely.
  190.  *    Use eventid 0 for a mapvariable.
  191.  *    You can put increase/multiply/divide/mod prefix.
  192.  *
  193.  * actortraitadd actorid code id value
  194.  * partymembertraitadd actorpos code id value
  195.  * enemytraitadd enemy code id value
  196.  *
  197.  *  - Adds an ingame trait to specified actor, actor in party or
  198.  *    in battle enemy.
  199.  *    Doesn't check for repeated traits (same code and id).
  200.  *
  201.  * actortrait actorid code id value
  202.  * partymembertrait actorpos code id value
  203.  * enemytrait enemy code id value
  204.  *
  205.  *  - Ensures an ingame trait to specified actor, actor in party or
  206.  *    in battle enemy. If there isn't it'll be added, if there is at least
  207.  *    one it'll be replaced and all repeated traits will be removed.
  208.  *
  209.  * actortraitplus actorid code id value
  210.  * partymembertraitplus actorpos code id value
  211.  * enemytraitplus enemy code id value
  212.  *
  213.  *  - Increase existing ingame trait to specified actor, actor in party or
  214.  *    in battle enemy by a value. If there isn't it'll be added, and
  215.  *    every repeated trait will be merged togeder by sum.
  216.  *
  217.  * actortraitrate actorid code id value
  218.  * partymembertraitrate actorpos code id value
  219.  * enemytraitrate enemy code id value
  220.  *
  221.  *  - Multiply existing ingame trait to specified actor, actor in party or
  222.  *    in battle enemy by a value. If there isn't it'll be added, and
  223.  *    every repeated trait will be merged togeder by multiplication.
  224.  *
  225.  * removeactortrait actorid code id
  226.  * removepartymembertrait actorpos code id
  227.  * removeenemytraitenemy code id
  228.  *
  229.  *  - Remove all ingame traits with specified code and id to specified actor,
  230.  *    actor in party or in battle enemy.
  231.  *
  232.  * clearactortraits actorid
  233.  * clearpartymembertraits actorpos
  234.  * clearenemytraits enemy
  235.  *
  236.  *  - Remove all ingame traits to specified actor, actor in party or in
  237.  *    battle enemy.
  238.  *
  239.  * ============================================================================
  240.  * Scripting functions
  241.  * ============================================================================
  242.  *
  243.  * Scripting functions are more complex. Read readme file.
  244.  *
  245.  * ============================================================================
  246.  * Incompatibilities
  247.  * ============================================================================
  248.  *
  249.  * There's no known incompatible plugins yet.
  250.  *
  251.  * ============================================================================
  252.  * Known isues
  253.  * ============================================================================
  254.  *
  255.  * Not yet.
  256.  *
  257.  * ============================================================================
  258.  * Changelog
  259.  * ============================================================================
  260.  *
  261.  * Version 1.02:
  262.  * - Extended battle and self switches and variables to all actors/enemies.
  263.  * - Added group effect system.
  264.  * - Improved trait system.
  265.  *
  266.  * Version 1.01:
  267.  * - Added battle switches and variables.
  268.  * - Added eval system.
  269.  * - Added more js functions.
  270.  *
  271.  * Version 1.00:
  272.  * - Finished plugin!
  273.  *
  274.  * ============================================================================
  275.  *
  276.  * For commercial and non-commercial games.
  277.  * Credit to ICF-Soft.
  278.  * Any plugin that needs this to work must add a clausule to say that ICF-Soft
  279.  * must be included in credits page.
  280.  * This entire header and plugin readme files must be included with plugin.
  281.  *
  282.  * ============================================================================
  283. */
  284. //=============================================================================
  285.  /*:es
  286.  * @plugindesc v1.02 Librería sdk con muchas utilidades para desarrolladores
  287.  * de juegos y complementos.
  288.  * @author ICF-Soft [http://icfsoft.blogspot.com.es/]
  289.  *
  290.  * @help
  291.  * ============================================================================
  292.  * Introducción
  293.  * ============================================================================
  294.  *
  295.  * Este complemento es una librería sdk con un montón de utilidades para
  296.  * programar más fácil.
  297.  * Es necesario para la mayoría de mis complementos.
  298.  *
  299.  * Incluye:
  300.  *  -Sistema json para editar/añadir campos.
  301.  *  -sistema especial de características que permite añadir características
  302.  *      en datos que normalmente no tienen (habilidades y objetos), añadir
  303.  *      características a los personajes y enemigos durante el juego y un
  304.  *      sistema especial de subcaracterísticas.
  305.  *  -Sistema especial de efectos system que permite añadir efectos en datos
  306.  *      que normalmente no tienen (actoers, clases, enemigos...) y un
  307.  *      sistema especial de sub-efectos.
  308.  *  -Sistema de interruptores y variables locales y de batalla.
  309.  *  -Sistema de ejecución de código javascript.
  310.  *  -Funciones extra para algunos objetos predefinidos de javascript.
  311.  *
  312.  * ============================================================================
  313.  * Uso
  314.  * ============================================================================
  315.  *
  316.  * Para añadir o editar datos se utilizan las etiquetas en las notas.
  317.  * Para desarrolladores de plugins se recomienda que se muestre cómo usarlas
  318.  * en sus plugins.
  319.  *
  320.  *
  321.  * La etiqueta 'Json master' permite alterar los datos de un modo particular.
  322.  * Puedes añadir nuevos campos o editarlos sin las restricciones predeterminadas,
  323.  * funciona en notación json, mejor que las simples etiquetas meta.
  324.  *
  325.  * Utiliza cada linea entre las etiquetas de abertura y cierre para editar
  326.  * un campo, primero el nombre del campo, luego dos puntos, un espacio y el
  327.  * código en formato json.
  328.  *
  329.  * Ejemplo:
  330.  *
  331.  * <JSON MASTER>
  332.  * gold: 50000000
  333.  * hands_power: [50,100]
  334.  * alias: 'Romistrugio'
  335.  * </JSON MASTER>
  336.  *
  337.  *
  338.  * La etiqueta 'Traits master' permite añadir características o rasgos.
  339.  * En cada linea entre las etiquetas de apertura y cierre van tres números
  340.  * separados por espacios. Se recomienda usar los tres aún cuando el rasgo
  341.  * solo necesite dos, puedes continuar la linea con comentarios.
  342.  * Puedes usar un nombre en lugar del primer número (en el archivo leeme
  343.  * puedes encontrar todos los disponibles).
  344.  *
  345.  * Ejemplo:
  346.  *
  347.  * <TRAITS MASTER>
  348.  * elem_rate 1 1.5
  349.  * 21 1 2
  350.  * 31 2 0 -Elemento de ataque
  351.  * </TRAITS MASTER>
  352.  *
  353.  *
  354.  * La etiqueta 'Subtraits master' permite añadir conjuntos de rasgos para
  355.  * diferentes usos tales como rasgos de subclase, rasgos aleatorios para
  356.  * enemigos/objetos/armas, fases de un estado alterado y más.
  357.  * Funciona como la etiqueta anterior pero no necesitas cerrar antes de abrir
  358.  * un nuevo subconjunto.
  359.  *
  360.  * Ejemplo:
  361.  *
  362.  * <SUBTRAITS MASTER> -Limo de fuego
  363.  * elem_rate 1 1.5
  364.  * 11 2 0.5
  365.  * 31 2 0 -Ataca con fuego
  366.  * <SUBTRAITS MASTER> -Limo de hielo
  367.  * elem_rate 1 1.5
  368.  * 11 2 2.1
  369.  * 31 3 0 -Ataca con hielo
  370.  * </SUBTRAITS MASTER>
  371.  *
  372.  * Nota: Varios complementos pueden usar subconjuntos para las mismas tablas
  373.  * de la base de datos para diferentes propósitos, de modo que debes
  374.  * proveer un modo de usar subconjuntos específicos, por ejemplo algo así
  375.  * como "<MiIncreiblePluginSubtraits primero ultimo>" podría ser útil.
  376.  *
  377.  * Para acceder a un subconjunto se utiliza 'item.subtraits[i].traits' en
  378.  * lugar de 'item.traits', donde 'i' es el índice.
  379.  * Y para el objeto del subconjunto usar 'item.subtraits[i]' en lugar de 'item'.
  380.  *
  381.  *
  382.  * Las etiquetas 'Effects master' y 'Subeffects master' funcionan de un modo
  383.  * similar a las traits/subtraits pero se usan para efectos sus grupos.
  384.  * Estas requieren el uso de cuatro números.
  385.  * Puedes usar un nombre en lugar del primer número (en el archivo leeme
  386.  * puedes encontrar todos los disponibles).
  387.  *
  388.  * Ejemplos:
  389.  *
  390.  * <EFFECTS MASTER>
  391.  * recover_hp 0 0.5 50
  392.  * gain_tp 0 10 0
  393.  * </EFFECTS MASTER>
  394.  *
  395.  * <SUBEFFECTS MASTER>
  396.  * recover_mp 0 0.5 50
  397.  * gain_tp 0 5 0
  398.  * <SUBEFFECTS MASTER>
  399.  * recover_hp 0 0.5 50
  400.  * gain_tp 0 10 0
  401.  * </SUBEFFECTS MASTER>
  402.  *
  403.  *
  404.  * La etiqueta 'JSEval master' permite añadir código javascript que se
  405.  * ejecutará en condiciones específicas o diversos propósitos.
  406.  * Se puede hacer de una clave, dos o las que hagan falta, y no hace falta
  407.  * cerrar la etiqueta cuando se ponen consecutivas.
  408.  *
  409.  * Ejemplo:
  410.  *
  411.  * <JSEVAL MASTER A>
  412.  * this.gainTp(15);
  413.  * <JSEVAL MASTER A B>
  414.  * if (this == subject) this.gainMp(-10);
  415.  * v.setValue(10, v.value(10) + 2);
  416.  * </JSEVAL MASTER>
  417.  *
  418.  * Hay algunas variables a las que se puede acceder dentro del código:
  419.  *   - subject: el sujeto de la acción.
  420.  *   - item: el objeto usado en la acción. Puede ser un objeto o habilidad.
  421.  *   - isSkill: comprueba si se trata de una habilidad.
  422.  *
  423.  * ============================================================================
  424.  * Interruptores y Variables de Batalla
  425.  * ============================================================================
  426.  *
  427.  * Son nuevos interruptores y variables reciclables que se reinician en
  428.  * cada batalla. Útiles para dividir la batalla en fases sin tocar otros
  429.  * interruptores o variables.
  430.  *
  431.  * Muy útiles para plugins que afectan las batallas.
  432.  *
  433.  * Para más información ver el archivo leeme.
  434.  *
  435.  * ============================================================================
  436.  * Comandos de complemento
  437.  * ============================================================================
  438.  *
  439.  * selfswitch x true/false
  440.  * mapswitch x true/false
  441.  * actorswitch actorid x true/false
  442.  * enemyswitch enemyid x true/false
  443.  * battleswitch x true/false
  444.  * actorbattleswitch actorid x true/false
  445.  * enemybattleswitch enemyposition x true/false
  446.  *
  447.  *  - Activa o desactiva el autointerruptor, interruptor de mapa
  448.  *    o de personaje.
  449.  *
  450.  * remoteswitch mapid eventid x true/false
  451.  *
  452.  *  - Activa o desactiva el autointerruptor o interruptor de mapa específico
  453.  *    de forma remota. Usar eventid 0 para interruptor de mapa.
  454.  *
  455.  * selfvariable x value
  456.  * mapvariable x value
  457.  * actorvariable actorid x value
  458.  * enemyvariable enemyid x value
  459.  * battlevariable x value
  460.  * actorbattlevariable actorid x value
  461.  * enemybattlevariable enemyposition x value
  462.  *
  463.  *  - Cambia el valor de la variable de evento, mapa o personaje.
  464.  *    Se pueden añadir los prefijos increase/multiply/divide/mod.
  465.  *
  466.  * remotevariable mapid eventid x value
  467.  *
  468.  *  - Cambia el valor de la variable de evento o mapa específico
  469.  *    de forma remota. Usar eventid 0 para interruptor de mapa.
  470.  *    Se pueden añadir los prefijos increase/multiply/divide/mod.
  471.  *
  472.  * actortraitadd actorid code id value
  473.  * partymembertraitadd actorpos code id value
  474.  * enemytraitadd enemy code id value
  475.  *
  476.  *  - Añade un rasgo dentro del juego para el personaje, personaje del
  477.  *    grupo o enemigo.
  478.  *    No comprueba si existen repetidos (mismos code e id).
  479.  *
  480.  * actortrait actorid code id value
  481.  * partymembertrait actorpos code id value
  482.  * enemytrait enemy code id value
  483.  *
  484.  *  - Asegura un rasgo dentro del juego para el personaje, personaje del
  485.  *    grupo o enemigo. Si no hay se añade, si hay almenos uno se
  486.  *    sobreescribe y el resto se elimina.
  487.  *
  488.  * actortraitplus actorid code id value
  489.  * partymembertraitplus actorpos code id value
  490.  * enemytraitplus enemy code id value
  491.  *
  492.  *  - Incrementa un rasgo dentro del juego para el personaje, personaje del
  493.  *    grupo o enemigo. Si no hay se añade, si hay almenos uno se
  494.  *    todos los que tenga se combinan mediante suma.
  495.  *
  496.  * actortraitrate actorid code id value
  497.  * partymembertraitrate actorpos code id value
  498.  * enemytraitrate enemy code id value
  499.  *
  500.  *  - Multiplica un rasgo dentro del juego para el personaje, personaje del
  501.  *    grupo o enemigo. Si no hay se añade, si hay almenos uno se
  502.  *    todos los que tenga se combinan mediante multiplicación.
  503.  *
  504.  * removeactortrait actorid code id
  505.  * removepartymembertrait actorpos code id
  506.  * removeenemytraitenemy code id
  507.  *
  508.  *  - Elimina todos los rasgos dentro del juego con código e id específicos
  509.  *    del personaje, personaje del grupo o enemigo.
  510.  *
  511.  * clearactortraits actorid
  512.  * clearpartymembertraits actorpos
  513.  * clearenemytraits enemy
  514.  *
  515.  *  - Elimina todos los rasgos dentro del juego del personaje, personaje
  516.  *    del grupo o enemigo.
  517.  *
  518.  * ============================================================================
  519.  * Funciones de script
  520.  * ============================================================================
  521.  *
  522.  * Las funciones de script son más complejas. Ver archivo léeme..
  523.  *
  524.  * ============================================================================
  525.  * Incompatibilidades
  526.  * ============================================================================
  527.  *
  528.  * No se conocen complementos que sean incompatibles hasta la fecha.
  529.  *
  530.  * ============================================================================
  531.  * Problemas conocidos
  532.  * ============================================================================
  533.  *
  534.  * Por el momento ninguno.
  535.  *
  536.  * ============================================================================
  537.  * Historial de versiones
  538.  * ============================================================================
  539.  *
  540.  * Versión 1.02:
  541.  * - Se han extendido los interruptores y variables locales y de batalla a
  542.  *   todos los personajes y enemigos.
  543.  * - Se ha añadido sistema de efectos y grupos de efectos.
  544.  * - Se ha mejorado el sistema de rasgos.
  545.  *
  546.  * Versión 1.01:
  547.  * - Se han añadido interruptores y variables de batalla.
  548.  * - Se han añadido funciones evaluables.
  549.  * - Se han añadido más funciones extra.
  550.  *
  551.  * Versión 1.00:
  552.  * - Complemento terminado.
  553.  *
  554.  * ============================================================================
  555.  *
  556.  * Para juegos comerciales y no comerciales.
  557.  * Se debe incluir a ICF-Soft en los créditos.
  558.  * Cualquier plugin que necesite este para funcionar debe incluir una cláusula
  559.  * que indique que se debe incluir a ICF-Soft en los créditos.
  560.  * Esta cabecera y los archivos leeme del complemento deben incluirse
  561.  * íntegramente con el plugin.
  562.  *
  563.  * ============================================================================
  564. */
  565. //=============================================================================
  566.  
  567. //=============================================================================
  568. // Parameter Variables
  569. //=============================================================================
  570.  
  571. ICF.Parameters = PluginManager.parameters('ICFSoft_MainUtility');
  572. ICF.Param = ICF.Param || {};
  573.  
  574. //=============================================================================
  575. // Constants
  576. //=============================================================================
  577.  
  578. ICF.MainUtility.traittags = [
  579.     ['elem_rate', 11, 0],
  580.     ['debuffrate', 12, 0],
  581.     ['ndebuffrate', 12, 10],
  582.     ['state_rate', 13, 0],
  583.     ['state_resist', 14, 0],
  584.     ['skill_rate', 15, 0],
  585.     ['itemdamage_rate', 15, 2000],
  586.     ['weapon_rate', 16, 0],
  587.     ['elem_absorb', 17, 0],
  588.     ['elem_curse', 18, 0],
  589.     ['elem_reflect', 19, 0],
  590.     ['paramplus', 21, 10],
  591.     ['paramrate', 21, 0],
  592.     ['paramflat', 21, 20],
  593.     ['paramxrate', 21, 30],
  594.     ['paramxflat', 21, 40],
  595.     ['xparamplus', 22, 0],
  596.     ['xparamrate', 22, 10],
  597.     ['xparamflat', 22, 20],
  598.     ['sparamplus', 23, 10],
  599.     ['sparamrate', 23, 0],
  600.     ['sparamflat', 23, 20],
  601.     ['nparamplus', 24, 0],
  602.     ['nparamrate', 24, 100],
  603.     ['nparamflat', 24, 200],
  604.     ['nparamxrate', 24, 300],
  605.     ['nparamxflat', 24, 400],
  606.     ['pparamplus', 25, 0],
  607.     ['pparamrate', 25, 100],
  608.     ['pparamflat', 25, 200],
  609.     ['attack_elem', 31, 0],
  610.     ['attack_state', 32, 0],
  611.     ['attack_speed', 33, 0],
  612.     ['attack_times', 34, 0],
  613.     ['attack_weapon', 35, 0],
  614.     ['elem_enhace', 36, 0],
  615.     ['skill_enhace', 36, 2000],
  616.     ['weapon_enhace', 36, 4000],
  617.     ['itemdamage_enhace', 36, 6000],
  618.     ['stypeadd', 41, 0],
  619.     ['stypeseal', 42, 0],
  620.     ['skilladd', 43, 0],
  621.     ['skillseal', 44, 0],
  622.     ['equipweapon', 51, 0],
  623.     ['equiparmor', 52, 0],
  624.     ['equiplock', 53, 0],
  625.     ['equipseal', 54, 0],
  626.     ['slot_type', 55, 0],
  627.     ['action_plus', 61, 0],
  628.     ['special_flag', 62, 0],
  629.     ['collapse_type', 63, 0],
  630.     ['party_ability', 64, 0]
  631. ];
  632.  
  633. ICF.MainUtility.effecttags = [
  634.     ['recover_hp', 11, 0],
  635.     ['recover_mp', 12, 0],
  636.     ['gain_tp', 13, 0],
  637.     ['add_state', 21, 0],
  638.     ['remove_state', 22, 0],
  639.     ['add_buff', 31, 0],
  640.     ['add_debuff', 32, 0],
  641.     ['remove_buff', 33, 0],
  642.     ['remove_debuff', 34, 0],
  643.     ['add_nbuff', 35, 0],
  644.     ['add_ndebuff', 36, 0],
  645.     ['remove_nbuff', 37, 0],
  646.     ['remove_ndebuff', 38, 0],
  647.     ['special', 41, 0],
  648.     ['grow', 42, 0],
  649.     ['learn_skill', 43, 0],
  650.     ['common_event', 44, 0],
  651.     ['ngrow', 45, 0]
  652. ];
  653.  
  654. var $gameSelfvariables    = null;
  655.  
  656. //=============================================================================
  657. // Game_SelfVariables
  658. //=============================================================================
  659.  
  660. function Game_SelfVariables() {
  661.     this.initialize.apply(this, arguments);
  662. }
  663.  
  664. Game_SelfVariables.prototype.initialize = function() {
  665.     this.clear();
  666. };
  667.  
  668. Game_SelfVariables.prototype.clear = function() {
  669.     this._data = {};
  670. };
  671.  
  672. Game_SelfVariables.prototype.value = function(key) {
  673.     return this._data[key] || 0;
  674. };
  675.  
  676. Game_SelfVariables.prototype.strictValue = function(key) {
  677.     var value = Number(this._data[key]);
  678.     return (isNaN(value))? 0 : Number(value);
  679. };
  680.  
  681. Game_SelfVariables.prototype.setValue = function(key, value) {
  682.     if (value) {
  683.         this._data[key] = (isNaN(Number(value))||Array.isArray(value))? value : Number(value);
  684.     } else {
  685.         delete this._data[key];
  686.     }
  687.     this.onChange();
  688. };
  689.  
  690. Game_SelfVariables.prototype.increaseValue = function(key, value) {
  691.     var val = Number(this._data[key] || 0);
  692.     if (isNaN(val)||isNaN(value)) return;
  693.     this._data[key] = Number(this._data[key] || 0) + Number(value);
  694.     this.onChange();
  695. };
  696.  
  697. Game_SelfVariables.prototype.multiplyValue = function(key, value) {
  698.     var val = Number(this._data[key] || 0);
  699.     if (isNaN(val)||isNaN(value)) return;
  700.     this._data[key] = Number(this._data[key] || 0) * Number(value);
  701.     this.onChange();
  702. };
  703.  
  704. Game_SelfVariables.prototype.divideValue = function(key, value) {
  705.     var val = Number(this._data[key] || 0);
  706.     if (isNaN(val)||isNaN(value)||value == 0) return;
  707.     this._data[key] = Number(this._data[key] || 0) / Number(value);
  708.     this.onChange();
  709. };
  710.  
  711. Game_SelfVariables.prototype.modValue = function(key, value) {
  712.     var val = Number(this._data[key] || 0);
  713.     if (isNaN(val)||isNaN(value)||value == 0) return;
  714.     this._data[key] = Number(this._data[key] || 0) % Number(value);
  715.     this.onChange();
  716. };
  717.  
  718. Game_SelfVariables.prototype.onChange = function() {
  719.     $gameMap.requestRefresh();
  720. };
  721.  
  722. //=============================================================================
  723. // Game_BattleSwitches
  724. //=============================================================================
  725.  
  726. function Game_BattleSwitches() {
  727.     this.initialize.apply(this, arguments);
  728. }
  729.  
  730. Game_BattleSwitches.prototype.initialize = function() {
  731.     this.clear();
  732. };
  733.  
  734. Game_BattleSwitches.prototype.clear = function() {
  735.     this._data = {};
  736. };
  737.  
  738. Game_BattleSwitches.prototype.value = function(key) {
  739.     return !!this._data[key];
  740. };
  741.  
  742. Game_BattleSwitches.prototype.setValue = function(key, value) {
  743.     if (value) {
  744.         this._data[key] = true;
  745.     } else {
  746.         delete this._data[key];
  747.     }
  748.     this.onChange();
  749. };
  750.  
  751. Game_BattleSwitches.prototype.onChange = function() {
  752.     //$gameMap.requestRefresh();
  753. };
  754.  
  755. var $gameBattleSwitches = new Game_BattleSwitches();
  756.  
  757. //=============================================================================
  758. // Game_BattleVariables
  759. //=============================================================================
  760.  
  761. function Game_BattleVariables() {
  762.     this.initialize.apply(this, arguments);
  763. }
  764.  
  765. Game_BattleVariables.prototype.initialize = function() {
  766.     this.clear();
  767. };
  768.  
  769. Game_BattleVariables.prototype.clear = function() {
  770.     this._data = {};
  771. };
  772.  
  773. Game_BattleVariables.prototype.value = function(key) {
  774.     return this._data[key] || 0;
  775. };
  776.  
  777. Game_BattleVariables.prototype.strictValue = function(key) {
  778.     var value = Number(this._data[key]);
  779.     return (isNaN(value))? 0 : Number(value);
  780. };
  781.  
  782. Game_BattleVariables.prototype.setValue = function(key, value) {
  783.     if (value) {
  784.         this._data[key] = (isNaN(Number(value))||Array.isArray(value))? value : Number(value);
  785.     } else {
  786.         delete this._data[key];
  787.     }
  788.     this.onChange();
  789. };
  790.  
  791. Game_BattleVariables.prototype.increaseValue = function(key, value) {
  792.     var val = Number(this._data[key] || 0);
  793.     if (isNaN(val)||isNaN(value)) return;
  794.     this._data[key] = Number(this._data[key] || 0) + Number(value);
  795.     this.onChange();
  796. };
  797.  
  798. Game_BattleVariables.prototype.multiplyValue = function(key, value) {
  799.     var val = Number(this._data[key] || 0);
  800.     if (isNaN(val)||isNaN(value)) return;
  801.     this._data[key] = Number(this._data[key] || 0) * Number(value);
  802.     this.onChange();
  803. };
  804.  
  805. Game_BattleVariables.prototype.divideValue = function(key, value) {
  806.     var val = Number(this._data[key] || 0);
  807.     if (isNaN(val)||isNaN(value)||value == 0) return;
  808.     this._data[key] = Number(this._data[key] || 0) / Number(value);
  809.     this.onChange();
  810. };
  811.  
  812. Game_BattleVariables.prototype.modValue = function(key, value) {
  813.     var val = Number(this._data[key] || 0);
  814.     if (isNaN(val)||isNaN(value)||value == 0) return;
  815.     this._data[key] = Number(this._data[key] || 0) % Number(value);
  816.     this.onChange();
  817. };
  818.  
  819. Game_BattleVariables.prototype.onChange = function() {
  820.     //$gameMap.requestRefresh();
  821. };
  822.  
  823. var $gameBattleVariables = new Game_BattleVariables();
  824.  
  825. //=============================================================================
  826. // DataManager
  827. //=============================================================================
  828.  
  829. ICF.MainUtility.extractMetadata = DataManager.extractMetadata;
  830. DataManager.extractMetadata = function(data) {
  831.     ICF.MainUtility.extractMetadata.call(this, data);
  832.     var note1 = /<(?:JSON MASTER)>/i;
  833.     var note1b = /<\/(?:JSON MASTER)>/i;
  834.     var note2 = /<(?:TRAITS MASTER)>/i;
  835.     var note2b = /<\/(?:TRAITS MASTER)>/i;
  836.     var note3 = /<(?:SUBTRAITS MASTER)>/i;
  837.     var note3b = /<\/(?:SUBTRAITS MASTER)>/i;
  838.     var note4 = /<(?:EFFECTS MASTER)>/i;
  839.     var note4b = /<\/(?:EFFECTS MASTER)>/i;
  840.     var note5 = /<(?:SUBEFFECTS MASTER)>/i;
  841.     var note5b = /<\/(?:SUBEFFECTS MASTER)>/i;
  842.     var note6 = /<(?:JSEVAL MASTER)[ ]+(\w+(?:\s+\w+)*)[ ]*>/i;
  843.     var note6b = /<\/(?:JSEVAL MASTER)>/i;
  844.  
  845.     var notedata = data.note.split(/[\r\n]+/);
  846.  
  847.     var flag1 = false;
  848.     var flag2 = false;
  849.     var flag3 = false;
  850.     var flag4 = false;
  851.     var flag5 = false;
  852.     var flag6 = false;
  853.  
  854.     var subindex = -1;
  855.     var subeindex = -1;
  856.  
  857.     data.jsreactions = data.jsreactions || {};
  858.     var key = '';
  859.  
  860.     for (var i = 0; i < notedata.length; i++) {
  861.     var line = notedata[i].trim().replace(/\s+/g, ' ');
  862.     if (line.match(note1)) {
  863.         flag1 = true;
  864.     } else if (line.match(note1b)) {
  865.         flag1 = false;
  866.     } else if (line.match(note2)) {
  867.         flag2 = true;
  868.         data.traits = data.traits || [];
  869.     } else if (line.match(note2b)) {
  870.         flag2 = false;
  871.     } else if (line.match(note3)) {
  872.         flag3 = true;
  873.         subindex += 1;
  874.         data.subtraits = data.subtraits || [];
  875.         data.subtraits[subindex] = data.subtraits[subindex] || {};
  876.         data.subtraits[subindex].traits = data.subtraits[subindex].traits || [];
  877.     } else if (line.match(note3b)) {
  878.         flag3 = false;
  879.     } else if (line.match(note4)) {
  880.         flag4 = true;
  881.         data.effects = data.effects || [];
  882.     } else if (line.match(note4b)) {
  883.         flag4 = false;
  884.     } else if (line.match(note5)) {
  885.         flag5 = true;
  886.         subeindex += 1;
  887.         data.subeffects = data.subeffects || [];
  888.         data.subeffects[subeindex] = data.subeffects[subeindex] || {};
  889.         data.subeffects[subeindex].effects = data.subeffects[subeindex].effects || [];
  890.     } else if (line.match(note5b)) {
  891.         flag5 = false;
  892.     } else if (line.match(note6)) {
  893.         flag6 = true;
  894.         key = RegExp.$1.split(/\s+/);
  895.         data.jsreactions[key] = data.jsreactions[key] || '';
  896.     } else if (line.match(note6b)) {
  897.         flag6 = false;
  898.         key = '';
  899.     } else if (flag1) {
  900.         var field = line.split(":")[0];
  901.         line = line.substring(line.indexOf(':') + 1);
  902.         data[field] = JsonEx.parse(line);
  903.     } else if (flag2) {
  904.         line = line.split(" ").clean();
  905.         if (isNaN(Number(line[0]))) {line = ICF.MainUtility.gettfield(line);};
  906.         if (line[0] > -1) {data.traits.push({code:Number(line[0]), dataId:Number(line[1]), value:Number(line[2])});};
  907.     } else if (flag3) {
  908.         line = line.split(" ").clean();
  909.         if (isNaN(Number(line[0]))) {line = ICF.MainUtility.gettfield(line);};
  910.         if (line[0] > -1) {data.subtraits[subindex].traits.push({code:Number(line[0]), dataId:Number(line[1]), value:Number(line[2])});};
  911.     } else if (flag4) {
  912.         line = line.split(" ").clean();
  913.         if (isNaN(Number(line[0]))) {line = ICF.MainUtility.getefield(line);};
  914.         if (line[0] > -1) {data.effects.push({code:Number(line[0]), dataId:Number(line[1]), value1:Number(line[2]), value2:Number(line[3])});};
  915.     } else if (flag5) {
  916.         line = line.split(" ").clean();
  917.         if (isNaN(Number(line[0]))) {line = ICF.MainUtility.getefield(line);};
  918.         if (line[0] > -1) {data.subeffects[subeindex].effects.push({code:Number(line[0]), dataId:Number(line[1]), value1:Number(line[2]), value2:Number(line[3])});};
  919.     } else if (flag6) {
  920.         data.jsreactions[key] = data.jsreactions[key] + line + '\n';
  921.     }
  922.  
  923.     }
  924. };
  925.  
  926. if (!Imported.ICFSoft_MainCore) {
  927.     ICF.MainUtility.createGameObjects = DataManager.createGameObjects;
  928.     DataManager.createGameObjects = function() {
  929.     ICF.MainUtility.createGameObjects.call(this);
  930.     $gameSelfVariables = new Game_SelfVariables();
  931.     };
  932.  
  933.     ICF.MainUtility.extractSaveContents = DataManager.extractSaveContents;
  934.     DataManager.extractSaveContents = function(contents) {
  935.     ICF.MainUtility.extractSaveContents.call(this, contents);
  936.     $gameSelfVariables = contents.selfVariables;
  937.     if (!$gameSelfVariables) $gameSelfVariables = new Game_SelfVariables();
  938.     };
  939.  
  940.     ICF.MainUtility.makeSaveContents = DataManager.makeSaveContents;
  941.     DataManager.makeSaveContents = function() {
  942.     var contents = ICF.MainUtility.makeSaveContents.call(this);
  943.     contents.selfvariables = $gameSelfvariables;
  944.     return contents;
  945.     };
  946.  
  947. } else {
  948.     ICF.MainUtility.createGameObjects = DataManager.createGameObjectsPhase1;
  949.     DataManager.createGameObjectsPhase1 = function() {
  950.     ICF.MainUtility.createGameObjects.call(this);
  951.     $gameSelfVariables = new Game_SelfVariables();
  952.     };
  953.  
  954.     ICF.MainUtility.extractSaveContents = DataManager.extractSaveContentsPhase1;
  955.     DataManager.extractSaveContentsPhase1 = function(contents) {
  956.     ICF.MainUtility.extractSaveContents.call(this, contents);
  957.     $gameSelfVariables = contents.selfVariables;
  958.     if (!$gameSelfVariables) $gameSelfVariables = new Game_SelfVariables();
  959.     };
  960.  
  961.     ICF.MainUtility.makeSaveContents = DataManager.makeSaveContentsPhase1;
  962.     DataManager.makeSaveContentsPhase1 = function() {
  963.     var contents = ICF.MainUtility.makeSaveContents.call(this);
  964.     contents.selfvariables = $gameSelfvariables;
  965.     return contents;
  966.     };
  967.  
  968. }
  969.  
  970.  
  971. //=============================================================================
  972. // Game_BattlerBase
  973. //=============================================================================
  974.  
  975. ICF.MainUtility.traitObjects = Game_BattlerBase.prototype.traitObjects;
  976. Game_BattlerBase.prototype.traitObjects = function() {
  977.     if (!this._traitsObject) {
  978.     this._traitsObject = {};
  979.     this._traitsObject.traits = [];
  980.     }
  981.     return ICF.MainUtility.traitObjects.call(this).concat([this._traitsObject]);
  982. };
  983.  
  984. ICF.MainUtility.initMembers = Game_BattlerBase.prototype.initMembers;
  985. Game_BattlerBase.prototype.initMembers = function() {
  986.     ICF.MainUtility.initMembers.call(this);
  987.     this._traitsObject = {};
  988.     this._traitsObject.traits = [];
  989. };
  990.  
  991. Game_BattlerBase.prototype.clearTraits = function() {
  992.     if (!this._traitsObject) {
  993.     this._traitsObject = {};
  994.     }
  995.     this._traitsObject.traits = [];
  996. };
  997.  
  998. Game_BattlerBase.prototype.addTrait = function(code, dataid, value) {
  999.     if (!this._traitsObject) {
  1000.     this._traitsObject = {};
  1001.     this._traitsObject.traits = [];
  1002.     }
  1003.     ICF.MainUtility.addTrait(this._traitsObject, 0, code, dataid, value);
  1004. };
  1005.  
  1006. Game_BattlerBase.prototype.setTrait = function(code, dataid, value) {
  1007.     if (!this._traitsObject) {
  1008.     this._traitsObject = {};
  1009.     this._traitsObject.traits = [];
  1010.     }
  1011.     ICF.MainUtility.addTrait(this._traitsObject, 1, code, dataid, value);
  1012. };
  1013.  
  1014. Game_BattlerBase.prototype.increaseTrait = function(code, dataid, value) {
  1015.     if (!this._traitsObject) {
  1016.     this._traitsObject = {};
  1017.     this._traitsObject.traits = [];
  1018.     }
  1019.     ICF.MainUtility.addTrait(this._traitsObject, 2, code, dataid, value);
  1020. };
  1021.  
  1022. Game_BattlerBase.prototype.multiplyTrait = function(code, dataid, value) {
  1023.     if (!this._traitsObject) {
  1024.     this._traitsObject = {};
  1025.     this._traitsObject.traits = [];
  1026.     }
  1027.     ICF.MainUtility.addTrait(this._traitsObject, 3, code, dataid, value);
  1028. };
  1029.  
  1030. Game_BattlerBase.prototype.removeTrait = function(code, dataid) {
  1031.     if (!this._traitsObject) {
  1032.     this._traitsObject = {};
  1033.     this._traitsObject.traits = [];
  1034.     }
  1035.     ICF.MainUtility.removeTrait(this._traitsObject, code, dataid);
  1036. };
  1037.  
  1038. Game_BattlerBase.prototype.selfswitch = function(selfswitch) { return false;};
  1039.  
  1040. Game_BattlerBase.prototype.setselfswitch = function(selfswitch, value) { };
  1041.  
  1042. Game_BattlerBase.prototype.battleswitch = function(selfswitch) { return false;};
  1043.  
  1044. Game_BattlerBase.prototype.setbattleswitch = function(selfswitch, value) { };
  1045.  
  1046. Game_BattlerBase.prototype.selfvariable = function(selfvariable) { return 0;};
  1047.  
  1048. Game_BattlerBase.prototype.strictselfvariable = function(selfvariable) { return 0;};
  1049.  
  1050. Game_BattlerBase.prototype.setselfvariable = function(selfvariable, value) { };
  1051.  
  1052. Game_BattlerBase.prototype.increaseselfvariable = function(selfvariable, value) { };
  1053.  
  1054. Game_BattlerBase.prototype.multiplyselfvariable = function(selfvariable, value) { };
  1055.  
  1056. Game_BattlerBase.prototype.divideselfvariable = function(selfvariable, value) { };
  1057.  
  1058. Game_BattlerBase.prototype.modselfvariable = function(selfvariable, value) { };
  1059.  
  1060. Game_BattlerBase.prototype.battlevariable = function(selfvariable) { return 0;};
  1061.  
  1062. Game_BattlerBase.prototype.strictbattlevariable = function(selfvariable) { return 0;};
  1063.  
  1064. Game_BattlerBase.prototype.setbattlevariable = function(selfvariable, value) { };
  1065.  
  1066. Game_BattlerBase.prototype.increasebattlevariable = function(selfvariable, value) { };
  1067.  
  1068. Game_BattlerBase.prototype.multiplybattlevariable = function(selfvariable, value) { };
  1069.  
  1070. Game_BattlerBase.prototype.dividebattlevariable = function(selfvariable, value) { };
  1071.  
  1072. Game_BattlerBase.prototype.modbattlevariable = function(selfvariable, value) { };
  1073.  
  1074. Game_BattlerBase.prototype.jsevalObjects = function() {
  1075.     return this.states().filter(function(obj) {
  1076.         return Object.keys(obj.jsreactions).length > 0;
  1077.     });
  1078. };
  1079.  
  1080. Game_BattlerBase.prototype.jsevalReactions = function(subject, item, isSkill, reaction) {
  1081.     var jsevalobjects = this.jsevalObjects();
  1082.     var s = $gameSwitches._data;
  1083.     var v = $gameVariables._data;
  1084.  
  1085.     for (var h = 0; h < jsevalobjects.length; h++) {
  1086.     if (jsevalobjects[h].jsreactions[reaction]) eval(jsevalobjects[h].jsreactions[reaction]);
  1087.     }
  1088. };
  1089.  
  1090. Game_BattlerBase.prototype.jsevalArrayReactions = function(subject, item, isSkill, reactions) {
  1091.     var jsevalobjects = this.jsevalObjects();
  1092.     var s = $gameSwitches._data;
  1093.     var v = $gameVariables._data;
  1094.  
  1095.     for (var h = 0; h < jsevalobjects.length; h++) {
  1096.     for (var i = 0; i < reactions.length; i++) {
  1097.         if (jsevalobjects[h].jsreactions[reactions[i]]) eval(jsevalobjects[h].jsreactions[reactions[i]]);
  1098.     }
  1099.     }
  1100. };
  1101.  
  1102. Game_BattlerBase.prototype.jsevalBulkReactions = function(subject, item, isSkill, reactions) {
  1103.     var jsevalobjects = this.jsevalObjects();
  1104.     var s = $gameSwitches._data;
  1105.     var v = $gameVariables._data;
  1106.  
  1107.     for (var h = 0; h < jsevalobjects.length; h++) {
  1108.     for (var i = 0; i < reactions.length; i++) {
  1109.         for (var j = 0; j < reactions[i][1].length; j++) {
  1110.             var key = [reactions[i][0],reactions[i][1][j]];
  1111.             if (jsevalobjects[h].jsreactions[key]) eval(jsevalobjects[h].jsreactions[key]);
  1112.         }
  1113.     }
  1114.     }
  1115. };
  1116.  
  1117. //=============================================================================
  1118. // Game_Battler
  1119. //=============================================================================
  1120.  
  1121. if (!Imported.ICFSoft_MainCore) {
  1122.     Game_Battler.prototype.gainHp = function(value) {
  1123.     this._result.hpDamage -= value;
  1124.     this._result.hpAffected = true;
  1125.     this.setHp(this.hp + value);
  1126.     };
  1127.  
  1128.     Game_Battler.prototype.gainMp = function(value) {
  1129.     this._result.mpDamage -= value;
  1130.     this.setMp(this.mp + value);
  1131.     };
  1132.  
  1133.     Game_Battler.prototype.gainTp = function(value) {
  1134.     this._result.tpDamage -= value;
  1135.     this.setTp(this.tp + value);
  1136.     };
  1137. }
  1138.  
  1139. //=============================================================================
  1140. // Game_Actor
  1141. //=============================================================================
  1142.  
  1143. Game_Actor.prototype.selfswitch = function(selfswitch) {
  1144.     var key = [0, this._actorId, selfswitch];
  1145.     return $gameSelfSwitches.value(key);
  1146. }
  1147.  
  1148. Game_Actor.prototype.setselfswitch = function(selfswitch, value) {
  1149.     ICF.MainUtility.CustomSwitch(0, this._actorId, selfswitch, value);
  1150. }
  1151.  
  1152. Game_Actor.prototype.battleswitch = function(selfswitch) {
  1153.     var key = [0, this._actorId, selfswitch];
  1154.     return $gameBattleSwitches.value(key);
  1155. }
  1156.  
  1157. Game_Actor.prototype.setbattleswitch = function(selfswitch, value) {
  1158.     ICF.MainUtility.BattleSwitch(0, this._actorId, selfswitch, value);
  1159. }
  1160.  
  1161. Game_Actor.prototype.selfvariable = function(selfvariable) {
  1162.     var key = [0, this._actorId, selfvariable];
  1163.     return $gameSelfVariables.value(key);
  1164. }
  1165.  
  1166. Game_Actor.prototype.strictselfvariable = function(selfvariable) {
  1167.     var key = [0, this._actorId, selfvariable];
  1168.     return $gameSelfVariables.strictValue(key);
  1169. }
  1170.  
  1171. Game_Actor.prototype.setselfvariable = function(selfvariable, value) {
  1172.     ICF.MainUtility.CustomVariable(0, this._actorId, selfvariable, value);
  1173. }
  1174.  
  1175. Game_Actor.prototype.increaseselfvariable = function(selfvariable, value) {
  1176.     ICF.MainUtility.IncreaseCustomVariable(0, this._actorId, selfvariable, value);
  1177. }
  1178.  
  1179. Game_Actor.prototype.multiplyselfvariable = function(selfvariable, value) {
  1180.     ICF.MainUtility.MultiplyCustomVariable(0, this._actorId, selfvariable, value);
  1181. }
  1182.  
  1183. Game_Actor.prototype.divideselfvariable = function(selfvariable, value) {
  1184.     ICF.MainUtility.DivideCustomVariable(0, this._actorId, selfvariable, value);
  1185. }
  1186.  
  1187. Game_Actor.prototype.modselfvariable = function(selfvariable, value) {
  1188.     ICF.MainUtility.ModCustomVariable(0, this._actorId, selfvariable, value);
  1189. }
  1190.  
  1191. Game_Actor.prototype.battlevariable = function(battlevariable) {
  1192.     var key = [0, this._actorId, battlevariable];
  1193.     return $gameBattleVariables.value(key);
  1194. }
  1195.  
  1196. Game_Actor.prototype.strictbattlevariable = function(battlevariable) {
  1197.     var key = [0, this._actorId, battlevariable];
  1198.     return $gameBattleVariables.strictValue(key);
  1199. }
  1200.  
  1201. Game_Actor.prototype.setbattlevariable = function(battlevariable, value) {
  1202.     ICF.MainUtility.BattleVariable(0, this._actorId, battlevariable, value);
  1203. }
  1204.  
  1205. Game_Actor.prototype.increasebattlevariable = function(battlevariable, value) {
  1206.     ICF.MainUtility.IncreaseBattleVariable(0, this._actorId, battlevariable, value);
  1207. }
  1208.  
  1209. Game_Actor.prototype.multiplybattlevariable = function(battlevariable, value) {
  1210.     ICF.MainUtility.MultiplyBattleVariable(0, this._actorId, battlevariable, value);
  1211. }
  1212.  
  1213. Game_Actor.prototype.dividebattlevariable = function(battlevariable, value) {
  1214.     ICF.MainUtility.DivideBattleVariable(0, this._actorId, battlevariable, value);
  1215. }
  1216.  
  1217. Game_Actor.prototype.modbattlevariable = function(battlevariable, value) {
  1218.     ICF.MainUtility.ModBattleVariable(0, this._actorId, battlevariable, value);
  1219. }
  1220.  
  1221. Game_Actor.prototype.jsevalObjects = function() {
  1222.     var objects = [this.actor(), this.currentClass()];
  1223.     objects = objects.concat(Game_Battler.prototype.jsevalObjects.call(this));
  1224.     var equips = this.equips();
  1225.     for (var i = 0; i < equips.length; i++) {
  1226.         var item = equips[i];
  1227.         if (item) {
  1228.             objects.push(item);
  1229.         }
  1230.     }
  1231.     return objects.filter(function(obj) {
  1232.         return Object.keys(obj.jsreactions).length > 0;
  1233.     });
  1234. };
  1235.  
  1236. //=============================================================================
  1237. // Game_Enemy
  1238. //=============================================================================
  1239.  
  1240. Game_Enemy.prototype.selfswitch = function(selfswitch) {
  1241.     var key = ["e", this.index(), selfswitch];
  1242.     return $gameSelfSwitches.value(key);
  1243. }
  1244.  
  1245. Game_Enemy.prototype.setselfswitch = function(selfswitch, value) {
  1246.     ICF.MainUtility.CustomSwitch("e", this.index(), selfswitch, value);
  1247. }
  1248.  
  1249. Game_Enemy.prototype.battleswitch = function(battleswitch) {
  1250.     var key = ["e", this.index(), battleswitch];
  1251.     return $gameBattleSwitches.value(key);
  1252. }
  1253.  
  1254. Game_Enemy.prototype.setbattleswitch = function(battleswitch, value) {
  1255.     var key = ["e", this.index(), battleswitch];
  1256.     value = (value.toString().toLowerCase() === "true");
  1257.     $gameBattleSwitches.setValue(key, value);
  1258. }
  1259.  
  1260. Game_Enemy.prototype.selfvariable = function(selfvariable) {
  1261.     var key = ["e", this.index(), selfvariable];
  1262.     return $gameSelfVariables.value(key);
  1263. }
  1264.  
  1265. Game_Enemy.prototype.strictselfvariable = function(selfvariable) {
  1266.     var key = ["e", this.index(), selfvariable];
  1267.     return $gameSelfVariables.strictValue(key);
  1268. }
  1269.  
  1270. Game_Enemy.prototype.setselfvariable = function(selfvariable, value) {
  1271.     var _key = ["e", this.index(), selfvariable];
  1272.     $gameSelfVariables.setValue(_key, value);
  1273. }
  1274.  
  1275. Game_Enemy.prototype.increaseselfvariable = function(selfvariable, value) {
  1276.     var _key = ["e", this.index(), selfvariable];
  1277.     $gameSelfVariables.increaseValue(_key, value);
  1278. }
  1279.  
  1280. Game_Enemy.prototype.multiplyselfvariable = function(selfvariable, value) {
  1281.     var _key = ["e", this.index(), selfvariable];
  1282.     $gameSelfVariables.multiplyValue(_key, value);
  1283. }
  1284.  
  1285. Game_Enemy.prototype.divideselfvariable = function(selfvariable, value) {
  1286.     var _key = ["e", this.index(), selfvariable];
  1287.     $gameSelfVariables.divideValue(_key, value);
  1288. }
  1289.  
  1290. Game_Enemy.prototype.modselfvariable = function(selfvariable, value) {
  1291.     var _key = ["e", this.index(), selfvariable];
  1292.     $gameSelfVariables.modValue(_key, value);
  1293. }
  1294.  
  1295. Game_Enemy.prototype.battlevariable = function(battlevariable) {
  1296.     var key = ["e", this.index(), battlevariable];
  1297.     return $gameBattleVariables.value(key);
  1298. }
  1299.  
  1300. Game_Enemy.prototype.strictbattlevariable = function(battlevariable) {
  1301.     var key = ["e", this.index(), battlevariable];
  1302.     return $gameBattleVariables.strictValue(key);
  1303. }
  1304.  
  1305. Game_Enemy.prototype.setbattlevariable = function(battlevariable, value) {
  1306.     var _key = ["e", this.index(), battlevariable];
  1307.     $gameBattleVariables.setValue(_key, value);
  1308. }
  1309.  
  1310. Game_Enemy.prototype.increasebattlevariable = function(battlevariable, value) {
  1311.     var _key = ["e", this.index(), battlevariable];
  1312.     $gameBattleVariables.increaseValue(_key, value);
  1313. }
  1314.  
  1315. Game_Enemy.prototype.multiplybattlevariable = function(battlevariable, value) {
  1316.     var _key = ["e", this.index(), battlevariable];
  1317.     $gameBattleVariables.multiplyValue(_key, value);
  1318. }
  1319.  
  1320. Game_Enemy.prototype.dividebattlevariable = function(battlevariable, value) {
  1321.     var _key = ["e", this.index(), battlevariable];
  1322.     $gameBattleVariables.divideValue(_key, value);
  1323. }
  1324.  
  1325. Game_Enemy.prototype.modbattlevariable = function(battlevariable, value) {
  1326.     var _key = ["e", this.index(), battlevariable];
  1327.     $gameBattleVariables.modValue(_key, value);
  1328. }
  1329.  
  1330. Game_Enemy.prototype.jsevalObjects = function() {
  1331.     var objects = [this.enemy()];
  1332.     objects = objects.concat(Game_Battler.prototype.jsevalObjects.call(this));
  1333.     return objects.filter(function(obj) {
  1334.         return Object.keys(obj.jsreactions).length > 0;
  1335.     });
  1336. };
  1337.  
  1338. //=============================================================================
  1339. // Game_Unit
  1340. //=============================================================================
  1341.  
  1342. Game_Unit.prototype.selfswitch = function(selfswitch) { return false;};
  1343.  
  1344. Game_Unit.prototype.selfvariable = function(selfvariable) { return 0;};
  1345.  
  1346. Game_Unit.prototype.maxselfvariable = function(selfvariable) { return 0;};
  1347.  
  1348. Game_Unit.prototype.minselfvariable = function(selfvariable) { return 0;};
  1349.  
  1350. Game_Unit.prototype.avgselfvariable = function(selfvariable) { return 0;};
  1351.  
  1352. Game_Unit.prototype.battleswitch = function(battleswitch) { return false;};
  1353.  
  1354. Game_Unit.prototype.battlevariable = function(battlevariable) { return 0;};
  1355.  
  1356. Game_Unit.prototype.maxbattlevariable = function(battlevariable) { return 0;};
  1357.  
  1358. Game_Unit.prototype.minbattlevariable = function(battlevariable) { return 0;};
  1359.  
  1360. Game_Unit.prototype.avgbattlevariable = function(battlevariable) { return 0;};
  1361.  
  1362. //=============================================================================
  1363. // Game_Troop
  1364. //=============================================================================
  1365.  
  1366. ICF.MainUtility.clearTroop = Game_Troop.prototype.clear;
  1367. Game_Troop.prototype.clear = function() {
  1368.     ICF.MainUtility.clearTroop.call(this);
  1369.     $gameBattleSwitches.clear();
  1370.     $gameBattleVariables.clear();
  1371. };
  1372.  
  1373. Game_Troop.prototype.selfswitch = function(selfswitch) {
  1374.     this.aliveMembers().forEach(function(enemy) {
  1375.         if (enemy.selfswitch(selfswitch)) {
  1376.             return true;
  1377.         }
  1378.     });
  1379.     return false;
  1380. }
  1381.  
  1382. Game_Troop.prototype.selfvariable = function(selfvariable) {
  1383.     var value = 0;
  1384.     this.aliveMembers().forEach(function(enemy) {
  1385.         value += enemy.strictselfvariable(selfvariable);
  1386.     });
  1387.     return Math.floor(value);
  1388. }
  1389.  
  1390. Game_Troop.prototype.maxselfvariable = function(selfvariable) {
  1391.     if (this.aliveMembers().length < 1) return 0;
  1392.     var value = this.aliveMembers()[0].strictselfvariable(selfvariable);
  1393.     this.aliveMembers().forEach(function(enemy) {
  1394.         value = Math.max(value, enemy.strictselfvariable(selfvariable));
  1395.     });
  1396.     return Math.floor(value);
  1397. }
  1398.  
  1399. Game_Troop.prototype.minselfvariable = function(selfvariable) {
  1400.     if (this.aliveMembers().length < 1) return 0;
  1401.     var value = this.aliveMembers()[0].strictselfvariable(selfvariable);
  1402.     this.aliveMembers().forEach(function(enemy) {
  1403.         value = Math.min(value, enemy.strictselfvariable(selfvariable));
  1404.     });
  1405.     return Math.floor(value);
  1406. }
  1407.  
  1408. Game_Troop.prototype.avgselfvariable = function(selfvariable) {
  1409.     if (this.aliveMembers().length < 1) return 0;
  1410.     var value = 0;
  1411.     this.aliveMembers().forEach(function(enemy) {
  1412.         value += enemy.strictselfvariable(selfvariable);
  1413.     });
  1414.     return Math.floor(value / this.aliveMembers().length);
  1415. }
  1416.  
  1417. Game_Troop.prototype.battleswitch = function(battleswitch) {
  1418.     this.aliveMembers().forEach(function(enemy) {
  1419.         if (enemy.battleswitch(battleswitch)) {
  1420.             return true;
  1421.         }
  1422.     });
  1423.     return false;
  1424. }
  1425.  
  1426. Game_Troop.prototype.battlevariable = function(battlevariable) {
  1427.     var value = 0;
  1428.     this.aliveMembers().forEach(function(enemy) {
  1429.         value += enemy.strictbattlevariable(battlevariable);
  1430.     });
  1431.     return Math.floor(value);
  1432. }
  1433.  
  1434. Game_Troop.prototype.maxbattlevariable = function(battlevariable) {
  1435.     if (this.aliveMembers().length < 1) return 0;
  1436.     var value = this.aliveMembers()[0].strictbattlevariable(battlevariable);
  1437.     this.aliveMembers().forEach(function(enemy) {
  1438.         value = Math.max(value, enemy.strictbattlevariable(battlevariable));
  1439.     });
  1440.     return Math.floor(value);
  1441. }
  1442.  
  1443. Game_Troop.prototype.minbattlevariable = function(battlevariable) {
  1444.     if (this.aliveMembers().length < 1) return 0;
  1445.     var value = this.aliveMembers()[0].strictbattlevariable(battlevariable);
  1446.     this.aliveMembers().forEach(function(enemy) {
  1447.         value = Math.min(value, enemy.strictbattlevariable(battlevariable));
  1448.     });
  1449.     return Math.floor(value);
  1450. }
  1451.  
  1452. Game_Troop.prototype.avgbattlevariable = function(battlevariable) {
  1453.     if (this.aliveMembers().length < 1) return 0;
  1454.     var value = 0;
  1455.     this.aliveMembers().forEach(function(enemy) {
  1456.         value += enemy.strictbattlevariable(battlevariable);
  1457.     });
  1458.     return Math.floor(value / this.aliveMembers().length);
  1459. }
  1460.  
  1461. //=============================================================================
  1462. // Game_Party
  1463. //=============================================================================
  1464.  
  1465. Game_Party.prototype.selfswitch = function(selfswitch) {
  1466.     this.allMembers().forEach(function(actor) {
  1467.         if (actor.selfswitch(selfswitch)) {
  1468.             return true;
  1469.         }
  1470.     });
  1471.     return false;
  1472. }
  1473.  
  1474. Game_Party.prototype.selfvariable = function(selfvariable) {
  1475.     var value = 0;
  1476.     this.allMembers().forEach(function(actor) {
  1477.         value += actor.strictselfvariable(selfvariable);
  1478.     });
  1479.     return Math.floor(value);
  1480. }
  1481.  
  1482. Game_Party.prototype.maxselfvariable = function(selfvariable) {
  1483.     if (this.allMembers().length < 1) return 0;
  1484.     var value = this.allMembers()[0].strictselfvariable(selfvariable);
  1485.     this.allMembers().forEach(function(actor) {
  1486.         value = Math.max(value, actor.strictselfvariable(selfvariable));
  1487.     });
  1488.     return Math.floor(value);
  1489. }
  1490.  
  1491. Game_Party.prototype.minselfvariable = function(selfvariable) {
  1492.     if (this.allMembers().length < 1) return 0;
  1493.     var value = this.allMembers()[0].strictselfvariable(selfvariable);
  1494.     this.allMembers().forEach(function(actor) {
  1495.         value = Math.min(value, actor.strictselfvariable(selfvariable));
  1496.     });
  1497.     return Math.floor(value);
  1498. }
  1499.  
  1500. Game_Party.prototype.avgselfvariable = function(selfvariable) {
  1501.     if (this.allMembers().length < 1) return 0;
  1502.     var value = 0;
  1503.     this.allMembers().forEach(function(actor) {
  1504.         value += actor.strictselfvariable(selfvariable);
  1505.     });
  1506.     return Math.floor(value / this.allMembers().length);
  1507. }
  1508.  
  1509. Game_Party.prototype.battleswitch = function(battleswitch) {
  1510.     this.aliveMembers().forEach(function(actor) {
  1511.         if (actor.battleswitch(battleswitch)) {
  1512.             return true;
  1513.         }
  1514.     });
  1515.     return false;
  1516. }
  1517.  
  1518. Game_Party.prototype.battlevariable = function(battlevariable) {
  1519.     var value = 0;
  1520.     this.aliveMembers().forEach(function(actor) {
  1521.         value += actor.strictbattlevariable(battlevariable);
  1522.     });
  1523.     return Math.floor(value);
  1524. }
  1525.  
  1526. Game_Party.prototype.maxbattlevariable = function(battlevariable) {
  1527.     if (this.aliveMembers().length < 1) return 0;
  1528.     var value = this.aliveMembers()[0].strictbattlevariable(battlevariable);
  1529.     this.aliveMembers().forEach(function(actor) {
  1530.         value = Math.max(value, actor.strictbattlevariable(battlevariable));
  1531.     });
  1532.     return Math.floor(value);
  1533. }
  1534.  
  1535. Game_Party.prototype.minbattlevariable = function(battlevariable) {
  1536.     if (this.aliveMembers().length < 1) return 0;
  1537.     var value = this.aliveMembers()[0].strictbattlevariable(battlevariable);
  1538.     this.aliveMembers().forEach(function(actor) {
  1539.         value = Math.min(value, actor.strictbattlevariable(battlevariable));
  1540.     });
  1541.     return Math.floor(value);
  1542. }
  1543.  
  1544. Game_Party.prototype.avgbattlevariable = function(battlevariable) {
  1545.     if (this.aliveMembers().length < 1) return 0;
  1546.     var value = 0;
  1547.     this.aliveMembers().forEach(function(actor) {
  1548.         value += actor.strictbattlevariable(battlevariable);
  1549.     });
  1550.     return Math.floor(value / this.aliveMembers().length);
  1551. }
  1552.  
  1553. //=============================================================================
  1554. // Game_Event
  1555. //=============================================================================
  1556.  
  1557. Game_Event.prototype.selfswitch = function(selfswitch) {
  1558.     var key = [this._mapId, this._eventId, selfswitch];
  1559.     return $gameSelfSwitches.value(key);
  1560. }
  1561.  
  1562. Game_Event.prototype.setselfswitch = function(selfswitch, value) {
  1563.     ICF.MainUtility.CustomSwitch(this._mapId, this._eventId, selfswitch, value);
  1564. }
  1565.  
  1566. Game_Event.prototype.mapswitch = function(mapswitch) {
  1567.     var key = [this._mapId, 0, mapswitch];
  1568.     return $gameSelfSwitches.value(key);
  1569. }
  1570.  
  1571. Game_Event.prototype.setmapswitch = function(mapswitch, value) {
  1572.     ICF.MainUtility.CustomSwitch(this._mapId, 0, mapswitch, value);
  1573. }
  1574.  
  1575. Game_Event.prototype.selfvariable = function(selfvariable) {
  1576.     var key = [this._mapId, this._eventId, selfvariable];
  1577.     return $gameSelfVariables.value(key);
  1578. }
  1579.  
  1580. Game_Event.prototype.strictselfvariable = function(selfvariable) {
  1581.     var key = [this._mapId, this._eventId, selfvariable];
  1582.     return $gameSelfVariables.strictValue(key);
  1583. }
  1584.  
  1585. Game_Event.prototype.setselfvariable = function(selfvariable, value) {
  1586.     ICF.MainUtility.CustomVariable(this._mapId, this._eventId, selfvariable, value);
  1587. }
  1588.  
  1589. Game_Event.prototype.increaseselfvariable = function(selfvariable, value) {
  1590.     ICF.MainUtility.IncreaseCustomVariable(this._mapId, this._eventId, selfvariable, value);
  1591. }
  1592.  
  1593. Game_Event.prototype.multiplyselfvariable = function(selfvariable, value) {
  1594.     ICF.MainUtility.MultiplyCustomVariable(this._mapId, this._eventId, selfvariable, value);
  1595. }
  1596.  
  1597. Game_Event.prototype.divideselfvariable = function(selfvariable, value) {
  1598.     ICF.MainUtility.DivideCustomVariable(this._mapId, this._eventId, selfvariable, value);
  1599. }
  1600.  
  1601. Game_Event.prototype.modselfvariable = function(selfvariable, value) {
  1602.     ICF.MainUtility.ModCustomVariable(this._mapId, this._eventId, selfvariable, value);
  1603. }
  1604.  
  1605. Game_Event.prototype.mapvariable = function(mapvariable) {
  1606.     var key = [this._mapId, 0, mapvariable];
  1607.     return $gameSelfVariables.value(key);
  1608. }
  1609.  
  1610. Game_Event.prototype.strictmapvariable = function(mapvariable) {
  1611.     var key = [this._mapId, 0, mapvariable];
  1612.     return $gameSelfVariables.strictValue(key);
  1613. }
  1614.  
  1615. Game_Event.prototype.setmapvariable = function(mapvariable, value) {
  1616.     ICF.MainUtility.CustomVariable(this._mapId, 0, mapvariable, value);
  1617. }
  1618.  
  1619. Game_Event.prototype.increasemapvariable = function(mapvariable, value) {
  1620.     ICF.MainUtility.IncreaseCustomVariable(this._mapId, 0, mapvariable, value);
  1621. }
  1622.  
  1623. Game_Event.prototype.multiplymapvariable = function(mapvariable, value) {
  1624.     ICF.MainUtility.MultiplyCustomVariable(this._mapId, 0, mapvariable, value);
  1625. }
  1626.  
  1627. Game_Event.prototype.dividemapvariable = function(mapvariable, value) {
  1628.     ICF.MainUtility.DivideCustomVariable(this._mapId, 0, mapvariable, value);
  1629. }
  1630.  
  1631. Game_Event.prototype.modmapvariable = function(mapvariable, value) {
  1632.     ICF.MainUtility.ModCustomVariable(this._mapId, 0, mapvariable, value);
  1633. }
  1634.  
  1635. //=============================================================================
  1636. // Game_Map
  1637. //=============================================================================
  1638.  
  1639. Game_Map.prototype.mapswitch = function(mapswitch) {
  1640.     var key = [this._mapId, 0, mapswitch];
  1641.     return $gameSelfSwitches.value(key);
  1642. }
  1643.  
  1644. Game_Map.prototype.setmapswitch = function(mapswitch, value) {
  1645.     ICF.MainUtility.CustomSwitch(this._mapId, 0, mapswitch, value);
  1646. }
  1647.  
  1648. Game_Map.prototype.mapvariable = function(mapvariable) {
  1649.     var key = [this._mapId, 0, mapvariable];
  1650.     return $gameSelfVariables.value(key);
  1651. }
  1652.  
  1653. Game_Map.prototype.strictmapvariable = function(mapvariable) {
  1654.     var key = [this._mapId, 0, mapvariable];
  1655.     return $gameSelfVariables.strictValue(key);
  1656. }
  1657.  
  1658. Game_Map.prototype.setmapvariable = function(mapvariable, value) {
  1659.     ICF.MainUtility.CustomVariable(this._mapId, 0, mapvariable, value);
  1660. }
  1661.  
  1662. Game_Map.prototype.increasemapvariable = function(mapvariable, value) {
  1663.     ICF.MainUtility.IncreaseCustomVariable(this._mapId, 0, mapvariable, value);
  1664. }
  1665.  
  1666. Game_Map.prototype.multiplymapvariable = function(mapvariable, value) {
  1667.     ICF.MainUtility.MultiplyCustomVariable(this._mapId, 0, mapvariable, value);
  1668. }
  1669.  
  1670. Game_Map.prototype.dividemapvariable = function(mapvariable, value) {
  1671.     ICF.MainUtility.DivideCustomVariable(this._mapId, 0, mapvariable, value);
  1672. }
  1673.  
  1674. Game_Map.prototype.modmapvariable = function(mapvariable, value) {
  1675.     ICF.MainUtility.ModCustomVariable(this._mapId, 0, mapvariable, value);
  1676. }
  1677.  
  1678. //=============================================================================
  1679. // Game_Item
  1680. //=============================================================================
  1681.  
  1682. Game_Item.prototype.traitDataTypes = function(code) {
  1683.     var data = this.object();
  1684.     if ((data == null)||(!data.traits)) return [];
  1685.     data = data.traits;
  1686.     return data.reduce(function(r, obj) {
  1687.         if (obj.code == code) return r.concat([obj.dataId]);
  1688.         return r;
  1689.     }, []).removeRepeated();
  1690. }
  1691.  
  1692. Game_Item.prototype.traitDataTypesOffset = function(code, min, max) {
  1693.     var data = this.object();
  1694.     if ((data == null)||(!data.traits)) return [];
  1695.     data = data.traits;
  1696.     return data.reduce(function(r, obj) {
  1697.         if ((obj.code == code)&&(obj.dataId >= min)&&(obj.dataId <= max)) return r.concat([obj.dataId - min]);
  1698.         return r;
  1699.     }, []).removeRepeated();
  1700. }
  1701.  
  1702. Game_Item.prototype.traitDataTypesMod = function(code, mod) {
  1703.     var data = this.object();
  1704.     if ((data == null)||(!data.traits)) return [];
  1705.     data = data.traits;
  1706.     return data.reduce(function(r, obj) {
  1707.         if (obj.code == code) return r.concat([obj.dataId % mod]);
  1708.         return r;
  1709.     }, []).removeRepeated();
  1710. }
  1711.  
  1712. //=============================================================================
  1713. // Game_Interpreter
  1714. //=============================================================================
  1715.  
  1716. Game_Interpreter.prototype.event = function() {
  1717.     return $gameMap.event(this._eventId);
  1718. };
  1719.  
  1720. ICF.MainUtility.pluginCommand = Game_Interpreter.prototype.pluginCommand;
  1721. Game_Interpreter.prototype.pluginCommand = function(command, args) {
  1722.         ICF.MainUtility.pluginCommand.call(this, command, args);
  1723.     if (command.toLowerCase() == 'selfswitch') {
  1724.         ICF.MainUtility.CustomSwitch(this._mapId, this._eventId, args[0], args[1]);
  1725.     } else if (command.toLowerCase() == 'mapswitch') {
  1726.         ICF.MainUtility.CustomSwitch(this._mapId, 0, args[0], args[1]);
  1727.     } else if (command.toLowerCase() == 'remoteswitch') {
  1728.         ICF.MainUtility.CustomSwitch(args[0], args[1], args[2], args[3]);
  1729.     } else if (command.toLowerCase().match(/((?:actor)|(?:partymember))(switch)/i)&&(RegExp.$1.length + RegExp.$2.length == command.length)) {
  1730.         var actor = (RegExp.$1 == "actor")? args[0] : ($gameParty.members()[args[0]])? $gameParty.members()[args[0]]._actorId : 0;
  1731.         if (actor > 0) {ICF.MainUtility.CustomSwitch(0, actor, args[1], args[2]);}
  1732.     } else if (command.toLowerCase() == 'enemyswitch') {
  1733.         ICF.MainUtility.CustomSwitch("e", args[0], args[1], args[2]);
  1734.     } else if (command.toLowerCase() == 'battleswitch') {
  1735.         ICF.MainUtility.BattleSwitch(0, 0, args[0], args[1]);
  1736.     } else if (command.toLowerCase().match(/((?:actor)|(?:partymember))(battleswitch)/i)&&(RegExp.$1.length + RegExp.$2.length == command.length)) {
  1737.         var actor = (RegExp.$1 == "actor")? args[0] : ($gameParty.members()[args[0]])? $gameParty.members()[args[0]]._actorId : 0;
  1738.         if (actor > 0) {ICF.MainUtility.BattleSwitch(0, actor, args[1], args[2]);}
  1739.     } else if (command.toLowerCase() == 'enemybattleswitch') {
  1740.         ICF.MainUtility.BattleSwitch("e", args[0], args[1], args[2]);
  1741.     } else if (command.toLowerCase().match(/((?:self)|(?:map))(variable)/i)&&(RegExp.$1.length + RegExp.$2.length == command.length)) {
  1742.         var event = (RegExp.$1 == "self")? this._eventId : 0;
  1743.         ICF.MainUtility.CustomVariable(this._mapId, event, args[0], args[1]);
  1744.     } else if (command.toLowerCase().match(/(increase)((?:self)|(?:map))(variable)/i)&&(RegExp.$1.length + RegExp.$2.length + RegExp.$3.length == command.length)) {
  1745.         var event = (RegExp.$2 == "self")? this._eventId : 0;
  1746.         ICF.MainUtility.IncreaseCustomVariable(this._mapId, event, args[0], args[1]);
  1747.     } else if (command.toLowerCase().match(/(multiply)((?:self)|(?:map))(variable)/i)&&(RegExp.$1.length + RegExp.$2.length + RegExp.$3.length == command.length)) {
  1748.         var event = (RegExp.$2 == "self")? this._eventId : 0;
  1749.         ICF.MainUtility.MultiplyCustomVariable(this._mapId, event, args[0], args[1]);
  1750.     } else if (command.toLowerCase().match(/(divide)((?:self)|(?:map))(variable)/i)&&(RegExp.$1.length + RegExp.$2.length + RegExp.$3.length == command.length)) {
  1751.         var event = (RegExp.$2 == "self")? this._eventId : 0;
  1752.         ICF.MainUtility.DivideCustomVariable(this._mapId, event, args[0], args[1]);
  1753.     } else if (command.toLowerCase().match(/(mod)((?:self)|(?:map))(variable)/i)&&(RegExp.$1.length + RegExp.$2.length + RegExp.$3.length == command.length)) {
  1754.         var event = (RegExp.$2 == "self")? this._eventId : 0;
  1755.         ICF.MainUtility.ModCustomVariable(this._mapId, event, args[0], args[1]);
  1756.     } else if (command.toLowerCase() == 'remotevariable') {
  1757.         ICF.MainUtility.CustomVariable(args[0], args[1], args[2], args[3]);
  1758.     } else if (command.toLowerCase() == 'increaseremotevariable') {
  1759.         ICF.MainUtility.IncreaseCustomVariable(args[0], args[1], args[2], args[3]);
  1760.     } else if (command.toLowerCase() == 'multiplyremotevariable') {
  1761.         ICF.MainUtility.MultiplyCustomVariable(args[0], args[1], args[2], args[3]);
  1762.     } else if (command.toLowerCase() == 'divideremotevariable') {
  1763.         ICF.MainUtility.DivideCustomVariable(args[0], args[1], args[2], args[3]);
  1764.     } else if (command.toLowerCase() == 'modremotevariable') {
  1765.         ICF.MainUtility.ModCustomVariable(args[0], args[1], args[2], args[3]);
  1766.     } else if (command.toLowerCase() == 'actorvariable') {
  1767.         ICF.MainUtility.CustomVariable(0, args[0], args[1], args[2]);
  1768.     } else if (command.toLowerCase() == 'increaseactorvariable') {
  1769.         ICF.MainUtility.IncreaseCustomVariable(0, args[0], args[1], args[2]);
  1770.     } else if (command.toLowerCase() == 'multiplyactorvariable') {
  1771.         ICF.MainUtility.MultiplyCustomVariable(0, args[0], args[1], args[2]);
  1772.     } else if (command.toLowerCase() == 'divideactorvariable') {
  1773.         ICF.MainUtility.DivideCustomVariable(0, args[0], args[1], args[2]);
  1774.     } else if (command.toLowerCase() == 'modactorvariable') {
  1775.         ICF.MainUtility.ModCustomVariable(0, args[0], args[1], args[2]);
  1776.     } else if (command.toLowerCase() == 'enemyvariable') {
  1777.         ICF.MainUtility.CustomVariable("e", args[0], args[1], args[2]);
  1778.     } else if (command.toLowerCase() == 'increaseenemyvariable') {
  1779.         ICF.MainUtility.IncreaseCustomVariable("e", args[0], args[1], args[2]);
  1780.     } else if (command.toLowerCase() == 'multiplyenemyvariable') {
  1781.         ICF.MainUtility.MultiplyCustomVariable("e", args[0], args[1], args[2]);
  1782.     } else if (command.toLowerCase() == 'divideenemyvariable') {
  1783.         ICF.MainUtility.DivideCustomVariable("e", args[0], args[1], args[2]);
  1784.     } else if (command.toLowerCase() == 'modenemyvariable') {
  1785.         ICF.MainUtility.ModCustomVariable("e", args[0], args[1], args[2]);
  1786.     } else if (command.toLowerCase().match(/(enemy)?(battlevariable)/i)&&(RegExp.$1.length + RegExp.$2.length == command.length)) {
  1787.         if (RegExp.$1 == "enemy") {ICF.MainUtility.BattleVariable("e", args[0], args[1], args[2]);}
  1788.         else {ICF.MainUtility.BattleVariable(0, 0, args[0], args[1]);}
  1789.     } else if (command.toLowerCase().match(/(increase)(enemy)?(battlevariable)/i)&&(RegExp.$1.length + RegExp.$2.length + RegExp.$3.length == command.length)) {
  1790.         if (RegExp.$2 == "enemy") {ICF.MainUtility.IncreaseBattleVariable("e", args[0], args[1], args[2]);}
  1791.         else {ICF.MainUtility.IncreaseBattleVariable(0, 0, args[0], args[1]);}
  1792.     } else if (command.toLowerCase().match(/(multiply)(enemy)?(battlevariable)/i)&&(RegExp.$1.length + RegExp.$2.length + RegExp.$3.length == command.length)) {
  1793.         if (RegExp.$2 == "enemy") {ICF.MainUtility.MultiplyBattleVariable("e", args[0], args[1], args[2]);}
  1794.         else {ICF.MainUtility.MultiplyBattleVariable(0, 0, args[0], args[1]);}
  1795.     } else if (command.toLowerCase().match(/(divide)(enemy)?(battlevariable)/i)&&(RegExp.$1.length + RegExp.$2.length + RegExp.$3.length == command.length)) {
  1796.         if (RegExp.$2 == "enemy") {ICF.MainUtility.DivideBattleVariable("e", args[0], args[1], args[2]);}
  1797.         else {ICF.MainUtility.DivideBattleVariable(0, 0, args[0], args[1]);}
  1798.     } else if (command.toLowerCase().match(/(mod)(enemy)?(battlevariable)/i)&&(RegExp.$1.length + RegExp.$2.length + RegExp.$3.length == command.length)) {
  1799.         if (RegExp.$2 == "enemy") {ICF.MainUtility.ModBattleVariable("e", args[0], args[1], args[2]);}
  1800.         else {ICF.MainUtility.ModBattleVariable(0, 0, args[0], args[1]);}
  1801.     } else if (command.toLowerCase() == 'actorbattlevariable') {
  1802.         ICF.MainUtility.BattleVariable(0, args[0], args[1], args[2]);
  1803.     } else if (command.toLowerCase() == 'increaseactorbattlevariable') {
  1804.         ICF.MainUtility.IncreaseBattleVariable(0, args[0], args[1], args[2]);
  1805.     } else if (command.toLowerCase() == 'multiplyactorbattlevariable') {
  1806.         ICF.MainUtility.MultiplyBattleVariable(0, args[0], args[1], args[2]);
  1807.     } else if (command.toLowerCase() == 'divideactorbattlevariable') {
  1808.         ICF.MainUtility.DivideBattleVariable(0, args[0], args[1], args[2]);
  1809.     } else if (command.toLowerCase() == 'modactorbattlevariable') {
  1810.         ICF.MainUtility.ModBattleVariable(0, args[0], args[1], args[2]);
  1811.     } else if (command.toLowerCase().match(/((?:actor)|(?:enemy)|(?:partymember))(trait)((?:add)|(?:rate)|(?:plus))?/i)&&(RegExp.$1.length + RegExp.$2.length + RegExp.$3.length == command.length)) {
  1812.         var data = (RegExp.$1 == "actor")? $gameActors.actor(args[0])._traitsObject : (RegExp.$1 == "enemy")? $gameTroop.members()[args[0]]._traitsObject : ($gameParty.members().length > args[0])? $gameParty.members()[args[0]]._traitsObject : undefined;
  1813.         var mode = (RegExp.$3 == "add")? 0 : (RegExp.$3 == "plus")? 2 : (RegExp.$3 == "rate")? 3 : 1;
  1814.         ICF.MainUtility.addTrait(data, mode, args[1], args[2], args[3]);
  1815.     } else if (command.toLowerCase().match(/(remove)((?:actor)|(?:enemy)|(?:partymember))(trait)/i)&&(RegExp.$1.length + RegExp.$2.length + RegExp.$3.length == command.length)) {
  1816.         var data = (RegExp.$2 == "actor")? $gameActors.actor(args[0])._traitsObject : (RegExp.$2 == "enemy")? $gameTroop.members()[args[0]]._traitsObject : ($gameParty.members().length > args[0])? $gameParty.members()[args[0]]._traitsObject : undefined;
  1817.         ICF.MainUtility.removeTrait(data, args[1], args[2]);
  1818.     } else if (command.toLowerCase().match(/(clear)((?:actor)|(?:enemy)|(?:partymember))(traits)/i)&&(RegExp.$1.length + RegExp.$2.length + RegExp.$3.length == command.length)) {
  1819.         var data = (RegExp.$2 == "actor")? $gameActors.actor(args[0]) : (RegExp.$2 == "enemy")? $gameTroop.members()[args[0]] : ($gameParty.members().length > args[0])? $gameParty.members()[args[0]] : undefined;
  1820.         if (data) data.clearTraits();
  1821.         }
  1822. };
  1823.  
  1824. //=============================================================================
  1825. // Utilities
  1826. //=============================================================================
  1827.  
  1828. ICF.MainUtility.gettfield = function(array) {
  1829.     for (var i = 0; i < ICF.MainUtility.traittags.length; i++) {
  1830.         if (array[0].toLowerCase() == ICF.MainUtility.traittags[i][0]) {
  1831.             array[0] = ICF.MainUtility.traittags[i][1];
  1832.             array[1] = Number(array[1]) + ICF.MainUtility.traittags[i][2];
  1833.             break;
  1834.         }
  1835.     }
  1836.     if (isNaN(Number(array[0]))) {return [-1];}
  1837.     return array;
  1838. }
  1839.  
  1840. ICF.MainUtility.getefield = function(array) {
  1841.     for (var i = 0; i < ICF.MainUtility.effecttags.length; i++) {
  1842.         if (array[0].toLowerCase() == ICF.MainUtility.effecttags[i][0]) {
  1843.             array[0] = ICF.MainUtility.effecttags[i][1];
  1844.             array[1] = Number(array[1]) + ICF.MainUtility.effecttags[i][2];
  1845.             break;
  1846.         }
  1847.     }
  1848.     if (isNaN(Number(array[0]))) {return [-1];}
  1849.     return array;
  1850. }
  1851.  
  1852. ICF.MainUtility.addTrait = function(data, mode, code, dataid, value) {
  1853.     if (!data || !data.traits) return;
  1854.     var array = [code, Number(dataid), Number(value)];
  1855.     if (isNaN(Number(array[0]))) {array = ICF.MainUtility.gettfield(array);};
  1856.     if (array[0] < 0) {return;};
  1857.     if (mode == 0) {data.traits.push({code:Number(array[0]), dataId:array[1], value:array[2]}); return;};
  1858.     var ind = -1;
  1859.     for (var i = 0; i < data.traits.length; i++) {
  1860.         if ((data.traits[i].code == array[0])&&(data.traits[i].dataId == array[1])) {
  1861.             ind = i;
  1862.             break;
  1863.         }
  1864.     }
  1865.     if (ind == -1) {data.traits.push({code:Number(array[0]), dataId:array[1], value:array[2]}); return;};
  1866.     if (mode == 1) {
  1867.         data.traits[ind].value = array[2];
  1868.         for (var i = data.traits.length - 1; i > ind; i--) {
  1869.             if ((data.traits[i].code == array[0])&&(data.traits[i].dataId == array[1])) {
  1870.                 data.traits.splice(i, 1);
  1871.             }
  1872.         }
  1873.     } else if (mode == 2){
  1874.         data.traits[ind].value += array[2];
  1875.         for (var i = data.traits.length - 1; i > ind; i--) {
  1876.             if ((data.traits[i].code == array[0])&&(data.traits[i].dataId == array[1])) {
  1877.                 data.traits[ind].value += data.traits[i].value;
  1878.                 data.traits.splice(i, 1);
  1879.             }
  1880.         }
  1881.     } else if (mode == 3){
  1882.         data.traits[ind].value *= array[2];
  1883.         for (var i = data.traits.length - 1; i > ind; i--) {
  1884.             if ((data.traits[i].code == array[0])&&(data.traits[i].dataId == array[1])) {
  1885.                 data.traits[ind].value *= data.traits[i].value;
  1886.                 data.traits.splice(i, 1);
  1887.             }
  1888.         }
  1889.     }
  1890. }
  1891.  
  1892. ICF.MainUtility.removeTrait = function(data, code, dataid) {
  1893.     if (!data.traits) return;
  1894.     var array = [code, Number(dataid), 0];
  1895.     if (isNaN(Number(array[0]))) {array = ICF.MainUtility.gettfield(array);};
  1896.     if (array[0] < 0) {return;};
  1897.     var ind = -1;
  1898.     for (var i = data.traits.length - 1; i >= 0; i--) {
  1899.         if ((data.traits[i].code == array[0])&&(data.traits[i].dataId == array[1])) {
  1900.             data.traits.splice(i, 1);
  1901.         }
  1902.     }
  1903. }
  1904.  
  1905. ICF.MainUtility.CustomSwitch = function(mapid, evid, switchname, value) {
  1906.     var _key = [mapid, evid, switchname];
  1907.     var _value = (value.toString().toLowerCase() === "true");
  1908.     $gameSelfSwitches.setValue(_key, _value);
  1909. }
  1910.  
  1911. ICF.MainUtility.CustomVariable = function(mapid, evid, variablename, value) {
  1912.     var _key = [mapid, evid, variablename];
  1913.     $gameSelfVariables.setValue(_key, value);
  1914. }
  1915.  
  1916. ICF.MainUtility.IncreaseCustomVariable = function(mapid, evid, variablename, value) {
  1917.     var _key = [mapid, evid, variablename];
  1918.     $gameSelfVariables.increaseValue(_key, value);
  1919. }
  1920.  
  1921. ICF.MainUtility.MultiplyCustomVariable = function(mapid, evid, variablename, value) {
  1922.     var _key = [mapid, evid, variablename];
  1923.     $gameSelfVariables.multiplyValue(_key, value);
  1924. }
  1925.  
  1926. ICF.MainUtility.DivideCustomVariable = function(mapid, evid, variablename, value) {
  1927.     var _key = [mapid, evid, variablename];
  1928.     $gameSelfVariables.divideValue(_key, value);
  1929. }
  1930.  
  1931. ICF.MainUtility.ModCustomVariable = function(mapid, evid, variablename, value) {
  1932.     var _key = [mapid, evid, variablename];
  1933.     $gameSelfVariables.modValue(_key, value);
  1934. }
  1935.  
  1936. ICF.MainUtility.BattleSwitch = function(code, evid, switchname, value) {
  1937.     var _key = [code, evid, switchname];
  1938.     var _value = (value.toString().toLowerCase() === "true");
  1939.     $gameBattleSwitches.setValue(_key, _value);
  1940. }
  1941.  
  1942. ICF.MainUtility.BattleVariable = function(code, evid, variablename, value) {
  1943.     var _key = [code, evid, variablename];
  1944.     $gameBattleVariables.setValue(_key, value);
  1945. }
  1946.  
  1947. ICF.MainUtility.IncreaseBattleVariable = function(code, evid, variablename, value) {
  1948.     var _key = [code, evid, variablename];
  1949.     $gameBattleVariables.increaseValue(_key, value);
  1950. }
  1951.  
  1952. ICF.MainUtility.MultiplyBattleVariable = function(code, evid, variablename, value) {
  1953.     var _key = [code, evid, variablename];
  1954.     $gameBattleVariables.multiplyValue(_key, value);
  1955. }
  1956.  
  1957. ICF.MainUtility.DivideBattleVariable = function(code, evid, variablename, value) {
  1958.     var _key = [code, evid, variablename];
  1959.     $gameBattleVariables.divideValue(_key, value);
  1960. }
  1961.  
  1962. ICF.MainUtility.ModBattleVariable = function(code, evid, variablename, value) {
  1963.     var _key = [code, evid, variablename];
  1964.     $gameBattleVariables.modValue(_key, value);
  1965. }
  1966.  
  1967. ICF.MainUtility.CheckVar = function(code, value1, value2) {
  1968.     switch (code) {
  1969.         case 0:
  1970.             return (value1 == value2); break;
  1971.         case 1:
  1972.             return (value1 !== value2); break;
  1973.         case 2:
  1974.             return (value1 > value2); break;
  1975.         case 3:
  1976.             return (value1 >= value2); break;
  1977.         case 4:
  1978.             return (value1 < value2); break;
  1979.         case 5:
  1980.             return (value1 <= value2); break;
  1981.         default:
  1982.             return false;
  1983.     }
  1984. }
  1985. Array.range = function() {
  1986.     var args = arguments;
  1987.     if (args.length < 1) return [];
  1988.     var x = [];
  1989.     if (args.length == 1) {
  1990.     if (args[0] == 0) return [0];
  1991.     if (args[0] > 0) for (var i = 1; i <= args[0]; i++) {
  1992.         x.push([i]);
  1993.     } else for (var i = -1; i >= args[0]; i--) {
  1994.         x.push([i]);
  1995.     }
  1996.     } else if (args.length == 2) {
  1997.     if (args[0] < args[1]) for (var i = args[0]; i <= args[1]; i++) {
  1998.         x.push([i]);
  1999.     } else for (var i = args[0]; i >= args[1]; i--) {
  2000.         x.push([i]);
  2001.     }
  2002.     } else {
  2003.     if (args[0] < args[1] && args[2] > 0) for (var i = args[0]; i <= args[1]; i += args[2]) {
  2004.         x.push([i]);
  2005.     } else if (args[0] > args[1] && args[2] < 0) for (var i = args[0]; i >= args[1]; i += args[2]) {
  2006.         x.push([i]);
  2007.     }
  2008.     }
  2009.     return x;
  2010. };
  2011.  
  2012. Array.coincidences = function() {
  2013.     var args = arguments;
  2014.     if (args.length < 1) return [];
  2015.     if (args.length == 1) return args[0];
  2016.     var x = [];
  2017.     for (var i = 0; i < args[0].length; i++) {
  2018.     if (args[1].indexOf(args[0][i]) > -1) x.push(args[0][i]);
  2019.     }
  2020.     if (args.length == 2) return x.removeRepeated();
  2021.     for (var i = x.length - 1; i >= 0; i--) {
  2022.     for (var il = 2; il < args.length; il++) {
  2023.         if (args[il].indexOf(x[i]) == -1) {
  2024.             x.splice(i,1);
  2025.             break;
  2026.         }
  2027.     }
  2028.     }
  2029.     return x.removeRepeated();
  2030. };
  2031.  
  2032. Array.prototype.removeRepeated = function() {
  2033.     this.sort(function(a, b) { return a - b;});
  2034.     for (var i = this.length - 1; i > 0; i--) {
  2035.        if (this[i] == this[i - 1]) this.splice(i,1);
  2036.     }
  2037.     return this;
  2038. };
  2039.  
  2040. Array.prototype.clean = function() {
  2041.     for (var i = this.length - 1; i >= 0; i -= 1) {
  2042.     if (this[i] == null) this.splice(i,1);
  2043.     if (String(this[i]).length == 0) this.splice(i,1);
  2044.     }
  2045.     return this;
  2046. };
  2047.  
  2048. Array.prototype.cleanAll = function() {
  2049.     for (var i = this.length - 1; i >= 0; i -= 1) {
  2050.     if (this[i] == null) this.splice(i,1);
  2051.     if (String(this[i]).length == 0) this.splice(i,1);
  2052.     if (Array.isArray(this[i])) this[i].cleanAll();
  2053.     }
  2054.     return this;
  2055. };
  2056.  
  2057. Array.prototype.cleaned = function() {
  2058.     var x = [];
  2059.     for (var i = 0; i < this.length; i++) {
  2060.     if (this[i] != null) x.push(this[i]);
  2061.     }
  2062.     return x;
  2063. };
  2064.  
  2065. Array.prototype.cleanedAll = function() {
  2066.     var x = [];
  2067.     var y = [];
  2068.     for (var i = 0; i < this.length; i++) {
  2069.     if (Array.isArray(this[i])) {
  2070.         y = this[i].cleanedAll();
  2071.         if (y.length > 0) x.push(y);
  2072.     } else if (this[i] != null) x.push(this[i]);
  2073.     }
  2074.     return x;
  2075. };
  2076.  
  2077. Array.prototype.extend = function() {
  2078.     this.clean();
  2079.     for (var i = this.length - 2; i > 0; i -= 1) {
  2080.     if ((String(this[i]).match(/(?:to)|(?:a)|(?:hasta)/))&&(RegExp.$1.length == String(this[i]).length)) {
  2081.         eval("this.splice(i - 1,3," + Array.range(this[i - 1], this[i + 1]).join() + ")");
  2082.         i--;
  2083.     }
  2084.     }
  2085.     return this;
  2086. };
  2087.  
  2088. Array.prototype.fixedBlocks = function(block) {
  2089.     if ((this.length % block)  > 0) {
  2090.     eval("this.splice(this.length,0," + new Array(block - this.length % block).join() + ")");
  2091.     }
  2092. };
  2093.  
  2094. Array.prototype.leaveNumbers = function() {
  2095.     for (var i = this.length - 1; i >= 0; i -= 1) {
  2096.     if (isNaN(Number(this[i]))) this.splice(i,1);
  2097.     else this[i] = Number(this[i]);
  2098.     }
  2099.     return this;
  2100. };
  2101.  
  2102. Array.prototype.numbers = function() {
  2103.     var x = [];
  2104.     for (var i = 0; i < this.length; i++) {
  2105.     if (!isNaN(Number(this[i]))) x.push(Number(this[i]));
  2106.     }
  2107.     return x;
  2108. };
  2109.  
  2110. Array.prototype.reduceToFit = function() {
  2111.     var args = arguments;
  2112.     if (args.length < 1) return this;
  2113.     for (var i = 0; i < args.length; i++) {
  2114.     if ((Array.isArray(args[i]))&&(args[i].length < this.length)) this.splice(args[i].length, this.length - args[i].length);
  2115.     }
  2116.     return this;
  2117. };
  2118.  
  2119. String.prototype.doubleSplit = function() {
  2120.     var x = this.split(",");
  2121.     for (var i = 0; i < x.length; i++) {
  2122.     x[i] = x[i].split(/\s+/);
  2123.     }
  2124.     return x;
  2125. }
  2126.  
  2127. String.prototype.doubleSplitNumbers = function() {
  2128.     var x = this.doubleSplit();
  2129.     for (var i = x.length - 1; i >= 0; i--) {
  2130.     x[i] = x[i].extend().numbers();
  2131.     if (x[i].length < 1) x.splice(i,1);
  2132.     }
  2133.     return x;
  2134. }
  2135.  
  2136. Number.prototype.percentage = function(decimals) {
  2137.     return (this * 100).toFixed(decimals) + "%";
  2138. }
  2139.  
  2140. Date.prototype.getMonthAndDay = function() {
  2141.     return this.getMonth() * 100 + this.getDate() + 100;
  2142. };
  2143.  
  2144. Date.prototype.getHourAndMinute = function() {
  2145.     return this.getHours() * 100 + this.getMinutes();
  2146. };
  2147.  
  2148. Date.prototype.getDayMinutes = function() {
  2149.     return this.getHours() * 60 + this.getMinutes();
  2150. };
  2151.  
  2152. Date.prototype.increaseMinutes = function(minutes) {
  2153.     this.setMinutes(this.getMinutes() + minutes);
  2154. };
  2155.  
  2156. //=============================================================================
  2157. // End of File
  2158. //=============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement