Detect if unit is amphibious

Dr Super Good

Spell Reviewer
Level 57
Joined
Jan 18, 2005
Messages
26,467
Try placing it in a suitably sized patch of water pathing using SetUnitPosition or whatever the native is called. If it is not amphibious it will displace to the nearby land. If it is then it will remain where you place it. Same can be done with land to test if the unit is naval only.
 
Level 21
Joined
Feb 6, 2014
Messages
2,468
i cant find any function that can check this but you could just give your amphibious units a dummy ability and check in the trigger if your unit has that ability

Yeah this was a good solution but it is not practical for the Spells Section.

What happens if u create a unit that can't walk on water, on water?

I guess the unit will be stuck on water?

Try placing it in a suitably sized patch of water pathing using SetUnitPosition or whatever the native is called. If it is not amphibious it will displace to the nearby land. If it is then it will remain where you place it. Same can be done with land to test if the unit is naval only.

Also a possible solution but too map-specific like Varimathas' answer.

Check if unit has the Submerge ability.
Not all amphibious units have this ability. E.g. Naga Siren.
 
Level 21
Joined
Feb 6, 2014
Messages
2,468
All right then. Perhaps, you can instead check for terrain pathing, using
  • if not IsTerrainPathable(GetUnitX(udg_GT_Target), GetUnitY(udg_GT_Target), PATHING_TYPE_FLOATABILITY) then
and IsUnitMoving by Bribe.

I don't wanna get things too complicated.
Anyway I managed to solve my original problem. Being able to detect amphibious movement type was sort of a backup plan. I gave rep to all those who helped me.
 
Level 14
Joined
Nov 30, 2007
Messages
1,202
Try placing it in a suitably sized patch of water pathing using SetUnitPosition or whatever the native is called. If it is not amphibious it will displace to the nearby land. If it is then it will remain where you place it. Same can be done with land to test if the unit is naval only.

But why do all those calls when you can just give it a hidden ability? :p
 
Top