diff --git a/include/crits.hpp b/include/crits.hpp index 3620bd6b..029fa190 100644 --- a/include/crits.hpp +++ b/include/crits.hpp @@ -8,6 +8,7 @@ extern settings::Boolean melee; extern std::vector crit_cmds; extern int current_index; extern bool isEnabled(); +extern bool force_crit_this_tick; void fixBucket(IClientEntity *weapon, CUserCmd *cmd); class weapon_info diff --git a/src/crits.cpp b/src/crits.cpp index ed0da912..1de312a9 100644 --- a/src/crits.cpp +++ b/src/crits.cpp @@ -46,10 +46,10 @@ static bool isRapidFire(IClientEntity *wep) return ret || wep->GetClientClass()->m_ClassID == CL_CLASS(CTFMinigun); } -static float getBucketCap() +static int getBucketCap() { static ConVar *tf_weapon_criticals_bucket_cap = g_ICvar->FindVar("tf_weapon_criticals_bucket_cap"); - return tf_weapon_criticals_bucket_cap->GetFloat(); + return tf_weapon_criticals_bucket_cap->GetInt(); } static float getWithdrawMult(IClientEntity *wep) @@ -64,7 +64,7 @@ static float getWithdrawMult(IClientEntity *wep) if (g_pLocalPlayer->weapon_mode != weapon_melee) flMultiply = RemapValClamped(((float) call_count / (float) crit_checks), 0.1f, 1.f, 1.f, 3.f); - float flToRemove = flMultiply * 3.0; + float flToRemove = flMultiply * 3.0f; return flToRemove; } @@ -84,10 +84,10 @@ static bool isAllowedToWithdrawFromBucket(IClientEntity *wep, float flDamage, bo if (isRapidFire(wep)) flToRemove = taken_per_crit * getWithdrawMult(wep); // Can remove - if (flToRemove <= info.crit_bucket) - return true; + if (flToRemove > info.crit_bucket) + return false; - return false; + return true; } // This simulates a shot in all the important aspects, like increating crit attempts, bucket, etc @@ -245,8 +245,9 @@ static bool randomCritEnabled() } // These are used when we want to force a crit regardless of states (e.g. for delayed weapons like sticky launchers) -static int force_ticks = 0; -static int prevent_ticks = 0; +static int force_ticks = 0; +static int prevent_ticks = 0; +bool force_crit_this_tick = false; // Is the hack enabled? bool isEnabled() @@ -306,7 +307,7 @@ bool prevent_crit() void force_crit() { // Crithack should not run - if (!isEnabled() && !preventCrits()) + if (!isEnabled() && !force_crit_this_tick && !preventCrits()) return; // Can't crit if (!added_per_shot) @@ -319,7 +320,7 @@ void force_crit() if (g_pLocalPlayer->weapon_mode != weapon_melee && LOCAL_W->m_iClassID() != CL_CLASS(CTFPipebombLauncher)) { // Force to not crit - if (crit_key && !crit_key.isKeyDown()) + if (!force_crit_this_tick && crit_key && !crit_key.isKeyDown()) { // Prevent Crit prevent_crit(); @@ -337,7 +338,7 @@ void force_crit() } } // We can just force to nearest crit for melee, and sticky launchers apparently - else if ((g_pLocalPlayer->weapon_mode == weapon_melee && melee) || (LOCAL_W->m_iClassID() == CL_CLASS(CTFPipebombLauncher) && enabled)) + else if ((g_pLocalPlayer->weapon_mode == weapon_melee && (melee || force_crit_this_tick)) || (LOCAL_W->m_iClassID() == CL_CLASS(CTFPipebombLauncher) && (force_crit_this_tick || enabled))) { int next_crit = nextCritTick(); if (next_crit != -1) @@ -349,7 +350,7 @@ void force_crit() if (force_ticks) force_ticks--; // Prevent crits - if (!prevent_ticks && !force_ticks && preventCrits()) + if (!force_crit_this_tick && !prevent_ticks && !force_ticks && preventCrits()) prevent_ticks = 3; if (prevent_ticks) { @@ -359,7 +360,7 @@ void force_crit() } } // Code for handling when to not crit with melee weapons - else if (force_no_crit) + else if (force_no_crit && !force_crit_this_tick) { if (hacks::shared::backtrack::isBacktrackEnabled) { @@ -397,6 +398,7 @@ void force_crit() current_late_user_cmd->random_seed = MD5_PseudoRandom(next_crit) & 0x7FFFFFFF; } } + force_crit_this_tick = false; } // Update the magic crit commands numbers @@ -492,7 +494,7 @@ static void updateCmds() // Never try to drain more than cap if (taken_per_crit * 3.0f > getBucketCap()) - taken_per_crit = getBucketCap() / 3.0f; + taken_per_crit = (float) getBucketCap() / 3.0f; } } // We found a cmd, store it @@ -580,9 +582,9 @@ void CreateMove() // Update magic crit commands updateCmds(); - if (!enabled && !melee) + if (!enabled && !force_crit_this_tick && !melee) return; - if (!force_ticks && (!(melee && g_pLocalPlayer->weapon_mode == weapon_melee) && !force_no_crit && crit_key && !crit_key.isKeyDown())) + if (!force_ticks && !force_crit_this_tick && (!(melee && g_pLocalPlayer->weapon_mode == weapon_melee) && !force_no_crit && crit_key && !crit_key.isKeyDown())) return; if (!current_late_user_cmd->command_number) return; diff --git a/src/hacks/MiscAimbot.cpp b/src/hacks/MiscAimbot.cpp index b08ede11..f7476a07 100644 --- a/src/hacks/MiscAimbot.cpp +++ b/src/hacks/MiscAimbot.cpp @@ -19,7 +19,7 @@ float sandwich_speed = 350.0f; float grav = 0.25f; int prevent = -1; -std::pair FindBestEnt(bool teammate, bool Predict, bool zcheck) +std::pair FindBestEnt(bool teammate, bool Predict, bool zcheck, bool fov_check) { CachedEntity *bestent = nullptr; float bestscr = FLT_MAX; @@ -47,8 +47,10 @@ std::pair FindBestEnt(bool teammate, bool Predict, bool if (zcheck && (ent->m_vecOrigin().z - LOCAL_E->m_vecOrigin().z) > 80.0f) continue; float scr = ent->m_flDistance(); + if (fov_check) + scr = GetFov(g_pLocalPlayer->v_OrigViewangles, g_pLocalPlayer->v_Eye, ent->m_vecOrigin()); if (g_pPlayerResource->GetClass(ent) == tf_medic) - scr *= 0.1f; + scr *= 0.5f; if (scr < bestscr) { bestent = ent; @@ -80,8 +82,10 @@ std::pair FindBestEnt(bool teammate, bool Predict, bool if (zcheck && (ent->m_vecOrigin().z - LOCAL_E->m_vecOrigin().z) > 80.0f) continue; float scr = ent->m_flDistance(); + if (fov_check) + scr = GetFov(g_pLocalPlayer->v_OrigViewangles, g_pLocalPlayer->v_Eye, ent->m_vecOrigin()); if (g_pPlayerResource->GetClass(ent) == tf_medic) - scr *= 0.1f; + scr *= 0.5f; if (scr < bestscr) { bestent = ent; @@ -177,7 +181,7 @@ static void SandwichAim() Vector Predict; CachedEntity *bestent = nullptr; std::pair result{}; - result = FindBestEnt(true, true, false); + result = FindBestEnt(true, true, false, false); bestent = result.first; Predict = result.second; if (bestent) @@ -209,7 +213,7 @@ static void ChargeAimbot() if (!HasCondition(LOCAL_E)) return; std::pair result{}; - result = FindBestEnt(false, false, true); + result = FindBestEnt(false, false, true, true); CachedEntity *bestent = result.first; if (bestent && result.second.IsValid()) { diff --git a/src/hacks/Warp.cpp b/src/hacks/Warp.cpp index 12363fc8..ecb290e4 100644 --- a/src/hacks/Warp.cpp +++ b/src/hacks/Warp.cpp @@ -221,6 +221,8 @@ void CreateMove() { case ATTACK: { + // Force a crit + criticals::force_crit_this_tick = true; current_user_cmd->buttons |= IN_ATTACK; current_state = CHARGE; should_warp = false;