C_BaseAnimating tracks both server and client ragdolls

This commit is contained in:
Blixibon 2021-09-24 00:24:40 -05:00
parent f1bd6fcf81
commit 8341a65a89
2 changed files with 12 additions and 4 deletions

View File

@ -784,6 +784,10 @@ C_BaseAnimating::C_BaseAnimating() :
m_nPrevSequence = -1; m_nPrevSequence = -1;
m_nRestoreSequence = -1; m_nRestoreSequence = -1;
m_pRagdoll = NULL; m_pRagdoll = NULL;
m_pClientsideRagdoll = NULL;
#ifdef MAPBASE
m_pServerRagdoll = NULL;
#endif
m_builtRagdoll = false; m_builtRagdoll = false;
m_hitboxBoneCacheHandle = 0; m_hitboxBoneCacheHandle = 0;
int i; int i;
@ -4948,26 +4952,26 @@ C_BaseAnimating *C_BaseAnimating::BecomeRagdollOnClient()
{ {
MoveToLastReceivedPosition( true ); MoveToLastReceivedPosition( true );
GetAbsOrigin(); GetAbsOrigin();
C_BaseAnimating *pRagdoll = CreateRagdollCopy(); m_pClientsideRagdoll = CreateRagdollCopy();
matrix3x4_t boneDelta0[MAXSTUDIOBONES]; matrix3x4_t boneDelta0[MAXSTUDIOBONES];
matrix3x4_t boneDelta1[MAXSTUDIOBONES]; matrix3x4_t boneDelta1[MAXSTUDIOBONES];
matrix3x4_t currentBones[MAXSTUDIOBONES]; matrix3x4_t currentBones[MAXSTUDIOBONES];
const float boneDt = 0.1f; const float boneDt = 0.1f;
GetRagdollInitBoneArrays( boneDelta0, boneDelta1, currentBones, boneDt ); GetRagdollInitBoneArrays( boneDelta0, boneDelta1, currentBones, boneDt );
pRagdoll->InitAsClientRagdoll( boneDelta0, boneDelta1, currentBones, boneDt ); m_pClientsideRagdoll->InitAsClientRagdoll( boneDelta0, boneDelta1, currentBones, boneDt );
#ifdef MAPBASE_VSCRIPT #ifdef MAPBASE_VSCRIPT
// Hook for ragdolling // Hook for ragdolling
if (m_ScriptScope.IsInitialized() && g_Hook_OnClientRagdoll.CanRunInScope( m_ScriptScope )) if (m_ScriptScope.IsInitialized() && g_Hook_OnClientRagdoll.CanRunInScope( m_ScriptScope ))
{ {
// ragdoll // ragdoll
ScriptVariant_t args[] = { ScriptVariant_t( pRagdoll->GetScriptInstance() ) }; ScriptVariant_t args[] = { ScriptVariant_t( m_pClientsideRagdoll->GetScriptInstance() ) };
g_Hook_OnClientRagdoll.Call( m_ScriptScope, NULL, args ); g_Hook_OnClientRagdoll.Call( m_ScriptScope, NULL, args );
} }
#endif #endif
return pRagdoll; return m_pClientsideRagdoll;
} }
bool C_BaseAnimating::InitAsClientRagdoll( const matrix3x4_t *pDeltaBones0, const matrix3x4_t *pDeltaBones1, const matrix3x4_t *pCurrentBonePosition, float boneDt, bool bFixedConstraints ) bool C_BaseAnimating::InitAsClientRagdoll( const matrix3x4_t *pDeltaBones0, const matrix3x4_t *pDeltaBones1, const matrix3x4_t *pCurrentBonePosition, float boneDt, bool bFixedConstraints )

View File

@ -531,6 +531,10 @@ private:
public: public:
CRagdoll *m_pRagdoll; CRagdoll *m_pRagdoll;
C_BaseAnimating *m_pClientsideRagdoll; // From Alien Swarm SDK
#ifdef MAPBASE
C_BaseAnimating *m_pServerRagdoll; // Not from Alien Swarm SDK (note that this can exist without the entity having died)
#endif
// Texture group to use // Texture group to use
int m_nSkin; int m_nSkin;