mirror of
https://github.com/mapbase-source/source-sdk-2013.git
synced 2024-12-27 07:15:31 +03:00
Added more client-side model/animating VScript functions + a hook for handling client-side ragdolls
This commit is contained in:
parent
f70c066a8e
commit
5e254d19c0
@ -281,6 +281,10 @@ BEGIN_DATADESC( C_ClientRagdoll )
|
||||
|
||||
END_DATADESC()
|
||||
|
||||
#ifdef MAPBASE_VSCRIPT
|
||||
ScriptHook_t C_BaseAnimating::g_Hook_OnClientRagdoll;
|
||||
#endif
|
||||
|
||||
BEGIN_ENT_SCRIPTDESC( C_BaseAnimating, C_BaseEntity, "Animating models client-side" )
|
||||
#ifdef MAPBASE_VSCRIPT
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetPoseParameter, "GetPoseParameter", "Get the specified pose parameter's value" )
|
||||
@ -288,6 +292,14 @@ BEGIN_ENT_SCRIPTDESC( C_BaseAnimating, C_BaseEntity, "Animating models client-si
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptSetPoseParameter, "SetPoseParameter", "Set the specified pose parameter to the specified value" )
|
||||
DEFINE_SCRIPTFUNC( IsSequenceFinished, "Ask whether the main sequence is done playing" )
|
||||
#ifdef MAPBASE_VSCRIPT
|
||||
DEFINE_SCRIPTFUNC( LookupAttachment, "Get the named attachement id" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetAttachmentOrigin, "GetAttachmentOrigin", "Get the attachement id's origin vector" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetAttachmentAngles, "GetAttachmentAngles", "Get the attachement id's angles as a p,y,r vector" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetAttachmentMatrix, "GetAttachmentMatrix", "Get the attachement id's matrix transform" )
|
||||
|
||||
DEFINE_SCRIPTFUNC( LookupBone, "Get the named bone id" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetBoneTransform, "GetBoneTransform", "Get the transform for the specified bone" )
|
||||
|
||||
DEFINE_SCRIPTFUNC( SetBodygroup, "Sets a bodygroup")
|
||||
DEFINE_SCRIPTFUNC( GetBodygroup, "Gets a bodygroup" )
|
||||
DEFINE_SCRIPTFUNC( GetBodygroupName, "Gets a bodygroup name" )
|
||||
@ -302,7 +314,22 @@ BEGIN_ENT_SCRIPTDESC( C_BaseAnimating, C_BaseEntity, "Animating models client-si
|
||||
DEFINE_SCRIPTFUNC( LookupActivity, "Gets the ID of the specified activity name" )
|
||||
DEFINE_SCRIPTFUNC( GetSequenceName, "Gets the name of the specified sequence index" )
|
||||
DEFINE_SCRIPTFUNC( GetSequenceActivityName, "Gets the activity name of the specified sequence index" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetSequenceMoveDist, "GetSequenceMoveDist", "Gets the move distance of the specified sequence" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetSequenceActivity, "GetSequenceActivity", "Gets the activity ID of the specified sequence index" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptSelectWeightedSequence, "SelectWeightedSequence", "Selects a sequence for the specified activity ID" )
|
||||
|
||||
DEFINE_SCRIPTFUNC( GetPlaybackRate, "" )
|
||||
DEFINE_SCRIPTFUNC( SetPlaybackRate, "" )
|
||||
DEFINE_SCRIPTFUNC( GetCycle, "" )
|
||||
DEFINE_SCRIPTFUNC( SetCycle, "" )
|
||||
DEFINE_SCRIPTFUNC( GetSkin, "Gets the model's skin" )
|
||||
DEFINE_SCRIPTFUNC( SetSkin, "Sets the model's skin" )
|
||||
|
||||
DEFINE_SCRIPTFUNC( IsRagdoll, "" )
|
||||
|
||||
BEGIN_SCRIPTHOOK( C_BaseAnimating::g_Hook_OnClientRagdoll, "OnClientRagdoll", FIELD_VOID, "Called when this entity turns into a client-side ragdoll." )
|
||||
DEFINE_SCRIPTHOOK_PARAM( "ragdoll", FIELD_HSCRIPT )
|
||||
END_SCRIPTHOOK()
|
||||
#endif
|
||||
END_SCRIPTDESC();
|
||||
|
||||
@ -1429,6 +1456,52 @@ float C_BaseAnimating::ClampCycle( float flCycle, bool isLooping )
|
||||
}
|
||||
|
||||
#ifdef MAPBASE_VSCRIPT
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Returns the world location and world angles of an attachment to vscript caller
|
||||
// Input : attachment name
|
||||
// Output : location and angles
|
||||
//-----------------------------------------------------------------------------
|
||||
const Vector& C_BaseAnimating::ScriptGetAttachmentOrigin( int iAttachment )
|
||||
{
|
||||
|
||||
static Vector absOrigin;
|
||||
static QAngle qa;
|
||||
|
||||
C_BaseAnimating::GetAttachment( iAttachment, absOrigin, qa );
|
||||
|
||||
return absOrigin;
|
||||
}
|
||||
|
||||
const Vector& C_BaseAnimating::ScriptGetAttachmentAngles( int iAttachment )
|
||||
{
|
||||
|
||||
static Vector absOrigin;
|
||||
static Vector absAngles;
|
||||
static QAngle qa;
|
||||
|
||||
C_BaseAnimating::GetAttachment( iAttachment, absOrigin, qa );
|
||||
absAngles.x = qa.x;
|
||||
absAngles.y = qa.y;
|
||||
absAngles.z = qa.z;
|
||||
return absAngles;
|
||||
}
|
||||
|
||||
HSCRIPT C_BaseAnimating::ScriptGetAttachmentMatrix( int iAttachment )
|
||||
{
|
||||
static matrix3x4_t matrix;
|
||||
|
||||
C_BaseAnimating::GetAttachment( iAttachment, matrix );
|
||||
return g_pScriptVM->RegisterInstance( &matrix );
|
||||
}
|
||||
|
||||
void C_BaseAnimating::ScriptGetBoneTransform( int iBone, HSCRIPT hTransform )
|
||||
{
|
||||
if (hTransform == NULL)
|
||||
return;
|
||||
|
||||
GetBoneTransform( iBone, *HScriptToClass<matrix3x4_t>( hTransform ) );
|
||||
}
|
||||
|
||||
float C_BaseAnimating::ScriptGetPoseParameter( const char* szName )
|
||||
{
|
||||
CStudioHdr* pHdr = GetModelPtr();
|
||||
@ -4736,6 +4809,17 @@ C_BaseAnimating *C_BaseAnimating::BecomeRagdollOnClient()
|
||||
const float boneDt = 0.1f;
|
||||
GetRagdollInitBoneArrays( boneDelta0, boneDelta1, currentBones, boneDt );
|
||||
pRagdoll->InitAsClientRagdoll( boneDelta0, boneDelta1, currentBones, boneDt );
|
||||
|
||||
#ifdef MAPBASE_VSCRIPT
|
||||
// Hook for ragdolling
|
||||
if (m_ScriptScope.IsInitialized() && g_Hook_OnClientRagdoll.CanRunInScope( m_ScriptScope ))
|
||||
{
|
||||
// ragdoll
|
||||
ScriptVariant_t args[] = { ScriptVariant_t( pRagdoll->GetScriptInstance() ) };
|
||||
g_Hook_OnClientRagdoll.Call( m_ScriptScope, NULL, args );
|
||||
}
|
||||
#endif
|
||||
|
||||
return pRagdoll;
|
||||
}
|
||||
|
||||
|
@ -454,6 +454,21 @@ public:
|
||||
virtual bool IsViewModel() const;
|
||||
|
||||
#ifdef MAPBASE_VSCRIPT
|
||||
const Vector& ScriptGetAttachmentOrigin(int iAttachment);
|
||||
const Vector& ScriptGetAttachmentAngles(int iAttachment);
|
||||
HSCRIPT ScriptGetAttachmentMatrix(int iAttachment);
|
||||
|
||||
void ScriptGetBoneTransform( int iBone, HSCRIPT hTransform );
|
||||
|
||||
int ScriptGetSequenceActivity( int iSequence ) { return GetSequenceActivity( iSequence ); }
|
||||
float ScriptGetSequenceMoveDist( int iSequence ) { return GetSequenceMoveDist( GetModelPtr(), iSequence ); }
|
||||
int ScriptSelectWeightedSequence( int activity ) { return SelectWeightedSequence( (Activity)activity ); }
|
||||
|
||||
// For VScript
|
||||
void SetSkin( int iSkin ) { m_nSkin = iSkin; }
|
||||
|
||||
static ScriptHook_t g_Hook_OnClientRagdoll;
|
||||
|
||||
float ScriptGetPoseParameter(const char* szName);
|
||||
#endif
|
||||
void ScriptSetPoseParameter(const char* szName, float fValue);
|
||||
@ -475,10 +490,6 @@ protected:
|
||||
|
||||
virtual bool CalcAttachments();
|
||||
|
||||
#ifdef MAPBASE_VSCRIPT
|
||||
int ScriptGetSequenceActivity( int iSequence ) { return GetSequenceActivity( iSequence ); }
|
||||
#endif
|
||||
|
||||
private:
|
||||
// This method should return true if the bones have changed + SetupBones needs to be called
|
||||
virtual float LastBoneChangedTime() { return FLT_MAX; }
|
||||
|
Loading…
Reference in New Issue
Block a user