Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //=============================================================================
- // RPG Maker MZ - Moar maps
- // Last Updated: 2020.08.26
- //=============================================================================
- // Copyright 2020 Zeriab
- //
- // This software is provided 'as-is', without any express or implied
- // warranty. In no event will the authors be held liable for any damages
- // arising from the use of this software.
- //
- // Permission is granted to anyone to use this software for any purpose,
- // including commercial applications, and to alter it and redistribute it
- // freely, subject to the following restrictions:
- //
- // 1. The origin of this software must not be misrepresented; you must not
- // claim that you wrote the original software. If you use this software
- // in a product, an acknowledgement in the product documentation would be
- // appreciated but is not required.
- // 2. Altered source versions must be plainly marked as such, and must not be
- // misrepresented as being the original software.
- // 3. This notice may not be removed or altered from any source distribution.
- //=============================================================================
- /*:
- * @target MZ
- * @plugindesc Allows using more than 2000 maps
- * @author Zeriab
- *
- * @help Zeriab_MoarMaps.js
- *
- * When 2000 maps is not enough. When you NEED MOAR MAPS!
- *
- * This plugin provides plugin commands transfering between subfolder of maps.
- * Each can have up to 2000 maps. No map limit is imposed.
- *
- * When you have hundreds of thousands of maps they do take up alot of harddrive
- * space. Fear not. This plugin together with my Zeriab_MoarMapsHelper plugin
- * allows you compress maps in all your subfolders.
- *
- * @param IsCompressed
- * @text Use compressed maps
- * @desc You can use Zeriab_MoarMapsHelper to compress your maps so they take up less space
- * @default false
- * @type boolean
- *
- * @param CompressedFolder
- * @type string
- * @default pak
- * @text Folder in 'data' that contains the compressed maps
- * @desc Please ensure this folder is the same as the one specified in the Zeriab_MoarMapsHelper plugin
- *
- *
- * @command transfer
- * @text Transfer to a subfolder
- * @desc Mimics the transfer event command with the option of changing the subfolder
- *
- * @arg subfolder
- * @type string
- * @default church
- * @text Subfolder
- * @desc Use maps from the specific subfolder. For example "church" and transfer to Map 3 leads to data/church/Map003.json
- *
- * @arg mapId
- * @text Map ID
- * @type number
- * @min 1
- * @max 2000
- * @default 1
- *
- * @arg x
- * @text X
- * @type number
- * @min 1
- * @max 256
- * @default 8
- *
- * @arg y
- * @text Y
- * @type number
- * @min 1
- * @max 256
- * @default 6
- *
- * @arg direction
- * @text Direction
- * @type select
- * @default 0
- * @option Retain
- * @value 0
- * @option Down
- * @value 2
- * @option Left
- * @value 4
- * @option Right
- * @value 6
- * @option Up
- * @value 8
- *
- * @arg fade
- * @text Fade
- * @type select
- * @default 0
- * @option Black
- * @value 0
- * @option White
- * @value 1
- * @option None
- * @value 2
- *
- *
- * @command transferMain
- * @text Transfer to the main folder
- * @desc Mimics the transfer event command
- * Use this when you need to transfer from a subfolder back to the main folder
- *
- * @arg mapId
- * @text Map ID
- * @type number
- * @min 1
- * @max 2000
- * @default 1
- *
- * @arg x
- * @text X
- * @type number
- * @min 1
- * @max 256
- * @default 8
- *
- * @arg y
- * @text Y
- * @type number
- * @min 1
- * @max 256
- * @default 6
- *
- * @arg direction
- * @text Direction
- * @type select
- * @default 0
- * @option Retain
- * @value 0
- * @option Down
- * @value 2
- * @option Left
- * @value 4
- * @option Right
- * @value 6
- * @option Up
- * @value 8
- *
- * @arg fade
- * @text Fade
- * @type select
- * @default 0
- * @option Black
- * @value 0
- * @option White
- * @value 1
- * @option None
- * @value 2
- */
- (() => {
- 'use strict';
- const pluginName = "Zeriab_MoarMaps";
- const parameters = PluginManager.parameters(pluginName);
- const isCompressed = eval(parameters.IsCompressed || 'false');
- const compressedFolder = parameters.CompressedFolder;
- PluginManager.registerCommand(pluginName, "transfer", args => {
- const subfolder = args.subfolder.toLowerCase();
- const mapId = Number(args.mapId);
- const x = Number(args.x);
- const y = Number(args.y);
- const direction = Number(args.direction);
- const fade = Number(args.fade);
- $gameSystem.setMapsFolder(subfolder);
- $gamePlayer.reserveTransfer(mapId, x, y, direction, fade);
- });
- PluginManager.registerCommand(pluginName, "transferMain", args => {
- const mapId = Number(args.mapId);
- const x = Number(args.x);
- const y = Number(args.y);
- const direction = Number(args.direction);
- const fade = Number(args.fade);
- $gameSystem.clearMapsFolder();
- $gamePlayer.reserveTransfer(mapId, x, y, direction, fade);
- });
- // Store the subfolder information in $gameSystem so it gets included in the saves
- Game_System.prototype.setMapsFolder = function(subfolder) {
- if (this._MapSubFolder !== subfolder)
- {
- this._MapSubFolder = subfolder;
- this._MapFolderChange = true;
- $gamePlayer.requestMapReload();
- }
- };
- // Default folder is the top level 'data' folder
- Game_System.prototype.clearMapsFolder = function() {
- this.setMapsFolder('');
- };
- const _DataManager_loadMapData = DataManager.loadMapData
- DataManager.loadMapData = function(mapId) {
- // Old saves without any subfolder information is considered to use the default folder
- const subfolder = $gameSystem._MapSubFolder || '';
- if (subfolder && subfolder.length >= 1)
- {
- if (mapId > 0) {
- var filename = DataManager.makeMapName(subfolder, mapId);
- if (isCompressed) {
- this.loadDataZipFile('$dataMap', filename);
- } else {
- this.loadDataFile('$dataMap', filename)
- }
- } else {
- this.makeEmptyMap();
- }
- }
- else
- {
- _DataManager_loadMapData.apply(this, arguments);
- }
- };
- DataManager.makeMapName = function(subfolder, mapId, compressed) {
- var filename = 'Map%1.json'.format(mapId.padZero(3));
- if (subfolder && subfolder.length >= 1)
- {
- if (isCompressed) {
- filename = '%3/%1/%2.pak'.format(subfolder, filename, compressedFolder);
- } else {
- filename = '%1/%2'.format(subfolder, filename);
- }
- }
- return filename;
- };
- DataManager.loadDataZipFile = function(name, src) {
- const xhr = new XMLHttpRequest();
- const url = "data/" + src;
- window[name] = null;
- xhr.open("GET", url);
- xhr.onload = () => this.onXhrZipLoad(xhr, name, src, url);
- xhr.onerror = () => this.onXhrError(name, src, url);
- xhr.send();
- };
- DataManager.onXhrZipLoad = function(xhr, name, src, url) {
- if (xhr.status < 400) {
- const zip = xhr.responseText;
- StorageManager
- .zipToJson(zip)
- .then(json =>
- StorageManager.jsonToObject(json)
- .then(map => {
- window[name] = map;
- this.onLoad(window[name]);
- })
- );
- } else {
- this.onXhrError(name, src, url);
- }
- };
- })();
Add Comment
Please, Sign In to add comment