Warcraft III: MapsModelsSkinsIconsSpellsToolsTutorials
WC3 JASS: Code SnippetsJASS and vJASS Spells and SystemsJass Tutorials
Chat @Discord

Author Topic: [Snippet] GetZ  (Read 22023 times)

  • Rookie - level 1
  • *
  • Posts: 41
  • WC3 Models: 0
  • WC3 Tutorials: 0
  • WC3 Tools: 0
  • WC3 Maps: 0
  • WC3 Skins: 0
  • WC3 Icons: 0
  • WC3 Spells: 0
  • Reputation: 13
    • View Profile
[Snippet] GetZ
« on: July 24, 2012, 03:27:36 PM »
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  [Select]
  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: July 24, 2012, 11:53:00 PM by Purgeandfire »

  • Site Owner
  • Administrator
  • Starter - level 4
  • *
  • Posts: 981
  • WC3 Models: 5
  • WC3 Tutorials: 11
  • WC3 Tools: 10
  • WC3 Maps: 11
  • WC3 Skins: 6
  • WC3 Icons: 2
  • WC3 Spells: 5
  • Reputation: 1153
  • Site Admin - I love fix things
    • View Profile
    • Blizzard Modding Information Center
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.

We can give you full hosting for your projects, a complete page!!

A custom altered melee map where you can play Naga and Demons. Check it out!!
Use Dropbox...

  • Rookie - level 1
  • *
  • Posts: 41
  • WC3 Models: 0
  • WC3 Tutorials: 0
  • WC3 Tools: 0
  • WC3 Maps: 0
  • WC3 Skins: 0
  • WC3 Icons: 0
  • WC3 Spells: 0
  • Reputation: 13
    • View Profile
Re: [Snippet] GetZ
« Reply #2 on: July 24, 2012, 11:53:18 PM »
Added the note. Thanks!

  • Site Owner
  • Administrator
  • Starter - level 4
  • *
  • Posts: 981
  • WC3 Models: 5
  • WC3 Tutorials: 11
  • WC3 Tools: 10
  • WC3 Maps: 11
  • WC3 Skins: 6
  • WC3 Icons: 2
  • WC3 Spells: 5
  • Reputation: 1153
  • Site Admin - I love fix things
    • View Profile
    • Blizzard Modding Information Center
Re: [Snippet] GetZ
« Reply #3 on: July 25, 2012, 11:02:49 PM »
Perfect :) and now it goes where it belongs :)

We can give you full hosting for your projects, a complete page!!

A custom altered melee map where you can play Naga and Demons. Check it out!!
Use Dropbox...

  • Rookie - level 1
  • *
  • Posts: 48
  • WC3 Models: 0
  • WC3 Tutorials: 0
  • WC3 Tools: 0
  • WC3 Maps: 0
  • WC3 Skins: 0
  • WC3 Icons: 0
  • WC3 Spells: 0
  • Reputation: 8
  • cool != useful
    • View Profile
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".

  • Rookie - level 1
  • *
  • Posts: 41
  • WC3 Models: 0
  • WC3 Tutorials: 0
  • WC3 Tools: 0
  • WC3 Maps: 0
  • WC3 Skins: 0
  • WC3 Icons: 0
  • WC3 Spells: 0
  • Reputation: 13
    • View Profile
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.

  • Rookie - level 1
  • *
  • Posts: 48
  • WC3 Models: 0
  • WC3 Tutorials: 0
  • WC3 Tools: 0
  • WC3 Maps: 0
  • WC3 Skins: 0
  • WC3 Icons: 0
  • WC3 Spells: 0
  • Reputation: 8
  • cool != useful
    • View Profile
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".

  • Rookie - level 1
  • *
  • Posts: 41
  • WC3 Models: 0
  • WC3 Tutorials: 0
  • WC3 Tools: 0
  • WC3 Maps: 0
  • WC3 Skins: 0
  • WC3 Icons: 0
  • WC3 Spells: 0
  • Reputation: 13
    • View Profile
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.

  • Rookie - level 1
  • *
  • Posts: 48
  • WC3 Models: 0
  • WC3 Tutorials: 0
  • WC3 Tools: 0
  • WC3 Maps: 0
  • WC3 Skins: 0
  • WC3 Icons: 0
  • WC3 Spells: 0
  • Reputation: 8
  • cool != useful
    • View Profile
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".

  • Rookie - level 1
  • *
  • Posts: 48
  • WC3 Models: 0
  • WC3 Tutorials: 0
  • WC3 Tools: 0
  • WC3 Maps: 0
  • WC3 Skins: 0
  • WC3 Icons: 0
  • WC3 Spells: 0
  • Reputation: 8
  • cool != useful
    • View Profile
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".

  • Rookie - level 1
  • *
  • Posts: 41
  • WC3 Models: 0
  • WC3 Tutorials: 0
  • WC3 Tools: 0
  • WC3 Maps: 0
  • WC3 Skins: 0
  • WC3 Icons: 0
  • WC3 Spells: 0
  • Reputation: 13
    • View Profile
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.

  • Rookie - level 1
  • *
  • Posts: 48
  • WC3 Models: 0
  • WC3 Tutorials: 0
  • WC3 Tools: 0
  • WC3 Maps: 0
  • WC3 Skins: 0
  • WC3 Icons: 0
  • WC3 Spells: 0
  • Reputation: 8
  • cool != useful
    • View Profile
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".

  • Rookie - level 1
  • *
  • Posts: 41
  • WC3 Models: 0
  • WC3 Tutorials: 0
  • WC3 Tools: 0
  • WC3 Maps: 0
  • WC3 Skins: 0
  • WC3 Icons: 0
  • WC3 Spells: 0
  • Reputation: 13
    • View Profile
Re: [Snippet] GetZ
« Reply #12 on: November 13, 2012, 10:35:06 PM »
Lol yeah

 

[Snippet] Group Units in line, with distance and optional spread-value

Started by rvonsonsnadtzBoard Codes & Snippets

Replies: 5
Views: 11447
Last post March 13, 2013, 06:52:16 PM
by rvonsonsnadtz
[Snippet] Single Player Detector

Started by moyackBoard Codes & Snippets

Replies: 12
Views: 21008
Last post March 13, 2013, 12:48:49 PM
by Magtheridon96
[Snippet] Simple Unit Indexer

Started by moyackBoard Codes & Snippets

Replies: 17
Views: 25829
Last post September 30, 2013, 08:07:19 AM
by moyack
[Snippet] Disable Transmission Skip

Started by PurgeandfireBoard Codes & Snippets

Replies: 2
Views: 8730
Last post July 02, 2013, 01:34:55 PM
by Purgeandfire
[Snippet] Timed Effects

Started by moyackBoard Codes & Snippets

Replies: 0
Views: 7398
Last post January 09, 2012, 07:03:32 PM
by moyack
Blizzard Modding Information Center Starcraft II Modding Information Center Wacraft III Modding Information Center WC3JASS.com - The JASS Vault Chronicles of Darkness - A Warcraft III mod Jetcraft - A Starcraft II mod Troll Smash - A Warcraft III Arena
  Mod DB - Change the Game Power of Corruption - A Warcraft III altered melee map Chaos Realm - The world of Game modders and wc3 addicts Follow us on Facebook!!