void AimLegit::Work(CUserCmd *usercmd) { this->usercmd = usercmd; if (!g_LocalPlayer->m_hActiveWeapon().Get()) return; if (g_LocalPlayer->m_hActiveWeapon().Get()->IsWeaponNonAim() || g_LocalPlayer->m_hActiveWeapon().Get()->m_iClip1() < 1) return; if (g_Options.legit_enabled && (g_InputSystem->IsButtonDown(static_cast<ButtonCode_t>(g_Options.legit_aimkey1)) || g_InputSystem->IsButtonDown(static_cast<ButtonCode_t>(g_Options.legit_aimkey2))) && !g_LocalPlayer->m_hActiveWeapon().Get()->IsWeaponNonAim()) { GetBestTarget(); if (HasTarget()) TargetRegion(); } if (g_Options.legit_trigger || (g_Options.legit_trigger_with_aimkey && (g_InputSystem->IsButtonDown(static_cast<ButtonCode_t>(g_Options.legit_aimkey1)) || g_InputSystem->IsButtonDown(static_cast<ButtonCode_t>(g_Options.legit_aimkey2))))) Triggerbot(); if (g_Options.legit_rcs) RecoilControlSystem(); if (!g_Options.rage_silent) // I dont feel here good, cause of ragebot and stuff and the part inside CM cause of that g_EngineClient->SetViewAngles(usercmd->viewangles); }
void Vision::FindTarget(double& offset, double& distance) { distance = 0.0; offset = 0.0; TargetReport tmp = GetBestTarget(); if (tmp.normalizedY > 0.0) { distance = tmp.distance; offset = tmp.normalizedX; } if (bestTargetCount == 0) return; int targetCase[4] = { -1, -1, -1, -1 }; GetTargetCase(bestTargets, bestTargetCount, targetCase[TOP_TARGET], targetCase[LEFT_TARGET], targetCase[RIGHT_TARGET], targetCase[BOTTOM_TARGET]); secondaryDisplay.PrintfLine(0, "Top Target: %d", targetCase[TOP_TARGET]); secondaryDisplay.PrintfLine(1, "Left Target: %d", targetCase[LEFT_TARGET]); secondaryDisplay.PrintfLine(2, "Right Target: %d", targetCase[RIGHT_TARGET]); secondaryDisplay.PrintfLine(3, "Bottom Target: %d", targetCase[BOTTOM_TARGET]); // Handle target cases if (targetCase[TOP_TARGET] >= 0 && targetCase[BOTTOM_TARGET] >= 0) { //Top / Bottom (best case scenario) offset = bestTargets[TOP_TARGET].normalizedX; double realHeight = BASKET_TOP_ELEVATION - BASKET_BOTTOM_ELEVATION; distance = GetDistanceFromHeight(realHeight, fabs(bestTargets[targetCase[BOTTOM_TARGET]].centerY - bestTargets[targetCase[TOP_TARGET]].centerY)); } else if (targetCase[TOP_TARGET] >= 0 && (targetCase[LEFT_TARGET] >= 0 || targetCase[RIGHT_TARGET] >= 0)) { //One of the top diagonals offset = bestTargets[targetCase[TOP_TARGET]].normalizedX; double realHeight = BASKET_TOP_ELEVATION - BASKET_MIDDLE_ELEVATION; if (targetCase[LEFT_TARGET] >= 0) { distance = GetDistanceFromHeight(realHeight, fabs(bestTargets[targetCase[LEFT_TARGET]].centerY - bestTargets[targetCase[TOP_TARGET]].centerY)); } else if (targetCase[RIGHT_TARGET] >= 0) { distance = GetDistanceFromHeight(realHeight, fabs(bestTargets[targetCase[RIGHT_TARGET]].centerY - bestTargets[targetCase[TOP_TARGET]].centerY)); } } else if (targetCase[BOTTOM_TARGET] >= 0 && (targetCase[LEFT_TARGET] >= 0 || targetCase[RIGHT_TARGET] >= 0)) { //One of the bottom diagonals offset = bestTargets[targetCase[BOTTOM_TARGET]].normalizedX; double realHeight = BASKET_MIDDLE_ELEVATION - BASKET_BOTTOM_ELEVATION; if (targetCase[LEFT_TARGET] >= 0) { distance = GetDistanceFromHeight(realHeight, fabs(bestTargets[targetCase[BOTTOM_TARGET]].centerY - bestTargets[targetCase[LEFT_TARGET]].centerY)); } else if (targetCase[RIGHT_TARGET] >= 0) { distance = GetDistanceFromHeight(realHeight, fabs(bestTargets[targetCase[BOTTOM_TARGET]].centerY - bestTargets[targetCase[RIGHT_TARGET]].centerY)); } } else if( targetCase[LEFT_TARGET] >= 0 && targetCase[RIGHT_TARGET] >= 0 ) { //Both side targets offset = (bestTargets[targetCase[RIGHT_TARGET]].normalizedX + bestTargets[targetCase[LEFT_TARGET]].normalizedX) / 2.0; distance = (bestTargets[targetCase[LEFT_TARGET]].distance + bestTargets[targetCase[RIGHT_TARGET]].distance) / 2.0; } }