- Joined
- Apr 30, 2011
- Messages
- 359
JASS:
//========================================================================================
//
// GetPointZ
// -*- overcold_ice -*-
//
// -[*] Requirements:
// - JNGP
// - latest version of JassHelper
//
// -[*] API:
//
// function GetPointZ takes real x, real y returns real
// returns the terrain z value of point [x, y]
//
//========================================================================================
library GetPointZ
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
endlibrary
JASS:
//========================================================================================
//
// UnitZ
// -*- overcold_ice -*-
//
// -[*] Requirements:
// - JNGP
// - latest version of JassHelper
//
// -[*] Optional Requirements:
// - AutoFly
// http://www.hiveworkshop.com/forums/jass-resources-412/snippet-autofly-unitindexer-version-195563/
// - GetPointZ
//
// Adds the real UnitZ functions (not UnitFlyHeight)
//
// -[*] API:
//
// function GetUnitZ takes unit u returns real
// returns the terrain z value of point [ux, uy] + its FlyHeight
// function SetUnitZ takes unit u, real z returns nothing
// sets the unit's FlyHeight to (z - ground z at [ux, uy])
//
//========================================================================================
library UnitZ requires optional AutoFly, optional GetPointZ
globals
private location _loc = Location(0, 0)
endglobals
function GetUnitZ takes unit u returns real
static if not LIBRARY_GetPointZ then
call MoveLocation(_loc, x, y)
return GetLocationZ(_loc) + GetUnitFlyHeight(u)
else
return GetPointZ(GetUnitX(u), GetUnitY(u)) + GetUnitFlyHeight(u)
endif
endfunction
function SetUnitZ takes unit u, real z returns nothing
static if not LIBRARY_AutoFly then
if UnitAddAbility(u, 'Amrf') and UnitRemoveAbility(u, 'Amrf') then
endif
endif
static if not LIBRARY_GetPointZ then
call MoveLocation(_loc, GetUnitX(u), GetUnitY(u))
call SetUnitFlyHeight(u, z - GetLocationZ(_loc), 0)
else
call SetUnitFlyHeight(u, z - GetPointZ(GetUnitX(u), GetUnitY(u)), 0)
endif
endfunction
endlibrary
Last edited: