wraithseeker
Tired.
- Reaction score
- 122
How do I detect units in front of caster as I have a spell which knocks enemy units away that is infront of the caster.
function IsSourceBehindTarget takes unit source, unit target, real arc returns boolean
//Shamelessly stolen from Builder Bob, then slightly modified.
//I have no idea if it works.
local real angle = Atan2(GetUnitY(target) - GetUnitY(source), GetUnitX(target) - GetUnitX(source)) - bj_DEGTORAD * (GetUnitFacing(target) - 180)
set angle = Atan2(Sin(angle), Cos(angle))
if angle < 0 then
set angle = -angle
endif
return angle < bj_DEGTORAD * arc / 2.
endfunction