From 55695ef2700de8c71461c7a4df62c7094aa43590 Mon Sep 17 00:00:00 2001 From: catlaptop Date: Thu, 4 Oct 2018 19:22:12 +0200 Subject: [PATCH] Fix AC tf --- include/hacks/ac/aimbot.hpp | 3 +++ src/hacks/AntiCheat.cpp | 5 +++-- src/hacks/ac/aimbot.cpp | 14 +++++++++++--- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/include/hacks/ac/aimbot.hpp b/include/hacks/ac/aimbot.hpp index 57d50520..972acb8b 100644 --- a/include/hacks/ac/aimbot.hpp +++ b/include/hacks/ac/aimbot.hpp @@ -7,6 +7,8 @@ #pragma once +#include "config.h" +#include "common.hpp" #include class KeyValues; @@ -24,6 +26,7 @@ struct ac_data extern int amount[32]; void ResetEverything(); +std::unordered_map &player_orgs(); void ResetPlayer(int idx); void Init(); diff --git a/src/hacks/AntiCheat.cpp b/src/hacks/AntiCheat.cpp index da354108..a59dae22 100644 --- a/src/hacks/AntiCheat.cpp +++ b/src/hacks/AntiCheat.cpp @@ -58,14 +58,15 @@ void CreateMove() if (!enable) return; angles::Update(); - for (int i = 1; i < 33; i++) + ac::aimbot::player_orgs().clear(); + for (int i = 1; i < g_IEngine->GetMaxClients(); i++) { if (skip_local && (i == g_IEngine->GetLocalPlayer())) continue; CachedEntity *ent = ENTITY(i); if (CE_GOOD(ent)) { - if ((CE_BYTE(ent, netvar.iLifeState) == 0)) + if (ent->m_bAlivePlayer()) { if (player_tools::shouldTarget(ent) == player_tools::IgnoreReason::DO_NOT_IGNORE || diff --git a/src/hacks/ac/aimbot.cpp b/src/hacks/ac/aimbot.cpp index 917dcfc3..360c2eaf 100644 --- a/src/hacks/ac/aimbot.cpp +++ b/src/hacks/ac/aimbot.cpp @@ -20,15 +20,22 @@ namespace ac::aimbot ac_data data_table[32]; int amount[32]; +std::unordered_map Player_origs{}; +std::unordered_map & player_orgs() +{ + return Player_origs; +} void ResetEverything() { memset(&data_table, 0, sizeof(ac_data) * 32); + Player_origs.clear(); } void ResetPlayer(int idx) { memset(&data_table[idx - 1], 0, sizeof(ac_data)); + Player_origs.clear(); } void Init() @@ -40,6 +47,7 @@ void Update(CachedEntity *player) { if (!enable) return; + Player_origs[player->m_IDX] = player->m_vecOrigin(); auto &data = data_table[player->m_IDX - 1]; auto &am = amount[player->m_IDX - 1]; if (data.check_timer) @@ -107,12 +115,12 @@ void Event(KeyValues *event) int victim = event->GetInt("userid"); int eid = g_IEngine->GetPlayerForUserID(attacker); int vid = g_IEngine->GetPlayerForUserID(victim); - if (eid > 0 && eid < 33) + if (eid > 0 && eid < 33 && vid > 0 && vid < 33) { CachedEntity *victim = ENTITY(vid); CachedEntity *attacker = ENTITY(eid); - if (CE_GOOD(victim) && CE_GOOD(attacker)) - if (victim->m_vecOrigin().DistTo(attacker->m_vecOrigin()) > 250) + if (Player_origs[vid].z != 0 && Player_origs[eid].z != 0) + if (Player_origs[vid].DistTo(Player_origs[eid]) > 250) { data_table[eid - 1].check_timer = 1; data_table[eid - 1].last_weapon = event->GetInt("weaponid");