Skip to content

Commit

Permalink
Merge pull request #110 from M3351AN/master
Browse files Browse the repository at this point in the history
Add Vis Check & Fov Range & RCS for aimbot
  • Loading branch information
maecry authored Aug 16, 2024
2 parents f6421aa + ea19ef1 commit 8e09ba6
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 3 deletions.
1 change: 1 addition & 0 deletions cstrike/core/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ void T::LegitBot()
}

ImGui::Checkbox(CS_XOR("enable##aimbot"), &C_GET(bool, Vars.bLegitbot));
ImGui::SliderFloat(CS_XOR("aim range"), &C_GET(float, Vars.flAimRange), 1.f, 135.f);
ImGui::SliderFloat(CS_XOR("smoothing"), &C_GET(float, Vars.flSmoothing), 1.f, 100.f);

ImGui::NewLine();
Expand Down
1 change: 1 addition & 0 deletions cstrike/core/variables.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ struct Variables_t
#pragma endregion
#pragma region variables_legitbot
C_ADD_VARIABLE(bool, bLegitbot, false);
C_ADD_VARIABLE(float, flAimRange, 10.0f);
C_ADD_VARIABLE(float, flSmoothing, 10.0f);
C_ADD_VARIABLE(bool, bLegitbotAlwaysOn, false);
C_ADD_VARIABLE(unsigned int, nLegitbotActivationKey, VK_HOME);
Expand Down
40 changes: 37 additions & 3 deletions cstrike/features/legitbot/aim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// used: cheat variables
#include "../../core/variables.h"

#include "../../sdk/interfaces/cgametracemanager.h"

void F::LEGITBOT::AIM::OnMove(CUserCmd* pCmd, CBaseUserCmdPB* pBaseCmd, CCSPlayerController* pLocalController, C_CSPlayerPawn* pLocalPawn)
{
// Check if the legitbot is enabled
Expand All @@ -25,6 +27,22 @@ void F::LEGITBOT::AIM::OnMove(CUserCmd* pCmd, CBaseUserCmdPB* pBaseCmd, CCSPlaye
AimAssist(pBaseCmd, pLocalPawn, pLocalController);
}

QAngle_t GetRecoil(CBaseUserCmdPB* pCmd,C_CSPlayerPawn* pLocal)
{
static QAngle_t OldPunch;//get last tick AimPunch angles
if (pLocal->GetShotsFired() >= 1)//only update aimpunch while shooting
{
QAngle_t viewAngles = pCmd->pViewAngles->angValue;
QAngle_t delta = viewAngles - (viewAngles + (OldPunch - (pLocal->GetAimPuchAngle() * 2.f)));//get current AimPunch angles delta

return pLocal->GetAimPuchAngle() * 2.0f;//return correct aimpunch delta
}
else
{
return QAngle_t{ 0, 0 ,0};//return 0 if is not shooting
}
}

QAngle_t GetAngularDifference(CBaseUserCmdPB* pCmd, Vector_t vecTarget, C_CSPlayerPawn* pLocal)
{
// The current position
Expand Down Expand Up @@ -127,8 +145,24 @@ void F::LEGITBOT::AIM::AimAssist(CBaseUserCmdPB* pUserCmd, C_CSPlayerPawn* pLoca
// Get the bone's position
Vector_t vecPos = pBoneCache->GetOrigin(iBone);

// @note: this is a simple example of how to check if the player is visible

// initialize trace, construct filterr and initialize ray
GameTrace_t trace = GameTrace_t();
TraceFilter_t filter = TraceFilter_t(0x1C3003, pLocalPawn, nullptr, 4);
Ray_t ray = Ray_t();

// cast a ray from local player eye positon -> player head bone
// @note: would recommend checking for nullptrs
I::GameTraceManager->TraceShape(&ray, pLocalPawn->GetEyePosition(), pPawn->GetGameSceneNode()->GetSkeletonInstance()->pBoneCache->GetOrigin(6), &filter, &trace);
// check if the hit entity is the one we wanted to check and if the trace end point is visible
if (trace.m_pHitEntity != pPawn || !trace.IsVisible())// if invisible, skip this entity
continue;

// Get the distance/weight of the move
float flCurrentDistance = GetAngularDistance(pUserCmd, vecPos, pLocalPawn);
if (flCurrentDistance > C_GET(float, Vars.flAimRange))// Skip if this move out of aim range
continue;
if (pTarget && flCurrentDistance > flDistance) // Override if this is the first move or if it is a better move
continue;

Expand All @@ -150,9 +184,9 @@ void F::LEGITBOT::AIM::AimAssist(CBaseUserCmdPB* pUserCmd, C_CSPlayerPawn* pLoca

// Get the smoothing
const float flSmoothing = C_GET(float, Vars.flSmoothing);

auto aimPunch = GetRecoil(pUserCmd, pLocalPawn); //get AimPunch angles
// Apply smoothing and set angles
pViewAngles->x += vNewAngles.x / flSmoothing;
pViewAngles->y += vNewAngles.y / flSmoothing;
pViewAngles->x += ( vNewAngles.x - aimPunch.x ) / flSmoothing;// minus AimPunch angle to counteract recoil
pViewAngles->y += ( vNewAngles.y - aimPunch.y ) / flSmoothing;
pViewAngles->Normalize();
}
1 change: 1 addition & 0 deletions cstrike/sdk/entity.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ class C_CSPlayerPawn : public C_CSPlayerPawnBase
SCHEMA_ADD_FIELD(bool, IsWaitForNoAttack, "C_CSPlayerPawn->m_bWaitForNoAttack");
SCHEMA_ADD_FIELD(int, GetShotsFired, "C_CSPlayerPawn->m_iShotsFired");
SCHEMA_ADD_FIELD(std::int32_t, GetArmorValue, "C_CSPlayerPawn->m_ArmorValue");
SCHEMA_ADD_FIELD(QAngle_t, GetAimPuchAngle, "C_CSPlayerPawn->m_aimPunchAngle");
};

class CBasePlayerController : public C_BaseModelEntity
Expand Down

0 comments on commit 8e09ba6

Please sign in to comment.