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

[JASS] Detect the actual Z value of the ground even under water

Not open for further replies.
Level 26
Feb 2, 2006
Is it really not possible to detect the actual Z value of the seabed below water?

I have already found these threads about this topic:
and there is no solution mentioned. I do not want to go with a fake water surface and flying units since I think that some of Warcraft's functionality will get lost like standard spells as Submerge or the floating units etc. I think that swimming units also add some water effect by default etc. and Warcraft's water might have some additional stuff which I don't know of yet and which might be hard to reproduce.

In this post there is a system mentioned which should return the correct camera offset for every location on the map. It seems to scan the map initially and somehow calculate the correct Z value: [General] - How to make water deeper?
However, this system did not work for under water locations. It works with GetLocationZ() and this function does not return any different Z value if there is a cliff under water.
In my map I have created a rather deep ocean and if I move the camera under water it will automatically get higher on locations where tehre is a cliff under water but GetLocationZ will always return the same value (maybe the one of the water surface?!), so Warcraft's camera system seems to know that there is a cliff but somehow GetLocationZ has special treatment for water areas?

I can only think of these two solutions:
  • Manually add Z offsets for rects where there are cliffs under water: Really much work to do.
  • Somehow move the camera on all locations of the map and get the actual Z value by using some absolute Z value function for the camera height if there is any (I don't know this yet).
I need the exact Z value since I want to have a fixed camera height under water and detect cliffs which are higher than the submerged unit, so it cannot move forward anymore.
Blockers are no option since they will block units above the water!

Here is a screenshot of my map, so you can get a better understanding of the issue (the under water cliffs in the distance should return a different Z than the current location but they don't!):

Level 21
Mar 29, 2020
I'm not exactly sure if this will help, but maybe worth a shot - from what I have seen, when you remove a units collision, it will always walk on the seabed (or lowest available terrain).

maybe you can use a dummy unit with no collision as a height detector.
Pretty interesting problem. I don't know of any trick to bypass the weird water limitations--imo it'd be best to write a script to process the w3x and compute the height of the terrain at each 32x32 tile (or more/less granular, depending on how you accurate you need it to be). Then dump those results into an array or hashtable.
Not open for further replies.