//hooks.cpp
void __stdcall Hooks::FrameStageNotify(ClientFrameStage_t curStage) {
g_Misc.Thirdperson_FSN(curStage);
oFrameStage(curStage);
}
///////////////////
///////////////////
void __fastcall Hooks::OverrideView(void* ecx, void* edx, CViewSetup* pSetup)
{
g_Misc.ThirdPerson();
oOverrideView(ecx, edx, pSetup);
}
///////////////////
//Misc.h
void ThirdPerson()
{
if (!g_pEngine->IsInGame() || !g_pEngine->IsConnected() || !Globals::LocalPlayer)
return;
static bool init = false;
static bool set_angle = false;
auto pLocalEntity = Globals::LocalPlayer;
static int stored_thirdperson_distance;
if (stored_thirdperson_distance != c_config::get().thirdperson_distance) {
std::string command; command += "cam_idealdist "; command += std::to_string(c_config::get().thirdperson_distance + 30);
g_pEngine->ExecuteClientCmd(command.c_str());
stored_thirdperson_distance = c_config::get().thirdperson_distance;
}
static Vector vecAngles;
g_pEngine->GetViewAngles(vecAngles);
if (GetKeyState(c_config::get().thirdperson_bind) && Globals::LocalPlayer->IsAlive())
{
if (init)
{
ConVar* sv_cheats = g_pCvar->FindVar("sv_cheats");
*(int*)((DWORD)&sv_cheats->fnChangeCallback + 0xC) = 0; // ew
sv_cheats->SetValue(1);
g_pEngine->ExecuteClientCmd("thirdperson");
std::string command; command += "cam_idealdist "; command += std::to_string(c_config::get().thirdperson_distance + 30);
g_pEngine->ExecuteClientCmd(command.c_str());
}
init = false;
}
else
{
if (!init)
{
ConVar* sv_cheats = g_pCvar->FindVar("sv_cheats");
*(int*)((DWORD)&sv_cheats->fnChangeCallback + 0xC) = 0; // ew
sv_cheats->SetValue(1);
g_pEngine->ExecuteClientCmd("firstperson");
}
init = true;
}
}
void Thirdperson_FSN(ClientFrameStage_t curStage) {
if (curStage == FRAME_RENDER_START && g_GameInput->m_fCameraInThirdPerson && Globals::LocalPlayer && Globals::LocalPlayer->IsAlive())
{
g_pPrediction->SetLocalViewAngles(Vector(Globals::RealAngle.x, Globals::RealAngle.y, 0));
}
}
///////////////////