14 years
edited 8 years
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)
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)
1 library GetZ /* v1.0.0.0
2 *******************************************************************3 *4 * This script will provide an interface to retrieve Z-values5 * of points and units without requiring you to deal with6 * locations.7 *8 *******************************************************************9 *10 * function GetPointZ takes real x, real y returns real11 *12 * - Returns the Z-value of a particular point on the terrain.13 *14 * function GetUnitZ takes unit u returns real15 *16 * - Returns the Z-value of a unit.17 * - This will take both terrain height and fly height into18 * account.19 *20 *******************************************************************/21 22 globals23 private location loc = Location(0, 0)
24 endglobals25 26 function GetPointZ takes real x, real y returns real
27 call MoveLocation(loc, x, y)
28 return GetLocationZ(loc)
29 endfunction30 31 function GetUnitZ takes unit u returns real
32 call MoveLocation(loc, GetUnitX(u), GetUnitY(u))
33 return GetLocationZ(loc) + GetUnitFlyHeight(u)
34 endfunction35 36 endlibrary
and now it goes where it belongs