- Joined
- Jul 26, 2008
- Messages
- 1,009
Alright, I'm trying to create a spell that works just like Carrion Beetles. However I can't seem to target and remove corpses. The spell is a no target spell, just like carrion beetles.
The reason this is spell triggered is because I'm trying to modify 1 unit via triggers after summoning it, instead of creating 5 different units for each level.
I figured it cuold be done by getting all units in a range, putting them in a group, then checking which are at 0 or less HP, removing them and creating beetles at their position. This however didn't work.
The reason this is spell triggered is because I'm trying to modify 1 unit via triggers after summoning it, instead of creating 5 different units for each level.
I figured it cuold be done by getting all units in a range, putting them in a group, then checking which are at 0 or less HP, removing them and creating beetles at their position. This however didn't work.
JASS:
function Swarm_Actions takes nothing returns nothing
local unit t
local unit c = GetTriggerUnit()
local group g = CreateGroup()
local player cp = GetOwningPlayer(c)
local integer i = 0
loop
set t = FirstOfGroup(g)
if IsUnitEnemy(t, GetOwningPlayer(c)) then
else
call GroupRemoveUnit(g, t)
endif
exitwhen t == null or i == 1
if GetWidgetLife(t) <= 0 then
call CreateUnit(cp, 'swar', GetUnitX(t), GetUnitY(t), bj_UNIT_FACING)
call GroupRemoveUnit(g,t)
call RemoveUnit(t)
set i = i + 1
else
call GroupRemoveUnit(g, t)
endif
endloop
set c = null
call DestroyGroup(g)
set t = null
set cp = null
endfunction
function Swarm_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'swar'
endfunction
//===========================================================================
function InitTrig_Swarm takes nothing returns nothing
local trigger Swarm = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(Swarm, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddAction( Swarm, function Swarm_Actions )
call TriggerAddCondition(Swarm, function Swarm_Conditions)
endfunction