CityShrimp's Cover Tiles

cityshrimp

Villager
Member
Joined
Aug 17, 2013
Messages
16
Reaction score
19
First Language
English
Primarily Uses
N/A
CS_CoverTiles v1.0.2
CityShrimp
Introduction

Cover Tiles for RPG Maker MV. Based on Neon Black's Terrain Tags script for Ace VX. Allows setting specific tiles as "covers" where the tile is passable and also drawn above the character. Common use case is to allow events and characters to walk behind walls and roofs.

Free for commercial and non commercial use.

Features
  1. Create cover tiles that are passable and drawn above events.
  2. Create block tiles that are always impassable
Change Log
1.0.2

  • Fixed bug where Tiles B-E do not show up when a tile is marked as a cover tile
  • Added a "Pass" tile. Does not change the appearance of a tile, just allows players to pass through.

1.0.1
  • Fixed bug where cover tiles are not in right layer after loading game.
  • Added support for non-WebGl graphics (never tested!)
How to Use
  • Download CS_CoverTiles.js
  • Place it into your project's Plugin list
  • Check description in file for latest Parameter
Script:

Download v1.0.2

/*=============================================================================
* CityShrimp's Cover Tiles
* CS_CoverTiles.js
* Version: 1.0.2
* Free for commercial and non commercial use.
*=============================================================================*/

/*:
* @plugindesc This plugin provides a way to create "covers".
*
* @author CityShrimp
*
* ===Parameter List===
*
* @param Pass RegionID
* @desc This region ID will cause tile to become passable.
* @Default 18
*
* @param Cover RegionID
* @desc This region ID will cause tile to become a cover (passable + higher than events).
* @Default 19
*
* @param Block RegionID
* @desc This region ID will cause tile to become impassible.
* @Default 20
*
* @Help
* ============================================================================
* Latest Version
* ============================================================================
*
* Get the latest version of this script on
* https://github.com/cityshrimp/rmmv/blob/master/CS_CoverTiles.js
*
*=============================================================================
*/

var Imported = Imported || {};
Imported['CS_CoverTiles'] = "1.0.2";

var CS_CoverTiles = CS_CoverTiles || {};

