Naga'sShadow
Ultra Cool Member
- Reaction score
- 49
I've recently decided to pick this up again and started with something I made a while ago. But things have changed and I've forgotten most of what I knew. So this Trigger was supposed to be a simple spell but It doesn't work and I need some help.
This is what I'm working with now, its a spell that reanimates everything in range for the duration of the spell. The base spell is a metamorphosis spell so I can have a visible duration. The whole thing is run through a loop that check's the caster's unit type. When it transforms back the spell should end.
On cast though the spell does nothing, so I may have outsmarted myself. Any help will be appreciated.
This is what I'm working with now, its a spell that reanimates everything in range for the duration of the spell. The base spell is a metamorphosis spell so I can have a visible duration. The whole thing is run through a loop that check's the caster's unit type. When it transforms back the spell should end.
Code:
scope Dawn initializer init
globals
private integer SPELLID = 'A000'
private integer UNITID = 'U000'
private integer UNITSPELL = 'A001'
private integer CASTER = 'u001'
endglobals
function Conditions takes nothing returns boolean
return GetSpellAbilityId() == SPELLID
endfunction
function gcondition takes nothing returns boolean
return IsUnitDeadBJ(GetFilterUnit()) == true
endfunction
function Actions takes nothing returns nothing
local unit u = GetTriggerUnit()
local player p = GetOwningPlayer(u)
local real x
local real y
local group g
local group g1
local real x1
local real y1
local unit c
loop
exitwhen GetUnitTypeId(u) != UNITID or IsUnitDeadBJ(u) == true
set x = GetUnitX(u)
set y = GetUnitY(u)
call GroupEnumUnitsInRange(g, x, y, 900, Condition(function gcondition))
loop
exitwhen FirstOfGroup(g) == null
set x1 = GetUnitX(FirstOfGroup(g))
set y1 = GetUnitY(FirstOfGroup(g))
set c = CreateUnit(p, CASTER, x1, y1, 0)
call UnitApplyTimedLife(c, 'BUAN', 2)
call UnitAddAbility(c, UNITSPELL)
call IssueImmediateOrder(c, "animatedead")
call GroupAddUnit(g1, FirstOfGroup(g))
call GroupRemoveUnit(g, FirstOfGroup(g))
set c = null
endloop
call PolledWait(1)
endloop
loop
exitwhen FirstOfGroup(g1) == null
call ExplodeUnitBJ(FirstOfGroup(g1))
call GroupRemoveUnit(g1, FirstOfGroup(g1))
endloop
call DestroyGroup(g)
call DestroyGroup(g1)
set u = null
endfunction
//===========================================================================
function init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t, Condition( function Conditions))
call TriggerAddAction( t, function Actions )
set t = null
endfunction
endscope
On cast though the spell does nothing, so I may have outsmarted myself. Any help will be appreciated.