From b720ec4c840c9ef1753a3a75793f57dd2429be69 Mon Sep 17 00:00:00 2001 From: Blixibon Date: Sat, 23 Jan 2021 09:32:28 -0600 Subject: [PATCH] Added spawnflag to make prop_ragdoll bones use constraints which are fixed to each other (also known as "make statue") --- sp/src/game/server/physics_prop_ragdoll.cpp | 7 +++++++ sp/src/game/shared/ragdoll_shared.cpp | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/sp/src/game/server/physics_prop_ragdoll.cpp b/sp/src/game/server/physics_prop_ragdoll.cpp index 78dd812c..8dbd3844 100644 --- a/sp/src/game/server/physics_prop_ragdoll.cpp +++ b/sp/src/game/server/physics_prop_ragdoll.cpp @@ -56,6 +56,9 @@ const float ATTACHED_DAMPING_SCALE = 50.0f; #define SF_RAGDOLLPROP_MOTIONDISABLED 0x4000 #define SF_RAGDOLLPROP_ALLOW_STRETCH 0x8000 #define SF_RAGDOLLPROP_STARTASLEEP 0x10000 +#ifdef MAPBASE +#define SF_RAGDOLLPROP_FIXED_CONSTRAINTS 0x20000 +#endif //----------------------------------------------------------------------------- // Networking @@ -758,7 +761,11 @@ void CRagdollProp::InitRagdoll( const Vector &forceVector, int forceBone, const params.pCurrentBones = pBoneToWorld; params.jointFrictionScale = 1.0; params.allowStretch = HasSpawnFlags(SF_RAGDOLLPROP_ALLOW_STRETCH); +#ifdef MAPBASE + params.fixedConstraints = HasSpawnFlags(SF_RAGDOLLPROP_FIXED_CONSTRAINTS); +#else params.fixedConstraints = false; +#endif RagdollCreate( m_ragdoll, params, physenv ); RagdollApplyAnimationAsVelocity( m_ragdoll, pPrevBones, pBoneToWorld, dt ); if ( m_anglesOverrideString != NULL_STRING && Q_strlen(m_anglesOverrideString.ToCStr()) > 0 ) diff --git a/sp/src/game/shared/ragdoll_shared.cpp b/sp/src/game/shared/ragdoll_shared.cpp index 2cbf751b..ded93773 100644 --- a/sp/src/game/shared/ragdoll_shared.cpp +++ b/sp/src/game/shared/ragdoll_shared.cpp @@ -174,6 +174,10 @@ void RagdollSetupAnimatedFriction( IPhysicsEnvironment *pPhysEnv, ragdoll_t *rag } } +#ifdef MAPBASE +ConVar g_ragdoll_fixed_constraints_mass( "g_ragdoll_fixed_constraints_mass", "1000", FCVAR_REPLICATED ); +#endif + static void RagdollAddSolid( IPhysicsEnvironment *pPhysEnv, ragdoll_t &ragdoll, const ragdollparams_t ¶ms, solid_t &solid ) { if ( solid.index >= 0 && solid.index < params.pCollide->solidCount) @@ -186,7 +190,12 @@ static void RagdollAddSolid( IPhysicsEnvironment *pPhysEnv, ragdoll_t &ragdoll, { if ( params.fixedConstraints ) { +#ifdef MAPBASE + if (g_ragdoll_fixed_constraints_mass.GetFloat() != -1) + solid.params.mass = g_ragdoll_fixed_constraints_mass.GetFloat(); +#else solid.params.mass = 1000.f; +#endif } solid.params.rotInertiaLimit = 0.1;