Rules FAQ Members List Search Register Login

 Raised This Month: \$68 Target: \$400 17%

Author Message
Guren
Senior Member
Join Date: Feb 2011
Location: Equestria, Ponyville
03-06-2013 , 04:06   [STOCK] Target is exist in client's angle and distance (03/07/2013 Ver 1.1)
#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);

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

Attached Files
 IsTargetInSightRange.inc (1.6 KB, 286 views)
__________________

Nick : Chamamyungsu // Korean Brony

Last edited by Guren; 03-06-2013 at 10:09. Reason: Updated
zipcore
Veteran Member
Join Date: Mar 2010
Location: m_flZipcore
 03-06-2013 , 07:45   Re: [STOCK] Target is exist in client's angle and distance #2 cool, good job
Franc1sco
Veteran Member
Join Date: Oct 2010
 03-06-2013 , 08:17   Re: [STOCK] Target is exist in client's angle and distance #3 Nice, very useful __________________ Veteran SourceMod Coder -> Activity channel I dont accept more paid request, here why. If you want my private help then you could get it for free, just ask me on steam You like my work? Drop a +Rep in my steam profile comments
Bimbo1
Senior Member
Join Date: Jan 2010
Location: brazil
 04-06-2013 , 11:54   Re: [STOCK] Target is exist in client's angle and distance (03/07/2013 Ver 1.1) #4 it's pretty cool! but it doesn't check whether there is an obstacle between the two players or not, does it? well, since cassiopeia's ult doesn't do that too, i guess it's fine. @edit: oh, since i think that you would be using this several times to detect all the players that are in range of someone, you would like to have it optimized. so, i recommend you using the third parameter of GetVectorDistance set as true, which will return a value without square rooting and, then, square the distance of your function. square rooting isn't as easy as a multiplication. also, checking the distance vector between the two players before doing anything else would be nice too, because it wouldn't do the angle calculation unnecessarily. if resultdistance(squared) is > distance(squared), nothing else matters, return it false right away. __________________ sie sind das essen und wir sind die jäger! Last edited by Bimbo1; 04-06-2013 at 17:09.
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
 04-06-2013 , 17:10   Re: [STOCK] Target is exist in client's angle and distance (03/07/2013 Ver 1.1) #5 Should make it draw tes too o: __________________ Profile - Steam Group - Plugins - Blog - Donate Add me on steam if you are seeking sp/map/model commissions.
Guren
Senior Member
Join Date: Feb 2011
Location: Equestria, Ponyville
04-29-2013 , 03:18   Re: [STOCK] Target is exist in client's angle and distance (03/07/2013 Ver 1.1)
#6

Quote:
 Originally Posted by Bimbo1 it's pretty cool! but it doesn't check whether there is an obstacle between the two players or not, does it? well, since cassiopeia's ult doesn't do that too, i guess it's fine. @edit: oh, since i think that you would be using this several times to detect all the players that are in range of someone, you would like to have it optimized. so, i recommend you using the third parameter of GetVectorDistance set as true, which will return a value without square rooting and, then, square the distance of your function. square rooting isn't as easy as a multiplication. also, checking the distance vector between the two players before doing anything else would be nice too, because it wouldn't do the angle calculation unnecessarily. if resultdistance(squared) is > distance(squared), nothing else matters, return it false right away.

i'll be fix. i'm a trial period now. so i don't have a many times.
__________________

Nick : Chamamyungsu // Korean Brony
ImACow
AlliedModders Donor
Join Date: Feb 2015
 02-28-2019 , 14:03   Re: [STOCK] Target is exist in client's angle and distance (03/07/2013 Ver 1.1) #7 Thanks for this Found this by google'ing client view cone __________________ Last edited by ImACow; 02-28-2019 at 14:09.
SZOKOZ
Member
Join Date: Jan 2014
 03-03-2019 , 05:07   Re: [STOCK] Target is exist in client's angle and distance (03/07/2013 Ver 1.1) #8 I've made a stock like this too. The only problem with this and mine is that it does not take into account the different yaw and pitch angles of a clients fov which will lead to false positives. (e.g. A players fov might be 70 degrees but due to their resolution their yaw angle will be different thus they do not truly see 70 degrees in both axis) I've had a couple ideas to increase the accuracy but none were satisfactory for me. I guess it all depends on how accurate you want it to be. There's even obstruction by models to consider where as using its bounding box to check if there is true obstruction may not even work if the model in question has collision via vphysics. GGWP Summoner. __________________ May still be available for SM scripting. Just look at my Steam profile regarding my availability. My Steam Last edited by SZOKOZ; 03-03-2019 at 05:09.
Edison1318
Senior Member
Join Date: Nov 2015
Location: Peaceful place of the in
 05-28-2019 , 20:53   Re: [STOCK] Target is exist in client's angle and distance (03/07/2013 Ver 1.1) #9 Not sure if this thread is still alive, I was thinking that if someone would able to code it that it look on sight correctly that is not behind the walls, and also while not looking up or downwards __________________ EdisonGar

 Thread Tools Display Modes Linear Mode

 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 Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Server Discussion     Source Servers (SRCDS)     HL1 Servers (HLDS) AMX Mod X     News     Bug Reports     General     Off-Topic     Plugins         Suggestions / Requests         Approved Plugins         New Plugin Submissions         Unapproved/Old Plugins         Translation Request         High-Traffic Plugins             GunGame             UAIO (Ultimate All-In-One Plugin)             xREDIRECT             CSDM             AMX Super             RuneMod             Zombie Plague Mod             SuperHero Mod                 News                 Tech Support                 Scripting Help                 Off-Topic / General Chat                 Heroes                     Suggestions / Requests                     Approved Heroes                     New Submissions                     Unapproved/Old Heroes                         Module Heroes                     SuperHero Mod Stats - By 123                 (OLD) Bug Reports     Scripting         Scripting Help         Code Snippets/Tutorials         Module Coding     Donor Access SourceMod     News     General     Plugins         Plugins         Unapproved Plugins         Plugin/Gameplay Ideas and Requests         High-Traffic Plugins             SourceMod Anti-Cheat             Zombie:Reloaded             SourceBans / SourceBans++             VSH / Freak Fortress             Store             SM_Hosties             HLstatsX:CE     Scripting     Extensions     Snippets and Tutorials     Donor Access     Metamod: Source         Metamod:Source Plugins         Metamod:Source Questions         Coding MM:S Plugins & SM Extensions Hosted Stuff     Asherkin's Plugins         TF2Items         TFDodgeball         SteamTools     Bail's Plugins         CSDM         CS:S DM Off-Topic & Trash     Off-Topic     Trash

All times are GMT -4. The time now is 08:20.

 DMCA - Archive - Top