Warp Transfer Terrain Tag Script

Power Master

Optimistic Game Designer
Veteran
Joined
Apr 18, 2015
Messages
112
Reaction score
12
First Language
English
Primarily Uses
RMMV
In the desert area of my game, if the player steps off the path, they will be transferred back to the start of the path and have to start again. I did this using simple "Transfer Player" event tiles, but now there are so many of them that the game lags considerably. It didn't used to be a problem until now. Nothing changed, so I don't know what happened. I tried deleting a few of the more unnecessary ones, but it's still lagging. I figured terrain tags would be a good thing to switch them to, but I have NO idea how to work those. I know a script has to be used in conjunction with the terrain tagged, but I don't know where said script is. I searched through Yanfly's script list, but the closest thing I found was the "Move Restrict Region" script, which isn't quite what I want.

To prevent lagging, I need a terrain tag script that warps the player to a specific point when touched. Any suggestions or creations?
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,111
Reaction score
13,715
First Language
English
Primarily Uses
RMMV
First, I'd look for the cause of the lag. You may find it's none of those events, but something else that you've done. It's probably a parallel process (or more) that you've got running, neverending (like one to set weather, screen tint, play BGM/BGS, etc that should only happen at the start of the map but you haven't erased, so it's continually doing it) and there is no Wait to come up for air between iterations. It could also be a common event that has a parallel process trigger, whose switch has been turned on (which could happen if you're using a script that requires switches and has a default switch it wants to use, and you've used that for something else)


Terrain tags mean you'd have to set the tag in the tileset, and that EVERY ONE of those tiles would have that tag. That's okay if you always want the same thing to happen whenever you walk on that tile. But sometimes you don't want ALL of them to behave that way.


If that's the case, you could use Regions instead of Terrain Tags. This way, you can just draw on the map over the tiles you want to have this behaviour, and they can be ANY tile. Then use a script (like my Region Common Events script, but there are others) to run a common event whenever the player steps on a tile with that region id.
 

MeowFace

Meow
Veteran
Joined
Feb 22, 2015
Messages
1,034
Reaction score
184
First Language
Meowish
Primarily Uses
Region triggers can be easily done using 1 common event set on parallel process.

A full eventing method without even using script call will be:

Record the player's X Y to 2 game variables. (you can do that in control variable)

Then use the variables to check terrain data for region id (3rd tab in event) and record it to a 3rd game variable

Now that you know which region id your player is stepping on, you can easily make it do transition using a conditional branch.
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,111
Reaction score
13,715
First Language
English
Primarily Uses
RMMV
Didn't even think of that this time around! Make sure you add a wait of about 4-5 frames or so right at the start, or that will be another thing to end up causing lag for you :)
 

Power Master

Optimistic Game Designer
Veteran
Joined
Apr 18, 2015
Messages
112
Reaction score
12
First Language
English
Primarily Uses
RMMV
First, I'd look for the cause of the lag. You may find it's none of those events, but something else that you've done. It's probably a parallel process (or more) that you've got running, neverending (like one to set weather, screen tint, play BGM/BGS, etc that should only happen at the start of the map but you haven't erased, so it's continually doing it) and there is no Wait to come up for air between iterations. It could also be a common event that has a parallel process trigger, whose switch has been turned on (which could happen if you're using a script that requires switches and has a default switch it wants to use, and you've used that for something else)

Terrain tags mean you'd have to set the tag in the tileset, and that EVERY ONE of those tiles would have that tag. That's okay if you always want the same thing to happen whenever you walk on that tile. But sometimes you don't want ALL of them to behave that way.

If that's the case, you could use Regions instead of Terrain Tags. This way, you can just draw on the map over the tiles you want to have this behaviour, and they can be ANY tile. Then use a script (like my Region Common Events script, but there are others) to run a common event whenever the player steps on a tile with that region id.
All this is is a large desert with events lined up around the path the player needs to take. Step off the path and it'll warp you back. There's nothing else on the map.

Region IDs would be helpful, yes, but it'd just have the same effect as the Terrain Tag. At least in this case. Where can I find your script, btw? It doesn't seem to be popping up in your pastebin link...

Region triggers can be easily done using 1 common event set on parallel process.

A full eventing method without even using script call will be:

Record the player's X Y to 2 game variables. (you can do that in control variable)

Then use the variables to check terrain data for region id (3rd tab in event) and record it to a 3rd game variable

Now that you know which region id your player is stepping on, you can easily make it do transition using a conditional branch.
...Pretty sure I'm doing something wrong here. Care to walk me through it...? I have the event on parallel process, but I think I need to create a new conditional switch as well?



EDIT: Never mind! It is no longer giving me lag for...some...reason? There's a bit of a area-loading lag, but that's it. Once I start moving around, it runs fairly smoothly.

However, I would still like to know what I'm doing wrong with the above event for future reference or to change it so something like this doesn't happen anymore.
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,111
Reaction score
13,715
First Language
English
Primarily Uses
RMMV
You only need ONE event like that, and set it to Parallel Process.


