I am trying to deal all the units in line, but deal the damage only once to each target.
I am just wondering if there is better way of doing this because I am using two groups.
Any better way of doing this?
I am just wondering if there is better way of doing this because I am using two groups.
Any better way of doing this?
JASS:
local unit u
local group g = CreateGroup()
local group tempGroup = CreateGroup()
local integer i = 0
local real x = GetUnitX(tu)
local real y = GetUnitY(tu)
local real r = 300
local real distance = 150.0
local real tx = GetSpellTargetX()
local real ty = GetSpellTargetY()
local real angle = Atan2(ty-y,tx-x)
local real distX = distance * Cos(angle)
local real distY = distance * Sin(angle)
local real loopX = x + distX
local real loopY = y + distY
loop
exitwhen i > 5
set loopX = loopX + distX
set loopY = loopY + distY
call GroupEnumUnitsInRange(tempGroup, loopX, loopY, r, null)
loop
set u = FirstOfGroup(tempGroup)
exitwhen u == null
if IsUnitInGroup(u, g) == false then
call GroupAddUnit(g, u)
endif
call GroupRemoveUnit(tempGroup, u)
endloop
set i = i + 1
endloop
loop
set u = FirstOfGroup(g)
exitwhen u == null
// damage
call GroupRemoveUnit(g, u)
endloop
call DestroyGroup(tempGroup)
call DestroyGroup(g)
set tempGroup = null
set g = null