(function($) {
"use strict";

// Load parameters
$.parameters = PluginManager.parameters("CS_CoverTiles") || {};
$._pass_region_id = Number($.parameters['Pass RegionId'] || 18);
$._cover_region_id = Number($.parameters['Cover RegionId'] || 19);
$._block_region_id = Number($.parameters['Block RegionId'] || 20);
$.tile_flag_set = {};

var old_Game_Map_checkPassage = Game_Map.prototype.checkPassage;
Game_Map.prototype.checkPassage = function(x, y, bit) {
var rid = this.regionId(x, y);
if (rid == $._block_region_id)
return false;
if (rid == $._pass_region_id || rid == $._cover_region_id)
return true;
return old_Game_Map_checkPassage.call(this, x, y, bit);
}

ShaderTilemap.prototype._paintTiles = function(startX, startY, x, y) {
var mx = startX + x;
var my = startY + y;
var dx = x * this._tileWidth, dy = y * this._tileHeight;
var tileId0 = this._readMapData(mx, my, 0);
var tileId1 = this._readMapData(mx, my, 1);
var tileId2 = this._readMapData(mx, my, 2);
var tileId3 = this._readMapData(mx, my, 3);
var shadowBits = this._readMapData(mx, my, 4);
var upperTileId1 = this._readMapData(mx, my - 1, 1);
var lowerLayer = this.lowerLayer.children[0];
var upperLayer = this.upperLayer.children[0];

var rtileId0 = (0 * $dataMap.height + my) * $dataMap.width + mx;
var rtileId1 = (1 * $dataMap.height + my) * $dataMap.width + mx;
var rtileId2 = (2 * $dataMap.height + my) * $dataMap.width + mx;
var rtileId3 = (3 * $dataMap.height + my) * $dataMap.width + mx;

if (this._isHigherTile(tileId0) || $gameMap.regionId(mx, my) == $._cover_region_id) {
this._drawTile(upperLayer, tileId0, dx, dy);
} else {
this._drawTile(lowerLayer, tileId0, dx, dy);
}
if (this._isHigherTile(tileId1) || $gameMap.regionId(mx, my) == $._cover_region_id) {
this._drawTile(upperLayer, tileId1, dx, dy);
} else {
this._drawTile(lowerLayer, tileId1, dx, dy);
}

this._drawShadow(lowerLayer, shadowBits, dx, dy);
if (this._isTableTile(upperTileId1) && !this._isTableTile(tileId1)) {
if (!Tilemap.isShadowingTile(tileId0)) {
this._drawTableEdge(lowerLayer, upperTileId1, dx, dy);
}
}

if (this._isOverpassPosition(mx, my)) {
this._drawTile(upperLayer, tileId2, dx, dy);
this._drawTile(upperLayer, tileId3, dx, dy);
} else {
if (this._isHigherTile(tileId2) || $gameMap.regionId(mx, my) == $._cover_region_id) {
this._drawTile(upperLayer, tileId2, dx, dy);
} else {
this._drawTile(lowerLayer, tileId2, dx, dy);
}

if (this._isHigherTile(tileId3) || $gameMap.regionId(mx, my) == $._cover_region_id) {
this._drawTile(upperLayer, tileId3, dx, dy);
} else {
this._drawTile(lowerLayer, tileId3, dx, dy);
}
}
};

Tilemap.prototype._paintTiles = function(startX, startY, x, y) {
var tableEdgeVirtualId = 10000;
var mx = startX + x;
var my = startY + y;
var dx = (mx * this._tileWidth).mod(this._layerWidth);
var dy = (my * this._tileHeight).mod(this._layerHeight);
var lx = dx / this._tileWidth;
var ly = dy / this._tileHeight;
var tileId0 = this._readMapData(mx, my, 0);
var tileId1 = this._readMapData(mx, my, 1);
var tileId2 = this._readMapData(mx, my, 2);
var tileId3 = this._readMapData(mx, my, 3);
var shadowBits = this._readMapData(mx, my, 4);
var upperTileId1 = this._readMapData(mx, my - 1, 1);
var lowerTiles = [];
var upperTiles = [];

if (this._isHigherTile(tileId0) || $gameMap.regionId(mx, my) == $._cover_region_id) {
upperTiles.push(tileId0);
} else {
lowerTiles.push(tileId0);
}
if (this._isHigherTile(tileId1) || $gameMap.regionId(mx, my) == $._cover_region_id) {
upperTiles.push(tileId1);
} else {
lowerTiles.push(tileId1);
}

lowerTiles.push(-shadowBits);

if (this._isTableTile(upperTileId1) && !this._isTableTile(tileId1)) {
if (!Tilemap.isShadowingTile(tileId0)) {
lowerTiles.push(tableEdgeVirtualId + upperTileId1);
}
}

if (this._isOverpassPosition(mx, my)) {
upperTiles.push(tileId2);
upperTiles.push(tileId3);
} else {
if (this._isHigherTile(tileId2) || $gameMap.regionId(mx, my) == $._cover_region_id) {
upperTiles.push(tileId2);
} else {
lowerTiles.push(tileId2);
}
if (this._isHigherTile(tileId3) || $gameMap.regionId(mx, my) == $._cover_region_id) {
upperTiles.push(tileId3);
} else {
lowerTiles.push(tileId3);
}
}

var lastLowerTiles = this._readLastTiles(0, lx, ly);
if (!lowerTiles.equals(lastLowerTiles) ||
(Tilemap.isTileA1(tileId0) && this._frameUpdated)) {
this._lowerBitmap.clearRect(dx, dy, this._tileWidth, this._tileHeight);
for (var i = 0; i < lowerTiles.length; i++) {
var lowerTileId = lowerTiles;
if (lowerTileId < 0) {
this._drawShadow(this._lowerBitmap, shadowBits, dx, dy);
} else if (lowerTileId >= tableEdgeVirtualId) {
this._drawTableEdge(this._lowerBitmap, upperTileId1, dx, dy);
} else {
this._drawTile(this._lowerBitmap, lowerTileId, dx, dy);
}
}
this._writeLastTiles(0, lx, ly, lowerTiles);
}

var lastUpperTiles = this._readLastTiles(1, lx, ly);
if (!upperTiles.equals(lastUpperTiles)) {
this._upperBitmap.clearRect(dx, dy, this._tileWidth, this._tileHeight);
for (var j = 0; j < upperTiles.length; j++) {
this._drawTile(this._upperBitmap, upperTiles[j], dx, dy);
}
this._writeLastTiles(1, lx, ly, upperTiles);
}
};

// ===End Alias Game_Map===
})(CS_CoverTiles);

Credits

  • CityShrimp
Notes and Limitations
  • Weird stuff happens when you using mouse and character tries to run off screen. This causes the x, y coordinates to screw up and the covers won't work properly anymore.
 
Last edited:

Kike

Paladin
Veteran
Joined
Nov 18, 2015
Messages
40
Reaction score
21
First Language
Portuguese - Br
Primarily Uses
RMMV
Wow! excellent plugin!!!
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

buinguyenhoangtho wrote on fizzly's profile.
Hello @fizzly, i would like to use your asset/ resource for my project ( is maybe commercial ). May i have your permission? Thanks you !
Working on breaking the limits of RPGMaker! :cool:
I have 470+ hours on RMMV but have only made a demo game, is this normal? :kaoswt: (I lose motivation a lot plus I use a 32gb laptop, so..)
I like Iron Maiden.
Benku wrote on Magnus0808's profile.
Hey man you helped me out a long time ago with a plugin i was wondering if you can help me out one more time since its literally the last thing i need help with if not is cool but id figured id ask you one more soild.

Forum statistics

Threads
95,427
Messages
929,082
Members
125,659
Latest member
AphoticAmaranth
Top