diff --git a/src/hacks/Aimbot.cpp b/src/hacks/Aimbot.cpp index 5f3bbe26..0ba8d930 100644 --- a/src/hacks/Aimbot.cpp +++ b/src/hacks/Aimbot.cpp @@ -15,11 +15,11 @@ static CatVar aimkey(CV_KEY, "aimbot_aimkey", "0", "Aimkey", "Aimkey. Look at Ai static CatEnum aimkey_modes_enum({ "DISABLED", "AIMKEY", "REVERSE", "TOGGLE" }); static CatVar aimkey_mode(aimkey_modes_enum, "aimbot_aimkey_mode", "1", "Aimkey mode", "DISABLED: aimbot is always active\nAIMKEY: aimbot is active when key is down\nREVERSE: aimbot is disabled when key is down\nTOGGLE: pressing key toggles aimbot"); static CatVar autoshoot(CV_SWITCH, "aimbot_autoshoot", "1", "Autoshoot", "Shoot automatically when the target is locked, isn't compatible with 'Enable when attacking'"); -static CatEnum hitbox_mode_enum({ "AUTO-HEAD", "AUTO-CLOSEST", "STATIC" }); +static CatEnum hitbox_mode_enum({ "AUTO", "AUTO-CLOSEST", "STATIC" }); static CatVar hitbox_mode(hitbox_mode_enum, "aimbot_hitboxmode", "0", "Hitbox Mode", "Defines hitbox selection mode"); static CatVar fov(CV_FLOAT, "aimbot_fov", "0", "Aimbot FOV", "FOV range for aimbot to lock targets. \"Smart FOV\" coming eventually.", 180.0f); static CatVar fovcircle_opacity(CV_FLOAT, "aimbot_fov_draw_opacity", "0.7", "FOV Circle Opacity", "Defines opacity of FOV circle", 0.0f, 1.0f); - +// Selective and related static CatEnum priority_mode_enum({ "SMART", "FOV", "DISTANCE", "HEALTH" }); static CatVar priority_mode(priority_mode_enum, "aimbot_prioritymode", "0", "Priority mode", "Priority mode.\n" "SMART: Basically Auto-Threat. Will be tweakable eventually. " @@ -35,6 +35,7 @@ static CatVar stickybot(CV_SWITCH, "aimbot_stickys", "0", "Aim Sticky", "Should static CatVar rageonly(CV_SWITCH, "aimbot_rage_only", "0", "Ignore non-rage targets", "Use playerlist to set up rage targets"); static CatEnum teammates_enum({ "ENEMY ONLY", "TEAMMATE ONLY", "BOTH" }); static CatVar teammates(teammates_enum, "aimbot_teammates", "0", "Aim at teammates", "Use to choose which team/s to target"); +// Other prefrences static CatVar silent(CV_SWITCH, "aimbot_silent", "1", "Silent", "Your screen doesn't get snapped to the point where aimbot aims at"); static CatVar target_lock(CV_SWITCH, "aimbot_target_lock", "0", "Target Lock", "Keeps your previously chosen target untill target check fails"); static CatEnum hitbox_enum({ @@ -49,12 +50,8 @@ static CatVar max_range(CV_INT, "aimbot_maxrange", "0", "Max distance", "Max range for aimbot\n" "900-1100 range is efficient for scout/widowmaker engineer", 4096.0f); static CatVar extrapolate(CV_SWITCH, "aimbot_extrapolate", "0", "Latency extrapolation", "(NOT RECOMMENDED) latency extrapolation"); -static CatVar slowaim(CV_SWITCH, "aimbot_slow", "0", "Slow Aim", "Slowly moves your crosshair onto the target for more legit play\nDisables silent aimbot"); -static CatVar slowaim_smoothing(CV_INT, "aimbot_slow_smooth", "10", "Slow Aim Smooth", "How slow the slow aim's aiming should be", 50); -static CatVar slowaim_autoshoot(CV_INT, "aimbot_slow_autoshoot", "10", "Slow Aim Threshhold", "Distance to autoshoot while smooth aiming", 25); +static CatVar slow_aim(CV_INT, "aimbot_slow", "0", "Slow Aim", "Slowly moves your crosshair onto the target for more legit play\nDisables silent aimbot", 1, 50); static CatVar projectile_aimbot(CV_SWITCH, "aimbot_projectile", "1", "Projectile aimbot", "If you turn it off, aimbot won't try to aim with projectile weapons"); -static CatVar proj_fov(CV_SWITCH, "aimbot_proj_fovpred", "0", "Projectile FOV mode", "If disabled, FOV restrictions apply to current target position"); -static CatVar proj_visibility(CV_SWITCH, "aimbot_proj_vispred", "0", "Projectile visibility prediction", "If enabled, projectile aimbot will perform additional visibility checking and won't try to predict enemies behind walls"); static CatVar proj_gravity(CV_FLOAT, "aimbot_proj_gravity", "0", "Projectile gravity", "Force override projectile gravity. Useful for debugging.", 1.0f); static CatVar proj_speed(CV_FLOAT, "aimbot_proj_speed", "0", "Projectile speed", @@ -64,12 +61,10 @@ static CatVar proj_speed(CV_FLOAT, "aimbot_proj_speed", "0", "Projectile speed", "cathook. Yet."); static CatVar huntsman_autoshoot(CV_FLOAT, "aimbot_huntsman_charge", "0.5", "Huntsman autoshoot", "Minimum charge for autoshooting with huntsman.\n" "Set it to 0.01 if you want to shoot as soon as you start pulling the arrow", 0.01f, 1.0f); -static CatVar huntsman_full_auto(CV_SWITCH, "aimbot_full_auto_huntsman", "1", "Auto Huntsman", "Autoshoot will pull huntsman's string"); static CatVar miss_chance(CV_FLOAT, "aimbot_miss_chance", "0", "Miss chance", "From 0 to 1. Aimbot will NOT aim in these % cases", 0.0f, 1.0f); // Debug vars static CatVar aimbot_debug(CV_SWITCH, "aimbot_debug", "0", "Aimbot Debug", "Display simple debug info for aimbot"); static CatVar engine_projpred(CV_SWITCH, "debug_aimbot_engine_pp", "0", "Engine ProjPred"); - // Followbot vars static CatVar auto_spin_up(CV_SWITCH, "aimbot_spin_up", "0", "Auto Spin Up", "Spin up minigun if you can see target, useful for followbots"); static CatVar auto_zoom(CV_SWITCH, "aimbot_auto_zoom", "0", "Auto Zoom", "Automatically zoom in if you can see target, useful for followbots"); @@ -86,8 +81,7 @@ bool projectile_mode { false }; float cur_proj_speed { 0.0f }; float cur_proj_grav { 0.0f }; // If slow aimbot allows autoshoot -bool slowCanShoot = false; -bool silent_huntsman { false }; +bool slow_can_shoot = false; // This array will store calculated projectile/hitscan predictions // for current frame, to avoid performing them again @@ -96,10 +90,9 @@ AimbotCalculatedData_s calculated_data_array[2048] {}; // The main "loop" of the aimbot. void CreateMove() { PROF_SECTION(PT_aimbot_cm); - - // Check if aimbot is enabled if (!enabled) return; + // Auto-Unzoom if (auto_unzoom) { if (g_pLocalPlayer->holding_sniper_rifle) { if (g_pLocalPlayer->bZoomed) { @@ -110,100 +103,62 @@ void CreateMove() { } // Refresh projectile info - int huntsman_ticks = 0; projectile_mode = (GetProjectileData(g_pLocalPlayer->weapon(), cur_proj_speed, cur_proj_grav)); if (proj_speed) cur_proj_speed = (float)proj_speed; if (proj_gravity) cur_proj_grav = (float)proj_gravity; - // Attemt to reduce huntsman_ticks by 1 untill it reaches 0 - if (huntsman_ticks) { - // Disable attack - g_pUserCmd->buttons |= IN_ATTACK; - // Returns 0 - Something higher than 0 - huntsman_ticks = max(0, huntsman_ticks - 1); - } - - // Save should aim info // We do this as we need to pass whether the aimkey allows aiming to both the find target and aiming system. If we just call the func than toggle aimkey would break so we save it to a var to use it twice bool aimkey_status = UpdateAimkey(); // Refresh our best target CachedEntity* target = RetrieveBestTarget(aimkey_status); - - // Check target for dormancy and if there even is a target at all - if (CE_GOOD(target) && foundTarget) { + if (CE_BAD(target) || !foundTarget) return; - IF_GAME (IsTF()) { - if (auto_zoom) { - if (g_pLocalPlayer->holding_sniper_rifle) { - if (not g_pLocalPlayer->bZoomed) { - g_pUserCmd->buttons |= IN_ATTACK2; - } - } - } - } - -#if ENABLE_VISUALS == 1 - // Set target esp color to pink - hacks::shared::esp::SetEntityColor(target, colors::pink); -#endif - - // Check if player can aim and if aimkey allows aiming - // We also preform a CanShoot check here per the old canshoot method - if (ShouldAim() && aimkey_status && GetCanAim(1)) { - - // Check if player isnt using a huntsman - if (g_pLocalPlayer->weapon()->m_iClassID != CL_CLASS(CTFCompoundBow)) { - - // We check if we need to do a canshoot check as we might want to shoot but not aim, so do that check here - if (GetCanAim(2)) { - // Check the flNextPrimaryAttack netvar to tell when to aim - if (CanShoot()) Aim(target); - } else { - // If settings dont allow canShoot check, then just aim - Aim(target); - } - // Attemt to auto-shoot - if (CanAutoShoot()) g_pUserCmd->buttons |= IN_ATTACK; - - // If player is using huntsman, we use a different system for autoshooting - } else { - - // Grab time when charge began - float begincharge = CE_FLOAT(g_pLocalPlayer->weapon(), netvar.flChargeBeginTime); - // Reset current charge count - float charge = 0; - // If bow is not charged, reset the charge time keeper - if (begincharge != 0) { - charge = g_GlobalVars->curtime - begincharge; - // Keep the charge time keeper kept at 1 second - if (charge > 1.0f) charge = 1.0f; - silent_huntsman = true; - } - // If current charge is equal to or more than the user limit allows, then release the huntsman - if (charge >= (float)huntsman_autoshoot) { - // Stop user attacking - g_pUserCmd->buttons &= ~IN_ATTACK; - // temporarily stop the anti-aim to allow the projectile to pass due to attack not being used - hacks::shared::antiaim::SetSafeSpace(3); - // If user shouldnt release hunstman, attack for user here - } else if (autoshoot && huntsman_full_auto) { - huntsman_ticks = 3; - g_pUserCmd->buttons |= IN_ATTACK; - } - // If player released the huntsman, aim here - if (!(g_pUserCmd->buttons & IN_ATTACK) && silent_huntsman) { - Aim(target); - silent_huntsman = false; + // Auto-zoom + IF_GAME (IsTF()) { + if (auto_zoom) { + if (g_pLocalPlayer->holding_sniper_rifle) { + if (not g_pLocalPlayer->bZoomed) { + g_pUserCmd->buttons |= IN_ATTACK2; } } } } + +#if ENABLE_VISUALS == 1 + hacks::shared::esp::SetEntityColor(target, colors::pink); +#endif + + // Local player check + Aimkey + if (!ShouldAim() || !aimkey_status) return; - // If settings allow and slowaim is disabled, Use silent angles - if (silent && !slowaim) g_pLocalPlayer->bUseSilentAngles = true; + // Attemt to auto-shoot + DoAutoshoot(); + + // flNextPrimaryAttack meme + if (only_can_shoot) { + + // Handle Compound bow + if (g_pLocalPlayer->weapon()->m_iClassID == CL_CLASS(CTFCompoundBow)) { + static bool currently_charging_huntsman = false; + + // Hunstman started charging + if (CE_FLOAT(g_pLocalPlayer->weapon(), netvar.flChargeBeginTime) != 0) + currently_charging_huntsman = true; + + // Huntsman was released + if (!(g_pUserCmd->buttons & IN_ATTACK) && currently_charging_huntsman) { + currently_charging_huntsman = false; + Aim(target); + } else return; + + // Not release type weapon + } else if (CanShoot() && (g_pUserCmd->buttons & IN_ATTACK)) Aim(target); + } else + Aim(target); + return; } @@ -221,17 +176,17 @@ bool ShouldAim() { if (g_pLocalPlayer->using_action_slot_item) return false; IF_GAME (IsTF2()) { - // Check if Carrying A building + // Carrying A building? if (CE_BYTE(g_pLocalPlayer->entity, netvar.m_bCarryingObject)) return false; - // Check if deadringer out + // Deadringer out? if (CE_BYTE(g_pLocalPlayer->entity, netvar.m_bFeignDeathReady)) return false; // If zoomed only is on, check if zoomed if (zoomed_only && g_pLocalPlayer->holding_sniper_rifle) { if (!g_pLocalPlayer->bZoomed && !(g_pUserCmd->buttons & IN_ATTACK)) return false; } - // Check if player is taunting + // Is taunting? if (HasCondition(g_pLocalPlayer->entity)) return false; - // Check if player is cloaked + // Is cloaked if (IsPlayerInvisible(g_pLocalPlayer->entity)) return false; // Disable aimbot with stickbomb launcher if (g_pLocalPlayer->weapon()->m_iClassID == CL_CLASS(CTFPipebombLauncher)) return false; @@ -301,40 +256,37 @@ CachedEntity* RetrieveBestTarget(bool aimkey_state) { foundTarget = false; target_last = nullptr; - // Book keeping vars + float target_highest_score, scr; CachedEntity* ent; CachedEntity* target_highest_ent = 0; target_highest_score = -256; - // Loop that checks all ents whether it is a good target or not + for (int i = 0; i < HIGHEST_ENTITY; i++) { ent = ENTITY(i); - // Check for null and dormant - if (CE_BAD(ent)) continue; + if (CE_BAD(ent)) continue; // Check for null and dormant // Check whether the current ent is good enough to target if (IsTargetStateGood(ent)) { - // Get a score for the entity + // Distance Priority, Uses this is melee is used if (GetWeaponMode() == weaponmode::weapon_melee || (int)priority_mode == 2) { scr = 4096.0f - calculated_data_array[i].aim_position.DistTo(g_pLocalPlayer->v_Eye); } else { switch ((int)priority_mode) { - case 0: // Smart Priority - scr = GetScoreForEntity(ent); - break; - case 1: // Fov Priority - scr = 360.0f - calculated_data_array[ent->m_IDX].fov; - break; - case 3: // Health Priority - scr = 450.0f - ent->m_iHealth; - break; + case 0: // Smart Priority + scr = GetScoreForEntity(ent); + break; + case 1: // Fov Priority + scr = 360.0f - calculated_data_array[ent->m_IDX].fov; + break; + case 3: // Health Priority + scr = 450.0f - ent->m_iHealth; + break; } } // Compare the top score to our current ents score if (scr > target_highest_score) { - // Set foundTarget status to true foundTarget = true; - // Save found target info to vars target_highest_score = scr; target_highest_ent = ent; } @@ -342,7 +294,7 @@ CachedEntity* RetrieveBestTarget(bool aimkey_state) { } // Save the ent for future use with target lock target_last = target_highest_ent; - // When our for loop finishes, return our ent + return target_highest_ent; } @@ -350,27 +302,27 @@ CachedEntity* RetrieveBestTarget(bool aimkey_state) { bool IsTargetStateGood(CachedEntity* entity) { PROF_SECTION(PT_aimbot_targetstatecheck); - // Check for Players + // Checks for Players if (entity->m_Type == ENTITY_PLAYER) { - // Check if target is The local player + // Local player check if (entity == LOCAL_E) return false; - // Dont aim at dead player + // Dead if (!entity->m_bAlivePlayer) return false; - // Dont aim at teammates + // Teammates if ((int)teammates != 2 && ((!entity->m_bEnemy && !teammates) || (entity->m_bEnemy && teammates))) return false; - // Check if player is too far away + // Distance if (EffectiveTargetingRange()) { if (entity->m_flDistance > EffectiveTargetingRange()) return false; } + // Rage only check if (rageonly) { if (playerlist::AccessData(entity).state != playerlist::k_EState::RAGE) { return false; } } IF_GAME (IsTF()) { - // If settings allow waiting for charge, and current charge cant kill target, dont aim unless at 100% and the player wants to fire at 100% anyways + // Wait for charge if (wait_for_charge && g_pLocalPlayer->holding_sniper_rifle) { - // Grab netvar for current charge damage and multiply by 3 for headshot float cdmg = CE_FLOAT(LOCAL_W, netvar.flChargedDamage) * 3; bool maxCharge = cdmg >= 450.0F; @@ -394,14 +346,13 @@ bool IsTargetStateGood(CachedEntity* entity) { } } - // If settings allow, ignore taunting players + // Taunting if (ignore_taunting && HasCondition(entity)) return false; - // Dont target invulnerable players, ex: uber, bonk + // Invulnerable players, ex: uber, bonk if (IsPlayerInvulnerable(entity)) return false; - // Checks for cloaked/deadringed players + // cloaked/deadringed players if (ignore_cloak || ignore_deadringer) { if (IsPlayerInvisible(entity)) { - // Determine whether cloaked player is using deadringer and checks user settings accordingly // Item id for deadringer is 59 as of time of creation if (HasWeapon(entity, 59)) { if (ignore_deadringer) return false; @@ -410,14 +361,14 @@ bool IsTargetStateGood(CachedEntity* entity) { } } } - // If settings allow, dont target vaccinated players + // Vaccinator if (g_pLocalPlayer->weapon_mode == weaponmode::weapon_hitscan || LOCAL_W->m_iClassID == CL_CLASS(CTFCompoundBow)) if (ignore_vaccinator && HasCondition(entity)) return false; } - // Dont target players marked as friendly + // Friendly player if (playerlist::IsFriendly(playerlist::AccessData(entity).state)) return false; IF_GAME (IsTF()) { - // If settings allow, ignore hoovys + // Hoovys if (ignore_hoovy && IsHoovy(entity)) { return false; } @@ -427,34 +378,30 @@ bool IsTargetStateGood(CachedEntity* entity) { AimbotCalculatedData_s& cd = calculated_data_array[entity->m_IDX]; cd.hitbox = hitbox; - // If VisCheck fails, dont target player + // Vis check + fov check if (!VischeckPredictedEntity(entity)) return false; - - // Check if player is within fov. Fov check can be preformed as it is a minimal fps drop and it even needs to be predicted beforehand by the vischeck anyways if ((float)fov > 0.0f && cd.fov > (float)fov) return false; - // Target passed the tests so return true return true; // Check for buildings } else if (entity->m_Type == ENTITY_BUILDING) { - // Check if building aimbot is enabled + // Enabled check if ( !(buildings_other || buildings_sentry) ) return false; - // Check if enemy building + // Teammates, Even with friendly fire enabled, buildings can NOT be damaged if (!entity->m_bEnemy) return false; - // Check if building is within range + // Distance if (EffectiveTargetingRange()) { if (entity->m_flDistance > (int)EffectiveTargetingRange()) return false; } - // If needed, Check if building type is allowed - if ( !(buildings_other && buildings_sentry) ) { + // Building type + if (!(buildings_other && buildings_sentry)) { // Check if target is a sentrygun - if ( entity->m_iClassID == CL_CLASS(CObjectSentrygun) ) { - // If sentrys are not allowed, dont target + if (entity->m_iClassID == CL_CLASS(CObjectSentrygun)) { if (!buildings_sentry) return false; + // Other } else { - // If target is not a sentry, check if other buildings are allowed if (!buildings_other) return false; } } @@ -462,52 +409,45 @@ bool IsTargetStateGood(CachedEntity* entity) { // Grab the prediction var AimbotCalculatedData_s& cd = calculated_data_array[entity->m_IDX]; - // If VisCheck fails, dont target building + // Vis and fov checks if (!VischeckPredictedEntity(entity)) return false; - - // Check if building is within fov if ((float)fov > 0.0f && cd.fov > (float)fov) return false; - // Target passed the tests so return true return true; // Check for stickybombs } else if (entity->m_iClassID == CL_CLASS(CTFGrenadePipebombProjectile)) { - - // Check if sticky aimbot is enabled + // Enabled if (!stickybot) return false; // Only hitscan weapons can break stickys so check for them. if (!(GetWeaponMode() == weapon_hitscan || GetWeaponMode() == weapon_melee)) return false; - // Check if target is within range + // Distance if (EffectiveTargetingRange()) { if (entity->m_flDistance > (int)EffectiveTargetingRange()) return false; } - // Check if thrower is a teammate + // Teammates, Even with friendly fire enabled, stickys can NOT be destroied if (!entity->m_bEnemy) return false; // Check if target is a pipe bomb if (CE_INT(entity, netvar.iPipeType) != 1) return false; - // Check if target is still + // Moving Sticky? if (!CE_VECTOR(entity, netvar.vVelocity).IsZero(1.0f)) return false; // Grab the prediction var AimbotCalculatedData_s& cd = calculated_data_array[entity->m_IDX]; - // If VisCheck fails, dont target building + // Vis and fov check if (!VischeckPredictedEntity(entity)) return false; - - // Check if building is within fov if ((float)fov > 0.0f && cd.fov > (float)fov) return false; - // Target passed the tests so return true return true; } else { - // If target is not player or building, return false + // Target not valid return false; } // An impossible error so just return false @@ -525,72 +465,79 @@ void Aim(CachedEntity* entity) { // Dont aim at a bad entity if (CE_BAD(entity)) return; - // Create some vars - Vector angles, tr; - int hitbox; - - // Grab the targets vector, and vector it for the eye angles - tr = (PredictEntity(entity) - g_pLocalPlayer->v_Eye); + // Get angles + Vector tr = (PredictEntity(entity) - g_pLocalPlayer->v_Eye); + Vector angles; VectorAngles(tr, angles); - - // Clamp angles + // Clamping is important fClampAngle(angles); - // Slow the aiming to the aim vector if true - if (slowaim) slowAim(angles, g_pUserCmd->viewangles); + // Slow aim + if (slow_aim) DoSlowAim(angles); // Set angles g_pUserCmd->viewangles = angles; + if (silent && !slow_aim) g_pLocalPlayer->bUseSilentAngles = true; + // Finish function return; } // A function to check whether player can autoshoot -bool CanAutoShoot() { +void DoAutoshoot() { - // First check whether user settings allow autoshoot - if (autoshoot) { + // Enable check + if (!autoshoot) return; + + // Handle Compound bow + if (g_pLocalPlayer->weapon()->m_iClassID == CL_CLASS(CTFCompoundBow)) { - // A var for weapons not to use with autoshoot - static int forbiddenWeapons[] = { CL_CLASS(CTFCompoundBow), CL_CLASS(CTFKnife) }; - int weapon_class; - bool attack = true; + // Grab time when charge began + float begincharge = CE_FLOAT(g_pLocalPlayer->weapon(), netvar.flChargeBeginTime); - // If your using a sniper rifle, are zoomed and cant headshot, then return false - IF_GAME (IsTF()) { - if (g_pLocalPlayer->clazz == tf_class::tf_sniper) { - if (g_pLocalPlayer->holding_sniper_rifle) { - if (zoomed_only && !CanHeadshot()) attack = false; - } + // Release hunstman if over huntsmans limit + if (g_GlobalVars->curtime - begincharge >= (float)huntsman_autoshoot) { + g_pUserCmd->buttons &= ~IN_ATTACK; + hacks::shared::antiaim::SetSafeSpace(3); + + // Pull string if charge isnt enough + } else + g_pUserCmd->buttons |= IN_ATTACK; + return; + } + + bool attack = true; + + // Rifle check + IF_GAME (IsTF()) { + if (g_pLocalPlayer->clazz == tf_class::tf_sniper) { + if (g_pLocalPlayer->holding_sniper_rifle) { + if (zoomed_only && !CanHeadshot()) attack = false; } } + } - // Check if ambassador can headshot - IF_GAME (IsTF2()) { - if (IsAmbassador(g_pLocalPlayer->weapon())) { - // Check if ambasador can headshot - if (!AmbassadorCanHeadshot()) return false; - } - } - - // Don't autoshoot with the knife or bow! - weapon_class = g_pLocalPlayer->weapon()->m_iClassID; - for (int i = 0; i < 2; i++) { - if (weapon_class == forbiddenWeapons[i]) { - attack = false; - break; - } + // Ambassador check + IF_GAME (IsTF2()) { + if (IsAmbassador(g_pLocalPlayer->weapon())) { + // Check if ambasador can headshot + if (!AmbassadorCanHeadshot()) attack = false; } + } + + // Forbidden weapons check + if (g_pLocalPlayer->weapon()->m_iClassID == CL_CLASS(CTFKnife)) attack = false; + + // Autoshoot breaks with Slow aimbot, so use a workaround to detect when it can + if (slow_aim && !slow_can_shoot) attack = false; - //Autoshoot breaks Slow aimbot, so use a workaround to detect when it can - if (slowaim && !slowCanShoot) attack = false; + // Dont autoshoot without anything in clip + if (CE_INT(g_pLocalPlayer->weapon(), netvar.m_iClip1) == 0) attack = false; - // Return what - return attack; - } else - // Return false due to setting not allowing autoshoot - return false; + if (attack) g_pUserCmd->buttons |= IN_ATTACK; + + return; } // Grab a vector for a specific ent @@ -598,9 +545,9 @@ const Vector& PredictEntity(CachedEntity* entity) { // Pull out predicted data AimbotCalculatedData_s& cd = calculated_data_array[entity->m_IDX]; Vector& result = cd.aim_position; - // If predicted vector has already been calculated this tick, then return it. if (cd.predict_tick == tickcount) return result; - // If ent is a player, find a corresponding vector + + // Players if ((entity->m_Type == ENTITY_PLAYER)) { // If using projectiles, predict a vector if (projectile_mode) { @@ -617,17 +564,15 @@ const Vector& PredictEntity(CachedEntity* entity) { else GetHitbox(entity, cd.hitbox, result); } - // If ent is a building, find a corresponding vector + // Buildings } else if (entity->m_Type == ENTITY_BUILDING) { result = GetBuildingPosition(entity); - // If ent isnt a special type, just use origin + // Other } else { result = entity->m_vecOrigin; } - // Reset the predicted tickcount for the ent cd.predict_tick = tickcount; - // Pre-Calculate fov and store to array cd.fov = GetFov(g_pLocalPlayer->v_OrigViewangles, g_pLocalPlayer->v_Eye, result); // Return the found vector return result; @@ -639,40 +584,33 @@ int BestHitbox(CachedEntity* target) { // Switch based apon the hitbox mode set by the user switch ((int)hitbox_mode) { case 0: { // AUTO-HEAD priority - // The best hitbox var int preferred = hitbox; - // Var to keep if we can bodyshot - bool headonly = false; - // Save the local players current weapon to a var - int ci = g_pLocalPlayer->weapon()->m_iClassID; + bool headonly = false;// Var to keep if we can bodyshot + IF_GAME (IsTF()) { - // Set our default hitbox for pelvis + int ci = g_pLocalPlayer->weapon()->m_iClassID; preferred = hitbox_t::pelvis; - // If user is using a sniper rifle, Set headonly to whether we can headshot or not, + // Sniper rifle if (g_pLocalPlayer->holding_sniper_rifle) { headonly = CanHeadshot(); - // If player is using a compund bow, set headonly to true + // Hunstman } else if (ci == CL_CLASS(CTFCompoundBow)) { headonly = true; - // If player is using an ambassador, set headonly to true + // Ambassador } else if (IsAmbassador(g_pLocalPlayer->weapon())) { - // We only want to aim for the head if the ambassador can headshot headonly = AmbassadorCanHeadshot(); // 18 health is a good number to use as thats the usual minimum damage it can do with a bodyshot, but damage could potentially be higher if (target->m_iHealth <= 18 || IsPlayerCritBoosted(g_pLocalPlayer->entity)) headonly = false; - // If player is using a rocket based weapon, prefer the hip + // Rocket launcher } else if (ci == CL_CLASS(CTFRocketLauncher) || ci == CL_CLASS(CTFRocketLauncher_AirStrike) || ci == CL_CLASS(CTFRocketLauncher_DirectHit) || ci == CL_CLASS(CTFRocketLauncher_Mortar)) { preferred = hitbox_t::hip_L; } - // If target is off the ground and local player is using projectile weapons other than the bow, use the higher hitbox, spine_3 + // Airborn projectile if (GetWeaponMode() == weaponmode::weapon_projectile) { - // Grab netvar for flags and save to a var - int flags = CE_INT(target, netvar.iFlags); - // Extract ground var from flags - bool ground = (flags & (1 << 0)); + bool ground = CE_INT(target, netvar.iFlags) & (1 << 0); if (!ground) { if (g_pLocalPlayer->weapon()->m_iClassID != CL_CLASS(CTFCompoundBow)) { preferred = hitbox_t::spine_3; @@ -683,29 +621,24 @@ int BestHitbox(CachedEntity* target) { // Bodyshot handling if (g_pLocalPlayer->holding_sniper_rifle) { - // Grab netvar for current charge damage float cdmg = CE_FLOAT(LOCAL_W, netvar.flChargedDamage); - // Set our baseline bodyshot damage float bdmg = 50; - // Darwins damage correction + // Darwins damage correction, protects against 15% of damage if (HasDarwins(target)) { - // Darwins protects against 15% of damage bdmg = (bdmg * .85) - 1; cdmg = (cdmg * .85) - 1; } - // Vaccinator damage correction + // Vaccinator damage correction, protects against 75% of damage if (HasCondition(target)) { - // Vac charge protects against 75% of damage bdmg = (bdmg * .25) - 1; cdmg = (cdmg * .25) - 1; + // Passive bullet resist protects against 10% of damage } else if (HasCondition(target)) { - // Passive bullet resist protects against 10% of damage bdmg = (bdmg * .90) - 1; cdmg = (cdmg * .90) - 1; } - // Invis damage correction + // Invis damage correction, Invis spies get protection from 10% of damage if (IsPlayerInvisible(target)) { - // Invis spies get protection from 10% of damage bdmg = (bdmg * .80) - 1; cdmg = (cdmg * .80) - 1; } @@ -720,7 +653,7 @@ int BestHitbox(CachedEntity* target) { } else IF_GAME (IsCSS()) { headonly = true; } - // If headonly is true, return the var here + // Head only if (headonly) { IF_GAME (IsTF()) return hitbox_t::head; @@ -734,16 +667,14 @@ int BestHitbox(CachedEntity* target) { if (target->hitboxes.VisibilityCheck(i)) return i; } } break; - case 1: { // AUTO-CLOSEST priority - // Return closest hitbox to crosshair + case 1: { // AUTO-CLOSEST priority, Return closest hitbox to crosshair return ClosestHitbox(target); } break; - case 2: { // STATIC priority - // Return a user chosen hitbox + case 2: { // STATIC priority, Return a user chosen hitbox return (int)hitbox; } break; } - // without a good hitbox, just return -1 in its place + // Hitbox machine :b:roke return -1; } @@ -769,189 +700,104 @@ int ClosestHitbox(CachedEntity* target) { bool VischeckPredictedEntity(CachedEntity* entity) { // Retrieve predicted data AimbotCalculatedData_s& cd = calculated_data_array[entity->m_IDX]; - // If vis check data is up-to-date with tick count then return it if (cd.vcheck_tick == tickcount) return cd.visible; - // Reset vis check tick and calculate new vis data + + // Update info cd.vcheck_tick = tickcount; cd.visible = IsEntityVectorVisible(entity, PredictEntity(entity)); - // Return found check return cd.visible; } // A helper function to find a user angle that isnt directly on the target angle, effectively slowing the aiming process -void slowAim(Vector &inputAngle, Vector userAngle) { - // Initialize vars for slow aim - int slowfliptype; - int slowdir; - float changey = 0; - float changex = 0; - - // Determine whether to move the mouse at all for the yaw - if (userAngle.y != inputAngle.y) { - - // Fliping The main axis to prevent 360s from happening when the bot trys to cross -180y and 180y - slowfliptype = 0; - if ( ((inputAngle.y < -90) && (userAngle.y > 90)) && (slowfliptype == 0) ) { - slowfliptype = 1; - inputAngle.y = inputAngle.y - 90; - userAngle.y = userAngle.y + 90; - } - if ( ((inputAngle.y > 90) && (userAngle.y < -90)) && (slowfliptype == 0) ) { - slowfliptype = 2; - inputAngle.y = inputAngle.y + 90; - userAngle.y = userAngle.y - 90; - } - - // Math to calculate how much to move the mouse - changey = (std::abs(userAngle.y - inputAngle.y)) / ((int)slowaim_smoothing) ; - // Use stronger shunting due to the flip - if (slowfliptype != 0) changey = ((( std::abs(userAngle.y - inputAngle.y) ) / ((int)slowaim_smoothing * (int)slowaim_smoothing)) / (int)slowaim_smoothing) ; - - // Determine the direction to move in before reseting the flipped angles - slowdir = 0; - if ((userAngle.y > inputAngle.y) && (slowdir == 0)) slowdir = 1; - if ((userAngle.y < inputAngle.y) && (slowdir == 0)) slowdir = 2; +void DoSlowAim(Vector &input_angle) { + static float slow_change_dist_p = 0; + static float slow_change_dist_y = 0; + + // Yaw + if (g_pUserCmd->viewangles.y != input_angle.y) { + + // Check if input angle and user angle are on opposing sides of yaw so we can correct for that + bool slow_opposing = false; + if (input_angle.y < -90 && g_pUserCmd->viewangles.y > 90 || input_angle.y > 90 && g_pUserCmd->viewangles.y < -90) + slow_opposing = true; - // Reset Flipped angles and fix directions - if (slowfliptype == 1) { - inputAngle.y = inputAngle.y + 90; - userAngle.y = userAngle.y - 90; - slowdir = 2; - } - if (slowfliptype == 2) { - inputAngle.y = inputAngle.y - 90; - userAngle.y = userAngle.y + 90; - slowdir = 1; - } - - // Move in the direction determined before the fliped angles - if (slowdir == 1) inputAngle.y = userAngle.y - changey; - if (slowdir == 2) inputAngle.y = userAngle.y + changey; - } - - // Determine whether to move the mouse at all for the pitch - if (userAngle.x != inputAngle.x) { - changex = (std::abs(userAngle.x - inputAngle.x)) / ((int)slowaim_smoothing) ; - - // Determine the direction to move in - if (userAngle.x > inputAngle.x) inputAngle.x = userAngle.x - changex; - if (userAngle.x < inputAngle.x) inputAngle.x = userAngle.x + changex; - } + // Direction + bool slow_dir = false; + if (slow_opposing) { + if (input_angle.y > 90 && g_pUserCmd->viewangles.y < -90) slow_dir = true; + } else + if (g_pUserCmd->viewangles.y > input_angle.y) slow_dir = true; + + // Speed, check if opposing. We dont get a new distance due to the opposing sides making the distance spike, so just cheap out and reuse our last one. + if (!slow_opposing) slow_change_dist_y = std::abs(g_pUserCmd->viewangles.y - input_angle.y) / (int)slow_aim; - // Check if can autoshoot with slowaim - slowCanShoot = false; - if (changey < (0.02*(int)slowaim_autoshoot) && changex < (0.02*(int)slowaim_autoshoot)) slowCanShoot = true; + // Move in the direction of the input angle + if (slow_dir) input_angle.y = g_pUserCmd->viewangles.y - slow_change_dist_y; + else input_angle.y = g_pUserCmd->viewangles.y + slow_change_dist_y; + } + + // Pitch + if (g_pUserCmd->viewangles.x != input_angle.x) { + // Get speed + slow_change_dist_p = std::abs(g_pUserCmd->viewangles.x - input_angle.x) / (int)slow_aim; + + // Move in the direction of the input angle + if (g_pUserCmd->viewangles.x > input_angle.x) input_angle.x = g_pUserCmd->viewangles.x - slow_change_dist_p; + else input_angle.x = g_pUserCmd->viewangles.x + slow_change_dist_p; + } + + // 0.17 is a good amount in general + slow_can_shoot = false; + if (slow_change_dist_y < 0.17 && slow_change_dist_p < 0.17) slow_can_shoot = true; + + // Clamp as we changed angles + fClampAngle(input_angle); } // A function that determins whether aimkey allows aiming bool UpdateAimkey() { static bool aimkey_flip = false; static bool pressed_last_tick = false; - bool key_down; - bool allowAimkey = true; + bool allow_aimkey = true; + // Check if aimkey is used if (aimkey && aimkey_mode) { // Grab whether the aimkey is depressed - key_down = g_IInputSystem->IsButtonDown((ButtonCode_t)(int)aimkey); - // Switch based on the user set aimkey mode + bool key_down = g_IInputSystem->IsButtonDown((ButtonCode_t)(int)aimkey); switch ((int)aimkey_mode) { - // Only while key is depressed, enable - case 1: - if (!key_down) { - allowAimkey = false; - } + case 1: // Only while key is depressed + if (!key_down) + allow_aimkey = false; break; - // Only while key is not depressed, enable - case 2: - if (key_down) { - allowAimkey = false; - } + case 2: // Only while key is not depressed, enable + if (key_down) + allow_aimkey = false; break; - // Aimkey acts like a toggle switch - case 3: + case 3: // Aimkey acts like a toggle switch if (!pressed_last_tick && key_down) aimkey_flip = !aimkey_flip; - if (!aimkey_flip) { - allowAimkey = false; - } + if (!aimkey_flip) + allow_aimkey = false; } pressed_last_tick = key_down; } // Return whether the aimkey allows aiming - return allowAimkey; -} - -// A function called at 2 points in the create move function -// First time is when the aimbot Determines if it should aim and autoshoot -// Second time is for when the aimbot determines only when it should aim and always autoshoots -// Using either mode has problems with some weapons so we compramise by using a combo of the 2 -// The point of using this function for 2 uses is to not make duplicate funcs for essentialy the same thing -bool GetCanAim(int mode) { - - // User setting check - switch (mode) { - case 1: // The first check when the aimbot checks if it can aim or shoot - - // If user settings dont allow, Always aim at the point this is called - if (!only_can_shoot) return true; - // Always aim with melee weapons - if (GetWeaponMode() == weaponmode::weapon_melee) return true; - break; - - case 2: // Second check when the aimbot checks if it can aim, and will shoot regardless of the output here - - // dont check if should aim with melee weapons - if (GetWeaponMode() == weaponmode::weapon_melee) return false; - - // At the point this is called, we dont want to check for can shoot if user settings dont allow - if (!only_can_shoot) return false; - } - - // Weapons that should attack continuously - bool using_wep_on_list = - g_pLocalPlayer->weapon()->m_iClassID == CL_CLASS(CTFPistol_Scout) || - g_pLocalPlayer->weapon()->m_iClassID == CL_CLASS(CTFMinigun) || - g_pLocalPlayer->weapon()->m_iClassID == CL_CLASS(CTFSyringeGun) || - g_pLocalPlayer->weapon()->m_iClassID == CL_CLASS(CTFSMG) || - g_pLocalPlayer->weapon()->m_iClassID == CL_CLASS(CTFRevolver) || - g_pLocalPlayer->weapon()->m_iClassID == CL_CLASS(CTFFlameThrower); - - switch (mode) { - case 1: // The first check when the aimbot checks if it can aim or shoot - - // If the player isnt using these weaps, then check for can shoot. If the weapon isnt on the list, then we need to check if the player should aim here and return the result - if (!using_wep_on_list) return CanShoot(); - break; - - case 2: // Second check when the aimbot checks if it can aim, and will shoot regardless of the output here - - // Return whether we are using one of the weapons on the list because we want to tell the aimbot that we should check for canshoot - return using_wep_on_list; - } - - // Mode wasnt input correctly, just return true and hope for the best - return true; + return allow_aimkey; } // Func to find value of how far to target ents float EffectiveTargetingRange() { - // Melees use a close range, TODO add dynamic range for demoknight swords - if (GetWeaponMode() == weapon_melee) { - return 100.0f; - // Pyros only have so much untill their flames hit - } else if (g_pLocalPlayer->weapon()->m_iClassID == CL_CLASS(CTFFlameThrower)) { - return 185.0f; - } - // Else return user settings + if (GetWeaponMode() == weapon_melee) return 100.0f; // Melees use a close range, TODO add dynamic range for demoknight swords + if (g_pLocalPlayer->weapon()->m_iClassID == CL_CLASS(CTFFlameThrower)) return 185.0f; // Pyros only have so much untill their flames hit + return (float)max_range; } // A function used by gui elements to determine the current target CachedEntity* CurrentTarget() { - // If a target is found return it if (foundTarget) - return ENTITY(target_eid); - // Else return a nullpointer + return target; // Doesnt work for some reason + return nullptr; } @@ -962,16 +808,12 @@ void Reset() { } #if ENABLE_VISUALS == 1 - -// Function called when we need to draw to screen static CatVar fov_draw(CV_SWITCH, "aimbot_fov_draw", "0", "Draw Fov Ring", "Draws a ring to represent your current aimbot fov"); void DrawText() { // Dont draw to screen when aimbot is disabled if (!enabled) return; // Fov ring to represent when a target will be shot - // Not perfect but does a good job of representing where its supposed to be - // Broken from kathook merge, TODO needs to be adapted for imgui if (fov_draw) { // It cant use fovs greater than 180, so we check for that if (float(fov) > 0.0f && float(fov) < 180) { @@ -980,17 +822,15 @@ void DrawText() { rgba_t color = GUIColor(); color.a = float(fovcircle_opacity); - // Grab the screen resolution and save to some vars int width, height; g_IEngine->GetScreenSize(width, height); - // Some math to find radius of the fov circle + // Math float mon_fov = (float(width) / float(height) / (4.0f / 3.0f)); float fov_real = RAD2DEG(2 * atanf(mon_fov * tanf(DEG2RAD(draw::fov / 2)))); - float radius = tan(DEG2RAD(float(fov)) / 2) / tan(DEG2RAD(fov_real) / 2) * (width); - // Draw a circle with our newfound circle + // Draw a circle float px = 0; float py = 0; constexpr float steps = 120; @@ -1010,7 +850,7 @@ void DrawText() { } } } - // Dont run the following unless debug is enabled + // Debug stuff if (!aimbot_debug) return; for (int i = 1; i < 32; i++) { CachedEntity* ent = ENTITY(i); @@ -1024,7 +864,6 @@ void DrawText() { } } } - #endif }}} diff --git a/src/hacks/Aimbot.h b/src/hacks/Aimbot.h index 924de27a..5a5e6909 100644 --- a/src/hacks/Aimbot.h +++ b/src/hacks/Aimbot.h @@ -50,12 +50,11 @@ bool ShouldAim(); CachedEntity* RetrieveBestTarget(bool aimkey_state); bool IsTargetStateGood(CachedEntity* entity); void Aim(CachedEntity* entity); -bool CanAutoShoot(); +void DoAutoshoot(); int BestHitbox(CachedEntity* target); int ClosestHitbox(CachedEntity* target); -void slowAim(Vector &inputAngle, Vector userAngle); +void DoSlowAim(Vector &inputAngle); bool UpdateAimkey(); -bool GetCanAim(int mode); float EffectiveTargetingRange(); }}} diff --git a/src/hacks/Misc.cpp b/src/hacks/Misc.cpp index b498df9b..8dfb7d61 100644 --- a/src/hacks/Misc.cpp +++ b/src/hacks/Misc.cpp @@ -325,7 +325,7 @@ void CreateMove() { g_IEngine->GetViewAngles(cameraAngle); // Set userAngle = camera angles - g_pUserCmd->viewangles.y = cameraAngle[1]; + //g_pUserCmd->viewangles.y = cameraAngle[1]; g_pLocalPlayer->v_OrigViewangles.y = cameraAngle[1]; // Use silent since we dont want to prevent the player from looking around @@ -420,6 +420,7 @@ void DrawText() { AddSideString(format("Velocity2: ", vel.Length2D())); AddSideString(format("flSimTime: ", LOCAL_E->var(netvar.m_flSimulationTime))); if (g_pUserCmd) AddSideString(format("command_number: ", last_cmd_number)); + AddSideString(format("clip: ", CE_INT(g_pLocalPlayer->weapon(), netvar.m_iClip1))); /*AddSideString(colors::white, "Weapon: %s [%i]", RAW_ENT(g_pLocalPlayer->weapon())->GetClientClass()->GetName(), g_pLocalPlayer->weapon()->m_iClassID); //AddSideString(colors::white, "flNextPrimaryAttack: %f", CE_FLOAT(g_pLocalPlayer->weapon(), netvar.flNextPrimaryAttack)); //AddSideString(colors::white, "nTickBase: %f", (float)(CE_INT(g_pLocalPlayer->entity, netvar.nTickBase)) * gvars->interval_per_tick); diff --git a/src/helpers.cpp b/src/helpers.cpp index c4997e7a..488748c0 100644 --- a/src/helpers.cpp +++ b/src/helpers.cpp @@ -695,6 +695,7 @@ bool CanHeadshot() { } bool CanShoot() { + float servertime, nextattack; servertime = (float)(CE_INT(g_pLocalPlayer->entity, netvar.nTickBase)) * g_GlobalVars->interval_per_tick;