Advertisement
ICF-Soft

ICF-Soft Main Utility 1.03 RPG Maker MV

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