• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Snippet] RangeFromSegment

Level 7
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.
 
Top