Raised This Month: $12 Target: $400
 3% 

Entity see ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
gubka
Veteran Member
Join Date: Jan 2012
Location: Russia
Old 12-06-2017 , 15:08   Entity see ?
Reply With Quote #1

I am really bad with vectors, anyone can help with an algorithm which checks that entity see the client in the 90 degrees? ( In front of entity, not on the back )

I tried
PHP Code:
Get angle of rotating of the entity
by
 GetEntPropVector
(entityProp_Send"m_angRotation"flAngle)

and 
compare it to the client eye position

stock float GetVector2Ddegrees
(float vFirst[3], float vSecond[3])
{
    
#if !defined PI
        #define PI 3.14159265
    #endif

    
static float flAngle;

    
flAngle = ((vFirst[0] * vSecond[0] + vFirst[1] * vSecond[1]) / (SquareRoot(vFirst[0] * vFirst[0] + vFirst[1]*vFirst[1]) * SquareRoot(vSecond[0] * vSecond[0] + vSecond[1] * vSecond[1])));
    return 
ArcCosine(Angle) / 180.0 PI;

Smth like that but also with GetClientAimTarget but just for entity
PHP Code:
stock bool CanSeeEachOther(int entityIndexint targetIndexfloat flDistance 0.0float flHeight 50.0)
{
    
// Validate target
    
if (IsPlayerExist(targetIndex))
    {
        
float vEntPosition[3]; float vTargetPosition[3];
        
        
GetEntPropVector(entityIndexProp_Send"m_vecOrigin"vEntPosition);
        
vMonsterPosition[2] += flHeight;
        
        
GetClientEyePosition(targetIndexvTargetPosition);
        
        if (
flDistance == 0.0 || GetVectorDistance(vEntPositionvTargetPositionfalse) < flDistance)
        {
            
Handle hTrace TR_TraceRayFilterEx(vEntPositionvTargetPositionMASK_SOLID_BRUSHONLYRayType_EndPoint, ......);

            if(
TR_DidHit(hTrace))
            {
                
CloseHandle(hTrace);
                return 
false;
            }
            
            
CloseHandle(hTrace);
            return 
true;
        }
    }
    
    return 
false;

But i couldnt get right value, help please. Thanks a milion
__________________

Last edited by gubka; 12-06-2017 at 15:45.
gubka is offline
Send a message via ICQ to gubka
Pelipoika
Veteran Member
Join Date: May 2012
Location: Inside
Old 12-06-2017 , 15:50   Re: Entity see ?
Reply With Quote #2

https://github.com/Pelipoika/TF2_Nex...sp#L1365-L1392
__________________
Pelipoika is offline
gubka
Veteran Member
Join Date: Jan 2012
Location: Russia
Old 12-06-2017 , 22:36   Re: Entity see ?
Reply With Quote #3

Quote:
Originally Posted by Pelipoika View Post
Thank you
__________________
gubka is offline
Send a message via ICQ to gubka
Reply


Thread Tools
Display Modes

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 10:42.


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