Someone please help me. No matter what I do, the unit will not change its flying height. I even changed the units movement type to flying just to test this.
Edit: Sorry, the spell is a jump spell in which the hero slashes the ground when he lands. Its the last function that has the code for changing the units height.
Code:
struct Aero
unit c
location l
real ux
real uy
real x
real y
real dist
real h
real spd
real ang
endstruct
function Trig_Aeroblade_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'AERO'
endfunction
function Aero_Dmg takes group g, player p, unit c returns nothing
local unit u
loop
set u = FirstOfGroup(g)
exitwhen u == null
call GroupRemoveUnit(g,u)
if IsUnitEnemy(u, p) == true then
call UnitDamageTargetBJ(c, u, 60, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL)
endif
endloop
endfunction
function Aero_Actions takes nothing returns nothing
local timer t = GetExpiredTimer()
local Aero data = GetTimerStructA(t)
local group g
local player p = GetOwningPlayer(data.c)
if data.dist > 0 then
set data.ux = data.ux + data.spd * Cos(data.ang)
set data.uy = data.uy + data.spd * Sin(data.ang)
set data.dist = data.dist - data.spd
call SetUnitPosition(data.c, data.ux, data.uy)
else
//call GetUnitsInRangeOfLocAll(100.00, data.l)
//call Aero_Dmg(g, p, data.c)
call SetUnitTimeScalePercent(data.c, 100)
call PauseUnit(data.c, false)
call SetUnitPathing(data.c, true)
call ResetUnitAnimation(data.c)
call SetUnitFlyHeight(data.c, 0 + data.h, 0)
call RemoveLocation(data.l)
call data.destroy()
call ClearTimerStructA (t)
call PauseTimerBJ(true, t)
call DestroyTimer (t)
endif
endfunction
function Trig_Aeroblade_Actions takes nothing returns nothing
local unit u = GetSpellAbilityUnit()
local location l = GetSpellTargetLoc()
local Aero data = Aero.create()
local timer t = CreateTimer()
set data.l = l
set data.c = u
set data.ux = GetUnitX(u)
set data.uy = GetUnitY(u)
set data.x = GetLocationX(l)
set data.y = GetLocationY(l)
set data.dist = SquareRoot((data.ux - data.x) * (data.ux - data.x) + (data.uy - data.y) * (data.uy - data.y))
set data.h = GetUnitFlyHeight(u)
set data.spd = data.dist/80
set data.ang = Atan2(data.y - data.uy, data.x - data.ux)
call UnitAddAbility(data.c, 'CROw')
call TriggerSleepAction(.01)
//call UnitRemoveAbility(data.c, 'CROw')
call SetTimerStructA(t, data)
call TimerStart(t, .03, true, function Aero_Actions)
call PauseUnit(data.c, true)
call SetUnitAnimationByIndex(data.c, 3)
call SetUnitTimeScalePercent(data.c, 36 )
call SetUnitPathing(data.c, false)
call SetUnitFlyHeightBJ(data.c, 200 + data.h, .3 * 20)
call TriggerSleepAction(.3 * 20)
call SetUnitFlyHeightBJ(data.c, 0 + data.h, .3 * 20)
endfunction
//===========================================================================
function InitTrig_Aeroblade takes nothing returns nothing
set gg_trg_Aeroblade = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Aeroblade, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Aeroblade, Condition( function Trig_Aeroblade_Conditions ) )
call TriggerAddAction( gg_trg_Aeroblade, function Trig_Aeroblade_Actions )
endfunction
Edit: Sorry, the spell is a jump spell in which the hero slashes the ground when he lands. Its the last function that has the code for changing the units height.