Advertisement
ICF-Soft

ICF-Soft Main Utility 1.05 RPG Maker MV

Mar 24th, 2019
305
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. ICF.NotetagsProcessor = ICF.NotetagsProcessor || {};
  12.  
  13. ICF.MainUtility.Version = 105; // 1.05
  14.  
  15. //=============================================================================
  16.  /*:
  17.  * @plugindesc v1.05b A sdk plugin with a lot of utilities for game
  18.  * and plugin developers.
  19.  * @author ICF-Soft [http://icfsoft.blogspot.com.es/]
  20.  *
  21.  * @param Trait Blocks
  22.  * @desc Make external blocks of traits for diverse pourposes.
  23.  * @type note[]
  24.  * @default []
  25.  *
  26.  * @param Effect Blocks
  27.  * @desc Make external blocks of effects for diverse pourposes.
  28.  * @type note[]
  29.  * @default []
  30.  *
  31.  * @help
  32.  * ============================================================================
  33.  * Introduction
  34.  *
  35.  * This is a sdk plugin with a lot of utilities to script easier.
  36.  * It's needed for the mayority of my plugins to work.
  37.  *
  38.  * It includes:
  39.  *  -Special json feature to edit/add data fields.
  40.  *  -Special trait system allowing to add traits to non-trait data (skills
  41.  *      and items), add actor/enemy traits ingame plus a subtraits system.
  42.  *  -Special effects system allowing to add effects to non-effect data (actors,
  43.  *      classes, enemies...) plus a subeffects system.
  44.  *  -Self and battle switchs/variables system.
  45.  *  -Tags system.
  46.  *  -Javascript runing system.
  47.  *  -Extended features for some js built-in objects.
  48.  *
  49.  * ============================================================================
  50.  * How to use
  51.  * ============================================================================
  52.  *
  53.  * It uses notetags to add/alter data.
  54.  * For plugin developers it's recommended to show how to use these tags
  55.  * inside your plugins.
  56.  *
  57.  *
  58.  * Json master tag allow to alter data in a particular way. You
  59.  * can add new fields or edit out of field limits, it works in
  60.  * json notation, better than just meta-tags.
  61.  *
  62.  * Use every line between open and close tags to edit a field, first
  63.  * field name followed by a two dots symbol, then one space and the
  64.  * code in json format.
  65.  *
  66.  * Example:
  67.  *
  68.  * <JSON MASTER>
  69.  * gold: 50000000
  70.  * hands_power: [50,100]
  71.  * grade: 'F'
  72.  * </JSON MASTER>
  73.  *
  74.  *
  75.  * Traits master tag allow to add traits througth notebox.
  76.  * Every line between open and close tags are three numbers separated
  77.  * by spaces. It is recomended to use the three numbers even if specified
  78.  * trait uses only two, next inline place can be used for comments.
  79.  * You can use a name instead of first number (see readme for all names).
  80.  *
  81.  * Example:
  82.  *
  83.  * <TRAITS MASTER>
  84.  * elem_rate 1 1.5
  85.  * 21 1 2
  86.  * 31 2 0 -Attack element
  87.  * </TRAITS MASTER>
  88.  *
  89.  *
  90.  * Subtraits master tag allow to add more trait setups for different
  91.  * uses like subclass traits, random enemy/item/equipment traits,
  92.  * alter states tiers and so on. It works like traits master but you
  93.  * dont't need to close tag every time you open a new subtrait setup.
  94.  *
  95.  * Example:
  96.  *
  97.  * <SUBTRAITS MASTER> -Fire slime
  98.  * elem_rate 1 1.5
  99.  * 11 2 0.5
  100.  * 31 2 0 -Fire attack element
  101.  * <SUBTRAITS MASTER> -Cold slime
  102.  * elem_rate 1 1.5
  103.  * 11 2 2.1
  104.  * 31 3 0 -Cold attack element
  105.  * </SUBTRAITS MASTER>
  106.  *
  107.  * Note: More than one plugin can use subtraits in same data for different
  108.  * purposes so you must provide a way to use specific blocks, something
  109.  * like "<MyAmacingPluginSubtraits first last>" can be usefull.
  110.  *
  111.  * To access a subtrait setup use 'item.subtraits[i].traits' instead of
  112.  * 'item.traits', where 'i' is the index.
  113.  * And for trait items use 'item.subtraits[i]' instead of 'item'.
  114.  *
  115.  * Effects master and Subeffects master tags work like traits/subtraits
  116.  * ones but are used for effects and effect setups, and need four numbers.
  117.  * You can use a name instead of first number (see readme for all names
  118.  * and how to use).
  119.  *
  120.  * Examples:
  121.  *
  122.  * <EFFECTS MASTER>
  123.  * recover_hp 0 0.5 50
  124.  * gain_tp 0 10 0
  125.  * </EFFECTS MASTER>
  126.  *
  127.  * <SUBEFFECTS MASTER>
  128.  * recover_mp 0 0.5 50
  129.  * gain_tp 0 5 0
  130.  * <SUBEFFECTS MASTER>
  131.  * recover_hp 0 0.5 50
  132.  * gain_tp 0 10 0
  133.  * </SUBEFFECTS MASTER>
  134.  *
  135.  *
  136.  * JSEval master tag allow to add javascript code that can be run
  137.  * when a condition is given or diverse pourposes.
  138.  * You can give single key, double key or more, and you dont't need
  139.  * to close tag every time you open a new code.
  140.  *
  141.  * Example:
  142.  *
  143.  * <JSEVAL MASTER A>
  144.  * this.gainTp(15);
  145.  * <JSEVAL MASTER A B>
  146.  * if (this == subject) this.gainMp(-10);
  147.  * v.setValue(10, v.value(10) + 2);
  148.  * </JSEVAL MASTER>
  149.  *
  150.  * Some variables are passed and can be used inside code:
  151.  *   - subject: the subject of the action.
  152.  *   - item: the object used in the action. Can be an item or a skill.
  153.  *   - isSkill: check if is an skill.
  154.  *
  155.  *
  156.  * You can add special tags for different pourposes with this:
  157.  *
  158.  * <TAGS tag1 tag2>
  159.  *
  160.  * Tags are divided into three groups based on where are.
  161.  *   - Base tags are those inherited from actors and enemies
  162.  *     (actors, classes, enemies and ingame given tags).
  163.  *   - Other tags are those that can be attached (states, armors
  164.  *     weapons...).
  165.  *   - Battle tags are those that can be given in battle, are avaiable
  166.  *     in battle and reset every battle. These are merged inside
  167.  *     second group.
  168.  *
  169.  * ============================================================================
  170.  * Parameters
  171.  * ============================================================================
  172.  *
  173.  * Trait Blocks: Allow to create external traits subgroups.
  174.  * Is configured like the content between trait master tags.
  175.  * Blocks are accesible with ICF.Param.subTraits[i] with i as a numerical index.
  176.  *
  177.  * Effect Blocks: Allow to create external effects subgroups.
  178.  * Is configured like the content between effect master tags.
  179.  * Blocks are accesible with ICF.Param.subEffects[i] with i as a numerical
  180.  * index.
  181.  *
  182.  * ============================================================================
  183.  * Battle Switches and Variables
  184.  * ============================================================================
  185.  *
  186.  * These are new reciclable switches an variables that are reset every
  187.  * battle. Are usefull in battle and help making battle steps without
  188.  * touching persistent switches or variables.
  189.  *
  190.  * Can be usefull for plugins that affect battles.
  191.  *
  192.  * See readme file for more info.
  193.  *
  194.  * ============================================================================
  195.  * Plugin Commands
  196.  * ============================================================================
  197.  *
  198.  * selfswitch x true/false
  199.  * mapswitch x true/false
  200.  * actorswitch actorid x true/false
  201.  * enemyswitch enemyid x true/false
  202.  * battleswitch x true/false
  203.  * actorbattleswitch actorid x true/false
  204.  * enemybattleswitch enemyposition x true/false
  205.  *
  206.  *  - Turns on/off specified selfswitch or mapswitch.
  207.  *    You can also use an actorswitch and battle ones.
  208.  *
  209.  * remoteswitch mapid eventid x true/false
  210.  *
  211.  *  - Turns on/off specified selfswitch or mapswitch remotely.
  212.  *    Use eventid 0 for a mapswitch.
  213.  *
  214.  * selfvariable x value
  215.  * mapvariable x value
  216.  * actorvariable actorid x value
  217.  * enemyvariable enemyid x value
  218.  * battlevariable x value
  219.  * actorbattlevariable actorid x value
  220.  * enemybattlevariable enemyposition x value
  221.  *
  222.  *  - Changes value of specified selfvariable or mapvariable.
  223.  *    You can also use an actorvariable.
  224.  *    You can put increase/multiply/divide/mod prefix.
  225.  *
  226.  * remotevariable mapid eventid x value
  227.  *
  228.  *  - Changes value of specified selfvariable or mapvariable remotely.
  229.  *    Use eventid 0 for a mapvariable.
  230.  *    You can put increase/multiply/divide/mod prefix.
  231.  *
  232.  * actortraitadd actorid code id value
  233.  * partymembertraitadd actorpos code id value
  234.  * enemytraitadd enemy code id value
  235.  *
  236.  *  - Adds an ingame trait to specified actor, actor in party or
  237.  *    in battle enemy.
  238.  *    Doesn't check for repeated traits (same code and id).
  239.  *
  240.  * actortrait actorid code id value
  241.  * partymembertrait actorpos code id value
  242.  * enemytrait enemy code id value
  243.  *
  244.  *  - Ensures an ingame trait to specified actor, actor in party or
  245.  *    in battle enemy. If there isn't it'll be added, if there is at least
  246.  *    one it'll be replaced and all repeated traits will be removed.
  247.  *
  248.  * actortraitplus actorid code id value
  249.  * partymembertraitplus actorpos code id value
  250.  * enemytraitplus enemy code id value
  251.  *
  252.  *  - Increase existing ingame trait to specified actor, actor in party or
  253.  *    in battle enemy by a value. If there isn't it'll be added, and
  254.  *    every repeated trait will be merged togeder by sum.
  255.  *
  256.  * actortraitrate actorid code id value
  257.  * partymembertraitrate actorpos code id value
  258.  * enemytraitrate enemy code id value
  259.  *
  260.  *  - Multiply existing ingame trait to specified actor, actor in party or
  261.  *    in battle enemy by a value. If there isn't it'll be added, and
  262.  *    every repeated trait will be merged togeder by multiplication.
  263.  *
  264.  * removeactortrait actorid code id
  265.  * removepartymembertrait actorpos code id
  266.  * removeenemytraitenemy code id
  267.  *
  268.  *  - Remove all ingame traits with specified code and id to specified actor,
  269.  *    actor in party or in battle enemy.
  270.  *
  271.  * clearactortraits actorid
  272.  * clearpartymembertraits actorpos
  273.  * clearenemytraits enemy
  274.  *
  275.  *  - Remove all ingame traits to specified actor, actor in party or in
  276.  *    battle enemy.
  277.  *
  278.  * addactortag actorid tag
  279.  * addpartymembertag actorposition tag
  280.  * addenemytag enemypos tag
  281.  *
  282.  *  - Add ingame tags to specified actor, actor in party or in battle
  283.  *    enemy. You can add all tags you want in a single line.
  284.  *
  285.  * removeactortag actorid tag
  286.  * removepartymember actorposition tag
  287.  * removeenemy enemypos tag
  288.  *
  289.  *  - Remove ingame tags to specified actor, actor in party or in battle
  290.  *    enemy. You can place all tags you want to remove in a single line.
  291.  *
  292.  * clearactortag actorid tag
  293.  * clearpartymember actorposition tag
  294.  * clearenemy enemypos tag
  295.  *
  296.  *  - Remove all ingame tags to specified actor, actor in party or in
  297.  *    battle enemy.
  298.  *
  299.  * By changing addactortag to addactorbattletag you can give battletags.
  300.  * Can be applied to all tag commands.
  301.  *
  302.  * ============================================================================
  303.  * Scripting functions
  304.  * ============================================================================
  305.  *
  306.  * Scripting functions are more complex. Read readme file.
  307.  *
  308.  * ============================================================================
  309.  * Incompatibilities
  310.  * ============================================================================
  311.  *
  312.  * There's no known incompatible plugins yet.
  313.  *
  314.  * ============================================================================
  315.  * Known isues
  316.  * ============================================================================
  317.  *
  318.  * Not yet.
  319.  *
  320.  * ============================================================================
  321.  * Changelog
  322.  * ============================================================================
  323.  *
  324.  * Version 1.05:
  325.  * - Added more js functions.
  326.  *
  327.  * Version 1.04:
  328.  * - Added external blocks for traits and effects.
  329.  * - Improved tags system.
  330.  * - Allow to filter selfswitches and variables.
  331.  *
  332.  * Version 1.03:
  333.  * - Added tags system.
  334.  *
  335.  * Version 1.02:
  336.  * - Extended battle and self switches and variables to all actors/enemies.
  337.  * - Added group effect system.
  338.  * - Improved trait system.
  339.  *
  340.  * Version 1.01:
  341.  * - Added battle switches and variables.
  342.  * - Added eval system.
  343.  * - Added more js functions.
  344.  *
  345.  * Version 1.00:
  346.  * - Finished plugin!
  347.  *
  348.  * ============================================================================
  349.  *
  350.  * For commercial and non-commercial games.
  351.  * Credit to ICF-Soft.
  352.  * Any plugin that needs this to work must add a clausule to say that ICF-Soft
  353.  * must be included in credits page.
  354.  * This entire header and plugin readme files must be included with plugin.
  355.  *
  356.  * ============================================================================
  357. */
  358. //=============================================================================
  359.  /*:es
  360.  * @plugindesc v1.05b Librería sdk con muchas utilidades para desarrolladores
  361.  * de juegos y complementos.
  362.  * @author ICF-Soft [http://icfsoft.blogspot.com.es/]
  363.  *
  364.  * @param Trait Blocks
  365.  * @desc Permite crear bloques externos de rasgos para diversos propósitos.
  366.  * @type note[]
  367.  * @default []
  368.  *
  369.  * @param Effect Blocks
  370.  * @desc Permite crear bloques externos de efectos para diversos propósitos.
  371.  * @type note[]
  372.  * @default []
  373.  *
  374.  * @help
  375.  * ============================================================================
  376.  * Introducción
  377.  * ============================================================================
  378.  *
  379.  * Este complemento es una librería sdk con un montón de utilidades para
  380.  * programar más fácil.
  381.  * Es necesario para la mayoría de mis complementos.
  382.  *
  383.  * Incluye:
  384.  *  -Sistema json para editar/añadir campos.
  385.  *  -sistema especial de características que permite añadir características
  386.  *      en datos que normalmente no tienen (habilidades y objetos), añadir
  387.  *      características a los personajes y enemigos durante el juego y un
  388.  *      sistema especial de subcaracterísticas.
  389.  *  -Sistema especial de efectos que permite añadir efectos en datos que
  390.  *      normalmente no tienen (actoers, clases, enemigos...) y un sistema
  391.  *      especial de sub-efectos.
  392.  *  -Sistema de interruptores y variables locales y de batalla.
  393.  *  -Sistema de etiquetas.
  394.  *  -Sistema de ejecución de código javascript.
  395.  *  -Funciones extra para algunos objetos predefinidos de javascript.
  396.  *
  397.  * ============================================================================
  398.  * Uso
  399.  * ============================================================================
  400.  *
  401.  * Para añadir o editar datos se utilizan las etiquetas en las notas.
  402.  * Para desarrolladores de plugins se recomienda que se muestre cómo usarlas
  403.  * en sus plugins.
  404.  *
  405.  *
  406.  * La etiqueta 'Json master' permite alterar los datos de un modo particular.
  407.  * Puedes añadir nuevos campos o editarlos sin las restricciones predeterminadas,
  408.  * funciona en notación json, mejor que las simples etiquetas meta.
  409.  *
  410.  * Utiliza cada linea entre las etiquetas de abertura y cierre para editar
  411.  * un campo, primero el nombre del campo, luego dos puntos, un espacio y el
  412.  * código en formato json.
  413.  *
  414.  * Ejemplo:
  415.  *
  416.  * <JSON MASTER>
  417.  * gold: 50000000
  418.  * hands_power: [50,100]
  419.  * alias: 'Romistrugio'
  420.  * </JSON MASTER>
  421.  *
  422.  *
  423.  * La etiqueta 'Traits master' permite añadir características o rasgos.
  424.  * En cada linea entre las etiquetas de apertura y cierre van tres números
  425.  * separados por espacios. Se recomienda usar los tres aún cuando el rasgo
  426.  * solo necesite dos, puedes continuar la linea con comentarios.
  427.  * Puedes usar un nombre en lugar del primer número (en el archivo leeme
  428.  * puedes encontrar todos los disponibles).
  429.  *
  430.  * Ejemplo:
  431.  *
  432.  * <TRAITS MASTER>
  433.  * elem_rate 1 1.5
  434.  * 21 1 2
  435.  * 31 2 0 -Elemento de ataque
  436.  * </TRAITS MASTER>
  437.  *
  438.  *
  439.  * La etiqueta 'Subtraits master' permite añadir conjuntos de rasgos para
  440.  * diferentes usos tales como rasgos de subclase, rasgos aleatorios para
  441.  * enemigos/objetos/armas, fases de un estado alterado y más.
  442.  * Funciona como la etiqueta anterior pero no necesitas cerrar antes de abrir
  443.  * un nuevo subconjunto.
  444.  *
  445.  * Ejemplo:
  446.  *
  447.  * <SUBTRAITS MASTER> -Limo de fuego
  448.  * elem_rate 1 1.5
  449.  * 11 2 0.5
  450.  * 31 2 0 -Ataca con fuego
  451.  * <SUBTRAITS MASTER> -Limo de hielo
  452.  * elem_rate 1 1.5
  453.  * 11 2 2.1
  454.  * 31 3 0 -Ataca con hielo
  455.  * </SUBTRAITS MASTER>
  456.  *
  457.  * Nota: Varios complementos pueden usar subconjuntos para las mismas tablas
  458.  * de la base de datos para diferentes propósitos, de modo que debes
  459.  * proveer un modo de usar subconjuntos específicos, por ejemplo algo así
  460.  * como "<MiIncreiblePluginSubtraits primero ultimo>" podría ser útil.
  461.  *
  462.  * Para acceder a un subconjunto se utiliza 'item.subtraits[i].traits' en
  463.  * lugar de 'item.traits', donde 'i' es el índice.
  464.  * Y para el objeto del subconjunto usar 'item.subtraits[i]' en lugar de 'item'.
  465.  *
  466.  *
  467.  * Las etiquetas 'Effects master' y 'Subeffects master' funcionan de un modo
  468.  * similar a las traits/subtraits pero se usan para efectos sus grupos.
  469.  * Estas requieren el uso de cuatro números.
  470.  * Puedes usar un nombre en lugar del primer número (en el archivo leeme
  471.  * puedes encontrar todos los disponibles).
  472.  *
  473.  * Ejemplos:
  474.  *
  475.  * <EFFECTS MASTER>
  476.  * recover_hp 0 0.5 50
  477.  * gain_tp 0 10 0
  478.  * </EFFECTS MASTER>
  479.  *
  480.  * <SUBEFFECTS MASTER>
  481.  * recover_mp 0 0.5 50
  482.  * gain_tp 0 5 0
  483.  * <SUBEFFECTS MASTER>
  484.  * recover_hp 0 0.5 50
  485.  * gain_tp 0 10 0
  486.  * </SUBEFFECTS MASTER>
  487.  *
  488.  *
  489.  * La etiqueta 'JSEval master' permite añadir código javascript que se
  490.  * ejecutará en condiciones específicas o diversos propósitos.
  491.  * Se puede hacer de una clave, dos o las que hagan falta, y no hace falta
  492.  * cerrar la etiqueta cuando se ponen consecutivas.
  493.  *
  494.  * Ejemplo:
  495.  *
  496.  * <JSEVAL MASTER A>
  497.  * this.gainTp(15);
  498.  * <JSEVAL MASTER A B>
  499.  * if (this == subject) this.gainMp(-10);
  500.  * v.setValue(10, v.value(10) + 2);
  501.  * </JSEVAL MASTER>
  502.  *
  503.  * Hay algunas variables a las que se puede acceder dentro del código:
  504.  *   - subject: el sujeto de la acción.
  505.  *   - item: el objeto usado en la acción. Puede ser un objeto o habilidad.
  506.  *   - isSkill: comprueba si se trata de una habilidad.
  507.  *
  508.  *
  509.  * Puedes añadir etiquetas para diferentes propósitos con:
  510.  *
  511.  * <TAGS tag1 tag2>
  512.  *
  513.  * Las etiquetas se dividen en tres grupos en base a su origen.
  514.  *   - Las base son las que son própias de los personajes y enemigos
  515.  *     (actores, clases, enemigos y las añadidas mediante comando).
  516.  *   - Las demás son las añadidas mediante estados alterados y equipamiento.
  517.  *   - Las de batalla son las que se añaden durante el combate, solo
  518.  *     son accesibles ahí y se reinician cada combate. Se añaden al segundo
  519.  *     grupo.
  520.  *
  521.  * ============================================================================
  522.  * Parámetros
  523.  * ============================================================================
  524.  *
  525.  * Trait Blocks: Permite crear subgrupos externos de rasgos.
  526.  * Se configura del mismo modo que el contenido interno de las etiquetas
  527.  * trait master.
  528.  * Se puede acceder mediante ICF.Param.subTraits[i] con i como índice numérico.
  529.  *
  530.  * Effect Blocks: Permite crear subgrupos externos de efectos.
  531.  * Se configura del mismo modo que el contenido interno de las etiquetas
  532.  * effect master.
  533.  * Se puede acceder mediante ICF.Param.subEffects[i] con i como índice numérico.
  534.  *
  535.  * ============================================================================
  536.  * Interruptores y Variables de Batalla
  537.  * ============================================================================
  538.  *
  539.  * Son nuevos interruptores y variables reciclables que se reinician en
  540.  * cada batalla. Útiles para dividir la batalla en fases sin tocar otros
  541.  * interruptores o variables.
  542.  *
  543.  * Muy útiles para plugins que afectan las batallas.
  544.  *
  545.  * Para más información ver el archivo leeme.
  546.  *
  547.  * ============================================================================
  548.  * Comandos de complemento
  549.  * ============================================================================
  550.  *
  551.  * selfswitch x true/false
  552.  * mapswitch x true/false
  553.  * actorswitch actorid x true/false
  554.  * enemyswitch enemyid x true/false
  555.  * battleswitch x true/false
  556.  * actorbattleswitch actorid x true/false
  557.  * enemybattleswitch enemyposition x true/false
  558.  *
  559.  *  - Activa o desactiva el autointerruptor, interruptor de mapa
  560.  *    o de personaje.
  561.  *
  562.  * remoteswitch mapid eventid x true/false
  563.  *
  564.  *  - Activa o desactiva el autointerruptor o interruptor de mapa específico
  565.  *    de forma remota. Usar eventid 0 para interruptor de mapa.
  566.  *
  567.  * selfvariable x value
  568.  * mapvariable x value
  569.  * actorvariable actorid x value
  570.  * enemyvariable enemyid x value
  571.  * battlevariable x value
  572.  * actorbattlevariable actorid x value
  573.  * enemybattlevariable enemyposition x value
  574.  *
  575.  *  - Cambia el valor de la variable de evento, mapa o personaje.
  576.  *    Se pueden añadir los prefijos increase/multiply/divide/mod.
  577.  *
  578.  * remotevariable mapid eventid x value
  579.  *
  580.  *  - Cambia el valor de la variable de evento o mapa específico
  581.  *    de forma remota. Usar eventid 0 para interruptor de mapa.
  582.  *    Se pueden añadir los prefijos increase/multiply/divide/mod.
  583.  *
  584.  * actortraitadd actorid code id value
  585.  * partymembertraitadd actorpos code id value
  586.  * enemytraitadd enemy code id value
  587.  *
  588.  *  - Añade un rasgo dentro del juego para el personaje, personaje del
  589.  *    grupo o enemigo.
  590.  *    No comprueba si existen repetidos (mismos code e id).
  591.  *
  592.  * actortrait actorid code id value
  593.  * partymembertrait actorpos code id value
  594.  * enemytrait enemy code id value
  595.  *
  596.  *  - Asegura un rasgo dentro del juego para el personaje, personaje del
  597.  *    grupo o enemigo. Si no hay se añade, si hay almenos uno se
  598.  *    sobreescribe y el resto se elimina.
  599.  *
  600.  * actortraitplus actorid code id value
  601.  * partymembertraitplus actorpos code id value
  602.  * enemytraitplus enemy code id value
  603.  *
  604.  *  - Incrementa un rasgo dentro del juego para el personaje, personaje del
  605.  *    grupo o enemigo. Si no hay se añade, si hay almenos uno se
  606.  *    todos los que tenga se combinan mediante suma.
  607.  *
  608.  * actortraitrate actorid code id value
  609.  * partymembertraitrate actorpos code id value
  610.  * enemytraitrate enemy code id value
  611.  *
  612.  *  - Multiplica un rasgo dentro del juego para el personaje, personaje del
  613.  *    grupo o enemigo. Si no hay se añade, si hay almenos uno se
  614.  *    todos los que tenga se combinan mediante multiplicación.
  615.  *
  616.  * removeactortrait actorid code id
  617.  * removepartymembertrait actorpos code id
  618.  * removeenemytraitenemy code id
  619.  *
  620.  *  - Elimina todos los rasgos dentro del juego con código e id específicos
  621.  *    del personaje, personaje del grupo o enemigo.
  622.  *
  623.  * clearactortraits actorid
  624.  * clearpartymembertraits actorpos
  625.  * clearenemytraits enemy
  626.  *
  627.  *  - Elimina todos los rasgos dentro del juego del personaje, personaje
  628.  *    del grupo o enemigo.
  629.  *
  630.  * addactortag actorid tag
  631.  * addpartymembertag actorposition tag
  632.  * addenemytag enemypos tag
  633.  *
  634.  *  - Añade etiquetas durante el juego a un personaje, personaje del
  635.  *    grupo o enemigo. Puedes poner varias en una misma linea.
  636.  *
  637.  * removeactortag actorid tag
  638.  * removepartymember actorposition tag
  639.  * removeenemy enemypos tag
  640.  *
  641.  *  - Elimina etiquetas durante el juego a un personaje, personaje del
  642.  *    grupo o enemigo previamente añadidas. Puedes eliminar varias en
  643.  *    una misma linea.
  644.  *
  645.  * clearactortag actorid tag
  646.  * clearpartymember actorposition tag
  647.  * clearenemy enemypos tag
  648.  *
  649.  *  - Elimina todas etiquetas añadidas durante el juego a un personaje,
  650.  *    personaje del grupo o enemigo.
  651.  *
  652.  * Cambiando addactortag por addactorbattletag puedes usar etiquetas de
  653.  * batalla. Para cualquier comando de etiquetas.
  654.  *
  655.  * ============================================================================
  656.  * Funciones de script
  657.  * ============================================================================
  658.  *
  659.  * Las funciones de script son más complejas. Ver archivo léeme..
  660.  *
  661.  * ============================================================================
  662.  * Incompatibilidades
  663.  * ============================================================================
  664.  *
  665.  * No se conocen complementos que sean incompatibles hasta la fecha.
  666.  *
  667.  * ============================================================================
  668.  * Problemas conocidos
  669.  * ============================================================================
  670.  *
  671.  * Por el momento ninguno.
  672.  *
  673.  * ============================================================================
  674.  * Historial de versiones
  675.  * ============================================================================
  676.  *
  677.  * Versión 1.05:
  678.  * - Se han añadido más funciones javascript extra.
  679.  *
  680.  * Versión 1.04:
  681.  * - Se han añadido bloques externos de rasgos y efectos.
  682.  * - Se ha mejorado sistema de etiquetas.
  683.  * - Permite filtrar los interruptores y variables locales.
  684.  *
  685.  * Versión 1.03:
  686.  * - Se ha añadido un sistema de etiquetas.
  687.  *
  688.  * Versión 1.02:
  689.  * - Se han extendido los interruptores y variables locales y de batalla a
  690.  *   todos los personajes y enemigos.
  691.  * - Se ha añadido sistema de efectos y grupos de efectos.
  692.  * - Se ha mejorado el sistema de rasgos.
  693.  *
  694.  * Versión 1.01:
  695.  * - Se han añadido interruptores y variables de batalla.
  696.  * - Se han añadido funciones evaluables.
  697.  * - Se han añadido más funciones extra.
  698.  *
  699.  * Versión 1.00:
  700.  * - Complemento terminado.
  701.  *
  702.  * ============================================================================
  703.  *
  704.  * Para juegos comerciales y no comerciales.
  705.  * Se debe incluir a ICF-Soft en los créditos.
  706.  * Cualquier plugin que necesite este para funcionar debe incluir una cláusula
  707.  * que indique que se debe incluir a ICF-Soft en los créditos.
  708.  * Esta cabecera y los archivos leeme del complemento deben incluirse
  709.  * íntegramente con el plugin.
  710.  *
  711.  * ============================================================================
  712. */
  713. //=============================================================================
  714.  
  715. //=============================================================================
  716. // Parameter Variables
  717. //=============================================================================
  718.  
  719. ICF.Parameters = PluginManager.parameters('ICFSoft_MainUtility');
  720. ICF.Param = ICF.Param || {};
  721.  
  722. ICF.Param.subTraits = [];
  723. ICF.temp = JSON.parse(ICF.Parameters['Trait Blocks']);
  724. for (var i = 0; i < ICF.temp.length; i++) {
  725.     ICF.Param.subTraits[i] = JSON.parse(ICF.temp[i]);
  726. }
  727.  
  728. ICF.Param.subEffects = [];
  729. ICF.temp = JSON.parse(ICF.Parameters['Effect Blocks']);
  730. for (var i = 0; i < ICF.temp.length; i++) {
  731.     ICF.Param.subEffects[i] = JSON.parse(ICF.temp[i]);
  732. }
  733.  
  734. //=============================================================================
  735. // Constants
  736. //=============================================================================
  737.  
  738. ICF.MainUtility.traittags = [
  739.     ['elem_rate', 11, 0],
  740.     ['debuffrate', 12, 0],
  741.     ['ndebuffrate', 12, 10],
  742.     ['cdebuffrate', 12, 200],
  743.     ['state_rate', 13, 0],
  744.     ['state_resist', 14, 0],
  745.     ['skill_rate', 15, 0],
  746.     ['itemdamage_rate', 15, 2000],
  747.     ['weapon_rate', 16, 0],
  748.     ['elem_absorb', 17, 0],
  749.     ['elem_curse', 18, 0],
  750.     ['elem_reflect', 19, 0],
  751.     ['paramplus', 21, 10],
  752.     ['paramrate', 21, 0],
  753.     ['paramflat', 21, 20],
  754.     ['paramxrate', 21, 30],
  755.     ['paramxflat', 21, 40],
  756.     ['xparamplus', 22, 0],
  757.     ['xparamrate', 22, 10],
  758.     ['xparamflat', 22, 20],
  759.     ['sparamplus', 23, 10],
  760.     ['sparamrate', 23, 0],
  761.     ['sparamflat', 23, 20],
  762.     ['nparamplus', 24, 0],
  763.     ['nparamrate', 24, 100],
  764.     ['nparamflat', 24, 200],
  765.     ['nparamxrate', 24, 300],
  766.     ['nparamxflat', 24, 400],
  767.     ['pparamplus', 25, 0],
  768.     ['pparamrate', 25, 100],
  769.     ['pparamflat', 25, 200],
  770.     ['cparamplus', 26, 0],
  771.     ['cparamrate', 26, 100],
  772.     ['cparamflat', 26, 200],
  773.     ['cparamxrate', 26, 300],
  774.     ['cparamxflat', 26, 400],
  775.     ['tpplus', 27, 0],
  776.     ['tprate', 27, 1],
  777.     ['tpflat', 27, 2],
  778.     ['tpxrate', 27, 3],
  779.     ['tpxflat', 27, 4],
  780.     ['attack_elem', 31, 0],
  781.     ['attack_state', 32, 0],
  782.     ['attack_speed', 33, 0],
  783.     ['attack_times', 34, 0],
  784.     ['attack_weapon', 35, 0],
  785.     ['elem_enhace', 36, 0],
  786.     ['skill_enhace', 36, 2000],
  787.     ['weapon_enhace', 36, 4000],
  788.     ['itemdamage_enhace', 36, 6000],
  789.     ['stypeadd', 41, 0],
  790.     ['stypeseal', 42, 0],
  791.     ['skilladd', 43, 0],
  792.     ['skillseal', 44, 0],
  793.     ['equipweapon', 51, 0],
  794.     ['equiparmor', 52, 0],
  795.     ['equiplock', 53, 0],
  796.     ['equipseal', 54, 0],
  797.     ['slot_type', 55, 0],
  798.     ['action_plus', 61, 0],
  799.     ['special_flag', 62, 0],
  800.     ['collapse_type', 63, 0],
  801.     ['party_ability', 64, 0]
  802. ];
  803.  
  804. ICF.MainUtility.effecttags = [
  805.     ['recover_hp', 11, 0],
  806.     ['recover_mp', 12, 0],
  807.     ['gain_tp', 13, 0],
  808.     ['recover_cparam', 14, 0],
  809.     ['add_state', 21, 0],
  810.     ['remove_state', 22, 0],
  811.     ['add_buff', 31, 0],
  812.     ['add_debuff', 32, 0],
  813.     ['remove_buff', 33, 0],
  814.     ['remove_debuff', 34, 0],
  815.     ['add_nbuff', 35, 0],
  816.     ['add_ndebuff', 36, 0],
  817.     ['remove_nbuff', 37, 0],
  818.     ['remove_ndebuff', 38, 0],
  819.     ['add_cbuff', 35, 100],
  820.     ['add_cdebuff', 36, 100],
  821.     ['remove_cbuff', 37, 100],
  822.     ['remove_cdebuff', 38, 100],
  823.     ['special', 41, 0],
  824.     ['grow', 42, 0],
  825.     ['xgrow', 42, 10],
  826.     ['sgrow', 42, 20],
  827.     ['learn_skill', 43, 0],
  828.     ['common_event', 44, 0],
  829.     ['ngrow', 45, 0],
  830.     ['pgrow', 46, 0],
  831.     ['cgrow', 47, 0]
  832. ];
  833.  
  834. //=============================================================================
  835. // Game_Switches
  836. //=============================================================================
  837.  
  838. Game_Switches.prototype.toogleValue = function(switchId) {
  839.     this.setValue(switchId, !this.value(switchId));
  840. };
  841.  
  842. //=============================================================================
  843. // Game_SelfSwitches
  844. //=============================================================================
  845.  
  846. Game_SelfSwitches.prototype.filter = function(a, b) {
  847.     return Object.keys(this._data).filter(function(key) {
  848.         return Array.isArray(key) && (key[0] == a) && (key[1] == b);
  849.     });
  850. };
  851.  
  852. Game_SelfSwitches.prototype.toogleValue = function(key) {
  853.     this.setValue(key, !this.value(key));
  854. };
  855.  
  856. //=============================================================================
  857. // Game_Variables
  858. //=============================================================================
  859.  
  860. Game_Variables.prototype.increaseValue = function(variableId, value) {
  861.     this.setValue(variableId, this.value(variableId) + value);
  862. };
  863.  
  864. Game_Variables.prototype.multiplyValue = function(variableId, value) {
  865.     this.setValue(variableId, this.value(variableId) * value);
  866. };
  867.  
  868. Game_Variables.prototype.divideValue = function(variableId, value) {
  869.     if (value != 0) this.setValue(variableId, this.value(variableId) / value);
  870. };
  871.  
  872. Game_Variables.prototype.modValue = function(variableId, value) {
  873.     if (value != 0) this.setValue(variableId, this.value(variableId) % value);
  874. };
  875.  
  876. var $gameSelfvariables    = null;
  877.  
  878. //=============================================================================
  879. // Game_SelfVariables
  880. //=============================================================================
  881.  
  882. function Game_SelfVariables() {
  883.     this.initialize.apply(this, arguments);
  884. }
  885.  
  886. Game_SelfVariables.prototype.initialize = function() {
  887.     this.clear();
  888. };
  889.  
  890. Game_SelfVariables.prototype.clear = function() {
  891.     this._data = {};
  892. };
  893.  
  894. Game_SelfVariables.prototype.value = function(key) {
  895.     return this._data[key] || 0;
  896. };
  897.  
  898. Game_SelfVariables.prototype.strictValue = function(key) {
  899.     var value = Number(this._data[key]);
  900.     return (isNaN(value))? 0 : Number(value);
  901. };
  902.  
  903. Game_SelfVariables.prototype.setValue = function(key, value) {
  904.     if (value) {
  905.         this._data[key] = (isNaN(Number(value))||Array.isArray(value))? value : Number(value);
  906.     } else {
  907.         delete this._data[key];
  908.     }
  909.     this.onChange();
  910. };
  911.  
  912. Game_SelfVariables.prototype.increaseValue = function(key, value) {
  913.     var val = Number(this._data[key] || 0);
  914.     if (isNaN(val)||isNaN(value)) return;
  915.     this._data[key] = Number(this._data[key] || 0) + Number(value);
  916.     this.onChange();
  917. };
  918.  
  919. Game_SelfVariables.prototype.multiplyValue = function(key, value) {
  920.     var val = Number(this._data[key] || 0);
  921.     if (isNaN(val)||isNaN(value)) return;
  922.     this._data[key] = Number(this._data[key] || 0) * Number(value);
  923.     this.onChange();
  924. };
  925.  
  926. Game_SelfVariables.prototype.divideValue = function(key, value) {
  927.     var val = Number(this._data[key] || 0);
  928.     if (isNaN(val)||isNaN(value)||value == 0) return;
  929.     this._data[key] = Number(this._data[key] || 0) / Number(value);
  930.     this.onChange();
  931. };
  932.  
  933. Game_SelfVariables.prototype.modValue = function(key, value) {
  934.     var val = Number(this._data[key] || 0);
  935.     if (isNaN(val)||isNaN(value)||value == 0) return;
  936.     this._data[key] = Number(this._data[key] || 0) % Number(value);
  937.     this.onChange();
  938. };
  939.  
  940. Game_SelfVariables.prototype.onChange = function() {
  941.     $gameMap.requestRefresh();
  942. };
  943.  
  944. Game_SelfVariables.prototype.filter = function(a, b) {
  945.     return Object.keys(this._data).filter(function(key) {
  946.         return Array.isArray(key) && (key[0] == a) && (key[1] == b);
  947.     });
  948. };
  949.  
  950. //=============================================================================
  951. // Game_BattleSwitches
  952. //=============================================================================
  953.  
  954. function Game_BattleSwitches() {
  955.     this.initialize.apply(this, arguments);
  956. }
  957.  
  958. Game_BattleSwitches.prototype.initialize = function() {
  959.     this.clear();
  960. };
  961.  
  962. Game_BattleSwitches.prototype.clear = function() {
  963.     this._data = {};
  964. };
  965.  
  966. Game_BattleSwitches.prototype.value = function(key) {
  967.     return !!this._data[key];
  968. };
  969.  
  970. Game_BattleSwitches.prototype.setValue = function(key, value) {
  971.     if (value) {
  972.         this._data[key] = true;
  973.     } else {
  974.         delete this._data[key];
  975.     }
  976.     this.onChange();
  977. };
  978.  
  979. Game_BattleSwitches.prototype.onChange = function() {
  980.     //$gameMap.requestRefresh();
  981. };
  982.  
  983. var $gameBattleSwitches = new Game_BattleSwitches();
  984.  
  985. //=============================================================================
  986. // Game_BattleVariables
  987. //=============================================================================
  988.  
  989. function Game_BattleVariables() {
  990.     this.initialize.apply(this, arguments);
  991. }
  992.  
  993. Game_BattleVariables.prototype.initialize = function() {
  994.     this.clear();
  995. };
  996.  
  997. Game_BattleVariables.prototype.clear = function() {
  998.     this._data = {};
  999. };
  1000.  
  1001. Game_BattleVariables.prototype.value = function(key) {
  1002.     return this._data[key] || 0;
  1003. };
  1004.  
  1005. Game_BattleVariables.prototype.strictValue = function(key) {
  1006.     var value = Number(this._data[key]);
  1007.     return (isNaN(value))? 0 : Number(value);
  1008. };
  1009.  
  1010. Game_BattleVariables.prototype.setValue = function(key, value) {
  1011.     if (value) {
  1012.         this._data[key] = (isNaN(Number(value))||Array.isArray(value))? value : Number(value);
  1013.     } else {
  1014.         delete this._data[key];
  1015.     }
  1016.     this.onChange();
  1017. };
  1018.  
  1019. Game_BattleVariables.prototype.increaseValue = function(key, value) {
  1020.     var val = Number(this._data[key] || 0);
  1021.     if (isNaN(val)||isNaN(value)) return;
  1022.     this._data[key] = Number(this._data[key] || 0) + Number(value);
  1023.     this.onChange();
  1024. };
  1025.  
  1026. Game_BattleVariables.prototype.multiplyValue = function(key, value) {
  1027.     var val = Number(this._data[key] || 0);
  1028.     if (isNaN(val)||isNaN(value)) return;
  1029.     this._data[key] = Number(this._data[key] || 0) * Number(value);
  1030.     this.onChange();
  1031. };
  1032.  
  1033. Game_BattleVariables.prototype.divideValue = function(key, value) {
  1034.     var val = Number(this._data[key] || 0);
  1035.     if (isNaN(val)||isNaN(value)||value == 0) return;
  1036.     this._data[key] = Number(this._data[key] || 0) / Number(value);
  1037.     this.onChange();
  1038. };
  1039.  
  1040. Game_BattleVariables.prototype.modValue = function(key, value) {
  1041.     var val = Number(this._data[key] || 0);
  1042.     if (isNaN(val)||isNaN(value)||value == 0) return;
  1043.     this._data[key] = Number(this._data[key] || 0) % Number(value);
  1044.     this.onChange();
  1045. };
  1046.  
  1047. Game_BattleVariables.prototype.onChange = function() {
  1048.     //$gameMap.requestRefresh();
  1049. };
  1050.  
  1051. var $gameBattleVariables = new Game_BattleVariables();
  1052.  
  1053. //=============================================================================
  1054. // Game_BattleTags
  1055. //=============================================================================
  1056.  
  1057. function Game_BattleTags() {
  1058.     this.initialize.apply(this, arguments);
  1059. }
  1060.  
  1061. Game_BattleTags.prototype.initialize = function() {
  1062.     this.clear();
  1063. };
  1064.  
  1065. Game_BattleTags.prototype.clear = function() {
  1066.     this._ATags = {};
  1067.     this._ETags = {};
  1068. };
  1069.  
  1070. Game_BattleTags.prototype.actorTags = function(key) {
  1071.     if (!this._ATags[key]) this._ATags[key] = [];
  1072.     return this._ATags[key];
  1073. };
  1074.  
  1075. Game_BattleTags.prototype.enemyTags = function(key) {
  1076.     if (!this._ETags[key]) this._ETags[key] = [];
  1077.     return this._ETags[key];
  1078. };
  1079.  
  1080. Game_BattleTags.prototype.clearActorTags = function(key) {
  1081.     this._ATags[key] = [];
  1082. };
  1083.  
  1084. Game_BattleTags.prototype.clearEnemyTags = function(key) {
  1085.     this._ETags[key] = [];
  1086. };
  1087.  
  1088. var $gameBattleTags = new Game_BattleTags();
  1089.  
  1090. //=============================================================================
  1091. // DataManager
  1092. //=============================================================================
  1093.  
  1094. ICF.MainUtility.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded;
  1095. DataManager.isDatabaseLoaded = function() {
  1096.     if (!ICF.MainUtility.DataManager_isDatabaseLoaded.call(this)) return false;
  1097.     if (!ICF.MainUtility.Procesed) {
  1098.     ICF.NotetagsProcessor.MainUtility1();
  1099.     ICF.NotetagsProcessor.MainUtility2();
  1100.     ICF.MainUtility.Procesed = true;
  1101.     }
  1102.     return true;
  1103. };
  1104.  
  1105. ICF.NotetagsProcessor.MainUtility1 = function() {
  1106.     for (var n = 0; n < ICF.Param.subTraits.length; n++) {
  1107.     var obj = ICF.Param.subTraits[n];
  1108.     ICF.Param.subTraits[n] = [];
  1109.     var notedata = obj.split(/[\r\n]+/);
  1110.     for (var i = 0; i < notedata.length; i++) {
  1111.         var line = notedata[i].split(/\s+/).clean();
  1112.         if (isNaN(Number(line[0]))) {line = ICF.MainUtility.gettfield(line);};
  1113.         if (line[0] > -1) {ICF.Param.subTraits[n].push({code:Number(line[0]), dataId:Number(line[1]), value:Number(line[2])});};
  1114.     }
  1115.     }
  1116. };
  1117.  
  1118. ICF.NotetagsProcessor.MainUtility2 = function() {
  1119.     for (var n = 0; n < ICF.Param.subEffects.length; n++) {
  1120.     var obj = ICF.Param.subEffects[n];
  1121.     ICF.Param.subEffects[n] = [];
  1122.     var notedata = obj.split(/[\r\n]+/);
  1123.     for (var i = 0; i < notedata.length; i++) {
  1124.         var line = notedata[i].split(/\s+/).clean();
  1125.         if (isNaN(Number(line[0]))) {line = ICF.MainUtility.getefield(line);};
  1126.         if (line[0] > -1) {ICF.Param.subEffects[n].push({code:Number(line[0]), dataId:Number(line[1]), value1:Number(line[2]), value2:Number(line[3])});};
  1127.     }
  1128.     }
  1129. };
  1130.  
  1131. ICF.MainUtility.extractMetadata = DataManager.extractMetadata;
  1132. DataManager.extractMetadata = function(data) {
  1133.     ICF.MainUtility.extractMetadata.call(this, data);
  1134.     var note1 = /<(?:JSON[-_ ]MASTER)>/i;
  1135.     var note1b = /<\/(?:JSON[-_ ]MASTER)>/i;
  1136.     var note2 = /<(?:TRAITS[-_ ]MASTER)>/i;
  1137.     var note2b = /<\/(?:TRAITS[-_ ]MASTER)>/i;
  1138.     var note3 = /<(?:SUBTRAITS[-_ ]MASTER)>/i;
  1139.     var note3b = /<\/(?:SUBTRAITS[-_ ]MASTER)>/i;
  1140.     var note4 = /<(?:EFFECTS[-_ ]MASTER)>/i;
  1141.     var note4b = /<\/(?:EFFECTS[-_ ]MASTER)>/i;
  1142.     var note5 = /<(?:SUBEFFECTS[-_ ]MASTER)>/i;
  1143.     var note5b = /<\/(?:SUBEFFECTS[-_ ]MASTER)>/i;
  1144.     var note6 = /<(?:JSEVAL[-_ ]MASTER)[ ]+(\w+(?:\s+\w+)*)[ ]*>/i;
  1145.     var note6b = /<\/(?:JSEVAL[-_ ]MASTER)>/i;
  1146.     var note7 = /<(?:TAGS)[ ]+((?:[\w-_]+\s*)+)>/i;
  1147.     var note7b = /<(?:TAG)[ ]+((?:[\w-_]+\s*)+)>/i;
  1148.  
  1149.     var notedata = data.note.split(/[\r\n]+/);
  1150.  
  1151.     var flag1 = false;
  1152.     var flag2 = false;
  1153.     var flag3 = false;
  1154.     var flag4 = false;
  1155.     var flag5 = false;
  1156.     var flag6 = false;
  1157.  
  1158.     var subindex = -1;
  1159.     var subeindex = -1;
  1160.  
  1161.     data.jsreactions = data.jsreactions || {};
  1162.     data.tags = data.tags || [];
  1163.     var key = '';
  1164.  
  1165.     for (var i = 0; i < notedata.length; i++) {
  1166.     var line = notedata[i].trim().replace(/\s+/g, ' ');
  1167.     if (line.match(note1)) {
  1168.         flag1 = true;
  1169.     } else if (line.match(note1b)) {
  1170.         flag1 = false;
  1171.     } else if (line.match(note2)) {
  1172.         flag2 = true;
  1173.         data.traits = data.traits || [];
  1174.     } else if (line.match(note2b)) {
  1175.         flag2 = false;
  1176.     } else if (line.match(note3)) {
  1177.         flag3 = true;
  1178.         subindex += 1;
  1179.         data.subtraits = data.subtraits || [];
  1180.         data.subtraits[subindex] = data.subtraits[subindex] || {};
  1181.         data.subtraits[subindex].traits = data.subtraits[subindex].traits || [];
  1182.     } else if (line.match(note3b)) {
  1183.         flag3 = false;
  1184.     } else if (line.match(note4)) {
  1185.         flag4 = true;
  1186.         data.effects = data.effects || [];
  1187.     } else if (line.match(note4b)) {
  1188.         flag4 = false;
  1189.     } else if (line.match(note5)) {
  1190.         flag5 = true;
  1191.         subeindex += 1;
  1192.         data.subeffects = data.subeffects || [];
  1193.         data.subeffects[subeindex] = data.subeffects[subeindex] || {};
  1194.         data.subeffects[subeindex].effects = data.subeffects[subeindex].effects || [];
  1195.     } else if (line.match(note5b)) {
  1196.         flag5 = false;
  1197.     } else if (line.match(note6)) {
  1198.         flag6 = true;
  1199.         key = RegExp.$1.split(/\s+/);
  1200.         data.jsreactions[key] = data.jsreactions[key] || '';
  1201.     } else if (line.match(note6b)) {
  1202.         flag6 = false;
  1203.         key = '';
  1204.     } else if (line.match(note7)) {
  1205.         data.tags = data.tags.concat(RegExp.$1.trim().split(/\s+/));
  1206.     } else if (line.match(note7b)) {
  1207.         data.tags = data.tags.push(RegExp.$1.trim());
  1208.     } else if (flag1) {
  1209.         var field = line.split(":")[0];
  1210.         line = line.substring(line.indexOf(':') + 1);
  1211.         data[field] = JsonEx.parse(line);
  1212.     } else if (flag2) {
  1213.         line = line.split(/\s+/).clean();
  1214.         if (isNaN(Number(line[0]))) {line = ICF.MainUtility.gettfield(line);};
  1215.         if (line[0] > -1) {data.traits.push({code:Number(line[0]), dataId:Number(line[1]), value:Number(line[2])});};
  1216.     } else if (flag3) {
  1217.         line = line.split(/\s+/).clean();
  1218.         if (isNaN(Number(line[0]))) {line = ICF.MainUtility.gettfield(line);};
  1219.         if (line[0] > -1) {data.subtraits[subindex].traits.push({code:Number(line[0]), dataId:Number(line[1]), value:Number(line[2])});};
  1220.     } else if (flag4) {
  1221.         line = line.split(/\s+/).clean();
  1222.         if (isNaN(Number(line[0]))) {line = ICF.MainUtility.getefield(line);};
  1223.         if (line[0] > -1) {data.effects.push({code:Number(line[0]), dataId:Number(line[1]), value1:Number(line[2]), value2:Number(line[3])});};
  1224.     } else if (flag5) {
  1225.         line = line.split(/\s+/).clean();
  1226.         if (isNaN(Number(line[0]))) {line = ICF.MainUtility.getefield(line);};
  1227.         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])});};
  1228.     } else if (flag6) {
  1229.         data.jsreactions[key] = data.jsreactions[key] + line + '\n';
  1230.     }
  1231.  
  1232.     }
  1233. };
  1234.  
  1235. if (!Imported.ICFSoft_MainCore) {
  1236.     ICF.MainUtility.createGameObjects = DataManager.createGameObjects;
  1237.     DataManager.createGameObjects = function() {
  1238.     ICF.MainUtility.createGameObjects.call(this);
  1239.     $gameSelfVariables = new Game_SelfVariables();
  1240.     };
  1241.  
  1242.     ICF.MainUtility.extractSaveContents = DataManager.extractSaveContents;
  1243.     DataManager.extractSaveContents = function(contents) {
  1244.     ICF.MainUtility.extractSaveContents.call(this, contents);
  1245.     $gameSelfVariables = contents.selfVariables;
  1246.     if (!$gameSelfVariables) $gameSelfVariables = new Game_SelfVariables();
  1247.     };
  1248.  
  1249.     ICF.MainUtility.makeSaveContents = DataManager.makeSaveContents;
  1250.     DataManager.makeSaveContents = function() {
  1251.     var contents = ICF.MainUtility.makeSaveContents.call(this);
  1252.     contents.selfvariables = $gameSelfvariables;
  1253.     return contents;
  1254.     };
  1255.  
  1256.     DataManager.loadDataArrayFiles = function(name, index, src) {
  1257.     window[name] = window[name] || [];
  1258.     var xhr = new XMLHttpRequest();
  1259.     var url = 'data/' + src;
  1260.     xhr.open('GET', url);
  1261.     xhr.overrideMimeType('application/json');
  1262.     xhr.onload = function() {
  1263.         if (xhr.status < 400) {
  1264.             window[name][index] = JSON.parse(xhr.responseText);
  1265.             DataManager.onLoad(window[name][index]);
  1266.         }
  1267.     };
  1268.     xhr.onerror = function() {
  1269.         DataManager._errorUrl = DataManager._errorUrl || url;
  1270.     };
  1271.     window[name][index] = null;
  1272.     xhr.send();
  1273.     };
  1274.  
  1275.     DataManager.loadDataObjFiles = function(name, key, src) {
  1276.     window[name] = window[name] || {};
  1277.     var xhr = new XMLHttpRequest();
  1278.     var url = 'data/' + src;
  1279.     xhr.open('GET', url);
  1280.     xhr.overrideMimeType('application/json');
  1281.     xhr.onload = function() {
  1282.         if (xhr.status < 400) {
  1283.             window[name][key] = JSON.parse(xhr.responseText);
  1284.             DataManager.onLoad(window[name][key]);
  1285.         }
  1286.     };
  1287.     xhr.onerror = function() {
  1288.         DataManager._errorUrl = DataManager._errorUrl || url;
  1289.     };
  1290.     window[name][key] = null;
  1291.     xhr.send();
  1292.     };
  1293.  
  1294. } else {
  1295.     ICF.MainUtility.createGameObjects = DataManager.createGameObjectsPhase1;
  1296.     DataManager.createGameObjectsPhase1 = function() {
  1297.     ICF.MainUtility.createGameObjects.call(this);
  1298.     $gameSelfVariables = new Game_SelfVariables();
  1299.     };
  1300.  
  1301.     ICF.MainUtility.extractSaveContents = DataManager.extractSaveContentsPhase1;
  1302.     DataManager.extractSaveContentsPhase1 = function(contents) {
  1303.     ICF.MainUtility.extractSaveContents.call(this, contents);
  1304.     $gameSelfVariables = contents.selfVariables;
  1305.     if (!$gameSelfVariables) $gameSelfVariables = new Game_SelfVariables();
  1306.     };
  1307.  
  1308.     ICF.MainUtility.makeSaveContents = DataManager.makeSaveContentsPhase1;
  1309.     DataManager.makeSaveContentsPhase1 = function() {
  1310.     var contents = ICF.MainUtility.makeSaveContents.call(this);
  1311.     contents.selfvariables = $gameSelfvariables;
  1312.     return contents;
  1313.     };
  1314.  
  1315. }
  1316.  
  1317.  
  1318. //=============================================================================
  1319. // Game_BattlerBase
  1320. //=============================================================================
  1321.  
  1322. Object.defineProperty(Game_BattlerBase.prototype, 'level', { value: 1, configurable: true});
  1323.  
  1324. if (!Game_BattlerBase.prototype.equips) Game_BattlerBase.prototype.equips = function() { return []; };
  1325. if (!Game_BattlerBase.prototype.weapons) Game_BattlerBase.prototype.weapons = function() { return []; };
  1326. if (!Game_BattlerBase.prototype.armors) Game_BattlerBase.prototype.armors = function() { return []; };
  1327. if (!Game_BattlerBase.prototype.currentClass) Game_BattlerBase.prototype.currentClass = function() { return null; };
  1328.  
  1329. Game_BattlerBase.prototype.hasWeapon = function(weapon) {
  1330.     return this.weapons().contains(weapon);
  1331. };
  1332.  
  1333. Game_BattlerBase.prototype.hasArmor = function(armor) {
  1334.     return this.armors().contains(armor);
  1335. };
  1336.  
  1337.  
  1338. ICF.MainUtility.traitObjects = Game_BattlerBase.prototype.traitObjects;
  1339. Game_BattlerBase.prototype.traitObjects = function() {
  1340.     if (!this._traitsObject) {
  1341.     this._traitsObject = {};
  1342.     this._traitsObject.traits = [];
  1343.     }
  1344.     return ICF.MainUtility.traitObjects.call(this).concat([this._traitsObject]);
  1345. };
  1346.  
  1347. ICF.MainUtility.initMembers = Game_BattlerBase.prototype.initMembers;
  1348. Game_BattlerBase.prototype.initMembers = function() {
  1349.     ICF.MainUtility.initMembers.call(this);
  1350.     this._traitsObject = {};
  1351.     this._traitsObject.traits = [];
  1352.     this._tags = [];
  1353. };
  1354.  
  1355. Game_BattlerBase.prototype.clearTraits = function() {
  1356.     if (!this._traitsObject) {
  1357.     this._traitsObject = {};
  1358.     }
  1359.     this._traitsObject.traits = [];
  1360. };
  1361.  
  1362. Game_BattlerBase.prototype.addTrait = function(code, dataid, value) {
  1363.     if (!this._traitsObject) {
  1364.     this._traitsObject = {};
  1365.     this._traitsObject.traits = [];
  1366.     }
  1367.     ICF.MainUtility.addTrait(this._traitsObject, 0, code, dataid, value);
  1368. };
  1369.  
  1370. Game_BattlerBase.prototype.setTrait = function(code, dataid, value) {
  1371.     if (!this._traitsObject) {
  1372.     this._traitsObject = {};
  1373.     this._traitsObject.traits = [];
  1374.     }
  1375.     ICF.MainUtility.addTrait(this._traitsObject, 1, code, dataid, value);
  1376. };
  1377.  
  1378. Game_BattlerBase.prototype.increaseTrait = function(code, dataid, value) {
  1379.     if (!this._traitsObject) {
  1380.     this._traitsObject = {};
  1381.     this._traitsObject.traits = [];
  1382.     }
  1383.     ICF.MainUtility.addTrait(this._traitsObject, 2, code, dataid, value);
  1384. };
  1385.  
  1386. Game_BattlerBase.prototype.multiplyTrait = function(code, dataid, value) {
  1387.     if (!this._traitsObject) {
  1388.     this._traitsObject = {};
  1389.     this._traitsObject.traits = [];
  1390.     }
  1391.     ICF.MainUtility.addTrait(this._traitsObject, 3, code, dataid, value);
  1392. };
  1393.  
  1394. Game_BattlerBase.prototype.removeTrait = function(code, dataid) {
  1395.     if (!this._traitsObject) {
  1396.     this._traitsObject = {};
  1397.     this._traitsObject.traits = [];
  1398.     }
  1399.     ICF.MainUtility.removeTrait(this._traitsObject, code, dataid);
  1400. };
  1401.  
  1402. Game_BattlerBase.prototype.selfswitch = function(selfswitch) { return false;};
  1403.  
  1404. Game_BattlerBase.prototype.selfswitches = function() { return [];};
  1405.  
  1406. Game_BattlerBase.prototype.selfswitchNames = function() { return [];};
  1407.  
  1408. Game_BattlerBase.prototype.setselfswitch = function(selfswitch, value) { };
  1409.  
  1410. Game_BattlerBase.prototype.battleswitch = function(selfswitch) { return false;};
  1411.  
  1412. Game_BattlerBase.prototype.setbattleswitch = function(selfswitch, value) { };
  1413.  
  1414. Game_BattlerBase.prototype.selfvariable = function(selfvariable) { return 0;};
  1415.  
  1416. Game_BattlerBase.prototype.strictselfvariable = function(selfvariable) { return 0;};
  1417.  
  1418. Game_BattlerBase.prototype.selfvariables = function() { return [];};
  1419.  
  1420. Game_BattlerBase.prototype.selfvariableNames = function() { return [];};
  1421.  
  1422. Game_BattlerBase.prototype.setselfvariable = function(selfvariable, value) { };
  1423.  
  1424. Game_BattlerBase.prototype.increaseselfvariable = function(selfvariable, value) { };
  1425.  
  1426. Game_BattlerBase.prototype.multiplyselfvariable = function(selfvariable, value) { };
  1427.  
  1428. Game_BattlerBase.prototype.divideselfvariable = function(selfvariable, value) { };
  1429.  
  1430. Game_BattlerBase.prototype.modselfvariable = function(selfvariable, value) { };
  1431.  
  1432. Game_BattlerBase.prototype.battlevariable = function(selfvariable) { return 0;};
  1433.  
  1434. Game_BattlerBase.prototype.strictbattlevariable = function(selfvariable) { return 0;};
  1435.  
  1436. Game_BattlerBase.prototype.setbattlevariable = function(selfvariable, value) { };
  1437.  
  1438. Game_BattlerBase.prototype.increasebattlevariable = function(selfvariable, value) { };
  1439.  
  1440. Game_BattlerBase.prototype.multiplybattlevariable = function(selfvariable, value) { };
  1441.  
  1442. Game_BattlerBase.prototype.dividebattlevariable = function(selfvariable, value) { };
  1443.  
  1444. Game_BattlerBase.prototype.modbattlevariable = function(selfvariable, value) { };
  1445.  
  1446. Game_BattlerBase.prototype.addTag = function(tag) {
  1447.     if (!this._tags) this._tags = [];
  1448.     this._tags.push(tag);
  1449. };
  1450.  
  1451. Game_BattlerBase.prototype.addTags = function(tags) {
  1452.     if (!this._tags) this._tags = [];
  1453.     this._tags = this._tags.concat(tags);
  1454. };
  1455.  
  1456. Game_BattlerBase.prototype.removeTag = function(tag) {
  1457.     if (!this._tags) this._tags = [];
  1458.     var i = this._tags.indexOf(tag);
  1459.     while (i > -1) {
  1460.     this._tags.splice(i,1);
  1461.     i = this._tags.indexOf(tag);
  1462.     }
  1463. };
  1464.  
  1465. Game_BattlerBase.prototype.removeTags = function(tags) {
  1466.     if (!this._tags) this._tags = [];
  1467.     for (var i = 0; i < tags.length; i++) {
  1468.     var j = this._tags.indexOf(tags[i]);
  1469.     while (j > -1) {
  1470.         this._tags.splice(j,1);
  1471.         j = this._tags.indexOf(tags[i]);
  1472.     }
  1473.     }
  1474. };
  1475.  
  1476. Game_BattlerBase.prototype.clearTags = function() {
  1477.     this._tags = [];
  1478. };
  1479.  
  1480. Game_BattlerBase.prototype.addBattleTag = function(tag) {
  1481.     this.battleTags().push(tag);
  1482. };
  1483.  
  1484. Game_BattlerBase.prototype.addBattleTags = function(tags) {
  1485.     var tagss = this.battleTags();
  1486.     for (var i = 0; i < tags.length; i++) {
  1487.     tagss.push(tags[i]);
  1488.     }
  1489. };
  1490.  
  1491. Game_BattlerBase.prototype.removeBattleTag = function(tag) {
  1492.     var tags = this.battleTags();
  1493.     var i = tags.indexOf(tag);
  1494.     while (i > -1) {
  1495.     tags.splice(i,1);
  1496.     i = tags.indexOf(tag);
  1497.     }
  1498. };
  1499.  
  1500. Game_BattlerBase.prototype.removeBattleTags = function(tags) {
  1501.     var tagss = this.battleTags();
  1502.     for (var i = 0; i < tags.length; i++) {
  1503.     var j = tagss.indexOf(tags[i]);
  1504.     while (j > -1) {
  1505.         tagss.splice(j,1);
  1506.         j = tagss.indexOf(tags[i]);
  1507.     }
  1508.     }
  1509. };
  1510.  
  1511. Game_BattlerBase.prototype.clearBattleTags = function() {};
  1512.  
  1513. Game_BattlerBase.prototype.hasBaseTag = function(tag) {
  1514.     return this.baseTags().contains(tag);
  1515. };
  1516.  
  1517. Game_BattlerBase.prototype.hasStateTag = function(tag, fix) {
  1518.     return this.stateTags().contains(tag);
  1519. };
  1520.  
  1521. Game_BattlerBase.prototype.hasWeaponTag = function(tag) {
  1522.     return this.weaponTags().contains(tag);
  1523. };
  1524.  
  1525. Game_BattlerBase.prototype.hasArmorTag = function(tag) {
  1526.     return this.armorTags().contains(tag);
  1527. };
  1528.  
  1529. Game_BattlerBase.prototype.hasEquipTag = function(tag) {
  1530.     return this.equipTags().contains(tag);
  1531. };
  1532.  
  1533. Game_BattlerBase.prototype.hasTag = function(tag, fix) {
  1534.     return this.allTags(fix).contains(tag);
  1535. };
  1536.  
  1537. Game_BattlerBase.prototype.countBaseTags = function(tags) {
  1538.     var r = 0;
  1539.     var tagss = this.baseTags();
  1540.     for (var i = 0; i < tags.length; i++) {
  1541.     if (tagss.contains(tags[i])) r++;
  1542.     }
  1543.     return r;
  1544. };
  1545.  
  1546. Game_BattlerBase.prototype.countStateTags = function(tags, fix) {
  1547.     var r = 0;
  1548.     var tagss = this.stateTags(fix);
  1549.     for (var i = 0; i < tags.length; i++) {
  1550.     if (tagss.contains(tags[i])) r++;
  1551.     }
  1552.     return r;
  1553. };
  1554.  
  1555. Game_BattlerBase.prototype.countWeaponTags = function(tags) {
  1556.     var r = 0;
  1557.     var tagss = this.weaponTags();
  1558.     for (var i = 0; i < tags.length; i++) {
  1559.     if (tagss.contains(tags[i])) r++;
  1560.     }
  1561.     return r;
  1562. };
  1563.  
  1564. Game_BattlerBase.prototype.countArmorTags = function(tags) {
  1565.     var r = 0;
  1566.     var tagss = this.armorTags();
  1567.     for (var i = 0; i < tags.length; i++) {
  1568.     if (tagss.contains(tags[i])) r++;
  1569.     }
  1570.     return r;
  1571. };
  1572.  
  1573. Game_BattlerBase.prototype.countEquipTags = function(tags) {
  1574.     var r = 0;
  1575.     var tagss = this.equipTags();
  1576.     for (var i = 0; i < tags.length; i++) {
  1577.     if (tagss.contains(tags[i])) r++;
  1578.     }
  1579.     return r;
  1580. };
  1581.  
  1582. Game_BattlerBase.prototype.countTags = function(tags, fix) {
  1583.     var r = 0;
  1584.     var tagss = this.allTags(fix);
  1585.     for (var i = 0; i < tags.length; i++) {
  1586.     if (tagss.contains(tags[i])) r++;
  1587.     }
  1588.     return r;
  1589. };
  1590.  
  1591. Game_BattlerBase.prototype.baseTags = function() {
  1592.     if (!this._tags) this._tags = [];
  1593.     return this._tags;
  1594. };
  1595.  
  1596. Game_BattlerBase.prototype.battleTags = function() {
  1597.     return [];
  1598. };
  1599.  
  1600. Game_BattlerBase.prototype.stateTags = function(fix) {
  1601.     if (fix) return this._states.reduce(function(r, obj) {
  1602.         return r.concat([obj.tags]);
  1603.     }, []);
  1604.     return this.states().reduce(function(r, obj) {
  1605.         return r.concat([obj.tags]);
  1606.     }, []);
  1607. };
  1608.  
  1609. Game_BattlerBase.prototype.weaponTags = function() {
  1610.     var tags = [];
  1611.     var equips = this.weapons();
  1612.     for (var i = 0; i < equips.length; i++) {
  1613.         var item = equips[i];
  1614.         if (item) {
  1615.             tags = tags.concat(item.tags);
  1616.         }
  1617.     }
  1618.     return tags;
  1619. };
  1620.  
  1621. Game_BattlerBase.prototype.armorTags = function() {
  1622.     var tags = [];
  1623.     var equips = this.armors();
  1624.     for (var i = 0; i < equips.length; i++) {
  1625.         var item = equips[i];
  1626.         if (item) {
  1627.             tags = tags.concat(item.tags);
  1628.         }
  1629.     }
  1630.     return tags;
  1631. };
  1632.  
  1633. Game_BattlerBase.prototype.equipTags = function() {
  1634.     var tags = [];
  1635.     var equips = this.equips();
  1636.     for (var i = 0; i < equips.length; i++) {
  1637.         var item = equips[i];
  1638.         if (item) {
  1639.             tags = tags.concat(item.tags);
  1640.         }
  1641.     }
  1642.     return tags;
  1643. };
  1644.  
  1645. Game_BattlerBase.prototype.allTags = function(fix) {
  1646.     if (!this._tags) this._tags = [];
  1647.     if (fix) return this._tags.concat(this._states.reduce(function(r, obj) {
  1648.         return r.concat([obj.tags]);
  1649.     }, [])).concat((this.friendsUnit().inBattle())? this.battleTags() : []);
  1650.     return this._tags.concat(this.states().reduce(function(r, obj) {
  1651.         return r.concat([obj.tags]);
  1652.     }, [])).concat((this.friendsUnit().inBattle())? this.battleTags() : []);
  1653. };
  1654.  
  1655. Game_BattlerBase.prototype.jsevalObjects = function() {
  1656.     return this.states().filter(function(obj) {
  1657.         return Object.keys(obj.jsreactions).length > 0;
  1658.     });
  1659. };
  1660.  
  1661. Game_BattlerBase.prototype.jsevalReactions = function(subject, item, isSkill, reaction) {
  1662.     var jsevalobjects = this.jsevalObjects();
  1663.     var s = $gameSwitches._data;
  1664.     var v = $gameVariables._data;
  1665.  
  1666.     for (var h = 0; h < jsevalobjects.length; h++) {
  1667.     if (jsevalobjects[h].jsreactions[reaction]) eval(jsevalobjects[h].jsreactions[reaction]);
  1668.     }
  1669. };
  1670.  
  1671. Game_BattlerBase.prototype.jsevalArrayReactions = function(subject, item, isSkill, reactions) {
  1672.     var jsevalobjects = this.jsevalObjects();
  1673.     var s = $gameSwitches._data;
  1674.     var v = $gameVariables._data;
  1675.  
  1676.     for (var h = 0; h < jsevalobjects.length; h++) {
  1677.     for (var i = 0; i < reactions.length; i++) {
  1678.         if (jsevalobjects[h].jsreactions[reactions[i]]) eval(jsevalobjects[h].jsreactions[reactions[i]]);
  1679.     }
  1680.     }
  1681. };
  1682.  
  1683. Game_BattlerBase.prototype.jsevalBulkReactions = function(subject, item, isSkill, reactions) {
  1684.     var jsevalobjects = this.jsevalObjects();
  1685.     var s = $gameSwitches._data;
  1686.     var v = $gameVariables._data;
  1687.  
  1688.     for (var h = 0; h < jsevalobjects.length; h++) {
  1689.     for (var i = 0; i < reactions.length; i++) {
  1690.         for (var j = 0; j < reactions[i][1].length; j++) {
  1691.             var key = [reactions[i][0],reactions[i][1][j]];
  1692.             if (jsevalobjects[h].jsreactions[key]) eval(jsevalobjects[h].jsreactions[key]);
  1693.         }
  1694.     }
  1695.     }
  1696. };
  1697.  
  1698. //=============================================================================
  1699. // Game_Battler
  1700. //=============================================================================
  1701.  
  1702. if (!Imported.ICFSoft_MainCore) {
  1703.     Game_Battler.prototype.gainHp = function(value) {
  1704.     this._result.hpDamage -= value;
  1705.     this._result.hpAffected = true;
  1706.     this.setHp(this.hp + value);
  1707.     };
  1708.  
  1709.     Game_Battler.prototype.gainMp = function(value) {
  1710.     this._result.mpDamage -= value;
  1711.     this.setMp(this.mp + value);
  1712.     };
  1713.  
  1714.     Game_Battler.prototype.gainTp = function(value) {
  1715.     this._result.tpDamage -= value;
  1716.     this.setTp(this.tp + value);
  1717.     };
  1718. }
  1719.  
  1720. //=============================================================================
  1721. // Game_Actor
  1722. //=============================================================================
  1723.  
  1724. Game_Actor.prototype.selfswitch = function(selfswitch) {
  1725.     var key = [0, this._actorId, selfswitch];
  1726.     return $gameSelfSwitches.value(key);
  1727. }
  1728.  
  1729. Game_Actor.prototype.selfswitches = function() {
  1730.     return $gameSelfSwitches.filter(0, this._actorId);
  1731. }
  1732.  
  1733. Game_Actor.prototype.selfswitchNames = function() {
  1734.     return $gameSelfSwitches.filter(0, this._actorId).reduce(function(r, obj) {
  1735.         return r.concat([obj[2]]);
  1736.     }, []);
  1737. }
  1738.  
  1739. Game_Actor.prototype.setselfswitch = function(selfswitch, value) {
  1740.     ICF.MainUtility.CustomSwitch(0, this._actorId, selfswitch, value);
  1741. }
  1742.  
  1743. Game_Actor.prototype.battleswitch = function(selfswitch) {
  1744.     var key = [0, this._actorId, selfswitch];
  1745.     return $gameBattleSwitches.value(key);
  1746. }
  1747.  
  1748. Game_Actor.prototype.setbattleswitch = function(selfswitch, value) {
  1749.     ICF.MainUtility.BattleSwitch(0, this._actorId, selfswitch, value);
  1750. }
  1751.  
  1752. Game_Actor.prototype.selfvariable = function(selfvariable) {
  1753.     var key = [0, this._actorId, selfvariable];
  1754.     return $gameSelfVariables.value(key);
  1755. }
  1756.  
  1757. Game_Actor.prototype.strictselfvariable = function(selfvariable) {
  1758.     var key = [0, this._actorId, selfvariable];
  1759.     return $gameSelfVariables.strictValue(key);
  1760. }
  1761.  
  1762. Game_Actor.prototype.selfvariables = function() {
  1763.     return $gameSelfVariables.filter(0, this._actorId);
  1764. }
  1765.  
  1766. Game_Actor.prototype.selfvariableNames = function() {
  1767.     return $gameSelfVariables.filter(0, this._actorId).reduce(function(r, obj) {
  1768.         return r.concat([obj[2]]);
  1769.     }, []);
  1770. }
  1771.  
  1772. Game_Actor.prototype.setselfvariable = function(selfvariable, value) {
  1773.     ICF.MainUtility.CustomVariable(0, this._actorId, selfvariable, value);
  1774. }
  1775.  
  1776. Game_Actor.prototype.increaseselfvariable = function(selfvariable, value) {
  1777.     ICF.MainUtility.IncreaseCustomVariable(0, this._actorId, selfvariable, value);
  1778. }
  1779.  
  1780. Game_Actor.prototype.multiplyselfvariable = function(selfvariable, value) {
  1781.     ICF.MainUtility.MultiplyCustomVariable(0, this._actorId, selfvariable, value);
  1782. }
  1783.  
  1784. Game_Actor.prototype.divideselfvariable = function(selfvariable, value) {
  1785.     ICF.MainUtility.DivideCustomVariable(0, this._actorId, selfvariable, value);
  1786. }
  1787.  
  1788. Game_Actor.prototype.modselfvariable = function(selfvariable, value) {
  1789.     ICF.MainUtility.ModCustomVariable(0, this._actorId, selfvariable, value);
  1790. }
  1791.  
  1792. Game_Actor.prototype.battlevariable = function(battlevariable) {
  1793.     var key = [0, this._actorId, battlevariable];
  1794.     return $gameBattleVariables.value(key);
  1795. }
  1796.  
  1797. Game_Actor.prototype.strictbattlevariable = function(battlevariable) {
  1798.     var key = [0, this._actorId, battlevariable];
  1799.     return $gameBattleVariables.strictValue(key);
  1800. }
  1801.  
  1802. Game_Actor.prototype.setbattlevariable = function(battlevariable, value) {
  1803.     ICF.MainUtility.BattleVariable(0, this._actorId, battlevariable, value);
  1804. }
  1805.  
  1806. Game_Actor.prototype.increasebattlevariable = function(battlevariable, value) {
  1807.     ICF.MainUtility.IncreaseBattleVariable(0, this._actorId, battlevariable, value);
  1808. }
  1809.  
  1810. Game_Actor.prototype.multiplybattlevariable = function(battlevariable, value) {
  1811.     ICF.MainUtility.MultiplyBattleVariable(0, this._actorId, battlevariable, value);
  1812. }
  1813.  
  1814. Game_Actor.prototype.dividebattlevariable = function(battlevariable, value) {
  1815.     ICF.MainUtility.DivideBattleVariable(0, this._actorId, battlevariable, value);
  1816. }
  1817.  
  1818. Game_Actor.prototype.modbattlevariable = function(battlevariable, value) {
  1819.     ICF.MainUtility.ModBattleVariable(0, this._actorId, battlevariable, value);
  1820. }
  1821.  
  1822. Game_Actor.prototype.baseTags = function() {
  1823.     return Game_BattlerBase.prototype.baseTags.call(this).concat(this.actor().tags).concat(this.currentClass().tags);
  1824. };
  1825.  
  1826. Game_Actor.prototype.allTags = function(fix) {
  1827.     var tags = Game_BattlerBase.prototype.allTags.call(this, fix).concat(this.actor().tags).concat(this.currentClass().tags);
  1828.     var equips = this.equips();
  1829.     for (var i = 0; i < equips.length; i++) {
  1830.         var item = equips[i];
  1831.         if (item) {
  1832.             tags = tags.concat(item.tags);
  1833.         }
  1834.     }
  1835.     return tags;
  1836. };
  1837.  
  1838. Game_Actor.prototype.battleTags = function() {
  1839.     return $gameBattleTags.actorTags(this._actorId);
  1840. };
  1841.  
  1842. Game_Actor.prototype.clearBattleTags = function() {
  1843.     $gameBattleTags.clearActorTags(this._actorId);
  1844. };
  1845.  
  1846. Game_Actor.prototype.jsevalObjects = function() {
  1847.     var objects = [this.actor(), this.currentClass()];
  1848.     objects = objects.concat(Game_Battler.prototype.jsevalObjects.call(this));
  1849.     var equips = this.equips();
  1850.     for (var i = 0; i < equips.length; i++) {
  1851.         var item = equips[i];
  1852.         if (item) {
  1853.             objects.push(item);
  1854.         }
  1855.     }
  1856.     return objects.filter(function(obj) {
  1857.         return Object.keys(obj.jsreactions).length > 0;
  1858.     });
  1859. };
  1860.  
  1861. //=============================================================================
  1862. // Game_Enemy
  1863. //=============================================================================
  1864.  
  1865. Game_Enemy.prototype.selfswitch = function(selfswitch) {
  1866.     var key = ["e", this._enemyId, selfswitch];
  1867.     return $gameSelfSwitches.value(key);
  1868. }
  1869.  
  1870. Game_Enemy.prototype.selfswitches = function() {
  1871.     return $gameSelfSwitches.filter("e", this._enemyId);
  1872. }
  1873.  
  1874. Game_Enemy.prototype.selfswitchNames = function() {
  1875.     return $gameSelfSwitches.filter("e", this._enemyId).reduce(function(r, obj) {
  1876.         return r.concat([obj[2]]);
  1877.     }, []);
  1878. }
  1879.  
  1880. Game_Enemy.prototype.setselfswitch = function(selfswitch, value) {
  1881.     ICF.MainUtility.CustomSwitch("e", this._enemyId, selfswitch, value);
  1882. }
  1883.  
  1884. Game_Enemy.prototype.battleswitch = function(battleswitch) {
  1885.     var key = ["e", this.index(), battleswitch];
  1886.     return $gameBattleSwitches.value(key);
  1887. }
  1888.  
  1889. Game_Enemy.prototype.setbattleswitch = function(battleswitch, value) {
  1890.     var key = ["e", this.index(), battleswitch];
  1891.     value = (value.toString().toLowerCase() === "true");
  1892.     $gameBattleSwitches.setValue(key, value);
  1893. }
  1894.  
  1895. Game_Enemy.prototype.selfvariable = function(selfvariable) {
  1896.     var key = ["e", this._enemyId, selfvariable];
  1897.     return $gameSelfVariables.value(key);
  1898. }
  1899.  
  1900. Game_Enemy.prototype.strictselfvariable = function(selfvariable) {
  1901.     var key = ["e", this._enemyId, selfvariable];
  1902.     return $gameSelfVariables.strictValue(key);
  1903. }
  1904.  
  1905. Game_Enemy.prototype.selfvariables = function() {
  1906.     return $gameSelfVariables.filter("e", this._enemyId);
  1907. }
  1908.  
  1909. Game_Enemy.prototype.selfvariableNames = function() {
  1910.     return $gameSelfVariables.filter("e", this._enemyId).reduce(function(r, obj) {
  1911.         return r.concat([obj[2]]);
  1912.     }, []);
  1913. }
  1914.  
  1915. Game_Enemy.prototype.setselfvariable = function(selfvariable, value) {
  1916.     var _key = ["e", this._enemyId, selfvariable];
  1917.     $gameSelfVariables.setValue(_key, value);
  1918. }
  1919.  
  1920. Game_Enemy.prototype.increaseselfvariable = function(selfvariable, value) {
  1921.     var _key = ["e", this._enemyId, selfvariable];
  1922.     $gameSelfVariables.increaseValue(_key, value);
  1923. }
  1924.  
  1925. Game_Enemy.prototype.multiplyselfvariable = function(selfvariable, value) {
  1926.     var _key = ["e", this._enemyId, selfvariable];
  1927.     $gameSelfVariables.multiplyValue(_key, value);
  1928. }
  1929.  
  1930. Game_Enemy.prototype.divideselfvariable = function(selfvariable, value) {
  1931.     var _key = ["e", this._enemyId, selfvariable];
  1932.     $gameSelfVariables.divideValue(_key, value);
  1933. }
  1934.  
  1935. Game_Enemy.prototype.modselfvariable = function(selfvariable, value) {
  1936.     var _key = ["e", this._enemyId, selfvariable];
  1937.     $gameSelfVariables.modValue(_key, value);
  1938. }
  1939.  
  1940. Game_Enemy.prototype.battlevariable = function(battlevariable) {
  1941.     var key = ["e", this.index(), battlevariable];
  1942.     return $gameBattleVariables.value(key);
  1943. }
  1944.  
  1945. Game_Enemy.prototype.strictbattlevariable = function(battlevariable) {
  1946.     var key = ["e", this.index(), battlevariable];
  1947.     return $gameBattleVariables.strictValue(key);
  1948. }
  1949.  
  1950. Game_Enemy.prototype.setbattlevariable = function(battlevariable, value) {
  1951.     var _key = ["e", this.index(), battlevariable];
  1952.     $gameBattleVariables.setValue(_key, value);
  1953. }
  1954.  
  1955. Game_Enemy.prototype.increasebattlevariable = function(battlevariable, value) {
  1956.     var _key = ["e", this.index(), battlevariable];
  1957.     $gameBattleVariables.increaseValue(_key, value);
  1958. }
  1959.  
  1960. Game_Enemy.prototype.multiplybattlevariable = function(battlevariable, value) {
  1961.     var _key = ["e", this.index(), battlevariable];
  1962.     $gameBattleVariables.multiplyValue(_key, value);
  1963. }
  1964.  
  1965. Game_Enemy.prototype.dividebattlevariable = function(battlevariable, value) {
  1966.     var _key = ["e", this.index(), battlevariable];
  1967.     $gameBattleVariables.divideValue(_key, value);
  1968. }
  1969.  
  1970. Game_Enemy.prototype.modbattlevariable = function(battlevariable, value) {
  1971.     var _key = ["e", this.index(), battlevariable];
  1972.     $gameBattleVariables.modValue(_key, value);
  1973. }
  1974.  
  1975. Game_Enemy.prototype.baseTags = function() {
  1976.     return Game_BattlerBase.prototype.baseTags.call(this).concat(this.enemy().tags);
  1977. };
  1978.  
  1979. Game_Enemy.prototype.allTags = function(fix) {
  1980.     return Game_BattlerBase.prototype.allTags.call(this, fix).concat(this.enemy().tags);
  1981. };
  1982.  
  1983. Game_Enemy.prototype.battleTags = function() {
  1984.     return $gameBattleTags.enemyTags(this.index());
  1985. };
  1986.  
  1987. Game_Enemy.prototype.clearBattleTags = function() {
  1988.     $gameBattleTags.clearEnemyTags(this.index());
  1989. };
  1990.  
  1991. Game_Enemy.prototype.jsevalObjects = function() {
  1992.     var objects = [this.enemy()];
  1993.     objects = objects.concat(Game_Battler.prototype.jsevalObjects.call(this));
  1994.     var equips = this.equips();
  1995.     for (var i = 0; i < equips.length; i++) {
  1996.         var item = equips[i];
  1997.         if (item) {
  1998.             objects.push(item);
  1999.         }
  2000.     }
  2001.     return objects.filter(function(obj) {
  2002.         return Object.keys(obj.jsreactions).length > 0;
  2003.     });
  2004. };
  2005.  
  2006. //=============================================================================
  2007. // Game_Unit
  2008. //=============================================================================
  2009.  
  2010. Game_Unit.prototype.selfswitch = function(selfswitch) { return false;};
  2011.  
  2012. Game_Unit.prototype.selfvariable = function(selfvariable) { return 0;};
  2013.  
  2014. Game_Unit.prototype.maxselfvariable = function(selfvariable) { return 0;};
  2015.  
  2016. Game_Unit.prototype.minselfvariable = function(selfvariable) { return 0;};
  2017.  
  2018. Game_Unit.prototype.avgselfvariable = function(selfvariable) { return 0;};
  2019.  
  2020. Game_Unit.prototype.battleswitch = function(battleswitch) { return false;};
  2021.  
  2022. Game_Unit.prototype.battlevariable = function(battlevariable) { return 0;};
  2023.  
  2024. Game_Unit.prototype.maxbattlevariable = function(battlevariable) { return 0;};
  2025.  
  2026. Game_Unit.prototype.minbattlevariable = function(battlevariable) { return 0;};
  2027.  
  2028. Game_Unit.prototype.avgbattlevariable = function(battlevariable) { return 0;};
  2029.  
  2030. //=============================================================================
  2031. // Game_Troop
  2032. //=============================================================================
  2033.  
  2034. ICF.MainUtility.clearTroop = Game_Troop.prototype.clear;
  2035. Game_Troop.prototype.clear = function() {
  2036.     ICF.MainUtility.clearTroop.call(this);
  2037.     $gameBattleSwitches.clear();
  2038.     $gameBattleVariables.clear();
  2039.     $gameBattleTags.clear();
  2040. };
  2041.  
  2042. Game_Troop.prototype.selfswitch = function(selfswitch) {
  2043.     this.aliveMembers().forEach(function(enemy) {
  2044.         if (enemy.selfswitch(selfswitch)) {
  2045.             return true;
  2046.         }
  2047.     });
  2048.     return false;
  2049. }
  2050.  
  2051. Game_Troop.prototype.selfvariable = function(selfvariable) {
  2052.     var value = 0;
  2053.     this.aliveMembers().forEach(function(enemy) {
  2054.         value += enemy.strictselfvariable(selfvariable);
  2055.     });
  2056.     return Math.floor(value);
  2057. }
  2058.  
  2059. Game_Troop.prototype.maxselfvariable = function(selfvariable) {
  2060.     if (this.aliveMembers().length < 1) return 0;
  2061.     var value = this.aliveMembers()[0].strictselfvariable(selfvariable);
  2062.     this.aliveMembers().forEach(function(enemy) {
  2063.         value = Math.max(value, enemy.strictselfvariable(selfvariable));
  2064.     });
  2065.     return Math.floor(value);
  2066. }
  2067.  
  2068. Game_Troop.prototype.minselfvariable = function(selfvariable) {
  2069.     if (this.aliveMembers().length < 1) return 0;
  2070.     var value = this.aliveMembers()[0].strictselfvariable(selfvariable);
  2071.     this.aliveMembers().forEach(function(enemy) {
  2072.         value = Math.min(value, enemy.strictselfvariable(selfvariable));
  2073.     });
  2074.     return Math.floor(value);
  2075. }
  2076.  
  2077. Game_Troop.prototype.avgselfvariable = function(selfvariable) {
  2078.     if (this.aliveMembers().length < 1) return 0;
  2079.     var value = 0;
  2080.     this.aliveMembers().forEach(function(enemy) {
  2081.         value += enemy.strictselfvariable(selfvariable);
  2082.     });
  2083.     return Math.floor(value / this.aliveMembers().length);
  2084. }
  2085.  
  2086. Game_Troop.prototype.battleswitch = function(battleswitch) {
  2087.     this.aliveMembers().forEach(function(enemy) {
  2088.         if (enemy.battleswitch(battleswitch)) {
  2089.             return true;
  2090.         }
  2091.     });
  2092.     return false;
  2093. }
  2094.  
  2095. Game_Troop.prototype.battlevariable = function(battlevariable) {
  2096.     var value = 0;
  2097.     this.aliveMembers().forEach(function(enemy) {
  2098.         value += enemy.strictbattlevariable(battlevariable);
  2099.     });
  2100.     return Math.floor(value);
  2101. }
  2102.  
  2103. Game_Troop.prototype.maxbattlevariable = function(battlevariable) {
  2104.     if (this.aliveMembers().length < 1) return 0;
  2105.     var value = this.aliveMembers()[0].strictbattlevariable(battlevariable);
  2106.     this.aliveMembers().forEach(function(enemy) {
  2107.         value = Math.max(value, enemy.strictbattlevariable(battlevariable));
  2108.     });
  2109.     return Math.floor(value);
  2110. }
  2111.  
  2112. Game_Troop.prototype.minbattlevariable = function(battlevariable) {
  2113.     if (this.aliveMembers().length < 1) return 0;
  2114.     var value = this.aliveMembers()[0].strictbattlevariable(battlevariable);
  2115.     this.aliveMembers().forEach(function(enemy) {
  2116.         value = Math.min(value, enemy.strictbattlevariable(battlevariable));
  2117.     });
  2118.     return Math.floor(value);
  2119. }
  2120.  
  2121. Game_Troop.prototype.avgbattlevariable = function(battlevariable) {
  2122.     if (this.aliveMembers().length < 1) return 0;
  2123.     var value = 0;
  2124.     this.aliveMembers().forEach(function(enemy) {
  2125.         value += enemy.strictbattlevariable(battlevariable);
  2126.     });
  2127.     return Math.floor(value / this.aliveMembers().length);
  2128. }
  2129.  
  2130. //=============================================================================
  2131. // Game_Party
  2132. //=============================================================================
  2133.  
  2134. Game_Party.prototype.selfswitch = function(selfswitch) {
  2135.     this.allMembers().forEach(function(actor) {
  2136.         if (actor.selfswitch(selfswitch)) {
  2137.             return true;
  2138.         }
  2139.     });
  2140.     return false;
  2141. }
  2142.  
  2143. Game_Party.prototype.selfvariable = function(selfvariable) {
  2144.     var value = 0;
  2145.     this.allMembers().forEach(function(actor) {
  2146.         value += actor.strictselfvariable(selfvariable);
  2147.     });
  2148.     return Math.floor(value);
  2149. }
  2150.  
  2151. Game_Party.prototype.maxselfvariable = function(selfvariable) {
  2152.     if (this.allMembers().length < 1) return 0;
  2153.     var value = this.allMembers()[0].strictselfvariable(selfvariable);
  2154.     this.allMembers().forEach(function(actor) {
  2155.         value = Math.max(value, actor.strictselfvariable(selfvariable));
  2156.     });
  2157.     return Math.floor(value);
  2158. }
  2159.  
  2160. Game_Party.prototype.minselfvariable = function(selfvariable) {
  2161.     if (this.allMembers().length < 1) return 0;
  2162.     var value = this.allMembers()[0].strictselfvariable(selfvariable);
  2163.     this.allMembers().forEach(function(actor) {
  2164.         value = Math.min(value, actor.strictselfvariable(selfvariable));
  2165.     });
  2166.     return Math.floor(value);
  2167. }
  2168.  
  2169. Game_Party.prototype.avgselfvariable = function(selfvariable) {
  2170.     if (this.allMembers().length < 1) return 0;
  2171.     var value = 0;
  2172.     this.allMembers().forEach(function(actor) {
  2173.         value += actor.strictselfvariable(selfvariable);
  2174.     });
  2175.     return Math.floor(value / this.allMembers().length);
  2176. }
  2177.  
  2178. Game_Party.prototype.battleswitch = function(battleswitch) {
  2179.     this.aliveMembers().forEach(function(actor) {
  2180.         if (actor.battleswitch(battleswitch)) {
  2181.             return true;
  2182.         }
  2183.     });
  2184.     return false;
  2185. }
  2186.  
  2187. Game_Party.prototype.battlevariable = function(battlevariable) {
  2188.     var value = 0;
  2189.     this.aliveMembers().forEach(function(actor) {
  2190.         value += actor.strictbattlevariable(battlevariable);
  2191.     });
  2192.     return Math.floor(value);
  2193. }
  2194.  
  2195. Game_Party.prototype.maxbattlevariable = function(battlevariable) {
  2196.     if (this.aliveMembers().length < 1) return 0;
  2197.     var value = this.aliveMembers()[0].strictbattlevariable(battlevariable);
  2198.     this.aliveMembers().forEach(function(actor) {
  2199.         value = Math.max(value, actor.strictbattlevariable(battlevariable));
  2200.     });
  2201.     return Math.floor(value);
  2202. }
  2203.  
  2204. Game_Party.prototype.minbattlevariable = function(battlevariable) {
  2205.     if (this.aliveMembers().length < 1) return 0;
  2206.     var value = this.aliveMembers()[0].strictbattlevariable(battlevariable);
  2207.     this.aliveMembers().forEach(function(actor) {
  2208.         value = Math.min(value, actor.strictbattlevariable(battlevariable));
  2209.     });
  2210.     return Math.floor(value);
  2211. }
  2212.  
  2213. Game_Party.prototype.avgbattlevariable = function(battlevariable) {
  2214.     if (this.aliveMembers().length < 1) return 0;
  2215.     var value = 0;
  2216.     this.aliveMembers().forEach(function(actor) {
  2217.         value += actor.strictbattlevariable(battlevariable);
  2218.     });
  2219.     return Math.floor(value / this.aliveMembers().length);
  2220. }
  2221.  
  2222. //=============================================================================
  2223. // Game_Event
  2224. //=============================================================================
  2225.  
  2226. Game_Event.prototype.selfswitch = function(selfswitch) {
  2227.     var key = [this._mapId, this._eventId, selfswitch];
  2228.     return $gameSelfSwitches.value(key);
  2229. }
  2230.  
  2231. Game_Event.prototype.selfswitches = function() {
  2232.     return $gameSelfSwitches.filter(this._mapId, this._eventId);
  2233. }
  2234.  
  2235. Game_Event.prototype.selfswitchNames = function() {
  2236.     return $gameSelfSwitches.filter(this._mapId, this._eventId).reduce(function(r, obj) {
  2237.         return r.concat([obj[2]]);
  2238.     }, []);
  2239. }
  2240.  
  2241. Game_Event.prototype.setselfswitch = function(selfswitch, value) {
  2242.     ICF.MainUtility.CustomSwitch(this._mapId, this._eventId, selfswitch, value);
  2243. }
  2244.  
  2245. Game_Event.prototype.mapswitch = function(mapswitch) {
  2246.     var key = [this._mapId, 0, mapswitch];
  2247.     return $gameSelfSwitches.value(key);
  2248. }
  2249.  
  2250. Game_Event.prototype.mapswitches = function() {
  2251.     return $gameSelfSwitches.filter(this._mapId, 0);
  2252. }
  2253.  
  2254. Game_Event.prototype.mapswitchNames = function() {
  2255.     return $gameSelfSwitches.filter(this._mapId, 0).reduce(function(r, obj) {
  2256.         return r.concat([obj[2]]);
  2257.     }, []);
  2258. }
  2259.  
  2260. Game_Event.prototype.setmapswitch = function(mapswitch, value) {
  2261.     ICF.MainUtility.CustomSwitch(this._mapId, 0, mapswitch, value);
  2262. }
  2263.  
  2264. Game_Event.prototype.selfvariable = function(selfvariable) {
  2265.     var key = [this._mapId, this._eventId, selfvariable];
  2266.     return $gameSelfVariables.value(key);
  2267. }
  2268.  
  2269. Game_Event.prototype.strictselfvariable = function(selfvariable) {
  2270.     var key = [this._mapId, this._eventId, selfvariable];
  2271.     return $gameSelfVariables.strictValue(key);
  2272. }
  2273.  
  2274. Game_Event.prototype.selfvariables = function() {
  2275.     return $gameSelfVariables.filter(this._mapId, this._eventId);
  2276. }
  2277.  
  2278. Game_Event.prototype.selfvariableNames = function() {
  2279.     return $gameSelfVariables.filter(this._mapId, this._eventId).reduce(function(r, obj) {
  2280.         return r.concat([obj[2]]);
  2281.     }, []);
  2282. }
  2283.  
  2284. Game_Event.prototype.setselfvariable = function(selfvariable, value) {
  2285.     ICF.MainUtility.CustomVariable(this._mapId, this._eventId, selfvariable, value);
  2286. }
  2287.  
  2288. Game_Event.prototype.increaseselfvariable = function(selfvariable, value) {
  2289.     ICF.MainUtility.IncreaseCustomVariable(this._mapId, this._eventId, selfvariable, value);
  2290. }
  2291.  
  2292. Game_Event.prototype.multiplyselfvariable = function(selfvariable, value) {
  2293.     ICF.MainUtility.MultiplyCustomVariable(this._mapId, this._eventId, selfvariable, value);
  2294. }
  2295.  
  2296. Game_Event.prototype.divideselfvariable = function(selfvariable, value) {
  2297.     ICF.MainUtility.DivideCustomVariable(this._mapId, this._eventId, selfvariable, value);
  2298. }
  2299.  
  2300. Game_Event.prototype.modselfvariable = function(selfvariable, value) {
  2301.     ICF.MainUtility.ModCustomVariable(this._mapId, this._eventId, selfvariable, value);
  2302. }
  2303.  
  2304. Game_Event.prototype.mapvariable = function(mapvariable) {
  2305.     var key = [this._mapId, 0, mapvariable];
  2306.     return $gameSelfVariables.value(key);
  2307. }
  2308.  
  2309. Game_Event.prototype.strictmapvariable = function(mapvariable) {
  2310.     var key = [this._mapId, 0, mapvariable];
  2311.     return $gameSelfVariables.strictValue(key);
  2312. }
  2313.  
  2314. Game_Event.prototype.mapvariables = function() {
  2315.     return $gameSelfVariables.filter(this._mapId, 0);
  2316. }
  2317.  
  2318. Game_Event.prototype.mapvariableNames = function() {
  2319.     return $gameSelfVariables.filter(this._mapId, 0).reduce(function(r, obj) {
  2320.         return r.concat([obj[2]]);
  2321.     }, []);
  2322. }
  2323.  
  2324. Game_Event.prototype.setmapvariable = function(mapvariable, value) {
  2325.     ICF.MainUtility.CustomVariable(this._mapId, 0, mapvariable, value);
  2326. }
  2327.  
  2328. Game_Event.prototype.increasemapvariable = function(mapvariable, value) {
  2329.     ICF.MainUtility.IncreaseCustomVariable(this._mapId, 0, mapvariable, value);
  2330. }
  2331.  
  2332. Game_Event.prototype.multiplymapvariable = function(mapvariable, value) {
  2333.     ICF.MainUtility.MultiplyCustomVariable(this._mapId, 0, mapvariable, value);
  2334. }
  2335.  
  2336. Game_Event.prototype.dividemapvariable = function(mapvariable, value) {
  2337.     ICF.MainUtility.DivideCustomVariable(this._mapId, 0, mapvariable, value);
  2338. }
  2339.  
  2340. Game_Event.prototype.modmapvariable = function(mapvariable, value) {
  2341.     ICF.MainUtility.ModCustomVariable(this._mapId, 0, mapvariable, value);
  2342. }
  2343.  
  2344. //=============================================================================
  2345. // Game_Map
  2346. //=============================================================================
  2347.  
  2348. Game_Map.prototype.mapswitch = function(mapswitch) {
  2349.     var key = [this._mapId, 0, mapswitch];
  2350.     return $gameSelfSwitches.value(key);
  2351. }
  2352.  
  2353. Game_Map.prototype.mapswitches = function() {
  2354.     return $gameSelfSwitches.filter(this._mapId, 0);
  2355. }
  2356.  
  2357. Game_Map.prototype.mapswitchNames = function() {
  2358.     return $gameSelfSwitches.filter(this._mapId, 0).reduce(function(r, obj) {
  2359.         return r.concat([obj[2]]);
  2360.     }, []);
  2361. }
  2362.  
  2363. Game_Map.prototype.setmapswitch = function(mapswitch, value) {
  2364.     ICF.MainUtility.CustomSwitch(this._mapId, 0, mapswitch, value);
  2365. }
  2366.  
  2367. Game_Map.prototype.mapvariable = function(mapvariable) {
  2368.     var key = [this._mapId, 0, mapvariable];
  2369.     return $gameSelfVariables.value(key);
  2370. }
  2371.  
  2372. Game_Map.prototype.mapvariables = function() {
  2373.     return $gameSelfVariables.filter(this._mapId, 0);
  2374. }
  2375.  
  2376. Game_Map.prototype.mapvariableNames = function() {
  2377.     return $gameSelfVariables.filter(this._mapId, 0).reduce(function(r, obj) {
  2378.         return r.concat([obj[2]]);
  2379.     }, []);
  2380. }
  2381.  
  2382. Game_Map.prototype.strictmapvariable = function(mapvariable) {
  2383.     var key = [this._mapId, 0, mapvariable];
  2384.     return $gameSelfVariables.strictValue(key);
  2385. }
  2386.  
  2387. Game_Map.prototype.setmapvariable = function(mapvariable, value) {
  2388.     ICF.MainUtility.CustomVariable(this._mapId, 0, mapvariable, value);
  2389. }
  2390.  
  2391. Game_Map.prototype.increasemapvariable = function(mapvariable, value) {
  2392.     ICF.MainUtility.IncreaseCustomVariable(this._mapId, 0, mapvariable, value);
  2393. }
  2394.  
  2395. Game_Map.prototype.multiplymapvariable = function(mapvariable, value) {
  2396.     ICF.MainUtility.MultiplyCustomVariable(this._mapId, 0, mapvariable, value);
  2397. }
  2398.  
  2399. Game_Map.prototype.dividemapvariable = function(mapvariable, value) {
  2400.     ICF.MainUtility.DivideCustomVariable(this._mapId, 0, mapvariable, value);
  2401. }
  2402.  
  2403. Game_Map.prototype.modmapvariable = function(mapvariable, value) {
  2404.     ICF.MainUtility.ModCustomVariable(this._mapId, 0, mapvariable, value);
  2405. }
  2406.  
  2407. //=============================================================================
  2408. // Game_Item
  2409. //=============================================================================
  2410.  
  2411. Game_Item.prototype.traitDataTypes = function(code) {
  2412.     var data = this.object();
  2413.     if ((data == null)||(!data.traits)) return [];
  2414.     data = data.traits;
  2415.     return data.reduce(function(r, obj) {
  2416.         if (obj.code == code) return r.concat([obj.dataId]);
  2417.         return r;
  2418.     }, []).removeRepeated();
  2419. }
  2420.  
  2421. Game_Item.prototype.traitDataTypesOffset = function(code, min, max) {
  2422.     var data = this.object();
  2423.     if ((data == null)||(!data.traits)) return [];
  2424.     data = data.traits;
  2425.     return data.reduce(function(r, obj) {
  2426.         if ((obj.code == code)&&(obj.dataId >= min)&&(obj.dataId <= max)) return r.concat([obj.dataId - min]);
  2427.         return r;
  2428.     }, []).removeRepeated();
  2429. }
  2430.  
  2431. Game_Item.prototype.traitDataTypesMod = function(code, mod) {
  2432.     var data = this.object();
  2433.     if ((data == null)||(!data.traits)) return [];
  2434.     data = data.traits;
  2435.     return data.reduce(function(r, obj) {
  2436.         if (obj.code == code) return r.concat([obj.dataId % mod]);
  2437.         return r;
  2438.     }, []).removeRepeated();
  2439. }
  2440.  
  2441. //=============================================================================
  2442. // Game_Interpreter
  2443. //=============================================================================
  2444.  
  2445. Game_Interpreter.prototype.event = function() {
  2446.     return $gameMap.event(this._eventId);
  2447. };
  2448.  
  2449. ICF.MainUtility.pluginCommand = Game_Interpreter.prototype.pluginCommand;
  2450. Game_Interpreter.prototype.pluginCommand = function(command, args) {
  2451.         ICF.MainUtility.pluginCommand.call(this, command, args);
  2452.     if (command.toLowerCase() == 'selfswitch') {
  2453.         ICF.MainUtility.CustomSwitch(this._mapId, this._eventId, args[0], args[1]);
  2454.     } else if (command.toLowerCase() == 'mapswitch') {
  2455.         ICF.MainUtility.CustomSwitch(this._mapId, 0, args[0], args[1]);
  2456.     } else if (command.toLowerCase() == 'remoteswitch') {
  2457.         ICF.MainUtility.CustomSwitch(args[0], args[1], args[2], args[3]);
  2458.     } else if (command.toLowerCase().match(/((?:actor)|(?:partymember))(switch)/i)&&(RegExp.$1.length + RegExp.$2.length == command.length)) {
  2459.         var actor = (RegExp.$1 == "actor")? args[0] : ($gameParty.members()[args[0]])? $gameParty.members()[args[0]]._actorId : 0;
  2460.         if (actor > 0) {ICF.MainUtility.CustomSwitch(0, actor, args[1], args[2]);}
  2461.     } else if (command.toLowerCase() == 'enemyswitch') {
  2462.         ICF.MainUtility.CustomSwitch("e", args[0], args[1], args[2]);
  2463.     } else if (command.toLowerCase() == 'battleswitch') {
  2464.         ICF.MainUtility.BattleSwitch(0, 0, args[0], args[1]);
  2465.     } else if (command.toLowerCase().match(/((?:actor)|(?:partymember))(battleswitch)/i)&&(RegExp.$1.length + RegExp.$2.length == command.length)) {
  2466.         var actor = (RegExp.$1 == "actor")? args[0] : ($gameParty.members()[args[0]])? $gameParty.members()[args[0]]._actorId : 0;
  2467.         if (actor > 0) {ICF.MainUtility.BattleSwitch(0, actor, args[1], args[2]);}
  2468.     } else if (command.toLowerCase() == 'enemybattleswitch') {
  2469.         ICF.MainUtility.BattleSwitch("e", args[0], args[1], args[2]);
  2470.     } else if (command.toLowerCase().match(/((?:self)|(?:map))(variable)/i)&&(RegExp.$1.length + RegExp.$2.length == command.length)) {
  2471.         var event = (RegExp.$1 == "self")? this._eventId : 0;
  2472.         ICF.MainUtility.CustomVariable(this._mapId, event, args[0], args[1]);
  2473.     } else if (command.toLowerCase().match(/(increase)((?:self)|(?:map))(variable)/i)&&(RegExp.$1.length + RegExp.$2.length + RegExp.$3.length == command.length)) {
  2474.         var event = (RegExp.$2 == "self")? this._eventId : 0;
  2475.         ICF.MainUtility.IncreaseCustomVariable(this._mapId, event, args[0], args[1]);
  2476.     } else if (command.toLowerCase().match(/(multiply)((?:self)|(?:map))(variable)/i)&&(RegExp.$1.length + RegExp.$2.length + RegExp.$3.length == command.length)) {
  2477.         var event = (RegExp.$2 == "self")? this._eventId : 0;
  2478.         ICF.MainUtility.MultiplyCustomVariable(this._mapId, event, args[0], args[1]);
  2479.     } else if (command.toLowerCase().match(/(divide)((?:self)|(?:map))(variable)/i)&&(RegExp.$1.length + RegExp.$2.length + RegExp.$3.length == command.length)) {
  2480.         var event = (RegExp.$2 == "self")? this._eventId : 0;
  2481.         ICF.MainUtility.DivideCustomVariable(this._mapId, event, args[0], args[1]);
  2482.     } else if (command.toLowerCase().match(/(mod)((?:self)|(?:map))(variable)/i)&&(RegExp.$1.length + RegExp.$2.length + RegExp.$3.length == command.length)) {
  2483.         var event = (RegExp.$2 == "self")? this._eventId : 0;
  2484.         ICF.MainUtility.ModCustomVariable(this._mapId, event, args[0], args[1]);
  2485.     } else if (command.toLowerCase() == 'remotevariable') {
  2486.         ICF.MainUtility.CustomVariable(args[0], args[1], args[2], args[3]);
  2487.     } else if (command.toLowerCase() == 'increaseremotevariable') {
  2488.         ICF.MainUtility.IncreaseCustomVariable(args[0], args[1], args[2], args[3]);
  2489.     } else if (command.toLowerCase() == 'multiplyremotevariable') {
  2490.         ICF.MainUtility.MultiplyCustomVariable(args[0], args[1], args[2], args[3]);
  2491.     } else if (command.toLowerCase() == 'divideremotevariable') {
  2492.         ICF.MainUtility.DivideCustomVariable(args[0], args[1], args[2], args[3]);
  2493.     } else if (command.toLowerCase() == 'modremotevariable') {
  2494.         ICF.MainUtility.ModCustomVariable(args[0], args[1], args[2], args[3]);
  2495.     } else if (command.toLowerCase() == 'actorvariable') {
  2496.         ICF.MainUtility.CustomVariable(0, args[0], args[1], args[2]);
  2497.     } else if (command.toLowerCase() == 'increaseactorvariable') {
  2498.         ICF.MainUtility.IncreaseCustomVariable(0, args[0], args[1], args[2]);
  2499.     } else if (command.toLowerCase() == 'multiplyactorvariable') {
  2500.         ICF.MainUtility.MultiplyCustomVariable(0, args[0], args[1], args[2]);
  2501.     } else if (command.toLowerCase() == 'divideactorvariable') {
  2502.         ICF.MainUtility.DivideCustomVariable(0, args[0], args[1], args[2]);
  2503.     } else if (command.toLowerCase() == 'modactorvariable') {
  2504.         ICF.MainUtility.ModCustomVariable(0, args[0], args[1], args[2]);
  2505.     } else if (command.toLowerCase() == 'enemyvariable') {
  2506.         ICF.MainUtility.CustomVariable("e", args[0], args[1], args[2]);
  2507.     } else if (command.toLowerCase() == 'increaseenemyvariable') {
  2508.         ICF.MainUtility.IncreaseCustomVariable("e", args[0], args[1], args[2]);
  2509.     } else if (command.toLowerCase() == 'multiplyenemyvariable') {
  2510.         ICF.MainUtility.MultiplyCustomVariable("e", args[0], args[1], args[2]);
  2511.     } else if (command.toLowerCase() == 'divideenemyvariable') {
  2512.         ICF.MainUtility.DivideCustomVariable("e", args[0], args[1], args[2]);
  2513.     } else if (command.toLowerCase() == 'modenemyvariable') {
  2514.         ICF.MainUtility.ModCustomVariable("e", args[0], args[1], args[2]);
  2515.     } else if (command.toLowerCase().match(/(enemy)?(battlevariable)/i)&&(RegExp.$1.length + RegExp.$2.length == command.length)) {
  2516.         if (RegExp.$1 == "enemy") {ICF.MainUtility.BattleVariable("e", args[0], args[1], args[2]);}
  2517.         else {ICF.MainUtility.BattleVariable(0, 0, args[0], args[1]);}
  2518.     } else if (command.toLowerCase().match(/(increase)(enemy)?(battlevariable)/i)&&(RegExp.$1.length + RegExp.$2.length + RegExp.$3.length == command.length)) {
  2519.         if (RegExp.$2 == "enemy") {ICF.MainUtility.IncreaseBattleVariable("e", args[0], args[1], args[2]);}
  2520.         else {ICF.MainUtility.IncreaseBattleVariable(0, 0, args[0], args[1]);}
  2521.     } else if (command.toLowerCase().match(/(multiply)(enemy)?(battlevariable)/i)&&(RegExp.$1.length + RegExp.$2.length + RegExp.$3.length == command.length)) {
  2522.         if (RegExp.$2 == "enemy") {ICF.MainUtility.MultiplyBattleVariable("e", args[0], args[1], args[2]);}
  2523.         else {ICF.MainUtility.MultiplyBattleVariable(0, 0, args[0], args[1]);}
  2524.     } else if (command.toLowerCase().match(/(divide)(enemy)?(battlevariable)/i)&&(RegExp.$1.length + RegExp.$2.length + RegExp.$3.length == command.length)) {
  2525.         if (RegExp.$2 == "enemy") {ICF.MainUtility.DivideBattleVariable("e", args[0], args[1], args[2]);}
  2526.         else {ICF.MainUtility.DivideBattleVariable(0, 0, args[0], args[1]);}
  2527.     } else if (command.toLowerCase().match(/(mod)(enemy)?(battlevariable)/i)&&(RegExp.$1.length + RegExp.$2.length + RegExp.$3.length == command.length)) {
  2528.         if (RegExp.$2 == "enemy") {ICF.MainUtility.ModBattleVariable("e", args[0], args[1], args[2]);}
  2529.         else {ICF.MainUtility.ModBattleVariable(0, 0, args[0], args[1]);}
  2530.     } else if (command.toLowerCase() == 'actorbattlevariable') {
  2531.         ICF.MainUtility.BattleVariable(0, args[0], args[1], args[2]);
  2532.     } else if (command.toLowerCase() == 'increaseactorbattlevariable') {
  2533.         ICF.MainUtility.IncreaseBattleVariable(0, args[0], args[1], args[2]);
  2534.     } else if (command.toLowerCase() == 'multiplyactorbattlevariable') {
  2535.         ICF.MainUtility.MultiplyBattleVariable(0, args[0], args[1], args[2]);
  2536.     } else if (command.toLowerCase() == 'divideactorbattlevariable') {
  2537.         ICF.MainUtility.DivideBattleVariable(0, args[0], args[1], args[2]);
  2538.     } else if (command.toLowerCase() == 'modactorbattlevariable') {
  2539.         ICF.MainUtility.ModBattleVariable(0, args[0], args[1], args[2]);
  2540.     } else if (command.toLowerCase().match(/((?:actor)|(?:enemy)|(?:partymember))(trait)((?:add)|(?:rate)|(?:plus))?/i)&&(RegExp.$1.length + RegExp.$2.length + RegExp.$3.length == command.length)) {
  2541.         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;
  2542.         var mode = (RegExp.$3 == "add")? 0 : (RegExp.$3 == "plus")? 2 : (RegExp.$3 == "rate")? 3 : 1;
  2543.         ICF.MainUtility.addTrait(data, mode, args[1], args[2], args[3]);
  2544.     } else if (command.toLowerCase().match(/(remove)((?:actor)|(?:enemy)|(?:partymember))(trait)/i)&&(RegExp.$1.length + RegExp.$2.length + RegExp.$3.length == command.length)) {
  2545.         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;
  2546.         ICF.MainUtility.removeTrait(data, args[1], args[2]);
  2547.     } else if (command.toLowerCase().match(/(clear)((?:actor)|(?:enemy)|(?:partymember))(traits)/i)&&(RegExp.$1.length + RegExp.$2.length + RegExp.$3.length == command.length)) {
  2548.         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;
  2549.         if (data) data.clearTraits();
  2550.     } else if (command.toLowerCase().match(/(add)((?:actor)|(?:enemy)|(?:partymember))((?:tag)|(?:tags))/i)&&(RegExp.$1.length + RegExp.$2.length + RegExp.$3.length == command.length)) {
  2551.         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;
  2552.         if (!data) return;
  2553.         if (args.length == 2) data.addTag(args[1]);
  2554.         else {
  2555.             args.shift();
  2556.             data.addTags(args);
  2557.         }
  2558.     } else if (command.toLowerCase().match(/(remove)((?:actor)|(?:enemy)|(?:partymember))((?:tag)|(?:tags))/i)&&(RegExp.$1.length + RegExp.$2.length + RegExp.$3.length == command.length)) {
  2559.         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;
  2560.         if (!data) return;
  2561.         if (args.length == 2) data.removeTag(args[1]);
  2562.         else {
  2563.             args.shift();
  2564.             data.removeTags(args);
  2565.         }
  2566.     } else if (command.toLowerCase().match(/(clear)((?:actor)|(?:enemy)|(?:partymember))((?:tag)|(?:tags))/i)&&(RegExp.$1.length + RegExp.$2.length + RegExp.$3.length == command.length)) {
  2567.         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;
  2568.         if (data) data.clearTags();
  2569.     } else if (command.toLowerCase().match(/(add)((?:actor)|(?:enemy)|(?:partymember))((?:battletag)|(?:battletags))/i)&&(RegExp.$1.length + RegExp.$2.length + RegExp.$3.length == command.length)) {
  2570.         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;
  2571.         if (!data) return;
  2572.         if (args.length == 2) data.addBattleTag(args[1]);
  2573.         else {
  2574.             args.shift();
  2575.             data.addBattleTags(args);
  2576.         }
  2577.     } else if (command.toLowerCase().match(/(remove)((?:actor)|(?:enemy)|(?:partymember))((?:battletag)|(?:battletags))/i)&&(RegExp.$1.length + RegExp.$2.length + RegExp.$3.length == command.length)) {
  2578.         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;
  2579.         if (!data) return;
  2580.         if (args.length == 2) data.removeBattleTag(args[1]);
  2581.         else {
  2582.             args.shift();
  2583.             data.removeBattleTags(args);
  2584.         }
  2585.     } else if (command.toLowerCase().match(/(clear)((?:actor)|(?:enemy)|(?:partymember))((?:battletag)|(?:battletags))/i)&&(RegExp.$1.length + RegExp.$2.length + RegExp.$3.length == command.length)) {
  2586.         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;
  2587.         if (data) data.clearBattleTags();
  2588.         }
  2589. };
  2590.  
  2591. //=============================================================================
  2592. // Game_System
  2593. //=============================================================================
  2594.  
  2595. ICF.MainUtility.GSystemInit = Game_System.prototype.initialize;
  2596. Game_System.prototype.initialize = function() {
  2597.         ICF.MainUtility.GSystemInit.call(this);
  2598.         this._icf = {};
  2599. };
  2600.  
  2601. Game_System.prototype.ICF = function() {
  2602.     if (!this._icf) this._icf = {};
  2603.     return this._icf;
  2604. };
  2605.  
  2606. //=============================================================================
  2607. // Game_Temp
  2608. //=============================================================================
  2609.  
  2610. if (!Imported.ICFSoft_MainCore) {
  2611.     Game_Temp.prototype.reserveCommonEvent = function(commonEventId) {
  2612.     if (!this._commontEventArray) this._commontEventArray = [];
  2613.     this._commontEventArray.push(commonEventId);
  2614.     };
  2615.  
  2616.     Game_Temp.prototype.clearCommonEvent = function() {
  2617.     if (!this._commontEventArray) this._commontEventArray = [];
  2618.     this._commontEventArray.splice(0, 1);
  2619.     };
  2620.  
  2621.     Game_Temp.prototype.isCommonEventReserved = function() {
  2622.     if (!this._commontEventArray) this._commontEventArray = [];
  2623.     return this._commontEventArray.length > 0;
  2624.     };
  2625.  
  2626.     Game_Temp.prototype.reservedCommonEvent = function() {
  2627.     if (!this._commontEventArray) this._commontEventArray = [];
  2628.     return $dataCommonEvents[this._commontEventArray[0]];
  2629.     };
  2630. }
  2631.  
  2632. //=============================================================================
  2633. // Utilities
  2634. //=============================================================================
  2635.  
  2636. ICF.MainUtility.gettfield = function(array) {
  2637.     if (array.length < 2) return [];
  2638.     for (var i = 0; i < ICF.MainUtility.traittags.length; i++) {
  2639.         if (array[0].toLowerCase() == ICF.MainUtility.traittags[i][0]) {
  2640.             array[0] = ICF.MainUtility.traittags[i][1];
  2641.             array[1] = Number(array[1]) + ICF.MainUtility.traittags[i][2];
  2642.             break;
  2643.         }
  2644.     }
  2645.     if (isNaN(Number(array[0]))) {return [-1];}
  2646.     return array;
  2647. }
  2648.  
  2649. ICF.MainUtility.getefield = function(array) {
  2650.     if (array.length < 4) return [];
  2651.     for (var i = 0; i < ICF.MainUtility.effecttags.length; i++) {
  2652.         if (array[0].toLowerCase() == ICF.MainUtility.effecttags[i][0]) {
  2653.             array[0] = ICF.MainUtility.effecttags[i][1];
  2654.             array[1] = Number(array[1]) + ICF.MainUtility.effecttags[i][2];
  2655.             break;
  2656.         }
  2657.     }
  2658.     if (isNaN(Number(array[0]))) {return [-1];}
  2659.     return array;
  2660. }
  2661.  
  2662. ICF.MainUtility.addTrait = function(data, mode, code, dataid, value) {
  2663.     if (!data || !data.traits) return;
  2664.     var array = [code, Number(dataid), Number(value)];
  2665.     if (isNaN(Number(array[0]))) {array = ICF.MainUtility.gettfield(array);};
  2666.     if (array[0] < 0) {return;};
  2667.     if (mode == 0) {data.traits.push({code:Number(array[0]), dataId:array[1], value:array[2]}); return;};
  2668.     var ind = -1;
  2669.     for (var i = 0; i < data.traits.length; i++) {
  2670.         if ((data.traits[i].code == array[0])&&(data.traits[i].dataId == array[1])) {
  2671.             ind = i;
  2672.             break;
  2673.         }
  2674.     }
  2675.     if (ind == -1) {data.traits.push({code:Number(array[0]), dataId:array[1], value:array[2]}); return;};
  2676.     if (mode == 1) {
  2677.         data.traits[ind].value = array[2];
  2678.         for (var i = data.traits.length - 1; i > ind; i--) {
  2679.             if ((data.traits[i].code == array[0])&&(data.traits[i].dataId == array[1])) {
  2680.                 data.traits.splice(i, 1);
  2681.             }
  2682.         }
  2683.     } else if (mode == 2){
  2684.         data.traits[ind].value += array[2];
  2685.         for (var i = data.traits.length - 1; i > ind; i--) {
  2686.             if ((data.traits[i].code == array[0])&&(data.traits[i].dataId == array[1])) {
  2687.                 data.traits[ind].value += data.traits[i].value;
  2688.                 data.traits.splice(i, 1);
  2689.             }
  2690.         }
  2691.     } else if (mode == 3){
  2692.         data.traits[ind].value *= array[2];
  2693.         for (var i = data.traits.length - 1; i > ind; i--) {
  2694.             if ((data.traits[i].code == array[0])&&(data.traits[i].dataId == array[1])) {
  2695.                 data.traits[ind].value *= data.traits[i].value;
  2696.                 data.traits.splice(i, 1);
  2697.             }
  2698.         }
  2699.     }
  2700. }
  2701.  
  2702. ICF.MainUtility.removeTrait = function(data, code, dataid) {
  2703.     if (!data.traits) return;
  2704.     var array = [code, Number(dataid), 0];
  2705.     if (isNaN(Number(array[0]))) {array = ICF.MainUtility.gettfield(array);};
  2706.     if (array[0] < 0) {return;};
  2707.     var ind = -1;
  2708.     for (var i = data.traits.length - 1; i >= 0; i--) {
  2709.         if ((data.traits[i].code == array[0])&&(data.traits[i].dataId == array[1])) {
  2710.             data.traits.splice(i, 1);
  2711.         }
  2712.     }
  2713. }
  2714.  
  2715. ICF.MainUtility.CustomSwitch = function(mapid, evid, switchname, value) {
  2716.     var _key = [mapid, evid, switchname];
  2717.     var _value = (value.toString().toLowerCase() === "true");
  2718.     $gameSelfSwitches.setValue(_key, _value);
  2719. }
  2720.  
  2721. ICF.MainUtility.CustomVariable = function(mapid, evid, variablename, value) {
  2722.     var _key = [mapid, evid, variablename];
  2723.     $gameSelfVariables.setValue(_key, value);
  2724. }
  2725.  
  2726. ICF.MainUtility.IncreaseCustomVariable = function(mapid, evid, variablename, value) {
  2727.     var _key = [mapid, evid, variablename];
  2728.     $gameSelfVariables.increaseValue(_key, value);
  2729. }
  2730.  
  2731. ICF.MainUtility.MultiplyCustomVariable = function(mapid, evid, variablename, value) {
  2732.     var _key = [mapid, evid, variablename];
  2733.     $gameSelfVariables.multiplyValue(_key, value);
  2734. }
  2735.  
  2736. ICF.MainUtility.DivideCustomVariable = function(mapid, evid, variablename, value) {
  2737.     var _key = [mapid, evid, variablename];
  2738.     $gameSelfVariables.divideValue(_key, value);
  2739. }
  2740.  
  2741. ICF.MainUtility.ModCustomVariable = function(mapid, evid, variablename, value) {
  2742.     var _key = [mapid, evid, variablename];
  2743.     $gameSelfVariables.modValue(_key, value);
  2744. }
  2745.  
  2746. ICF.MainUtility.BattleSwitch = function(code, evid, switchname, value) {
  2747.     var _key = [code, evid, switchname];
  2748.     var _value = (value.toString().toLowerCase() === "true");
  2749.     $gameBattleSwitches.setValue(_key, _value);
  2750. }
  2751.  
  2752. ICF.MainUtility.BattleVariable = function(code, evid, variablename, value) {
  2753.     var _key = [code, evid, variablename];
  2754.     $gameBattleVariables.setValue(_key, value);
  2755. }
  2756.  
  2757. ICF.MainUtility.IncreaseBattleVariable = function(code, evid, variablename, value) {
  2758.     var _key = [code, evid, variablename];
  2759.     $gameBattleVariables.increaseValue(_key, value);
  2760. }
  2761.  
  2762. ICF.MainUtility.MultiplyBattleVariable = function(code, evid, variablename, value) {
  2763.     var _key = [code, evid, variablename];
  2764.     $gameBattleVariables.multiplyValue(_key, value);
  2765. }
  2766.  
  2767. ICF.MainUtility.DivideBattleVariable = function(code, evid, variablename, value) {
  2768.     var _key = [code, evid, variablename];
  2769.     $gameBattleVariables.divideValue(_key, value);
  2770. }
  2771.  
  2772. ICF.MainUtility.ModBattleVariable = function(code, evid, variablename, value) {
  2773.     var _key = [code, evid, variablename];
  2774.     $gameBattleVariables.modValue(_key, value);
  2775. }
  2776.  
  2777. ICF.MainUtility.CheckVar = function(code, value1, value2) {
  2778.     switch (code) {
  2779.         case 0:
  2780.             return (value1 == value2); break;
  2781.         case 1:
  2782.             return (value1 !== value2); break;
  2783.         case 2:
  2784.             return (value1 > value2); break;
  2785.         case 3:
  2786.             return (value1 >= value2); break;
  2787.         case 4:
  2788.             return (value1 < value2); break;
  2789.         case 5:
  2790.             return (value1 <= value2); break;
  2791.         default:
  2792.             return false;
  2793.     }
  2794. }
  2795.  
  2796. ICF.MainUtility.validateColor = function(color) {
  2797.     if (!isNaN(Number(color))) return Number(color);
  2798.     try {
  2799.         var btm = new Bitmap(2,2);
  2800.         var gra = btm._context.createLinearGradient(1,1,1,2);
  2801.         gra.addColorStop(1,color);
  2802.             return color;
  2803.     } catch (e) {
  2804.         return "rgba(0,0,0,0)";
  2805.     }
  2806.     return "rgba(0,0,0,0)";
  2807. }
  2808.  
  2809. Array.range = function() {
  2810.     var args = arguments;
  2811.     if (args.length < 1) return [];
  2812.     var x = [];
  2813.     if (args.length == 1) {
  2814.     if (args[0] == 0) return [0];
  2815.     if (args[0] > 0) for (var i = 1; i <= args[0]; i++) {
  2816.         x.push(i);
  2817.     } else for (var i = -1; i >= args[0]; i--) {
  2818.         x.push(i);
  2819.     }
  2820.     } else if (args.length == 2) {
  2821.     if (args[0] < args[1]) for (var i = args[0]; i <= args[1]; i++) {
  2822.         x.push(i);
  2823.     } else for (var i = args[0]; i >= args[1]; i--) {
  2824.         x.push(i);
  2825.     }
  2826.     } else {
  2827.     if (args[0] < args[1] && args[2] > 0) for (var i = args[0]; i <= args[1]; i += args[2]) {
  2828.         x.push(i);
  2829.     } else if (args[0] > args[1] && args[2] < 0) for (var i = args[0]; i >= args[1]; i += args[2]) {
  2830.         x.push(i);
  2831.     }
  2832.     }
  2833.     return x;
  2834. };
  2835.  
  2836. Array.coincidences = function() {
  2837.     var args = arguments;
  2838.     if (args.length < 1) return [];
  2839.     if (args.length == 1) return args[0];
  2840.     var x = [];
  2841.     for (var i = 0; i < args[0].length; i++) {
  2842.     if (args[1].indexOf(args[0][i]) > -1) x.push(args[0][i]);
  2843.     }
  2844.     if (args.length == 2) return x.removeRepeated();
  2845.     for (var i = x.length - 1; i >= 0; i--) {
  2846.     for (var il = 2; il < args.length; il++) {
  2847.         if (args[il].indexOf(x[i]) == -1) {
  2848.             x.splice(i,1);
  2849.             break;
  2850.         }
  2851.     }
  2852.     }
  2853.     return x.removeRepeated();
  2854. };
  2855.  
  2856. Array.prototype.removeRepeated = function() {
  2857.     this.sort(function(a, b) { return a - b;});
  2858.     for (var i = this.length - 1; i > 0; i--) {
  2859.        if (this[i] == this[i - 1]) this.splice(i,1);
  2860.     }
  2861.     return this;
  2862. };
  2863.  
  2864. Array.prototype.clean = function() {
  2865.     for (var i = this.length - 1; i >= 0; i -= 1) {
  2866.     if (this[i] == null) this.splice(i,1);
  2867.     if (String(this[i]).length == 0) this.splice(i,1);
  2868.     }
  2869.     return this;
  2870. };
  2871.  
  2872. Array.prototype.cleanAll = function() {
  2873.     for (var i = this.length - 1; i >= 0; i -= 1) {
  2874.     if (this[i] == null) this.splice(i,1);
  2875.     if (String(this[i]).length == 0) this.splice(i,1);
  2876.     if (Array.isArray(this[i])) this[i].cleanAll();
  2877.     }
  2878.     return this;
  2879. };
  2880.  
  2881. Array.prototype.cleaned = function() {
  2882.     var x = [];
  2883.     for (var i = 0; i < this.length; i++) {
  2884.     if (this[i] != null) x.push(this[i]);
  2885.     }
  2886.     return x;
  2887. };
  2888.  
  2889. Array.prototype.cleanedAll = function() {
  2890.     var x = [];
  2891.     var y = [];
  2892.     for (var i = 0; i < this.length; i++) {
  2893.     if (Array.isArray(this[i])) {
  2894.         y = this[i].cleanedAll();
  2895.         if (y.length > 0) x.push(y);
  2896.     } else if (this[i] != null) x.push(this[i]);
  2897.     }
  2898.     return x;
  2899. };
  2900.  
  2901. Array.prototype.extend = function() {
  2902.     this.clean();
  2903.     for (var i = this.length - 2; i > 0; i -= 1) {
  2904.     if ((String(this[i]).match(/((?:to)|(?:a)|(?:hasta))/i))&&(RegExp.$1.length == String(this[i]).length)) {
  2905.         eval("this.splice(i - 1,3," + Array.range(Number(this[i - 1]), Number(this[i + 1])).join() + ")");
  2906.         i--;
  2907.     }
  2908.     }
  2909.     return this;
  2910. };
  2911.  
  2912. Array.prototype.fixedBlocks = function(block) {
  2913.     if ((this.length % block)  > 0) {
  2914.     eval("this.splice(this.length,0," + new Array(block - this.length % block).join() + ")");
  2915.     }
  2916. };
  2917.  
  2918. Array.prototype.leaveNumbers = function() {
  2919.     for (var i = this.length - 1; i >= 0; i -= 1) {
  2920.     if (isNaN(Number(this[i]))) this.splice(i,1);
  2921.     else this[i] = Number(this[i]);
  2922.     }
  2923.     return this;
  2924. };
  2925.  
  2926. Array.prototype.numbers = function() {
  2927.     var x = [];
  2928.     for (var i = 0; i < this.length; i++) {
  2929.     if (!isNaN(Number(this[i]))) x.push(Number(this[i]));
  2930.     }
  2931.     return x;
  2932. };
  2933.  
  2934. Array.prototype.reduceToFit = function() {
  2935.     var args = arguments;
  2936.     if (args.length < 1) return this;
  2937.     for (var i = 0; i < args.length; i++) {
  2938.     if ((Array.isArray(args[i]))&&(args[i].length < this.length)) this.splice(args[i].length, this.length - args[i].length);
  2939.     }
  2940.     return this;
  2941. };
  2942.  
  2943. String.prototype.doubleSplit = function() {
  2944.     var x = this.split(",");
  2945.     for (var i = 0; i < x.length; i++) {
  2946.     x[i] = x[i].split(/\s+/);
  2947.     }
  2948.     return x;
  2949. }
  2950.  
  2951. String.prototype.doubleSplitNumbers = function() {
  2952.     var x = this.doubleSplit();
  2953.     for (var i = x.length - 1; i >= 0; i--) {
  2954.     x[i] = x[i].extend().numbers();
  2955.     if (x[i].length < 1) x.splice(i,1);
  2956.     }
  2957.     return x;
  2958. }
  2959.  
  2960. Boolean.or = function() {
  2961.     var args = arguments;
  2962.     if (args.length < 1) return false;
  2963.     if (args.length == 1 && Array.isArray(args[0])) args = args[0];
  2964.     for (var i = 0; i < args.length; i++) {
  2965.     if (!!args[i]) return true;
  2966.     }
  2967.     return false;
  2968. }
  2969.  
  2970. Boolean.nor = function() {
  2971.     var args = arguments;
  2972.     if (args.length < 1) return true;
  2973.     if (args.length == 1 && Array.isArray(args[0])) args = args[0];
  2974.     for (var i = 0; i < args.length; i++) {
  2975.     if (!!args[i]) return false;
  2976.     }
  2977.     return true;
  2978. }
  2979.  
  2980. Boolean.and = function() {
  2981.     var args = arguments;
  2982.     if (args.length < 1) return true;
  2983.     if (args.length == 1 && Array.isArray(args[0])) args = args[0];
  2984.     for (var i = 0; i < args.length; i++) {
  2985.     if (!args[i]) return false;
  2986.     }
  2987.     return true;
  2988. }
  2989.  
  2990. Boolean.nand = function() {
  2991.     var args = arguments;
  2992.     if (args.length < 1) return false;
  2993.     if (args.length == 1 && Array.isArray(args[0])) args = args[0];
  2994.     for (var i = 0; i < args.length; i++) {
  2995.     if (!args[i]) return true;
  2996.     }
  2997.     return false;
  2998. }
  2999.  
  3000. Boolean.xor = function() {
  3001.     var args = arguments;
  3002.     if (args.length < 1) return false;
  3003.     if (args.length == 1 && Array.isArray(args[0])) args = args[0];
  3004.     var a = !!args[0];
  3005.     for (var i = 1; i < args.length; i++) {
  3006.     if (!!args[i] != a) return true;
  3007.     }
  3008.     return false;
  3009. }
  3010.  
  3011. Boolean.nxor = function() {
  3012.     var args = arguments;
  3013.     if (args.length < 1) return true;
  3014.     if (args.length == 1 && Array.isArray(args[0])) args = args[0];
  3015.     var a = !!args[0];
  3016.     for (var i = 1; i < args.length; i++) {
  3017.     if (!!args[i] != a) return false;
  3018.     }
  3019.     return true;
  3020. }
  3021.  
  3022. Boolean.prototype.or = function(b) {
  3023.     return this == true || b;
  3024. }
  3025.  
  3026. Boolean.prototype.nor = function(b) {
  3027.     return !(this == true || b);
  3028. }
  3029.  
  3030. Boolean.prototype.and = function(b) {
  3031.     return this == true && b;
  3032. }
  3033.  
  3034. Boolean.prototype.nand = function(b) {
  3035.     return !(this == true && b);
  3036. }
  3037.  
  3038. Boolean.prototype.xor = function(b) {
  3039.     return this == true != b;
  3040. }
  3041.  
  3042. Boolean.prototype.nxor = function(b) {
  3043.     return this == true == b;
  3044. }
  3045.  
  3046. Number.prototype.percentage = function(decimals) {
  3047.     return (this * 100).toFixed(decimals) + "%";
  3048. }
  3049.  
  3050. Date.prototype.getMonthAndDay = function() {
  3051.     return this.getMonth() * 100 + this.getDate() + 100;
  3052. };
  3053.  
  3054. Date.prototype.getHourAndMinute = function() {
  3055.     return this.getHours() * 100 + this.getMinutes();
  3056. };
  3057.  
  3058. Date.prototype.getDayMinutes = function() {
  3059.     return this.getHours() * 60 + this.getMinutes();
  3060. };
  3061.  
  3062. Date.prototype.increaseMinutes = function(minutes) {
  3063.     this.setMinutes(this.getMinutes() + minutes);
  3064. };
  3065.  
  3066. //=============================================================================
  3067. // End of File
  3068. //=============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement