Why Wont The Unit Change Its Flying Height?

Frosthowl

TH.net Regular
Reaction score
15
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.

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.
 
From what I see you set data.h to the unit's fly height, then in the timer callback set it to "0 + data.h" which would result in no change. The id for Crow Form is 'Arav', and I'd use that instead of any custom ability (assuming 'CROw' is a custom ability based off of Crow form).
 
It only does that to prevent the unit from hovering slightly when landing on other units. Even when removed it still doesnt work right.

I tried both of your suggestions but nothing worked.
 
Haha. You're setting the fly height at a rate of 0!

You need this to be a large vale. The larger the value, the faster the unit changes flying height. It doesn't move at all if the rate is 0 :p

And at the other times you're using a rate of .3*20 which is 6. That's so slow, you'll never notice it.
 
If the rate is 0.00, it is instant ;).

EDIT:// Lol and it was meant not to be like that. I am using the jumpparabola for jumps.. so it made me confused :(.. Sorry about my existance :(.
 
Ah, that would be it lol, I was thinking that the higher the number, the slower it would be with 0 being instant. Works now, thanks.
 
If the rate is 0.00, it is instant ;).

EDIT:// Lol and it was meant not to be like that. I am using the jumpparabola for jumps.. so it made me confused :(.. Sorry about my existance :(.

There, there, it's okay Ubie baby, it's alright.

Ah, that would be it lol, I was thinking that the higher the number, the slower it would be with 0 being instant. Works now, thanks.

Sure thing. Thanks for the rep, I'm at 199 now :p
Come to think of it, I've been in the 190's forever...and I've released two systems since then.. Oh well, I don't need little boxes to be awesome :D
 
General chit-chat
Help Users

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top