- Joined
- Apr 27, 2011
- Messages
- 272
JASS:
function GetRangeFromSegment takes unit u, real x1, real y1, real x2, real y2 returns real
local real r=SquareRoot((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1))
local real a1=Atan2(y2-y1,x2-x1)
local real a2=Atan2(GetUnitX(u)-x1,GetUnitY(u)-y1)
if(a1>a2)then
return Sin(a1-a2)*r
endif
return Sin(a2-a1)*r
endfunction
just a little snippet that checks the linear range of a unit from a segment.