1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still haven't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The reforging of the races is complete. Come see the 14th Techtree Contest Results.
    Dismiss Notice
  4. It's time to choose your horse in the race - the 32nd Modeling Contest Poll is up!
    Dismiss Notice
  5. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[JASS] Water Detection System

Discussion in 'Triggers & Scripts' started by KaiserG, Feb 22, 2008.

  1. KaiserG

    KaiserG

    Joined:
    Feb 12, 2008
    Messages:
    207
    Resources:
    0
    Resources:
    0
    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 ^^
     
  2. Gallin

    Gallin

    Joined:
    Sep 24, 2007
    Messages:
    1,049
    Resources:
    1
    Models:
    1
    Resources:
    1
    couldnt you just make a region where the water is??
     
  3. KaiserG

    KaiserG

    Joined:
    Feb 12, 2008
    Messages:
    207
    Resources:
    0
    Resources:
    0
    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...
     
  4. donut3.5

    donut3.5

    Joined:
    Feb 22, 2006
    Messages:
    3,389
    Resources:
    31
    Models:
    20
    Icons:
    9
    Maps:
    1
    Tutorials:
    1
    Resources:
    31
    Shallow or deep water?
    There are boolean checks for pathable for swimming creatures, but that only works for deep water.
    --donut3.5--
     
  5. Dil999

    Dil999

    Joined:
    Jun 10, 2007
    Messages:
    226
    Resources:
    2
    Maps:
    2
    Resources:
    2
    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.
     
  6. KaiserG

    KaiserG

    Joined:
    Feb 12, 2008
    Messages:
    207
    Resources:
    0
    Resources:
    0
    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!
     
  7. GhostWolf

    GhostWolf

    Joined:
    Jul 29, 2007
    Messages:
    4,872
    Resources:
    2
    Tools:
    1
    Tutorials:
    1
    Resources:
    2
    Why is this in Jass forum ? :huh:

    Anyway, another solution would be putting a diffrent terrain type or however its called.

    So for example you put sand under all the water and then check if the type there is sand.
     
  8. LeP

    LeP

    Joined:
    Feb 13, 2008
    Messages:
    463
    Resources:
    0
    Resources:
    0
    Or use something like this:
    Code (vJASS):
    function IsPointWater takes real x, real y returns boolean
        return not(IsTerrainPathable(x, y, PATHING_TYPE_FLOATABILITY))
    endfunction
     
  9. KaiserG

    KaiserG

    Joined:
    Feb 12, 2008
    Messages:
    207
    Resources:
    0
    Resources:
    0
    hummm does that work for shallow water?
     
  10. Earth-Fury

    Earth-Fury

    Joined:
    Feb 18, 2004
    Messages:
    538
    Resources:
    1
    Tutorials:
    1
    Resources:
    1
    I just... have to nit pick.

    rect
    s are only rectangular.
    region
    s are collections of
    rect
    s.

    is it
    SetTerrainPathable()
    or
    IsTerrainPathable()
    or both where the boolean value representing pathability reversed? Or am I going completely senile?
     
  11. Herman

    Herman

    Joined:
    Aug 20, 2007
    Messages:
    877
    Resources:
    0
    Resources:
    0
    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)
     
  12. KaiserG

    KaiserG

    Joined:
    Feb 12, 2008
    Messages:
    207
    Resources:
    0
    Resources:
    0
    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...
     
  13. Herman

    Herman

    Joined:
    Aug 20, 2007
    Messages:
    877
    Resources:
    0
    Resources:
    0
    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
     
  14. PurplePoot

    PurplePoot

    Joined:
    Dec 14, 2005
    Messages:
    11,161
    Resources:
    3
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    3
    The pathing check works best, especially since it allows you to still have various water levels, but I guess whatever works for you.

    (Also, spells like War Stomp cause terrain deformations!)
     
  15. ban-lord

    ban-lord

    Joined:
    May 26, 2007
    Messages:
    204
    Resources:
    2
    Models:
    1
    Tutorials:
    1
    Resources:
    2
    Just a suggestion, why not a special tile for your water? The game can check tiles.
     
  16. KaiserG

    KaiserG

    Joined:
    Feb 12, 2008
    Messages:
    207
    Resources:
    0
    Resources:
    0
    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.

    That was the 1st idea, but i'm actually using all the tileset for my map.
     
  17. Herman

    Herman

    Joined:
    Aug 20, 2007
    Messages:
    877
    Resources:
    0
    Resources:
    0
    I suppose

    There alot of ways to do it, you could pretty much pick one out of a hat
     
  18. PurplePoot

    PurplePoot

    Joined:
    Dec 14, 2005
    Messages:
    11,161
    Resources:
    3
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    3
    It does, as boats can float in shallow water.
     
  19. Herman

    Herman

    Joined:
    Aug 20, 2007
    Messages:
    877
    Resources:
    0
    Resources:
    0
    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
     
  20. Lestat(br)

    Lestat(br)

    Joined:
    Oct 2, 2005
    Messages:
    406
    Resources:
    7
    Models:
    7
    Resources:
    7
    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.