Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Aim Lock

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

#include "AimAssist.

h"
#include "Triggerbot.h"

bool AimLock::WasOnEnemy = false;


QAngle LastAngle = QAngle(0, 0, 0);

float GetAngleDelta()
{
QAngle ViewAngles;
Interfaces::Engine()->GetViewAngles(ViewAngles);
ViewAngles -= LastAngle;
Utils::Clamp(ViewAngles);
return Vector(ViewAngles.x, ViewAngles.y, ViewAngles.z).Length();
}

float GetRelativeFOVAngle(int PlayerID)


{
if (!PlayerID) return 180.0f;
auto pLocal = C_CSPlayer::GetLocalPlayer();
auto Target = static_cast<C_CSPlayer*>(SourceEngine::Interfaces::EntityList()-
>GetClientEntity(PlayerID));
QAngle TargetAngles = (Target->GetOrigin() - pLocal->GetOrigin()).Angle();
QAngle ViewAngles;
Interfaces::Engine()->GetViewAngles(ViewAngles);
TargetAngles -= ViewAngles;
Utils::Clamp(TargetAngles);
return Vector(TargetAngles.x, TargetAngles.y, TargetAngles.z).Length();
}

void AimLock::LookAtPlayer(int PlayerID, SourceEngine::CUserCmd* pCmd)


{
if (!PlayerID) return;
auto pLocal = C_CSPlayer::GetLocalPlayer();
auto ActiveWeapon = pLocal->GetActiveWeapon();

auto Target = static_cast<C_CSPlayer*>(SourceEngine::Interfaces::EntityList()-


>GetClientEntity(PlayerID));
SourceEngine::Vector AimPos = SourceEngine::Vector(0, 0, 0);
if (Config.g_iAimbotTarget == 0)
AimPos = Target->GetHeadCenterPos();
else if (Config.g_iAimbotTarget == 1)
AimPos = Target->GetBoneByName(XorStr("spine_3"));
else if (Config.g_iAimbotTarget == 2)
AimPos = Target->GetBoneByName(XorStr("spine_0"));

pCmd->viewangles = (AimPos - pLocal->GetEyePos()).Angle();


pCmd->viewangles -= RCS::GetCurrentPunchAngles();

if (!Config.g_iViewMode)
Interfaces::Engine()->SetViewAngles(pCmd->viewangles);
}

void AimLock::LookAtPoint(SourceEngine::Vector Point, SourceEngine::CUserCmd* pCmd)


{
auto pLocal = C_CSPlayer::GetLocalPlayer();
auto ActiveWeapon = pLocal->GetActiveWeapon();

SourceEngine::QAngle Angle = (Point - pLocal->GetEyePos()).Angle();


Utils::Clamp(Angle);
pCmd->viewangles = Angle;
pCmd->viewangles -= RCS::GetCurrentPunchAngles();
}

void AimLock::LockOnTarget(int PlayerID, SourceEngine::CUserCmd* pCmd)


{
auto ActiveWeapon = C_CSPlayer::GetLocalPlayer()->GetActiveWeapon();
if (ActiveWeapon->IsKnife()) return;
if (ActiveWeapon->IsSniper() && !(C_CSPlayer::GetLocalPlayer()->IsScoped()))
return;
LookAtPlayer(PlayerID, pCmd);
SourceEngine::Interfaces::Engine()->SetViewAngles(pCmd->viewangles);
}

void AimLock::Think(SourceEngine::CUserCmd* pCmd)


{
auto pLocal = C_CSPlayer::GetLocalPlayer();
int PlayerID = pLocal->InCross();
if (PlayerID)
{
if (!WasOnEnemy &&
Utils::IsViableTarget(static_cast<C_CSPlayer*>(SourceEngine::Interfaces::EntityList
()->GetClientEntity(pLocal->InCross()))))
AimLock::LockOnTarget(pLocal->InCross(), pCmd);
}
}

You might also like