Announcement

Collapse
No announcement yet.

AntiAim for GoldSRC

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • AntiAim for GoldSRC

    Somewhere or before CreateMove:
    Code:
    #define NORMALIZE(v,dist) \
    if(dist==0){ \
    v[0]=0; \
    v[1]=0; \
    v[2]=1; \
    } else { \
    dist=1/dist; \
    v[0]=v[0]*dist; \
    v[1]=v[1]*dist; \
    v[2]=v[2]*dist; \
    }
    
    void AntiAim(usercmd_t *usercmd,usercmd_t orig_cmd)
    {
    if(!(usercmd->buttons&IN_ATTACK)&&
    !(usercmd->buttons&IN_USE)&& me.alive &&
    (!IsCurWeaponC4()&&(!gCvar.knifeantiaim&&!IsCurWeaponKnife()||gCvar.knifeantiaim)&&!IsCurWeaponNade()))
    {
    static bool yFlip;
    cl_entity_t *pLocal;
    Vector viewforward, viewright, viewup, aimforward, aimright, aimup, v;
    float newforward, newright, newup, fTime;
    float forward = usercmd->forwardmove;
    float right = usercmd->sidemove;
    float up = usercmd->upmove;
    bool movetype_walk = (gEngine.GetLocalPlayer()->curstate.movetype == MOVETYPE_WALK);
    if(movetype_walk){
    v[0]=0.0f;
    v[1]=usercmd->viewangles[1];
    v[2]=0.0f;
    gEngine.pfnAngleVectors(v, viewforward, viewright, viewup);
    } else {
    gEngine.pfnAngleVectors(usercmd->viewangles, viewforward, viewright, viewup);}
    fTime = gEngine.GetClientTime();
    if(gCvar.antiaimpitch==1)
    {
    //Down
    usercmd->viewangles.x = 88;
    }
    else if(gCvar.antiaimpitch==2)
    {
    //Up
    usercmd->viewangles.x = -88;
    }
    else if(gCvar.antiaimpitch==3)
    {
    //FakeDown
    usercmd->viewangles.x = 1620;
    }
    else if(gCvar.antiaimpitch==4)
    {
    //FakeUp
    usercmd->viewangles.x = -1619;
    }
    else if(gCvar.antiaimpitch==5)
    {
    //Spin X
    usercmd->viewangles.x = cos(fTime * 11 * 3.14159265358979323846) * 360.0f;
    usercmd->viewangles.x = cos(fTime * 11 * 3.14159265358979323846) * 90.0f;
    }
    else if(gCvar.antiaimpitch==6)
    {
    //Static
    usercmd->viewangles.x = 0;
    }
    
    if(gCvar.antiaimyaw==1||gCvar.fakeantiaimyaw==1)
    {
    //Backwards
    usercmd->viewangles.y = usercmd->viewangles.y + 180;
    }
    else if(gCvar.antiaimyaw==2||gCvar.fakeantiaimyaw==2)
    {
    //Static Left
    usercmd->viewangles.y = 90;
    }
    else if(gCvar.antiaimyaw==3||gCvar.fakeantiaimyaw==3)
    {
    //Static Right
    usercmd->viewangles.y = 270;
    }
    if(gCvar.antiaimyaw==4||gCvar.fakeantiaimyaw==4)
    {
    //Left
    usercmd->viewangles.y = usercmd->viewangles.y + 90;
    }
    else if(gCvar.antiaimyaw==5||gCvar.fakeantiaimyaw==5)
    {
    //Right
    usercmd->viewangles.y = usercmd->viewangles.y + 270;
    }
    else if(gCvar.antiaimyaw==6||gCvar.fakeantiaimyaw==6)
    {
    //Spin Y
    usercmd->viewangles.y = sin(fTime * 11 * 3.14159265358979323846) * 360.0f;
    }
    else if(gCvar.antiaimyaw==7||gCvar.fakeantiaimyaw==7)
    {
    //Static
    usercmd->viewangles.y = 0;
    }
    else if(gCvar.antiaimyaw==8||gCvar.fakeantiaimyaw==8)
    {
    int random = rand() % 100;
    
    if (random < 98)
    // Look backwards
    usercmd->viewangles.y -= 180;
    
    // Jitter
    if (random < 15)
    {
    float change = -70 + (rand() % (int)(140 + 1));
    usercmd->viewangles.y += change;
    }
    if (random == 69)
    {
    float change = -90 + (rand() % (int)(180 + 1));
    usercmd->viewangles.y += change;
    }
    
    }
    else if(gCvar.antiaimyaw==9||gCvar.fakeantiaimyaw==9)
    {
    //Jitter
    int random = 1 + (rand() % (int)(100 - 1 + 1));
    if(random < 10)
    {
    usercmd->viewangles.y+=180;
    }
    if(random > 90)
    {
    usercmd->viewangles.y=usercmd->viewangles.y;
    }
    }
    if(movetype_walk){
    v[0]=0.0f;
    v[1]=usercmd->viewangles[1];
    v[2]=0.0f;
    gEngine.pfnAngleVectors(v, aimforward, aimright, aimup);
    } else {
    gEngine.pfnAngleVectors(usercmd->viewangles, aimforward, aimright, aimup);}
    float flLen1=(float)sqrt(viewforward[0]*viewforward[0]+viewforward[1]*viewforward[1]+viewforward[2]*viewforward[2]);
    float flLen2=(float)sqrt(viewright[0]*viewright[0]+viewright[1]*viewright[1]+viewright[2]*viewright[2]);
    float flLen3=(float)sqrt(viewup[0]*viewup[0]+viewup[1]*viewup[1]+viewup[2]*viewup[2]);
    NORMALIZE(viewforward,flLen1);
    NORMALIZE(viewright,flLen2);
    NORMALIZE(viewup,flLen3);
    viewforward[0]=forward*viewforward[0];
    viewforward[1]=forward*viewforward[1];
    viewforward[2]=forward*viewforward[2];
    viewright[0]=right*viewright[0];
    viewright[1]=right*viewright[1];
    viewright[2]=right*viewright[2];
    viewup[0]=up*viewup[0];
    viewup[1]=up*viewup[1];
    viewup[2]=up*viewup[2];
    newforward = ( (viewforward[0]*aimforward[0] + viewforward[1]*aimforward[1] + viewforward[2]*aimforward[2])+
    (viewright[0]*aimforward[0] + viewright[1]*aimforward[1] + viewright[2]*aimforward[2])+
    (viewup[0]*aimforward[0] + viewup[1]*aimforward[1] + viewup[2]*aimforward[2]));
    newright = ( (viewforward[0]*aimright[0] + viewforward[1]*aimright[1] + viewforward[2]*aimright[2])+
    (viewright[0]*aimright[0] + viewright[1]*aimright[1] + viewright[2]*aimright[2])+
    (viewup[0]*aimright[0] + viewup[1]*aimright[1] + viewup[2]*aimright[2]));
    newup = ( (viewforward[0]*aimup[0] + viewforward[1]*aimup[1] + viewforward[2]*aimup[2])+
    (viewright[0]*aimup[0] + viewright[1]*aimup[1] + viewright[2]*aimup[2])+
    (viewup[0]*aimup[0] + viewup[1]*aimup[1] + viewup[2]*aimup[2]));
    if(gCvar.antiaimpitch==3||gCvar.antiaimpitch==4)
    {
    usercmd->forwardmove = -newforward;
    usercmd->sidemove = newright;
    usercmd->upmove = newup;
    }
    else
    {
    usercmd->forwardmove = newforward;
    usercmd->sidemove = newright;
    usercmd->upmove = newup;
    }
    }
    }


    CreateMove:
    Code:
    if(gCvar.antiaim)
    {
    memcpy(&ucmd_backup,ucmd,sizeof(usercmd_t));
    AntiAim(ucmd,ucmd_backup);
    }
Working...
X