Exposed client-side ragdoll class and functions to VScript

This commit is contained in:
Blixibon 2020-12-25 23:57:02 -06:00
parent cb7cee6283
commit 4861893235
3 changed files with 37 additions and 0 deletions

View File

@ -282,6 +282,16 @@ BEGIN_DATADESC( C_ClientRagdoll )
END_DATADESC() END_DATADESC()
#ifdef MAPBASE_VSCRIPT #ifdef MAPBASE_VSCRIPT
BEGIN_ENT_SCRIPTDESC( C_ClientRagdoll, C_BaseAnimating, "Client-side ragdolls" )
DEFINE_SCRIPTFUNC_NAMED( SUB_Remove, "FadeOut", "Fades out the ragdoll and removes it from the client." )
// TODO: Proper shared ragdoll funcs?
DEFINE_SCRIPTFUNC_NAMED( ScriptGetRagdollObject, "GetRagdollObject", "Gets the ragdoll object of the specified index." )
DEFINE_SCRIPTFUNC_NAMED( ScriptGetRagdollObjectCount, "GetRagdollObjectCount", "Gets the number of ragdoll objects on this ragdoll." )
END_SCRIPTDESC();
ScriptHook_t C_BaseAnimating::g_Hook_OnClientRagdoll; ScriptHook_t C_BaseAnimating::g_Hook_OnClientRagdoll;
#endif #endif
@ -693,6 +703,24 @@ void C_ClientRagdoll::Release( void )
BaseClass::Release(); BaseClass::Release();
} }
#ifdef MAPBASE_VSCRIPT
HSCRIPT C_ClientRagdoll::ScriptGetRagdollObject( int iIndex )
{
if (iIndex < 0 || iIndex > m_pRagdoll->RagdollBoneCount())
{
Warning("%s GetRagdollObject: Index %i not valid (%i objects)\n", GetDebugName(), iIndex, m_pRagdoll->RagdollBoneCount());
return NULL;
}
return g_pScriptVM->RegisterInstance( m_pRagdoll->GetElement(iIndex) );
}
int C_ClientRagdoll::ScriptGetRagdollObjectCount()
{
return m_pRagdoll->RagdollBoneCount();
}
#endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Incremented each frame in InvalidateModelBones. Models compare this value to what it // Incremented each frame in InvalidateModelBones. Models compare this value to what it
// was last time they setup their bones to determine if they need to re-setup their bones. // was last time they setup their bones to determine if they need to re-setup their bones.

View File

@ -678,6 +678,9 @@ public:
C_ClientRagdoll( bool bRestoring = true ); C_ClientRagdoll( bool bRestoring = true );
DECLARE_CLASS( C_ClientRagdoll, C_BaseAnimating ); DECLARE_CLASS( C_ClientRagdoll, C_BaseAnimating );
DECLARE_DATADESC(); DECLARE_DATADESC();
#ifdef MAPBASE_VSCRIPT
DECLARE_ENT_SCRIPTDESC();
#endif
// inherited from IPVSNotify // inherited from IPVSNotify
virtual void OnPVSStatusChanged( bool bInPVS ); virtual void OnPVSStatusChanged( bool bInPVS );
@ -699,6 +702,11 @@ public:
void FadeOut( void ); void FadeOut( void );
virtual float LastBoneChangedTime(); virtual float LastBoneChangedTime();
#ifdef MAPBASE_VSCRIPT
HSCRIPT ScriptGetRagdollObject( int iIndex );
int ScriptGetRagdollObjectCount();
#endif
bool m_bFadeOut; bool m_bFadeOut;
bool m_bImportant; bool m_bImportant;
float m_flEffectTime; float m_flEffectTime;

View File

@ -166,6 +166,7 @@ BEGIN_ENT_SCRIPTDESC( CRagdollProp, CBaseAnimating, "Ragdoll physics prop." )
DEFINE_SCRIPTFUNC( SetSourceClassName, "Sets the ragdoll's source classname." ) DEFINE_SCRIPTFUNC( SetSourceClassName, "Sets the ragdoll's source classname." )
DEFINE_SCRIPTFUNC( HasPhysgunInteraction, "Checks if the ragdoll has the specified interaction." ) DEFINE_SCRIPTFUNC( HasPhysgunInteraction, "Checks if the ragdoll has the specified interaction." )
// TODO: Proper shared ragdoll funcs?
DEFINE_SCRIPTFUNC_NAMED( ScriptGetRagdollObject, "GetRagdollObject", "Gets the ragdoll object of the specified index." ) DEFINE_SCRIPTFUNC_NAMED( ScriptGetRagdollObject, "GetRagdollObject", "Gets the ragdoll object of the specified index." )
DEFINE_SCRIPTFUNC_NAMED( ScriptGetRagdollObjectCount, "GetRagdollObjectCount", "Gets the number of ragdoll objects on this ragdoll." ) DEFINE_SCRIPTFUNC_NAMED( ScriptGetRagdollObjectCount, "GetRagdollObjectCount", "Gets the number of ragdoll objects on this ragdoll." )