Advertisement
ICF-Soft

ICF-Soft Map Extension RPG Maker MV

May 6th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // ICF-Soft Plugins - Map Extension
  3. // ICFSoft_MapExtension.js
  4. //=============================================================================
  5.  
  6. var Imported = Imported || {};
  7. Imported.ICFSoft_MapExtension = true;
  8.  
  9. var ICF = ICF || {};
  10. ICF.MapExtension = ICF.MapExtension || {};
  11.  
  12. //=============================================================================
  13.  /*:
  14.  * @plugindesc v1.00b This plugin allow to use more than 999 maps.
  15.  * @author ICF-Soft [http://icfsoft.blogspot.com.es/]
  16.  *
  17.  * @param Current Map Index
  18.  * @desc Current index using.
  19.  * @default 0
  20.  *
  21.  * @param Map Index Count
  22.  * @desc How many indexes are.
  23.  * @default 1
  24.  *
  25.  * @param Custom start map
  26.  * @desc To start in a specified location.
  27.  * mapId x y
  28.  * @default 0
  29.  *
  30.  * @param Custom boat position
  31.  * @desc Custom starting position for boat.
  32.  * mapId x y
  33.  * @default 0
  34.  *
  35.  * @param Custom ship position
  36.  * @desc Custom starting position for ship.
  37.  * mapId x y
  38.  * @default 0
  39.  *
  40.  * @param Custom airship position
  41.  * @desc Custom starting position for airship.
  42.  * mapId x y
  43.  * @default 0
  44.  *
  45.  * @help
  46.  * ============================================================================
  47.  * Introduction
  48.  *
  49.  * By default RPG Maker MV has a 999 map limit and cannot be added or use
  50.  * more.
  51.  *
  52.  * This plugin uses a system to allow more than 999 maps by grouping
  53.  * inside folders.
  54.  *
  55.  * ============================================================================
  56.  * How to use
  57.  * ============================================================================
  58.  *
  59.  * Inside data folder you create folders named '000', '001', '002' and so
  60.  * on. These correspond to indexes.
  61.  *
  62.  * When first 999 maps are filled copy all of them and map infos to '000'
  63.  * folder and update current index. Proccess is intuitive for every folder.
  64.  * You can edit only last index.
  65.  * You would usually close and open project while doing this.
  66.  *
  67.  * Maps nº 0, 1000, 2000 and so on are not used by RPG Maker, so are
  68.  * skipped.
  69.  *
  70.  * To edit maps from other index you should place current maps to its group
  71.  * and place maps from index to main data folder.
  72.  *
  73.  * CAREFULL:
  74.  * If you know what are you doing and you will not confuse maps you can
  75.  * move only the map you are going to edit to save time.
  76.  * Doing this wrong can make you lose maps.
  77.  *
  78.  * ============================================================================
  79.  * Plugin commands
  80.  * ============================================================================
  81.  *
  82.  * Without plugin commands you can only reffer to maps from 1 to 999.
  83.  *
  84.  * maptransfer mapid x y [down|left|right|up]
  85.  *
  86.  *  - Transfer player to a specified location.
  87.  *
  88.  * maptransferv var var var [down|left|right|up]
  89.  *
  90.  *  - Transfer player to a specified location given by game variables.
  91.  *
  92.  * setvehiclelocation mapid x y [boat|ship|airship]
  93.  *
  94.  *  - Set vehicle location to a specified spot.
  95.  *
  96.  * setvehiclelocationv var var var [boat|ship|airship]
  97.  *
  98.  *  - Set vehicle location to a specified spot given by game variables.
  99.  *
  100.  * ============================================================================
  101.  * Parameters
  102.  * ============================================================================
  103.  *
  104.  * Current Map Index: This is the current index you are using.
  105.  * When player goes to a map in this index map will be loaded from main
  106.  * data folder, else will be loaded from the right one.
  107.  *
  108.  * Map Index Count: How many indexes are been using.
  109.  * It's needed for map infos files.
  110.  *
  111.  * Custom start map / [boat ship airship] positions:
  112.  * Custom starting positions for starting map and vehicles.
  113.  * They need mapId and x y to work, else will be ignored.
  114.  *
  115.  * ============================================================================
  116.  * Incompatibilities
  117.  * ============================================================================
  118.  *
  119.  * There's no known incompatible plugins yet.
  120.  *
  121.  * ============================================================================
  122.  * Known isues
  123.  * ============================================================================
  124.  *
  125.  * Not yet.
  126.  *
  127.  * ============================================================================
  128.  *
  129.  * For commercial and non-commercial games.
  130.  * Credit to ICF-Soft.
  131.  * This entire header must be included with plugin.
  132.  *
  133.  * ============================================================================
  134. */
  135. //=============================================================================
  136.  /*:es
  137.  * @plugindesc v1.00b Este plugin permite sobrepasar el límite de 999 mapas.
  138.  * @author ICF-Soft [http://icfsoft.blogspot.com.es/]
  139.  *
  140.  * @param Current Map Index
  141.  * @desc El índice actual de mapas.
  142.  * @default 0
  143.  *
  144.  * @param Map Index Count
  145.  * @desc El número de índices existentes.
  146.  * @default 1
  147.  *
  148.  * @param Custom start map
  149.  * @desc Posición inicial del jugador personalizada.
  150.  * mapId x y
  151.  * @default 0
  152.  *
  153.  * @param Custom boat position
  154.  * @desc Posición inicial del vehículo personalizada.
  155.  * mapId x y
  156.  * @default 0
  157.  *
  158.  * @param Custom ship position
  159.  * @desc Posición inicial del vehículo personalizada.
  160.  * mapId x y
  161.  * @default 0
  162.  *
  163.  * @param Custom airship position
  164.  * @desc Posición inicial del vehículo personalizada.
  165.  * mapId x y
  166.  * @default 0
  167.  *
  168.  * @help
  169.  * ============================================================================
  170.  * Introducción
  171.  * ============================================================================
  172.  *
  173.  * De manera predeterminada RPG Maker MV tiene un límite de 999 mapas
  174.  * y no se pueden añadir o usar más.
  175.  *
  176.  * Este complemento usa un sistema que permite el uso de más de 999 mapas
  177.  * agrupándolos en carpetas.
  178.  *
  179.  * ============================================================================
  180.  * Uso
  181.  * ============================================================================
  182.  *
  183.  * Dentro de la carpeta 'data' creas otras llamadas '000', '001', '002'
  184.  * y así sucesivamente las que necesites. Corresponden a los índices.
  185.  *
  186.  * Al terminar los primeros 999 mapas los colocas en la carpeta '000'
  187.  * junto a mapinfos y actualizas el índice. El proceso se repite para
  188.  * cada nuevo índice. Solo puedes editar los mapas del índice actual.
  189.  * Cada vez hay que cerrar y abrir el proyecto.
  190.  *
  191.  * Los mapas nº 0, 1000, 2000 no son utilizados por RPG Maker, así que
  192.  * se saltan.
  193.  *
  194.  * Para editar mapas de otro índice tienes que poner los mapas actuales
  195.  * en su carpeta correspondiente y poner los mapas del índice en 'data'.
  196.  *
  197.  * PRECAUCIÓN:
  198.  * Si sabes lo que haces y no vas a confundir mapas puedes mover solo
  199.  * el mapa que vas a editar para ahorrar tiempo.
  200.  * Hacerlo mal puede resultar en la pérdida de mapas.
  201.  *
  202.  * ============================================================================
  203.  * Comandos de complemento
  204.  * ============================================================================
  205.  *
  206.  * Sin estos comandos solo puedes referirte a los mapas del 1 al 999.
  207.  *
  208.  * maptransfer mapid x y [down|left|right|up]
  209.  *
  210.  *  - Transfiere al jugador a una posición específica.
  211.  *
  212.  * maptransferv var var var [down|left|right|up]
  213.  *
  214.  *  - Transfiere al jugador a una posición almacenada en variables.
  215.  *
  216.  * setvehiclelocation mapid x y [boat|ship|airship]
  217.  *
  218.  *  - Coloca el vehículo en una posición específica.
  219.  *
  220.  * setvehiclelocationv var var var [boat|ship|airship]
  221.  *
  222.  *  - Coloca el vehículo en una posición almacenada en variables.
  223.  *
  224.  * ============================================================================
  225.  * Parámetros
  226.  * ============================================================================
  227.  *
  228.  * Current Map Index: Este es el índice actual en uso.
  229.  * Cuando el jugador es transferido a un mapa dentro del índice se cargará
  230.  * desde la carpeta 'data' principal, en caso contrario se cargará desde
  231.  * la carpeta correspondiente.
  232.  *
  233.  * Map Index Count: Cuantos índices se están utilizando.
  234.  * Es necesario para los archivos 'mapinfos.json'.
  235.  *
  236.  * Custom start map / [boat ship airship] positions:
  237.  * Posiciones personalizadas iniciales para el jugador y los vehículos.
  238.  * Permiten empezar en un mapa posterior al 999. Se configura con tres
  239.  * números separados por espacios para mapId, x e y.
  240.  * En caso contrario se usarán los predeterminados por el MV.
  241.  *
  242.  * ============================================================================
  243.  * Incompatibilidades
  244.  * ============================================================================
  245.  *
  246.  * No se conocen complementos que sean incompatibles hasta la fecha.
  247.  *
  248.  * ============================================================================
  249.  * Problemas conocidos
  250.  * ============================================================================
  251.  *
  252.  * Por el momento ninguno.
  253.  *
  254.  * ============================================================================
  255.  *
  256.  * Para juegos comerciales y no comerciales.
  257.  * Se debe incluir a ICF-Soft en los créditos.
  258.  * Esta cabecera debe incluirse íntegramente con el plugin.
  259.  *
  260.  * ============================================================================
  261. */
  262. //=============================================================================
  263.  
  264. //=============================================================================
  265. // Parameter Variables
  266. //=============================================================================
  267.  
  268. ICF.Parameters = PluginManager.parameters('ICFSoft_MapExtension');
  269. ICF.Param = ICF.Param || {};
  270.  
  271. ICF.Param.CurrentMapIndex = Number(ICF.Parameters['Current Map Index']);
  272. ICF.Param.MapIndexCount = Number(ICF.Parameters['Map Index Count']);
  273. ICF.Param.CustomStartMap = ICF.Parameters['Custom start map'].trim().split(/\s+/);
  274. if (ICF.Param.CustomStartMap.length < 3) ICF.Param.CustomStartMap = null;
  275.  
  276. ICF.Param.CustomVehiclePosition = [];
  277. ICF.Param.CustomVehiclePosition[0] = ICF.Parameters['Custom boat position'].trim().split(/\s+/);
  278. ICF.Param.CustomVehiclePosition[1] = ICF.Parameters['Custom ship position'].trim().split(/\s+/);
  279. ICF.Param.CustomVehiclePosition[2] = ICF.Parameters['Custom airship position'].trim().split(/\s+/);
  280.  
  281. if (ICF.Param.CustomVehiclePosition[0].length < 3) ICF.Param.CustomVehiclePosition[0] = null;
  282. if (ICF.Param.CustomVehiclePosition[1].length < 3) ICF.Param.CustomVehiclePosition[1] = null;
  283. if (ICF.Param.CustomVehiclePosition[2].length < 3) ICF.Param.CustomVehiclePosition[2] = null;
  284.  
  285. //=============================================================================
  286. // DataManager
  287. //=============================================================================
  288.  
  289. ICF.MapExtension.loadDatabase = DataManager.loadDatabase;
  290. DataManager.loadDatabase = function() {
  291.     ICF.MapExtension.loadDatabase.call(this);
  292.     var test = this.isBattleTest() || this.isEventTest();
  293.     if (!test) {
  294.     window.setTimeout(function () {
  295.         DataManager.loadingMapInfos();
  296.     },50);
  297.     }
  298. };
  299.  
  300. DataManager.loadingMapInfos = function() {
  301.     if ($dataMapInfos) {
  302.     var array = [];
  303.     array[ICF.Param.CurrentMapIndex] = $dataMapInfos;
  304.     $dataMapInfos = array;
  305.     for (var i = 0; i < ICF.Param.MapIndexCount; i++) {
  306.         if (i != ICF.Param.CurrentMapIndex) {
  307.             this.loadDataArrayFiles('$dataMapInfos', i, i.padZero(3) + '/MapInfos.json');
  308.         }
  309.     }
  310.     } else {
  311.     window.setTimeout(function () {
  312.         DataManager.loadingMapInfos();
  313.     },50);
  314.     }
  315. };
  316.  
  317. DataManager.loadMapData = function(mapId) {
  318.     if (mapId > 0) {
  319.         var baseId = mapId % 1000;
  320.     var index = Math.trunc(mapId / 1000);
  321.         var filename = 'Map%1.json'.format(baseId.padZero(3));
  322.     if (index != ICF.Param.CurrentMapIndex) filename = index.padZero(3) + '/' + filename;
  323.         this.loadDataFile('$dataMap', filename);
  324.     } else {
  325.         this.makeEmptyMap();
  326.     }
  327. };
  328.  
  329. ICF.MapExtension.setupNewGame = DataManager.setupNewGame;
  330. DataManager.setupNewGame = function() {
  331.     ICF.MapExtension.setupNewGame.call(this);
  332.     if (ICF.Param.CustomStartMap) $gamePlayer.reserveTransfer(ICF.Param.CustomStartMap[0],
  333.         ICF.Param.CustomStartMap[1], ICF.Param.CustomStartMap[2]);
  334.     else $gamePlayer.reserveTransfer($dataSystem.startMapId + ICF.Param.CurrentMapIndex * 1000,
  335.         $dataSystem.startX, $dataSystem.startY);
  336. };
  337.  
  338. //=============================================================================
  339. // Game_Map
  340. //=============================================================================
  341.  
  342. Game_Map.prototype.mapInfo = function() {
  343.     var baseId = this._mapId % 1000;
  344.     var index = Math.trunc(this._mapId / 1000);
  345.     return $dataMapInfos[index][baseId];
  346. };
  347.  
  348. //=============================================================================
  349. // Game_Vehicle
  350. //=============================================================================
  351.  
  352. ICF.MapExtension.vehicleInitPositions = Game_Vehicle.prototype.loadSystemSettings;
  353. Game_Vehicle.prototype.loadSystemSettings = function() {
  354.     ICF.MapExtension.vehicleInitPositions.call(this);
  355.     if (this.isBoat()) {
  356.     if (ICF.Param.CustomVehiclePosition[0]) {
  357.         this._mapId = ICF.Param.CustomVehiclePosition[0][0];
  358.         this.setPosition(ICF.Param.CustomVehiclePosition[0][1], ICF.Param.CustomVehiclePosition[0][2]);
  359.     }
  360.     } else if (this.isShip()) {
  361.     if (ICF.Param.CustomVehiclePosition[1]) {
  362.         this._mapId = ICF.Param.CustomVehiclePosition[1][0];
  363.         this.setPosition(ICF.Param.CustomVehiclePosition[1][1], ICF.Param.CustomVehiclePosition[1][2]);
  364.     }
  365.     } else if (this.isAirship()) {
  366.     if (ICF.Param.CustomVehiclePosition[2]) {
  367.         this._mapId = ICF.Param.CustomVehiclePosition[2][0];
  368.         this.setPosition(ICF.Param.CustomVehiclePosition[2][1], ICF.Param.CustomVehiclePosition[2][2]);
  369.     }
  370.     }
  371. };
  372.  
  373. //=============================================================================
  374. // Game_Interpreter
  375. //=============================================================================
  376.  
  377. ICF.MapExtension.pluginCommand = Game_Interpreter.prototype.pluginCommand;
  378. Game_Interpreter.prototype.pluginCommand = function(command, args) {
  379.         ICF.MapExtension.pluginCommand.call(this, command, args);
  380.     if (command.toLowerCase() === 'maptransfer') {
  381.         if (args.length < 3) return;
  382.         if (args.length == 3) {
  383.             args[3] = 0;
  384.         } else if (args.length >= 4) {
  385.             if (isNaN(Number(args[3]))) args[3] = (['down','left','right','up'].indexOf(args[3].toLowerCase()) + 1) * 2;
  386.             if ([2,4,6,8].indexOf(args[3]) < 0) args[3] = 0;
  387.         }
  388.         if (args.length >= 5) {
  389.             args[4] = ['fade'].indexOf(args[4]) + 1;
  390.         } else {
  391.             args[4] = 0;
  392.         }
  393.         $gamePlayer.reserveTransfer(args[0], args[1], args[2], args[3], args[4]);
  394.     } else if (command.toLowerCase() === 'maptransferv') {
  395.         if (args.length < 3) return;
  396.         args[0] = $gameVariables.value(args[0]);
  397.         args[1] = $gameVariables.value(args[1]);
  398.         args[2] = $gameVariables.value(args[2]);
  399.         if (args.length == 3) {
  400.             args[3] = 0;
  401.         } else if (args.length >= 4) {
  402.             if (isNaN(Number(args[3]))) args[3] = (['down','left','right','up'].indexOf(args[3].toLowerCase()) + 1) * 2;
  403.             if ([2,4,6,8].indexOf(args[3]) < 0) args[3] = 0;
  404.         }
  405.         if (args.length >= 5) {
  406.             args[4] = ['fade'].indexOf(args[4].toLowerCase()) + 1;
  407.         } else {
  408.             args[4] = 0;
  409.         }
  410.         $gamePlayer.reserveTransfer(args[0], args[1], args[2], args[3], args[4]);
  411.     } else if (command.toLowerCase() === 'setvehiclelocation') {
  412.         if (args.length < 4) return;
  413.         if (isNaN(Number(args[0]))) args[0] = ['boat','ship','airship'].indexOf(args[3].toLowerCase());
  414.         if (args[0] < 0) return;
  415.         var vehicle = $gameMap.vehicle(args[0]);
  416.         if (vehicle) {
  417.             vehicle.setLocation(args[1], args[2], args[3]);
  418.         }
  419.     } else if (command.toLowerCase() === 'setvehiclelocationv') {
  420.         if (args.length < 4) return;
  421.         args[1] = $gameVariables.value(args[1]);
  422.         args[2] = $gameVariables.value(args[2]);
  423.         args[3] = $gameVariables.value(args[3]);
  424.         if (isNaN(Number(args[0]))) args[0] = ['boat','ship','airship'].indexOf(args[3].toLowerCase());
  425.         if (args[0] < 0) return;
  426.         var vehicle = $gameMap.vehicle(args[0]);
  427.         if (vehicle) {
  428.             vehicle.setLocation(args[1], args[2], args[3]);
  429.         }
  430.     }
  431. };
  432.  
  433. //=============================================================================
  434. // End of File
  435. //=============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement