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:28   Re: Best player in viewcone
Reply With Quote #1

My function was only intended to set the clients aim vector to an origin regardless where this origin is.

btw : there is a much more efficient way
Code:
stock setClientAIM ( Client, Entity ) {     static Float:vecOrigin[ 3 ];     static Float:vecTarget[ 3 ];     static Float:angResult[ 3 ];     entity_get_vector( Client, EV_VEC_origin, vecOrigin );     entity_get_vector( Entity, EV_VEC_origin, vecTarget );     vecOrigin[ 0 ] = vecTarget[ 0 ] - vecOrigin[ 0 ];     vecOrigin[ 1 ] = vecTarget[ 1 ] - vecOrigin[ 1 ];     vecOrigin[ 2 ] = vecTarget[ 2 ] - vecOrigin[ 2 ];     vector_to_angle( vecOrigin, angResult );     entity_set_vector( Client, EV_VEC_angles, angResult );     entity_set_int( Client, EV_INT_fixangle, 1 ); }

but what you need is more like
Code:
stock getNextEnemy ( Client ) {     new end = get_maxplayers();     new Float:minr = float( getTeleportRange( Client ) );     new Ret = 0;     new Float:rang;     for ( new Enemy = 1; Enemy <= end; Enemy++ )     {         if ( !is_user_connected( Enemy ) )             continue;         if ( !is_user_alive( Enemy ) || Enemy == Client )             continue;         if ( getGameMODE() > 0 && getClientTEAM( Enemy ) == getClientTEAM( Client ) )             continue;                     // add in view cone / trace line here         rang = entity_range( Enemy, Client );         if ( rang < minr )         {             Ret = Enemy ;             minr = rang;         }     }     return Ret; }
This finds the closest enemy next to you ( but with z dimension because its actually for the ESF Mod ^^ ) but if you add inviewcone (and traceline?) the origins then you should have reached your goal

Of course you need to get the natives I used mod specific


And for enemy2 you will need also need to add something like the smallest( floatabs(floatacos( dotp( playera, playerb ) ) )) as i did with the distance

for dotp you may consult your favourite math formula collection^^
or use pm's xs library

Last edited by Lord of Destruction; 12-27-2006 at 10:44.
Lord of Destruction 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