vJASS & Zinc Documentation
For the latest documentation about how it works vJASS and Zinc language layers for Warcraft III, please follow these links:
Jasshelper documentation - Zinc documentation - WC3 Optimizer documentation

[Snippet] GetZ

Purgeandfire · 24956

0 Members and 1 Guest are viewing this topic.

Rating

Average Score - 5 / 5

« Created: November 16, 2018, 11:22:24 PM by moyack »

[Snippet] GetZ
on: July 24, 2012, 03:27:36 PM
Category: Geometry
Language: vJASS

A very simple snippet. It allows you to retrieve the Z values of points and units.

Note: Try not to use terrain deformations or abilities that cause terrain deformations (shock wave, war stomp, etc.), or else this may cause a desync. (rare cases, but has been rumored to have happened)

Code: jass
  1. library GetZ /* v1.0.0.0
  2. *******************************************************************
  3. *
  4. *   This script will provide an interface to retrieve Z-values
  5. *   of points and units without requiring you to deal with
  6. *   locations.
  7. *
  8. *******************************************************************
  9. *
  10. *   function GetPointZ takes real x, real y returns real
  11. *
  12. *      -  Returns the Z-value of a particular point on the terrain.
  13. *
  14. *   function GetUnitZ takes unit u returns real
  15. *
  16. *      -  Returns the Z-value of a unit.
  17. *      -  This will take both terrain height and fly height into
  18. *         account.
  19. *
  20. *******************************************************************/
  21.  
  22.     globals
  23.         private location loc = Location(0, 0)
  24.     endglobals
  25.  
  26.     function GetPointZ takes real x, real y returns real
  27.         call MoveLocation(loc, x, y)
  28.         return GetLocationZ(loc)
  29.     endfunction
  30.  
  31.     function GetUnitZ takes unit u returns real
  32.         call MoveLocation(loc, GetUnitX(u), GetUnitY(u))
  33.         return GetLocationZ(loc) + GetUnitFlyHeight(u)
  34.     endfunction
  35.  
  36. endlibrary
« Last Edit: December 19, 2017, 07:43:14 PM by moyack »



Re: [Snippet] GetZ
Reply #1 on: July 24, 2012, 09:38:15 PM

I think it's important to add to the first post the specifications about desyncs for using this technique over dynamic terrain deformations.

But in general It's lovely.


Re: [Snippet] GetZ
Reply #2 on: July 24, 2012, 11:53:18 PM

Added the note. Thanks!



Re: [Snippet] GetZ
Reply #3 on: July 25, 2012, 11:02:49 PM

Perfect :) and now it goes where it belongs :)


Re: [Snippet] GetZ
Reply #4 on: August 02, 2012, 12:19:47 PM

If i believe people (can be easily tested anyway) GetLocationZ can return a different value with walkable destructables with animations.
It's a fact that animations are not synced, they are even not played at all if you don't have the view on it.
So, no need to GetLocalPlayer to have different values on different computers.

That's probably the same with spell animations like shockwave (again it's easy to test, one player is enough)

vJass is already a jass preprocessor, no need to (ab)use vJass features in order to make some inferior vJass preprocessor coded "by hand".


Re: [Snippet] GetZ
Reply #5 on: August 02, 2012, 07:34:03 PM

I remember having animations not synced, and it was an annoying issue when it came to map making. However, I reopened the editor today and tested my old maps and I couldn't reproduce the problem.

I made a blank map and made archimonde cast his spell slam when I hit esc. When I tested it, I took my camera to the edge of the map (archimonde not in sight) then I pressed esc, and then brought my camera to him and it still played the animation. I tested this a few times with the same results.

So... did blizzard fix this problem in some patch? I am using 1.26, and unless I ran the tests wrong, it seems like they are played just fine. But idk.



Re: Re: [Snippet] GetZ
Reply #6 on: August 02, 2012, 09:26:01 PM

I remember having animations not synced, and it was an annoying issue when it came to map making. However, I reopened the editor today and tested my old maps and I couldn't reproduce the problem.

I made a blank map and made archimonde cast his spell slam when I hit esc. When I tested it, I took my camera to the edge of the map (archimonde not in sight) then I pressed esc, and then brought my camera to him and it still played the animation. I tested this a few times with the same results.

So... did blizzard fix this problem in some patch? I am using 1.26, and unless I ran the tests wrong, it seems like they are played just fine. But idk.

Well, that was not my point.

Display the Z of the same point on the spell area effect over time, and check if it changes while you have not the view on it or if it doesn't.

vJass is already a jass preprocessor, no need to (ab)use vJass features in order to make some inferior vJass preprocessor coded "by hand".


Re: [Snippet] GetZ
Reply #7 on: August 02, 2012, 09:54:40 PM

Okay. I made a tauren chieftain, gave him shockwave, and made him cast it upon pressing ESC. I had another trigger read the Z values of the point he cast it on periodically.

I first had my camera on him, then I cast it and it read 0.00 several times, then read -0.287 or w/e then reverted back to 0.00.

Then I moved my camera away, made him cast, and had the same results (it read 0.00, then -0.287 a few times, then 0.00 again)

I don't know if those results are true for all patches, but I can confirm that those are the results from patch 1.26. That means that even if it is not in view, it will still perform the animations/deformation. I haven't tested it extensively, but w/e.



Re: [Snippet] GetZ
Reply #8 on: August 03, 2012, 10:18:58 AM

Ok, and what about walkable destructables with animations ? (if you care to test it)

vJass is already a jass preprocessor, no need to (ab)use vJass features in order to make some inferior vJass preprocessor coded "by hand".


Re: [Snippet] GetZ
Reply #9 on: September 21, 2012, 03:56:53 PM

I'm just wondering what happens if you use coordinates which are outside the whole map (GetWorldBounds).
You could add some debug stuff in GetPointZ if it crash wc3 (in debug mode or not).

Same for GetUnitZ, it shouldn't crash with an invalid unit, but it should return the Z of the Location(0,0) and not just 0, now again maybe some debug stuff is unecessary.

Note that here i'm only guessing, tests are needed.

At least i think that it should be mentionned by some comments.

vJass is already a jass preprocessor, no need to (ab)use vJass features in order to make some inferior vJass preprocessor coded "by hand".


Re: [Snippet] GetZ
Reply #10 on: September 21, 2012, 04:59:21 PM

I'll check it out soon and report back with results/details.



Re: [Snippet] GetZ
Reply #11 on: November 13, 2012, 01:18:46 PM

I'll check it out soon and report back with results/details.

I see that you've the same meaning than mine for "soon" :p

vJass is already a jass preprocessor, no need to (ab)use vJass features in order to make some inferior vJass preprocessor coded "by hand".


Re: [Snippet] GetZ
Reply #12 on: November 13, 2012, 10:35:06 PM

Lol yeah



 

Chaos Realm - The world of Game modders and wc3 addicts     WC3JASS.com - The JASS Vault   Jetcraft - A Starcraft II mod