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.00 This plugin allows more conditions to events.
- * @author ICF-Soft [http://icfsoft.blogspot.com.es/]
- *
- * @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", "lower than" or "equal to" a value.
- *
- * ============================================================================
- * How to use
- * ============================================================================
- *
- * To add an extra condition to a page just add a comment or note, same
- * format as plugin commands:
- *
- * switch x
- * selfswitch x
- * mapswitch x
- *
- * - Add specified game, self or map switch to conditions.
- *
- * variable x value
- * variableless x value
- * variableequal x value
- *
- * - Add a variable condition. There are three types: min, lower and equal.
- *
- * ============================================================================
- * Plugin commands
- * ============================================================================
- *
- * selfswitch x true/false
- * mapswitch x true/false
- *
- * - Turns on/off specified selfswitch or 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.
- *
- * ============================================================================
- *
- * Commercial use avaiable.
- * Credit to ICF-Soft.
- * This entire header must be included with plugin.
- *
- * ============================================================================
- */
- //=============================================================================
- /*:es
- * @plugindesc v1.00 Este complemento permite más condiciones en los
- * eventos.
- * @author ICF-Soft [http://icfsoft.blogspot.com.es/]
- *
- * @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", "menor que" e
- * "igual que".
- *
- * ============================================================================
- * 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
- * selfswitch x
- * mapswitch x
- *
- * - Para añadir interruptor, autointerruptor e interruptor de mapa.
- *
- * variable x value
- * variableless x value
- * variableequal x value
- *
- * - Para añadir condición de variable. Tipos: mínimo, menos e igual.
- *
- * ============================================================================
- * Comandos de complemento
- * ============================================================================
- *
- * selfswitch x true/false
- * mapswitch x true/false
- *
- * - Turns on/off specified selfswitch or mapswitch.
- *
- * ============================================================================
- * 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.
- *
- * ============================================================================
- *
- * Se permite el uso comercial.
- * Se debe incluir a ICF-Soft en los créditos.
- * Esta cabecera debe incluirse íntegramente con el plugin.
- *
- * ============================================================================
- */
- //=============================================================================
- //=============================================================================
- // Event Utilities
- //=============================================================================
- 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 (args[0] !== null && args[1] !== null) {
- if (args[0].toLowerCase() == "switch") {
- page._switchs.push(args[1]);
- } else if (args[0].toLowerCase() == "selfswitch") {
- page._selfswitchs.push(args[1]);
- } else if (args[0].toLowerCase() == "mapswitch") {
- page._mapswitchs.push(args[1]);
- } else if (args[0].toLowerCase() == "variable" && args[2] !== null) {
- page._vars.push([args[1], args[2]]);
- } else if (args[0].toLowerCase() == "variableless" && args[2] !== null) {
- page._varslow.push([args[1], args[2]]);
- } else if (args[0].toLowerCase() == "variableequal" && args[2] !== null) {
- page._varseq.push([args[1], args[2]]);
- }
- }
- }
- //=============================================================================
- // 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]);
- }
- };
- //=============================================================================
- // 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 = [];
- for (j = 0; j < page.list.length; j += 1) {
- var command = page.list[j];
- if (command.code === 408 || command.code === 108) {
- 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 ($gameVariables.value(page._vars[i][0]) < page._vars[i][1]) {
- return false;
- }
- }
- for (i = 0; i < page._varslow.length; i += 1) {
- if ($gameVariables.value(page._varslow[i][0]) >= page._varslow[i][1]) {
- return false;
- }
- }
- for (i = 0; i < page._varseq.length; i += 1) {
- if ($gameVariables.value(page._varseq[i][0]) != page._varseq[i][1]) {
- return false;
- }
- }
- return true;
- };
- //=============================================================================
- // End of File
- //=============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement