Hi,
Im writing a script that should move the target into the air and then slam it to the ground. I thought i could make it work but strange things happen.
First of all, it doesnt work on ground units, only flying units get lifted and slammed to the ground.
second, when i add a line to create a message when the target gets slammed, so after the second loop, the message doesnt appear. Looks like the second loop doenst end.
The effect for the slam will be added later, when it works properly.
I could use some help
Thanks
Im writing a script that should move the target into the air and then slam it to the ground. I thought i could make it work but strange things happen.
JASS:
function slamlift takes nothing returns nothing
local real z2 = GetUnitFlyHeight(udg_slam) + 5.0
call SetUnitFlyHeight(udg_slam,z2,0)
endfunction
function slamdecent takes nothing returns nothing
local real z = GetUnitFlyHeight(udg_slam) - 12.5
call SetUnitFlyHeight(udg_slam,z,0)
endfunction
function Trig_slameactions takes nothing returns nothing
local unit u = GetTriggerUnit()
local timer t = CreateTimer()
local timer t2 = CreateTimer()
local real z2
local real x = (GetUnitX(u) + 300.0)
local real y = (GetUnitY(u) + 300.0)
local real r = 10.0
set udg_slam = GetSpellTargetUnit()
set z2 = GetUnitFlyHeight(udg_slam) + 200.0
// the lift
call TimerStart(t,0.04,true,function slamlift)
loop
exitwhen r >= z2
call TriggerSleepAction(0)
set r = GetUnitFlyHeight(udg_slam) + 10.0
endloop // works decent
call PauseTimer(t)
// the descent
call TimerStart(t2,0.04,true,function slamdecent)
loop
exitwhen r <= 0
call TriggerSleepAction(0)
set r = GetUnitFlyHeight(udg_slam)
endloop // doenst end
call PauseTimer(t2)
call DisplayTimedTextToPlayer(GetOwningPlayer(u),0,0,400,R2S(GetUnitFlyHeight(udg_slam))) // doesnt appear
call DestroyTimer(t2)
call DestroyTimer(t)
set u = null
set t = null
set t2 = null
set udg_slam = null
endfunction
//==== Init Trigger NewTrigger ====
function InitTrig_slam takes nothing returns nothing
set gg_trg_slam = CreateTrigger()
call TriggerRegisterUnitEvent(gg_trg_slam,gg_unit_Udea_0000,EVENT_UNIT_SPELL_CAST)
call TriggerAddAction(gg_trg_slam, function Trig_slameactions)
endfunction
First of all, it doesnt work on ground units, only flying units get lifted and slammed to the ground.
second, when i add a line to create a message when the target gets slammed, so after the second loop, the message doesnt appear. Looks like the second loop doenst end.
The effect for the slam will be added later, when it works properly.
I could use some help
Thanks