Advertisement
ICF-Soft

ICF-Soft Event Expansion v1.01 RPG Maker MV

Feb 19th, 2016
98
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.01 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.  * Lunatic Mode
  54.  * ============================================================================
  55.  *
  56.  * You can use special conditions to a page by using javascript.
  57.  * There are inside a comment or note like others conditions and if you use more
  58.  * than one all will be merged.
  59.  *
  60.  * Actually it only works for first line. It will be solved in a later version.
  61.  *
  62.  * customreq: code
  63.  *
  64.  *  result - this is where result is stored. By default is false.
  65.  *
  66.  * ============================================================================
  67.  * Plugin commands
  68.  * ============================================================================
  69.  *
  70.  * selfswitch x true/false
  71.  * mapswitch x true/false
  72.  *
  73.  *  - Turns on/off specified selfswitch or mapswitch.
  74.  *
  75.  * ============================================================================
  76.  * Incompatibilities
  77.  * ============================================================================
  78.  *
  79.  * There's no known incompatible plugins yet.
  80.  *
  81.  * ============================================================================
  82.  * Known isues
  83.  * ============================================================================
  84.  *
  85.  * Not yet.
  86.  *
  87.  * Plugins that allow to have more than 999 maps without increasing map ids
  88.  * can cause glitches between maps that shares selfswitches and mapswitches.
  89.  *
  90.  * ============================================================================
  91.  * Changelog
  92.  * ============================================================================
  93.  *
  94.  * Version 1.01:
  95.  * - Added lunatic mode.
  96.  *
  97.  * Version 1.00:
  98.  * - Finished plugin!
  99.  *
  100.  * ============================================================================
  101.  *
  102.  * Commercial use avaiable.
  103.  * Credit to ICF-Soft.
  104.  * This entire header must be included with plugin.
  105.  *
  106.  * ============================================================================
  107. */
  108. //=============================================================================
  109.  /*:es
  110.  * @plugindesc v1.01 Este complemento permite más condiciones en los
  111.  * eventos.
  112.  * @author ICF-Soft [http://icfsoft.blogspot.com.es/]
  113.  *
  114.  * @help
  115.  * ============================================================================
  116.  * Introducción
  117.  * ============================================================================
  118.  *
  119.  * Las páginas de los eventos tienen un número limitado de condiciones, son
  120.  * útiles pero a veces no son suficientes.
  121.  * Las variables por defecto no son muy versátiles pues sólo tienen la opción
  122.  * de "igual o mayor".
  123.  *
  124.  * Con este complemento puedes añadir condiciones extra tales como más
  125.  * interruptores, autointerruptores ilimitados, interruptores de mapa ilimitados
  126.  * y variables más versátiles.
  127.  *
  128.  * Los nuevos interruptores de mapa son unos interruptores especiales similares
  129.  * a los automáticos, que afectan a todos los eventos del mapa.
  130.  *
  131.  * Las variables ahora permiten las opciones "igual o mayor", "menor que" e
  132.  * "igual que".
  133.  *
  134.  * ============================================================================
  135.  * Uso
  136.  * ============================================================================
  137.  *
  138.  * Para añadir una condición extra en una página simplemente añadir una nota
  139.  * en el mismo formato que un comando de complemento:
  140.  *
  141.  * switch x
  142.  * selfswitch x
  143.  * mapswitch x
  144.  *
  145.  *  - Para añadir interruptor, autointerruptor e interruptor de mapa.
  146.  *
  147.  * variable x value
  148.  * variableless x value
  149.  * variableequal x value
  150.  *
  151.  *  - Para añadir condición de variable. Tipos: mínimo, menos e igual.
  152.  *
  153.  * ============================================================================
  154.  * Lunatic Mode
  155.  * ============================================================================
  156.  *
  157.  * Puedes usar condiciones especiales en una página mediante javascript.
  158.  * Se pone el código en una nota del mismo modo que las demás condiciones.
  159.  * Si usas más de una se juntarán todas.
  160.  *
  161.  * Actualmente Sólo funciona con la primera linea. Se arreglará en una próxima
  162.  * versión.
  163.  *
  164.  * customreq: código
  165.  *
  166.  *  result - aquí se almacena el resultado. Por defecto está desactivado.
  167.  *
  168.  * ============================================================================
  169.  * Comandos de complemento
  170.  * ============================================================================
  171.  *
  172.  * selfswitch x true/false
  173.  * mapswitch x true/false
  174.  *
  175.  *  - Activa o desactiva el autointerruptor o interruptor de mapa.
  176.  *
  177.  * ============================================================================
  178.  * Incompatibilidades
  179.  * ============================================================================
  180.  *
  181.  * No se conocen complementos que sean incompatibles hasta la fecha.
  182.  *
  183.  * ============================================================================
  184.  * Problemas conocidos
  185.  * ============================================================================
  186.  *
  187.  * Por el momento ninguno.
  188.  *
  189.  * El uso de complementos que permiten usar más de 999 mapas que no incrementan
  190.  * las id's puede ocasionar bugs entre mapas que compartan interruptores
  191.  * especiales.
  192.  *
  193.  * ============================================================================
  194.  * Historial de versiones
  195.  * ============================================================================
  196.  *
  197.  * Version 1.01:
  198.  * - Se ha añadido el modo lunático.
  199.  *
  200.  * Version 1.00:
  201.  * - Complemento terminado.
  202.  *
  203.  * ============================================================================
  204.  *
  205.  * Se permite el uso comercial.
  206.  * Se debe incluir a ICF-Soft en los créditos.
  207.  * Esta cabecera debe incluirse íntegramente con el plugin.
  208.  *
  209.  * ============================================================================
  210. */
  211. //=============================================================================
  212.  
  213. //=============================================================================
  214. // Event Utilities
  215. //=============================================================================
  216.  
  217. ICF.Events.CustomSwitch = function(mapid, evid, switchname, value) {
  218.     var _key = [mapid, evid, switchname];
  219.     var _value = (value.toLowerCase() === "true");
  220.     $gameSelfSwitches.setValue(_key, _value);
  221. }
  222.  
  223. ICF.Events.CustomCondition = function(page, content) {
  224.     var args = content.split(" ");
  225.     if (args[0] !== null && args[1] !== null) {
  226.         if (args[0].toLowerCase() == "switch") {
  227.             page._switchs.push(args[1]);
  228.         } else if (args[0].toLowerCase() == "selfswitch") {
  229.             page._selfswitchs.push(args[1]);
  230.         } else if (args[0].toLowerCase() == "mapswitch") {
  231.             page._mapswitchs.push(args[1]);
  232.         } else if (args[0].toLowerCase() == "variable" && args[2] !== null) {
  233.             page._vars.push([args[1], args[2]]);
  234.         } else if (args[0].toLowerCase() == "variableless" && args[2] !== null) {
  235.             page._varslow.push([args[1], args[2]]);
  236.         } else if (args[0].toLowerCase() == "variableequal" && args[2] !== null) {
  237.             page._varseq.push([args[1], args[2]]);
  238.         } else if (args[0].toLowerCase() == "customreq:") {
  239.             page._customreq = page._customreq + content.substring(10) + " ";
  240.         }
  241.     }
  242. }
  243.  
  244. //=============================================================================
  245. // Game_Interpreter
  246. //=============================================================================
  247.  
  248. ICF.Events.pluginCommand = Game_Interpreter.prototype.pluginCommand;
  249. Game_Interpreter.prototype.pluginCommand = function(command, args) {
  250.         ICF.Events.pluginCommand.call(this, command, args);
  251.     if (command === 'selfswitch') {
  252.         ICF.Events.CustomSwitch(this._mapId, this._eventId, args[0], args[1]);
  253.     } else if (command === 'mapswitch') {
  254.         ICF.Events.CustomSwitch(this._mapId, 0, args[0], args[1]);
  255.     }
  256. };
  257.  
  258. //=============================================================================
  259. // Game_Event
  260. //=============================================================================
  261.  
  262. ICF.Events.init = Game_Event.prototype.initialize;
  263. Game_Event.prototype.initialize = function(mapId, eventId) {
  264.     ICF.Events.init.call(this, mapId, eventId);
  265.     var pages = this.event().pages;
  266.     for (i = 0; i < pages.length; i += 1) {
  267.         var page = pages[i];
  268.         page._switchs = [];
  269.         page._selfswitchs = [];
  270.         page._mapswitchs = [];
  271.         page._vars = [];
  272.         page._varslow = [];
  273.         page._varseq = [];
  274.         page._customreq = "";
  275.         for (j = 0; j < page.list.length; j += 1) {
  276.             var command = page.list[j];
  277.             if (command.code === 408 || command.code === 108) {
  278.                 ICF.Events.CustomCondition(page, command.parameters[0]);
  279.             }
  280.         }
  281.     }
  282.     this.refresh();
  283. };
  284.  
  285. ICF.Events.meetsConditions = Game_Event.prototype.meetsConditions;
  286. Game_Event.prototype.meetsConditions = function(page) {
  287.     if (!ICF.Events.meetsConditions.call(this, page)) {return false;}
  288.     if (page._switchs == null) {return true;}
  289.     for (i = 0; i < page._switchs.length; i += 1) {
  290.         if (!$gameSwitches.value(page._switchs[i])) {
  291.             return false;
  292.         }
  293.     }
  294.     for (i = 0; i < page._selfswitchs.length; i += 1) {
  295.         var key = [this._mapId, this._eventId, page._selfswitchs[i]];
  296.         if ($gameSelfSwitches.value(key) !== true) {
  297.             return false;
  298.         }
  299.     }
  300.     for (i = 0; i < page._mapswitchs.length; i += 1) {
  301.         var key = [this._mapId, 0, page._mapswitchs[i]];
  302.         if ($gameSelfSwitches.value(key) !== true) {
  303.             return false;
  304.         }
  305.     }
  306.     for (i = 0; i < page._vars.length; i += 1) {
  307.         if ($gameVariables.value(page._vars[i][0]) < page._vars[i][1]) {
  308.             return false;
  309.         }
  310.     }
  311.     for (i = 0; i < page._varslow.length; i += 1) {
  312.         if ($gameVariables.value(page._varslow[i][0]) >= page._varslow[i][1]) {
  313.             return false;
  314.         }
  315.     }
  316.     for (i = 0; i < page._varseq.length; i += 1) {
  317.         if ($gameVariables.value(page._varseq[i][0]) != page._varseq[i][1]) {
  318.             return false;
  319.         }
  320.     }
  321.  
  322.     if (page._customreq.length != "") {
  323.         var result = false;
  324.         eval(page._customreq);
  325.         return result;
  326.     }
  327.  
  328.     return true;
  329. };
  330.  
  331. //=============================================================================
  332. // End of File
  333. //=============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement