Client-side Aimbot Detection
Hi, I’m making a client-sided cheat detection system in my internal for legit play, and flagging of other cheaters. Currently I detect fakelag/fake angles, which works flawlessly, but I am stuck at my aimbot detection!
I am basically trying to check if the enemies viewangles flick by x degrees in two given ticks, and if so, flagging it as aimbot. The problem I have at the moment, is that regardless of the angle delta, be it 0.1 or 70 degrees, it is being flagged as aimbot and returning the respective console output.
void misc::cheatdetection(CInput::CUserCmd *pCmd, C_BaseEntity *local)
{
struct OldData_t {
bool m_bInitialized;
QAngle m_qOldAngles;
float m_flSimulationTime;
int m_iAimbotCount;
int m_iLagCount;
int m_iBhopCount;
float m_flAvgAirVel;
};
static OldData_t sOldData[65];
constexpr float MAX_ANGLE_DELTA = 45.f;
// reset the angle arrays for new round.
static int iPreviousTotalRounds{ -1 };
if (offsets.DT_CSGameRulesProxy.m_totalRoundsPlayed > iPreviousTotalRounds) {
for (int i = 1; i < g_Engine->GetMaxClients(); i++)
{
sOldData[i].m_bInitialized = false;
}
iPreviousTotalRounds = offsets.DT_CSGameRulesProxy.m_totalRoundsPlayed;
}
for (int i = 1; i < g_Engine->GetMaxClients(); i++) {
C_BaseEntity* pEntity = g_EntityList->GetClientEntity(i);
// get data accessor for the old data for this player.
OldData_t* pOldData = &sOldData[i];
if (!pEntity || pEntity->GetTeamNum() == local->GetTeamNum() || !pEntity->IsAlive())
continue;
if (pEntity == local)
continue;
if (pEntity->IsDormant()) {
pOldData->m_flSimulationTime = 0.f;
continue;
}
player_info_t pinfo;
if (!g_Engine->GetPlayerInfo(i, &pinfo))
continue;
// dereferenece it to get value into local scope.
QAngle qEyeAngles = *pEntity->GetEyeAngles();
// store the old eye angles once, if not done yet.
if (!pOldData->m_bInitialized) {
pOldData->m_qOldAngles = qEyeAngles;
pOldData->m_bInitialized = true;
continue;
}
// get a relative angle delta.
float flRelativeDelta = std::abs(qEyeAngles.y - pOldData->m_qOldAngles.y);
// big snap detected.
if (flRelativeDelta > MAX_ANGLE_DELTA) {
pOldData->m_iAimbotCount++;
// notify user.
std::string message = ("echo Aimbot Detected");
g_Engine->ClientCmd_Unrestricted(message.c_str());
}
// set old data for next call
pOldData->m_qOldAngles = qEyeAngles;
}
}
I call this procedure from my createmove if anyone is interested, and before people tell me “45 degree flicks are obvious, if they are ragehacking you don’t need a feature to tell you!!” I intend on making an inverse detection for mechanical or “too subtle” angle changes in an effort to detect legit-aimbot.
Any help/ideas would be greatly appreciated!
Additionally, if anyone has suggestions of other things I could “detect” it would be cool to hear your input. So far I plan on making a bunnyhop detection, with the respective ground time in-between bunny hops, and possibly something to detect consistent high velocity in the air in an effort to detect autostrafers etc.
|