CityShrimp's Cover Tiles

cityshrimp

Villager
Member
Joined
Aug 17, 2013
Messages
16
Reaction score
20
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
46
Reaction score
24
First Language
Portuguese - Br
Primarily Uses
RMMV
Wow! excellent plugin!!!
 

ThePreparator

Warper
Member
Joined
Jun 2, 2020
Messages
3
Reaction score
1
First Language
Arabic
Primarily Uses
RMMV
Thanks. It's easy to use and works great but it eliminates the shadow if you have shadow above your tiles or at least it did for me.
 

Wavelength

Edge of Eternity
Global Mod
Joined
Jul 22, 2014
Messages
5,402
Reaction score
4,792
First Language
English
Primarily Uses
RMVXA
@ThePreparator Welcome to the forum! It's been a couple of years since the plugin's author was last seen here, so you may want to post a topic on the JS Plugin Support board if you're looking for help getting the shadows to work correctly with this plugin. Maybe someone else who has used this plugin can help you there.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Not going to lie... PIXI Particles make fantastic graphics... But predicting the hitbox of something with a "fixed size" but whose graphics can stick out past that, is quite challenging. :kaoswt:
Would you like a glass of spiders?
Besides my Might and Magic inspired project, I have always wanted to make a Fire Emblem-like game. Time is the culprit... Between life, composing music packs, and working on a game can it be done!? The tactical plugins for MV work quite well based on what I have tested.
Yaaay! My second public script is out and approved! A VX Ace Final Fantasy IX styled Throw Script!

I look forward to all the constructive feedback I get but most importantly I hope everyone who ends up using it enjoys!

Yaaaay! Making scripts is fun lol. :D

Forum statistics

Threads
100,530
Messages
976,882
Members
132,081
Latest member
Kaezyelnatz
Top