Hey so game is pretty dead, but I still wanted to write some shitty code
Currently working on the aimbot but I'm probably doing the calculation wrong (just setting the viewangles to VectorAngles(delta))
Code:
Code:
Vector3 VectorAngles(const Vector3 forward)
{
Vector3 angles = Vector3();
float tmp, yaw, pitch;
if (forward.x == 0 && forward.y == 0)
{
yaw = 0;
if (forward.z > 0)
pitch = 90.f;
else
pitch = 270.f;
}
else
{
yaw = RAD2DEG(atan2f(forward.y, forward.x));
if (yaw < 0)
yaw += 360;
tmp = forward.Length2D();
pitch = RAD2DEG(atan2f(forward.z, tmp));
if (pitch < 0)
pitch += 360;
}
angles.x = -pitch;
angles.y = yaw;
angles.z = 0;
return angles;
}
Vector2 VectorToViewangles(Vector3 src, Vector3 dst)
{
RefDef* refDef = Functions::GetRefDef();
Vector3 vecEntity = Vector3();
Vector3 vecAngle = Vector3();
vecEntity = dst - src;
vecAngle = VectorAngles(vecEntity);
if (vecAngle.y > 180.0f)
vecAngle.y -= 360.0f;
else if (vecAngle.y < -180.0f)
vecAngle.y += 360.0f;
if (vecAngle.x > 180.0f)
vecAngle.x -= 360.0f;
else if (vecAngle.x < -180.0f)
vecAngle.x += 360.0f;
return Vector2(vecAngle.x, vecAngle.y);
}
And calling that in Draw2D hook:
Code:
if (closestPlayer != nullptr)
{
void* font = Functions::RegisterFont(FONT_NORMAL, 1);
ClientInfo* client = Functions::GetClientByIndex(closestPlayerNum);
Functions::CmdDrawText(client->Name, font, 100, 375, Color::white);
Vector3 headPos = Functions::GetBonePos(closestPlayer, Enums::Bones::HEAD);
Vector3 eyePos = refDef->eyePos
Vector2 angle = VectorToViewangles(eyePos, headPos);
viewAngles->x = angle.x;
viewAngles->y = angle.y;
}
ViewAngles = 0xBC7750 (can change them and they look right)
RefDef = 0x90B648
Code:
class RefDef
{
char stub[8];
int scrWidth;
int scrHeight;
Vector2 fov;
Vector3 eyePos;
Vector3 viewAxis[3];
char stub2[16200];
Vector3 rdViewAngles;
};
It sometimes locks to the sky or the exact opposite direction. Most of the time pitch is right but yaw fucks up.
Would be great if someone knew how to fix this