• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

GetUnitLoc

Status
Not open for further replies.
You can alternatively use this:
http://wc3jass.com/4981/snippet-getz/msg38689/topicseen/#new

JASS:
library GetZ /* v1.0.0.0
*******************************************************************
*
*   This script will provide an interface to retrieve Z-values
*   of points and units without requiring you to deal with
*   locations.
*
*******************************************************************
*
*   function GetPointZ takes real x, real y returns real
*
*      -  Returns the Z-value of a particular point on the terrain.
*
*   function GetUnitZ takes unit u returns real
*
*      -  Returns the Z-value of a unit.
*      -  This will take both terrain height and fly height into
*         account.
*
*******************************************************************/

    globals
        private location loc = Location(0, 0)
    endglobals

    function GetPointZ takes real x, real y returns real
	    call MoveLocation(loc, x, y)
	    return GetLocationZ(loc)
    endfunction

    function GetUnitZ takes unit u returns real
	    call MoveLocation(loc, GetUnitX(u), GetUnitY(u))
	    return GetLocationZ(loc) + GetUnitFlyHeight(u)
    endfunction

endlibrary

@mckill: You have to account for the unit's flying height as well as the location z.
 
Status
Not open for further replies.
Top