Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //=============================================================================
- // ICF-Soft Plugins - Event Extension
- // ICFSoft_EventExtension.js
- //=============================================================================
- var Imported = Imported || {};
- Imported.ICFSoft_Events = true;
- var ICF = ICF || {};
- ICF.Events = ICF.Events || {};
- //=============================================================================
- /*:
- * @plugindesc v1.02 This plugin allows more conditions to events.
- * @author ICF-Soft [http://icfsoft.blogspot.com.es/]
- *
- * @param Developer HaltJS
- * @desc When true it throws an error if an custom event condition
- * javascript doesn't work. NO - false YES - true
- * @default false
- *
- * @help
- * ============================================================================
- * Introduction
- *
- * Pageevents have a limited set of conditions, there are usefull but sometimes
- * aren't enough.
- * Variables by default aren't versatile enough because they have "greater or
- * equal" only option.
- *
- * With this plugin you can add extra conditions like more switches, unlimited
- * selfswitches, unlimited mapswitches and versatile variables.
- *
- * Mapswitches are special switches that aplies to all events in a map.
- *
- * Variables can now be "greater or equal", "greater than", "lower than",
- * "lower or equal", "equal to" or "different than" a value.
- *
- * ============================================================================
- * Parameters
- * ============================================================================
- *
- * Developer HaltJS: This is a development variable usefull to check if there is
- * a wrong javascript event condition.
- * When true will throw an error when it found a wrong javascript in lunatic
- * mode.
- * When false it will be ignored and game continues.
- *
- * ============================================================================
- * How to use
- * ============================================================================
- *
- * To add an extra condition to a page just add a comment or note, same
- * format as plugin commands:
- *
- * switch x x x x x x
- * selfswitch x x x x x
- * mapswitch x x
- *
- * - Add specified game, self or map switch to conditions.
- * - You can place all same-tipe switchs you need in same line.
- *
- * variable x value
- * variablehigh x value
- * variableless x value
- * variablemax x value
- * variableequal x value
- * variabledif x value
- *
- * - Add a variable condition. There are six types: min value, higher than,
- * lower than, max value, equal and not equal.
- *
- * ============================================================================
- * Lunatic Mode
- * ============================================================================
- *
- * You can use special conditions to a page by using javascript.
- * There are inside a comment or note like others conditions and if you use more
- * than one all will be merged.
- *
- * Actually it only works for first line. It will be solved in a later version.
- *
- * customreq: code
- *
- * result - this is where result is stored. By default is false.
- *
- * ============================================================================
- * Plugin commands
- * ============================================================================
- *
- * selfswitch x true/false
- * mapswitch x true/false
- *
- * - Turns on/off specified selfswitch or mapswitch.
- *
- * remoteswitch mapid eventid x true/false
- *
- * - Turns on/off specified selfswitch or mapswitch remotely.
- * Use eventid 0 for a mapswitch.
- *
- * ============================================================================
- * Incompatibilities
- * ============================================================================
- *
- * There's no known incompatible plugins yet.
- *
- * ============================================================================
- * Known isues
- * ============================================================================
- *
- * Not yet.
- *
- * Plugins that allow to have more than 999 maps without increasing map ids
- * can cause glitches between maps that shares selfswitches and mapswitches.
- *
- * ============================================================================
- * Changelog
- * ============================================================================
- *
- * Version 1.02:
- * - Fixed and improved lunatic mode.
- * - More versatile variables.
- * - Added remote switchs.
- *
- * Version 1.01:
- * - Added lunatic mode.
- *
- * Version 1.00:
- * - Finished plugin!
- *
- * ============================================================================
- *
- * For commercial and non-commercial games.
- * Credit to ICF-Soft.
- * This entire header must be included with plugin.
- *
- * ============================================================================
- */
- //=============================================================================
- /*:es
- * @plugindesc v1.02 Este complemento permite más condiciones en los
- * eventos.
- * @author ICF-Soft [http://icfsoft.blogspot.com.es/]
- *
- * @param Developer HaltJS
- * @desc Si está activado salta cuando una función personalizada
- * da error. No - false Si - true
- * @default false
- *
- * @help
- * ============================================================================
- * Introducción
- * ============================================================================
- *
- * Las páginas de los eventos tienen un número limitado de condiciones, son
- * útiles pero a veces no son suficientes.
- * Las variables por defecto no son muy versátiles pues sólo tienen la opción
- * de "igual o mayor".
- *
- * Con este complemento puedes añadir condiciones extra tales como más
- * interruptores, autointerruptores ilimitados, interruptores de mapa ilimitados
- * y variables más versátiles.
- *
- * Los nuevos interruptores de mapa son unos interruptores especiales similares
- * a los automáticos, que afectan a todos los eventos del mapa.
- *
- * Las variables ahora permiten las opciones "igual o mayor", "mayor que",
- * "menor que", "menor o igual", "igual que" o "distinto a".
- *
- * ============================================================================
- * Parámetros
- * ============================================================================
- *
- * Developer HaltJS: Esta es una variable de uso durante el desarrollo del juego
- * útil cuando quieres comprobar si hay alguna función personalizada incorrecta.
- * Cuando está activado al encontrar un error el juego se para.
- * Cuando está desactivado ignora el error y el juego continúa.
- *
- * ============================================================================
- * Uso
- * ============================================================================
- *
- * Para añadir una condición extra en una página simplemente añadir una nota
- * en el mismo formato que un comando de complemento:
- *
- * switch x x x x x
- * selfswitch x x x
- * mapswitch x
- *
- * - Para añadir interruptor, autointerruptor e interruptor de mapa.
- * - Puedes usar todos los que necesites del mismo tipo en una misma linea.
- *
- * variable x value
- * variablehigh x value
- * variableless x value
- * variablemax x value
- * variableequal x value
- * variabledif x value
- *
- * - Para añadir condición de variable. Tipos: mínimo, mayor, menos,
- * máximo, igual y distinto.
- *
- * ============================================================================
- * Lunatic Mode
- * ============================================================================
- *
- * Puedes usar condiciones especiales en una página mediante javascript.
- * Se pone el código en una nota del mismo modo que las demás condiciones.
- * Si usas más de una se juntarán todas.
- *
- * Actualmente Sólo funciona con la primera linea. Se arreglará en una próxima
- * versión.
- *
- * customreq: código
- *
- * result - aquí se almacena el resultado. Por defecto está desactivado.
- *
- * ============================================================================
- * Comandos de complemento
- * ============================================================================
- *
- * selfswitch x true/false
- * mapswitch x true/false
- *
- * - Activa o desactiva el autointerruptor o interruptor de mapa.
- *
- * remoteswitch mapid eventid x true/false
- *
- * - Activa o desactiva el autointerruptor o interruptor de mapa específico
- * de forma remota. Usar eventid 0 para interruptor de mapa.
- *
- * ============================================================================
- * Incompatibilidades
- * ============================================================================
- *
- * No se conocen complementos que sean incompatibles hasta la fecha.
- *
- * ============================================================================
- * Problemas conocidos
- * ============================================================================
- *
- * Por el momento ninguno.
- *
- * El uso de complementos que permiten usar más de 999 mapas que no incrementan
- * las id's puede ocasionar bugs entre mapas que compartan interruptores
- * especiales.
- *
- * ============================================================================
- * Historial de versiones
- * ============================================================================
- *
- * Version 1.02:
- * - Modo lunático arreglado y mejorado.
- * - Variables más versátiles.
- * - Se han añadido interruptores remotos.
- *
- * Version 1.01:
- * - Se ha añadido el modo lunático.
- *
- * Version 1.00:
- * - Complemento terminado.
- *
- * ============================================================================
- *
- * Para juegos comerciales y no comerciales.
- * Se debe incluir a ICF-Soft en los créditos.
- * Esta cabecera debe incluirse íntegramente con el plugin.
- *
- * ============================================================================
- */
- //=============================================================================
- //=============================================================================
- // Parameter Variables
- //=============================================================================
- ICF.Parameters = PluginManager.parameters('ICFSoft_EventExtension');
- ICF.Param = ICF.Param || {};
- ICF.Param.EventExHalt = ICF.Parameters['Developer HaltJS'].toLowerCase() === "true";
- //=============================================================================
- // Event Utilities
- //=============================================================================
- ICF.Events.Checking = false;
- ICF.Events.CustomSwitch = function(mapid, evid, switchname, value) {
- var _key = [mapid, evid, switchname];
- var _value = (value.toLowerCase() === "true");
- $gameSelfSwitches.setValue(_key, _value);
- }
- ICF.Events.CustomCondition = function(page, content) {
- var args = content.split(" ");
- if (ICF.Events.Checking) {
- page._customreq = page._customreq + content + '\n';
- } else if (args[0] !== null && args[1] !== null) {
- if (args[0].toLowerCase() == "switch") {
- args.splice(0, 1);
- page._switchs = page._switchs.concat(args);
- } else if (args[0].toLowerCase() == "selfswitch") {
- args.splice(0, 1);
- page._selfswitchs = page._selfswitchs.concat(args);
- } else if (args[0].toLowerCase() == "mapswitch") {
- args.splice(0, 1);
- page._mapswitchs = page._mapswitchs.concat(args);
- } else if (((args[0].toLowerCase() == "variable")||(args[0].toLowerCase() == "variablemin")) && args[2] !== null) {
- page._vars.push([3, args[1], args[2]]);
- } else if (args[0].toLowerCase() == "variablehigh" && args[2] !== null) {
- page._vars.push([2, args[1], args[2]]);
- } else if (args[0].toLowerCase() == "variableless" && args[2] !== null) {
- page._vars.push([4, args[1], args[2]]);
- } else if (args[0].toLowerCase() == "variablemax" && args[2] !== null) {
- page._vars.push([5, args[1], args[2]]);
- } else if (args[0].toLowerCase() == "variableequal" && args[2] !== null) {
- page._vars.push([0, args[1], args[2]]);
- } else if (args[0].toLowerCase() == "variabledif" && args[2] !== null) {
- page._vars.push([1, args[1], args[2]]);
- } else if (args[0].toLowerCase() == "customreq:") {
- page._customreq = page._customreq + content.substring(10) + '\n';
- ICF.Events.Checking = true;
- }
- }
- }
- ICF.Events.CheckVar = function(code, value1, value2) {
- switch (code) {
- case 0:
- return (value1 == value2); break;
- case 1:
- return (value1 !== value2); break;
- case 2:
- return (value1 > value2); break;
- case 3:
- return (value1 >= value2); break;
- case 4:
- return (value1 < value2); break;
- case 5:
- return (value1 <= value2); break;
- default:
- return false;
- }
- }
- //=============================================================================
- // Game_Interpreter
- //=============================================================================
- ICF.Events.pluginCommand = Game_Interpreter.prototype.pluginCommand;
- Game_Interpreter.prototype.pluginCommand = function(command, args) {
- ICF.Events.pluginCommand.call(this, command, args);
- if (command === 'selfswitch') {
- ICF.Events.CustomSwitch(this._mapId, this._eventId, args[0], args[1]);
- } else if (command === 'mapswitch') {
- ICF.Events.CustomSwitch(this._mapId, 0, args[0], args[1]);
- } else if (command === 'remoteswitch') {
- ICF.Events.CustomSwitch(args[0], args[1], args[2], args[3]);
- }
- };
- //=============================================================================
- // Game_Event
- //=============================================================================
- ICF.Events.init = Game_Event.prototype.initialize;
- Game_Event.prototype.initialize = function(mapId, eventId) {
- ICF.Events.init.call(this, mapId, eventId);
- var pages = this.event().pages;
- for (i = 0; i < pages.length; i += 1) {
- var page = pages[i];
- page._switchs = [];
- page._selfswitchs = [];
- page._mapswitchs = [];
- page._vars = [];
- page._varslow = [];
- page._varseq = [];
- page._customreq = "";
- for (j = 0; j < page.list.length; j += 1) {
- var command = page.list[j];
- if (command.code === 108) {
- ICF.Events.Checking = false;
- ICF.Events.CustomCondition(page, command.parameters[0]);
- } else if (command.code === 408) {
- ICF.Events.CustomCondition(page, command.parameters[0]);
- }
- }
- }
- this.refresh();
- };
- ICF.Events.meetsConditions = Game_Event.prototype.meetsConditions;
- Game_Event.prototype.meetsConditions = function(page) {
- if (!ICF.Events.meetsConditions.call(this, page)) {return false;}
- if (page._switchs == null) {return true;}
- for (i = 0; i < page._switchs.length; i += 1) {
- if (!$gameSwitches.value(page._switchs[i])) {
- return false;
- }
- }
- for (i = 0; i < page._selfswitchs.length; i += 1) {
- var key = [this._mapId, this._eventId, page._selfswitchs[i]];
- if ($gameSelfSwitches.value(key) !== true) {
- return false;
- }
- }
- for (i = 0; i < page._mapswitchs.length; i += 1) {
- var key = [this._mapId, 0, page._mapswitchs[i]];
- if ($gameSelfSwitches.value(key) !== true) {
- return false;
- }
- }
- for (i = 0; i < page._vars.length; i += 1) {
- if (!ICF.Events.CheckVar(page._vars[i][0], $gameVariables.value(page._vars[i][1]), page._vars[i][2])) {
- return false;
- }
- }
- if (page._customreq.length != "") {
- var result = false;
- try {eval(page._customreq);}
- catch (e) {if(ICF.Param.EventExHalt){throw new Error('Error in custom page condition for event');}}
- return result;
- }
- return true;
- };
- //=============================================================================
- // End of File
- //=============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement