I am currently working on an external recoil control system and it keeps snapping to one location instead of wherever I am shooting. I have been debugging for the last couple hours and have had no luck so if anyone could help me, it would be appreciated.
Code:
struct RCS {
void SetViewAngles(vect angle)
{
vect newAngle = angle;
if (newAngle.x >= -180 && newAngle.x <= 180 && newAngle.y >= -180 && newAngle.y <= 180)
{
mem.WriteMemory<vect>(var.clientState + offsets.dwClientState_ViewAngles, newAngle);
}
}
void Recoil() {
vect CurrentViewAngles, vPunch, NewViewAngles, OldAimPunch;
OldAimPunch.x = 0, OldAimPunch.y = 0, OldAimPunch.z = 0;
var.shotsFired = mem.ReadMemory<int>(var.localPlayer + offsets.m_iShotsFired);
var.localPlayer = mem.ReadMemory<DWORD>(mod.Client.dwBase + offsets.dwLocalPlayer);
var.clientState = mem.ReadMemory<DWORD>(mod.Engine.dwBase + offsets.dwClientState);
if (var.RCS == true && var.shotsFired >= 1) {
vPunch = mem.ReadMemory<vect>(var.localPlayer + offsets.m_aimPunchAngle);
vPunch.x = vPunch.x * 2.f;
vPunch.y = vPunch.y * 2.f;
CurrentViewAngles = mem.ReadMemory<vect>(var.clientState + offsets.m_viewPunchAngle);
NewViewAngles.x = ((CurrentViewAngles.x + OldAimPunch.x) - vPunch.x);
NewViewAngles.y = ((CurrentViewAngles.y + OldAimPunch.y) - vPunch.y);
NewViewAngles.z = 0;
SetViewAngles(NewViewAngles);
OldAimPunch.x = vPunch.x;
OldAimPunch.y = vPunch.y;
Sleep(1);
}
else {
OldAimPunch.x = 0, OldAimPunch.y = 0, OldAimPunch.z = 0, NewViewAngles.x = 0, NewViewAngles.y = 0, NewViewAngles.z = 0;
}
}
} RCS;