• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] Water Detection System

Status
Not open for further replies.
Level 6
Joined
Feb 12, 2008
Messages
207
Ok i need something to get to know if a unit is on water or not, just like the "Terrain Type comparison" in the GUI... if possible in GUI... but i dont think there is, so JASS is also appreciated =)

thanks in advance ^^
 
Level 6
Joined
Feb 12, 2008
Messages
207
regions are only square... and my water terrain formation is kinda spread all around... i think theres no way to get if a unit is on water... so maybe ill use regions, but in some part of the water... thx anyway :)

EDIT: the last resource i have in mind is making that the zones with water should have a specific terrain tile, so if a unit is stepping on that terrain-type, it can work fine... the problem is that i need to use the whole tileset... so it would be better to find (if there is) a way to do it with the water...
 
Level 7
Joined
Jun 10, 2007
Messages
225
If you entire map has an underlayer of water (make the entire thing shallow an raise the heightmap from there, so whenever you use Lower terrain it becomes water).
Once you do that, check if a locations height is less than 0; if so, it is in water.
 
Level 6
Joined
Feb 12, 2008
Messages
207
whoa! thanks a lot dil! i'll check it out! just what i needed ^^

BTW, i used some sectors with terrain cliff under the water level... but thats no problem... as they are just a couple of parts.. i can use a region to mark the entire zone (no problem if the region marks outside the zone... its the same) and include if the unit is NOT in that region on the conditions ^^

thanks again! +rep!
 

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
539
Or use something like this:
JASS:
function IsPointWater takes real x, real y returns boolean
    return not(IsTerrainPathable(x, y, PATHING_TYPE_FLOATABILITY))
endfunction
 
Level 6
Joined
Feb 12, 2008
Messages
207
Or use something like this:
JASS:
function IsPointWater takes real x, real y returns boolean
    return not(IsTerrainPathable(x, y, PATHING_TYPE_FLOATABILITY))
endfunction

hummm does that work for shallow water?
 
Level 11
Joined
Feb 18, 2004
Messages
394
regions are only square...
I just... have to nit pick.

rects are only rectangular. regions are collections of rects.

Or use something like this:
JASS:
function IsPointWater takes real x, real y returns boolean
    return not(IsTerrainPathable(x, y, PATHING_TYPE_FLOATABILITY))
endfunction

is it SetTerrainPathable() or IsTerrainPathable() or both where the boolean value representing pathability reversed? Or am I going completely senile?
 
Level 12
Joined
Aug 20, 2007
Messages
866
Well

If you can't do it any other way, what regions truly are, are values bewtween the top left corner (x1, y1) and the southern corner (x2,y2) and when you check if a position/coorinate is in a region/rect, you are checking

If x coordinate is > x1 and < x2 And y coordinate > y1 and < y2

Once you understand that concept, you can make regions of any size, shape, anything!!!


It might take long as hell, but you can specify all the parts that are water using some massive function check in JASS

I don't know enough about JASS to write out the function, but I can conceptualize it, something that would be a boolexpr


Would somebody be kind enough to build + show a boolexpr similar to the one discribed above that would cover water terrain in a small map? (show a picture of the map with an arial view)
 
Level 6
Joined
Feb 12, 2008
Messages
207
neh sorry that would take too much, its a map with size EPIC, so i'm using Dil999's recommendation, im just checking if the height position of the unit is less than -1. And as i used some low terrain places with no water, the trigger also checks if the unit is NOT in the region of the place with lowered height but no water on it...
 
Level 12
Joined
Aug 20, 2007
Messages
866
Hm

Yeah thats probably the best way to do it

The thing I mentioned is do-able, but there are many more functions in The Frozen Throne that do the same thing easier
 
Level 6
Joined
Feb 12, 2008
Messages
207
PurplePoot said:
The pathing check works best, especially since it allows you to still have various water levels, but I guess whatever works for you.
Well... i actually would used that one, but i asked if that checks for shallow water too (since amphibious units doesnt swim at shallow water)? if it does, i will use it, bcause its the best way to do it.

banlord said:
Just a suggestion, why not a special tile for your water? The game can check tiles.
That was the 1st idea, but i'm actually using all the tileset for my map.
 
Level 12
Joined
Aug 20, 2007
Messages
866
So what does the pathing function do???

Besides return a boolean (I'm talking about the programming that would create the function)

Is it something like all the terrain tile-spaces have a # attached to them, and the PathingFunction first finds the tile (using the coordinates given) then checks to see if the found tile has the same # as a water tile should

???

I guess something like that?
I suppose you could make your very own tiles if you recreated what I described above with some arrays
 
Level 10
Joined
Oct 2, 2005
Messages
398
spells like war stomp can cause deformations, but the rolling shores aren't changed at all, if you raise the floor with 9999 height from shallow water in game, it won't pass the water and will look confusing, the water is unvariable during the game, I recommend the float pathing system.
 
Status
Not open for further replies.
Top