mirror of
https://github.com/rei-2/Amalgam
synced 2026-10-10 04:43:09 +08:00
fix local strafe prediction and weapon swap cancelling
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ class CMisc
|
||||
|
||||
bool m_bPeekPlaced = false;
|
||||
Vec3 m_vPeekReturnPos = {};
|
||||
|
||||
//bool bSteamCleared = false;
|
||||
|
||||
public:
|
||||
|
||||
@@ -113,7 +113,7 @@ void CMovementSimulation::Store()
|
||||
for (auto pEntity : H::Entities.GetGroup(EGroupType::PLAYERS_ALL))
|
||||
{
|
||||
auto pPlayer = pEntity->As<CTFPlayer>();
|
||||
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<CTFPlayer>();
|
||||
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<IHandleEntity*>(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)
|
||||
|
||||
@@ -102,8 +102,8 @@ private:
|
||||
bool m_bOldFirstTimePredicted = false;
|
||||
float m_flOldFrametime = 0.f;
|
||||
|
||||
std::unordered_map<int, std::deque<MoveData>> mRecords;
|
||||
std::unordered_map<int, std::deque<float>> mSimTimes;
|
||||
std::unordered_map<int, std::deque<MoveData>> m_mRecords;
|
||||
std::unordered_map<int, std::deque<float>> m_mSimTimes;
|
||||
|
||||
public:
|
||||
void Store();
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
@@ -492,8 +492,8 @@ const std::vector<CBaseEntity*>& 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<CTFPlayer>(); 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<CTFPlayer>(); 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; }
|
||||
|
||||
Reference in New Issue
Block a user