Raised This Month: $ Target: $400
 0% 

Best player in viewcone


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Lord of Destruction
Member
Join Date: Sep 2004
Old 12-27-2006 , 10:48   Re: Best player in viewcone
Reply With Quote #1

upps playera is the <forward>vector of the players angles ( ang_to_vec ) aka his aiming vector
playerb is the enemyorigin - clientorigin ( connectionvector )

so you'll have to find the smallest
floatabs(floatacos( dotp( forwardvector( client.angles ), enemy.origin - client.origin ) ) )
this should result in the closest enemy to your crosshair

Last edited by Lord of Destruction; 12-27-2006 at 11:01.
Lord of Destruction is offline
MrDev
Member
Join Date: Sep 2005
Old 12-27-2006 , 10:55   Re: Best player in viewcone
Reply With Quote #2

Thanks Lod and others

I got it to work with a modified sample of the c++ variant. This code will return a float where 0.0 is furthest away and 1.0 is closests to our aimline. If the player is not in the radius (distance) this function will return 0.0. Now all there is to do is to make a traceline check and people can begin to drain life

Code:
public Float:Find_Angle(Core,Target,Float:dist) {     new Float:vec2LOS[2]     new Float:flDot     new Float:CoreOrigin[3]     new Float:TargetOrigin[3]     new Float:CoreAngles[3]         pev(Core,pev_origin,CoreOrigin)     pev(Target,pev_origin,TargetOrigin)         if (get_distance_f(CoreOrigin,TargetOrigin) > dist)         return 0.0         pev(Core,pev_angles, CoreAngles)         for ( new i = 0; i < 2; i++ )         vec2LOS[i] = TargetOrigin[i] - CoreOrigin[i]             new Float:veclength = Vec2DLength(vec2LOS)         //Normalize V2LOS     if (veclength <= 0.0)     {         vec2LOS[x] = 0.0         vec2LOS[y] = 0.0     }     else     {         new Float:flLen = 1.0 / veclength;         vec2LOS[x] = vec2LOS[x]*flLen         vec2LOS[y] = vec2LOS[y]*flLen     }         //Do a makevector to make v_forward right     engfunc(EngFunc_MakeVectors,CoreAngles)         new Float:v_forward[3]     new Float:v_forward2D[2]     get_global_vector(GL_v_forward, v_forward)         v_forward2D[x] = v_forward[x]     v_forward2D[y] = v_forward[y]     //flDot = DotProduct (vec2LOS , gpGlobals->v_forward.Make2D() );     flDot = vec2LOS[x]*v_forward2D[x]+vec2LOS[y]*v_forward2D[y]         //0.5 = 90'     if ( flDot > 0.5 )     {         return flDot     }             return 0.0     }
MrDev is offline
Reply



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 22:24.


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