Detect if unit is in water?

Magentix

if (OP.statement == false) postCount++;
Reaction score
107
JASS:
    function IsPointWater takes real x, real y returns boolean
        return IsTerrainPathable(x,y,PATHING_TYPE_WALKABILITY) and not(IsTerrainPathable(x,y,PATHING_TYPE_AMPHIBIOUSPATHING))
    endfunction


Use that function with [ljass]GetUnitX[/ljass] and [ljass]GetUnitY[/ljass]

Edit:
[ljass]IsPointWater[/ljass] is an old func out of Vexorian's CasterSystem, it seems wrong, but apparently it works...
(You'd think you want the terrain to be AMPHI, but not WALKABLE...)

Edit 2: [ljass]IsTerrainPathable[/ljass] is a FUBARed native, returns the opposite of what you'd expect. So the function I provided works
 

shiFt

Member
Reaction score
8
how would I use this to, basically want to detect if units are in water and slow there ms, then when they exit again they get their ms restored to normal speed. Regions?
 

ertaboy356b

Old School Gamer
Reaction score
86
how would I use this to, basically want to detect if units are in water and slow there ms, then when they exit again they get their ms restored to normal speed. Regions?

The easier system is to put a dummy unit with a slow aura that affects any units over bodies of water..
 

PurgeandFire

zxcvmkgdfg
Reaction score
508
You would basically do something like this:
JASS:
scope WaterSlow initializer Init
globals
    private constant integer raw = 'A000'
    private unit myCaster
    private group myGroup = CreateGroup()
endglobals
native UnitAlive takes unit id returns boolean
private function SlowWaterPeople takes real x, real y returns boolean
    local unit u = GetFilterUnit()
    local real x = GetUnitX(u)
    local real y = GetUnitY(u)
    if IsTerrainPathable(x,y,PATHING_TYPE_WALKABILITY) and not IsTerrainPathable(x,y,PATHING_TYPE_AMPHIBIOUSPATHING) and UnitAlive(u) then
        call IssueTargetOrder(mydummyunitorwhatevertocastslow,"slow",u)
    endif
    set u = null
    return false
endfunction
private function Grouping takes nothing returns boolean
    if GetSpellAbilityId() == raw then
        set myCaster = GetTriggerUnit()
        call GroupEnumUnitsInRange(myGroup,GetUnitX(GetTriggerUnit()),GetUnitY(GetTriggerUnit()),500,Condition(function SlowWaterPeople))
        call GroupClear(myGroup)
    endif
    return false
endfunction
private function Init takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(t,Condition(function Grouping))
    set t = null
endfunction
endscope


Although, I just made this really quick. It is an example. Not even sure if it parses without syntax errors. :p
 

ertaboy356b

Old School Gamer
Reaction score
86
Just edit the "Target" of the "Spell" to make it work with everyone.. Put as many dummy units as needed to occupy every body of water..
 

G00dG4m3

New Member
Reaction score
1
you can do it in GUI:
First set point as unit's location
check if the terrain pathing 'floating' is on
 

PurgeandFire

zxcvmkgdfg
Reaction score
508
It's just "more accurate" than GetWidgetLife(unit)>.405 supposedly. It might also be a bit faster too since it is a direct native rather than a real comparison.

You can use JASSHelper's native declarations to declare natives found in the common.ai. There are only a select few that are useful though.
 

Magentix

if (OP.statement == false) postCount++;
Reaction score
107
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top