mirror of
https://github.com/rei-2/Amalgam
synced 2026-10-10 04:43:09 +08:00
fix some issues with dormant prediction
prioritize points not in water/higher points in water for physics weapons
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
enum BOUNDS_HITBOXES
|
||||
{
|
||||
BOUNDS_HEAD, BOUNDS_BODY, BOUNDS_FEET
|
||||
BOUNDS_HEAD, BOUNDS_BODY, BOUNDS_FEET, BOUNDS_COUNT
|
||||
};
|
||||
|
||||
Enum(Target, Unknown, Player, Sentry, Dispenser, Teleporter, Sticky, NPC, Bomb)
|
||||
|
||||
@@ -1466,6 +1466,14 @@ bool CAimbotProjectile::HandleDirect(DirectHistory_t& mDirectHistory)
|
||||
uint8_t iType = it->first;
|
||||
auto& vDirectHistory = it->second;
|
||||
|
||||
if (F::ProjSim.m_bPhysics)
|
||||
{
|
||||
for (auto& tHistory : vDirectHistory)
|
||||
{
|
||||
if (I::EngineTrace->GetPointContents(tHistory.m_vPoint) & CONTENTS_WATER)
|
||||
tHistory.m_iPriority = COORD_EXTENT - tHistory.m_vPoint.z;
|
||||
}
|
||||
}
|
||||
std::sort(vDirectHistory.begin(), vDirectHistory.end(), [&](const Direct_t& a, const Direct_t& b) -> bool
|
||||
{
|
||||
return a.m_iPriority < b.m_iPriority;
|
||||
|
||||
@@ -47,7 +47,7 @@ static inline void HandleMovement(CTFPlayer* pPlayer, MoveData* pLastRecord, Mov
|
||||
{
|
||||
bool bLocal = pPlayer->entindex() == I::EngineClient->GetLocalPlayer();
|
||||
|
||||
if (pLastRecord)
|
||||
if (pLastRecord && !pPlayer->IsDormant())
|
||||
{
|
||||
/*
|
||||
if (tRecord.m_iMode != pLastRecord->m_iMode)
|
||||
@@ -209,23 +209,24 @@ bool CMovementSimulation::Initialize(CBaseEntity* pEntity, MoveStorage& tMoveSto
|
||||
// the hacks that make it work
|
||||
I::MoveHelper->SetHost(pPlayer);
|
||||
pPlayer->m_pCurrentCommand() = &G::DummyCmd;
|
||||
pPlayer->m_nPlayerState() = TF_STATE_ACTIVE;
|
||||
if (pPlayer->m_MoveType() == MOVETYPE_NONE || pPlayer->m_MoveType() == MOVETYPE_OBSERVER)
|
||||
pPlayer->m_MoveType() = MOVETYPE_WALK;
|
||||
|
||||
if (auto pAvgVelocity = H::Entities.GetAvgVelocity(pPlayer->entindex()))
|
||||
pPlayer->m_vecVelocity() = *pAvgVelocity; // only use average velocity here
|
||||
|
||||
if (pPlayer->m_bDucked() = pPlayer->IsDucking())
|
||||
{
|
||||
pPlayer->m_fFlags() &= ~FL_DUCKING; // breaks origin's z if FL_DUCKING is not removed
|
||||
pPlayer->m_flDucktime() = 0.f;
|
||||
pPlayer->m_flDuckJumpTime() = 0.f;
|
||||
pPlayer->m_bDucking() = false;
|
||||
pPlayer->m_bInDuckJump() = false;
|
||||
}
|
||||
pPlayer->m_bDucked() = pPlayer->IsDucking() && !pPlayer->IsDormant();
|
||||
pPlayer->m_fFlags() &= ~FL_DUCKING; // breaks origin's z if FL_DUCKING is not removed
|
||||
pPlayer->m_flDucktime() = 0.f;
|
||||
pPlayer->m_flDuckJumpTime() = 0.f;
|
||||
pPlayer->m_bDucking() = false;
|
||||
pPlayer->m_bInDuckJump() = false;
|
||||
|
||||
if (pPlayer->entindex() != I::EngineClient->GetLocalPlayer())
|
||||
{
|
||||
pPlayer->m_vecBaseVelocity() = Vec3(); // residual basevelocity causes issues
|
||||
if (pPlayer->IsOnGround())
|
||||
if (pPlayer->IsOnGround() && !pPlayer->IsDormant())
|
||||
pPlayer->m_vecVelocity().z = std::min(pPlayer->m_vecVelocity().z, 0.f); // step fix
|
||||
else
|
||||
pPlayer->m_hGroundEntity() = nullptr; // fix for velocity.z being set to 0 even if in air
|
||||
@@ -265,7 +266,7 @@ void CMovementSimulation::SetupMoveData(MoveStorage& tMoveStorage)
|
||||
{
|
||||
tMoveStorage.m_MoveData.m_bFirstRunOfFunctions = false;
|
||||
tMoveStorage.m_MoveData.m_bGameCodeMovedPlayer = false;
|
||||
tMoveStorage.m_MoveData.m_nPlayerHandle = reinterpret_cast<IHandleEntity*>(tMoveStorage.m_pPlayer)->GetRefEHandle();
|
||||
tMoveStorage.m_MoveData.m_nPlayerHandle = tMoveStorage.m_pPlayer->As<IHandleEntity>()->GetRefEHandle();
|
||||
|
||||
tMoveStorage.m_MoveData.m_vecAbsOrigin = tMoveStorage.m_pPlayer->m_vecOrigin();
|
||||
tMoveStorage.m_MoveData.m_vecVelocity = tMoveStorage.m_pPlayer->m_vecVelocity();
|
||||
@@ -318,13 +319,6 @@ void CMovementSimulation::SetupMoveData(MoveStorage& tMoveStorage)
|
||||
tMoveStorage.m_bDirectMove = tMoveStorage.m_pPlayer->IsOnGround() || tMoveStorage.m_pPlayer->IsSwimming();
|
||||
}
|
||||
|
||||
static inline float GetGravity()
|
||||
{
|
||||
static auto sv_gravity = H::ConVars.FindVar("sv_gravity");
|
||||
|
||||
return sv_gravity->GetFloat();
|
||||
}
|
||||
|
||||
static inline float GetFrictionScale(float flVelocityXY, float flTurn, float flVelocityZ, float flMin = 50.f, float flMax = 150.f)
|
||||
{
|
||||
if (0.f >= flVelocityZ || flVelocityZ > 250.f)
|
||||
@@ -362,7 +356,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 == MoveEnum::Air)
|
||||
vVelocity /= GetFrictionScale(tRecord1.m_vVelocity.Length2D(), flYaw, tRecord1.m_vVelocity.z + GetGravity() * TICK_INTERVAL, 0.f, 56.f);
|
||||
vVelocity /= GetFrictionScale(tRecord1.m_vVelocity.Length2D(), flYaw, tRecord1.m_vVelocity.z + SDK::GetGravity() * TICK_INTERVAL, 0.f, 56.f);
|
||||
G::LineStorage.emplace_back(std::pair<Vec3, Vec3>(tRecord1.m_vOrigin, tRecord1.m_vOrigin + vVelocity), I::GlobalVars->curtime + 5.f, tColor);
|
||||
}
|
||||
}
|
||||
@@ -378,7 +372,7 @@ static inline bool GetYawDifference(MoveData& tRecord1, MoveData& tRecord2, bool
|
||||
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);
|
||||
*pYaw /= GetFrictionScale(tRecord1.m_vVelocity.Length2D(), *pYaw, tRecord1.m_vVelocity.z + SDK::GetGravity() * TICK_INTERVAL, 0.f, 56.f);
|
||||
if (fabsf(*pYaw) > 45.f)
|
||||
return false;
|
||||
|
||||
@@ -670,7 +664,7 @@ void CMovementSimulation::RunTick(MoveStorage& tMoveStorage, bool bPath, RunTick
|
||||
{
|
||||
flCorrection = 90.f * sign(tMoveStorage.m_flAverageYaw);
|
||||
if (Vars::Aimbot::Projectile::MovesimFrictionFlags.Value & Vars::Aimbot::Projectile::MovesimFrictionFlagsEnum::RunReduce)
|
||||
flMult = GetFrictionScale(tMoveStorage.m_MoveData.m_vecVelocity.Length2D(), tMoveStorage.m_flAverageYaw, tMoveStorage.m_MoveData.m_vecVelocity.z + GetGravity() * TICK_INTERVAL);
|
||||
flMult = GetFrictionScale(tMoveStorage.m_MoveData.m_vecVelocity.Length2D(), tMoveStorage.m_flAverageYaw, tMoveStorage.m_MoveData.m_vecVelocity.z + SDK::GetGravity() * TICK_INTERVAL);
|
||||
}
|
||||
tMoveStorage.m_MoveData.m_vecViewAngles.y += tMoveStorage.m_flAverageYaw * flMult + flCorrection;
|
||||
}
|
||||
|
||||
@@ -10,8 +10,7 @@ bool CProjectileSimulation::GetInfoMain(CTFPlayer* pPlayer, CTFWeaponBase* pWeap
|
||||
if (!pWeapon || !pPlayer->IsAlive() || pPlayer->IsAGhost() || pPlayer->IsTaunting())
|
||||
return false;
|
||||
|
||||
static auto sv_gravity = H::ConVars.FindVar("sv_gravity");
|
||||
float flGravity = sv_gravity->GetFloat(); // vphysics projectiles affected by server start gravity
|
||||
float flGravity = SDK::GetGravity(); // vphysics projectiles affected by server start gravity
|
||||
bool bDucking = pPlayer->m_fFlags() & FL_DUCKING;
|
||||
|
||||
bool bRedirect = iFlags & ProjSimEnum::Redirect;
|
||||
|
||||
@@ -171,8 +171,7 @@ public:
|
||||
{
|
||||
float flReturn = 0.f;
|
||||
|
||||
static auto sv_gravity = H::ConVars.FindVar("sv_gravity");
|
||||
float flGravity = sv_gravity->GetFloat();
|
||||
float flGravity = SDK::GetGravity();
|
||||
switch (pProjectile->GetClassID())
|
||||
{
|
||||
case ETFClassID::CBaseGrenade:
|
||||
|
||||
@@ -15,9 +15,8 @@ public:
|
||||
float flGravityCorrection = 0.f;
|
||||
if (bZ)
|
||||
{
|
||||
static auto sv_gravity = H::ConVars.FindVar("sv_gravity");
|
||||
float flDeltaTicks = float(iDeltaTicks) + 0.5f; // ?
|
||||
flGravityCorrection = (powf(flDeltaTicks, 2.f) - flDeltaTicks) / 2.f * sv_gravity->GetFloat() * powf(TICK_INTERVAL, 2);
|
||||
flGravityCorrection = (powf(flDeltaTicks, 2.f) - flDeltaTicks) / 2.f * SDK::GetGravity() * powf(TICK_INTERVAL, 2);
|
||||
}
|
||||
float flDeltaValue = m_flNewAxisValue - m_flOldAxisValue;
|
||||
float flTickVelocity = flDeltaValue + (flDeltaValue ? PLAYER_ORIGIN_COMPRESSION / 2 * sign(m_flNewAxisValue) : 0.f) - flGravityCorrection;
|
||||
@@ -120,8 +119,7 @@ MAKE_HOOK(CBaseEntity_SetAbsVelocity, S::CBaseEntity_SetAbsVelocity(), void,
|
||||
FloatRange_t flPositionRange = { tAxisInfo[i].m_flNewAxisValue + flVelocityRange.Max * flRewind, tAxisInfo[i].m_flNewAxisValue + flVelocityRange.Min * flRewind };
|
||||
if (i == 2)
|
||||
{
|
||||
static auto sv_gravity = H::ConVars.FindVar("sv_gravity");
|
||||
float flGravityCorrection = sv_gravity->GetFloat() * powf(flRewind + TICK_INTERVAL / 2, 2.f) / 2;
|
||||
float flGravityCorrection = SDK::GetGravity() * 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)
|
||||
|
||||
@@ -48,7 +48,7 @@ public:
|
||||
NETVAR(m_flLaggedMovementValue, float, "CBasePlayer", "m_flLaggedMovementValue");
|
||||
NETVAR_EMBED(m_AttributeList, void*, "CBasePlayer", "m_AttributeList");
|
||||
NETVAR_EMBED(pl, void*, "CBasePlayer", "pl");
|
||||
NETVAR(deadflag, int, "CBasePlayer", "deadflag");
|
||||
NETVAR(deadflag, bool, "CBasePlayer", "deadflag");
|
||||
NETVAR(m_iFOV, int, "CBasePlayer", "m_iFOV");
|
||||
NETVAR(m_iFOVStart, int, "CBasePlayer", "m_iFOVStart");
|
||||
NETVAR(m_flFOVTime, float, "CBasePlayer", "m_flFOVTime");
|
||||
@@ -67,9 +67,7 @@ public:
|
||||
NETVAR(m_hViewModel, EHANDLE, "CBasePlayer", "m_hViewModel[0]");
|
||||
NETVAR(m_szLastPlaceName, const char*, "CBasePlayer", "m_szLastPlaceName");
|
||||
|
||||
NETVAR_OFF(m_flWaterJumpTime, float, "CBasePlayer", "m_fOnTarget", -60);
|
||||
NETVAR_OFF(m_flSwimSoundTime, float, "CBasePlayer", "m_fOnTarget", -44);
|
||||
NETVAR_OFF(m_vecLadderNormal, Vec3, "CBasePlayer", "m_fOnTarget", -36);
|
||||
NETVAR_OFF(m_flWaterJumpTime, float, "CBasePlayer", "m_nTickBase", -44);
|
||||
NETVAR_OFF(m_flPhysics, int, "CBasePlayer", "m_nTickBase", -4);
|
||||
NETVAR_OFF(m_nFinalPredictedTick, int, "CBasePlayer", "m_nTickBase", 4);
|
||||
NETVAR_OFF(m_nButtons, int, "CBasePlayer", "m_hConstraintEntity", -12);
|
||||
|
||||
@@ -388,13 +388,13 @@ bool CEntities::ManageDormancy(CBaseEntity* pEntity)
|
||||
|
||||
if (bDormant)
|
||||
{
|
||||
if (pEntity->IsPlayer())
|
||||
if (auto pResource = GetResource(); pResource && pEntity->IsPlayer())
|
||||
{
|
||||
if (auto pResource = GetResource(); pResource)
|
||||
{
|
||||
pEntity->As<CTFPlayer>()->m_lifeState() = pResource->m_bAlive(n) ? LIFE_ALIVE : LIFE_DEAD;
|
||||
pEntity->As<CTFPlayer>()->m_iHealth() = pResource->m_iHealth(n);
|
||||
}
|
||||
auto pPlayer = pEntity->As<CTFPlayer>();
|
||||
pPlayer->m_lifeState() = pResource->m_bAlive(n) ? LIFE_ALIVE : LIFE_DEAD;
|
||||
pPlayer->m_iHealth() = pResource->m_iHealth(n);
|
||||
if (pPlayer->IsAlive() && pPlayer->m_iObserverMode() != OBS_MODE_NONE)
|
||||
pPlayer->m_iObserverMode() = OBS_MODE_NONE;
|
||||
}
|
||||
if (s_mDormancy.contains(n))
|
||||
{
|
||||
|
||||
@@ -693,6 +693,13 @@ int SDK::IsAttacking(CTFPlayer* pLocal, CTFWeaponBase* pWeapon, const CUserCmd*
|
||||
return G::CanPrimaryAttack && pCmd->buttons & IN_ATTACK ? 1 : G::Reloading && pCmd->buttons & IN_ATTACK ? 2 : 0;
|
||||
}
|
||||
|
||||
float SDK::GetGravity()
|
||||
{
|
||||
static auto sv_gravity = H::ConVars.FindVar("sv_gravity");
|
||||
|
||||
return sv_gravity->GetFloat();
|
||||
}
|
||||
|
||||
float SDK::MaxSpeed(CTFPlayer* pPlayer, bool bIncludeCrouch, bool bIgnoreSpecialAbility)
|
||||
{
|
||||
float flSpeed = pPlayer->CalculateMaxSpeed(bIgnoreSpecialAbility);
|
||||
|
||||
@@ -121,6 +121,7 @@ namespace SDK
|
||||
const char* GetClassByIndex(const int nClass, bool bLower = true);
|
||||
|
||||
int IsAttacking(CTFPlayer* pLocal, CTFWeaponBase* pWeapon, const CUserCmd* pCmd, bool bTickBase = false);
|
||||
float GetGravity();
|
||||
float MaxSpeed(CTFPlayer* pPlayer, bool bIncludeCrouch = false, bool bIgnoreSpecialAbility = false);
|
||||
float AttribHookValue(float value, const char* name, void* econent, void* buffer = nullptr, bool isGlobalConstString = true);
|
||||
|
||||
|
||||
@@ -686,7 +686,7 @@ NAMESPACE_BEGIN(Vars)
|
||||
CVar(ForwardCutoff, "Forward cutoff", 0.1f, NOSAVE | DEBUGVAR | SLIDER_PRECISION, 0.f, 1.f, 0.1f);
|
||||
CVar(Hull, "Hull", 0.f, NOSAVE | DEBUGVAR | SLIDER_MIN | SLIDER_PRECISION, 0.f, 10.f, 0.5f);
|
||||
CVar(Speed, "Speed", 1100.f, NOSAVE | DEBUGVAR | SLIDER_MIN | SLIDER_PRECISION, 0.f, 5000.f, 50.f);
|
||||
CVar(Gravity, "Gravity", 0.f, NOSAVE | DEBUGVAR | SLIDER_PRECISION, 0.f, 1.f, 0.1f);
|
||||
CVar(Gravity, "Gravity", 0.f, NOSAVE | DEBUGVAR | SLIDER_PRECISION, 0.f, 800.f, 100.f);
|
||||
CVar(LifeTime, "Life time", 10.f, NOSAVE | DEBUGVAR | SLIDER_MIN | SLIDER_PRECISION, 0.f, 10.f, 0.1f);
|
||||
CVar(UpVelocity, "Up velocity", 0.f, NOSAVE | DEBUGVAR | SLIDER_PRECISION, 0.f, 1000.f, 50.f);
|
||||
CVar(AngularVelocityX, "Angular velocity X", 0.f, NOSAVE | DEBUGVAR | SLIDER_PRECISION, -1000.f, 1000.f, 50.f);
|
||||
|
||||
Reference in New Issue
Block a user