diff --git a/include/navparser.hpp b/include/navparser.hpp index ff1de98a..9a88f74b 100644 --- a/include/navparser.hpp +++ b/include/navparser.hpp @@ -26,7 +26,7 @@ void Draw(); int FindInVector(size_t id); int FindNearestValid(Vector vec); -int FindNearestValidbyDist(Vector vec, float mindist, float maxdist); +int FindNearestValidbyDist(Vector vec, float mindist, float maxdist, bool closest); class inactivityTracker { @@ -130,10 +130,8 @@ public: } return false; } - void updateSentries() + void AddSentries() { - sentryAreas.clear(); - sentries.clear(); for (int i = 0; i < HIGHEST_ENTITY; i++) { CachedEntity *ent = ENTITY(i); @@ -155,6 +153,11 @@ public: } } } + void ClearSentries() + { + sentries.clear(); + sentryAreas.clear(); + } bool IsIgnored(std::pair connection) { if (!IsPlayerDisguised(LOCAL_E)) diff --git a/src/hacks/AntiBackstab.cpp b/src/hacks/AntiBackstab.cpp index c4d7ed9b..db1384e3 100644 --- a/src/hacks/AntiBackstab.cpp +++ b/src/hacks/AntiBackstab.cpp @@ -12,7 +12,7 @@ static settings::Bool enable{ "antibackstab.enable", "0" }; static settings::Float distance{ "antibackstab.distance", "200" }; static settings::Bool silent{ "antibackstab.silent", "1" }; -static settings::Float angle{ "antibackstab.angle", "90" }; +static settings::Float angle{ "antibackstab.angle", "107.5" }; static settings::Bool sayno{ "antibackstab.nope", "0" }; namespace hacks::tf2::antibackstab @@ -95,22 +95,17 @@ void CreateMove() if (!enable) return; spy = ClosestSpy(); - ConVar *pitchdown = g_ICvar->FindVar("cl_pitchdown"); - static int normal_val = pitchdown->GetInt(); if (spy) { noaa = true; - pitchdown->SetValue(180); - current_user_cmd->viewangles.x = 140.0f; + current_user_cmd->viewangles.x = 160.0f; if (silent) g_pLocalPlayer->bUseSilentAngles = true; if (sayno) SayNope(); } else - { - pitchdown->SetValue(normal_val); noaa = false; - } + } } // namespace hacks::tf2::antibackstab diff --git a/src/hacks/MiscAimbot.cpp b/src/hacks/MiscAimbot.cpp index cd1ad268..1cfb7169 100644 --- a/src/hacks/MiscAimbot.cpp +++ b/src/hacks/MiscAimbot.cpp @@ -12,12 +12,49 @@ static settings::Int aimkey_mode{ "sandwichaim.aimkey-mode", "0" }; float sandwich_speed = 350.0f; float grav = 0.25f; +int prevent = -1; std::pair FindBestEnt(bool teammate, bool Predict, bool zcheck) { CachedEntity *bestent = nullptr; float bestscr = FLT_MAX; Vector predicted{}; + for (int i = 0; i < 1; i++) + { + if (prevent != -1) + { + auto ent = ENTITY(prevent); + if (CE_BAD(ent) || !ent->m_bAlivePlayer() || (teammate && ent->m_iTeam() != LOCAL_E->m_iTeam()) || ent == LOCAL_E) + continue; + if (!teammate && ent->m_iTeam() == LOCAL_E->m_ItemType()) + continue; + if (!ent->hitboxes.GetHitbox(1)) + continue; + Vector target{}; + if (Predict) + target = ProjectilePrediction(ent, 1, sandwich_speed, grav, + PlayerGravityMod(ent)); + else + target = ent->hitboxes.GetHitbox(1)->center; + if (!IsEntityVectorVisible(ent, target)) + continue; + if (zcheck && (ent->m_vecOrigin().z - LOCAL_E->m_vecOrigin().z) > 80.0f) + continue; + float scr = ent->m_flDistance(); + if (g_pPlayerResource->GetClass(ent) == tf_medic) + scr *= 0.1f; + if (scr < bestscr) + { + bestent = ent; + predicted = target; + bestscr = scr; + prevent = ent->m_IDX; + } + } + if (bestent && predicted.z) + return { bestent, predicted }; + } + prevent = -1; for (int i = 0; i < g_IEngine->GetMaxClients(); i++) { CachedEntity *ent = ENTITY(i); @@ -47,6 +84,7 @@ std::pair FindBestEnt(bool teammate, bool Predict, bestent = ent; predicted = target; bestscr = scr; + prevent = ent->m_IDX; } } return { bestent, predicted }; diff --git a/src/hacks/NavBot.cpp b/src/hacks/NavBot.cpp index 18eb8c8e..f08405b2 100644 --- a/src/hacks/NavBot.cpp +++ b/src/hacks/NavBot.cpp @@ -356,36 +356,93 @@ bool NavToSentry(int priority) return true; return false; } +static Vector lastgoal{0, 0, 0}; +int lastent = -1; bool NavToEnemy() { if (*stay_near) { - static Vector lastgoal{}; - CachedEntity *ent = NearestEnemy(); + if (lastent != -1) + { + CachedEntity *ent = ENTITY(lastent); + if (CE_BAD(ent) || !ent->m_bAlivePlayer() || ent->m_iTeam() == LOCAL_E->m_iTeam()) + { + lastent = -1; + if (lastgoal.x > 1.0f || lastgoal.x < -1.0f) + { + nav::NavTo(lastgoal, false, true, 1337); + return true; + } + } + else + { + int nearestvalid = -1; + if (!*heavy_mode) + nearestvalid = nav::FindNearestValidbyDist(ent->m_vecOrigin(), 200, 2000, true); + else + nearestvalid = nav::FindNearestValidbyDist(ent->m_vecOrigin(), 200, 1000, true); + if (nearestvalid != -1) + { + auto area = nav::areas[nearestvalid]; + nav::NavTo(area.m_center, false, true, 1337); + lastgoal = area.m_center; + lastent = ent->m_IDX; + return true; + } + else if ((lastgoal.x > 1.0f || lastgoal.x < -1.0f) && lastgoal.DistTo(LOCAL_E->m_vecOrigin()) > 200.0f) + { + nav::NavTo(lastgoal, false, true, 1337); + lastgoal = {0, 0, 0}; + return true; + } + else + { + lastgoal = {0, 0, 0}; + lastent = -1; + } + } + + } + + auto ent = NearestEnemy(); if (CE_GOOD(ent)) { - int nearestvalid{}; + int nearestvalid = -1; if (!*heavy_mode) - nearestvalid = - nav::FindNearestValidbyDist(ent->m_vecOrigin(), 2000, 6000); + nearestvalid = nav::FindNearestValidbyDist(ent->m_vecOrigin(), 200, 2000, true); else - nearestvalid = - nav::FindNearestValidbyDist(ent->m_vecOrigin(), 200, 1000); + nearestvalid = nav::FindNearestValidbyDist(ent->m_vecOrigin(), 200, 1000, true); if (nearestvalid != -1) { auto area = nav::areas[nearestvalid]; nav::NavTo(area.m_center, false, true, 1337); lastgoal = area.m_center; + lastent = ent->m_IDX; return true; } + else if ((lastgoal.x > 1.0f || lastgoal.x < -1.0f) && lastgoal.DistTo(LOCAL_E->m_vecOrigin()) > 200.0f) + { + nav::NavTo(lastgoal, false, true, 1337); + lastgoal = {0, 0, 0}; + return true; + } + else + { + lastgoal = {0, 0, 0}; + lastent = -1; + } } - else if (lastgoal.z && LOCAL_E->m_vecOrigin().DistTo(lastgoal) > 200.0f) + else if ((lastgoal.x > 1.0f || lastgoal.x < -1.0f) && lastgoal.DistTo(LOCAL_E->m_vecOrigin()) > 200.0f) { nav::NavTo(lastgoal, false, true, 1337); + lastgoal = {0, 0, 0}; return true; } else - lastgoal = {}; + { + lastgoal = {0, 0, 0}; + lastent = -1; + } } return false; } @@ -461,9 +518,6 @@ static HookedFunction return; if (primary_only && enable) UpdateSlot(); - if (*stay_near && nav_enemy_cd.test_and_set(1000) && - (!HasLowAmmo()) & (!HasLowHealth())) - NavToEnemy(); if (HasLowHealth() && ammo_health_cooldown.test_and_set(5000)) { CachedEntity *med = nearestHealth(); @@ -508,6 +562,10 @@ static HookedFunction } } } + if (*stay_near && nav_enemy_cd.test_and_set(1000) && + !HasLowAmmo() && !HasLowHealth()) + if (NavToEnemy()) + return; if (enable) { if (!nav::ReadyForCommands && !spy_mode && !heavy_mode && diff --git a/src/hooks/CreateMove.cpp b/src/hooks/CreateMove.cpp index ed85ea5f..e1628933 100644 --- a/src/hooks/CreateMove.cpp +++ b/src/hooks/CreateMove.cpp @@ -101,6 +101,8 @@ void RunEnginePrediction(IClientEntity *ent, CUserCmd *ucmd) g_GlobalVars->frametime = frameTime; g_GlobalVars->curtime = curTime; + // Adjust tickbase + NET_INT(ent, netvar.nTickBase)++; return; } } // namespace engine_prediction diff --git a/src/irc.cpp b/src/irc.cpp index 2007c8be..d65a9509 100644 --- a/src/irc.cpp +++ b/src/irc.cpp @@ -246,24 +246,29 @@ static HookedFunction paint(HookedFunctions_types::HF_Paint, "IRC", 16, []() { { if (last_steamid_received.test_and_set(10000)) { - if (!steamidvec.empty()) - { - steamidvec.push_back(g_ISteamUser->GetSteamID().GetAccountID()); - int idx = -1; - unsigned lowest = UINT_MAX; - for (int i = 0; i < steamidvec.size(); i++) - if (steamidvec[i] < lowest) - { - lowest = steamidvec[i]; - idx = i; - } - if (idx != -1 && steamidvec[idx] != g_ISteamUser->GetSteamID().GetAccountID()) + static uintptr_t addr = gSignatures.GetClientSignature("55 89 E5 57 56 53 83 EC ? 8B 7D ? 8B 77 ? 85 F6 0F 84"); + typedef int (*GetNumOnlineMembers_t)(re::CTFPartyClient *); + auto GetNumOnlineMembers_fn = GetNumOnlineMembers_t(addr); + auto party_client = re::CTFPartyClient::GTFPartyClient(); + if (party_client && GetNumOnlineMembers_fn(party_client) != 6) + if (!steamidvec.empty()) { - hack::command_stack().push("tf_party_leave"); - hack::command_stack().push(format("tf_party_request_join_user ", steamidvec[idx])); + steamidvec.push_back(g_ISteamUser->GetSteamID().GetAccountID()); + int idx = -1; + unsigned lowest = UINT_MAX; + for (int i = 0; i < steamidvec.size(); i++) + if (steamidvec[i] < lowest) + { + lowest = steamidvec[i]; + idx = i; + } + if (idx != -1 && steamidvec[idx] != g_ISteamUser->GetSteamID().GetAccountID()) + { + hack::command_stack().push("tf_party_leave"); + hack::command_stack().push(format("tf_party_request_join_user ", steamidvec[idx])); + } + steamidvec.clear(); } - steamidvec.clear(); - } } if (irc_party && last_sent_steamid.test_and_set(*party_cooldown * 1000)) irc.privmsg(format("cc_partysteam", diff --git a/src/navparser.cpp b/src/navparser.cpp index c42b36f4..2f170e5c 100644 --- a/src/navparser.cpp +++ b/src/navparser.cpp @@ -28,24 +28,11 @@ int FindInVector(size_t id) } static int bestarea = -1; Timer reselect{}; -int FindNearestValidbyDist(Vector vec, float mindist, float maxdist) +int FindNearestValidbyDist(Vector vec, float mindist, float maxdist, bool closest) { if (reselect.test_and_set(500)) { float bestscr = FLT_MAX; - if (bestarea != -1) - { - bool success = false; - Vector area = areas[bestarea].m_center; - float scr = area.DistTo(vec); - if (scr < maxdist && scr > mindist) - if (IsVectorVisible(vec, area, false)) - success = true; - if (!success) - bestarea = -1; - } - else - { bestarea = -1; for (int ar = 0; ar < areas.size(); ar++) { @@ -54,7 +41,13 @@ int FindNearestValidbyDist(Vector vec, float mindist, float maxdist) float scr = area.DistTo(vec); if (scr > maxdist || scr < mindist) continue; - if (scr > bestscr) + if (closest) + { + if (scr > bestscr) + continue; + + } + else if (scr < bestscr) continue; if (IsVectorVisible(vec, area, false)) { @@ -62,7 +55,6 @@ int FindNearestValidbyDist(Vector vec, float mindist, float maxdist) bestarea = ar; } } - } } return bestarea; } @@ -330,6 +322,7 @@ void clearInstructions() static Timer ignoreReset{}; static Timer patherReset{}; static Timer sentryUpdate{}; +static Timer sentryClear{}; static Timer sentryCheck{}; // Function for removing ignores void ignoreManagerCM() @@ -340,8 +333,10 @@ void ignoreManagerCM() TF2MAP->inactiveTracker.reset(); if (patherReset.test_and_set(30000)) TF2MAP->pather->Reset(); - if (sentryUpdate.test_and_set(1000)) - TF2MAP->inactiveTracker.updateSentries(); + if (sentryClear.test_and_set(20000)) + TF2MAP->inactiveTracker.ClearSentries(); + if (sentryUpdate.test_and_set(500)) + TF2MAP->inactiveTracker.AddSentries(); } void Repath()