You're using variable 13 as the region and the map X. It shouldn't cause a problem, but it'd be tidier if you'd use a new variable for the region.


After those commands, you need to add a Conditional Branch to see if the region variable contains the region ID you used to paint the boundaries with.


And add that Wait 4 Frames as the first command.


Beware of issues that happen then disappear for "no apparent reason" - they are likely to happen again, and indicate that you've got something set up badly.
 

MeowFace

Meow
Veteran
Joined
Feb 22, 2015
Messages
1,034
Reaction score
184
First Language
Meowish
Primarily Uses
Yes, just flip the switch to turn on the common event parallel process on area transition to start running it.

Or you can simply put an event in the map that you wish to check for region transition with all those settings and set it to run in parallel.

Normally when you packed the map with events the lag will show.

Or, on a slower machine, a large map with auto-tiles that animates will lag without any events in it.

RGSS3 Player(your game.exe) do not support graphic GPU. So the processing power is very limited

And believe it or not, event is your least problem for lag in most cases, unless you really go and place over 100+ events in a packed area.

So most of the cases with lags are caused by script/script conflicts.

In your case, since you don't have to fix it to make the problem goes away, there will be chances that it will come back.

Sounds more like a memory leak problem to me. You will need to check each of your custom script for conflicts.

A few of the famous "flashy" scripts out there are actually known to have memory leak problem.

And some are caused by script conflicts that broken some important features.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,111
Reaction score
13,715
First Language
English
Primarily Uses
RMMV
Most cases of lag I've seen are caused by badly written events. Especially parallel process events.
 

MeowFace

Meow
Veteran
Joined
Feb 22, 2015
Messages
1,034
Reaction score
184
First Language
Meowish
Primarily Uses
Lag from event can be fixed easily, they are quite instant and show up directly if you use them wrongly.

And if you don't use any script calls but only using the event commands, the chances for algorithm error is limited to a few commands only, eg, loop, or even wait. Yes, wait can stimulate "lag" if you use it in the wrong place and loop definitely needs a wait inside or it will freeze the game.

But scripts can cause memory leaks that result in crashes or lag in a long run that can be hard to detect.

That's the serious problem, especially these don't usually shows until past the mid-game building, making it extremely hard if you need to scrap a script to make things work. Better check them before the problem finds you. ;)
 

Power Master

Optimistic Game Designer
Veteran
Joined
Apr 18, 2015
Messages
112
Reaction score
12
First Language
English
Primarily Uses
RMMV
I'm not seeing anywhere in the Conditional Branch options to set the Region ID. I added another CV, like Shaz said, so do I set "Variable X is equal to Variable 15."

I have no idea what I'm doing as I've never used Region IDs outside of setting enemy encounter locations...

After those commands, you need to add a Conditional Branch to see if the region variable contains the region ID you used to paint the boundaries with.
How do I do this?
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,111
Reaction score
13,715
First Language
English
Primarily Uses
RMMV
You are setting a variable to the region id. The conditional branch allows you to check if the variable contains a certain value.


So if you use region id 5 for the "border" tiles, and you use Get Location Info to put the region id from the player's x and player's y into variable 8, your conditional branch will be "if Variable 8 == 5"


Re the lag - yes, sometimes it's easy to find it when it's caused by events, IF you know that using event commands incorrectly or triggers incorrectly can cause lag. But most newbies don't know how, and don't even consider that there are "good" and "bad" ways of making events that can affect this. And yes, scripts can cause lag, but most newbies wouldn't be writing their own scripts, and if there were scripts available for download that caused bad lag because of memory leaks, you can bet that it will be reported by many people. I suspect that if we went through the forum looking for people asking for help with lag that happened sometimes and suddenly disappeared (or ANY lag), we'd find a lot more caused by events than by scripts. For this reason, we usually ask people to look at the events that are running, either on their maps or on common events, to look for possible causes of lag, before we start looking at the scripts.
 
Last edited by a moderator:

Power Master

Optimistic Game Designer
Veteran
Joined
Apr 18, 2015
Messages
112
Reaction score
12
First Language
English
Primarily Uses
RMMV
Okay, yes! It finally works! And it's not laggy anymore! :)

Sorry if that took longer than it should've for me to understand the process for this. I'll experiment more with this and I'll be able to use it in other areas as well. Thanks, guys!
 

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

Latest Threads

Latest Profile Posts

Don't forget, aspiring writers: Personality isn't what your characters do, it is WHY they do it.
Hello! I would like to know if there are any pluggings or any way to customize how battles look?
I was thinking that when you start the battle for it to appear the eyes of your characters and opponents sorta like Ace Attorney.
Sadly I don't know how that would be possible so I would be needing help! If you can help me in any way I would really apreciate it!
The biggest debate we need to complete on which is better, Waffles or Pancakes?
rux
How is it going? :D
Day 9 of giveaways! 8 prizes today :D

Forum statistics

Threads
106,051
Messages
1,018,549
Members
137,837
Latest member
Dabi
Top