TriggerHappy
...
- Reaction score
- 341
SetUnitZ
TriggerHappy187
Why?
SetUnitFlyHeight native only sets the units flying height, not the height compared to the to terrain level. This fixes that.
This can be usefull for spells that use effects, where a dummy has a fixed height. Or even projectile systems.
Anyways, I needed this for my Object System, and after looking at this thread, I decided to make it.
Code
JASS:
//***************************************************************************
//*
//* SetUnitZ - By TriggerHappy187
//*
//***************************************************************************
//*
//* Installation
//* * All you need to do is copy this script into your map and you can use
//* the provided functions.
//*
//***************************************************************************
//*
//* Requirements
//* * This requires no external systems, all it requires is JassHelper.
//*
//***************************************************************************
//
// Precautions
// * If this function is used on a point with a terarin deformation
// A desync may occur.
//
//***************************************************************************
library SetUnitZ
globals
private location heightFixer = Location(0,0)
endglobals
function SetUnitZ takes unit whichUnit, real height, real rate returns nothing
if GetUnitFlyHeight(whichUnit) == 0 then
if UnitAddAbility(whichUnit, 039;Arav039;) then
call UnitRemoveAbility(whichUnit, 039;Arav039;)
endif
endif
call MoveLocation(heightFixer, GetUnitX(whichUnit), GetUnitY(whichUnit))
call SetUnitFlyHeight(whichUnit, height-GetLocationZ(heightFixer), rate)
endfunction
function GetUnitZ takes unit whichUnit returns real
call MoveLocation(heightFixer, GetUnitX(whichUnit), GetUnitY(whichUnit))
return GetUnitFlyHeight(whichUnit)-GetLocationZ(heightFixer)
endfunction
function GetCoordZ takes real x, real y returns real
call MoveLocation(heightFixer, x, y)
return GetLocationZ(heightFixer)
endfunction
endlibrary