mirror of
https://github.com/mapbase-source/source-sdk-2013.git
synced 2024-12-27 07:15:31 +03:00
Added OnServerRagdoll hook for VScript
This commit is contained in:
parent
e55bfa0036
commit
8e283f3738
@ -282,6 +282,10 @@ IMPLEMENT_SERVERCLASS_ST(CBaseAnimating, DT_BaseAnimating)
|
||||
|
||||
END_SEND_TABLE()
|
||||
|
||||
#ifdef MAPBASE_VSCRIPT
|
||||
ScriptHook_t CBaseAnimating::g_Hook_OnServerRagdoll;
|
||||
#endif
|
||||
|
||||
BEGIN_ENT_SCRIPTDESC( CBaseAnimating, CBaseEntity, "Animating models" )
|
||||
|
||||
DEFINE_SCRIPTFUNC( LookupAttachment, "Get the named attachement id" )
|
||||
@ -333,6 +337,11 @@ BEGIN_ENT_SCRIPTDESC( CBaseAnimating, CBaseEntity, "Animating models" )
|
||||
DEFINE_SCRIPTFUNC( BecomeRagdollOnClient, "" )
|
||||
DEFINE_SCRIPTFUNC( IsRagdoll, "" )
|
||||
DEFINE_SCRIPTFUNC( CanBecomeRagdoll, "" )
|
||||
|
||||
BEGIN_SCRIPTHOOK( CBaseAnimating::g_Hook_OnServerRagdoll, "OnServerRagdoll", FIELD_VOID, "Called when this entity creates/turns into a server-side ragdoll." )
|
||||
DEFINE_SCRIPTHOOK_PARAM( "ragdoll", FIELD_HSCRIPT )
|
||||
DEFINE_SCRIPTHOOK_PARAM( "submodel", FIELD_BOOLEAN )
|
||||
END_SCRIPTHOOK()
|
||||
#endif
|
||||
END_SCRIPTDESC();
|
||||
|
||||
|
@ -209,6 +209,8 @@ public:
|
||||
// For VScript
|
||||
int GetSkin() { return m_nSkin; }
|
||||
void SetSkin( int iSkin ) { m_nSkin = iSkin; }
|
||||
|
||||
static ScriptHook_t g_Hook_OnServerRagdoll;
|
||||
#endif
|
||||
|
||||
// These return the attachment in the space of the entity
|
||||
|
@ -1353,6 +1353,16 @@ CBaseAnimating *CreateServerRagdollSubmodel( CBaseAnimating *pOwner, const char
|
||||
matrix3x4_t pBoneToWorld[MAXSTUDIOBONES], pBoneToWorldNext[MAXSTUDIOBONES];
|
||||
pRagdoll->ResetSequence( 0 );
|
||||
|
||||
#ifdef MAPBASE_VSCRIPT
|
||||
// Hook for pre-spawn ragdolling
|
||||
if (pOwner->m_ScriptScope.IsInitialized() && CBaseAnimating::g_Hook_OnServerRagdoll.CanRunInScope( pOwner->m_ScriptScope ))
|
||||
{
|
||||
// ragdoll, submodel
|
||||
ScriptVariant_t args[] = { ScriptVariant_t( pRagdoll->GetScriptInstance() ), true };
|
||||
CBaseAnimating::g_Hook_OnServerRagdoll.Call( pOwner->m_ScriptScope, NULL, args );
|
||||
}
|
||||
#endif
|
||||
|
||||
// let bone merging do the work of copying everything over for us
|
||||
pRagdoll->SetParent( pOwner );
|
||||
pRagdoll->SetupBones( pBoneToWorld, BONE_USED_BY_ANYTHING );
|
||||
@ -1377,6 +1387,16 @@ CBaseEntity *CreateServerRagdoll( CBaseAnimating *pAnimating, int forceBone, con
|
||||
pRagdoll->CopyAnimationDataFrom( pAnimating );
|
||||
pRagdoll->SetOwnerEntity( pAnimating );
|
||||
|
||||
#ifdef MAPBASE_VSCRIPT
|
||||
// Hook for pre-spawn ragdolling
|
||||
if (pAnimating->m_ScriptScope.IsInitialized() && CBaseAnimating::g_Hook_OnServerRagdoll.CanRunInScope( pAnimating->m_ScriptScope ))
|
||||
{
|
||||
// ragdoll, submodel
|
||||
ScriptVariant_t args[] = { ScriptVariant_t( pRagdoll->GetScriptInstance() ), false };
|
||||
CBaseAnimating::g_Hook_OnServerRagdoll.Call( pAnimating->m_ScriptScope, NULL, args );
|
||||
}
|
||||
#endif
|
||||
|
||||
pRagdoll->InitRagdollAnimation();
|
||||
matrix3x4_t pBoneToWorld[MAXSTUDIOBONES], pBoneToWorldNext[MAXSTUDIOBONES];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user