I'm wondering a couple things, first of all will this function actually work, and also will it leak.
Basically the idea behind the function is to return a unit group of all the units that would lie inside a cone, so that cone-based attacks can be triggered properly.
EDIT: updated with a couple changes/fixes
Basically the idea behind the function is to return a unit group of all the units that would lie inside a cone, so that cone-based attacks can be triggered properly.
JASS:
function GetCone takes unit caster, real distance, real maxspread, real minspread, group units returns nothing
local group g = CreateGroup()
local unit u = null
local real x = GetUnitX(caster)
local real y = GetUnitY(caster)
local real face = GetUnitFacing(caster)
local real fakeX = (maxspread/(maxspread-minspread)*distance)*Cos(face+355/113) + x //create a fake point that for the tip of a full cone
local real fakeY = (maxspread/(maxspread-minspread)*distance)*Sin(face+355/113) + y //rather than the truncated one given
local real finalSpread = (maxspread-minspread)/(2*distance) //calculates the spread angle
call GroupEnumUnitsInRange(g,x,y,distance,Filter(null))
loop
set u = FirstOfGroup(g)
exitwhen u == null
call GroupRemoveUnit(g,u)
if RAbsBJ((GetUnitY(u) - fakeY)/(GetUnitX(u) - fakeX)) < RAbsBJ(finalSpread) then
call GroupAddUnit(units,u)
endif
endloop
set g = null
set u = null
endfunction
EDIT: updated with a couple changes/fixes
Last edited: