Advertisement
ICF-Soft

ICF-Soft Event Expansion RPG Maker MV

Jan 29th, 2016
161
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. //=============================================================================
  13.  /*:
  14.  * @plugindesc v1.00 This plugin allows more conditions to events.
  15.  * @author ICF-Soft [http://icfsoft.blogspot.com.es/]
  16.  *
  17.  * @help
  18.  * ============================================================================
  19.  * Introduction
  20.  *
  21.  * Pageevents have a limited set of conditions, there are usefull but sometimes
  22.  * aren't enough.
  23.  * Variables by default aren't versatile enough because they have "greater or
  24.  * equal" only option.
  25.  *
  26.  * With this plugin you can add extra conditions like more switches, unlimited
  27.  * selfswitches, unlimited mapswitches and versatile variables.
  28.  *
  29.  * Mapswitches are special switches that aplies to all events in a map.
  30.  *
  31.  * Variables can now be "greater or equal", "lower than" or "equal to" a value.
  32.  *
  33.  * ============================================================================
  34.  * How to use
  35.  * ============================================================================
  36.  *
  37.  * To add an extra condition to a page just add a comment or note, same
  38.  * format as plugin commands:
  39.  *
  40.  * switch x
  41.  * selfswitch x
  42.  * mapswitch x
  43.  *
  44.  *  - Add specified game, self or map switch to conditions.
  45.  *
  46.  * variable x value
  47.  * variableless x value
  48.  * variableequal x value
  49.  *
  50.  *  - Add a variable condition. There are three types: min, lower and equal.
  51.  *
  52.  * ============================================================================
  53.  * Plugin commands
  54.  * ============================================================================
  55.  *
  56.  * selfswitch x true/false
  57.  * mapswitch x true/false
  58.  *
  59.  *  - Turns on/off specified selfswitch or mapswitch.
  60.  *
  61.  * ============================================================================
  62.  * Incompatibilities
  63.  * ============================================================================
  64.  *
  65.  * There's no known incompatible plugins yet.
  66.  *
  67.  * ============================================================================
  68.  * Known isues
  69.  * ============================================================================
  70.  *
  71.  * Not yet.
  72.  *
  73.  * Plugins that allow to have more than 999 maps without increasing map ids
  74.  * can cause glitches between maps that shares selfswitches and mapswitches.
  75.  *
  76.  * ============================================================================
  77.  *
  78.  * Commercial use avaiable.
  79.  * Credit to ICF-Soft.
  80.  * This entire header must be included with plugin.
  81.  *
  82.  * ============================================================================
  83. */
  84. //=============================================================================
  85.  /*:es
  86.  * @plugindesc v1.00 Este complemento permite más condiciones en los
  87.  * eventos.
  88.  * @author ICF-Soft [http://icfsoft.blogspot.com.es/]
  89.  *
  90.  * @help
  91.  * ============================================================================
  92.  * Introducción
  93.  * ============================================================================
  94.  *
  95.  * Las páginas de los eventos tienen un número limitado de condiciones, son
  96.  * útiles pero a veces no son suficientes.
  97.  * Las variables por defecto no son muy versátiles pues sólo tienen la opción
  98.  * de "igual o mayor".
  99.  *
  100.  * Con este complemento puedes añadir condiciones extra tales como más
  101.  * interruptores, autointerruptores ilimitados, interruptores de mapa ilimitados
  102.  * y variables más versátiles.
  103.  *
  104.  * Los nuevos interruptores de mapa son unos interruptores especiales similares
  105.  * a los automáticos, que afectan a todos los eventos del mapa.
  106.  *
  107.  * Las variables ahora permiten las opciones "igual o mayor", "menor que" e
  108.  * "igual que".
  109.  *
  110.  * ============================================================================
  111.  * Uso
  112.  * ============================================================================
  113.  *
  114.  * Para añadir una condición extra en una página simplemente añadir una nota
  115.  * en el mismo formato que un comando de complemento:
  116.  *
  117.  * switch x
  118.  * selfswitch x
  119.  * mapswitch x
  120.  *
  121.  *  - Para añadir interruptor, autointerruptor e interruptor de mapa.
  122.  *
  123.  * variable x value
  124.  * variableless x value
  125.  * variableequal x value
  126.  *
  127.  *  - Para añadir condición de variable. Tipos: mínimo, menos e igual.
  128.  *
  129.  * ============================================================================
  130.  * Comandos de complemento
  131.  * ============================================================================
  132.  *
  133.  * selfswitch x true/false
  134.  * mapswitch x true/false
  135.  *
  136.  *  - Turns on/off specified selfswitch or mapswitch.
  137.  *
  138.  * ============================================================================
  139.  * Incompatibilidades
  140.  * ============================================================================
  141.  *
  142.  * No se conocen complementos que sean incompatibles hasta la fecha.
  143.  *
  144.  * ============================================================================
  145.  * Problemas conocidos
  146.  * ============================================================================
  147.  *
  148.  * Por el momento ninguno.
  149.  *
  150.  * El uso de complementos que permiten usar más de 999 mapas que no incrementan
  151.  * las id's puede ocasionar bugs entre mapas que compartan interruptores
  152.  * especiales.
  153.  *
  154.  * ============================================================================
  155.  *
  156.  * Se permite el uso comercial.
  157.  * Se debe incluir a ICF-Soft en los créditos.
  158.  * Esta cabecera debe incluirse íntegramente con el plugin.
  159.  *
  160.  * ============================================================================
  161. */
  162. //=============================================================================
  163.  
  164. //=============================================================================
  165. // Event Utilities
  166. //=============================================================================
  167.  
  168. ICF.Events.CustomSwitch = function(mapid, evid, switchname, value) {
  169.     var _key = [mapid, evid, switchname];
  170.     var _value = (value.toLowerCase() === "true");
  171.     $gameSelfSwitches.setValue(_key, _value);
  172. }
  173.  
  174. ICF.Events.CustomCondition = function(page, content) {
  175.     var args = content.split(" ");
  176.     if (args[0] !== null && args[1] !== null) {
  177.         if (args[0].toLowerCase() == "switch") {
  178.             page._switchs.push(args[1]);
  179.         } else if (args[0].toLowerCase() == "selfswitch") {
  180.             page._selfswitchs.push(args[1]);
  181.         } else if (args[0].toLowerCase() == "mapswitch") {
  182.             page._mapswitchs.push(args[1]);
  183.         } else if (args[0].toLowerCase() == "variable" && args[2] !== null) {
  184.             page._vars.push([args[1], args[2]]);
  185.         } else if (args[0].toLowerCase() == "variableless" && args[2] !== null) {
  186.             page._varslow.push([args[1], args[2]]);
  187.         } else if (args[0].toLowerCase() == "variableequal" && args[2] !== null) {
  188.             page._varseq.push([args[1], args[2]]);
  189.         }
  190.     }
  191. }
  192.  
  193. //=============================================================================
  194. // Game_Interpreter
  195. //=============================================================================
  196.  
  197. ICF.Events.pluginCommand = Game_Interpreter.prototype.pluginCommand;
  198. Game_Interpreter.prototype.pluginCommand = function(command, args) {
  199.         ICF.Events.pluginCommand.call(this, command, args);
  200.     if (command === 'selfswitch') {
  201.         ICF.Events.CustomSwitch(this._mapId, this._eventId, args[0], args[1]);
  202.     } else if (command === 'mapswitch') {
  203.         ICF.Events.CustomSwitch(this._mapId, 0, args[0], args[1]);
  204.     }
  205. };
  206.  
  207. //=============================================================================
  208. // Game_Event
  209. //=============================================================================
  210.  
  211. ICF.Events.init = Game_Event.prototype.initialize;
  212. Game_Event.prototype.initialize = function(mapId, eventId) {
  213.     ICF.Events.init.call(this, mapId, eventId);
  214.     var pages = this.event().pages;
  215.     for (i = 0; i < pages.length; i += 1) {
  216.         var page = pages[i];
  217.         page._switchs = [];
  218.         page._selfswitchs = [];
  219.         page._mapswitchs = [];
  220.         page._vars = [];
  221.         page._varslow = [];
  222.         page._varseq = [];
  223.         for (j = 0; j < page.list.length; j += 1) {
  224.             var command = page.list[j];
  225.             if (command.code === 408 || command.code === 108) {
  226.                 ICF.Events.CustomCondition(page, command.parameters[0]);
  227.             }
  228.         }
  229.     }
  230.     this.refresh();
  231. };
  232.  
  233. ICF.Events.meetsConditions = Game_Event.prototype.meetsConditions;
  234. Game_Event.prototype.meetsConditions = function(page) {
  235.     if (!ICF.Events.meetsConditions.call(this, page)) {return false;}
  236.     if (page._switchs == null) {return true;}
  237.     for (i = 0; i < page._switchs.length; i += 1) {
  238.         if (!$gameSwitches.value(page._switchs[i])) {
  239.             return false;
  240.         }
  241.     }
  242.     for (i = 0; i < page._selfswitchs.length; i += 1) {
  243.         var key = [this._mapId, this._eventId, page._selfswitchs[i]];
  244.         if ($gameSelfSwitches.value(key) !== true) {
  245.             return false;
  246.         }
  247.     }
  248.     for (i = 0; i < page._mapswitchs.length; i += 1) {
  249.         var key = [this._mapId, 0, page._mapswitchs[i]];
  250.         if ($gameSelfSwitches.value(key) !== true) {
  251.             return false;
  252.         }
  253.     }
  254.     for (i = 0; i < page._vars.length; i += 1) {
  255.         if ($gameVariables.value(page._vars[i][0]) < page._vars[i][1]) {
  256.             return false;
  257.         }
  258.     }
  259.     for (i = 0; i < page._varslow.length; i += 1) {
  260.         if ($gameVariables.value(page._varslow[i][0]) >= page._varslow[i][1]) {
  261.             return false;
  262.         }
  263.     }
  264.     for (i = 0; i < page._varseq.length; i += 1) {
  265.         if ($gameVariables.value(page._varseq[i][0]) != page._varseq[i][1]) {
  266.             return false;
  267.         }
  268.     }
  269.  
  270.     return true;
  271. };
  272.  
  273. //=============================================================================
  274. // End of File
  275. //=============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement