Advertisement
ICF-Soft

ICF-Soft Main Utility 1.04 RPG Maker MV

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