From 351722db9b951977b4332c09ee4a67e892099301 Mon Sep 17 00:00:00 2001 From: rei-2 <174158077+rei-2@users.noreply.github.com> Date: Sat, 4 Jan 2025 14:00:38 -0500 Subject: [PATCH] changes to movesim & player velocity --- Amalgam/src/Features/ImGui/Menu/Menu.cpp | 4 + .../MovementSimulation/MovementSimulation.cpp | 98 +++++++++-------- Amalgam/src/Features/Visuals/ESP/ESP.cpp | 3 +- .../src/Hooks/CBaseEntity_SetAbsVelocity.cpp | 101 +++++++++--------- .../IBaseClientDLL_DispatchUserMessage.cpp | 16 +-- Amalgam/src/SDK/Helpers/Entities/Entities.cpp | 2 + Amalgam/src/SDK/Helpers/Entities/Entities.h | 3 + Amalgam/src/SDK/Vars.h | 12 ++- 8 files changed, 131 insertions(+), 108 deletions(-) diff --git a/Amalgam/src/Features/ImGui/Menu/Menu.cpp b/Amalgam/src/Features/ImGui/Menu/Menu.cpp index 1445a80e..f5ff0e05 100644 --- a/Amalgam/src/Features/ImGui/Menu/Menu.cpp +++ b/Amalgam/src/Features/ImGui/Menu/Menu.cpp @@ -229,6 +229,8 @@ void CMenu::MenuAimbot() FSlider("high min distance##ground", Vars::Aimbot::Projectile::GroundHighMinimumDistance, 0.f, 10000.f, 100.f, "%g", FSlider_Right | FSlider_Min | FSlider_Precision); FSlider("max changes##ground", Vars::Aimbot::Projectile::GroundMaxChanges, 0, 5, 1, "%i", FSlider_Left | FSlider_Min | FSlider_Precision); FSlider("max change time##ground", Vars::Aimbot::Projectile::GroundMaxChangeTime, 0, 66, 1, "%i", FSlider_Right | FSlider_Min | FSlider_Precision); + FSlider("new weight##ground", Vars::Aimbot::Projectile::GroundNewWeight, 0.f, 200.f, 5.f, "%g%%", FSlider_Left | FSlider_Min | FSlider_Precision); + FSlider("old weight##ground", Vars::Aimbot::Projectile::GroundOldWeight, 0.f, 200.f, 5.f, "%g%%", FSlider_Right | FSlider_Min | FSlider_Precision); FText("air"); FSlider("samples##air", Vars::Aimbot::Projectile::AirSamples, 3, 66, 1, "%i", FSlider_Left); @@ -239,6 +241,8 @@ void CMenu::MenuAimbot() FSlider("high min distance##air", Vars::Aimbot::Projectile::AirHighMinimumDistance, 0.f, 10000.f, 100.f, "%g", FSlider_Right | FSlider_Min | FSlider_Precision); FSlider("max changes##air", Vars::Aimbot::Projectile::AirMaxChanges, 0, 5, 1, "%i", FSlider_Left | FSlider_Min | FSlider_Precision); FSlider("max change time##air", Vars::Aimbot::Projectile::AirMaxChangeTime, 0, 66, 1, "%i", FSlider_Right | FSlider_Min | FSlider_Precision); + FSlider("new weight##air", Vars::Aimbot::Projectile::AirNewWeight, 0.f, 200.f, 5.f, "%g%%", FSlider_Left | FSlider_Min | FSlider_Precision); + FSlider("old weight##air", Vars::Aimbot::Projectile::AirOldWeight, 0.f, 200.f, 5.f, "%g%%", FSlider_Right | FSlider_Min | FSlider_Precision); FText(""); FSlider("velocity average count", Vars::Aimbot::Projectile::VelocityAverageCount, 1, 10, 1, "%i", FSlider_Left); diff --git a/Amalgam/src/Features/Simulation/MovementSimulation/MovementSimulation.cpp b/Amalgam/src/Features/Simulation/MovementSimulation/MovementSimulation.cpp index 2a130069..3c2ede3c 100644 --- a/Amalgam/src/Features/Simulation/MovementSimulation/MovementSimulation.cpp +++ b/Amalgam/src/Features/Simulation/MovementSimulation/MovementSimulation.cpp @@ -379,6 +379,9 @@ bool CMovementSimulation::Initialize(CBaseEntity* pEntity, PlayerStorage& player // the hacks that make it work { + if (auto pAvgVelocity = H::Entities.GetAvgVelocity(pPlayer->entindex())) + pPlayer->m_vecVelocity() = *pAvgVelocity; // only use average velocity here + if (pPlayer->IsDucking()) { pPlayer->m_fFlags() &= ~FL_DUCKING; // breaks origin's z if FL_DUCKING is not removed @@ -532,7 +535,7 @@ bool CMovementSimulation::SetupMoveData(PlayerStorage& playerStorage) return true; } -static bool GetYawDifference(std::deque& vRecords, size_t i, float* flYaw, float flStraightFuzzyValue, int iMaxChanges = 0, int iMaxChangeTime = 0) +static bool GetYawDifference(std::deque& vRecords, size_t i, float* pYaw, float flStraightFuzzyValue, int iMaxChanges = 0, int iMaxChangeTime = 0) { if (vRecords.size() <= i + 2) return false; @@ -542,16 +545,16 @@ static bool GetYawDifference(std::deque& vRecords, size_t i, float* fl const float flTime1 = pRecord1.m_flSimTime, flTime2 = pRecord2.m_flSimTime; const int iTicks = std::max(TIME_TO_TICKS(flTime1 - flTime2), 1); - *flYaw = flYaw1 - flYaw2; - *flYaw = fmodf(*flYaw + 180.f, 360.f); - *flYaw += *flYaw < 0 ? 180.f : -180.f; - *flYaw /= iTicks; + *pYaw = flYaw1 - flYaw2; + *pYaw = fmodf(*pYaw + 180.f, 360.f); + *pYaw += *pYaw < 0 ? 180.f : -180.f; + *pYaw /= iTicks; static int iSign = 0; const int iLastSign = iSign; - const int iCurSign = iSign = *flYaw > 0 ? 1 : -1; + const int iCurSign = iSign = *pYaw > 0 ? 1 : -1; - if (fabsf(*flYaw) * pRecord1.m_vVelocity.Length2D() * iTicks <= flStraightFuzzyValue) // dumb way to get straight bool + if (fabsf(*pYaw) * pRecord1.m_vVelocity.Length2D() * iTicks <= flStraightFuzzyValue) // dumb way to get straight bool return false; static int iChanges, iStart; @@ -567,81 +570,88 @@ static bool GetYawDifference(std::deque& vRecords, size_t i, float* fl return true; } -static bool GetYawInfo(CTFPlayer* pPlayer, std::deque& vRecords, int iSamples, bool bGround, float* pAverageYaw, float* pAverageDelta, int* pTicks) +void CMovementSimulation::GetAverageYaw(PlayerStorage& playerStorage, int iSamples) { + auto pPlayer = playerStorage.m_pPlayer; + auto& vRecords = mRecords[pPlayer->entindex()]; + + bool bGround = pPlayer->IsOnGround(); float flStraightFuzzyValue = bGround ? Vars::Aimbot::Projectile::GroundStraightFuzzyValue.Value : Vars::Aimbot::Projectile::AirStraightFuzzyValue.Value; int iMaxChanges = bGround ? Vars::Aimbot::Projectile::GroundMaxChanges.Value : Vars::Aimbot::Projectile::AirMaxChanges.Value; int iMaxChangeTime = bGround ? Vars::Aimbot::Projectile::GroundMaxChangeTime.Value : Vars::Aimbot::Projectile::AirMaxChangeTime.Value; + float flLowMinimumDistance = bGround ? Vars::Aimbot::Projectile::GroundLowMinimumDistance.Value : Vars::Aimbot::Projectile::AirLowMinimumDistance.Value; + float flLowMinimumSamples = bGround ? Vars::Aimbot::Projectile::GroundLowMinimumSamples.Value : Vars::Aimbot::Projectile::AirLowMinimumSamples.Value; + float flHighMinimumDistance = bGround ? Vars::Aimbot::Projectile::GroundHighMinimumDistance.Value : Vars::Aimbot::Projectile::AirHighMinimumDistance.Value; + float flHighMinimumSamples = bGround ? Vars::Aimbot::Projectile::GroundHighMinimumSamples.Value : Vars::Aimbot::Projectile::AirHighMinimumSamples.Value; + float flNewWeight = (bGround ? Vars::Aimbot::Projectile::GroundNewWeight.Value : Vars::Aimbot::Projectile::AirNewWeight.Value) / 100; + float flOldWeight = (bGround ? Vars::Aimbot::Projectile::GroundOldWeight.Value : Vars::Aimbot::Projectile::AirOldWeight.Value) / 100; + float flMaxWeight = std::max(flNewWeight, flOldWeight); + if (!flMaxWeight) + return; - float flAverageYaw = 0.f, flAverageDelta = 0.f; int iDeltaChanges = 0; - *pTicks = 0; for (; *pTicks < iSamples; (*pTicks)++) + float flAverageYaw = 0.f, flAverageDelta = 0.f, flTotalWeight = 0.f; + int iTicks = 0, iDeltaChanges = 0; + for (; iTicks < iSamples; iTicks++) { float flYaw; - if (!GetYawDifference(vRecords, *pTicks, &flYaw, flStraightFuzzyValue, iMaxChanges, iMaxChangeTime)) + /* + if (!GetYawDifference(vRecords, iTicks, &flYaw, flStraightFuzzyValue, iMaxChanges, iMaxChangeTime)) + break; + */ + + bool bYaw = GetYawDifference(vRecords, iTicks, &flYaw, flStraightFuzzyValue, iMaxChanges, iMaxChangeTime); + SDK::Output("GetYawDifference", std::format("{}: {}, {}", iTicks, flYaw, bYaw).c_str(), { 50, 127, 75, 255 }, Vars::Debug::Logging.Value); + if (!bYaw) break; float flMult = 1.f; if (!pPlayer->IsOnGround()) { - float flPrevVelZ = vRecords[*pTicks].m_vVelocity.z - GetPlayerGravity(pPlayer) * TICK_INTERVAL; + float flPrevVelZ = vRecords[iTicks].m_vVelocity.z - GetPlayerGravity(pPlayer) * TICK_INTERVAL; flMult = 0.f < flPrevVelZ && flPrevVelZ <= 250.f ? 0.25f : 1.f; // flEntFriction will be 0.25f if flPrevVelZ is between 0.f and 250.f } + float flWeight = powf(Math::RemapValClamped(iTicks, 0, iSamples, flNewWeight, flOldWeight) / flMaxWeight, flMaxWeight); + flYaw *= flWeight / flMult, flTotalWeight += flWeight; + flAverageYaw += flYaw; if (Vars::Aimbot::Projectile::StrafeDelta.Value) { - flYaw /= flMult; static float flStaticYaw; float flLastYaw = flStaticYaw; flStaticYaw = flYaw; - if (*pTicks > 0) + if (iTicks > 0) { static float flStaticDelta; float flLastDelta = flStaticDelta; float flDelta = flStaticDelta = flLastYaw - flYaw; - if (*pTicks > 1 && sign(flDelta) != sign(flLastDelta)) + if (iTicks > 1 && sign(flDelta) != sign(flLastDelta)) iDeltaChanges++; flAverageDelta += flDelta; } } } - flAverageDelta /= std::max(iDeltaChanges, 1); - if (*pTicks > 3) // valid strafes high enough - { - *pAverageYaw = flAverageYaw; - if (*pTicks > 6) // valid strafes probably fine for this - *pAverageDelta = flAverageDelta; - return true; - } - return false; -} - -void CMovementSimulation::GetAverageYaw(PlayerStorage& playerStorage, int iSamples) -{ - bool bGround = playerStorage.m_pPlayer->IsOnGround(); - - float flAverageYaw, flAverageDelta; int iTicks; - if (!GetYawInfo(playerStorage.m_pPlayer, mRecords[playerStorage.m_pPlayer->entindex()], iSamples, bGround, &flAverageYaw, &flAverageDelta, &iTicks)) + if (!flTotalWeight || iTicks <= 3) // valid strafes not high enough return; - - float flLowMinimumDistance = bGround ? Vars::Aimbot::Projectile::GroundLowMinimumDistance.Value : Vars::Aimbot::Projectile::AirLowMinimumDistance.Value; - float flLowMinimumSamples = bGround ? Vars::Aimbot::Projectile::GroundLowMinimumSamples.Value : Vars::Aimbot::Projectile::AirLowMinimumSamples.Value; - float flHighMinimumDistance = bGround ? Vars::Aimbot::Projectile::GroundHighMinimumDistance.Value : Vars::Aimbot::Projectile::AirHighMinimumDistance.Value; - float flHighMinimumSamples = bGround ? Vars::Aimbot::Projectile::GroundHighMinimumSamples.Value : Vars::Aimbot::Projectile::AirHighMinimumSamples.Value; + if (iTicks > 6) // valid strafes probably fine for this + flAverageDelta /= std::max(iDeltaChanges, 1); + else + flAverageDelta = 0.f; float flDistance = 0.f; if (auto pLocal = H::Entities.GetLocal()) flDistance = pLocal->m_vecOrigin().DistTo(playerStorage.m_pPlayer->m_vecOrigin()); - int iMinimumStrafes = (flDistance < flLowMinimumDistance) ? flLowMinimumSamples : Math::RemapValClamped(flDistance, flLowMinimumDistance, flHighMinimumDistance, flLowMinimumSamples + 1, flHighMinimumSamples); - flAverageYaw /= std::max(iTicks, iMinimumStrafes); + int iMinimumStrafes = flDistance < flLowMinimumDistance ? flLowMinimumSamples : Math::RemapValClamped(flDistance, flLowMinimumDistance, flHighMinimumDistance, flLowMinimumSamples + 1, flHighMinimumSamples); + flAverageYaw /= flTotalWeight; + flAverageYaw *= std::min(float(iTicks) / iMinimumStrafes, 1.f); flAverageDelta = std::clamp(flAverageDelta / std::max(iTicks, iMinimumStrafes), -0.05f, 0.05f); if (fabsf(flAverageYaw) < 0.1f) return; - SDK::Output("MovementSimulation", std::format("flAverageYaw calculated to {} ({}) from {} ({})", flAverageYaw, flAverageDelta, std::max(iTicks, iMinimumStrafes), iTicks).c_str(), { 100, 255, 150, 255 }, Vars::Debug::Logging.Value); + SDK::Output("MovementSimulation", std::format("flAverageYaw calculated to {} ({}) from {} ({})", flAverageYaw, flAverageDelta, iTicks, iMinimumStrafes).c_str(), { 100, 255, 150, 255 }, Vars::Debug::Logging.Value); playerStorage.m_flAverageYaw = flAverageYaw; playerStorage.m_flAverageDelta = flAverageDelta; @@ -666,7 +676,7 @@ void CMovementSimulation::RunTick(PlayerStorage& playerStorage, bool bPath) if (bPath) playerStorage.m_vPath.push_back(playerStorage.m_MoveData.m_vecAbsOrigin); - //make sure frametime and prediction vars are right + // make sure frametime and prediction vars are right I::Prediction->m_bInPrediction = true; I::Prediction->m_bFirstTimePredicted = false; I::GlobalVars->frametime = I::Prediction->m_bEnginePaused ? 0.f : TICK_INTERVAL; @@ -674,11 +684,13 @@ void CMovementSimulation::RunTick(PlayerStorage& playerStorage, bool bPath) float flCorrection = 0.f; if (playerStorage.m_flAverageYaw) { - float flYaw = playerStorage.m_flAverageYaw, flDelta = playerStorage.m_flAverageDelta, flMult = 1.f; + float flYaw = playerStorage.m_flAverageYaw, flDelta = playerStorage.m_flAverageDelta; + float flMult = 1.f; if (!playerStorage.m_pPlayer->IsOnGround()) { - flCorrection = 90.f * sign(flYaw); + if (!playerStorage.m_pPlayer->InCond(TF_COND_SHIELD_CHARGE)) + flCorrection = 90.f * sign(flYaw); float flPrevVelZ = playerStorage.m_MoveData.m_vecVelocity.z + GetPlayerGravity(playerStorage.m_pPlayer) * TICK_INTERVAL; flMult = 0.f < flPrevVelZ && flPrevVelZ <= 250.f ? 0.25f : 1.f; // flEntFriction will be 0.25f if flPrevVelZ is between 0.f and 250.f diff --git a/Amalgam/src/Features/Visuals/ESP/ESP.cpp b/Amalgam/src/Features/Visuals/ESP/ESP.cpp index 1ed3f558..880bae1e 100644 --- a/Amalgam/src/Features/Visuals/ESP/ESP.cpp +++ b/Amalgam/src/Features/Visuals/ESP/ESP.cpp @@ -1119,8 +1119,7 @@ bool CESP::GetDrawBounds(CBaseEntity* pEntity, float& x, float& y, float& w, flo const char* CESP::GetPlayerClass(int iClassNum) { static const char* szClasses[] = { - "Unknown", "Scout", "Sniper", "Soldier", "Demoman", - "Medic", "Heavy", "Pyro", "Spy", "Engineer" + "Unknown", "Scout", "Sniper", "Soldier", "Demoman", "Medic", "Heavy", "Pyro", "Spy", "Engineer" }; return iClassNum < 10 && iClassNum > 0 ? szClasses[iClassNum] : szClasses[0]; diff --git a/Amalgam/src/Hooks/CBaseEntity_SetAbsVelocity.cpp b/Amalgam/src/Hooks/CBaseEntity_SetAbsVelocity.cpp index b84f87a7..693b7fe3 100644 --- a/Amalgam/src/Hooks/CBaseEntity_SetAbsVelocity.cpp +++ b/Amalgam/src/Hooks/CBaseEntity_SetAbsVelocity.cpp @@ -59,78 +59,73 @@ MAKE_HOOK(CBaseEntity_SetAbsVelocity, S::CBaseEntity_SetAbsVelocity(), void, { static const auto dwDesired = S::CBasePlayer_PostDataUpdate_SetAbsVelocity_Call(); const auto dwRetAddr = uintptr_t(_ReturnAddress()); - if (dwRetAddr != dwDesired) return CALL_ORIGINAL(rcx, vecAbsVelocity); const auto pPlayer = reinterpret_cast(rcx); - if (!pPlayer || !G::VelocityMap.contains(pPlayer->entindex()) || pPlayer->IsDormant()) + if (pPlayer->IsDormant() || !G::VelocityMap.contains(pPlayer->entindex()) || G::VelocityMap[pPlayer->entindex()].empty()) return CALL_ORIGINAL(rcx, vecAbsVelocity); auto& vRecords = G::VelocityMap[pPlayer->entindex()]; - if (vRecords.empty()) - return; - bool bGrounded = pPlayer->IsOnGround(); + auto& tOldRecord = vRecords.front(); + auto tNewRecord = VelFixRecord(pPlayer->m_vecOrigin() + Vec3(0, 0, pPlayer->m_vecMaxs().z - pPlayer->m_vecMins().z), pPlayer->m_flSimulationTime()); + + int iDeltaTicks = TIME_TO_TICKS(tNewRecord.m_flSimulationTime - tOldRecord.m_flSimulationTime); + float flDeltaTime = TICKS_TO_TIME(iDeltaTicks); + if (iDeltaTicks <= 0) + return; + + static auto sv_lagcompensation_teleport_dist = U::ConVars.FindVar("sv_lagcompensation_teleport_dist"); + float flDist = powf(sv_lagcompensation_teleport_dist ? sv_lagcompensation_teleport_dist->GetFloat() : 64.f, 2.f) * iDeltaTicks; + if ((tNewRecord.m_vecOrigin - tOldRecord.m_vecOrigin).Length2DSqr() >= flDist) + return vRecords.clear(); + AxisInfo tAxisInfo = {}; + for (int i = 0; i < 3; i++) { - auto& tOldRecord = vRecords.front(); - auto tNewRecord = VelFixRecord(pPlayer->m_vecOrigin() + Vec3(0, 0, pPlayer->m_vecMaxs().z - pPlayer->m_vecMins().z), pPlayer->m_flSimulationTime()); + tAxisInfo[i].m_flOldAxisValue = tOldRecord.m_vecOrigin[i]; + tAxisInfo[i].m_flNewAxisValue = tNewRecord.m_vecOrigin[i]; + tAxisInfo[i].m_flOldSimulationTime = tOldRecord.m_flSimulationTime; + tAxisInfo[i].m_flNewSimulationTime = tNewRecord.m_flSimulationTime; - int iDeltaTicks = TIME_TO_TICKS(tNewRecord.m_flSimulationTime - tOldRecord.m_flSimulationTime); - float flDeltaTime = TICKS_TO_TIME(iDeltaTicks); - if (iDeltaTicks <= 0) - return; + if (i == 2 && bGrounded) + break; - static auto sv_lagcompensation_teleport_dist = U::ConVars.FindVar("sv_lagcompensation_teleport_dist"); - float flDist = powf(sv_lagcompensation_teleport_dist ? sv_lagcompensation_teleport_dist->GetFloat() : 64.f, 2.f) * iDeltaTicks; - if ((tNewRecord.m_vecOrigin - tOldRecord.m_vecOrigin).Length2DSqr() >= flDist) - return vRecords.clear(); + float flOldPos1 = tOldRecord.m_vecOrigin[i], flOldPos2 = flOldPos1 + 0.125f * sign(flOldPos1); + float flNewPos1 = tNewRecord.m_vecOrigin[i], flNewPos2 = flNewPos1 + 0.125f * sign(flNewPos1); + if (!flOldPos1) flOldPos1 = -0.125f, flOldPos2 = 0.125f; + if (!flNewPos1) flNewPos1 = -0.125f, flNewPos2 = 0.125f; - for (int i = 0; i < 3; i++) + FloatRange_t flVelocityRange; { - tAxisInfo[i].m_flOldAxisValue = tOldRecord.m_vecOrigin[i]; - tAxisInfo[i].m_flNewAxisValue = tNewRecord.m_vecOrigin[i]; - tAxisInfo[i].m_flOldSimulationTime = tOldRecord.m_flSimulationTime; - tAxisInfo[i].m_flNewSimulationTime = tNewRecord.m_flSimulationTime; + std::deque vDeltas = { flNewPos1 - flOldPos1, flNewPos2 - flOldPos1, flNewPos1 - flOldPos2, flNewPos2 - flOldPos2 }; + std::sort(vDeltas.begin(), vDeltas.end(), std::less()); + flVelocityRange = { vDeltas.front() / flDeltaTime, vDeltas.back() / flDeltaTime }; + } - if (i == 2 && bGrounded) + for (auto& tRecord : vRecords) + { + if (tAxisInfo[i].m_flOldSimulationTime <= tRecord.m_flSimulationTime) + continue; + + float flRewind = -ROUND_TO_TICKS(tNewRecord.m_flSimulationTime - tRecord.m_flSimulationTime); + FloatRange_t flPositionRange = { tAxisInfo[i].m_flNewAxisValue + flVelocityRange.Max * flRewind, tAxisInfo[i].m_flNewAxisValue + flVelocityRange.Min * flRewind }; + if (i == 2) + { + static auto sv_gravity = U::ConVars.FindVar("sv_gravity"); + float flGravityCorrection = (sv_gravity ? sv_gravity->GetFloat() : 800.f) * powf(flRewind + TICK_INTERVAL / 2, 2.f) / 2; + flPositionRange.Min -= flGravityCorrection, flPositionRange.Max -= flGravityCorrection; + } + if (flPositionRange.Min > tRecord.m_vecOrigin[i] || tRecord.m_vecOrigin[i] > flPositionRange.Max) break; - float flOldPos1 = tOldRecord.m_vecOrigin[i], flOldPos2 = flOldPos1 + 0.125f * sign(flOldPos1); - float flNewPos1 = tNewRecord.m_vecOrigin[i], flNewPos2 = flNewPos1 + 0.125f * sign(flNewPos1); - if (!flOldPos1) flOldPos1 = -0.125f, flOldPos2 = 0.125f; - if (!flNewPos1) flNewPos1 = -0.125f, flNewPos2 = 0.125f; - - FloatRange_t flVelocityRange; - { - std::deque vDeltas = { flNewPos1 - flOldPos1, flNewPos2 - flOldPos1, flNewPos1 - flOldPos2, flNewPos2 - flOldPos2 }; - std::sort(vDeltas.begin(), vDeltas.end(), std::less()); - flVelocityRange = { vDeltas.front() / flDeltaTime, vDeltas.back() / flDeltaTime }; - } - - for (auto& tRecord : vRecords) - { - if (tAxisInfo[i].m_flOldSimulationTime <= tRecord.m_flSimulationTime) - continue; - - float flRewind = -ROUND_TO_TICKS(tNewRecord.m_flSimulationTime - tRecord.m_flSimulationTime); - FloatRange_t flPositionRange = { tAxisInfo[i].m_flNewAxisValue + flVelocityRange.Max * flRewind, tAxisInfo[i].m_flNewAxisValue + flVelocityRange.Min * flRewind }; - if (i == 2) - { - static auto sv_gravity = U::ConVars.FindVar("sv_gravity"); - float flGravityCorrection = (sv_gravity ? sv_gravity->GetFloat() : 800.f) * powf(flRewind + TICK_INTERVAL / 2, 2.f) / 2; - flPositionRange.Min -= flGravityCorrection, flPositionRange.Max -= flGravityCorrection; - } - if (flPositionRange.Min > tRecord.m_vecOrigin[i] || tRecord.m_vecOrigin[i] > flPositionRange.Max) - break; - - tAxisInfo[i].m_flOldAxisValue = tRecord.m_vecOrigin[i]; - tAxisInfo[i].m_flOldSimulationTime = tRecord.m_flSimulationTime; - } + tAxisInfo[i].m_flOldAxisValue = tRecord.m_vecOrigin[i]; + tAxisInfo[i].m_flOldSimulationTime = tRecord.m_flSimulationTime; } } - CALL_ORIGINAL(rcx, tAxisInfo.Get(bGrounded)); + H::Entities.SetAvgVelocity(pPlayer->entindex(), tAxisInfo.Get(bGrounded)); + CALL_ORIGINAL(rcx, (tNewRecord.m_vecOrigin - tOldRecord.m_vecOrigin) / flDeltaTime); } \ No newline at end of file diff --git a/Amalgam/src/Hooks/IBaseClientDLL_DispatchUserMessage.cpp b/Amalgam/src/Hooks/IBaseClientDLL_DispatchUserMessage.cpp index 29f5e969..a0678d51 100644 --- a/Amalgam/src/Hooks/IBaseClientDLL_DispatchUserMessage.cpp +++ b/Amalgam/src/Hooks/IBaseClientDLL_DispatchUserMessage.cpp @@ -36,20 +36,24 @@ MAKE_HOOK(IBaseClientDLL_DispatchUserMessage, U::Memory.GetVFunc(I::BaseClientDL if (F::NoSpreadHitscan.ParsePlayerPerf(msgData)) return true; - if (Vars::Misc::Automation::AntiAutobalance.Value && msgData.GetNumBitsLeft() > 35) + if (Vars::Misc::Automation::AntiAutobalance.Value && bufData && msgData.GetNumBitsLeft() > 35) { - std::string data(bufData); - if (data.find("TeamChangeP") != std::string::npos && H::Entities.GetLocal()) - I::EngineClient->ClientCmd_Unrestricted("retry"); + std::string sMsg = bufData; + if (!sMsg.empty()) + { + sMsg.erase(0, 1); + if (FNV1A::Hash32(sMsg.c_str()) == FNV1A::Hash32Const("#TF_Autobalance_TeamChangePending")) + I::EngineClient->ClientCmd_Unrestricted("retry"); + } } break; case VGUIMenu: - if (Vars::Visuals::Removals::MOTD.Value && strcmp(reinterpret_cast(msgData.m_pData), "info") == 0) + if (Vars::Visuals::Removals::MOTD.Value && bufData + && FNV1A::Hash32(bufData) == FNV1A::Hash32Const("info")) { I::EngineClient->ClientCmd_Unrestricted("closedwelcomemenu"); return true; } - break; case ForcePlayerViewAngles: return Vars::Visuals::Removals::AngleForcing.Value ? true : CALL_ORIGINAL(rcx, type, msgData); diff --git a/Amalgam/src/SDK/Helpers/Entities/Entities.cpp b/Amalgam/src/SDK/Helpers/Entities/Entities.cpp index 35513e51..619dcb50 100644 --- a/Amalgam/src/SDK/Helpers/Entities/Entities.cpp +++ b/Amalgam/src/SDK/Helpers/Entities/Entities.cpp @@ -377,6 +377,8 @@ Vec3 CEntities::GetEyeAngles(int iIndex) { return m_mEyeAngles.contains(iIndex) Vec3 CEntities::GetPingAngles(int iIndex) { return m_mPingAngles.contains(iIndex) ? m_mPingAngles[iIndex] : Vec3(); } bool CEntities::GetLagCompensation(int iIndex) { return m_mLagCompensation[iIndex]; } void CEntities::SetLagCompensation(int iIndex, bool bLagComp) { m_mLagCompensation[iIndex] = bLagComp; } +Vec3* CEntities::GetAvgVelocity(int iIndex) { return iIndex != I::EngineClient->GetLocalPlayer() ? &m_mAvgVelocities[iIndex] : nullptr; } +void CEntities::SetAvgVelocity(int iIndex, Vec3 vAvgVelocity) { m_mAvgVelocities[iIndex] = vAvgVelocity; } bool CEntities::IsFriend(int iIndex) { return m_mIFriends[iIndex]; } bool CEntities::IsFriend(uint32_t friendsID) { return m_mUFriends[friendsID]; } diff --git a/Amalgam/src/SDK/Helpers/Entities/Entities.h b/Amalgam/src/SDK/Helpers/Entities/Entities.h index 69f3d982..ade8b30a 100644 --- a/Amalgam/src/SDK/Helpers/Entities/Entities.h +++ b/Amalgam/src/SDK/Helpers/Entities/Entities.h @@ -32,6 +32,7 @@ class CEntities std::unordered_map m_mEyeAngles, m_mPingAngles; std::unordered_map m_mLagCompensation; std::unordered_map m_mDormancy; + std::unordered_map m_mAvgVelocities; std::unordered_map m_mIFriends; std::unordered_map m_mUFriends; @@ -68,6 +69,8 @@ public: bool GetLagCompensation(int iIndex); void SetLagCompensation(int iIndex, bool bLagComp); bool GetDormancy(int iIndex); + Vec3* GetAvgVelocity(int iIndex); + void SetAvgVelocity(int iIndex, Vec3 vAvgVelocity); bool IsFriend(int iIndex); bool IsFriend(uint32_t friendsID); diff --git a/Amalgam/src/SDK/Vars.h b/Amalgam/src/SDK/Vars.h index b0b1a897..1c83c0c3 100644 --- a/Amalgam/src/SDK/Vars.h +++ b/Amalgam/src/SDK/Vars.h @@ -161,20 +161,24 @@ namespace Vars CVar(GroundSamples, 33, DEBUGVAR) CVar(GroundStraightFuzzyValue, 100.f, DEBUGVAR) CVar(GroundLowMinimumSamples, 8, DEBUGVAR) - CVar(GroundHighMinimumSamples, 16, DEBUGVAR) + CVar(GroundHighMinimumSamples, 33, DEBUGVAR) CVar(GroundLowMinimumDistance, 0.f, DEBUGVAR) CVar(GroundHighMinimumDistance, 2500.f, DEBUGVAR) CVar(GroundMaxChanges, 0, DEBUGVAR) CVar(GroundMaxChangeTime, 0, DEBUGVAR) + CVar(GroundNewWeight, 100.f, DEBUGVAR) + CVar(GroundOldWeight, 0.f, DEBUGVAR) - CVar(AirSamples, 16, DEBUGVAR) + CVar(AirSamples, 33, DEBUGVAR) CVar(AirStraightFuzzyValue, 10.f, DEBUGVAR) - CVar(AirLowMinimumSamples, 5, DEBUGVAR) - CVar(AirHighMinimumSamples, 5, DEBUGVAR) + CVar(AirLowMinimumSamples, 8, DEBUGVAR) + CVar(AirHighMinimumSamples, 8, DEBUGVAR) CVar(AirLowMinimumDistance, 100000.f, DEBUGVAR) CVar(AirHighMinimumDistance, 100000.f, DEBUGVAR) CVar(AirMaxChanges, 1, DEBUGVAR) CVar(AirMaxChangeTime, 10, DEBUGVAR) + CVar(AirNewWeight, 100.f, DEBUGVAR) + CVar(AirOldWeight, 0.f, DEBUGVAR) CVar(VelocityAverageCount, 5, DEBUGVAR) CVar(VerticalShift, 5.f, DEBUGVAR)