From 9cec06e27bf84a58c8e13d2c9e3a2378b482b6a3 Mon Sep 17 00:00:00 2001 From: rei-2 <174158077+rei-2@users.noreply.github.com> Date: Thu, 5 Jun 2025 17:52:45 -0400 Subject: [PATCH] fix local strafe prediction and weapon swap cancelling --- .../AimbotProjectile/AimbotProjectile.cpp | 18 ++++++------------ Amalgam/src/Features/Misc/Misc.h | 1 + .../MovementSimulation/MovementSimulation.cpp | 13 ++++++------- .../MovementSimulation/MovementSimulation.h | 4 ++-- .../SDK/Definitions/Main/CBaseCombatWeapon.h | 1 + Amalgam/src/SDK/Helpers/Entities/Entities.cpp | 4 ++-- 6 files changed, 18 insertions(+), 23 deletions(-) diff --git a/Amalgam/src/Features/Aimbot/AimbotProjectile/AimbotProjectile.cpp b/Amalgam/src/Features/Aimbot/AimbotProjectile/AimbotProjectile.cpp index 096ecdd4..cbdf3fa6 100644 --- a/Amalgam/src/Features/Aimbot/AimbotProjectile/AimbotProjectile.cpp +++ b/Amalgam/src/Features/Aimbot/AimbotProjectile/AimbotProjectile.cpp @@ -1689,23 +1689,17 @@ static inline void CancelShot(CTFPlayer* pLocal, CTFWeaponBase* pWeapon, CUserCm break; } case TF_WEAPON_CANNON: - { - if (auto pSwap = pLocal->GetWeaponFromSlot(SLOT_SECONDARY)) - { - pCmd->weaponselect = pSwap->entindex(); - iLastTickCancel = pWeapon->entindex(); - } - break; - } case TF_WEAPON_PIPEBOMBLAUNCHER: { - auto pSwap = pLocal->GetWeaponFromSlot(SLOT_PRIMARY); - if (pSwap == pWeapon) - pSwap = pLocal->GetWeaponFromSlot(SLOT_SECONDARY); - if (pSwap) + for (int i = 0; i < MAX_WEAPONS; i++) { + auto pSwap = pLocal->GetWeaponFromSlot(i); + if (!pSwap || pSwap == pWeapon || !pSwap->CanBeSelected()) + continue; + pCmd->weaponselect = pSwap->entindex(); iLastTickCancel = pWeapon->entindex(); + break; } } } diff --git a/Amalgam/src/Features/Misc/Misc.h b/Amalgam/src/Features/Misc/Misc.h index dc75c50f..cc89a914 100644 --- a/Amalgam/src/Features/Misc/Misc.h +++ b/Amalgam/src/Features/Misc/Misc.h @@ -22,6 +22,7 @@ class CMisc bool m_bPeekPlaced = false; Vec3 m_vPeekReturnPos = {}; + //bool bSteamCleared = false; public: diff --git a/Amalgam/src/Features/Simulation/MovementSimulation/MovementSimulation.cpp b/Amalgam/src/Features/Simulation/MovementSimulation/MovementSimulation.cpp index 009b5828..da8f652e 100644 --- a/Amalgam/src/Features/Simulation/MovementSimulation/MovementSimulation.cpp +++ b/Amalgam/src/Features/Simulation/MovementSimulation/MovementSimulation.cpp @@ -113,7 +113,7 @@ void CMovementSimulation::Store() for (auto pEntity : H::Entities.GetGroup(EGroupType::PLAYERS_ALL)) { auto pPlayer = pEntity->As(); - auto& vRecords = mRecords[pPlayer->entindex()]; + auto& vRecords = m_mRecords[pPlayer->entindex()]; if (pPlayer->IsDormant() || !pPlayer->IsAlive() || pPlayer->IsAGhost() || pPlayer->m_vecVelocity().IsZero()) { @@ -184,7 +184,7 @@ void CMovementSimulation::Store() for (auto pEntity : H::Entities.GetGroup(EGroupType::PLAYERS_ALL)) { auto pPlayer = pEntity->As(); - auto& vSimTimes = mSimTimes[pPlayer->entindex()]; + auto& vSimTimes = m_mSimTimes[pPlayer->entindex()]; if (pEntity->entindex() == I::EngineClient->GetLocalPlayer() || pPlayer->IsDormant() || !pPlayer->IsAlive() || pPlayer->IsAGhost()) { @@ -269,7 +269,7 @@ bool CMovementSimulation::Initialize(CBaseEntity* pEntity, PlayerStorage& tStora // really hope this doesn't work like shit if (bHitchance && bCalculated && !pPlayer->m_vecVelocity().IsZero() && Vars::Aimbot::Projectile::HitChance.Value) { - const auto& vRecords = mRecords[pPlayer->entindex()]; + const auto& vRecords = m_mRecords[pPlayer->entindex()]; const auto iSamples = vRecords.size(); float flCurrentChance = 1.f, flAverageYaw = 0.f; @@ -317,8 +317,6 @@ bool CMovementSimulation::SetupMoveData(PlayerStorage& tStorage) if (!tStorage.m_pPlayer) return false; - const auto& vRecords = mRecords[tStorage.m_pPlayer->entindex()]; - tStorage.m_MoveData.m_bFirstRunOfFunctions = false; tStorage.m_MoveData.m_bGameCodeMovedPlayer = false; tStorage.m_MoveData.m_nPlayerHandle = reinterpret_cast(tStorage.m_pPlayer)->GetRefEHandle(); @@ -336,6 +334,7 @@ bool CMovementSimulation::SetupMoveData(PlayerStorage& tStorage) else tStorage.m_MoveData.m_vecViewAngles = iIndex == I::EngineClient->GetLocalPlayer() && G::CurrentUserCmd ? G::CurrentUserCmd->viewangles : H::Entities.GetEyeAngles(iIndex); + const auto& vRecords = m_mRecords[tStorage.m_pPlayer->entindex()]; if (!vRecords.empty()) { auto& tRecord = vRecords.front(); @@ -466,7 +465,7 @@ static bool GetYawDifference(MoveData& tRecord1, MoveData& tRecord2, bool bStart void CMovementSimulation::GetAverageYaw(PlayerStorage& tStorage, int iSamples) { auto pPlayer = tStorage.m_pPlayer; - auto& vRecords = mRecords[pPlayer->entindex()]; + auto& vRecords = m_mRecords[pPlayer->entindex()]; if (vRecords.empty()) return; @@ -727,7 +726,7 @@ void CMovementSimulation::Restore(PlayerStorage& tStorage) float CMovementSimulation::GetPredictedDelta(CBaseEntity* pEntity) { - auto& vSimTimes = mSimTimes[pEntity->entindex()]; + auto& vSimTimes = m_mSimTimes[pEntity->entindex()]; if (!vSimTimes.empty()) { switch (Vars::Aimbot::Projectile::DeltaMode.Value) diff --git a/Amalgam/src/Features/Simulation/MovementSimulation/MovementSimulation.h b/Amalgam/src/Features/Simulation/MovementSimulation/MovementSimulation.h index bb3fb176..e9327dfd 100644 --- a/Amalgam/src/Features/Simulation/MovementSimulation/MovementSimulation.h +++ b/Amalgam/src/Features/Simulation/MovementSimulation/MovementSimulation.h @@ -102,8 +102,8 @@ private: bool m_bOldFirstTimePredicted = false; float m_flOldFrametime = 0.f; - std::unordered_map> mRecords; - std::unordered_map> mSimTimes; + std::unordered_map> m_mRecords; + std::unordered_map> m_mSimTimes; public: void Store(); diff --git a/Amalgam/src/SDK/Definitions/Main/CBaseCombatWeapon.h b/Amalgam/src/SDK/Definitions/Main/CBaseCombatWeapon.h index 6c0195bc..b30e6b81 100644 --- a/Amalgam/src/SDK/Definitions/Main/CBaseCombatWeapon.h +++ b/Amalgam/src/SDK/Definitions/Main/CBaseCombatWeapon.h @@ -22,5 +22,6 @@ public: NETVAR_OFF(m_bInReload, bool, "CBaseCombatWeapon", "m_flTimeWeaponIdle", 4); NETVAR_OFF(m_bRemoveable, bool, "CBaseCombatWeapon", "m_iState", -12); + VIRTUAL(CanBeSelected, bool, 233, this); VIRTUAL(GetName, const char*, 333, this); }; \ No newline at end of file diff --git a/Amalgam/src/SDK/Helpers/Entities/Entities.cpp b/Amalgam/src/SDK/Helpers/Entities/Entities.cpp index f0590932..63be7146 100644 --- a/Amalgam/src/SDK/Helpers/Entities/Entities.cpp +++ b/Amalgam/src/SDK/Helpers/Entities/Entities.cpp @@ -492,8 +492,8 @@ const std::vector& CEntities::GetGroup(const EGroupType& Group) { float CEntities::GetSimTime(int iIndex) { if (m_mSimTimes.contains(iIndex)) return m_mSimTimes[iIndex]; auto pEntity = I::ClientEntityList->GetClientEntity(iIndex)->As(); if (pEntity) return pEntity->m_flSimulationTime(); return 0.f; } float CEntities::GetOldSimTime(int iIndex) { if (m_mOldSimTimes.contains(iIndex)) return m_mOldSimTimes[iIndex]; auto pEntity = I::ClientEntityList->GetClientEntity(iIndex)->As(); if (pEntity) return pEntity->m_flOldSimulationTime(); return 0.f; } -float CEntities::GetDeltaTime(int iIndex) { return m_mDeltaTimes.contains(iIndex) ? m_mDeltaTimes[iIndex] : 0.f; } -float CEntities::GetLagTime(int iIndex) { return m_mLagTimes.contains(iIndex) ? m_mLagTimes[iIndex] : 0.f; } +float CEntities::GetDeltaTime(int iIndex) { return m_mDeltaTimes.contains(iIndex) ? m_mDeltaTimes[iIndex] : TICK_INTERVAL; } +float CEntities::GetLagTime(int iIndex) { return m_mLagTimes.contains(iIndex) ? m_mLagTimes[iIndex] : TICK_INTERVAL; } int CEntities::GetChoke(int iIndex) { return m_mChokes.contains(iIndex) ? m_mChokes[iIndex] : 0; } bool CEntities::GetDormancy(int iIndex) { return m_mDormancy.contains(iIndex); } matrix3x4* CEntities::GetBones(int iIndex) { return m_mBones[iIndex].first ? m_mBones[iIndex].second : nullptr; }