Terrain Tag Passability - PG_TTagPass.js
This plugin gives you the ability to make terrain passable or not by turning switches on or off.Instead of using regions (which are not related to the tiles used) it uses terrain tags. Up to 6 terrain tags may have their passability controlled. It overides the passability of land tiles with specific terrain tags.Spoiler: Why use Terrain Tags to Control Access?Terrain Tags are settings that can be made in the "Tilesets" tab of the editor. Individual tiles can be given a terrain tag of 0 to 7. Multiple tiles can have the same terrain tag. By default, all terrain tags are 0.
Whenever a tile is used, the places it is used have the terrain tag of that tile. Unlike regions, if you change your mind where a wood or mountain range is, the terrain tag of each place is set automatically.
Terrain tags are a feature that I haven't previously used, and I suspect, are not used by many other people. Regions are sometimes used by other plugins for various effects. By default, they get used to control which enemies may be encountered in different areas of the same map. With this plugin, you could, for example, make all mountains impassable to the party, until they learn the mountaineering. Using a plugin that controls access by region, means that every time you edit the map you have to check whether the regions need updating. With this plugin, the party can be given access to previous blocked terrain by setting a switch.
To use a switch to control passability for a terrain tag, put the switch number into the relevant parameter. If the switch is "On", then tiles with that terrain tag are passable for the party, while if the switch is "Off" then they are impassable. If you don't want to overide the passability of tiles with a particular terrain tag, leave the parameter for the switch controlling it as '0'.
Version 2
JavaScript:
//=============================================================================
// PG_TTagPass.js
//=============================================================================
/*:
* @plugindesc Allows switched tile passability using terrain tags
*
* @author Piyan Glupak, amended for version 2 by Trihan
*
*
* @help
* This plugin has 6 parameters, for switches to control passability of tiles
* with terrain tags of 2, 3 , 4, 5, 6 and 7. If the switch is 'on', then all
* tiles with that terrain tag are passable. If the switch is 'off', then they
* are impassable. If no switch is chosen for a terrain tag (parameter is '0'),
* the
* tiles with that terrain tag have their default passability.
*
* Terrain tags are '0' by default, but can be set in the editor.
*
* This is intended for land. It is possible to fly over tiles the tiles with
* switched passability with the airship.
*
* This is Version 2.
*
* TERMS OF USE
**************************************************************************
* TERMS OF USE
* Free for use in commercial and non-commercial games. No liability accepted.
* Credit Piyan Glupak and Trihan
**************************************************************************
*
* COMPATIBILITY
* No issues known
*
* Version 2 - Code improved by Trihan when he wrote a supplementry plugin to
* improve visual aspects.
* Version 1 - Original version by Piyan Glupak
*
* @param Terrain Tag 2 Flag
* @type number
* @min 0
* @desc Number of the flag allowing passability of Terrain Tag 2
* @default 0
*
* @param Terrain Tag 3 Flag
* @type number
* @min 0
* @desc Number of the flag allowing passability of Terrain Tag 3
* @default 0
*
* @param Terrain Tag 4 Flag
* @type number
* @min 0
* @desc Number of the flag allowing passability of Terrain Tag 4
* @default 0
*
* @param Terrain Tag 5 Flag
* @type number
* @min 0
* @desc Number of the flag allowing passability of Terrain Tag 5
* @default 0
*
* @param Terrain Tag 6 Flag
* @type number
* @min 0
* @desc Number of the flag allowing passability of Terrain Tag 6
* @default 0
*
* @param Terrain Tag 7 Flag
* @type number
* @min 0
* @desc Number of the flag allowing passability of Terrain Tag 7
* @default 0
*/
window.PG = window.PG || {};
PG.parameters = PluginManager.parameters('PG_TTagPass');
PG.TFlag2 = Number(PG.parameters['Terrain Tag 2 Flag']);
PG.TFlag3 = Number(PG.parameters['Terrain Tag 3 Flag']);
PG.TFlag4 = Number(PG.parameters['Terrain Tag 4 Flag']);
PG.TFlag5 = Number(PG.parameters['Terrain Tag 5 Flag']);
PG.TFlag6 = Number(PG.parameters['Terrain Tag 6 Flag']);
PG.TFlag7 = Number(PG.parameters['Terrain Tag 7 Flag']);
Game_Map.prototype.checkPassage = function(x, y, bit) {
var flags = this.tilesetFlags();
var tiles = this.allTiles(x, y);
var TerTag = $gameMap.terrainTag(x,y);
for (const tile of tiles) {
const flag = flags;
if ((flag & 0x10) !== 0)//
[*] No effect on passage
continue;
for (let i = 2; i <= 7; i++) {
const propName = `TFlag${i}`;
if (TerTag === i && PG > 0) {
return $gameSwitches.value(PG);
}
}
if ((flag & bit) === 0) // Passable
return true;
if ((flag & bit) === bit) // Impassable
return false;
}
return false;
};
Terms and Conditions:
Free to use for both free and commercial games.Please do not publish this elsewhere on the Internet, but link to this thread. (This is in case I ever need to update the plugin; I would want only the latest version to be available.) I would prefer to be credited, either as "Piyan Glupak" or by my real name. Please credit Trihan as well, if using version 2.
Trihan's Supplementary Plugin may be found in post 7 of this thread.
本贴来自国际rpgmaker官方论坛作者:Piyan Glupak处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/terrain-tag-passability-pg_ttagpass-js.164894/
页:
[1]