From f2f58403a9628b65065c5e92812a25555c7047f1 Mon Sep 17 00:00:00 2001 From: LightCat Date: Mon, 20 Aug 2018 21:44:01 +0200 Subject: [PATCH 1/8] Engie mode --- build_names | 1 - data/menu/nullifiedcat/catbot.xml | 1 + include/core/netvars.hpp | 1 + src/core/netvars.cpp | 2 + src/hacks/NavBot.cpp | 230 +++++++++++++++++++++++++++--- 5 files changed, 217 insertions(+), 18 deletions(-) diff --git a/build_names b/build_names index 04cd2951..5e199666 100755 --- a/build_names +++ b/build_names @@ -23,4 +23,3 @@ libtinfo.so.5.9.4.2 libudev.so.1.6.6.4.7 libwrap.so.0.7.6.1.5 libz.so.1.2.1.1.2.4 - diff --git a/data/menu/nullifiedcat/catbot.xml b/data/menu/nullifiedcat/catbot.xml index a8e78ecf..9ecace83 100755 --- a/data/menu/nullifiedcat/catbot.xml +++ b/data/menu/nullifiedcat/catbot.xml @@ -61,6 +61,7 @@ + diff --git a/include/core/netvars.hpp b/include/core/netvars.hpp index cee7796b..bf3170fc 100755 --- a/include/core/netvars.hpp +++ b/include/core/netvars.hpp @@ -63,6 +63,7 @@ public: offset_t hActiveWeapon; offset_t flChargedDamage; offset_t iUpgradeLevel; + offset_t m_hBuilder; offset_t iPipeType; offset_t iBuildingHealth; offset_t iBuildingMaxHealth; diff --git a/src/core/netvars.cpp b/src/core/netvars.cpp index 9ac29553..d94f25b9 100644 --- a/src/core/netvars.cpp +++ b/src/core/netvars.cpp @@ -120,6 +120,8 @@ void NetVars::Init() "DT_TFSniperRifle", "SniperRifleLocalData", "m_flChargedDamage"); this->iUpgradeLevel = gNetvars.get_offset("DT_BaseObject", "m_iUpgradeLevel"); + this->m_hBuilder = + gNetvars.get_offset("DT_BaseObject", "m_hBuilder"); this->iPipeType = gNetvars.get_offset("DT_TFProjectile_Pipebomb", "m_iType"); this->iBuildingHealth = diff --git a/src/hacks/NavBot.cpp b/src/hacks/NavBot.cpp index 7a642aaa..46a22fc5 100644 --- a/src/hacks/NavBot.cpp +++ b/src/hacks/NavBot.cpp @@ -12,6 +12,7 @@ namespace hacks::tf2::NavBot static settings::Bool enable("navbot.enable", "false"); static settings::Bool spy_mode("navbot.spy-mode", "false"); static settings::Bool heavy_mode("navbot.heavy-mode", "false"); +static settings::Bool engi_mode("navbot.engi-mode", "false"); static settings::Bool primary_only("navbot.primary-only", "true"); static settings::Bool enable_fb{ "navbot.medbot", "false" }; @@ -157,16 +158,27 @@ CachedEntity *NearestEnemy() Timer cdr{}; Timer cd2{}; Timer cd3{}; +Timer engi_spot_cd{}; +std::vector preferred_sniper_spots; std::vector sniper_spots; +std::vector nest_spots; void Init() { sniper_spots.clear(); + preferred_sniper_spots.clear(); + nest_spots.clear(); for (auto area : nav::areas) + { + if (area.m_attributeFlags & NAV_MESH_NO_HOSTAGES) + preferred_sniper_spots.push_back(area.m_center); + if (area.m_attributeFlags & NAV_MESH_RUN) + nest_spots.push_back(area.m_center); for (auto hide : area.m_hidingSpots) if (hide.IsGoodSniperSpot() || hide.IsIdealSniperSpot() || hide.IsExposed()) sniper_spots.push_back(hide.m_pos); - logging::Info("%d", sniper_spots.size()); + } + logging::Info("Sniper spots: %d, Manual Sniper Spots: %d, Sentry Spots: %d", sniper_spots.size(), preferred_sniper_spots.size(), nest_spots.size()); } void initonce() { @@ -175,6 +187,7 @@ void initonce() cdr.update(); cd2.update(); cd3.update(); + engi_spot_cd.update(); return; } @@ -191,7 +204,7 @@ void UpdateSlot() { int slot = re::C_BaseCombatWeapon::GetSlot(weapon); int newslot = 1; - if (spy_mode) + if (spy_mode || engi_mode) newslot = 3; if (slot != newslot - 1) g_IEngine->ClientCmd_Unrestricted( @@ -199,6 +212,76 @@ void UpdateSlot() } } } +enum BuildingNum +{ + DISPENSER = 0, + TELEPORT_ENT, + SENTRY, + TELEPORT_EXT, +}; +std::vector GetBuildings() + { + float bestscr = FLT_MAX; + std::vector buildings; + for (int i = 0; i < HIGHEST_ENTITY; i++) + { + CachedEntity *ent = ENTITY(i); + if (CE_BAD(ent)) + continue; + if (ent->m_Type() != ENTITY_BUILDING) + continue; + if ((CE_INT(ent, netvar.m_hBuilder) & 0xFFF) != g_pLocalPlayer->entity_idx) + continue; + if (ent->m_vecOrigin().DistTo(LOCAL_E->m_vecOrigin()) < bestscr) + { + buildings.push_back(i); + bestscr = ent->m_vecOrigin().DistTo(LOCAL_E->m_vecOrigin()); + } + } + return buildings; +} +int cost[4] = {100, 50, 130, 50}; +int GetBestBuilding(int metal) +{ + bool hasSentry, hasDispenser; + if (!GetBuildings().empty()) + for (auto build : GetBuildings()) + { + CachedEntity *building = ENTITY(build); + if (building->m_iClassID() == CL_CLASS(CObjectSentrygun)) + hasSentry = true; + if (building->m_iClassID() == CL_CLASS(CObjectDispenser)) + hasDispenser = true; + } + if (metal >= cost[SENTRY] && !hasSentry) + return SENTRY; + else if (metal >= cost[DISPENSER] && !hasDispenser) + return DISPENSER; + if (hasSentry && hasDispenser) + return 3; + return -1; +} +int GetClosestBuilding() +{ + float bestscr = FLT_MAX; + int BestBuilding = -1; + for (int i = 0; i < HIGHEST_ENTITY; i++) + { + CachedEntity *ent = ENTITY(i); + if (CE_BAD(ent)) + continue; + if (ent->m_Type() != ENTITY_BUILDING) + continue; + if ((CE_INT(ent, netvar.m_hBuilder) & 0xFFF) != g_pLocalPlayer->entity_idx) + continue; + if (ent->m_vecOrigin().DistTo(LOCAL_E->m_vecOrigin()) < bestscr) + { + BestBuilding = i; + bestscr = ent->m_vecOrigin().DistTo(LOCAL_E->m_vecOrigin()); + } + } + return BestBuilding; +} int follow_target = 0; void CreateMove() { @@ -212,42 +295,40 @@ void CreateMove() { CachedEntity *med = nearestHealth(); if (CE_GOOD(med)) - { nav::NavTo(med->m_vecOrigin(), true, true, 7); - } } if (HasLowAmmo() && cdr.test_and_set(5000)) { CachedEntity *ammo = nearestAmmo(); if (CE_GOOD(ammo)) - { nav::NavTo(ammo->m_vecOrigin(), true, true, 6); - } } if ((!HasLowHealth() && nav::priority == 7) || (!HasLowAmmo() && nav::priority == 6)) nav::clearInstructions(); if (enable) { - if (!nav::ReadyForCommands && !spy_mode && !heavy_mode) + if (!nav::ReadyForCommands && !spy_mode && !heavy_mode && !engi_mode) cd3.update(); - bool isready = (spy_mode || heavy_mode) ? 1 : nav::ReadyForCommands; - int waittime = (spy_mode || heavy_mode) ? 100 : 5000; + bool isready = (spy_mode || heavy_mode || engi_mode) ? 1 : nav::ReadyForCommands; + int waittime = (spy_mode || heavy_mode || engi_mode) ? 100 : 5000; if (isready && cd3.test_and_set(waittime)) { - if (!spy_mode && !heavy_mode) + if (!spy_mode && !heavy_mode && !engi_mode) { cd3.update(); Vector random_spot; if (cd2.test_and_set(5000)) Init(); - if (!sniper_spots.size()) + if (!sniper_spots.size() && !preferred_sniper_spots.size()) return; - int rng = rand() % sniper_spots.size(); - random_spot = sniper_spots.at(rng); + auto snip_spot = preferred_sniper_spots.size() ? preferred_sniper_spots : sniper_spots; + int rng = rand() % snip_spot.size(); + random_spot = snip_spot.at(rng); if (random_spot.z) nav::NavTo(random_spot, true, true); + return; } - else + else if (!engi_mode) { CachedEntity *tar = NearestEnemy(); if (CE_BAD(tar) && last_tar == -1 && nav::ReadyForCommands) @@ -255,10 +336,11 @@ void CreateMove() Vector random_spot; if (cd2.test_and_set(5000)) Init(); - if (!sniper_spots.size()) + if (!sniper_spots.size() && !preferred_sniper_spots.size()) return; - int rng = rand() % sniper_spots.size(); - random_spot = sniper_spots.at(rng); + auto snip_spot = preferred_sniper_spots.size() ? preferred_sniper_spots : sniper_spots; + int rng = rand() % snip_spot.size(); + random_spot = snip_spot.at(rng); if (random_spot.z) nav::NavTo(random_spot, false); return; @@ -279,6 +361,120 @@ void CreateMove() } } } + // Engi Mode + else + { + // Init things + if (cd2.test_and_set(5000)) + Init(); + // If No spots set just return + if (nest_spots.empty()) + return; + // Get Metal (offset of MAX metal is +8 and current metal +12) + int metal = CE_INT(LOCAL_E, netvar.m_iAmmo + 12); + // Best spot storage + static Vector best_spot{}; + // Get Best spot based on distance + if (engi_spot_cd.test_and_set(10000)) + { + float bestscr = FLT_MAX; + for (auto spot : nest_spots) + { + if (spot.DistTo(LOCAL_E->m_vecOrigin()) < bestscr) + { + bestscr = spot.DistTo(LOCAL_E->m_vecOrigin()); + best_spot = spot; + } + } + } + if (nav::priority == 1) + { + CachedEntity *ammo = nearestAmmo(); + if (CE_GOOD(ammo)) + { + nav::NavTo(ammo->m_vecOrigin(), false, true); + return; + } + } + // If Near The best spot and ready for commands + if (best_spot.DistTo(LOCAL_E->m_vecOrigin()) < 300.0f && (nav::ReadyForCommands || nav::priority == 1)) + { + // Get the closest Building + int ClosestBuilding = GetClosestBuilding(); + // If A Building was found + if (ClosestBuilding != -1) + { + CachedEntity *ent = ENTITY(ClosestBuilding); + // If we have more than 25 metal and the building is damaged or not fully upgraded hit it with the wrench + if (metal > 25 && (CE_INT(ent, netvar.iUpgradeLevel) < 3 || CE_INT(ent, netvar.iBuildingHealth) < CE_INT(ent, netvar.iBuildingMaxHealth))) + { + auto collide = RAW_ENT(ent)->GetCollideable(); + Vector min = ent->m_vecOrigin() + collide->OBBMins(); + Vector max = ent->m_vecOrigin() + collide->OBBMaxs(); + // Distance check + if (min.DistTo(g_pLocalPlayer->v_Eye) > re::C_TFWeaponBaseMelee::GetSwingRange(RAW_ENT(LOCAL_W)) && max.DistTo(g_pLocalPlayer->v_Eye) > re::C_TFWeaponBaseMelee::GetSwingRange(RAW_ENT(LOCAL_W)) && GetBuildingPosition(ent).DistTo(g_pLocalPlayer->v_Eye) > re::C_TFWeaponBaseMelee::GetSwingRange(RAW_ENT(LOCAL_W))) + { + float min = min.DistTo(g_pLocalPlayer->v_Eye); + float max = max.DistTo(g_pLocalPlayer->v_Eye); + float center = GetBuildingPosition(ent).DistTo(g_pLocalPlayer->v_Eye); + float closest = fminf(min, fminf(max, center)); + nav::NavTo(closest, false, false); + } + Vector tr = GetBuildingPosition(ent) - g_pLocalPlayer->v_Eye; + Vector angles; + VectorAngles(tr, angles); + // Clamping is important + fClampAngle(angles); + current_user_cmd->viewangles = angles; + current_user_cmd->buttons |= IN_ATTACK; + g_pLocalPlayer->bUseSilentAngles = true; + return; + } + } + // Get A building, Sentry > Dispenser + int tobuild = GetBestBuilding(metal); + // If not enough metal then Find ammo + if (tobuild == -1) + { + CachedEntity *ammo = nearestAmmo(); + if (CE_GOOD(ammo)) + { + nav::NavTo(ammo->m_vecOrigin(), false, true); + return; + } + // Ammo is dormant, go and find it! + else if (sniper_spots.size() && nav::ReadyForCommands) + { + Vector random_spot; + if (cd2.test_and_set(5000)) + Init(); + if (!sniper_spots.size() && !preferred_sniper_spots.size()) + return; + auto snip_spot = preferred_sniper_spots.size() ? preferred_sniper_spots : sniper_spots; + int rng = rand() % snip_spot.size(); + random_spot = snip_spot.at(rng); + if (random_spot.z) + nav::NavTo(random_spot, false, false, 1); + return; + } + } + // Build Building + else if (tobuild != 3) + { + // Make ENgi look slightly down + current_user_cmd->viewangles.x = 20.0f; + // Build buildings in a 360° angle around player + current_user_cmd->viewangles.y = 90.0f * (tobuild + 1); + // Build new one + g_IEngine->ServerCmd(format("build ", tobuild).c_str(), true); + current_user_cmd->buttons |= IN_ATTACK; + g_pLocalPlayer->bUseSilentAngles = true; + } + } + // If not near best spot then navigate to it + else if (nav::ReadyForCommands) + nav::NavTo(best_spot, false, true); + } } } else if (enable_fb) From 9fccf7e76d1b53fe6961a3f2f08e407fb63589d1 Mon Sep 17 00:00:00 2001 From: LightCat Date: Tue, 21 Aug 2018 00:28:42 +0200 Subject: [PATCH 2/8] Update NavBot.cpp --- src/hacks/NavBot.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/hacks/NavBot.cpp b/src/hacks/NavBot.cpp index 46a22fc5..2c1feaea 100644 --- a/src/hacks/NavBot.cpp +++ b/src/hacks/NavBot.cpp @@ -414,10 +414,11 @@ void CreateMove() // Distance check if (min.DistTo(g_pLocalPlayer->v_Eye) > re::C_TFWeaponBaseMelee::GetSwingRange(RAW_ENT(LOCAL_W)) && max.DistTo(g_pLocalPlayer->v_Eye) > re::C_TFWeaponBaseMelee::GetSwingRange(RAW_ENT(LOCAL_W)) && GetBuildingPosition(ent).DistTo(g_pLocalPlayer->v_Eye) > re::C_TFWeaponBaseMelee::GetSwingRange(RAW_ENT(LOCAL_W))) { - float min = min.DistTo(g_pLocalPlayer->v_Eye); - float max = max.DistTo(g_pLocalPlayer->v_Eye); + float minf = min.DistTo(g_pLocalPlayer->v_Eye); + float maxf = max.DistTo(g_pLocalPlayer->v_Eye); float center = GetBuildingPosition(ent).DistTo(g_pLocalPlayer->v_Eye); - float closest = fminf(min, fminf(max, center)); + float closest = fminf(minf, fminf(maxf, center)); + Vector tonav = (minf == closest) ? min : (maxf == closest) ? max : GetBuildingPosition(ent); nav::NavTo(closest, false, false); } Vector tr = GetBuildingPosition(ent) - g_pLocalPlayer->v_Eye; From 737adc5e9c9feaf36f14a43a323bdee26741a76a Mon Sep 17 00:00:00 2001 From: LightCat Date: Tue, 21 Aug 2018 00:31:11 +0200 Subject: [PATCH 3/8] Update NavBot.cpp --- src/hacks/NavBot.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hacks/NavBot.cpp b/src/hacks/NavBot.cpp index 2c1feaea..26efd86d 100644 --- a/src/hacks/NavBot.cpp +++ b/src/hacks/NavBot.cpp @@ -419,7 +419,7 @@ void CreateMove() float center = GetBuildingPosition(ent).DistTo(g_pLocalPlayer->v_Eye); float closest = fminf(minf, fminf(maxf, center)); Vector tonav = (minf == closest) ? min : (maxf == closest) ? max : GetBuildingPosition(ent); - nav::NavTo(closest, false, false); + nav::NavTo(tonav, false, false); } Vector tr = GetBuildingPosition(ent) - g_pLocalPlayer->v_Eye; Vector angles; From 1d8cef9520ba96d0f45ecccd90dbe065b1c67794 Mon Sep 17 00:00:00 2001 From: LightCat Date: Tue, 21 Aug 2018 12:06:56 +0200 Subject: [PATCH 4/8] More fixes, textmode.club --- data/menu/nullifiedcat/catbot.xml | 2 +- include/tfmm.hpp | 1 + src/core/netvars.cpp | 3 +- src/hacks/AutoJoin.cpp | 2 +- src/hacks/NavBot.cpp | 133 +++++++++++++++++++---------- src/hooks/Shutdown.cpp | 4 +- src/hooks/visual/PaintTraverse.cpp | 23 +++-- src/navparser.cpp | 32 +++---- src/online/Online.cpp | 1 - src/textmode.cpp | 4 +- src/tfmm.cpp | 13 ++- 11 files changed, 140 insertions(+), 78 deletions(-) mode change 100755 => 100644 src/textmode.cpp diff --git a/data/menu/nullifiedcat/catbot.xml b/data/menu/nullifiedcat/catbot.xml index 9ecace83..e873011d 100755 --- a/data/menu/nullifiedcat/catbot.xml +++ b/data/menu/nullifiedcat/catbot.xml @@ -64,7 +64,7 @@ - + diff --git a/include/tfmm.hpp b/include/tfmm.hpp index fd7f252a..43236a2d 100644 --- a/include/tfmm.hpp +++ b/include/tfmm.hpp @@ -14,5 +14,6 @@ void startQueue(); void leaveQueue(); void disconnectAndAbandon(); void abandon(); +bool isMMBanned(); int getQueue(); } // namespace tfmm diff --git a/src/core/netvars.cpp b/src/core/netvars.cpp index d94f25b9..6e057904 100644 --- a/src/core/netvars.cpp +++ b/src/core/netvars.cpp @@ -120,8 +120,7 @@ void NetVars::Init() "DT_TFSniperRifle", "SniperRifleLocalData", "m_flChargedDamage"); this->iUpgradeLevel = gNetvars.get_offset("DT_BaseObject", "m_iUpgradeLevel"); - this->m_hBuilder = - gNetvars.get_offset("DT_BaseObject", "m_hBuilder"); + this->m_hBuilder = gNetvars.get_offset("DT_BaseObject", "m_hBuilder"); this->iPipeType = gNetvars.get_offset("DT_TFProjectile_Pipebomb", "m_iType"); this->iBuildingHealth = diff --git a/src/hacks/AutoJoin.cpp b/src/hacks/AutoJoin.cpp index 6c662090..5397ff92 100644 --- a/src/hacks/AutoJoin.cpp +++ b/src/hacks/AutoJoin.cpp @@ -97,7 +97,7 @@ void updateSearch() logging::Info("Starting queue"); tfmm::startQueue(); } -#if LAGBOT_MODE +#if not ENABLE_VISUALS if (req_timer.test_and_set(1800000)) { logging::Info("Stuck in queue, segfaulting"); diff --git a/src/hacks/NavBot.cpp b/src/hacks/NavBot.cpp index 26efd86d..d498a7aa 100644 --- a/src/hacks/NavBot.cpp +++ b/src/hacks/NavBot.cpp @@ -125,10 +125,12 @@ CachedEntity *nearestAmmo() int last_tar = -1; CachedEntity *NearestEnemy() { - if (last_tar == -1 || nav::ReadyForCommands) { - float bestscr = FLT_MAX; + if (last_tar == -1 || nav::ReadyForCommands) + { + float bestscr = FLT_MAX; CachedEntity *bestent = nullptr; - for (int i = 0; i < g_IEngine->GetMaxClients(); i++) { + for (int i = 0; i < g_IEngine->GetMaxClients(); i++) + { CachedEntity *ent = ENTITY(i); if (CE_BAD(ent) || ent->m_Type() != ENTITY_PLAYER) continue; @@ -140,7 +142,8 @@ CachedEntity *NearestEnemy() scr *= 5.0f; if (g_pPlayerResource->GetClass(ent) == tf_pyro) scr *= 7.0f; - if (scr < bestscr) { + if (scr < bestscr) + { bestscr = scr; bestent = ent; } @@ -178,7 +181,9 @@ void Init() hide.IsExposed()) sniper_spots.push_back(hide.m_pos); } - logging::Info("Sniper spots: %d, Manual Sniper Spots: %d, Sentry Spots: %d", sniper_spots.size(), preferred_sniper_spots.size(), nest_spots.size()); + logging::Info("Sniper spots: %d, Manual Sniper Spots: %d, Sentry Spots: %d", + sniper_spots.size(), preferred_sniper_spots.size(), + nest_spots.size()); } void initonce() { @@ -220,27 +225,28 @@ enum BuildingNum TELEPORT_EXT, }; std::vector GetBuildings() +{ + float bestscr = FLT_MAX; + std::vector buildings; + for (int i = 0; i < HIGHEST_ENTITY; i++) { - float bestscr = FLT_MAX; - std::vector buildings; - for (int i = 0; i < HIGHEST_ENTITY; i++) + CachedEntity *ent = ENTITY(i); + if (CE_BAD(ent)) + continue; + if (ent->m_Type() != ENTITY_BUILDING) + continue; + if ((CE_INT(ent, netvar.m_hBuilder) & 0xFFF) != + g_pLocalPlayer->entity_idx) + continue; + if (ent->m_vecOrigin().DistTo(LOCAL_E->m_vecOrigin()) < bestscr) { - CachedEntity *ent = ENTITY(i); - if (CE_BAD(ent)) - continue; - if (ent->m_Type() != ENTITY_BUILDING) - continue; - if ((CE_INT(ent, netvar.m_hBuilder) & 0xFFF) != g_pLocalPlayer->entity_idx) - continue; - if (ent->m_vecOrigin().DistTo(LOCAL_E->m_vecOrigin()) < bestscr) - { - buildings.push_back(i); - bestscr = ent->m_vecOrigin().DistTo(LOCAL_E->m_vecOrigin()); - } + buildings.push_back(i); + bestscr = ent->m_vecOrigin().DistTo(LOCAL_E->m_vecOrigin()); } - return buildings; + } + return buildings; } -int cost[4] = {100, 50, 130, 50}; +int cost[4] = { 100, 50, 130, 50 }; int GetBestBuilding(int metal) { bool hasSentry, hasDispenser; @@ -263,7 +269,7 @@ int GetBestBuilding(int metal) } int GetClosestBuilding() { - float bestscr = FLT_MAX; + float bestscr = FLT_MAX; int BestBuilding = -1; for (int i = 0; i < HIGHEST_ENTITY; i++) { @@ -272,12 +278,13 @@ int GetClosestBuilding() continue; if (ent->m_Type() != ENTITY_BUILDING) continue; - if ((CE_INT(ent, netvar.m_hBuilder) & 0xFFF) != g_pLocalPlayer->entity_idx) + if ((CE_INT(ent, netvar.m_hBuilder) & 0xFFF) != + g_pLocalPlayer->entity_idx) continue; if (ent->m_vecOrigin().DistTo(LOCAL_E->m_vecOrigin()) < bestscr) { BestBuilding = i; - bestscr = ent->m_vecOrigin().DistTo(LOCAL_E->m_vecOrigin()); + bestscr = ent->m_vecOrigin().DistTo(LOCAL_E->m_vecOrigin()); } } return BestBuilding; @@ -303,13 +310,15 @@ void CreateMove() if (CE_GOOD(ammo)) nav::NavTo(ammo->m_vecOrigin(), true, true, 6); } - if ((!HasLowHealth() && nav::priority == 7) || (!HasLowAmmo() && nav::priority == 6)) + if ((!HasLowHealth() && nav::priority == 7) || + (!HasLowAmmo() && nav::priority == 6)) nav::clearInstructions(); if (enable) { if (!nav::ReadyForCommands && !spy_mode && !heavy_mode && !engi_mode) cd3.update(); - bool isready = (spy_mode || heavy_mode || engi_mode) ? 1 : nav::ReadyForCommands; + bool isready = + (spy_mode || heavy_mode || engi_mode) ? 1 : nav::ReadyForCommands; int waittime = (spy_mode || heavy_mode || engi_mode) ? 100 : 5000; if (isready && cd3.test_and_set(waittime)) { @@ -321,7 +330,9 @@ void CreateMove() Init(); if (!sniper_spots.size() && !preferred_sniper_spots.size()) return; - auto snip_spot = preferred_sniper_spots.size() ? preferred_sniper_spots : sniper_spots; + auto snip_spot = preferred_sniper_spots.size() + ? preferred_sniper_spots + : sniper_spots; int rng = rand() % snip_spot.size(); random_spot = snip_spot.at(rng); if (random_spot.z) @@ -338,7 +349,9 @@ void CreateMove() Init(); if (!sniper_spots.size() && !preferred_sniper_spots.size()) return; - auto snip_spot = preferred_sniper_spots.size() ? preferred_sniper_spots : sniper_spots; + auto snip_spot = preferred_sniper_spots.size() + ? preferred_sniper_spots + : sniper_spots; int rng = rand() % snip_spot.size(); random_spot = snip_spot.at(rng); if (random_spot.z) @@ -347,11 +360,13 @@ void CreateMove() } if (CE_GOOD(tar)) { - if (!spy_mode || !hacks::shared::backtrack::isBacktrackEnabled) + if (!spy_mode || + !hacks::shared::backtrack::isBacktrackEnabled) nav::NavTo(tar->m_vecOrigin(), false); else { - for (auto i : hacks::shared::backtrack::headPositions[tar->m_IDX]) + for (auto i : hacks::shared::backtrack::headPositions + [tar->m_IDX]) { if (!hacks::shared::backtrack::ValidTick(i, tar)) continue; @@ -382,7 +397,7 @@ void CreateMove() { if (spot.DistTo(LOCAL_E->m_vecOrigin()) < bestscr) { - bestscr = spot.DistTo(LOCAL_E->m_vecOrigin()); + bestscr = spot.DistTo(LOCAL_E->m_vecOrigin()); best_spot = spot; } } @@ -397,7 +412,8 @@ void CreateMove() } } // If Near The best spot and ready for commands - if (best_spot.DistTo(LOCAL_E->m_vecOrigin()) < 300.0f && (nav::ReadyForCommands || nav::priority == 1)) + if (best_spot.DistTo(LOCAL_E->m_vecOrigin()) < 300.0f && + (nav::ReadyForCommands || nav::priority == 1)) { // Get the closest Building int ClosestBuilding = GetClosestBuilding(); @@ -405,23 +421,46 @@ void CreateMove() if (ClosestBuilding != -1) { CachedEntity *ent = ENTITY(ClosestBuilding); - // If we have more than 25 metal and the building is damaged or not fully upgraded hit it with the wrench - if (metal > 25 && (CE_INT(ent, netvar.iUpgradeLevel) < 3 || CE_INT(ent, netvar.iBuildingHealth) < CE_INT(ent, netvar.iBuildingMaxHealth))) + // If we have more than 25 metal and the building is + // damaged or not fully upgraded hit it with the wrench + if (metal > 25 && + (CE_INT(ent, netvar.iUpgradeLevel) < 3 || + CE_INT(ent, netvar.iBuildingHealth) < + CE_INT(ent, netvar.iBuildingMaxHealth))) { auto collide = RAW_ENT(ent)->GetCollideable(); - Vector min = ent->m_vecOrigin() + collide->OBBMins(); - Vector max = ent->m_vecOrigin() + collide->OBBMaxs(); + Vector min = + ent->m_vecOrigin() + collide->OBBMins(); + Vector max = + ent->m_vecOrigin() + collide->OBBMaxs(); // Distance check - if (min.DistTo(g_pLocalPlayer->v_Eye) > re::C_TFWeaponBaseMelee::GetSwingRange(RAW_ENT(LOCAL_W)) && max.DistTo(g_pLocalPlayer->v_Eye) > re::C_TFWeaponBaseMelee::GetSwingRange(RAW_ENT(LOCAL_W)) && GetBuildingPosition(ent).DistTo(g_pLocalPlayer->v_Eye) > re::C_TFWeaponBaseMelee::GetSwingRange(RAW_ENT(LOCAL_W))) + if (min.DistTo(g_pLocalPlayer->v_Eye) > + re::C_TFWeaponBaseMelee::GetSwingRange( + RAW_ENT(LOCAL_W)) && + max.DistTo(g_pLocalPlayer->v_Eye) > + re::C_TFWeaponBaseMelee::GetSwingRange( + RAW_ENT(LOCAL_W)) && + GetBuildingPosition(ent).DistTo( + g_pLocalPlayer->v_Eye) > + re::C_TFWeaponBaseMelee::GetSwingRange( + RAW_ENT(LOCAL_W))) { float minf = min.DistTo(g_pLocalPlayer->v_Eye); float maxf = max.DistTo(g_pLocalPlayer->v_Eye); - float center = GetBuildingPosition(ent).DistTo(g_pLocalPlayer->v_Eye); - float closest = fminf(minf, fminf(maxf, center)); - Vector tonav = (minf == closest) ? min : (maxf == closest) ? max : GetBuildingPosition(ent); + float center = GetBuildingPosition(ent).DistTo( + g_pLocalPlayer->v_Eye); + float closest = + fminf(minf, fminf(maxf, center)); + Vector tonav = + (minf == closest) + ? min + : (maxf == closest) + ? max + : GetBuildingPosition(ent); nav::NavTo(tonav, false, false); } - Vector tr = GetBuildingPosition(ent) - g_pLocalPlayer->v_Eye; + Vector tr = GetBuildingPosition(ent) - + g_pLocalPlayer->v_Eye; Vector angles; VectorAngles(tr, angles); // Clamping is important @@ -449,9 +488,12 @@ void CreateMove() Vector random_spot; if (cd2.test_and_set(5000)) Init(); - if (!sniper_spots.size() && !preferred_sniper_spots.size()) + if (!sniper_spots.size() && + !preferred_sniper_spots.size()) return; - auto snip_spot = preferred_sniper_spots.size() ? preferred_sniper_spots : sniper_spots; + auto snip_spot = preferred_sniper_spots.size() + ? preferred_sniper_spots + : sniper_spots; int rng = rand() % snip_spot.size(); random_spot = snip_spot.at(rng); if (random_spot.z) @@ -467,7 +509,8 @@ void CreateMove() // Build buildings in a 360° angle around player current_user_cmd->viewangles.y = 90.0f * (tobuild + 1); // Build new one - g_IEngine->ServerCmd(format("build ", tobuild).c_str(), true); + g_IEngine->ServerCmd(format("build ", tobuild).c_str(), + true); current_user_cmd->buttons |= IN_ATTACK; g_pLocalPlayer->bUseSilentAngles = true; } diff --git a/src/hooks/Shutdown.cpp b/src/hooks/Shutdown.cpp index ad18fd3f..80ad2fb4 100644 --- a/src/hooks/Shutdown.cpp +++ b/src/hooks/Shutdown.cpp @@ -21,11 +21,11 @@ DEFINE_HOOKED_METHOD(Shutdown, void, INetChannel *this_, const char *reason) // This is a INetChannel hook - it SHOULDN'T be static because netchannel // changes. logging::Info("Disconnect: %s", reason); - if (strstr(reason, "banned")) + if (strstr(reason, "banned") || strstr(reason, "Generic_Kicked")) { if (die_if_vac) { - logging::Info("VAC banned"); + logging::Info("VAC/Matchmaking banned"); *(int *) 0 = 0; exit(1); } diff --git a/src/hooks/visual/PaintTraverse.cpp b/src/hooks/visual/PaintTraverse.cpp index 627dfa2c..23f65dfe 100644 --- a/src/hooks/visual/PaintTraverse.cpp +++ b/src/hooks/visual/PaintTraverse.cpp @@ -70,7 +70,7 @@ and no [])", [](const CCommand &args) { bool replaced = false; namespace hooked_methods { - +Timer checkmmban{}; DEFINE_HOOKED_METHOD(PaintTraverse, void, vgui::IPanel *this_, unsigned int panel, bool force, bool allow_force) { @@ -96,21 +96,28 @@ DEFINE_HOOKED_METHOD(PaintTraverse, void, vgui::IPanel *this_, if (switcherido && spamdur && !joinspam.check(spamdur * 1000)) { auto gc = re::CTFGCClientSystem::GTFGCClientSystem(); - if (!gc) - goto label1; - gc->JoinMMMatch(); + if (gc) + gc->JoinMMMatch(); } else if (!joinspam.check(spamdur * 1000) && spamdur) { INetChannel *ch = (INetChannel *) g_IEngine->GetNetChannelInfo(); - if (!ch) - goto label1; - ch->Shutdown(""); + if (ch) + ch->Shutdown(""); } } -label1: scndwait++; switcherido = !switcherido; +#if not ENABLE_VISUALS + if (checkmmban.test_and_set(1000)) + { + if (tfmm::isMMBanned()) + { + *(int *) nullptr = 0; + exit(1); + } + } +#endif /*static bool replacedparty = false; static int callcnt = 0; if (party_bypass && !replacedparty && callcnt < 5) diff --git a/src/navparser.cpp b/src/navparser.cpp index 758f5058..1c39a9f8 100644 --- a/src/navparser.cpp +++ b/src/navparser.cpp @@ -181,9 +181,9 @@ bool Prepare() } else { - lastmap = g_IEngine->GetLevelName(); - pathfinding = false; - init = true; + lastmap = g_IEngine->GetLevelName(); + pathfinding = false; + init = true; threadingFinished = false; std::thread initer(Init); initer.detach(); @@ -211,7 +211,7 @@ int findClosestNavSquare(Vector vec) // Make sure we're not stuck on the same area for too long if (std::count(findClosestNavSquare_localAreas.begin(), findClosestNavSquare_localAreas.end(), i) < 3) - overlapping.emplace_back( i, &areas.at(i) ); + overlapping.emplace_back(i, &areas.at(i)); } } @@ -320,7 +320,7 @@ bool NavTo(Vector dest, bool navToLocalCenter, bool persistent, TF2MAP->pather->Reset(); } crumbs.clear(); - crumbs = std::move(path); + crumbs = std::move(path); lastArea = crumbs.at(0); if (!navToLocalCenter && crumbs.size() > 1) crumbs.erase(crumbs.begin()); @@ -490,15 +490,17 @@ CatCommand navpath("nav_path", "Debug nav path", [](const CCommand &args) { } }); -CatCommand navpathnolocal("nav_path_nolocal", "Debug nav path", [](const CCommand &args) { - if (NavTo(loc, false, true, 50 + priority)) - { - logging::Info("Pathing: Success! Walking to path..."); - } - else - { - logging::Info("Pathing: Failed!"); - } -}); +CatCommand navpathnolocal("nav_path_nolocal", "Debug nav path", + [](const CCommand &args) { + if (NavTo(loc, false, true, 50 + priority)) + { + logging::Info( + "Pathing: Success! Walking to path..."); + } + else + { + logging::Info("Pathing: Failed!"); + } + }); } // namespace nav diff --git a/src/online/Online.cpp b/src/online/Online.cpp index a9080929..6addb4a6 100644 --- a/src/online/Online.cpp +++ b/src/online/Online.cpp @@ -13,7 +13,6 @@ #undef null - #include #include #include diff --git a/src/textmode.cpp b/src/textmode.cpp old mode 100755 new mode 100644 index 925fe849..63620d44 --- a/src/textmode.cpp +++ b/src/textmode.cpp @@ -21,8 +21,8 @@ void EXPOSED_Epic_VACBypass_1337_DoNotSteal_xXx_$1_xXx_MLG() static unsigned char patch[] = { 0x55, 0x89, 0xE5, 0x83, 0xEC, 0x18, 0xB8, 0x01, 0x00, 0x00, 0x00, 0xC9, 0xC3 }; uintptr_t Host_IsSecureServerAllowed_addr = gSignatures.GetEngineSignature( - "55 89 E5 83 EC 18 E8 ? ? ? ? 8B 10 C7 44 24 04 ? ? ? ? 89 04 24 FF 52 " - "2C 85 C0 74 11"); + "55 89 E5 83 EC ? E8 ? ? ? ? 8B 10 C7 44 24 ? ? ? ? ? 89 04 24 FF 52 ? " + "85 C0 74 ? C6 05"); // +0x21 = allowSecureServers // logging::Info("1337 VAC bypass: 0x%08x", // Host_IsSecureServerAllowed_addr); diff --git a/src/tfmm.cpp b/src/tfmm.cpp index c4f9deb4..81617b0c 100644 --- a/src/tfmm.cpp +++ b/src/tfmm.cpp @@ -32,7 +32,17 @@ CatCommand get_state("mm_state", "Get party state", []() { namespace tfmm { - +int queuecount = 0; +bool isMMBanned() +{ + auto client = re::CTFPartyClient::GTFPartyClient(); + if (!client || (client->BInQueueForMatchGroup(7) && queuecount < 10)) + { + queuecount = 0; + return false; + } + return true; +} int getQueue() { return *queue; @@ -47,6 +57,7 @@ void startQueue() client->LoadSavedCasualCriteria(); client->RequestQueueForMatch((int) queue); hacks::shared::autojoin::resetQueueTimer(); + queuecount++; } else logging::Info("queue_start: CTFPartyClient == null!"); From 448d676007b5a5fca23e3440f20ffd6c48f28c7c Mon Sep 17 00:00:00 2001 From: LightCat Date: Tue, 21 Aug 2018 14:21:27 +0200 Subject: [PATCH 5/8] why would this not ignore players --- src/trace.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/trace.cpp b/src/trace.cpp index f54885eb..4dce6d1f 100755 --- a/src/trace.cpp +++ b/src/trace.cpp @@ -1,4 +1,4 @@ -/* +fixi/* * trace.cpp * * Created on: Oct 10, 2016 @@ -42,6 +42,8 @@ bool trace::FilterDefault::ShouldHitEntity(IHandleEntity *handle, int mask) switch (clazz->m_ClassID) { // TODO magic numbers: invisible entity ids + case 246: + case 248: case 64: case 225: case 55: @@ -79,7 +81,6 @@ void trace::FilterNoPlayer::SetSelf(IClientEntity *self) bool trace::FilterNoPlayer::ShouldHitEntity(IHandleEntity *handle, int mask) { - return false; IClientEntity *entity; ClientClass *clazz; @@ -91,6 +92,7 @@ bool trace::FilterNoPlayer::ShouldHitEntity(IHandleEntity *handle, int mask) switch (clazz->m_ClassID) { // TODO magic numbers: invisible entity ids + case case 64: case 225: case 55: From a8f902ca68d6e86889bf82d3ab675915581c481a Mon Sep 17 00:00:00 2001 From: LightCat Date: Tue, 21 Aug 2018 14:25:27 +0200 Subject: [PATCH 6/8] ""fixi"" --- src/trace.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/trace.cpp b/src/trace.cpp index 4dce6d1f..586fdd2e 100755 --- a/src/trace.cpp +++ b/src/trace.cpp @@ -1,4 +1,4 @@ -fixi/* +/* * trace.cpp * * Created on: Oct 10, 2016 From 323cee6363dceb89a47e4e9973d9bd603fa8af7c Mon Sep 17 00:00:00 2001 From: LightCat Date: Tue, 21 Aug 2018 14:31:35 +0200 Subject: [PATCH 7/8] gay --- src/trace.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/trace.cpp b/src/trace.cpp index 586fdd2e..3100dfe7 100755 --- a/src/trace.cpp +++ b/src/trace.cpp @@ -92,7 +92,8 @@ bool trace::FilterNoPlayer::ShouldHitEntity(IHandleEntity *handle, int mask) switch (clazz->m_ClassID) { // TODO magic numbers: invisible entity ids - case + case 248: + case 246: case 64: case 225: case 55: From 5f2613ef96fe76348d1021749b66baf7f2eea22d Mon Sep 17 00:00:00 2001 From: LightCat Date: Tue, 21 Aug 2018 15:27:34 +0200 Subject: [PATCH 8/8] Unsiged overflow, great --- src/hacks/AutoJoin.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/hacks/AutoJoin.cpp b/src/hacks/AutoJoin.cpp index 5397ff92..d5b6ba65 100644 --- a/src/hacks/AutoJoin.cpp +++ b/src/hacks/AutoJoin.cpp @@ -97,14 +97,6 @@ void updateSearch() logging::Info("Starting queue"); tfmm::startQueue(); } -#if not ENABLE_VISUALS - if (req_timer.test_and_set(1800000)) - { - logging::Info("Stuck in queue, segfaulting"); - *(int *) nullptr; - exit(1); - } -#endif } void update()