MV/MZ SDJB_DynamicRegions

PluginName: SDJB_DynamicRegions
Author: ShadowDragon

Spoiler: How it works
Code:
 How it works
 ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞
 Dynamic Regions which can block passages for players and find a switch
 to open it that you set in the database.

 When the switch is OFF, the region is passable,
 When the switch is ON, the region is blocked.
 When a required tag and state is given, you can pss through blocked tiles.

 Parameters:
 ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞ ͞
 RegionId      => set the region id from 1-255
 SwitchId      => set the switch required to turn it ON or OFF
 Require Tag   => use a tag to override passthrough?
 Required Tag  => set tag to use (ex: "floating")

 If the tag is required, set inside the state the tag <floating>
 
 Once state is given with the tag, you can passthrough the region
 which normally block the player when the switch is on.

 No state given or not the tag required still block the player,
 this can give you the ability to cross the water on said region
 with the state.

 State given works only for the party leader, not the party member.

=== TERMS OF USE ===
Free for Non-Commercial and Commercial use when credit is given.
credit one of the following:
ShadowDragon
ShadowDragonJB

Version + UPDATE'S
12-11-2024 Version 1.0.0 first release
16-07-2025 Version 2.0.0 rewrote and added features

=== WARNING ===
YOU ARE NOT ALLOWED TO REDISTRIBUTE OR SELL IT OR TAKE CODE FOR YOUR OWN.
DO NOT REMOVE THE HEADER.

(file is below as it require my base plugin (SDJB_Base or SDJB_BaseMZ (minified version))


Download from itch.io
small update, that it can break potentional movement,
if set below others with the functions, this is now aliased
and re-coded so it wont collide with other plugins.

if you downloaded it before, please re-download and replace it.
everything should work as before 🙂
small update, changed json parser that breaks it with MZ plugins
or MV that use array.remove function, this is fixed in this version.
Thank you!

Useful plugin, especially for a Region enthusiast!

Question/request: Would it be possible to set up more than one region? Like as many as wanted even? Overlapping multiple regions is the only way to get the most out of them.

example: Region w/SDDRP=region1, Region with damage floor+SDDRP=region2, Region w/common event+SDDRP=Region3, etc..
Question/request: Would it be possible to set up more than one region? Like as many as wanted even? Overlapping multiple regions is the only way to get the most out of them.
The trick is that regions are a specific layer of the map data. Adding more layers to accommodate the storage of multiple regions (or turning it into an array) would require the careful modification of every piece of code that interacts with map layers or tiles.

And then there would be no way to put it into the editor, you'd have to be manually setting these lists of multiple regions via notetags in the maps.

It seems like it would be easier to just use whatever means of interacting with regions you already are and account for it on your end.
That's not necessarily what I meant. The plugin allows for one on/off region. I just wanted to know if we could get more than one one region to do on/off with a seperate switches. I assume I could easily do this if I knew JS but as of now I don't. like one map has region 1 set to this plugin, and another map (or the same) has another region set to this plugin and just on a seperate switch.

I don't want multiple regions on the same tile. (well I do but that's another thing). And I have already put multiple plugins using the same tiles like, passability plugin, common event plugin, show name tag plugin, and region effects plugin all using the same region.

Oh, check this out. Plugin layers. (I just dunno if I want to go to this amount of setup and execution): https://eric-the-funny-baron.itch.io/region-id-layers-plugin
Oh wait, I have just discovered that you can, actually. The plugin totally allows you to add as many as you want. Um... I don't now how I missed that. I swear I specifically looked to see if you could add more region/region switches and... Well, thank you now even more Shadow Dragon! I was actually wondering how you could have decided not to allow that.

Thanks for trying to help Turan. I have wasted your valuable time.
@ephesus you can set many regions to block player/unblock paths.
for any kind, the link is you placed is more for tiled, but if you want
region or temp region for dmg, and common event to run, you can
look into [Red_setRegionId] as mine doesn't have that purpose, other
than block/unblock the player (once I got time, I see what I can do for
the Events as well, so they can block when a switch is ON.

but nothing is impossible, but some things are impossible for me,
but not for advance coders ^^

I'm glad you got it to work, but read helpfile before asking questions,
the request you asked is something out of purpose of this plugin feature.

@ATT_Turan thank you for the nice explanation of layers 🙂
Adding multiple instances was exactly what I was looking for. So, now I'm very happy and feel silly for asking when it was already there.

The plugin you linked is something I'll use for sure, thanks! Can you help me with this however?:
"To change a tile range, use the function "$gameMap.setTileSquareId(x, x2, y, y2, r)""

I've neve heard of tile range and also am not sure how to use x, x2, y ,y2. (r is the region id I'm pretty sure.) Is x2 and y2 the size we want x and y expanded to?
I didn't use that on my own, but I think the following: (its best to try).

x = 3
x2 = 10 (so tiles 3 through 10 is covered)
y = 1
y2 = 5 (so y 1 through 5 is covered)
r = regionId.

but I dont know if it goes like left to right and up and down or a square part.
test to see the effect, make a simple text message or grass/sand area and
see if it triggers with the numbers inputted, otherwise I dont know.

I use that plugin more as a sensor plugin for hidden items 🙂
but if you really want help, make a new thread, or it goes far off topic than the
purpose of the plugin feature.
This plugin has been rewritten on a special request, and it seems
a really cool feature as well, so it is being extended for usage.

there will be more features added that can swap regions id
from 4 to 8 (1 region or all regions) by plugin command, or scriptcall.

while MZ is a bit harder with plugin commands, it might be scriptcall
for those users (or help on it).

so what will be new!

current features (rewritten)

Region ID
Switch ID

if switch is ON, player is blocked, while OFF is passable.
this also counted for directions.

new feature added are
Require tag (true or false)
Required tag (string) ("floating")

so if you fly, the player get blocked, but if the player (leader) has
the state with the tag <floating> (customize tags), you can fly
through it, even if the passable tile is blocking, but if the region is
painted over it, you can have full passable on this region!

so it was a challenge to add this, but soon available under the name:
SDJB_DynamicRegions (require my base) for both MV and MZ.
Plugin updated to version 2.0 (require my base).

enjoy the new version =)

Original thread: https://forums.rpgmakerweb.com/threads/sdjb_dynamicregions.146845/