Raised This Month: $ Target: $400
 0% 

[STOCK] Target is exist in client's angle and distance (03/07/2013 Ver 1.1)


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Guren
Senior Member
Join Date: Feb 2011
Location: Equestria, Ponyville
Old 03-06-2013 , 04:06   [STOCK] Target is exist in client's angle and distance (03/07/2013 Ver 1.1)
Reply With Quote #1

i made this function cuz i want make skills like a league of legends.

Thanks to javalia. (helped to solve my question)


Update log
03 07 2013 - Changed function name, add to negativeangle


Code:
stock bool:IsTargetInSightRange(client, target, Float:angle=90.0, Float:distance=0.0, bool:heightcheck=true, bool:negativeangle=false)
{
	if(angle > 360.0 || angle < 0.0)
		ThrowError("Angle Max : 360 & Min : 0. %d isn't proper angle.", angle);
	if(!isClientConnectedIngameAlive(client))
		ThrowError("Client is not Alive.");
	if(!isClientConnectedIngameAlive(target))
		ThrowError("Target is not Alive.");
		
	decl Float:clientpos[3], Float:targetpos[3], Float:anglevector[3], Float:targetvector[3], Float:resultangle, Float:resultdistance;
	
	GetClientEyeAngles(client, anglevector);
	anglevector[0] = anglevector[2] = 0.0;
	GetAngleVectors(anglevector, anglevector, NULL_VECTOR, NULL_VECTOR);
	NormalizeVector(anglevector, anglevector);
	if(negativeangle)
		NegateVector(anglevector);

	GetClientAbsOrigin(client, clientpos);
	GetClientAbsOrigin(target, targetpos);
	if(heightcheck && distance > 0)
		resultdistance = GetVectorDistance(clientpos, targetpos);
	clientpos[2] = targetpos[2] = 0.0;
	MakeVectorFromPoints(clientpos, targetpos, targetvector);
	NormalizeVector(targetvector, targetvector);
	
	resultangle = RadToDeg(ArcCosine(GetVectorDotProduct(targetvector, anglevector)));
	
	if(resultangle <= angle/2)	
	{
		if(distance > 0)
		{
			if(!heightcheck)
				resultdistance = GetVectorDistance(clientpos, targetpos);
			if(distance >= resultdistance)
				return true;
			else
				return false;
		}
		else
			return true;
	}
	else
		return false;
}
Attached Thumbnails
Click image for larger version

Name:	?????.jpg
Views:	1265
Size:	55.1 KB
ID:	116688  
Attached Files
File Type: inc IsTargetInSightRange.inc (1.6 KB, 614 views)
__________________

Nick : Chamamyungsu // Korean Brony

Last edited by Guren; 03-06-2013 at 10:09. Reason: Updated
Guren is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 19:39.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode