Slow walk speed on specific tilesets

Hi everyone, Although I've used RPG Maker 2003 years ago, I've never actually done any coding in the program.

I'm simply trying to make certain tilesets slow character speed down, in this case it's water tilesets. I would like to have movement speed back to normal once out of the water.

I have an archaic way of doing it - by lining the water with events that decrease speed, and having the shoreline bring it back to normal. This however, is obviously not the most efficient way to do it. Can anyone help be find a cleaner, more concise way of doing this, thanks in advance!
You could use regions instead of events - draw on the water tiles with one region, and around the edge with another, like you're doing with your events. Then have a single event set to parallel process (if this is only on one map, or a small number of maps, use a map event, otherwise use a common event with parallel process trigger and turn on a switch at the start of the game).

The event should do the following (we'll assume you use region 5 for the water outline, and region 6 for the land outline surrounding it):
Code:
Wait 5 Frames
Control Variables: [Player Current Region] = Script: $gamePlayer.regionId()
If Variable [Player Current Region] = 5
  change speed to slower
Else
  If Variable [Player Current Region] = 6
    change speed to faster
  End
End

Now, there are a few ways you could do this. The example above checks every 5 frames, and changes the speed even if you're already at that speed. I've done it that way because there are a few other things that could cause the speed to adjust, like dashing or using vehicles, and when you do those things, or stop doing them, it would set the player speed, ignoring the tiles.

If you don't have vehicles and don't allow dashing on those maps, you could make it more efficient by checking to see if the region has changed, and only doing the above steps when that happens. In that case you'll need 2 variables - the second one will be set to 0 initially, but which will trigger the commands straight away:
Code:
Wait 5 Frames
Control Variables: [Player Current Region] = Script: $gamePlayer.regionId()
If Variable [Player Current Region] <> Variable [Player Previous Region]
  Control Variables: [Player Previous Region] = Variable [Player Current Region]
  If Variable [Player Current Region] = 5
    change speed to slower
  Else
    If Variable [Player Current Region] = 6
      change speed to faster
    End
  End
End

The wait should be there in both cases, to reduce lag. Otherwise it'd check 60 times a second, and there's no way the player can move to 60 different tiles in a second. A wait of 5 frames caters for up to 12 tiles a second, which is probably still higher than needed, but it allows plenty of breathing room for other events to have their turns.

And of course, if you want to be even more efficient, you could request a plugin to be written to do it for you.
As you surmised, using dozens of touch events along the edge of the water is an inefficient way to do it (and it can cause a performance loss if you need hundreds of them or are playing on a slow computer). I would recommend using Regions to accomplish this kind of thing. Line the edge of the water with a designated Region ID, and the shoreline with another designated Region ID.

Then, either use a plugin like Yanfly's Region Common Events to run eventing (like changing player speed) when you walk onto water/land, or simply create a Parallel Process event which runs every couple of frames (add a 2-3 frame Wait at the end of the PP event) and checks what terrain the player is on, adjusting their speed accordingly.

If you use a PP event, I recommend painting the entire land/water areas in their region IDs, rather than only a narrow strip at the shoreline, just in case the player traverses those tiles within the couple of frames between "runs" of the event.
You could use regions instead of events - draw on the water tiles with one region, and around the edge with another, like you're doing with your events. Then have a single event set to parallel process (if this is only on one map, or a small number of maps, use a map event, otherwise use a common event with parallel process trigger and turn on a switch at the start of the game).

The event should do the following (we'll assume you use region 5 for the water outline, and region 6 for the land outline surrounding it):
Code:
Wait 5 Frames
Control Variables: [Player Current Region] = Script: $gamePlayer.regionId()
If Variable [Player Current Region] = 5
  change speed to slower
Else
  If Variable [Player Current Region] = 6
    change speed to faster
  End
End

Now, there are a few ways you could do this. The example above checks every 5 frames, and changes the speed even if you're already at that speed. I've done it that way because there are a few other things that could cause the speed to adjust, like dashing or using vehicles, and when you do those things, or stop doing them, it would set the player speed, ignoring the tiles.

If you don't have vehicles and don't allow dashing on those maps, you could make it more efficient by checking to see if the region has changed, and only doing the above steps when that happens. In that case you'll need 2 variables - the second one will be set to 0 initially, but which will trigger the commands straight away:
Code:
Wait 5 Frames
Control Variables: [Player Current Region] = Script: $gamePlayer.regionId()
If Variable [Player Current Region] <> Variable [Player Previous Region]
  Control Variables: [Player Previous Region] = Variable [Player Current Region]
  If Variable [Player Current Region] = 5
    change speed to slower
  Else
    If Variable [Player Current Region] = 6
      change speed to faster
    End
  End
End

The wait should be there in both cases, to reduce lag. Otherwise it'd check 60 times a second, and there's no way the player can move to 60 different tiles in a second. A wait of 5 frames caters for up to 12 tiles a second, which is probably still higher than needed, but it allows plenty of breathing room for other events to have their turns.

And of course, if you want to be even more efficient, you could request a plugin to be written to do it for you.
Hey, appreciate your time, I've found
You could use regions instead of events - draw on the water tiles with one region, and around the edge with another, like you're doing with your events. Then have a single event set to parallel process (if this is only on one map, or a small number of maps, use a map event, otherwise use a common event with parallel process trigger and turn on a switch at the start of the game).

The event should do the following (we'll assume you use region 5 for the water outline, and region 6 for the land outline surrounding it):
Code:
Wait 5 Frames
Control Variables: [Player Current Region] = Script: $gamePlayer.regionId()
If Variable [Player Current Region] = 5
  change speed to slower
Else
  If Variable [Player Current Region] = 6
    change speed to faster
  End
End

Now, there are a few ways you could do this. The example above checks every 5 frames, and changes the speed even if you're already at that speed. I've done it that way because there are a few other things that could cause the speed to adjust, like dashing or using vehicles, and when you do those things, or stop doing them, it would set the player speed, ignoring the tiles.

If you don't have vehicles and don't allow dashing on those maps, you could make it more efficient by checking to see if the region has changed, and only doing the above steps when that happens. In that case you'll need 2 variables - the second one will be set to 0 initially, but which will trigger the commands straight away:
Code:
Wait 5 Frames
Control Variables: [Player Current Region] = Script: $gamePlayer.regionId()
If Variable [Player Current Region] <> Variable [Player Previous Region]
  Control Variables: [Player Previous Region] = Variable [Player Current Region]
  If Variable [Player Current Region] = 5
    change speed to slower
  Else
    If Variable [Player Current Region] = 6
      change speed to faster
    End
  End
End

The wait should be there in both cases, to reduce lag. Otherwise it'd check 60 times a second, and there's no way the player can move to 60 different tiles in a second. A wait of 5 frames caters for up to 12 tiles a second, which is probably still higher than needed, but it allows plenty of breathing room for other events to have their turns.

And of course, if you want to be even more efficient, you could request a plugin to be written to do it for you.

As you surmised, using dozens of touch events along the edge of the water is an inefficient way to do it (and it can cause a performance loss if you need hundreds of them or are playing on a slow computer). I would recommend using Regions to accomplish this kind of thing. Line the edge of the water with a designated Region ID, and the shoreline with another designated Region ID.

Then, either use a plugin like Yanfly's Region Common Events to run eventing (like changing player speed) when you walk onto water/land, or simply create a Parallel Process event which runs every couple of frames (add a 2-3 frame Wait at the end of the PP event) and checks what terrain the player is on, adjusting their speed accordingly.

If you use a PP event, I recommend painting the entire land/water areas in their region IDs, rather than only a narrow strip at the shoreline, just in case the player traverses those tiles within the couple of frames between "runs" of the event.

Thanks for your time, I've decided to use the plugin for regions, thanks!

Original thread: https://forums.rpgmakerweb.com/threads/slow-walk-speed-on-specific-tilesets.114571/