Hi all,
I have a problem with SetUnitFlyHeight
In the function Arrow_Actions I create a unit (data.dummy) and then i change it's height to 80.0 + height of caster unit. (if caster is for example jumping it's height is not 0.0 so in this way it'll create the unit in front of him)
But nothing happens and the unit creates at height 0 even if the message shows the real height.
I've checked it with a simple trigger in order to see if it was a unit issue but it worked perfectly.
I'm confused :S
I have a problem with SetUnitFlyHeight
JASS:
scope ArrowSystem initializer Init
globals
private constant integer CROW = 'Amrf'
private constant integer dummyID = 'h006'
private constant integer SpellID = 'A002'
private constant real FAR = 800.
private constant real PERIOD = 0.01
private constant real RANGE = 20
private constant real SPEED = 8
endglobals
private struct ArrowSystemStruct
location target
unit caster
unit dummy
timer duration
boolean TimerBooOk
method onDestroy takes nothing returns nothing
set .target = null
set .caster = null
set .dummy = null
call ReleaseTimer(.duration)
endmethod
static method Move takes nothing returns nothing
local ArrowSystemStruct data = GetTimerData(GetExpiredTimer())
local unit caster = data.caster
local location dummyLoc = GetUnitLoc(data.dummy)
local real height = GetLocationZ(dummyLoc)
local real flyHeight = GetUnitFlyHeight(data.dummy)
local real angle = AngleBetweenPoints(dummyLoc, data.target)
local location newLoc
local location casterLoc = GetUnitLoc(data.caster)
if (data.TimerBooOk == FALSE) then
set newLoc = PolarProjectionBJ(dummyLoc,SPEED,angle)
set flyHeight = (flyHeight - 0.001)
call SetUnitFlyHeight(data.dummy, flyHeight - height, 0.00)
call SetUnitPositionLocFacingBJ(data.dummy,newLoc,angle)
endif
if (DistanceBetweenPoints(dummyLoc, data.target) < RANGE)and (data.TimerBooOk == FALSE) then
set data.TimerBooOk = TRUE
endif
if (data.TimerBooOk == TRUE) then
call RemoveUnit(data.dummy)
call data.destroy()
endif
call RemoveLocation(dummyLoc)
call RemoveLocation(GetUnitLoc(caster))
call RemoveLocation(casterLoc)
set caster = null
set data = 0
endmethod
endstruct
private function Arrow_Actions takes nothing returns nothing
local ArrowSystemStruct data = ArrowSystemStruct.create()
local location casterLoc = GetUnitLoc(GetTriggerUnit())
local real height
local real face
set data.TimerBooOk = FALSE
set data.caster = GetTriggerUnit()
set height = GetUnitFlyHeight(data.caster)
set face = GetUnitFacing(data.caster)
set data.target = PolarProjectionBJ(casterLoc, FAR, face)
set data.duration = NewTimer()
set data.dummy = CreateUnitAtLoc(GetOwningPlayer(data.caster ), dummyID, PolarProjectionBJ(casterLoc,10, face), face)
call SetUnitFlyHeight(data.dummy, height + 80., 0.00)
call DisplayTextToForce( GetPlayersAll(), ( R2S(GetUnitFlyHeight(data.dummy) ) ) )
call DisplayTextToForce( GetPlayersAll(), ( R2S(GetUnitFlyHeight(data.caster) ) ) )
call SetUnitPathing(data.dummy, false)
call SetTimerData(data.duration ,data)
call TimerStart(data.duration , PERIOD, true, function ArrowSystemStruct.Move)
call RemoveLocation(casterLoc)
set data = 0
endfunction
function Arrow_Conditions takes nothing returns boolean
if (GetSpellAbilityId() == SpellID) then
call Arrow_Actions()
endif
return false
endfunction
//===========================================================================
function Init takes nothing returns nothing
local trigger t1 = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( t1, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( t1, Condition( function Arrow_Conditions ) )
endfunction
endscope
In the function Arrow_Actions I create a unit (data.dummy) and then i change it's height to 80.0 + height of caster unit. (if caster is for example jumping it's height is not 0.0 so in this way it'll create the unit in front of him)
But nothing happens and the unit creates at height 0 even if the message shows the real height.
JASS:
call DisplayTextToForce( GetPlayersAll(), ( R2S(GetUnitFlyHeight(data.dummy) ) ) )
I've checked it with a simple trigger in order to see if it was a unit issue but it worked perfectly.
I'm confused :S