[General] How to decrease Movement Speed while on water?

Status
Not open for further replies.
Level 28
Joined
Sep 26, 2009
Messages
2,544
You could create regions over all deep water and when unit enters one of those regions and it is your specified unit-type, you decrease its movement speed. When it leaves those regions, you increase its movement speed.

You need to be aware of movement-increasing/decreasing buffs and effects and add them to the calculation.
 
Level 9
Joined
Dec 15, 2009
Messages
523
if your not good with triggers

how about..
copy endurance aura,change the bonus movement speed values to negative( adjust to your liking)
Set the area of effect base on how huge your water/sea is
remove the aura effect model
remove/change buff (eg this unit is on water,movement speed is slowed)
create an invisible unit(with no model)
give him the endurance aura ability you just edited.
give him locust ability too (so he cant be selected)
place him in water ..doneee!!

im sorry if its not the smartest or accurate ways to do things.
just an optional lazy way to do it :D
 
Last edited:
Level 11
Joined
Jan 23, 2015
Messages
788
I'm planning to do something similar in the map I'm currently working on.
How about making a dummy unit with 99999 line of sight (obstructed) that will be placed in water as many times as needed in order to make the owner of the dummy to have vision over the whole water area. So when that unit is visible for the "dummy player" you give it a decreased movement speed, and when it gets outside line of sight, you increase it's ms again.
 
I'm planning to do something similar in the map I'm currently working on.
How about making a dummy unit with 99999 line of sight (obstructed) that will be placed in water as many times as needed in order to make the owner of the dummy to have vision over the whole water area. So when that unit is visible for the "dummy player" you give it a decreased movement speed, and when it gets outside line of sight, you increase it's ms again.
This is actually pretty clever, as it gets rid of all the region triggering.

The downside is, this occupies a whole player slot.

But it has the same problems with shallow water or smooth non-cliff transitions of terrain.
 
Regions are a nice solution if your water is organized in rectangles. If you end up with too many rectangles to fill them all, then perhaps you would want to go with a different solution.

You can always use a library such as this:
http://www.wc3c.net/showthread.php?t=103862
(if you don't use vJASS, you can simply place these functions in your map's header):
JASS:
function IsTerrainDeepWater takes real x, real y returns boolean
    return not IsTerrainPathable(x, y, PATHING_TYPE_FLOATABILITY) and IsTerrainPathable(x, y, PATHING_TYPE_WALKABILITY)
endfunction
function IsTerrainShallowWater takes real x, real y returns boolean
    return not IsTerrainPathable(x, y, PATHING_TYPE_FLOATABILITY) and not IsTerrainPathable(x, y, PATHING_TYPE_WALKABILITY) and IsTerrainPathable(x, y, PATHING_TYPE_BUILDABILITY)
endfunction
Then you can run a timer and check if the user is in water. If he is, then reduce his movement speed by 80, and save some boolean to let yourself know that he no longer needs his movement speed reduced (you can save a value in a hashtable). If those booleans return false, then you can increase the movement speed by 80 again.

That method should work, but having a timer periodically check can be a bit expensive. Especially if you have many units being tracked. But it can serve as a simple solution until you find a more efficient one.
 
That method should work, but having a timer periodically check can be a bit expensive. Especially if you have many units being tracked. But it can serve as a simple solution until you find a more efficient one.
It's easy enough to make this more efficient, depending on the terrain of the map. He could just define a rect around the general water area and only consider those units inside the rect.
So basicly, filtering out the majority of units that isn't even close to water.

That should be good enough, unless we are talking a tower defense map with masses of units.
 

EdgeOfChaos

E

EdgeOfChaos

Why not just use GetLocationZ? Seems easier than this stuff.
 
Status
Not open for further replies.
Top