diff --git a/Amalgam/Amalgam.vcxproj b/Amalgam/Amalgam.vcxproj index 10037148..59363316 100644 --- a/Amalgam/Amalgam.vcxproj +++ b/Amalgam/Amalgam.vcxproj @@ -996,7 +996,7 @@ - + diff --git a/Amalgam/Amalgam.vcxproj.filters b/Amalgam/Amalgam.vcxproj.filters index e1075495..08c48409 100644 --- a/Amalgam/Amalgam.vcxproj.filters +++ b/Amalgam/Amalgam.vcxproj.filters @@ -181,7 +181,7 @@ - + diff --git a/Amalgam/src/Features/Aimbot/AimbotMelee/AimbotMelee.cpp b/Amalgam/src/Features/Aimbot/AimbotMelee/AimbotMelee.cpp index a50beb67..a6fab038 100644 --- a/Amalgam/src/Features/Aimbot/AimbotMelee/AimbotMelee.cpp +++ b/Amalgam/src/Features/Aimbot/AimbotMelee/AimbotMelee.cpp @@ -243,7 +243,7 @@ bool CAimbotMelee::CanBackstab(CBaseEntity* pTarget, CTFPlayer* pLocal, Vec3 vEy } Vec3 vEyePos = m_vEyePos; - const float flCompDist = 0.0625f; + const float flCompDist = PLAYER_ORIGIN_COMPRESSION / 2; const float flSqCompDist = 0.0884f; if (auto pCmd = G::CurrentUserCmd; @@ -364,8 +364,8 @@ int CAimbotMelee::CanHit(Target_t& tTarget, CTFPlayer* pLocal, CTFWeaponBase* pW Vec3 vRestoreMaxs = tTarget.m_pEntity->m_vecMaxs(); tTarget.m_pEntity->SetAbsOrigin(pRecord->m_vOrigin); - tTarget.m_pEntity->m_vecMins() = pRecord->m_vMins + 0.125f; // account for origin compression - tTarget.m_pEntity->m_vecMaxs() = pRecord->m_vMaxs - 0.125f; + tTarget.m_pEntity->m_vecMins() = pRecord->m_vMins + PLAYER_ORIGIN_COMPRESSION; // account for origin compression + tTarget.m_pEntity->m_vecMaxs() = pRecord->m_vMaxs - PLAYER_ORIGIN_COMPRESSION; Vec3 vDiff = { 0, 0, std::clamp(m_vEyePos.z - pRecord->m_vOrigin.z, pRecord->m_vMins.z, pRecord->m_vMaxs.z) }; tTarget.m_vPos = pRecord->m_vOrigin + vDiff; diff --git a/Amalgam/src/Features/Aimbot/AimbotProjectile/AimbotProjectile.cpp b/Amalgam/src/Features/Aimbot/AimbotProjectile/AimbotProjectile.cpp index aa66e3a0..e66ba4a1 100644 --- a/Amalgam/src/Features/Aimbot/AimbotProjectile/AimbotProjectile.cpp +++ b/Amalgam/src/Features/Aimbot/AimbotProjectile/AimbotProjectile.cpp @@ -12,7 +12,7 @@ //#define SPLASH_DEBUG5 // trace count #ifdef SPLASH_DEBUG5 -static std::unordered_map s_mTraceCount = {}; +static std::map s_mTraceCount = {}; #endif static inline std::vector GetTargets(CTFPlayer* pLocal, CTFWeaponBase* pWeapon) @@ -445,7 +445,7 @@ static inline void TracePoint(Vec3& vPoint, int& iType, Vec3& vTargetEye, Info_t { SDK::TraceHull(vTargetEye, vPoint, tInfo.m_vHull * -1, tInfo.m_vHull, MASK_SOLID, &filter, &trace); #ifdef SPLASH_DEBUG5 - s_mTraceCount["Splash regular"]++; + s_mTraceCount["Splash out"]++; #endif if (checkPoint(trace, bErase, bNormal)) @@ -471,16 +471,15 @@ static inline void TracePoint(Vec3& vPoint, int& iType, Vec3& vTargetEye, Info_t size_t iOriginalSize = vPoints.size(); { - // necessary performance wise? - //if (bNormal = (tInfo.m_vLocalEye - vTargetEye).Dot(vTargetEye - vPoint) > 0.f) - if (bNormal = (tInfo.m_vLocalEye - vTargetEye).DotNormalized(vTargetEye - vPoint) > Vars::Aimbot::Projectile::Out2NormalCheck.Value) + float flNormal = (tInfo.m_vLocalEye - vTargetEye).DotNormalized(vTargetEye - vPoint); + if (bNormal = Vars::Aimbot::Projectile::Out2NormalMin.Value > flNormal || flNormal > Vars::Aimbot::Projectile::Out2NormalMax.Value) goto breakOutExtra; if (!(iOriginalType & PointTypeEnum::Out)) // don't do the same trace over again { SDK::Trace(vTargetEye, vPoint, MASK_SOLID, &filter, &trace); #ifdef SPLASH_DEBUG5 - s_mTraceCount["Splash rocket (2)"]++; + s_mTraceCount["Splash out 1"]++; #endif bNormal = !trace.m_pEnt || trace.fraction == 1.f; #ifdef SPLASH_DEBUG2 @@ -490,13 +489,21 @@ static inline void TracePoint(Vec3& vPoint, int& iType, Vec3& vTargetEye, Info_t goto breakOutExtra; } - filter.pSkip = trace.m_pEnt->GetClassID() != ETFClassID::CWorld || trace.hitbox ? trace.m_pEnt : nullptr; // make sure we get past entity or prop - SDK::Trace(trace.endpos - (vTargetEye - vPoint).Normalized(), vPoint, MASK_SOLID | CONTENTS_NOSTARTSOLID, &filter, &trace); - filter.pSkip = nullptr; + switch (trace.m_pEnt->GetClassID()) + { // make sure we get past entity or prop + case ETFClassID::CWorld: + if (trace.hitbox) filter.iTeam = trace.hitbox - 1; + filter.pSkip = nullptr; + break; + default: + filter.pSkip = trace.m_pEnt; + } + SDK::Trace(trace.endpos - (vTargetEye - vPoint).Normalized(), vPoint, MASK_SOLID | CONTENTS_NOSKIP, &filter, &trace); + filter.pSkip = nullptr, filter.iTeam = -1; #ifdef SPLASH_DEBUG5 - s_mTraceCount["Splash rocket (2, 2)"]++; + s_mTraceCount["Splash out 2"]++; #endif - bNormal = trace.fraction == 1.f || trace.allsolid || (trace.startpos - trace.endpos).IsZero() || trace.surface.flags & (/*SURF_NODRAW |*/ SURF_SKY); + bNormal = trace.fraction == 1.f || !trace.fraction || trace.fraction == trace.fractionleftsolid || trace.allsolid || trace.surface.flags & (/*SURF_NODRAW |*/ SURF_SKY); #ifdef SPLASH_DEBUG2 drawTrace(!bNormal, Vars::Colors::IndicatorTextBad.Value, trace); #endif @@ -507,7 +514,7 @@ static inline void TracePoint(Vec3& vPoint, int& iType, Vec3& vTargetEye, Info_t { SDK::Trace(trace.endpos + trace.plane.normal, vTargetEye, MASK_SHOT, &filter, &trace); #ifdef SPLASH_DEBUG5 - s_mTraceCount["Splash rocket check (2)"]++; + s_mTraceCount["Splash out rocket check"]++; #endif #ifdef SPLASH_DEBUG2 drawTrace(trace.fraction >= 1.f, Vars::Colors::IndicatorTextMisc.Value, trace); @@ -535,7 +542,7 @@ static inline void TracePoint(Vec3& vPoint, int& iType, Vec3& vTargetEye, Info_t { SDK::Trace(vPoint, vTargetEye, MASK_SHOT, &filter, &trace); #ifdef SPLASH_DEBUG5 - s_mTraceCount["Splash grate check"]++; + s_mTraceCount["Splash in check"]++; #endif bNormal = trace.DidHit(); #ifdef SPLASH_DEBUG2 @@ -546,7 +553,7 @@ static inline void TracePoint(Vec3& vPoint, int& iType, Vec3& vTargetEye, Info_t SDK::TraceHull(vPoint, vTargetEye, tInfo.m_vHull * -1, tInfo.m_vHull, MASK_SOLID, &filter, &trace); #ifdef SPLASH_DEBUG5 - s_mTraceCount["Splash grate"]++; + s_mTraceCount["Splash in"]++; #endif checkPoint(trace, bErase, bNormal); @@ -556,11 +563,11 @@ static inline void TracePoint(Vec3& vPoint, int& iType, Vec3& vTargetEye, Info_t } else // currently experimental, there may be a more efficient way to do this? { - SDK::Trace(vPoint, vTargetEye, MASK_SOLID | CONTENTS_NOSTARTSOLID, &filter, &trace); + SDK::Trace(vPoint, vTargetEye, MASK_SOLID | CONTENTS_NOSKIP, &filter, &trace); #ifdef SPLASH_DEBUG5 - s_mTraceCount["Splash rocket (1)"]++; + s_mTraceCount["Splash in 1"]++; #endif - bNormal = trace.fraction == 1.f || trace.allsolid || trace.surface.flags & SURF_SKY; + bNormal = trace.fraction == 1.f || !trace.fraction || trace.allsolid || trace.surface.flags & SURF_SKY; #ifdef SPLASH_DEBUG2 drawTrace(!bNormal, Vars::Colors::IndicatorMid.Value, trace); #endif @@ -570,11 +577,11 @@ static inline void TracePoint(Vec3& vPoint, int& iType, Vec3& vTargetEye, Info_t goto breakOut; CGameTrace trace2 = {}; - SDK::Trace(trace.endpos - (vPoint - vTargetEye).Normalized(), vTargetEye, MASK_SOLID | CONTENTS_NOSTARTSOLID, &filter, &trace2); + SDK::Trace(trace.endpos - (vPoint - vTargetEye).Normalized(), vTargetEye, MASK_SOLID | CONTENTS_NOSKIP, &filter, &trace2); #ifdef SPLASH_DEBUG5 - s_mTraceCount["Splash rocket (1, 2)"]++; + s_mTraceCount["Splash in 2"]++; #endif - bNormal = trace2.fraction == 1.f || trace.allsolid || (trace2.startpos - trace2.endpos).IsZero() || trace2.surface.flags & (SURF_NODRAW | SURF_SKY); + bNormal = trace2.fraction == 1.f || !trace2.fraction || trace2.fraction == trace2.fractionleftsolid || trace2.allsolid || trace2.surface.flags & (SURF_NODRAW | SURF_SKY); #ifdef SPLASH_DEBUG2 drawTrace(!bNormal, Vars::Colors::IndicatorBad.Value, trace2); #endif @@ -588,7 +595,7 @@ static inline void TracePoint(Vec3& vPoint, int& iType, Vec3& vTargetEye, Info_t { SDK::Trace(trace.endpos + trace.plane.normal, vTargetEye, MASK_SHOT, &filter, &trace); #ifdef SPLASH_DEBUG5 - s_mTraceCount["Splash rocket check (1)"]++; + s_mTraceCount["Splash in rocket check"]++; #endif #ifdef SPLASH_DEBUG2 drawTrace(!bNormal, Vars::Colors::IndicatorMisc.Value, trace); @@ -1098,10 +1105,10 @@ bool CAimbotProjectile::TestAngle(const Vec3& vPoint, const Vec3& vAngles, int i case TF_WEAPON_SHOTGUN_BUILDING_RESCUE: case TF_WEAPON_SYRINGEGUN_MEDIC: case TF_WEAPON_FLAME_BALL: - s_mTraceCount["Setup trace test"]++; + s_mTraceCount["Setup trace"]++; } } - s_mTraceCount["Trace init check test"]++; + s_mTraceCount["Trace init check"]++; #endif m_tProjInfo = {}; if (!F::ProjSim.GetInfo(pLocal, pWeapon, vAngles, m_tProjInfo, iFlags) diff --git a/Amalgam/src/Features/Aimbot/AutoDetonate/AutoDetonate.cpp b/Amalgam/src/Features/Aimbot/AutoDetonate/AutoDetonate.cpp index e8c7fc50..b1c3be5d 100644 --- a/Amalgam/src/Features/Aimbot/AutoDetonate/AutoDetonate.cpp +++ b/Amalgam/src/Features/Aimbot/AutoDetonate/AutoDetonate.cpp @@ -15,7 +15,7 @@ void CAutoDetonate::PredictPlayers(CTFPlayer* pLocal, float flLatency, bool bLoc m_mRestore[pPlayer] = pPlayer->GetAbsOrigin(); - pPlayer->SetAbsOrigin(SDK::PredictOrigin(pPlayer->m_vecOrigin(), pPlayer->m_vecVelocity(), flLatency, true, pPlayer->m_vecMins() + 0.125f, pPlayer->m_vecMaxs() - 0.125f, pPlayer->SolidMask())); + pPlayer->SetAbsOrigin(SDK::PredictOrigin(pPlayer->m_vecOrigin(), pPlayer->m_vecVelocity(), flLatency, true, pPlayer->m_vecMins() + PLAYER_ORIGIN_COMPRESSION, pPlayer->m_vecMaxs() - PLAYER_ORIGIN_COMPRESSION, pPlayer->SolidMask())); } } @@ -82,9 +82,9 @@ Vec3 CAutoDetonate::GetOrigin(CBaseEntity* pProjectile, EntityEnum::EntityEnum i bool CAutoDetonate::CheckEntity(CBaseEntity* pEntity, CTFPlayer* pLocal, CTFWeaponBase* pWeapon, CUserCmd* pCmd, CBaseEntity* pProjectile, float flRadius, Vec3 vOrigin) { - // CEntitySphereQuery actually does a box test so we need to make sure the distance is less than the radius first - Vec3 vPos; pEntity->m_Collision()->CalcNearestPoint(vOrigin, &vPos); - if (vOrigin.DistTo(vPos) > flRadius) + // CEntitySphereQuery actually does a box test so we need to make sure the distance is less than the radius first + Vec3 vPos; pEntity->m_Collision()->CalcNearestPoint(vOrigin, &vPos); + if (vOrigin.DistTo(vPos) > flRadius) return false; if (pEntity != pLocal @@ -92,13 +92,13 @@ bool CAutoDetonate::CheckEntity(CBaseEntity* pEntity, CTFPlayer* pLocal, CTFWeap : !SDK::VisPosWorld(pProjectile, pEntity, vOrigin, pEntity->GetAbsOrigin() + pEntity->As()->m_vecViewOffset(), MASK_SHOT)) return false; - if (pCmd && pWeapon->GetWeaponID() == TF_WEAPON_PIPEBOMBLAUNCHER && pWeapon->As()->GetDetonateType() == TF_DETONATE_MODE_DOT) - { - Vec3 vAngleTo = Math::CalcAngle(pLocal->GetShootPos(), vOrigin); - SDK::FixMovement(pCmd, vAngleTo); - pCmd->viewangles = vAngleTo; - G::PSilentAngles = true; - } + if (pCmd && pWeapon->GetWeaponID() == TF_WEAPON_PIPEBOMBLAUNCHER && pWeapon->As()->GetDetonateType() == TF_DETONATE_MODE_DOT) + { + Vec3 vAngleTo = Math::CalcAngle(pLocal->GetShootPos(), vOrigin); + SDK::FixMovement(pCmd, vAngleTo); + pCmd->viewangles = vAngleTo; + G::PSilentAngles = true; + } return true; } @@ -120,7 +120,7 @@ bool CAutoDetonate::CheckEntities(CTFPlayer* pLocal, CTFWeaponBase* pWeapon, CUs continue; if (CheckEntity(pEntity, pLocal, pWeapon, pCmd, pProjectile, flRadius, vOrigin)) - return true; + return true; } return false; @@ -198,4 +198,4 @@ void CAutoDetonate::Run(CTFPlayer* pLocal, CUserCmd* pCmd) if (Check(pLocal, pCmd, EntityEnum::LocalStickies, Vars::Aimbot::Projectile::AutoDetonateEnum::Stickies) || Check(pLocal, pCmd, EntityEnum::LocalFlares, Vars::Aimbot::Projectile::AutoDetonateEnum::Flares)) pCmd->buttons |= IN_ATTACK2; - } \ No newline at end of file +} \ No newline at end of file diff --git a/Amalgam/src/Features/EnginePrediction/EnginePrediction.cpp b/Amalgam/src/Features/EnginePrediction/EnginePrediction.cpp index 0b2d5df5..b94e8f0a 100644 --- a/Amalgam/src/Features/EnginePrediction/EnginePrediction.cpp +++ b/Amalgam/src/Features/EnginePrediction/EnginePrediction.cpp @@ -16,8 +16,8 @@ void CEnginePrediction::AdjustPlayers(CBaseEntity* pLocal) m_mRestore[pPlayer] = { pPlayer->GetAbsOrigin(), pPlayer->m_vecMins(), pPlayer->m_vecMaxs() }; pPlayer->SetAbsOrigin(pPlayer->m_vecOrigin()); - pPlayer->m_vecMins() += 0.125f; - pPlayer->m_vecMaxs() -= 0.125f; + pPlayer->m_vecMins() += PLAYER_ORIGIN_COMPRESSION; + pPlayer->m_vecMaxs() -= PLAYER_ORIGIN_COMPRESSION; } } void CEnginePrediction::RestorePlayers() diff --git a/Amalgam/src/Features/Misc/Misc.cpp b/Amalgam/src/Features/Misc/Misc.cpp index 7456a594..dd437fb1 100644 --- a/Amalgam/src/Features/Misc/Misc.cpp +++ b/Amalgam/src/Features/Misc/Misc.cpp @@ -488,7 +488,7 @@ int CMisc::AntiBackstab(CTFPlayer* pLocal, CUserCmd* pCmd, bool bSendPacket) { auto TargetIsBehind = [&]() { - const float flCompDist = 0.0625f; + const float flCompDist = PLAYER_ORIGIN_COMPRESSION / 2; const float flSqCompDist = 0.0884f; Vec3 vToTarget = (pLocal->m_vecOrigin() - pTargetPos.first).To2D(); diff --git a/Amalgam/src/Features/Simulation/MovementSimulation/MovementSimulation.cpp b/Amalgam/src/Features/Simulation/MovementSimulation/MovementSimulation.cpp index d7fde5af..2eb95ef0 100644 --- a/Amalgam/src/Features/Simulation/MovementSimulation/MovementSimulation.cpp +++ b/Amalgam/src/Features/Simulation/MovementSimulation/MovementSimulation.cpp @@ -34,6 +34,67 @@ void CMovementSimulation::Reset(MoveStorage& tMoveStorage) } } +static inline void HandleMovement(CTFPlayer* pPlayer, MoveData* pLastRecord, MoveData& tCurRecord, std::deque& vRecords) +{ + bool bLocal = pPlayer->entindex() == I::EngineClient->GetLocalPlayer(); + + if (pLastRecord) + { + /* + if (tRecord.m_iMode != pLastRecord->m_iMode) + { + pLastRecord = nullptr; + vRecords.clear(); + } + else */ + { // does this eat up fps? i can't tell currently + CGameTrace trace = {}; + CTraceFilterWorldAndPropsOnly filter = {}; + SDK::TraceHull(pLastRecord->m_vOrigin, pLastRecord->m_vOrigin + pLastRecord->m_vVelocity * TICK_INTERVAL, pPlayer->m_vecMins() + PLAYER_ORIGIN_COMPRESSION, pPlayer->m_vecMaxs() - PLAYER_ORIGIN_COMPRESSION, pPlayer->SolidMask(), &filter, &trace); + if (trace.DidHit() && trace.plane.normal.z < 0.707f) + { + pLastRecord = nullptr; + vRecords.clear(); + } + } + } + if (!pLastRecord) + return; + + if (pPlayer->InCond(TF_COND_SHIELD_CHARGE)) + { + s_tDummyCmd.forwardmove = 450.f; + s_tDummyCmd.sidemove = 0.f; + SDK::FixMovement(&s_tDummyCmd, bLocal ? F::EnginePrediction.m_vAngles : pPlayer->GetEyeAngles(), {}); + tCurRecord.m_vDirection.x = s_tDummyCmd.forwardmove; + tCurRecord.m_vDirection.y = -s_tDummyCmd.sidemove; + return; + } + + switch (tCurRecord.m_iMode) + { + case MoveEnum::Ground: + { + if (bLocal && Vars::Misc::Movement::Bunnyhop.Value && G::OriginalCmd.buttons & IN_JUMP) + { + float flMaxSpeed = SDK::MaxSpeed(pPlayer, true); + tCurRecord.m_vDirection = tCurRecord.m_vVelocity.Normalized2D() * flMaxSpeed; + } + break; + } + case MoveEnum::Air: + { + float flMaxSpeed = SDK::MaxSpeed(pPlayer, true); + tCurRecord.m_vDirection = tCurRecord.m_vVelocity.Normalized2D() * flMaxSpeed; + break; + } + case MoveEnum::Swim: + { + tCurRecord.m_vDirection *= 2; + } + } +} + void CMovementSimulation::Store() { for (auto pEntity : H::Entities.GetGroup(EntityEnum::PlayerAll)) @@ -58,7 +119,7 @@ void CMovementSimulation::Store() vRecords.emplace_front( vDirection, pPlayer->m_flSimulationTime(), - pPlayer->IsSwimming() ? 2 : pPlayer->IsOnGround() ? 0 : 1, + pPlayer->IsSwimming() ? MoveEnum::Swim : pPlayer->IsOnGround() ? MoveEnum::Ground : MoveEnum::Air, vVelocity, vOrigin ); @@ -66,45 +127,7 @@ void CMovementSimulation::Store() if (vRecords.size() > 66) vRecords.pop_back(); - float flMaxSpeed = SDK::MaxSpeed(pPlayer); - if (pLastRecord) - { - /* - if (tRecord.m_iMode != pLastRecord->m_iMode) - vRecords.clear(); - else // does this eat up fps? i can't tell currently - */ - { - CGameTrace trace = {}; - CTraceFilterWorldAndPropsOnly filter = {}; - SDK::TraceHull(pLastRecord->m_vOrigin, pLastRecord->m_vOrigin + pLastRecord->m_vVelocity * TICK_INTERVAL, pPlayer->m_vecMins() + 0.125f, pPlayer->m_vecMaxs() - 0.125f, pPlayer->SolidMask(), &filter, &trace); - if (trace.DidHit() && trace.plane.normal.z < 0.707f) - vRecords.clear(); - } - } - if (pPlayer->InCond(TF_COND_SHIELD_CHARGE)) - { - s_tDummyCmd.forwardmove = 450.f; - s_tDummyCmd.sidemove = 0.f; - SDK::FixMovement(&s_tDummyCmd, bLocal ? F::EnginePrediction.m_vAngles : pPlayer->GetEyeAngles(), {}); - tCurRecord.m_vDirection.x = s_tDummyCmd.forwardmove; - tCurRecord.m_vDirection.y = -s_tDummyCmd.sidemove; - } - else - { - switch (tCurRecord.m_iMode) - { - case 0: - if (bLocal && Vars::Misc::Movement::Bunnyhop.Value && G::OriginalCmd.buttons & IN_JUMP) - tCurRecord.m_vDirection = vVelocity.Normalized2D() * flMaxSpeed; - break; - case 1: - tCurRecord.m_vDirection = vVelocity.Normalized2D() * flMaxSpeed; - break; - case 2: - tCurRecord.m_vDirection *= 2; - } - } + HandleMovement(pPlayer, pLastRecord, tCurRecord, vRecords); } for (auto pEntity : H::Entities.GetGroup(EntityEnum::PlayerAll)) @@ -165,7 +188,7 @@ bool CMovementSimulation::Initialize(CBaseEntity* pEntity, MoveStorage& tMoveSto pPlayer->m_bInDuckJump() = false; } - if (pPlayer != H::Entities.GetLocal()) + if (pPlayer->entindex() != I::EngineClient->GetLocalPlayer()) { pPlayer->m_vecBaseVelocity() = Vec3(); // residual basevelocity causes issues if (pPlayer->IsOnGround()) @@ -341,7 +364,7 @@ static inline void VisualizeRecords(MoveData& tRecord1, MoveData& tRecord2, Colo { Vec3 vVelocity = tRecord1.m_vVelocity.Normalized2D() * 5; vVelocity = Math::RotatePoint(vVelocity, {}, { 0, flYaw > 0 ? 90.f : -90.f, 0 }); - if (Vars::Aimbot::Projectile::MovesimFrictionFlags.Value & Vars::Aimbot::Projectile::MovesimFrictionFlagsEnum::CalculateIncrease && tRecord1.m_iMode == 1) + if (Vars::Aimbot::Projectile::MovesimFrictionFlags.Value & Vars::Aimbot::Projectile::MovesimFrictionFlagsEnum::CalculateIncrease && tRecord1.m_iMode == MoveEnum::Air) vVelocity /= GetFrictionScale(tRecord1.m_vVelocity.Length2D(), flYaw, tRecord1.m_vVelocity.z + GetGravity() * TICK_INTERVAL, 0.f, 56.f); G::LineStorage.emplace_back(std::pair(tRecord1.m_vOrigin, tRecord1.m_vOrigin + vVelocity), I::GlobalVars->curtime + 5.f, tColor); } @@ -355,7 +378,7 @@ static inline bool GetYawDifference(MoveData& tRecord1, MoveData& tRecord2, bool const int iTicks = std::max(TIME_TO_TICKS(flTime1 - flTime2), 1); *pYaw = Math::NormalizeAngle(flYaw1 - flYaw2); - if (flMaxSpeed && tRecord1.m_iMode != 1) + if (flMaxSpeed && tRecord1.m_iMode != MoveEnum::Air) *pYaw *= std::clamp(tRecord1.m_vVelocity.Length2D() / flMaxSpeed, 0.f, 1.f); if (Vars::Aimbot::Projectile::MovesimFrictionFlags.Value & Vars::Aimbot::Projectile::MovesimFrictionFlagsEnum::CalculateIncrease && tRecord1.m_iMode == 1) *pYaw /= GetFrictionScale(tRecord1.m_vVelocity.Length2D(), *pYaw, tRecord1.m_vVelocity.z + GetGravity() * TICK_INTERVAL, 0.f, 56.f); @@ -416,7 +439,7 @@ void CMovementSimulation::GetAverageYaw(MoveStorage& tMoveStorage, int iSamples) continue; } - bGround = tRecord1.m_iMode != 1; + bGround = tRecord1.m_iMode != MoveEnum::Air; 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; @@ -531,10 +554,10 @@ void CMovementSimulation::SetBounds(CTFPlayer* pPlayer) { if (auto pViewVectors = pGameRules->GetViewVectors()) { - pViewVectors->m_vHullMin = Vec3(-24, -24, 0) + 0.125f; - pViewVectors->m_vHullMax = Vec3(24, 24, 82) - 0.125f; - pViewVectors->m_vDuckHullMin = Vec3(-24, -24, 0) + 0.125f; - pViewVectors->m_vDuckHullMax = Vec3(24, 24, 62) - 0.125f; + pViewVectors->m_vHullMin = Vec3(-24, -24, 0) + PLAYER_ORIGIN_COMPRESSION; + pViewVectors->m_vHullMax = Vec3(24, 24, 82) - PLAYER_ORIGIN_COMPRESSION; + pViewVectors->m_vDuckHullMin = Vec3(-24, -24, 0) + PLAYER_ORIGIN_COMPRESSION; + pViewVectors->m_vDuckHullMax = Vec3(24, 24, 62) - PLAYER_ORIGIN_COMPRESSION; } } } diff --git a/Amalgam/src/Features/Simulation/MovementSimulation/MovementSimulation.h b/Amalgam/src/Features/Simulation/MovementSimulation/MovementSimulation.h index 8848a078..33777876 100644 --- a/Amalgam/src/Features/Simulation/MovementSimulation/MovementSimulation.h +++ b/Amalgam/src/Features/Simulation/MovementSimulation/MovementSimulation.h @@ -2,6 +2,8 @@ #include "../../../SDK/SDK.h" #include +Enum(Move, Ground, Air, Swim) + struct MoveStorage { CTFPlayer* m_pPlayer = nullptr; diff --git a/Amalgam/src/Hooks/CBaseEntity_SetAbsVelocity.cpp b/Amalgam/src/Hooks/CBaseEntity_SetAbsVelocity.cpp index 6599fc8b..472e3efd 100644 --- a/Amalgam/src/Hooks/CBaseEntity_SetAbsVelocity.cpp +++ b/Amalgam/src/Hooks/CBaseEntity_SetAbsVelocity.cpp @@ -20,7 +20,7 @@ public: flGravityCorrection = (powf(flDeltaTicks, 2.f) - flDeltaTicks) / 2.f * sv_gravity->GetFloat() * powf(TICK_INTERVAL, 2); } float flDeltaValue = m_flNewAxisValue - m_flOldAxisValue; - float flTickVelocity = flDeltaValue + (flDeltaValue ? 0.0625f * sign(m_flNewAxisValue) : 0.f) - flGravityCorrection; + float flTickVelocity = flDeltaValue + (flDeltaValue ? PLAYER_ORIGIN_COMPRESSION / 2 * sign(m_flNewAxisValue) : 0.f) - flGravityCorrection; return flTickVelocity / TICKS_TO_TIME(iDeltaTicks); } }; @@ -99,10 +99,10 @@ MAKE_HOOK(CBaseEntity_SetAbsVelocity, S::CBaseEntity_SetAbsVelocity(), void, if (i == 2 && bGrounded) 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; + float flOldPos1 = tOldRecord.m_vecOrigin[i], flOldPos2 = flOldPos1 + PLAYER_ORIGIN_COMPRESSION * sign(flOldPos1); + float flNewPos1 = tNewRecord.m_vecOrigin[i], flNewPos2 = flNewPos1 + PLAYER_ORIGIN_COMPRESSION * sign(flNewPos1); + if (!flOldPos1) flOldPos1 = -PLAYER_ORIGIN_COMPRESSION, flOldPos2 = PLAYER_ORIGIN_COMPRESSION; + if (!flNewPos1) flNewPos1 = -PLAYER_ORIGIN_COMPRESSION, flNewPos2 = PLAYER_ORIGIN_COMPRESSION; FloatRange_t flVelocityRange; { diff --git a/Amalgam/src/Hooks/IEngineTrace_SetTraceEntity.cpp b/Amalgam/src/Hooks/IEngineTrace_SetTraceEntity.cpp deleted file mode 100644 index 08a9073a..00000000 --- a/Amalgam/src/Hooks/IEngineTrace_SetTraceEntity.cpp +++ /dev/null @@ -1,125 +0,0 @@ -#include "../SDK/SDK.h" - -MAKE_SIGNATURE(CM_BoxTrace, "engine.dll", "48 89 5C 24 ? 48 89 6C 24 ? 48 89 74 24 ? 48 89 7C 24 ? 41 56 48 83 EC ? 45 0F B6 F1", 0x0); -MAKE_SIGNATURE(CM_TraceToLeaf_True, "engine.dll", "48 8B C4 55 57 48 81 EC ? ? ? ? 48 8B B9 ? ? ? ? 48 8B E9 44 0F 29 40 ? 44 0F 28 C3 44 0F 29 48 ? 44 0F 28 CA 85 D2 0F 88 ? ? ? ? 3B 97 ? ? ? ? 0F 8D ? ? ? ? 48 63 89 ? ? ? ? 48 89 70 ? 4C 89 60 ? 4C 89 68 ? 44 8B AC 8D ? ? ? ? 4C 89 70 ? 45 33 F6 4C 89 78 ? 0F 29 78 ? 0F 57 FF 4C 63 FA 49 C1 E7 ? 4C 03 BF ? ? ? ? 48 89 58 ? 48 8B C1 48 C1 E0 ? 41 0F B7 77 ? 41 0F B7 57 ? 4C 8B A4 28 ? ? ? ? 03 D6 3B F2 0F 83 ? ? ? ? 8B C2 8B DE 48 89 84 24 ? ? ? ? 41 BA ? ? ? ? 48 85 DB 0F 88 ? ? ? ? 3B B7 ? ? ? ? 0F 8D ? ? ? ? 48 8B 87 ? ? ? ? 0F B7 0C 58 3B 8F ? ? ? ? 0F 8D ? ? ? ? 48 8B 87 ? ? ? ? 4C 8D 1C C8 45 39 2C 8C 0F 84 ? ? ? ? 45 89 2C 8C 41 8B 03 8B 8D ? ? ? ? 23 C1 0F 84 ? ? ? ? 3D ? ? ? ? 0F 85 ? ? ? ? 0F BA E1 ? 0F 83 ? ? ? ? 41 0F B7 4B ? 41 0F B7 43 ? 4C 8B 8D ? ? ? ? 66 41 3B CA 75 ? 41 3B 81 ? ? ? ? 0F 8D ? ? ? ? 48 8D 14 40 4D 8B C6 48 C1 E2 ? 48 83 C2 ? 49 03 91 ? ? ? ? 0F B7 0A 66 41 3B CA 75 ? 48 8D 05 ? ? ? ? EB ? 41 3B 89 ? ? ? ? 0F 8D ? ? ? ? 48 8B C1 48 C1 E0 ? 49 03 81 ? ? ? ? F6 40 ? ? 0F 85 ? ? ? ? 49 FF C0 48 83 C2 ? 49 83 F8 ? 7C ? EB ? 41 3B 41 ? 0F 8D ? ? ? ? 48 8B D0 45 8B C6 48 C1 E2 ? 44 8B D1 48 83 C2 ? 85 C9 74 ? 49 03 51 ? 66 90 0F B7 0A B8 ? ? ? ? 66 3B C8 75 ? 48 8D 05 ? ? ? ? EB ? 41 3B 89 ? ? ? ? 0F 8D ? ? ? ? 48 8B C1 48 C1 E0 ? 49 03 81 ? ? ? ? F6 40 ? ? 75 ? 41 FF C0 48 83 C2 ? 45 3B C2 7C ? 49 8B D3 48 8B CD E8 ? ? ? ? 0F 2E BD ? ? ? ? 0F 84 ? ? ? ? 41 BA ? ? ? ? FF C6 48 FF C3 48 3B 9C 24 ? ? ? ? 0F 8C ? ? ? ? 44 38 B5 ? ? ? ? 0F 85 ? ? ? ? 41 0F B7 57 ? 66 85 D2 0F 84 ? ? ? ? 48 63 8D ? ? ? ? 48 8B C1 0F 29 74 24", 0x0); -MAKE_SIGNATURE(CM_TraceToLeaf_False, "engine.dll", "48 8B C4 55 57 48 81 EC ? ? ? ? 48 8B B9 ? ? ? ? 48 8B E9 44 0F 29 40 ? 44 0F 28 C3 44 0F 29 48 ? 44 0F 28 CA 85 D2 0F 88 ? ? ? ? 3B 97 ? ? ? ? 0F 8D ? ? ? ? 48 63 89 ? ? ? ? 48 89 70 ? 4C 89 60 ? 4C 89 68 ? 44 8B AC 8D ? ? ? ? 4C 89 70 ? 45 33 F6 4C 89 78 ? 0F 29 78 ? 0F 57 FF 4C 63 FA 49 C1 E7 ? 4C 03 BF ? ? ? ? 48 89 58 ? 48 8B C1 48 C1 E0 ? 41 0F B7 77 ? 41 0F B7 57 ? 4C 8B A4 28 ? ? ? ? 03 D6 3B F2 0F 83 ? ? ? ? 8B C2 8B DE 48 89 84 24 ? ? ? ? 41 BA ? ? ? ? 48 85 DB 0F 88 ? ? ? ? 3B B7 ? ? ? ? 0F 8D ? ? ? ? 48 8B 87 ? ? ? ? 0F B7 0C 58 3B 8F ? ? ? ? 0F 8D ? ? ? ? 48 8B 87 ? ? ? ? 4C 8D 1C C8 45 39 2C 8C 0F 84 ? ? ? ? 45 89 2C 8C 41 8B 03 8B 8D ? ? ? ? 23 C1 0F 84 ? ? ? ? 3D ? ? ? ? 0F 85 ? ? ? ? 0F BA E1 ? 0F 83 ? ? ? ? 41 0F B7 4B ? 41 0F B7 43 ? 4C 8B 8D ? ? ? ? 66 41 3B CA 75 ? 41 3B 81 ? ? ? ? 0F 8D ? ? ? ? 48 8D 14 40 4D 8B C6 48 C1 E2 ? 48 83 C2 ? 49 03 91 ? ? ? ? 0F B7 0A 66 41 3B CA 75 ? 48 8D 05 ? ? ? ? EB ? 41 3B 89 ? ? ? ? 0F 8D ? ? ? ? 48 8B C1 48 C1 E0 ? 49 03 81 ? ? ? ? F6 40 ? ? 0F 85 ? ? ? ? 49 FF C0 48 83 C2 ? 49 83 F8 ? 7C ? EB ? 41 3B 41 ? 0F 8D ? ? ? ? 48 8B D0 45 8B C6 48 C1 E2 ? 44 8B D1 48 83 C2 ? 85 C9 74 ? 49 03 51 ? 66 90 0F B7 0A B8 ? ? ? ? 66 3B C8 75 ? 48 8D 05 ? ? ? ? EB ? 41 3B 89 ? ? ? ? 0F 8D ? ? ? ? 48 8B C1 48 C1 E0 ? 49 03 81 ? ? ? ? F6 40 ? ? 75 ? 41 FF C0 48 83 C2 ? 45 3B C2 7C ? 49 8B D3 48 8B CD E8 ? ? ? ? 0F 2E BD ? ? ? ? 0F 84 ? ? ? ? 41 BA ? ? ? ? FF C6 48 FF C3 48 3B 9C 24 ? ? ? ? 0F 8C ? ? ? ? 44 38 B5 ? ? ? ? 0F 85 ? ? ? ? 41 0F B7 57 ? 66 85 D2 0F 84 ? ? ? ? 48 63 8D ? ? ? ? 48 8B C1 0F 29 B4 24", 0x0); -MAKE_SIGNATURE(CM_ClipBoxToBrush_True, "engine.dll", "48 89 5C 24 ? 57 48 81 EC ? ? ? ? 44 0F B7 42", 0x0); -MAKE_SIGNATURE(CM_ClipBoxToBrush_False, "engine.dll", "48 8B C4 48 89 58 ? 57 48 81 EC ? ? ? ? 44 0F B7 42", 0x0); -MAKE_SIGNATURE(IEngineTrace_TraceRay_SetTraceEntity_Call, "engine.dll", "40 38 7E ? 0F 85", 0x0); - -#define MAX_CHECK_COUNT_DEPTH 2 -typedef uint32 TraceCounter_t; -typedef CUtlVector CTraceCounterVec; - -struct TraceInfo_t -{ - Vector m_start; - Vector m_end; - Vector m_mins; - Vector m_maxs; - Vector m_extents; - Vector m_delta; - Vector m_invDelta; - trace_t m_trace; - trace_t m_stabTrace; - int m_contents; - bool m_ispoint; - bool m_isswept; - void* m_pBSPData; - Vector m_DispStabDir; - int m_bDispHit; - bool m_bCheckPrimary; - int m_nCheckDepth; - TraceCounter_t m_Count[MAX_CHECK_COUNT_DEPTH]; - CTraceCounterVec m_BrushCounters[MAX_CHECK_COUNT_DEPTH]; - CTraceCounterVec m_DispCounters[MAX_CHECK_COUNT_DEPTH]; -}; - -static int s_iOriginalMask = false; -static bool s_bOriginalStartSolid = false; - -MAKE_HOOK(IEngineTrace_SetTraceEntity, U::Memory.GetVirtual(I::EngineTrace, 20), void, - void* rcx, ICollideable* pCollideable, trace_t* pTrace) -{ - DEBUG_RETURN(IEngineTrace_SetTraceEntity, rcx, pCollideable, pTrace); - - const auto dwRetAddr = uintptr_t(_ReturnAddress()); - const auto dwDesired = S::IEngineTrace_TraceRay_SetTraceEntity_Call(); - - CALL_ORIGINAL(rcx, pCollideable, pTrace); - - if (dwRetAddr && dwDesired && s_iOriginalMask & CONTENTS_NOSTARTSOLID) - pTrace->startsolid = false; -} - -MAKE_HOOK(CM_BoxTrace, S::CM_BoxTrace(), void, - const Ray_t& ray, int headnode, int brushmask, bool computeEndpt, trace_t& tr) -{ - DEBUG_RETURN(CM_BoxTrace, ray, headnode, brushmask, computeEndpt, tr); - - CALL_ORIGINAL(ray, headnode, brushmask, computeEndpt, tr); - - s_iOriginalMask = brushmask; -} - -MAKE_HOOK(CM_TraceToLeaf_True, S::CM_TraceToLeaf_True(), void, - TraceInfo_t* pTraceInfo, int ndxLeaf, float startFrac, float endFrac) -{ - DEBUG_RETURN(CM_TraceToLeaf_True, pTraceInfo, ndxLeaf, startFrac, endFrac); - - if (pTraceInfo->m_contents & CONTENTS_NOSTARTSOLID) - { - s_bOriginalStartSolid = pTraceInfo->m_trace.startsolid; - pTraceInfo->m_trace.startsolid = false; - CALL_ORIGINAL(pTraceInfo, ndxLeaf, startFrac, endFrac); - pTraceInfo->m_trace.startsolid = s_bOriginalStartSolid; - return; - } - - CALL_ORIGINAL(pTraceInfo, ndxLeaf, startFrac, endFrac); -} - -MAKE_HOOK(CM_TraceToLeaf_False, S::CM_TraceToLeaf_False(), void, - TraceInfo_t* pTraceInfo, int ndxLeaf, float startFrac, float endFrac) -{ - DEBUG_RETURN(CM_TraceToLeaf_False, pTraceInfo, ndxLeaf, startFrac, endFrac); - - if (pTraceInfo->m_contents & CONTENTS_NOSTARTSOLID) - { - s_bOriginalStartSolid = pTraceInfo->m_trace.startsolid; - pTraceInfo->m_trace.startsolid = false; - CALL_ORIGINAL(pTraceInfo, ndxLeaf, startFrac, endFrac); - pTraceInfo->m_trace.startsolid = s_bOriginalStartSolid; - return; - } - - CALL_ORIGINAL(pTraceInfo, ndxLeaf, startFrac, endFrac); -} - -MAKE_HOOK(CM_ClipBoxToBrush_True, S::CM_ClipBoxToBrush_True(), void, - TraceInfo_t* pTraceInfo, void* brush) -{ - DEBUG_RETURN(CM_ClipBoxToBrush_True, pTraceInfo, brush); - - CALL_ORIGINAL(pTraceInfo, brush); - - if (pTraceInfo->m_contents & CONTENTS_NOSTARTSOLID && pTraceInfo->m_trace.startsolid) - { - s_bOriginalStartSolid = true; - pTraceInfo->m_trace.startsolid = false; - } -} - -MAKE_HOOK(CM_ClipBoxToBrush_False, S::CM_ClipBoxToBrush_False(), void, - TraceInfo_t* pTraceInfo, void* brush) -{ - DEBUG_RETURN(CM_ClipBoxToBrush_False, pTraceInfo, brush); - - CALL_ORIGINAL(pTraceInfo, brush); - - if (pTraceInfo->m_contents & CONTENTS_NOSTARTSOLID && pTraceInfo->m_trace.startsolid) - { - s_bOriginalStartSolid = true; - pTraceInfo->m_trace.startsolid = false; - } -} \ No newline at end of file diff --git a/Amalgam/src/Hooks/IEngineTrace_TraceRay.cpp b/Amalgam/src/Hooks/IEngineTrace_TraceRay.cpp index 5539621b..d813220d 100644 --- a/Amalgam/src/Hooks/IEngineTrace_TraceRay.cpp +++ b/Amalgam/src/Hooks/IEngineTrace_TraceRay.cpp @@ -1,12 +1,52 @@ #include "../SDK/SDK.h" -#ifdef DEBUG_TRACES +#include + +MAKE_SIGNATURE(CM_BoxTrace, "engine.dll", "48 89 5C 24 ? 48 89 6C 24 ? 48 89 74 24 ? 48 89 7C 24 ? 41 56 48 83 EC ? 45 0F B6 F1", 0x0); +MAKE_SIGNATURE(CM_ClipBoxToBrush_True, "engine.dll", "48 89 5C 24 ? 57 48 81 EC ? ? ? ? 44 0F B7 42", 0x0); +MAKE_SIGNATURE(CM_ClipBoxToBrush_False, "engine.dll", "48 8B C4 48 89 58 ? 57 48 81 EC ? ? ? ? 44 0F B7 42", 0x0); +MAKE_SIGNATURE(CEngineTrace_ClipTraceToTrace, "engine.dll", "48 89 5C 24 ? 57 48 83 EC ? 80 7A ? ? 49 8B D8", 0x0); + +#define MAX_CHECK_COUNT_DEPTH 2 +typedef uint32 TraceCounter_t; +typedef CUtlVector CTraceCounterVec; + +struct TraceInfo_t +{ + Vector m_start; + Vector m_end; + Vector m_mins; + Vector m_maxs; + Vector m_extents; + Vector m_delta; + Vector m_invDelta; + trace_t m_trace; + trace_t m_stabTrace; + int m_contents; + bool m_ispoint; + bool m_isswept; + void* m_pBSPData; + Vector m_DispStabDir; + int m_bDispHit; + bool m_bCheckPrimary; + int m_nCheckDepth; + TraceCounter_t m_Count[MAX_CHECK_COUNT_DEPTH]; + CTraceCounterVec m_BrushCounters[MAX_CHECK_COUNT_DEPTH]; + CTraceCounterVec m_DispCounters[MAX_CHECK_COUNT_DEPTH]; +}; + +static bool s_bNoSkip = false; +static std::optional s_bStartSolid = std::nullopt; + MAKE_HOOK(IEngineTrace_TraceRay, U::Memory.GetVirtual(I::EngineTrace, 4), void, void* rcx, const Ray_t& ray, unsigned int fMask, ITraceFilter* pTraceFilter, trace_t* pTrace) { DEBUG_RETURN(IEngineTrace_TraceRay, rcx, ray, fMask, pTraceFilter, pTrace); + s_bNoSkip = fMask & CONTENTS_NOSKIP; + CALL_ORIGINAL(rcx, ray, fMask, pTraceFilter, pTrace); +#ifdef DEBUG_TRACES if (Vars::Debug::VisualizeTraces.Value) { Vec3 vStart = ray.m_Start + ray.m_StartOffset; @@ -18,5 +58,70 @@ MAKE_HOOK(IEngineTrace_TraceRay, U::Memory.GetVirtual(I::EngineTrace, 4), void, G::BoxStorage.emplace_back(vEnd - ray.m_StartOffset, ray.m_Extents * -1, ray.m_Extents, Vec3(), I::GlobalVars->curtime + 0.015f, Color_t(0, 0, 255), Color_t(0, 0, 0, 0), bool(GetAsyncKeyState(VK_MENU) & 0x8000)); } } +#endif + + if (s_bStartSolid) + pTrace->startsolid = s_bStartSolid.value(), s_bStartSolid = std::nullopt; + + s_bNoSkip = false; } -#endif \ No newline at end of file + +MAKE_HOOK(CM_BoxTrace, S::CM_BoxTrace(), void, + const Ray_t& ray, int headnode, int brushmask, bool computeEndpt, trace_t& tr) +{ + CALL_ORIGINAL(ray, headnode, brushmask, computeEndpt, tr); + + if (s_bStartSolid) + tr.startsolid = s_bStartSolid.value(), s_bStartSolid = std::nullopt; + if (s_bNoSkip) + s_bStartSolid = tr.startsolid, tr.startsolid = false; +} + +MAKE_HOOK(CM_ClipBoxToBrush_True, S::CM_ClipBoxToBrush_True(), void, + TraceInfo_t* pTraceInfo, void* brush) +{ + DEBUG_RETURN(CM_ClipBoxToBrush_True, pTraceInfo, brush); + + if (s_bStartSolid) + pTraceInfo->m_trace.startsolid = s_bStartSolid.value(), s_bStartSolid = std::nullopt; + + CALL_ORIGINAL(pTraceInfo, brush); + + if (s_bNoSkip) + { + s_bStartSolid = pTraceInfo->m_trace.startsolid, pTraceInfo->m_trace.startsolid = false; + if (!s_bStartSolid.value() && !pTraceInfo->m_trace.fractionleftsolid && pTraceInfo->m_trace.fraction != 1.f) + pTraceInfo->m_trace.fractionleftsolid = pTraceInfo->m_trace.fraction - FLT_EPSILON; + } +} + +MAKE_HOOK(CM_ClipBoxToBrush_False, S::CM_ClipBoxToBrush_False(), void, + TraceInfo_t* pTraceInfo, void* brush) +{ + DEBUG_RETURN(CM_ClipBoxToBrush_False, pTraceInfo, brush); + + if (s_bStartSolid) + pTraceInfo->m_trace.startsolid = s_bStartSolid.value(), s_bStartSolid = std::nullopt; + + CALL_ORIGINAL(pTraceInfo, brush); + + if (s_bNoSkip) + { + s_bStartSolid = pTraceInfo->m_trace.startsolid, pTraceInfo->m_trace.startsolid = false; + if (!s_bStartSolid.value() && !pTraceInfo->m_trace.fractionleftsolid && pTraceInfo->m_trace.fraction != 1.f) + pTraceInfo->m_trace.fractionleftsolid = pTraceInfo->m_trace.fraction - FLT_EPSILON; + } +} + +MAKE_HOOK(CEngineTrace_ClipTraceToTrace, S::CEngineTrace_ClipTraceToTrace(), bool, + void* rcx, trace_t& clipTrace, trace_t* pFinalTrace) +{ + DEBUG_RETURN(CEngineTrace_ClipTraceToTrace, rcx, clipTrace, pFinalTrace); + + if (s_bStartSolid) + pFinalTrace->startsolid = s_bStartSolid.value(), s_bStartSolid = std::nullopt; + if (s_bNoSkip && (!clipTrace.fraction || clipTrace.fraction < pFinalTrace->fractionleftsolid)) + return false; + + return CALL_ORIGINAL(rcx, clipTrace, pFinalTrace); +} \ No newline at end of file diff --git a/Amalgam/src/SDK/Definitions/Main/CBaseEntity.cpp b/Amalgam/src/SDK/Definitions/Main/CBaseEntity.cpp index 7046bb78..086aba3b 100644 --- a/Amalgam/src/SDK/Definitions/Main/CBaseEntity.cpp +++ b/Amalgam/src/SDK/Definitions/Main/CBaseEntity.cpp @@ -7,6 +7,11 @@ int CBaseEntity::GetIntermediateDataSize() return std::max(GetPredDescMap()->packed_size, 4); } +Vec3 CBaseEntity::GetOrigin(float flCompression) +{ + return m_vecOrigin() + Vec3(flCompression / 2 * sign(m_vecOrigin().x), flCompression / 2 * sign(m_vecOrigin().y), flCompression / 2 * sign(m_vecOrigin().z)); +} + Vec3 CBaseEntity::GetSize() { return m_vecMaxs() - m_vecMins(); diff --git a/Amalgam/src/SDK/Definitions/Main/CBaseEntity.h b/Amalgam/src/SDK/Definitions/Main/CBaseEntity.h index 79018d09..ae5d3f62 100644 --- a/Amalgam/src/SDK/Definitions/Main/CBaseEntity.h +++ b/Amalgam/src/SDK/Definitions/Main/CBaseEntity.h @@ -291,6 +291,7 @@ public: } int GetIntermediateDataSize(); + Vec3 GetOrigin(float flCompression); Vec3 GetSize(); Vec3 GetOffset(); Vec3 GetCenter(); diff --git a/Amalgam/src/SDK/Definitions/Main/CTFPlayer.h b/Amalgam/src/SDK/Definitions/Main/CTFPlayer.h index 3f569425..459bcb08 100644 --- a/Amalgam/src/SDK/Definitions/Main/CTFPlayer.h +++ b/Amalgam/src/SDK/Definitions/Main/CTFPlayer.h @@ -2,6 +2,8 @@ #include "CBasePlayer.h" #include "CMultiPlayerAnimState.h" +#define PLAYER_ORIGIN_COMPRESSION 0.125f + MAKE_SIGNATURE(CTFPlayer_IsPlayerOnSteamFriendsList, "client.dll", "40 57 48 81 EC ? ? ? ? 48 8B FA E8", 0x0); MAKE_SIGNATURE(TeamFortress_CalculateMaxSpeed, "client.dll", "88 54 24 ? 53 55", 0x0); MAKE_SIGNATURE(CTFPlayer_UpdateClientSideAnimation, "client.dll", "48 89 5C 24 ? 57 48 83 EC ? 48 8B D9 E8 ? ? ? ? 48 8B F8 48 85 C0 74 ? 48 8B 00 48 8B CF FF 90 ? ? ? ? 84 C0 75 ? 33 FF 48 3B DF", 0x0); diff --git a/Amalgam/src/SDK/Definitions/Misc/BSPFlags.h b/Amalgam/src/SDK/Definitions/Misc/BSPFlags.h index fc8403f7..3199dff9 100644 --- a/Amalgam/src/SDK/Definitions/Misc/BSPFlags.h +++ b/Amalgam/src/SDK/Definitions/Misc/BSPFlags.h @@ -55,7 +55,7 @@ #define CONTENTS_TRANSLUCENT 0x10000000 // auto set if any surface has trans #define CONTENTS_LADDER 0x20000000 #define CONTENTS_HITBOX 0x40000000 // use accurate hitboxes on trace -#define CONTENTS_NOSTARTSOLID 0x80000000 // don't skip entities or displacements when starting in solid +#define CONTENTS_NOSKIP 0x80000000 // don't skip entities or displacements when starting in solid // NOTE: These are stored in a short in the engine now. Don't use more than 16 bits diff --git a/Amalgam/src/SDK/Helpers/TraceFilters/TraceFilters.cpp b/Amalgam/src/SDK/Helpers/TraceFilters/TraceFilters.cpp index 46415000..d3be477b 100644 --- a/Amalgam/src/SDK/Helpers/TraceFilters/TraceFilters.cpp +++ b/Amalgam/src/SDK/Helpers/TraceFilters/TraceFilters.cpp @@ -114,7 +114,7 @@ bool CTraceFilterWorldAndPropsOnly::ShouldHitEntity(IHandleEntity* pServerEntity if (!pServerEntity || pServerEntity == pSkip) return false; if (pServerEntity->GetRefEHandle().GetSerialNumber() == (1 << 15)) - return I::ClientEntityList->GetClientEntity(0) != pSkip; + return pServerEntity->GetRefEHandle().GetEntryIndex() != iTeam; // just use team variable since cliententitylist can give us nullptrs for some props for whatever reason auto pEntity = reinterpret_cast(pServerEntity); if (iTeam == -1) iTeam = pSkip ? pSkip->m_iTeamNum() : 0; diff --git a/Amalgam/src/SDK/Vars.h b/Amalgam/src/SDK/Vars.h index c8081eb4..a48d2919 100644 --- a/Amalgam/src/SDK/Vars.h +++ b/Amalgam/src/SDK/Vars.h @@ -375,7 +375,8 @@ NAMESPACE_BEGIN(Vars) VA_LIST("Regular", "Special light", "Special heavy"), Regular, SpecialLight, SpecialHeavy); CVar(SplashGrates, "Splash grates", true, NOSAVE | DEBUGVAR); - CVar(Out2NormalCheck, "Out2 normal check", 0.7f, NOSAVE | DEBUGVAR | SLIDER_CLAMP | SLIDER_PRECISION, -1.f, 1.f, 0.1f); + CVar(Out2NormalMin, "Out2 normal min", -0.7f, NOSAVE | DEBUGVAR | SLIDER_CLAMP | SLIDER_PRECISION, -1.f, 1.f, 0.1f); + CVar(Out2NormalMax, "Out2 normal max", 0.7f, NOSAVE | DEBUGVAR | SLIDER_CLAMP | SLIDER_PRECISION, -1.f, 1.f, 0.1f); CVar(DeltaCount, "Delta count", 5, NOSAVE | DEBUGVAR, 1, 5); CVarEnum(DeltaMode, "Delta mode", 0, NOSAVE | DEBUGVAR, nullptr,