• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a faction for Warcraft 3 and enter Hive's 19th Techtree Contest: Co-Op Commanders! Click here to enter!
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 21st Texturing Contest: Upgrade is now concluded, time to vote for your favourite set of icons! Click here to vote!

[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