- Joined
- Feb 23, 2007
- Messages
- 1,030
JASS:
function GraveCallingSpell takes nothing returns boolean
return GetSpellAbilityId() == 'A01X'
endfunction
function GraveCallingFilter takes nothing returns boolean
return IsUnitType(GetFilterUnit(), UNIT_TYPE_ANCIENT)==false and IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE)==false and GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE)>.4
endfunction
function GraveCallingTimer takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer p = GetHandleInt(t,"p")
local integer lvl = GetHandleInt(t,"lvl")
local integer c = GetHandleInt(t,"c")
local integer z = GetHandleInt(t,"z")
local unit array u
local integer a
local real x1
local real y1
local real x2
local real y2
local real d
call SetHandleInt(t,"z",z+1)
loop
exitwhen a>c
set u[a] = GetHandleUnit(t,"unit"+I2S(a))
if GetUnitState(u[a], UNIT_STATE_LIFE)<.4 and GetUnitTypeId(u[a]) != Zombie1() and GetUnitTypeId(u[a]) != Zombie2() and GetUnitTypeId(u[a]) != Zombie3() and GetUnitTypeId(u[a]) != Zombie4() and GetUnitTypeId(u[a]) != Zombie5() then
if lvl == 1 then
set u[a] = CreateUnit(Player(p),Zombie1(),GetUnitX(u[a]),GetUnitY(u[a]),270)
elseif lvl == 2 then
set u[a] = CreateUnit(Player(p),Zombie2(),GetUnitX(u[a]),GetUnitY(u[a]),270)
elseif lvl == 3 then
set u[a] = CreateUnit(Player(p),Zombie3(),GetUnitX(u[a]),GetUnitY(u[a]),270)
elseif lvl == 4 then
set u[a] = CreateUnit(Player(p),Zombie4(),GetUnitX(u[a]),GetUnitY(u[a]),270)
elseif lvl == 5 then
set u[a] = CreateUnit(Player(p),Zombie5(),GetUnitX(u[a]),GetUnitY(u[a]),270)
endif
call UnitAddAbility(u[a],'A01Y')
call SetHandleHandle(t,"unit"+I2S(a),u[a])
endif
set x1 = x1+GetUnitX(u[a])
set y1 = y1+GetUnitY(u[a])
set a = a+1
endloop
set a = 0
set x2 = x1/c
set y2 = y1/c
loop
exitwhen a>c
set x1 = GetUnitX(u[a])
set y1 = GetUnitY(u[a])
call SetUnitAbilityLevel(u[a],'A01Y',IMaxBJ(R2I(SquareRoot((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)))/50,20))
set a = a+1
endloop
set a = 0
if z == 6 then
call DisplayTextToPlayer(Player(p),0,0,"THIS SUCKS AT LIFE")
call DestroyLightning(GetHandleLightning(t,"l0"))
loop
exitwhen a>c
call DestroyLightning(GetHandleLightning(t,"l"+I2S(a)))
set a = a+1
endloop
elseif z == 200 then
call DisplayTextToPlayer(Player(p),0,0,"THIS SUCKS AT LIFE")
loop
exitwhen a>c
call UnitRemoveAbilityBJ('A01Y',u[a])
set u[a] = null
set a = a+1
endloop
call FlushHandleLocals(t)
call PauseTimer(t)
call DestroyTimer(t)
endif
set t = null
endfunction
function GraveCallingActions takes nothing returns nothing
local unit u = GetTriggerUnit()
local unit w = GetSpellTargetUnit()
local real x = GetUnitX(w)
local real y = GetUnitY(w)
local group g = CreateGroup()
local timer t = CreateTimer()
local integer c = 1
local unit q
local lightning l
call GroupEnumUnitsInRange(g, x, y, 500, Condition(function GraveCallingFilter))
call SetHandleHandle(t,"unit0",t)
call SetHandleHandle(t,"effect0",AddLightning("DRAL",true,GetUnitX(u),GetUnitY(u),GetUnitX(w),GetUnitY(w)))
loop
exitwhen c>5 or q==null
set q = FirstOfGroup(g)
set l = AddLightning("DRAL",true,GetUnitX(w),GetUnitY(w),GetUnitX(q),GetUnitY(q))
call SetHandleHandle(t,"l"+I2S(c),l)
call SetHandleHandle(t,"unit"+I2S(c),q)
set w = q
call GroupRemoveUnit(g,q)
set c = c+1
endloop
call SetHandleInt(t,"p",GetPlayerId(GetOwningPlayer(u)))
call SetHandleInt(t,"lvl",GetUnitAbilityLevel(u,'A01X'))
call SetHandleInt(t,"c",c)
call SetHandleInt(t,"z",0)
call TimerStart(t,0.04,true, function GraveCallingTimer)
call DestroyGroup(g)
set u = null
set t = null
set g = null
set q = null
set w = null
set l = null
endfunction
//===========================================================================
function InitTrig_Grave_Calling takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t, Condition(function GraveCallingSpell))
call TriggerAddAction(t, function GraveCallingActions)
endfunction
The lightnings are created, but never destroyed.
The slow ability 'A01Y' never gets added...
The whole thing just doesn't seem to work!
It seems that the structs are not being attached at all.
I added in THIS SUX AT LIFE to help me debug.
Please help me :O