48x48 tilesets //============================================================================= // Change Tile Size // by Shaz // version 1.2 // Last Update: 2017.04.12 //============================================================================= /*: * @plugindesc Allows maps based on a grid size other than 48x48 v1.1 * @author Shaz 48x48 tilesets How to use it? 48x48 tilesets * * @param Tile Size * @desc Size of tiles (pixels) * @default 48 * * @param Tileset Image Folder * @desc Folder where the in-game tilesets are kept * @default img/tilesets/ * * @param Parallax Image Folder 48x48 tilesets How to use it? 48x48 tilesets * @desc Folder where the in-game parallaxes are kept * @default img/parallaxes/ * * @help This plugin does not provide plugin commands. * * To use the map editor with tiles of a size other than 48x48 in your project, * have two folders for tileset images. The folder named in the plugin * parameters is for original, high-quality, final-sized tiles. The * original folder, img/tilesets/ can contain a duplicate copy of each * tileset, shrunk or enlarged to 48x48 pixels per tile. Quality in the 48x48 tilesets PasteShr 48x48 tilesets * editor may be poorer, but the original tiles will be used in the game. * The img/tilesets folder can be cleared prior to distribution. * * The same applies to the img/parallaxes folder if using a parallax map * with a grid size other than 48x48. * * ---------------------------------------------------------------------------- * Revisions * * 1.1 2016.10.17 Catered for Tilemap tilesize to reduce choppiness 48x48 tilesets PasteShr 48x48 tilesets * Removed dependency on js file name * 2016.10.23 Ensure resized tiles/parallaxes are included in build * 1.2 2017.04.12 Fix issue with excluding unused resources * ---------------------------------------------------------------------------- RESOURCE LIST - DO NOT MODIFY BELOW THIS LINE RESOURCE LIST - DO NOT MODIFY ABOVE THIS LINE */ (function() { 48x48 tilesets PasteShr 48x48 tilesets var parameters = $plugins.filter(function(p) { return p.description.contains(''); })[0].parameters; var tileSize = parseInt(parameters['Tile Size'] || 48); var tilesetsFolder = String(parameters['Tileset Image Folder'] || 'img/tilesets/'); var parallaxesFolder = String(parameters['Parallax Image Folder'] || 'img/parallaxes/'); ImageManager.loadTileset = function(filename, hue) { return this.loadBitmap(tilesetsFolder, filename, hue, false); }; ImageManager.loadParallax = function(filename, hue) { 48x48 tilesets PasteShr 48x48 tilesets return this.loadBitmap(parallaxesFolder, filename, hue, true); }; Game_Map.prototype.tileWidth = function() { return tileSize; }; Game_Map.prototype.tileHeight = function() { return tileSize; }; 48x48 tilesets How to use it? 48x48 tilesets Game_Vehicle.prototype.maxAltitude = function() { return tileSize; }; var Tilemap_initialize = Tilemap.prototype.initialize; Tilemap.prototype.initialize = function() { Tilemap_initialize.call(this); this._tileWidth = tileSize; this._tileHeight = tileSize; 48x48 tilesets PasteShr 48x48 tilesets }; // Add image files to required assets list, to ensure they are included // in a deployed project var _changeTileSize_Scene_Boot_start = Scene_Boot.prototype.start; Scene_Boot.prototype.start = function() { _changeTileSize_Scene_Boot_start.call(this); if (!Utils.isOptionValid('test') || DataManager.isBattleTest() || DataManager.isEventTest()) { 48x48 tilesets How to dowload it? 48x48 tilesets return; } // Read in this script var fs = require('fs'); var path = window.location.pathname.replace(/(\/www|)\/[^\/]*$/, '/'); if (path.match(/^\/([A-Z]\:)/)) { path = path.slice(1); } path = decodeURIComponent(path); 48x48 tilesets How to use it? 48x48 tilesets var scriptName = $plugins.filter(function(p) { return p.description.contains('') && p.status; })[0].name + '.js'; var sourcePath = path + 'js/plugins/' + scriptName; var dataPath = path + 'data/'; if (fs.existsSync(sourcePath)) { var source = fs.readFileSync(sourcePath, { encoding: 'utf8' }); source = source.split('\r\n'); var resListStart = source.indexOf('RESOURCE LIST - DO NOT MODIFY BELOW THIS LINE'); var resListEnd = source.indexOf('RESOURCE LIST - DO NOT MODIFY ABOVE THIS LINE'); 48x48 tilesets How to use it? 48x48 tilesets if (resListStart === -1 || resListEnd === -1) { console.log('ERROR - Unable to create resource list for ' + scriptName); console.log('Please redownload the script and paste over your current version'); } else { // remove previous list of resources source.splice(resListStart + 1, resListEnd - resListStart - 1); // build list of new resources var resTilesets = []; var resParallaxes = []; 48x48 tilesets How to dowload it? 48x48 tilesets // get tilesets & parallaxes that are actually used $dataMapInfos.forEach(function(mapinfo) { if (mapinfo) { var map = JSON.parse(fs.readFileSync(dataPath + 'Map%1.json'.format(mapinfo.id.padZero(3)))); if (!resTilesets.contains(map.tilesetId)) { resTilesets.push(map.tilesetId); } if (map.parallaxName !== '' && !resParallaxes.contains(map.parallaxName)) { 48x48 tilesets How to get it for free? 48x48 tilesets resParallaxes.push(map.parallaxName); } // map events map.events.forEach(function (event) { if (event) { event.pages.forEach(function (page) { if (page) { getResources(page.list, resTilesets, resParallaxes); } 48x48 tilesets How to get it? 48x48 tilesets }) } }) } }); // common events $dataCommonEvents.forEach(function(commonEvent) { if (commonEvent) { getResources(commonEvent.list, resTilesets, resParallaxes); 48x48 tilesets How to dowload it? 48x48 tilesets } }); // troop events $dataTroops.forEach(function (troop) { if (troop) { troop.pages.forEach(function (page) { if (page) { getResources(page.list, resTilesets, resParallaxes); } 48x48 tilesets How to get it? 48x48 tilesets }) } }) // add resource list to script var inspos = resListStart + 1; resTilesetNames = []; resTilesets.forEach(function(tilesetId) { var tileset = $dataTilesets[tilesetId]; 48x48 tilesets How to get it for free? 48x48 tilesets if (tileset) { tileset.tilesetNames.forEach(function(tilesetName) { if (tilesetName !== '' && !resTilesetNames.contains(tilesetName)) { resTilesetNames.push(tilesetName); } }) } }); var tag = ' * @requiredAssets'; 48x48 tilesets How to get it for free? 48x48 tilesets source.splice(inspos, 0, tag); resTilesetNames.forEach(function(tilesetName) { tag = ' * @requiredAssets ' + tilesetsFolder + tilesetName; source.splice(inspos, 0, tag); }); resParallaxes.forEach(function(parallaxName) { tag = ' * @requiredAssets ' + parallaxesFolder + parallaxName; source.splice(inspos, 0, tag); 48x48 tilesets How to dowload it? 48x48 tilesets }); // and save the file source = source.join('\r\n'); fs.writeFileSync(sourcePath, source, { encoding: 'utf8' }); } } }; getResources = function(list, aryTilesets, aryParallaxes) { 48x48 tilesets How to dowload it? 48x48 tilesets list.filter(function (cmd) { return cmd.code === 282 || cmd.code === 284; }).forEach(function(cmd) { if (cmd.code === 282 && !aryTilesets.contains(cmd.parameters[0])) { aryTilesets.push(cmd.parameters[0]); } if (cmd.code === 284 && !aryParallaxes.contains(cmd.parameters[0])) { aryParallaxes.push(cmd.parameters[0]); } }); 48x48 tilesets How to get it for free? 48x48 tilesets }; })(); 48x48 tilesets