• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Water check

Status
Not open for further replies.
Level 5
Joined
Apr 8, 2008
Messages
88
Is there a way to check if a unit is in water except for terraintype check and terrain levelcheck?

If there is a way in Jass, please post as custom scripts and explain it a bit, because im not using jass...
 
Level 5
Joined
Apr 8, 2008
Messages
88
Hmmm... Got any suggestion of what i could do then?
Is it possible to check the height of a point without checking terrain level?
 
Level 5
Joined
Apr 8, 2008
Messages
88
But that doesn't have anything to do with water, has it? Just because its lower as the normal terrain doesn't mean it has to include water.

I'll check if I can get anything to work somehow, however, I really doubt its makeable.

Since water has a specific level that is lower then ground if im not using wc3 clifs and no water doodads i think it works?
 
Level 5
Joined
Apr 8, 2008
Messages
88
So you have a flat terrain and if terrain is lower then the normal terrain it has to be water?
Then it should work.

However, it wouldn't work for others though.

True, or well. It dont have to be flat (But allways higher then the sealevel)

Do you know how to check if a point is lower then a specific value?
 
JASS:
    globals
        constant location zLoc      = Location(0, 0)
        constant real     TERRAIN_HEIGHT    = 7 * 64
    endglobals
    
    function GetLocZ takes real x, real y returns real
        call MoveLocation(zLoc, x, y)
        return GetLocationZ(zLoc)
    endfunction

   function IsLocInWater takes location loc returns boolean
       return GetLocZ(GetLocationX(loc), GetLocationY(loc)) < TERRAIN_HEIGHT
   endfunction

Change the TERRAIN_HEIGHT to the value that is your minimum terrain height of non-water.
Please note that this takes into account the cliffheight you have.
 
JASS:
local real x = GetUnitX(unit)
local real y = GetUnitY(unit)
if IsTerrainPathable(x,y,PATHING_TYPE_WALKABILITY) then
    call BJDebugMsg("unit is in water")
end

This code seems to work for me. Not sure how accurate it is, but it's worked for me (and never conflicted).
You also said no terraintype checks, this is a pathing check (to clarify).
 
Anachron said:
He does not understand jass.

Yet he requested jass scripts.
I'm fairly sure he can replace (unit) with (udg_unitvar).

Anachron said:
I posted a little script and explained how to implement, you posted a full JASS2 version of it.

Good job, I posted an alternative method which he could implement on his own time.
I didn't have the time the thoroughly explain my 5 lines of code.

And... don't say Jass2. I doesn't make you look any more intelligent or sophisticated.

Anachron said:
And btw, your code does not work probably when you have buildings/cliffs/destructables on the checked loc.

Did you mean properly, or probably?
Anyways, I never said it was 100% accurate.

I actually stated that it wasn't accurate to my knowledge.
Not sure how accurate it is, but it's worked for me (and never conflicted).
 
Status
Not open for further replies.
Top