• 🏆 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!

Detect if unit is amphibious

Status
Not open for further replies.

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,230
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 23
Joined
Feb 6, 2014
Messages
2,466
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 23
Joined
Feb 6, 2014
Messages
2,466
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 15
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
 
Status
Not open for further replies.
Top