Snippet GetTerrainZ

D.V.D

Make a wish
Reaction score
73
I don't know if this was posted before but here's a little snippet that gets the TerrainZ in location of your choice.

Code:

JASS:
library GetTerrainZ

// How to Implement:
//
// Copy this code
// Create a trigger in your map
// Change the trigger to custom script
// Paste the code into the trigger

globals
    location GL = Location(0,0)
endglobals

function GetTerrainZ takes real x, real y returns real
    call MoveLocation(GL, x, y)
    return GetLocationZ(GL)
endfunction

function GetTerrainZLoc takes location loc returns real
    call MoveLocation(GL, GetLocationX(loc), GetLocationY(loc))
    return GetLocationZ(GL)
endfunction

endlibrary
 

D.V.D

Make a wish
Reaction score
73
Yea I'll make one.

EDIT: I don't see the reason why locations are bad. Its either location or a unit and I think Locations are much more effiecient than creating a unit and stuff.
 

Romek

Super Moderator
Reaction score
964
This is as bad as submitting H2I as a snippet.

Besides, GL should be private.

GY'd
 

Jesus4Lyf

Good Idea™
Reaction score
397
No no no, wait. Stop.

This got GY'd before someone got to slap him for writing
JASS:
function GetTerrainZLoc takes location loc returns real
    call MoveLocation(GL, GetLocationX(loc), GetLocationY(loc))
    return GetLocationZ(GL)
endfunction

which could just be the native, GetLocationZ?

THAT'S FUNNY!...

Like, if that's useful, then the other code should be:
JASS:
function GetTerrainZ takes real x, real y returns real
    call MoveLocation(GL, x, y)
    return GetTerrainZLoc(GL)
endfunction

Lol! Now we can move the same location twice! Hey, let's change the other one now...
JASS:
function GetTerrainZLoc takes location loc returns real
    call MoveLocation(GL, GetLocationX(loc), GetLocationY(loc))
    return GetTerrainZ.evaluate(GetLocationX(GL), GetLocationY(GL))
endfunction

LOOK! I MADE SOMETHING SO USELESS THE NATIVE DISAPPEARS! XD
 

Steel

Software Engineer
Reaction score
109
GetLocationZ has been known to cause desyncs, don't use it unless you know what you're doing.
 

D.V.D

Make a wish
Reaction score
73
This is as bad as submitting H2I as a snippet.

Besides, GL should be private.

GY'd

How is this so bad? I could find many reasons why people would use this. Atleast tell me why its bad.

No no no, wait. Stop.

This got GY'd before someone got to slap him for writing
JASS:
function GetTerrainZLoc takes location loc returns real
    call MoveLocation(GL, GetLocationX(loc), GetLocationY(loc))
    return GetLocationZ(GL)
endfunction

which could just be the native, GetLocationZ?

THAT'S FUNNY!...

Like, if that's useful, then the other code should be:
JASS:
function GetTerrainZ takes real x, real y returns real
    call MoveLocation(GL, x, y)
    return GetTerrainZLoc(GL)
endfunction

Lol! Now we can move the same location twice! Hey, let's change the other one now...
JASS:
function GetTerrainZLoc takes location loc returns real
    call MoveLocation(GL, GetLocationX(loc), GetLocationY(loc))
    return GetTerrainZ.evaluate(GetLocationX(GL), GetLocationY(GL))
endfunction

LOOK! I MADE SOMETHING SO USELESS THE NATIVE DISAPPEARS! XD

If you find it useful, don't bitch about it.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top