Skip to content

Commit

Permalink
Resolved the issue with the hook aimbot when the target is behind an …
Browse files Browse the repository at this point in the history
…obstruction
  • Loading branch information
scar17off committed Feb 12, 2025
1 parent 1ac4dd0 commit 6b58266
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/game/client/components/cheat/hitscan/hook_hitscan.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class CHookHitscan : public CComponent
virtual int Sizeof() const override { return sizeof(*this); }

vec2 EdgeScan(int ClientId);
bool HitScanHook(vec2 initPos, vec2 targetPos, vec2 scanDir);

private:
class CScanJob : public IJob
Expand Down Expand Up @@ -49,7 +50,6 @@ class CHookHitscan : public CComponent
};

void ScanAngles(float StartAngle, float EndAngle, int Steps, int ClientId, std::vector<vec2> &ValidPoints);
bool HitScanHook(vec2 initPos, vec2 targetPos, vec2 scanDir);
bool IntersectCharacter(vec2 hookPos, vec2 targetPos, vec2 &newPos);

std::mutex m_ScanMutex;
Expand Down
13 changes: 10 additions & 3 deletions src/game/client/components/controls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,16 +346,23 @@ int CControls::SnapInput(int *pData)
// Try edge scan first for hook
AimPosition = m_pClient->m_HookHitscan.EdgeScan(Target);

// If edge scan fails, try prediction as fallback
if(length(AimPosition) == 0.0f)
// Only try prediction if edge scan fails AND we're just pressing hook (not holding)
if(length(AimPosition) < 1.0f && HookPressed)
{
vec2 myVel = m_pClient->m_PredictedChar.m_Vel;
vec2 targetVel = m_pClient->m_aClients[Target].m_Predicted.m_Vel;
vec2 predictedPos = PlayerPos;

// Only set aim if prediction succeeds
if(m_pClient->m_HookPrediction.PredictHook(LocalPos, myVel, predictedPos, targetVel))
{
AimPosition = predictedPos - LocalPos;
vec2 predictedDirection = predictedPos - LocalPos;

// Verify the predicted position with hitscan before using it
if(m_pClient->m_HookHitscan.HitScanHook(LocalPos, predictedPos, predictedDirection))
{
AimPosition = predictedDirection;
}
}
}
}
Expand Down

0 comments on commit 6b58266

Please sign in to comment.