ППХУДЕР
-
Автор темы
- #1
База qo0, мувемент фикс с фаталити
CreaeMove
MovementFix.cpp
MovementFix.h
CreaeMove
C++:
bool FASTCALL H::hkCreateMove(IClientModeShared* thisptr, int edx, float flInputSampleTime, CUserCmd* pCmd)
{
static auto oCreateMove = DTR::CreateMove.GetOriginal<decltype(&hkCreateMove)>();
auto wish_angle = pCmd->angViewPoint;
/*
* get global localplayer pointer
* @note: dont forget check global localplayer for nullptr when using not in createmove
*/
CBaseEntity* pLocal = G::pLocal = CBaseEntity::GetLocalPlayer();
// is called from CInput::ExtraMouseSample
if (pCmd->iCommandNumber == 0)
return oCreateMove(thisptr, edx, flInputSampleTime, pCmd);
/*
* check is called from CInput::CreateMove
* and SetLocalViewAngles for engine/prediction at the same time
* cuz SetViewAngles isn't called if return false and can cause frame stuttering
*/
if (oCreateMove(thisptr, edx, flInputSampleTime, pCmd))
I::Prediction->SetLocalViewAngles(pCmd->angViewPoint);
// save global cmd pointer
G::pCmd = pCmd;
if (I::ClientState == nullptr || I::Engine->IsPlayingDemo())
return oCreateMove(thisptr, edx, flInputSampleTime, pCmd);
// netchannel pointer
INetChannel* pNetChannel = I::ClientState->pNetChannel;
// get stack frame without asm inlines
// safe and will not break if you omitting frame pointer
const volatile auto vlBaseAddress = *reinterpret_cast<std::uintptr_t*>(reinterpret_cast<std::uintptr_t>(_AddressOfReturnAddress()) - sizeof(std::uintptr_t));
// get sendpacket pointer from stack frame
bool& bSendPacket = *reinterpret_cast<bool*>(vlBaseAddress - 0x1C);
// save previous view angles for movement correction
QAngle angOldViewPoint = pCmd->angViewPoint;
SEH_START
// @note: need do bunnyhop and other movements before prediction
CMiscellaneous::Get().Run(pCmd, pLocal, bSendPacket);
/*
* CL_RunPrediction
* correct prediction when framerate is lower than tickrate
* https://github.com/VSES/SourceEngine2007/blob/master/se2007/engine/cl_pred.cpp#L41
*/
if (I::ClientState->iDeltaTick > 0)
I::Prediction->Update(I::ClientState->iDeltaTick, I::ClientState->iDeltaTick > 0, I::ClientState->iLastCommandAck, I::ClientState->iLastOutgoingCommand + I::ClientState->nChokedCommands);
CPrediction::Get().Start(pCmd, pLocal);
{
if (C::Get<bool>(Vars.bMiscAutoPistol))
CMiscellaneous::Get().AutoPistol(pCmd, pLocal);
if (C::Get<bool>(Vars.bMiscFakeLag) || C::Get<bool>(Vars.bAntiAim))
CMiscellaneous::Get().FakeLag(pLocal, bSendPacket);
if (C::Get<bool>(Vars.bRage))
CRageBot::Get().Run(pCmd, pLocal, bSendPacket);
if (C::Get<bool>(Vars.bLegit))
CLegitBot::Get().Run(pCmd, pLocal, bSendPacket);
if (C::Get<bool>(Vars.bTrigger))
CTriggerBot::Get().Run(pCmd, pLocal);
if (C::Get<bool>(Vars.bAntiAim))
CAntiAim::Get().UpdateServerAnimations(pCmd, pLocal);
if (C::Get<bool>(Vars.bAntiAim))
CAntiAim::Get().Run(pCmd, pLocal, bSendPacket);
}
CPrediction::Get().End(pCmd, pLocal);
CAntiAim::Get().MovementFix(wish_angle);
if (pLocal->IsAlive())
CMiscellaneous::Get().MovementCorrection(pCmd, angOldViewPoint);
// clamp & normalize view angles
if (C::Get<bool>(Vars.bMiscAntiUntrusted))
{
pCmd->angViewPoint.Normalize();
pCmd->angViewPoint.Clamp();
}
if (C::Get<bool>(Vars.bMiscPingSpike))
CLagCompensation::Get().UpdateIncomingSequences(pNetChannel);
else
CLagCompensation::Get().ClearIncomingSequences();
// @note: doesnt need rehook cuz detours here
if (pNetChannel != nullptr)
{
if (!DTR::SendNetMsg.IsHooked())
DTR::SendNetMsg.Create(MEM::GetVFunc(pNetChannel, VTABLE::SENDNETMSG), &hkSendNetMsg);
if (!DTR::SendDatagram.IsHooked())
DTR::SendDatagram.Create(MEM::GetVFunc(pNetChannel, VTABLE::SENDDATAGRAM), &hkSendDatagram);
}
// store next tick view angles state
G::angRealView = pCmd->angViewPoint;
// store current tick send packet state
G::bSendPacket = bSendPacket;
// @note: i seen many times this mistake and please do not set/clamp angles here cuz u get confused with psilent aimbot later!
SEH_END
return false;
}
C++:
void CAntiAim::MovementFix(const QAngle wish_angle)
{
Vector view_fwd, view_right, view_up, cmd_fwd, cmd_right, cmd_up;
auto viewangles = G::pCmd->angViewPoint.Clamp();
viewangles.Normalize();
M::AngleVectors(wish_angle, &view_fwd, &view_right, &view_up);
M::AngleVectors(viewangles, &cmd_fwd, &cmd_right, &cmd_up);
const auto v8 = sqrtf((view_fwd.x * view_fwd.x) + (view_fwd.y * view_fwd.y));
const auto v10 = sqrtf((view_right.x * view_right.x) + (view_right.y * view_right.y));
const auto v12 = sqrtf(view_up.z * view_up.z);
const Vector norm_view_fwd((1.f / v8) * view_fwd.x, (1.f / v8) * view_fwd.y, 0.f);
const Vector norm_view_right((1.f / v10) * view_right.x, (1.f / v10) * view_right.y, 0.f);
const Vector norm_view_up(0.f, 0.f, (1.f / v12) * view_up.z);
const auto v14 = sqrtf((cmd_fwd.x * cmd_fwd.x) + (cmd_fwd.y * cmd_fwd.y));
const auto v16 = sqrtf((cmd_right.x * cmd_right.x) + (cmd_right.y * cmd_right.y));
const auto v18 = sqrtf(cmd_up.z * cmd_up.z);
const Vector norm_cmd_fwd((1.f / v14) * cmd_fwd.x, (1.f / v14) * cmd_fwd.y, 0.f);
const Vector norm_cmd_right((1.f / v16) * cmd_right.x, (1.f / v16) * cmd_right.y, 0.f);
const Vector norm_cmd_up(0.f, 0.f, (1.f / v18) * cmd_up.z);
const auto v22 = norm_view_fwd.x * G::pCmd->flForwardMove;
const auto v26 = norm_view_fwd.y * G::pCmd->flForwardMove;
const auto v28 = norm_view_fwd.z * G::pCmd->flForwardMove;
const auto v24 = norm_view_right.x * G::pCmd->flSideMove;
const auto v23 = norm_view_right.y * G::pCmd->flSideMove;
const auto v25 = norm_view_right.z * G::pCmd->flSideMove;
const auto v30 = norm_view_up.x * G::pCmd->flUpMove;
const auto v27 = norm_view_up.z * G::pCmd->flUpMove;
const auto v29 = norm_view_up.y * G::pCmd->flUpMove;
G::pCmd->flForwardMove = ((((norm_cmd_fwd.x * v24) + (norm_cmd_fwd.y * v23)) + (norm_cmd_fwd.z * v25))
+ (((norm_cmd_fwd.x * v22) + (norm_cmd_fwd.y * v26)) + (norm_cmd_fwd.z * v28)))
+ (((norm_cmd_fwd.y * v30) + (norm_cmd_fwd.x * v29)) + (norm_cmd_fwd.z * v27));
G::pCmd->flSideMove = ((((norm_cmd_right.x * v24) + (norm_cmd_right.y * v23)) + (norm_cmd_right.z * v25))
+ (((norm_cmd_right.x * v22) + (norm_cmd_right.y * v26)) + (norm_cmd_right.z * v28)))
+ (((norm_cmd_right.x * v29) + (norm_cmd_right.y * v30)) + (norm_cmd_right.z * v27));
G::pCmd->flUpMove = ((((norm_cmd_up.x * v23) + (norm_cmd_up.y * v24)) + (norm_cmd_up.z * v25))
+ (((norm_cmd_up.x * v26) + (norm_cmd_up.y * v22)) + (norm_cmd_up.z * v28)))
+ (((norm_cmd_up.x * v30) + (norm_cmd_up.y * v29)) + (norm_cmd_up.z * v27));
}
C++:
static void MovementFix(QAngle wish_angle);