- Joined
- Jul 20, 2009
- Messages
- 835
I have a spell. It creates 5 + lvl dummies facing target point + Random real between -15 and 15. So, I see that all the dummies are created but they aren't moving... How to fix that pesky trouble? Here is the code:
JASS:
function call_grave_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 0x4130355A
endfunction
function Call_Grave_Part3 takes nothing returns nothing
local timer t = GetExpiredTimer()
local timer t2 = LoadTimerHandle(udg_Hashtable,GetHandleId(t),0)
call FlushChildHashtable(udg_Hashtable,GetHandleId(t))
call PauseTimer(t2)
call DestroyTimer(t2)
call DestroyTimer(t)
set t2 = null
set t = null
endfunction
function Call_Grave_Part2 takes nothing returns nothing
local timer t = GetExpiredTimer()
local timer t2 = CreateTimer()
local timer per = LoadTimerHandle(udg_Hashtable,GetHandleId(t),0)
local unit caster = LoadUnitHandle(udg_Hashtable,GetHandleId(t),1)
call SaveTimerHandle(udg_Hashtable,GetHandleId(t2),0,per)
call SetUnitAnimation(caster,"stand")
call TimerStart(t2,1.8,false,function Call_Grave_Part3)
call FlushChildHashtable(udg_Hashtable,GetHandleId(t))
call DestroyTimer(t)
set per = null
set caster = null
set t = null
endfunction
function callgravedamage takes nothing returns nothing
local unit e = GetEnumUnit()
local timer t = GetExpiredTimer()
local unit caster = LoadUnitHandle(udg_Hashtable,GetHandleId(t),20)
local unit dummy = LoadUnitHandle(udg_Hashtable,GetHandleId(t),21)
local integer lvl = GetUnitAbilityLevel(caster,0x4130355A)
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Undead\\DeathandDecay\\DeathandDecayTarget.mdl",e,"overhead"))
call UnitDamageTarget(caster,e,lvl - 1 * 20 + GetRandomReal(30,60),true,true,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_DIVINE,WEAPON_TYPE_WHOKNOWS)
call RemoveUnit(dummy)
set e = null
set t = null
set caster = null
set dummy = null
endfunction
function GraveUltFilt takes nothing returns boolean
local timer t = GetExpiredTimer()
local unit caster = LoadUnitHandle(udg_Hashtable,GetHandleId(t),20)
local unit f = GetFilterUnit()
if IsUnitType(f,UNIT_TYPE_STRUCTURE) == false and IsUnitEnemy(f,GetOwningPlayer(caster)) and GetUnitState(f,UNIT_STATE_LIFE) > 0 then
set t = null
set f = null
set caster = null
return true
endif
set t = null
set f = null
set caster = null
return false
endfunction
function Call_Grave_Movedummy takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit u
local real a
local unit caster = LoadUnitHandle(udg_Hashtable,GetHandleId(t),20)
local integer i2 = 5 + GetUnitAbilityLevel(caster,0x4130355A)
local real x
local real y
local integer i = 1
local group g = CreateGroup()
loop
exitwhen i > i2
set u = LoadUnitHandle(udg_Hashtable,GetHandleId(t),i)
set a = LoadReal(udg_Hashtable,GetHandleId(t),10 + i)
set x = GetUnitX(u)
set y = GetUnitY(u)
call SetUnitX(u,x + 35 * Cos(a * 0.0174532))
call SetUnitY(u,y + 35 * Sin(a * 0.0174532))
if x >= udg_MaxX then
call SetUnitX(u,udg_MaxX)
endif
if x <= udg_MinX then
call SetUnitX(u,udg_MinX)
endif
if y >= udg_MaxY then
call SetUnitY(u,udg_MaxY)
endif
if y <= udg_MinY then
call SetUnitY(u,udg_MinY)
endif
call SaveUnitHandle(udg_Hashtable,GetHandleId(t),21,u)
call GroupEnumUnitsInRange(g,x,y,100,Filter(function GraveUltFilt))
call ForGroup(g,function callgravedamage)
call GroupClear(g)
call DestroyGroup(g)
set u = null
set i = i + 1
endloop
set g = null
set caster = null
set t = null
endfunction
function Call_Grave_DummyCreate takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer i = LoadInteger(udg_Hashtable,GetHandleId(t),10)
local integer i2 = LoadInteger(udg_Hashtable,GetHandleId(t),11)
local integer i3 = 1
local unit caster = LoadUnitHandle(udg_Hashtable,GetHandleId(t),12)
local real a = LoadReal(udg_Hashtable,GetHandleId(t),13) + GetRandomReal(-15,15)
local unit u
local timer t2
local timer t3
if i != i2 then
set u = CreateUnit(GetOwningPlayer(caster),0x6E303030,GetUnitX(caster),GetUnitY(caster),270)
call UnitApplyTimedLife(u,0x42544C46,1.7)
call SaveUnitHandle(udg_Hashtable,GetHandleId(t),i,u)
call SaveReal(udg_Hashtable,GetHandleId(t),14 + i,a)
call SaveInteger(udg_Hashtable,GetHandleId(t),10,i + 1)
else
set t2 = CreateTimer()
set t3 = CreateTimer()
loop
exitwhen i3 > i2
call SaveUnitHandle(udg_Hashtable,GetHandleId(t2),i3,LoadUnitHandle(udg_Hashtable,GetHandleId(t),i3))
call SaveReal(udg_Hashtable,GetHandleId(t2),10 + i3,LoadReal(udg_Hashtable,GetHandleId(t),14 + i3))
set i3 = i3 + 1
endloop
call SaveTimerHandle(udg_Hashtable,GetHandleId(t3),0,t2)
call SaveUnitHandle(udg_Hashtable,GetHandleId(t3),1,caster)
call SaveUnitHandle(udg_Hashtable,GetHandleId(t2),20,caster)
call TimerStart(t2,0.05,true,function Call_Grave_Movedummy)
call TimerStart(t3,0.2 * i2 - 5 + 1.2,false,function Call_Grave_Part2)
call FlushChildHashtable(udg_Hashtable,GetHandleId(t))
call PauseTimer(t)
call DestroyTimer(t)
set t2 = null
endif
set caster = null
set u = null
set t = null
endfunction
function call_grave_Actions takes nothing returns nothing
local unit caster = GetTriggerUnit()
local integer lvl = GetUnitAbilityLevel(caster,0x4130355A)
local real ux = GetUnitX(caster)
local real uy = GetUnitY(caster)
local real tx = GetSpellTargetX()
local real ty = GetSpellTargetY()
local real a = 57.295827 * Atan2(ty - uy,tx - ux)
local timer t = CreateTimer()
if udg_Hashtable == null then
set udg_Hashtable = InitHashtable()
endif
call SaveInteger(udg_Hashtable,GetHandleId(t),10,5 + lvl)
call SaveInteger(udg_Hashtable,GetHandleId(t),11,1)
call SaveUnitHandle(udg_Hashtable,GetHandleId(t),12,caster)
call SaveReal(udg_Hashtable,GetHandleId(t),13,a)
call TimerStart(t,0.2,true,function Call_Grave_DummyCreate)
set caster = null
set t = null
endfunction
//===========================================================================
function InitTrig_call_grave takes nothing returns nothing
set gg_trg_call_grave = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(gg_trg_call_grave,EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(gg_trg_call_grave,Condition(function call_grave_Conditions))
call TriggerAddAction(gg_trg_call_grave,function call_grave_Actions)
endfunction