I am working with unit groups for the first time. Mostly I try to do things using unit arrays. This is my jass trigger..
Can anyone say if it leaks or not? Is there anyway by which unit arrays can completely replace unit groups. Don't look at the tirggers other than the group part. They are really complicated lol.
JASS:
function Trig_ShadowBall_Dot_Actions takes nothing returns nothing
local unit temp
local real x
local real y
local integer cvalue
local integer tempunitpreset
local group shadowballgroup = CreateGroup()
local integer n1
local integer n = 1
loop
exitwhen(n > dhcount)
if (shadowballcast[n] == 1) then
set x = GetUnitX(shadowballunit[n])
set y = GetUnitY(shadowballunit[n])
call GroupEnumUnitsInRange(shadowballgroup, x, y, 200, Filter(function TrueBoolexpr))
loop
set temp = FirstOfGroup(shadowballgroup)
exitwhen temp == null
set cvalue = GetPlayerId(GetOwningPlayer(demonhunters[n]))
if (GetPlayerId(GetOwningPlayer(temp)) != cvalue) then
if (GetPlayerId(GetOwningPlayer(temp)) != 15) then
set tempunitpreset = 0
set n1 = ((n*50)-50)
loop
exitwhen(n1>shadowballhitunitsno[n])
if(shadowballhitunits[n1+((n*50)-50)] == temp) then
set tempunitpreset = 1
endif
set n1 = n1 + 1
set dpstest = dpstest + 1
endloop
if (tempunitpreset == 0) then
call UnitDamageTarget( dummyheros[cvalue], temp, 150, true, false, ATTACK_TYPE_MAGIC , DAMAGE_TYPE_UNIVERSAL, WEAPON_TYPE_WHOKNOWS )
set shadowballhitunitsno[n] = shadowballhitunitsno[n] + 1
set shadowballhitunits[shadowballhitunitsno[n]+((n*50)-50)] = temp
endif
endif
endif
call GroupRemoveUnit(shadowballgroup, temp)
endloop
set shadowballgroup=null
set shadowballtimer[n] = shadowballtimer[n] - 20
if (shadowballtimer[n] <= 0) then
set shadowballcast[n] = 0
set shadowballunit[n] = null
set shadowballhitunitsno[n] = ((n*50)-50)
endif
endif
set n = n + 1
endloop
call DestroyGroup(shadowballgroup)
endfunction
Can anyone say if it leaks or not? Is there anyway by which unit arrays can completely replace unit groups. Don't look at the tirggers other than the group part. They are really complicated lol.