Advertisement
ICF-Soft

ICF-Soft Event Extension 1.05 RPG Maker MV

Jan 13th, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // ICF-Soft Plugins - Event Extension
  3. // ICFSoft_EventExtension.js
  4. //=============================================================================
  5.  
  6. var Imported = Imported || {};
  7. Imported.ICFSoft_Events = true;
  8.  
  9. var ICF = ICF || {};
  10. ICF.Events = ICF.Events || {};
  11.  
  12. ICF.Events.Version = 105; // 1.05
  13.  
  14. //=============================================================================
  15.  /*:
  16.  * @plugindesc v1.05b This plugin allows more conditions to events.
  17.  * @author ICF-Soft [http://icfsoft.blogspot.com.es/]
  18.  *
  19.  * @param Developer HaltJS
  20.  * @desc When true it throws an error if an custom event condition
  21.  * javascript doesn't work.   NO - false     YES - true
  22.  * @default false
  23.  *
  24.  * @help
  25.  * ============================================================================
  26.  * Introduction
  27.  *
  28.  * Pageevents have a limited set of conditions, there are usefull but sometimes
  29.  * aren't enough.
  30.  * Variables by default aren't versatile enough because they have "greater or
  31.  * equal" only option.
  32.  *
  33.  * With this plugin you can add extra conditions like more switches, unlimited
  34.  * selfswitches, unlimited mapswitches and versatile variables.
  35.  *
  36.  * Mapswitches are special switches that aplies to all events in a map.
  37.  *
  38.  * Partyswitches aren't special switches themselves. If at least one member of
  39.  * the party has this switch returns true.
  40.  *
  41.  * Variables can now be "greater or equal", "greater than", "lower than",
  42.  * "lower or equal", "equal to" or "different than" a value.
  43.  *
  44.  * Self and map variables don't need an explanation on how these work.
  45.  * Partyvariables are actor variables combinations (sum, min, max and average).
  46.  *
  47.  * Now you can assign names to pages to allow calling by name and/or make it
  48.  * dummy to disallow be using inside map.
  49.  * Plus a way to group events for use in common events without needing of id.
  50.  *
  51.  * ============================================================================
  52.  * Parameters
  53.  * ============================================================================
  54.  *
  55.  * Developer HaltJS: This is a development variable usefull to check if there is
  56.  * a wrong javascript event condition.
  57.  * When true will throw an error when it found a wrong javascript in lunatic
  58.  * mode.
  59.  * When false it will be ignored and game continues.
  60.  *
  61.  * ============================================================================
  62.  * How to use
  63.  * ============================================================================
  64.  *
  65.  * To add an extra condition to a page just add a comment or note, same
  66.  * format as plugin commands:
  67.  *
  68.  * switch x x x x x x
  69.  * selfswitch x x x x x
  70.  * mapswitch x x
  71.  * partyswitch x x x
  72.  *
  73.  *  - Add specified game, self, map or party switch to conditions.
  74.  *    You can place all same-type switchs you need in same line.
  75.  *
  76.  * [prefix]variable x value
  77.  * [prefix]variablehigh x value
  78.  * [prefix]variableless x value
  79.  * [prefix]variablemax x value
  80.  * [prefix]variableequal x value
  81.  * [prefix]variabledif x value
  82.  *
  83.  *  - Add a variable condition. There are six types: min value, higher than,
  84.  *    lower than, max value, equal and not equal.
  85.  *    Optionaly you can add a prefix to use self, map and party variables
  86.  *    this way:
  87.  *
  88.  * selfvariable x value
  89.  * mapvariable x value
  90.  * partyvariable x value [min/max/avg]
  91.  *
  92.  *  - Partyvariables can have an extra parameter. If omited it will check
  93.  *    sum of party members specified variables.
  94.  *    -min: check minimun of party members specified variables.
  95.  *    -max: check maximun of party members specified variables.
  96.  *    -avg: check average value of party members specified variables.
  97.  *
  98.  * You can also give a name to a page and/or make it dummy with these:
  99.  *
  100.  * pagename name
  101.  *
  102.  *  - Give a name to a page.
  103.  *
  104.  * dummypage [name]
  105.  *
  106.  *  - Disallow a page to be trigered by page conditions.
  107.  *    You can optionally give it a name.
  108.  *
  109.  * You can group events with this note:
  110.  *
  111.  * groupevent [name]
  112.  *
  113.  *  - Add event to a group array.
  114.  *    You can optionally asign it to a name.
  115.  *
  116.  * ============================================================================
  117.  * Lunatic Mode
  118.  * ============================================================================
  119.  *
  120.  * You can use special conditions to a page by using javascript.
  121.  * There are inside a comment or note like others conditions and if you use more
  122.  * than one all will be merged.
  123.  *
  124.  * customreq: code
  125.  *
  126.  *  result - this is where result is stored. By default is false.
  127.  *
  128.  * ============================================================================
  129.  * Plugin commands
  130.  * ============================================================================
  131.  *
  132.  * CallPage x
  133.  *
  134.  *   - Call page by it's name or page number.
  135.  *
  136.  * CallEventPage 1 2 3
  137.  *
  138.  *   - You can call a page from other event by it's name or page number.
  139.  *     Works different depending on how many arguments have been added.
  140.  *     1: Calls first page from event.
  141.  *     2: Second parameter is the page name or number.
  142.  *     3: Third is the eventid that can be affected by self switchs/vars
  143.  *        or commands. You can use "this" as a param.
  144.  *
  145.  *
  146.  * These other plugin commands are actually included in ICF-Soft Main Utility.
  147.  * Reffer to Main Utility readme for full list.
  148.  *
  149.  * selfswitch x true/false
  150.  * mapswitch x true/false
  151.  *
  152.  *  - Turns on/off specified selfswitch or mapswitch.
  153.  *
  154.  * remoteswitch mapid eventid x true/false
  155.  *
  156.  *  - Turns on/off specified selfswitch or mapswitch remotely.
  157.  *    Use eventid 0 for a mapswitch.
  158.  *
  159.  * ============================================================================
  160.  * Scripting functions
  161.  * ============================================================================
  162.  *
  163.  * event.callPage(name);
  164.  *
  165.  *  - Call an event page by it's name.
  166.  *
  167.  * $gameMap.groupEvents();
  168.  *
  169.  *  - Return an array with all grouped events.
  170.  *
  171.  * $gameMap.groupEvents(name);
  172.  *
  173.  *  - Return an array with all events inside specified group.
  174.  *
  175.  * ============================================================================
  176.  * Incompatibilities
  177.  * ============================================================================
  178.  *
  179.  * There's no known incompatible plugins yet.
  180.  *
  181.  * ============================================================================
  182.  * Known isues
  183.  * ============================================================================
  184.  *
  185.  * Not yet.
  186.  *
  187.  * Plugins that allow to have more than 999 maps without increasing map ids
  188.  * can cause glitches between maps that shares special switches and variables.
  189.  *
  190.  * ============================================================================
  191.  * Changelog
  192.  * ============================================================================
  193.  *
  194.  * Version 1.05:
  195.  * - Allow to group events in an array to use without eventId.
  196.  *
  197.  * Version 1.04:
  198.  * - Added pagenames and dummypages.
  199.  *
  200.  * Version 1.03:
  201.  * - Use of ICF-Soft Main Utility.
  202.  * - Added partyswitchs.
  203.  * - Added self, map and party variables.
  204.  *
  205.  * Version 1.02:
  206.  * - Fixed and improved lunatic mode.
  207.  * - More versatile variables.
  208.  * - Added remote switchs.
  209.  *
  210.  * Version 1.01:
  211.  * - Added lunatic mode.
  212.  *
  213.  * Version 1.00:
  214.  * - Finished plugin!
  215.  *
  216.  * ============================================================================
  217.  *
  218.  * For commercial and non-commercial games.
  219.  * Credit to ICF-Soft.
  220.  * This entire header must be included with plugin.
  221.  *
  222.  * ============================================================================
  223. */
  224. //=============================================================================
  225.  /*:es
  226.  * @plugindesc v1.05b Este complemento permite más condiciones en los
  227.  * eventos.
  228.  * @author ICF-Soft [http://icfsoft.blogspot.com.es/]
  229.  *
  230.  * @param Developer HaltJS
  231.  * @desc Si está activado salta cuando una función personalizada
  232.  * da error.   No - false   Si - true
  233.  * @default false
  234.  *
  235.  * @help
  236.  * ============================================================================
  237.  * Introducción
  238.  * ============================================================================
  239.  *
  240.  * Las páginas de los eventos tienen un número limitado de condiciones, son
  241.  * útiles pero a veces no son suficientes.
  242.  * Las variables por defecto no son muy versátiles pues sólo tienen la opción
  243.  * de "igual o mayor".
  244.  *
  245.  * Con este complemento puedes añadir condiciones extra tales como más
  246.  * interruptores, autointerruptores ilimitados, interruptores de mapa ilimitados
  247.  * y variables más versátiles.
  248.  *
  249.  * Los nuevos interruptores de mapa son unos interruptores especiales similares
  250.  * a los automáticos, que afectan a todos los eventos del mapa.
  251.  *
  252.  * Los partyswitches no son interruptores en sí mismos. Indican si algún
  253.  * personaje del grupo tiene el interruptor activado.
  254.  *
  255.  * Las variables ahora permiten las opciones "igual o mayor", "mayor que",
  256.  * "menor que", "menor o igual", "igual que" o "distinto a".
  257.  *
  258.  * Las variables de evento y mapa no requieren explicar cómo funcionan.
  259.  * Las partyvariables funcionan como combinación de las variables de los
  260.  * personajes que se encuentran en el grupo (suma, min, máx y media).
  261.  *
  262.  * Ahora puedes asignar nombres a las páginas para poder llamarlas y/o hacerlas
  263.  * que no se activen en el mapa.
  264.  * Además de un modo de agrupar los eventos para poder llamarlos sin necesidad
  265.  * de usar la id.
  266.  *
  267.  * ============================================================================
  268.  * Parámetros
  269.  * ============================================================================
  270.  *
  271.  * Developer HaltJS: Esta es una variable de uso durante el desarrollo del juego
  272.  * útil cuando quieres comprobar si hay alguna función personalizada incorrecta.
  273.  * Cuando está activado al encontrar un error el juego se para.
  274.  * Cuando está desactivado ignora el error y el juego continúa.
  275.  *
  276.  * ============================================================================
  277.  * Uso
  278.  * ============================================================================
  279.  *
  280.  * Para añadir una condición extra en una página simplemente añadir una nota
  281.  * en el mismo formato que un comando de complemento:
  282.  *
  283.  * switch x x x x x
  284.  * selfswitch x x x
  285.  * mapswitch x
  286.  * partyswitch x x x
  287.  *
  288.  *  - Para añadir interruptor, autointerruptor, interruptor de mapa o
  289.  *    interruptor del grupo.
  290.  *    Puedes usar todos los que necesites del mismo tipo en una misma linea.
  291.  *
  292.  * [prefijo]variable x value
  293.  * [prefijo]variablehigh x value
  294.  * [prefijo]variableless x value
  295.  * [prefijo]variablemax x value
  296.  * [prefijo]variableequal x value
  297.  * [prefijo]variabledif x value
  298.  *
  299.  *  - Para añadir condición de variable. Tipos: mínimo, mayor, menos,
  300.  *    máximo, igual y distinto respectivamente.
  301.  *    Opcionalmente puedes utilizar un prefijo para usar autovariables,
  302.  *    de mapa o del grupo.
  303.  *    Quedaría así:
  304.  *
  305.  * selfvariable x value
  306.  * mapvariable x value
  307.  * partyvariable x value [min/max/avg]
  308.  *
  309.  *  - Partyvariables pueden usar un parámetro extra. Si se omite se usará
  310.  *    la suma de la variable de cada personaje del grupo.
  311.  *    -min: para comprobar el mínimo entre la variable de cada personaje
  312.  *          del grupo.
  313.  *    -max: para comprobar el máximo entre la variable de cada personaje
  314.  *          del grupo.
  315.  *    -avg: para comprobar la media de la variable de cada personaje
  316.  *          del grupo.
  317.  *
  318.  * Puedes poner un nombre a una página y/o deshabilitarla en mapa con las
  319.  * siguientes notas:
  320.  *
  321.  * pagename name
  322.  *
  323.  *  - Nombrar una página.
  324.  *
  325.  * dummypage [name]
  326.  *
  327.  *  - Impide que la página pueda ser activada del modo usual.
  328.  *    Opcionalmente puedes ponerle un nombre para que solo se pueda llamar
  329.  *    por el.
  330.  *
  331.  * Para agrupar eventos puedes utilizar la siguiente nota:
  332.  *
  333.  * groupevent [name]
  334.  *
  335.  *  - Añade el evento al grupo principal.
  336.  *    Optionalmente puedes añadirlo a un subgrupo específico.
  337.  *
  338.  * ============================================================================
  339.  * Lunatic Mode
  340.  * ============================================================================
  341.  *
  342.  * Puedes usar condiciones especiales en una página mediante javascript.
  343.  * Se pone el código en una nota del mismo modo que las demás condiciones.
  344.  * Si usas más de una se juntarán todas.
  345.  *
  346.  * customreq: código
  347.  *
  348.  *  result - aquí se almacena el resultado. Por defecto está desactivado.
  349.  *
  350.  * ============================================================================
  351.  * Comandos de complemento
  352.  * ============================================================================
  353.  *
  354.  * CallPage x
  355.  *
  356.  *   - Llama a una página del evento por su nombre o número.
  357.  *
  358.  * CallEventPage 1 2 3
  359.  *
  360.  *   - Llama a una página de otro evento por su nombre o número.
  361.  *     Funciona diferente según el número de argumentos que le pongas.
  362.  *     1: Llama la primera página del evento.
  363.  *     2: El segundo es nombre de página o número.
  364.  *     3: El tercero es la id del evento que puede ser afectado por las
  365.  *        variables/interruptores locales o comandos como borrar evento.
  366.  *        Puedes usar "this" para que afecte al evento desde donde se llama.
  367.  *
  368.  *
  369.  * El resto de comandos de complemento están actualmente incluidos
  370.  * en ICF-Soft Main Utility.
  371.  * Para ver la lista completa es mejor referirse al archivo leeme
  372.  * del Main Utility.
  373.  *
  374.  * selfswitch x true/false
  375.  * mapswitch x true/false
  376.  *
  377.  *  - Activa o desactiva el autointerruptor o interruptor de mapa.
  378.  *
  379.  * remoteswitch mapid eventid x true/false
  380.  *
  381.  *  - Activa o desactiva el autointerruptor o interruptor de mapa específico
  382.  *    de forma remota. Usar eventid 0 para interruptor de mapa.
  383.  *
  384.  * ============================================================================
  385.  * Funciones de script
  386.  * ============================================================================
  387.  *
  388.  * event.callPage(name);
  389.  *
  390.  *  - Llama a una página del evento por su nombre.
  391.  *
  392.  * $gameMap.groupEvents();
  393.  *
  394.  *  - Devuelve un array con los eventos agrupados.
  395.  *
  396.  * $gameMap.groupEvents(name);
  397.  *
  398.  *  - Devuelve un array con los eventos de un subgrupo.
  399.  *
  400.  * ============================================================================
  401.  * Incompatibilidades
  402.  * ============================================================================
  403.  *
  404.  * No se conocen complementos que sean incompatibles hasta la fecha.
  405.  *
  406.  * ============================================================================
  407.  * Problemas conocidos
  408.  * ============================================================================
  409.  *
  410.  * Por el momento ninguno.
  411.  *
  412.  * El uso de complementos que permiten usar más de 999 mapas que no incrementan
  413.  * las id's puede ocasionar bugs entre mapas que compartan interruptores
  414.  * y variables especiales.
  415.  *
  416.  * ============================================================================
  417.  * Historial de versiones
  418.  * ============================================================================
  419.  *
  420.  * Version 1.05:
  421.  * - Posibilidad de agrupar eventos en array para usarlos sin su id.
  422.  *
  423.  * Version 1.04:
  424.  * - Se han añadido nombres para páginas y deshabilitación de páginas.
  425.  *
  426.  * Version 1.03:
  427.  * - Se empieza a utilizar el ICF-Soft Main Utility.
  428.  * - Se han añadido los interruptores de grupo.
  429.  * - Se han añadido las variables de evento, mapa y de grupo.
  430.  *
  431.  * Version 1.02:
  432.  * - Modo lunático arreglado y mejorado.
  433.  * - Variables más versátiles.
  434.  * - Se han añadido interruptores remotos.
  435.  *
  436.  * Version 1.01:
  437.  * - Se ha añadido el modo lunático.
  438.  *
  439.  * Version 1.00:
  440.  * - Complemento terminado.
  441.  *
  442.  * ============================================================================
  443.  *
  444.  * Para juegos comerciales y no comerciales.
  445.  * Se debe incluir a ICF-Soft en los créditos.
  446.  * Esta cabecera debe incluirse íntegramente con el plugin.
  447.  *
  448.  * ============================================================================
  449. */
  450. //=============================================================================
  451.  
  452. //=============================================================================
  453. // Parameter Variables
  454. //=============================================================================
  455.  
  456. ICF.Parameters = PluginManager.parameters('ICFSoft_EventExtension');
  457. ICF.Param = ICF.Param || {};
  458.  
  459. ICF.Param.EventExHalt = ICF.Parameters['Developer HaltJS'].toLowerCase() === "true";
  460.  
  461. if (!Imported.ICFSoft_MainUtility) {throw new Error('This plugin requires ICF-Soft Main Utility plugin version 1.02 to work.\nYou can download it at icfsoft.blogspot.com inside plugins section.');}
  462. if (ICF.MainUtility.Version < 102) {throw new Error('This plugin requires ICF-Soft Main Utility plugin version 1.02 to work.\nYou can download it at icfsoft.blogspot.com inside plugins section.');}
  463.  
  464. //=============================================================================
  465. // Event Utilities
  466. //=============================================================================
  467.  
  468. ICF.Events.Checking = false;
  469.  
  470. ICF.Events.CustomSwitch = function(mapid, evid, switchname, value) {
  471.     var _key = [mapid, evid, switchname];
  472.     var _value = (value.toLowerCase() === "true");
  473.     $gameSelfSwitches.setValue(_key, _value);
  474. }
  475.  
  476. ICF.Events.ProcessComment = function(page, obj, content) {
  477.     var args = content.split(" ");
  478.     if (ICF.Events.Checking) {
  479.         page._customreq = page._customreq + content + '\n';
  480.     } else if (args[0] !== null && args[1] !== null) {
  481.         if (args[0].toLowerCase() == "groupevent") {
  482.             obj._isGrouped = true;
  483.             if (args[1] !== null) {obj._groupName = args[1].toLowerCase();};
  484.         } else if (args[0].toLowerCase() == "dummypage") {
  485.             page._isDummy = true;
  486.             if (args[1] !== null) {obj.pagenames[args[1]] = page;};
  487.         } else if ((args[0].toLowerCase() == "pagename") && (args[1] !== null)) {
  488.             obj.pagenames[args[1]] = page;
  489.         } else if (args[0].toLowerCase() == "switch") {
  490.             args.splice(0, 1);
  491.             page._switchs = page._switchs.concat(args);
  492.         } else if (args[0].toLowerCase() == "selfswitch") {
  493.             args.splice(0, 1);
  494.             page._selfswitchs = page._selfswitchs.concat(args);
  495.         } else if (args[0].toLowerCase() == "mapswitch") {
  496.             args.splice(0, 1);
  497.             page._mapswitchs = page._mapswitchs.concat(args);
  498.         } else if (args[0].toLowerCase() == "partyswitch") {
  499.             args.splice(0, 1);
  500.             page._mapswitchs = page._partyswitchs.concat(args);
  501.         } else if (args[0].toLowerCase().match(/((?:self)|(?:map)|(?:party))?(variable)((?:high)|(?:less)|(?:min)|(?:max)|(?:equal)|(?:dif))?/i)&&(RegExp.$1.length + RegExp.$2.length + RegExp.$3.length == args[0].length)) {
  502.             var code = (RegExp.$3 == "high")? 2 : (RegExp.$3 == "less")? 4 : (RegExp.$3 == "max")? 5 : (RegExp.$3 == "equal")? 0 : (RegExp.$3 == "dif")? 1 : 3;
  503.             if (RegExp.$1 == "self") page._selfvars.push([code, args[1], args[2]]);
  504.             else if (RegExp.$1 == "map") page._mapvars.push([code, args[1], args[2]]);
  505.             else if (RegExp.$1 == "party") page._partyvars.push([code, args[1], args[2], args[3]]);
  506.             else page._vars.push([code, args[1], args[2]]);
  507.         } else if (args[0].toLowerCase() == "customreq:") {
  508.             page._customreq = page._customreq + content.substring(10) + '\n';
  509.             ICF.Events.Checking = true;
  510.         }
  511.     }
  512. }
  513.  
  514. ICF.Events.CheckVar = function(code, value1, value2) {
  515.     switch (code) {
  516.         case 0:
  517.             return (value1 == value2); break;
  518.         case 1:
  519.             return (value1 !== value2); break;
  520.         case 2:
  521.             return (value1 > value2); break;
  522.         case 3:
  523.             return (value1 >= value2); break;
  524.         case 4:
  525.             return (value1 < value2); break;
  526.         case 5:
  527.             return (value1 <= value2); break;
  528.         default:
  529.             return false;
  530.     }
  531. }
  532.  
  533. //=============================================================================
  534. // Game_Event
  535. //=============================================================================
  536.  
  537. ICF.Events.init = Game_Event.prototype.initialize;
  538. Game_Event.prototype.initialize = function(mapId, eventId) {
  539.     ICF.Events.init.call(this, mapId, eventId);
  540.     var pages = this.event().pages;
  541.     this.event().pagenames = {};
  542.     for (i = 0; i < pages.length; i += 1) {
  543.         var page = pages[i];
  544.         page._switchs = [];
  545.         page._selfswitchs = [];
  546.         page._mapswitchs = [];
  547.         page._partyswitchs = [];
  548.         page._vars = [];
  549.         page._selfvars = [];
  550.         page._mapvars = [];
  551.         page._partyvars = [];
  552.         page._customreq = "";
  553.         for (j = 0; j < page.list.length; j += 1) {
  554.             var command = page.list[j];
  555.             if (command.code === 108) {
  556.                 ICF.Events.Checking = false;
  557.                 ICF.Events.ProcessComment(page, this.event(), command.parameters[0]);
  558.             } else if (command.code === 408) {
  559.                 ICF.Events.ProcessComment(page, this.event(), command.parameters[0]);
  560.             }
  561.         }
  562.     }
  563.     this.refresh();
  564. };
  565.  
  566. ICF.Events.meetsConditions = Game_Event.prototype.meetsConditions;
  567. Game_Event.prototype.meetsConditions = function(page) {
  568.     if (page._isDummy) {return false;}
  569.     if (!ICF.Events.meetsConditions.call(this, page)) {return false;}
  570.     if (page._switchs == null) {return true;}
  571.     for (i = 0; i < page._switchs.length; i += 1) {
  572.         if (!$gameSwitches.value(page._switchs[i])) {
  573.             return false;
  574.         }
  575.     }
  576.     for (i = 0; i < page._selfswitchs.length; i += 1) {
  577.         var key = [this._mapId, this._eventId, page._selfswitchs[i]];
  578.         if ($gameSelfSwitches.value(key) !== true) {
  579.             return false;
  580.         }
  581.     }
  582.     for (i = 0; i < page._mapswitchs.length; i += 1) {
  583.         var key = [this._mapId, 0, page._mapswitchs[i]];
  584.         if ($gameSelfSwitches.value(key) !== true) {
  585.             return false;
  586.         }
  587.     }
  588.     for (i = 0; i < page._partyswitchs.length; i += 1) {
  589.         if ($gameParty.selfswitch(page._partyswitchs[i]) !== true) {
  590.             return false;
  591.         }
  592.     }
  593.     for (i = 0; i < page._vars.length; i += 1) {
  594.         if (!ICF.MainUtility.CheckVar(page._vars[i][0], $gameVariables.value(page._vars[i][1]), page._vars[i][2])) {
  595.             return false;
  596.         }
  597.     }
  598.     for (i = 0; i < page._selfvars.length; i += 1) {
  599.         var key = [this._mapId, this._eventId, page._selfvars[i][1]];
  600.         if (!ICF.MainUtility.CheckVar(page._selfvars[i][0], $gameSelfVariables.value(key), page._selfvars[i][2])) {
  601.             return false;
  602.         }
  603.     }
  604.     for (i = 0; i < page._mapvars.length; i += 1) {
  605.         var key = [this._mapId, 0, page._mapvars[i][1]];
  606.         if (!ICF.MainUtility.CheckVar(page._mapvars[i][0], $gameSelfVariables.value(key), page._mapvars[i][2])) {
  607.             return false;
  608.         }
  609.     }
  610.     for (i = 0; i < page._partyvars.length; i += 1) {
  611.         var code = -1;
  612.         if (!!page._partyvars[i][3]) {code = ["min", "max", "avg"].indexOf(page._partyvars[i][3].toLowerCase());}
  613.         if (code == 0) {if (!ICF.MainUtility.CheckVar(page._partyvars[i][0], $gameParty.minselfvariable(page._partyvars[i][1]), page._partyvars[i][2])) {
  614.             return false;}
  615.         } else if (code == 1) {if (!ICF.MainUtility.CheckVar(page._partyvars[i][0], $gameParty.maxselfvariable(page._partyvars[i][1]), page._partyvars[i][2])) {
  616.             return false;}
  617.         } else if (code == 2) {if (!ICF.MainUtility.CheckVar(page._partyvars[i][0], $gameParty.avgselfvariable(page._partyvars[i][1]), page._partyvars[i][2])) {
  618.             return false;}
  619.         } else {if (!ICF.MainUtility.CheckVar(page._partyvars[i][0], $gameParty.selfvariable(page._partyvars[i][1]), page._partyvars[i][2])) {
  620.             return false;}
  621.         }
  622.     }
  623.  
  624.     if (page._customreq.length != "") {
  625.         var result = false;
  626.         try {eval(page._customreq);}
  627.         catch (e) {if(ICF.Param.EventExHalt){throw new Error('Error in custom page condition for event');}}
  628.         return result;
  629.     }
  630.  
  631.     return true;
  632. };
  633.  
  634. Game_Event.prototype.callPage = function(pagename) {
  635.     var list = null;
  636.     if (isNaN(Number(pagename)) || pagename > 20) {
  637.         list = this.event().pagenames[pagename];
  638.     } else {
  639.         list = this.event().pages[page - 1];
  640.     }
  641.     if (!list) return;
  642.     $gameMap.interpreter.setupChild(list, this._eventId);
  643. };
  644.  
  645. Game_Event.prototype.callPageGlobally = function(pagename) {
  646.     var list = null;
  647.     if (isNaN(Number(pagename)) || pagename > 20) {
  648.         list = this.event().pagenames[pagename];
  649.     } else {
  650.         list = this.event().pages[page - 1];
  651.     }
  652.     if (!list) return;
  653.     $gameMap.interpreter.setupChild(list, 0);
  654. };
  655.  
  656. //=============================================================================
  657. // Game_Map
  658. //=============================================================================
  659.  
  660. Game_Map.prototype.interpreter = function() {
  661.     return this._interpreter;
  662. };
  663.  
  664. ICF.Events.mapsetup = Game_Map.prototype.setup;
  665. Game_Map.prototype.setup = function(mapId) {
  666.     ICF.Events.mapsetup.call(this, mapId);
  667.     this._groupEvents = [];
  668.     this._groupEventNames = {};
  669.     for (var i = 0; i < this._events.length; i++) {
  670.         if (this._events[i]._isGrouped) {
  671.             this._groupEvents.push(this._events[i]);
  672.             if (!!this._events[i]._groupName) {
  673.                 this._groupEventNames[this._events[i]._groupName] = this._groupEventNames[this._events[i]._groupName] || [];
  674.                 this._groupEventNames[this._events[i]._groupName].push(this._events[i]);
  675.             }
  676.         }
  677.     }
  678. };
  679.  
  680. Game_Map.prototype.groupEvents = function(group) {
  681.     if (group == undefined) return this._groupEvents;
  682.     if (!this._groupEventNames[group]) return [];
  683.     return this._groupEventNames[group];
  684. };
  685.  
  686. //=============================================================================
  687. // Game_Interpreter
  688. //=============================================================================
  689.  
  690. ICF.Events.pluginCommand = Game_Interpreter.prototype.pluginCommand;
  691. Game_Interpreter.prototype.pluginCommand = function(command, args) {
  692.     ICF.Events.pluginCommand.call(this, command, args);
  693.     if (command.toLowerCase() == 'callpage') {
  694.         this.callEventPage(this._mapId, this.eventId(), args[0], this.eventId());
  695.     } else if (command.toLowerCase() == 'calleventpage') {
  696.         if (args.lenght == 0) return;
  697.         else if (args.lenght == 1) this.callEventPage(this._mapId, args[0], 1, args[0]);
  698.         else if (args.lenght == 2) this.callEventPage(this._mapId, args[0], args[1], args[0]);
  699.         else if (args.lenght == 3 && args[2].toLowerCase() == 'this') this.callEventPage(this._mapId, args[0], args[1], this.eventId());
  700.         else if (args.lenght == 3) this.callEventPage(this._mapId, args[0], args[1], args[2]);
  701.     }
  702. };
  703.  
  704. Game_Interpreter.prototype.callEventPage = function(mapId, eventId, page, source) {
  705.     var event = $gameMap.events[eventId];
  706.     if (!event) return;
  707.     var list = null;
  708.     if (isNaN(Number(page)) || page > 20) {
  709.         list = event.pagenames[page];
  710.     } else {
  711.         list = event.pages[page - 1];
  712.     }
  713.     if (!list) return;
  714.     if (isNaN(Number(source))) source = 0;
  715.     this.setupChild(list, source);
  716. };
  717.  
  718. //=============================================================================
  719. // End of File
  720. //=============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement