View Single Post
GoD-Tony
Veteran Member
Join Date: Jul 2005
Old 11-24-2011 , 07:52   Re: SMAC Development Thread
#320

A quick follow-up from IRC...

Quote:
Originally Posted by Unsleddable View Post
Have you ever thought about detecting actual no spread, instead of just checking for improper angles?
I did have an idea in mind but didn't get a chance to try it out. I quickly threw this together to help explain. After looking at it, I think it's a greatly oversimplified version of what you posted:
PHP Code:
public OnPluginStart()
{
    
// This tempent should provide all the data needed.
    
AddTempEntHook("Shotgun Shot"Hook_FireBullets);
    
    
// Init list of weapons that we should be checking.
    
g_bCheckWeapon[1] = true;
    
g_bCheckWeapon[5] = true;
    
g_bCheckWeapon[20] = true;
    
/* ... etc ... */
}

public 
Action:Hook_FireBullets(const String:te_name[], const Players[], numClientsFloat:delay)
{
    
/*
    "m_vecOrigin"        "vector"
    "m_vecAngles[0]"    "float"
    "m_vecAngles[1]"    "float"
    "m_iWeaponID"        "int"
    "m_iMode"            "int"
    "m_iSeed"            "int"
    "m_iPlayer"            "int"
    "m_fInaccuracy"        "float"
    "m_fSpread"            "float"
    */
    
    
new client TE_ReadNum("m_iPlayer") + 1;
    new 
iWeaponID TE_ReadNum("m_iWeaponID");
    
    if (
client && g_bCheckWeapon[iWeaponID])
    {
        
decl Float:vBulletAngles[3];
        
vBulletAngles[0] = TE_ReadFloat("m_vecAngles[0]");
        
vBulletAngles[1] = TE_ReadFloat("m_vecAngles[1]");
        
vBulletAngles[2] = 0.0// Not used in CS:S (and maybe all of ep2v).
        
        // Check if the client adjusted their angles perfectly for the shot.
        
decl Float:vDelta1[3], Float:vDelta2[3];
        
SubtractVectors(vBulletAnglesg_vPreviousEyeAngles[client], vDelta1);
        
SubtractVectors(g_vCurrentEyeAngles[client], g_vPreviousEyeAngles[client], vDelta2);
        
        if (
AreVectorsAlmostEqual(vDelta1vDelta21.0))
        {
            
g_iDetections[client]++;
        }
    }
    
    return 
Plugin_Continue;
}

public 
Action:OnPlayerRunCmd(client, &buttons, &impulseFloat:vel[3], Float:angles[3], &weapon)
{
    
g_vPreviousEyeAngles[client] = g_vCurrentEyeAngles[client];
    
g_vCurrentEyeAngles[client] = angles;
    return 
Plugin_Continue;
}

stock bool:AreVectorsAlmostEqual(const Float:vec1[3], const Float:vec2[3], const Float:tolerance=0.1)
{
    return 
FloatAbs(vec1[0] - vec2[0]) <= tolerance && 
        
FloatAbs(vec1[1] - vec2[1]) <= tolerance && 
        
FloatAbs(vec1[2] - vec2[2]) <= tolerance;

No real error checking as it was just an idea, but statistics could build very fast on full-auto weapons. I'm interested to know how your algorithm performs. Hopefully I get a chance for some test cases next week or so.

Quote:
Originally Posted by Unsleddable View Post
It's also possible to do actual aimbot detection by callling StartLagCompensation, since it will rewind all players to their relative positions and allow you to check if their viewangles are locked onto someone's head bone. You can optimize by hooking WantsLagCompensationOnEntity and only rewinding the player that we think is being locked on to.
This one is very interesting. Two questions: How often would the checks run, and what effect does it have on players when it runs?
__________________

Last edited by GoD-Tony; 11-24-2011 at 08:08.
GoD-Tony is offline