This is actually pretty clever, as it gets rid of all the region triggering.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.
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
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.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 a little buggy on water.Why not just use GetLocationZ? Seems easier than this stuff.