mirror of
https://github.com/mapbase-source/source-sdk-2013.git
synced 2025-01-12 23:07:55 +03:00
Merge pull request #172 from samisalreadytaken/sq-typemask
vscript fixes and additions
This commit is contained in:
commit
1143570f3e
@ -178,3 +178,39 @@ BEGIN_PREDICTION_DATA( C_BaseCombatCharacter )
|
||||
DEFINE_PRED_ARRAY( m_hMyWeapons, FIELD_EHANDLE, MAX_WEAPONS, FTYPEDESC_INSENDTABLE ),
|
||||
|
||||
END_PREDICTION_DATA()
|
||||
|
||||
#ifdef MAPBASE_VSCRIPT
|
||||
|
||||
BEGIN_ENT_SCRIPTDESC( C_BaseCombatCharacter, CBaseEntity, "" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetAmmoCount, "GetAmmoCount", "" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetActiveWeapon, "GetActiveWeapon", "" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetWeapon, "GetWeapon", "" )
|
||||
END_SCRIPTDESC();
|
||||
|
||||
|
||||
int C_BaseCombatCharacter::ScriptGetAmmoCount( int i )
|
||||
{
|
||||
Assert( i == -1 || i < MAX_AMMO_SLOTS );
|
||||
|
||||
if ( i < 0 || i >= MAX_AMMO_SLOTS )
|
||||
return NULL;
|
||||
|
||||
return GetAmmoCount( i );
|
||||
}
|
||||
|
||||
HSCRIPT C_BaseCombatCharacter::ScriptGetActiveWeapon()
|
||||
{
|
||||
return ToHScript( GetActiveWeapon() );
|
||||
}
|
||||
|
||||
HSCRIPT C_BaseCombatCharacter::ScriptGetWeapon( int i )
|
||||
{
|
||||
Assert( i >= 0 && i < MAX_WEAPONS );
|
||||
|
||||
if ( i < 0 || i >= MAX_WEAPONS )
|
||||
return NULL;
|
||||
|
||||
return ToHScript( GetWeapon(i) );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -29,6 +29,9 @@ class C_BaseCombatCharacter : public C_BaseFlex
|
||||
public:
|
||||
DECLARE_CLIENTCLASS();
|
||||
DECLARE_PREDICTABLE();
|
||||
#ifdef MAPBASE_VSCRIPT
|
||||
DECLARE_ENT_SCRIPTDESC();
|
||||
#endif
|
||||
|
||||
C_BaseCombatCharacter( void );
|
||||
virtual ~C_BaseCombatCharacter( void );
|
||||
@ -99,6 +102,12 @@ public:
|
||||
virtual void GetGlowEffectColor( float *r, float *g, float *b );
|
||||
#endif // GLOWS_ENABLE
|
||||
|
||||
#ifdef MAPBASE_VSCRIPT
|
||||
int ScriptGetAmmoCount( int i );
|
||||
HSCRIPT ScriptGetActiveWeapon();
|
||||
HSCRIPT ScriptGetWeapon( int i );
|
||||
#endif
|
||||
|
||||
public:
|
||||
|
||||
float m_flNextAttack;
|
||||
|
@ -252,10 +252,7 @@ CScriptMaterialProxy::CScriptMaterialProxy()
|
||||
m_hScriptInstance = NULL;
|
||||
m_hFuncOnBind = NULL;
|
||||
|
||||
for (int i = 0; i < SCRIPT_MAT_PROXY_MAX_VARS; i++)
|
||||
{
|
||||
m_MaterialVars[i] = NULL;
|
||||
}
|
||||
V_memset( m_MaterialVars, 0, sizeof(m_MaterialVars) );
|
||||
}
|
||||
|
||||
CScriptMaterialProxy::~CScriptMaterialProxy()
|
||||
@ -387,13 +384,10 @@ void CScriptMaterialProxy::OnBind( void *pRenderable )
|
||||
|
||||
if (!pEnt)
|
||||
{
|
||||
// Needs to register as a null value so the script doesn't break if it looks for an entity
|
||||
g_pScriptVM->SetValue( m_ScriptScope, "entity", SCRIPT_VARIANT_NULL );
|
||||
}
|
||||
|
||||
m_ScriptScope.Call( m_hFuncOnBind, NULL );
|
||||
|
||||
g_pScriptVM->ClearValue( m_ScriptScope, "entity" );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -305,7 +305,7 @@ BEGIN_ENT_SCRIPTDESC( CBaseAnimating, CBaseEntity, "Animating models" )
|
||||
DEFINE_SCRIPTFUNC( GetNumBones, "Get the number of bones" )
|
||||
DEFINE_SCRIPTFUNC( GetSequence, "Gets the current sequence" )
|
||||
DEFINE_SCRIPTFUNC( SetSequence, "Sets the current sequence" )
|
||||
DEFINE_SCRIPTFUNC( SequenceLoops, "Loops the current sequence" )
|
||||
DEFINE_SCRIPTFUNC( SequenceLoops, "Does the current sequence loop?" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptSequenceDuration, "SequenceDuration", "Get the specified sequence duration" )
|
||||
DEFINE_SCRIPTFUNC( LookupSequence, "Gets the index of the specified sequence name" )
|
||||
DEFINE_SCRIPTFUNC( LookupActivity, "Gets the ID of the specified activity name" )
|
||||
@ -318,6 +318,8 @@ BEGIN_ENT_SCRIPTDESC( CBaseAnimating, CBaseEntity, "Animating models" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptSelectWeightedSequence, "SelectWeightedSequence", "Selects a sequence for the specified activity ID" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptSelectHeaviestSequence, "SelectHeaviestSequence", "Selects the sequence with the heaviest weight for the specified activity ID" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetSequenceKeyValues, "GetSequenceKeyValues", "Get a KeyValue class instance on the specified sequence. WARNING: This uses the same KeyValue pointer as GetModelKeyValues!" )
|
||||
DEFINE_SCRIPTFUNC( ResetSequenceInfo, "" )
|
||||
DEFINE_SCRIPTFUNC( StudioFrameAdvance, "" )
|
||||
DEFINE_SCRIPTFUNC( GetPlaybackRate, "" )
|
||||
DEFINE_SCRIPTFUNC( SetPlaybackRate, "" )
|
||||
DEFINE_SCRIPTFUNC( GetCycle, "" )
|
||||
|
@ -151,11 +151,11 @@ ScriptHook_t CBaseCombatCharacter::g_Hook_RelationshipPriority;
|
||||
|
||||
BEGIN_ENT_SCRIPTDESC( CBaseCombatCharacter, CBaseFlex, "The base class shared by players and NPCs." )
|
||||
|
||||
DEFINE_SCRIPTFUNC_NAMED( GetScriptActiveWeapon, "GetActiveWeapon", "Get the character's active weapon entity." )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetActiveWeapon, "GetActiveWeapon", "Get the character's active weapon entity." )
|
||||
DEFINE_SCRIPTFUNC( WeaponCount, "Get the number of weapons a character possesses." )
|
||||
DEFINE_SCRIPTFUNC_NAMED( GetScriptWeaponIndex, "GetWeapon", "Get a specific weapon in the character's inventory." )
|
||||
DEFINE_SCRIPTFUNC_NAMED( GetScriptWeaponByType, "FindWeapon", "Find a specific weapon in the character's inventory by its classname." )
|
||||
DEFINE_SCRIPTFUNC_NAMED( GetScriptAllWeapons, "GetAllWeapons", "Get the character's weapon inventory." )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetWeapon, "GetWeapon", "Get a specific weapon in the character's inventory." )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetWeaponByType, "FindWeapon", "Find a specific weapon in the character's inventory by its classname." )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetAllWeapons, "GetAllWeapons", "Get the character's weapon inventory." )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetCurrentWeaponProficiency, "GetCurrentWeaponProficiency", "Get the character's current proficiency (accuracy) with their current weapon." )
|
||||
|
||||
DEFINE_SCRIPTFUNC_NAMED( Weapon_ShootPosition, "ShootPosition", "Get the character's shoot position." )
|
||||
@ -176,7 +176,7 @@ BEGIN_ENT_SCRIPTDESC( CBaseCombatCharacter, CBaseFlex, "The base class shared by
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptRelationPriority, "GetRelationPriority", "Get a character's relationship priority for a specific entity." )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptSetRelationship, "SetRelationship", "Set a character's relationship with a specific entity." )
|
||||
|
||||
DEFINE_SCRIPTFUNC_NAMED( GetScriptVehicleEntity, "GetVehicleEntity", "Get the entity for a character's current vehicle if they're in one." )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetVehicleEntity, "GetVehicleEntity", "Get the entity for a character's current vehicle if they're in one." )
|
||||
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptInViewCone, "InViewCone", "Check if the specified position is in the character's viewcone." )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptEntInViewCone, "EntInViewCone", "Check if the specified entity is in the character's viewcone." )
|
||||
@ -4456,28 +4456,33 @@ void CBaseCombatCharacter::DoMuzzleFlash()
|
||||
#ifdef MAPBASE_VSCRIPT
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
HSCRIPT CBaseCombatCharacter::GetScriptActiveWeapon()
|
||||
HSCRIPT CBaseCombatCharacter::ScriptGetActiveWeapon()
|
||||
{
|
||||
return ToHScript( GetActiveWeapon() );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
HSCRIPT CBaseCombatCharacter::GetScriptWeaponIndex( int i )
|
||||
HSCRIPT CBaseCombatCharacter::ScriptGetWeapon( int i )
|
||||
{
|
||||
Assert( i >= 0 && i < MAX_WEAPONS );
|
||||
|
||||
if ( i < 0 || i >= MAX_WEAPONS )
|
||||
return NULL;
|
||||
|
||||
return ToHScript( GetWeapon( i ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
HSCRIPT CBaseCombatCharacter::GetScriptWeaponByType( const char *pszWeapon, int iSubType )
|
||||
HSCRIPT CBaseCombatCharacter::ScriptGetWeaponByType( const char *pszWeapon, int iSubType )
|
||||
{
|
||||
return ToHScript( Weapon_OwnsThisType( pszWeapon, iSubType ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBaseCombatCharacter::GetScriptAllWeapons( HSCRIPT hTable )
|
||||
void CBaseCombatCharacter::ScriptGetAllWeapons( HSCRIPT hTable )
|
||||
{
|
||||
for (int i=0;i<MAX_WEAPONS;i++)
|
||||
{
|
||||
@ -4566,6 +4571,11 @@ void CBaseCombatCharacter::ScriptRemoveAmmo( int iCount, int iAmmoIndex )
|
||||
//-----------------------------------------------------------------------------
|
||||
int CBaseCombatCharacter::ScriptGetAmmoCount( int iType ) const
|
||||
{
|
||||
Assert( iType == -1 || iType < MAX_AMMO_SLOTS );
|
||||
|
||||
if ( iType < 0 || iType >= MAX_AMMO_SLOTS )
|
||||
return 0;
|
||||
|
||||
return GetAmmoCount( iType );
|
||||
}
|
||||
|
||||
@ -4573,11 +4583,10 @@ int CBaseCombatCharacter::ScriptGetAmmoCount( int iType ) const
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBaseCombatCharacter::ScriptSetAmmoCount( int iType, int iCount )
|
||||
{
|
||||
if (iType == -1)
|
||||
{
|
||||
Warning("%i is not a valid ammo type\n", iType);
|
||||
Assert( iType == -1 || iType < MAX_AMMO_SLOTS );
|
||||
|
||||
if ( iType < 0 || iType >= MAX_AMMO_SLOTS )
|
||||
return;
|
||||
}
|
||||
|
||||
return SetAmmoCount( iCount, iType );
|
||||
}
|
||||
@ -4636,7 +4645,7 @@ void CBaseCombatCharacter::ScriptSetRelationship( HSCRIPT pTarget, int dispositi
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
HSCRIPT CBaseCombatCharacter::GetScriptVehicleEntity()
|
||||
HSCRIPT CBaseCombatCharacter::ScriptGetVehicleEntity()
|
||||
{
|
||||
return ToHScript( GetVehicleEntity() );
|
||||
}
|
||||
|
@ -420,10 +420,10 @@ public:
|
||||
virtual void DoMuzzleFlash();
|
||||
|
||||
#ifdef MAPBASE_VSCRIPT
|
||||
HSCRIPT GetScriptActiveWeapon();
|
||||
HSCRIPT GetScriptWeaponIndex( int i );
|
||||
HSCRIPT GetScriptWeaponByType( const char *pszWeapon, int iSubType = 0 );
|
||||
void GetScriptAllWeapons( HSCRIPT hTable );
|
||||
HSCRIPT ScriptGetActiveWeapon();
|
||||
HSCRIPT ScriptGetWeapon( int i );
|
||||
HSCRIPT ScriptGetWeaponByType( const char *pszWeapon, int iSubType = 0 );
|
||||
void ScriptGetAllWeapons( HSCRIPT hTable );
|
||||
int ScriptGetCurrentWeaponProficiency() { return GetCurrentWeaponProficiency(); }
|
||||
|
||||
void ScriptDropWeapon( HSCRIPT hWeapon );
|
||||
@ -441,7 +441,7 @@ public:
|
||||
int ScriptRelationPriority( HSCRIPT pTarget );
|
||||
void ScriptSetRelationship( HSCRIPT pTarget, int disposition, int priority );
|
||||
|
||||
HSCRIPT GetScriptVehicleEntity();
|
||||
HSCRIPT ScriptGetVehicleEntity();
|
||||
|
||||
bool ScriptInViewCone( const Vector &vecSpot ) { return FInViewCone( vecSpot ); }
|
||||
bool ScriptEntInViewCone( HSCRIPT pEntity ) { return FInViewCone( ToEnt( pEntity ) ); }
|
||||
|
@ -10226,13 +10226,10 @@ const Vector& CBaseEntity::ScriptGetBoundingMaxs(void)
|
||||
//-----------------------------------------------------------------------------
|
||||
int CBaseEntity::ScriptTakeDamage( HSCRIPT pInfo )
|
||||
{
|
||||
if (pInfo)
|
||||
CTakeDamageInfo *info = HScriptToClass< CTakeDamageInfo >( pInfo );
|
||||
if ( info )
|
||||
{
|
||||
CTakeDamageInfo *info = HScriptToClass<CTakeDamageInfo>( pInfo ); //ToDamageInfo( pInfo );
|
||||
if (info)
|
||||
{
|
||||
return OnTakeDamage( *info );
|
||||
}
|
||||
return OnTakeDamage( *info );
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -10242,14 +10239,10 @@ int CBaseEntity::ScriptTakeDamage( HSCRIPT pInfo )
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBaseEntity::ScriptFireBullets( HSCRIPT pInfo )
|
||||
{
|
||||
if (pInfo)
|
||||
FireBulletsInfo_t *info = HScriptToClass< FireBulletsInfo_t >( pInfo );
|
||||
if ( info )
|
||||
{
|
||||
extern FireBulletsInfo_t *GetFireBulletsInfoFromInfo( HSCRIPT hBulletsInfo );
|
||||
FireBulletsInfo_t *info = GetFireBulletsInfoFromInfo( pInfo );
|
||||
if (info)
|
||||
{
|
||||
FireBullets( *info );
|
||||
}
|
||||
FireBullets( *info );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3063,15 +3063,33 @@ END_PREDICTION_DATA()
|
||||
IMPLEMENT_NETWORKCLASS_ALIASED( BaseCombatWeapon, DT_BaseCombatWeapon )
|
||||
|
||||
#ifdef MAPBASE_VSCRIPT
|
||||
|
||||
// Don't allow client to use Set functions.
|
||||
// They will only cause visual discrepancies,
|
||||
// and will be reverted on the next update from the server.
|
||||
#ifdef GAME_DLL
|
||||
#define DEFINE_SCRIPTFUNC_SV( p1, p2 ) DEFINE_SCRIPTFUNC( p1, p2 )
|
||||
#define DEFINE_SCRIPTFUNC_NAMED_SV( p1, p2, p3 ) DEFINE_SCRIPTFUNC_NAMED( p1, p2, p3 )
|
||||
|
||||
#define DEFINE_SCRIPTFUNC_CL( p1, p2 )
|
||||
#define DEFINE_SCRIPTFUNC_NAMED_CL( p1, p2, p3 )
|
||||
#else
|
||||
#define DEFINE_SCRIPTFUNC_SV( p1, p2 )
|
||||
#define DEFINE_SCRIPTFUNC_NAMED_SV( p1, p2, p3 )
|
||||
|
||||
#define DEFINE_SCRIPTFUNC_CL( p1, p2 ) DEFINE_SCRIPTFUNC( p1, p2 )
|
||||
#define DEFINE_SCRIPTFUNC_NAMED_CL( p1, p2, p3 ) DEFINE_SCRIPTFUNC_NAMED( p1, p2, p3 )
|
||||
#endif
|
||||
|
||||
BEGIN_ENT_SCRIPTDESC( CBaseCombatWeapon, CBaseAnimating, "The base class for all equippable weapons." )
|
||||
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetOwner, "GetOwner", "Get the weapon's owner." )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptSetOwner, "SetOwner", "Set the weapon's owner." )
|
||||
DEFINE_SCRIPTFUNC_NAMED_SV( ScriptSetOwner, "SetOwner", "Set the weapon's owner." )
|
||||
|
||||
DEFINE_SCRIPTFUNC( Clip1, "Get the weapon's current primary ammo." )
|
||||
DEFINE_SCRIPTFUNC( Clip2, "Get the weapon's current secondary ammo." )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptSetClip1, "SetClip1", "Set the weapon's current primary ammo." )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptSetClip2, "SetClip2", "Set the weapon's current secondary ammo." )
|
||||
DEFINE_SCRIPTFUNC_NAMED_SV( ScriptSetClip1, "SetClip1", "Set the weapon's current primary ammo." )
|
||||
DEFINE_SCRIPTFUNC_NAMED_SV( ScriptSetClip2, "SetClip2", "Set the weapon's current secondary ammo." )
|
||||
DEFINE_SCRIPTFUNC( GetMaxClip1, "Get the weapon's maximum primary ammo." )
|
||||
DEFINE_SCRIPTFUNC( GetMaxClip2, "Get the weapon's maximum secondary ammo." )
|
||||
DEFINE_SCRIPTFUNC( GetDefaultClip1, "Get the weapon's default primary ammo." )
|
||||
@ -3082,18 +3100,16 @@ BEGIN_ENT_SCRIPTDESC( CBaseCombatWeapon, CBaseAnimating, "The base class for all
|
||||
DEFINE_SCRIPTFUNC( HasSecondaryAmmo, "Check if the weapon currently has ammo or doesn't need secondary ammo." )
|
||||
DEFINE_SCRIPTFUNC( UsesPrimaryAmmo, "Check if the weapon uses primary ammo." )
|
||||
DEFINE_SCRIPTFUNC( UsesSecondaryAmmo, "Check if the weapon uses secondary ammo." )
|
||||
DEFINE_SCRIPTFUNC( GiveDefaultAmmo, "Fill the weapon back up to default ammo." )
|
||||
DEFINE_SCRIPTFUNC_SV( GiveDefaultAmmo, "Fill the weapon back up to default ammo." )
|
||||
|
||||
DEFINE_SCRIPTFUNC( UsesClipsForAmmo1, "Check if the weapon uses clips for primary ammo." )
|
||||
DEFINE_SCRIPTFUNC( UsesClipsForAmmo2, "Check if the weapon uses clips for secondary ammo." )
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
DEFINE_SCRIPTFUNC( GetPrimaryAmmoType, "Get the weapon's primary ammo type." )
|
||||
DEFINE_SCRIPTFUNC( GetSecondaryAmmoType, "Get the weapon's secondary ammo type." )
|
||||
#endif
|
||||
|
||||
DEFINE_SCRIPTFUNC( GetSubType, "Get the weapon's subtype." )
|
||||
DEFINE_SCRIPTFUNC( SetSubType, "Set the weapon's subtype." )
|
||||
DEFINE_SCRIPTFUNC_SV( SetSubType, "Set the weapon's subtype." )
|
||||
|
||||
DEFINE_SCRIPTFUNC( GetFireRate, "Get the weapon's firing rate." )
|
||||
DEFINE_SCRIPTFUNC( AddViewKick, "Applies the weapon's view kick." )
|
||||
@ -3103,16 +3119,18 @@ BEGIN_ENT_SCRIPTDESC( CBaseCombatWeapon, CBaseAnimating, "The base class for all
|
||||
DEFINE_SCRIPTFUNC( GetDroppedModel, "Get the weapon's unique dropped model if it has one." )
|
||||
|
||||
DEFINE_SCRIPTFUNC( GetWeight, "Get the weapon's weight." )
|
||||
DEFINE_SCRIPTFUNC( GetPrintName, "" )
|
||||
|
||||
DEFINE_SCRIPTFUNC_CL( GetSlot, "" )
|
||||
DEFINE_SCRIPTFUNC_CL( GetPosition, "" )
|
||||
|
||||
DEFINE_SCRIPTFUNC( CanBePickedUpByNPCs, "Check if the weapon can be picked up by NPCs." )
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
DEFINE_SCRIPTFUNC( CapabilitiesGet, "Get the capabilities the weapon currently possesses." )
|
||||
#endif
|
||||
DEFINE_SCRIPTFUNC_SV( CapabilitiesGet, "Get the capabilities the weapon currently possesses." )
|
||||
|
||||
DEFINE_SCRIPTFUNC( HasWeaponIdleTimeElapsed, "Returns true if the idle time has elapsed." )
|
||||
DEFINE_SCRIPTFUNC( GetWeaponIdleTime, "Returns the next time WeaponIdle() will run." )
|
||||
DEFINE_SCRIPTFUNC( SetWeaponIdleTime, "Sets the next time WeaponIdle() will run." )
|
||||
DEFINE_SCRIPTFUNC_SV( SetWeaponIdleTime, "Sets the next time WeaponIdle() will run." )
|
||||
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptWeaponClassify, "WeaponClassify", "Returns the weapon's classify class from the WEPCLASS_ constant group" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptWeaponSound, "WeaponSound", "Plays one of the weapon's sounds." )
|
||||
@ -3129,22 +3147,22 @@ BEGIN_ENT_SCRIPTDESC( CBaseCombatWeapon, CBaseAnimating, "The base class for all
|
||||
DEFINE_SCRIPTFUNC( IsViewModelSequenceFinished, "Returns true if the current view model animation is finished." )
|
||||
|
||||
DEFINE_SCRIPTFUNC( FiresUnderwater, "Returns true if this weapon can fire underwater." )
|
||||
DEFINE_SCRIPTFUNC( SetFiresUnderwater, "Sets whether this weapon can fire underwater." )
|
||||
DEFINE_SCRIPTFUNC_SV( SetFiresUnderwater, "Sets whether this weapon can fire underwater." )
|
||||
DEFINE_SCRIPTFUNC( AltFiresUnderwater, "Returns true if this weapon can alt-fire underwater." )
|
||||
DEFINE_SCRIPTFUNC( SetAltFiresUnderwater, "Sets whether this weapon can alt-fire underwater." )
|
||||
DEFINE_SCRIPTFUNC_SV( SetAltFiresUnderwater, "Sets whether this weapon can alt-fire underwater." )
|
||||
DEFINE_SCRIPTFUNC( MinRange1, "Returns the closest this weapon can be used." )
|
||||
DEFINE_SCRIPTFUNC( SetMinRange1, "Sets the closest this weapon can be used." )
|
||||
DEFINE_SCRIPTFUNC_SV( SetMinRange1, "Sets the closest this weapon can be used." )
|
||||
DEFINE_SCRIPTFUNC( MinRange2, "Returns the closest this weapon can be used." )
|
||||
DEFINE_SCRIPTFUNC( SetMinRange2, "Sets the closest this weapon can be used." )
|
||||
DEFINE_SCRIPTFUNC_SV( SetMinRange2, "Sets the closest this weapon can be used." )
|
||||
DEFINE_SCRIPTFUNC( ReloadsSingly, "Returns true if this weapon reloads 1 round at a time." )
|
||||
DEFINE_SCRIPTFUNC( SetReloadsSingly, "Sets whether this weapon reloads 1 round at a time." )
|
||||
DEFINE_SCRIPTFUNC_SV( SetReloadsSingly, "Sets whether this weapon reloads 1 round at a time." )
|
||||
DEFINE_SCRIPTFUNC( FireDuration, "Returns the amount of time that the weapon has sustained firing." )
|
||||
DEFINE_SCRIPTFUNC( SetFireDuration, "Sets the amount of time that the weapon has sustained firing." )
|
||||
DEFINE_SCRIPTFUNC_SV( SetFireDuration, "Sets the amount of time that the weapon has sustained firing." )
|
||||
|
||||
DEFINE_SCRIPTFUNC( NextPrimaryAttack, "Returns the next time PrimaryAttack() will run when the player is pressing +ATTACK." )
|
||||
DEFINE_SCRIPTFUNC( SetNextPrimaryAttack, "Sets the next time PrimaryAttack() will run when the player is pressing +ATTACK." )
|
||||
DEFINE_SCRIPTFUNC_SV( SetNextPrimaryAttack, "Sets the next time PrimaryAttack() will run when the player is pressing +ATTACK." )
|
||||
DEFINE_SCRIPTFUNC( NextSecondaryAttack, "Returns the next time SecondaryAttack() will run when the player is pressing +ATTACK2." )
|
||||
DEFINE_SCRIPTFUNC( SetNextSecondaryAttack, "Sets the next time SecondaryAttack() will run when the player is pressing +ATTACK2." )
|
||||
DEFINE_SCRIPTFUNC_SV( SetNextSecondaryAttack, "Sets the next time SecondaryAttack() will run when the player is pressing +ATTACK2." )
|
||||
|
||||
END_SCRIPTDESC();
|
||||
#endif
|
||||
|
@ -187,23 +187,41 @@ public:
|
||||
|
||||
BaseClass::OnRestore();
|
||||
}
|
||||
#else
|
||||
void InputCallScriptFunctionClient( inputdata_t &inputdata )
|
||||
{
|
||||
// TODO: Support for specific players?
|
||||
CBroadcastRecipientFilter filter;
|
||||
filter.MakeReliable();
|
||||
|
||||
const char *pszFunction = inputdata.value.String();
|
||||
if (strlen( pszFunction ) > 64)
|
||||
void ReceiveMessage( int classID, bf_read &msg )
|
||||
{
|
||||
if ( classID != GetClientClass()->m_ClassID )
|
||||
{
|
||||
Msg("%s CallScriptFunctionClient: \"%s\" is too long at %i characters, must be 64 or less\n", GetDebugName(), pszFunction, strlen(pszFunction));
|
||||
BaseClass::ReceiveMessage( classID, msg );
|
||||
return;
|
||||
}
|
||||
|
||||
UserMessageBegin( filter, "CallClientScriptFunction" );
|
||||
WRITE_STRING( pszFunction ); // function
|
||||
WRITE_SHORT( entindex() ); // entity
|
||||
char szFunction[64];
|
||||
msg.ReadString( szFunction, sizeof( szFunction ) );
|
||||
|
||||
if ( m_ScriptScope.IsInitialized() )
|
||||
{
|
||||
CallScriptFunction( szFunction, NULL );
|
||||
}
|
||||
else
|
||||
{
|
||||
CGMsg( 0, CON_GROUP_VSCRIPT, "%s script scope not initialized!\n", GetDebugName() );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef GAME_DLL
|
||||
void InputCallScriptFunctionClient( inputdata_t &inputdata )
|
||||
{
|
||||
const char *pszFunction = inputdata.value.String();
|
||||
if ( V_strlen( pszFunction ) >= 64 )
|
||||
{
|
||||
Msg( "%s CallScriptFunctionClient: \"%s\" is too long at %i characters, must be 64 or less\n", GetDebugName(), pszFunction, V_strlen(pszFunction)+1 );
|
||||
return;
|
||||
}
|
||||
|
||||
EntityMessageBegin( this, true );
|
||||
WRITE_STRING( pszFunction );
|
||||
MessageEnd();
|
||||
}
|
||||
#endif
|
||||
|
@ -16,39 +16,9 @@
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
void __MsgFunc_CallClientScriptFunction( bf_read &msg )
|
||||
{
|
||||
char szFunction[64];
|
||||
if (!msg.ReadString( szFunction, sizeof( szFunction ) ))
|
||||
{
|
||||
CGMsg( 0, CON_GROUP_VSCRIPT, "Unable to read function string\n" );
|
||||
}
|
||||
|
||||
int idx = msg.ReadByte();
|
||||
C_BaseEntity *pEntity = CBaseEntity::Instance( idx );
|
||||
|
||||
if (pEntity)
|
||||
{
|
||||
if (pEntity->m_ScriptScope.IsInitialized())
|
||||
{
|
||||
//CGMsg( 0, CON_GROUP_VSCRIPT, "%s calling function \"%s\"\n", pEntity->GetDebugName(), szFunction );
|
||||
pEntity->CallScriptFunction( szFunction, NULL );
|
||||
}
|
||||
else
|
||||
{
|
||||
CGMsg( 0, CON_GROUP_VSCRIPT, "%s scope not initialized\n", pEntity->GetDebugName() );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CGMsg( 0, CON_GROUP_VSCRIPT, "Clientside entity not found for script function (index %i)\n", idx );
|
||||
}
|
||||
}
|
||||
|
||||
void HookMapbaseUserMessages( void )
|
||||
{
|
||||
// VScript
|
||||
HOOK_MESSAGE( CallClientScriptFunction );
|
||||
//HOOK_MESSAGE( ScriptMsg ); // Hooked in CNetMsgScriptHelper
|
||||
}
|
||||
#endif
|
||||
@ -56,7 +26,6 @@ void HookMapbaseUserMessages( void )
|
||||
void RegisterMapbaseUserMessages( void )
|
||||
{
|
||||
// VScript
|
||||
usermessages->Register( "CallClientScriptFunction", -1 );
|
||||
usermessages->Register( "ScriptMsg", -1 ); // CNetMsgScriptHelper
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
|
@ -126,6 +126,15 @@ extern void RegisterWeaponScriptConstants();
|
||||
|
||||
void RegisterSharedScriptConstants()
|
||||
{
|
||||
// "SERVER_DLL" is used in Source 2.
|
||||
#ifdef GAME_DLL
|
||||
ScriptRegisterConstantNamed( g_pScriptVM, 1, "SERVER_DLL", "" );
|
||||
ScriptRegisterConstantNamed( g_pScriptVM, 0, "CLIENT_DLL", "" );
|
||||
#else
|
||||
ScriptRegisterConstantNamed( g_pScriptVM, 0, "SERVER_DLL", "" );
|
||||
ScriptRegisterConstantNamed( g_pScriptVM, 1, "CLIENT_DLL", "" );
|
||||
#endif
|
||||
|
||||
//
|
||||
// Activities
|
||||
//
|
||||
|
@ -258,8 +258,8 @@ void ScriptDispatchSpawn( HSCRIPT hEntity )
|
||||
static HSCRIPT CreateDamageInfo( HSCRIPT hInflictor, HSCRIPT hAttacker, const Vector &vecForce, const Vector &vecDamagePos, float flDamage, int iDamageType )
|
||||
{
|
||||
// The script is responsible for deleting this via DestroyDamageInfo().
|
||||
CTakeDamageInfo *damageInfo = new CTakeDamageInfo(ToEnt(hInflictor), ToEnt(hAttacker), flDamage, iDamageType);
|
||||
HSCRIPT hScript = g_pScriptVM->RegisterInstance( damageInfo, true );
|
||||
CTakeDamageInfo *damageInfo = new CTakeDamageInfo( ToEnt(hInflictor), ToEnt(hAttacker), flDamage, iDamageType );
|
||||
HSCRIPT hScript = g_pScriptVM->RegisterInstance( damageInfo );
|
||||
|
||||
damageInfo->SetDamagePosition( vecDamagePos );
|
||||
damageInfo->SetDamageForce( vecForce );
|
||||
@ -269,28 +269,54 @@ static HSCRIPT CreateDamageInfo( HSCRIPT hInflictor, HSCRIPT hAttacker, const Ve
|
||||
|
||||
static void DestroyDamageInfo( HSCRIPT hDamageInfo )
|
||||
{
|
||||
if (hDamageInfo)
|
||||
CTakeDamageInfo *pInfo = HScriptToClass< CTakeDamageInfo >( hDamageInfo );
|
||||
if ( pInfo )
|
||||
{
|
||||
CTakeDamageInfo *pInfo = (CTakeDamageInfo*)g_pScriptVM->GetInstanceValue( hDamageInfo, GetScriptDescForClass( CTakeDamageInfo ) );
|
||||
if (pInfo)
|
||||
{
|
||||
g_pScriptVM->RemoveInstance( hDamageInfo );
|
||||
delete pInfo;
|
||||
}
|
||||
g_pScriptVM->RemoveInstance( hDamageInfo );
|
||||
delete pInfo;
|
||||
}
|
||||
}
|
||||
|
||||
void ScriptCalculateExplosiveDamageForce( HSCRIPT info, const Vector &vecDir, const Vector &vecForceOrigin, float flScale ) { CalculateExplosiveDamageForce( HScriptToClass<CTakeDamageInfo>(info), vecDir, vecForceOrigin, flScale ); }
|
||||
void ScriptCalculateBulletDamageForce( HSCRIPT info, int iBulletType, const Vector &vecBulletDir, const Vector &vecForceOrigin, float flScale ) { CalculateBulletDamageForce( HScriptToClass<CTakeDamageInfo>(info), iBulletType, vecBulletDir, vecForceOrigin, flScale ); }
|
||||
void ScriptCalculateMeleeDamageForce( HSCRIPT info, const Vector &vecMeleeDir, const Vector &vecForceOrigin, float flScale ) { CalculateMeleeDamageForce( HScriptToClass<CTakeDamageInfo>( info ), vecMeleeDir, vecForceOrigin, flScale ); }
|
||||
void ScriptGuessDamageForce( HSCRIPT info, const Vector &vecForceDir, const Vector &vecForceOrigin, float flScale ) { GuessDamageForce( HScriptToClass<CTakeDamageInfo>( info ), vecForceDir, vecForceOrigin, flScale ); }
|
||||
void ScriptCalculateExplosiveDamageForce( HSCRIPT info, const Vector &vecDir, const Vector &vecForceOrigin, float flScale )
|
||||
{
|
||||
CTakeDamageInfo *pInfo = HScriptToClass< CTakeDamageInfo >( info );
|
||||
if ( pInfo )
|
||||
{
|
||||
CalculateExplosiveDamageForce( pInfo, vecDir, vecForceOrigin, flScale );
|
||||
}
|
||||
}
|
||||
|
||||
void ScriptCalculateBulletDamageForce( HSCRIPT info, int iBulletType, const Vector &vecBulletDir, const Vector &vecForceOrigin, float flScale )
|
||||
{
|
||||
CTakeDamageInfo *pInfo = HScriptToClass< CTakeDamageInfo >( info );
|
||||
if ( pInfo )
|
||||
{
|
||||
CalculateBulletDamageForce( pInfo, iBulletType, vecBulletDir, vecForceOrigin, flScale );
|
||||
}
|
||||
}
|
||||
|
||||
void ScriptCalculateMeleeDamageForce( HSCRIPT info, const Vector &vecMeleeDir, const Vector &vecForceOrigin, float flScale )
|
||||
{
|
||||
CTakeDamageInfo *pInfo = HScriptToClass< CTakeDamageInfo >( info );
|
||||
if ( pInfo )
|
||||
{
|
||||
CalculateMeleeDamageForce( pInfo, vecMeleeDir, vecForceOrigin, flScale );
|
||||
}
|
||||
}
|
||||
|
||||
void ScriptGuessDamageForce( HSCRIPT info, const Vector &vecForceDir, const Vector &vecForceOrigin, float flScale )
|
||||
{
|
||||
CTakeDamageInfo *pInfo = HScriptToClass< CTakeDamageInfo >( info );
|
||||
if ( pInfo )
|
||||
{
|
||||
GuessDamageForce( pInfo, vecForceDir, vecForceOrigin, flScale );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
BEGIN_SCRIPTDESC_ROOT_NAMED( CTraceInfoAccessor, "CGameTrace", "Handle for accessing trace_t info." )
|
||||
DEFINE_SCRIPT_CONSTRUCTOR()
|
||||
|
||||
BEGIN_SCRIPTDESC_ROOT_NAMED( CScriptGameTrace, "CGameTrace", "trace_t" )
|
||||
DEFINE_SCRIPTFUNC( DidHitWorld, "Returns whether the trace hit the world entity or not." )
|
||||
DEFINE_SCRIPTFUNC( DidHitNonWorldEntity, "Returns whether the trace hit something other than the world entity." )
|
||||
DEFINE_SCRIPTFUNC( GetEntityIndex, "Returns the index of whatever entity this trace hit." )
|
||||
@ -318,120 +344,95 @@ BEGIN_SCRIPTDESC_ROOT_NAMED( CTraceInfoAccessor, "CGameTrace", "Handle for acces
|
||||
DEFINE_SCRIPTFUNC( AllSolid, "Returns whether the trace is completely within a solid." )
|
||||
DEFINE_SCRIPTFUNC( StartSolid, "Returns whether the trace started within a solid." )
|
||||
|
||||
DEFINE_SCRIPTFUNC( Surface, "Returns the trace's surface." )
|
||||
DEFINE_SCRIPTFUNC( Plane, "Returns the trace's plane." )
|
||||
DEFINE_SCRIPTFUNC( Surface, "" )
|
||||
DEFINE_SCRIPTFUNC( Plane, "" )
|
||||
|
||||
DEFINE_SCRIPTFUNC( Destroy, "Deletes this instance. Important for preventing memory leaks." )
|
||||
END_SCRIPTDESC();
|
||||
|
||||
BEGIN_SCRIPTDESC_ROOT_NAMED( scriptsurfacedata_t, "surfacedata_t", "Handle for accessing surface data." )
|
||||
DEFINE_SCRIPTFUNC( GetFriction, "The surface's friction." )
|
||||
DEFINE_SCRIPTFUNC( GetThickness, "The surface's thickness." )
|
||||
BEGIN_SCRIPTDESC_ROOT_NAMED( scriptsurfacedata_t, "surfacedata_t", "" )
|
||||
DEFINE_SCRIPTFUNC( GetFriction, "" )
|
||||
DEFINE_SCRIPTFUNC( GetThickness, "" )
|
||||
|
||||
DEFINE_SCRIPTFUNC( GetJumpFactor, "The surface's jump factor." )
|
||||
DEFINE_SCRIPTFUNC( GetMaterialChar, "The surface's material character." )
|
||||
DEFINE_SCRIPTFUNC( GetJumpFactor, "" )
|
||||
DEFINE_SCRIPTFUNC( GetMaterialChar, "" )
|
||||
|
||||
DEFINE_SCRIPTFUNC( GetSoundStepLeft, "The surface's left step sound." )
|
||||
DEFINE_SCRIPTFUNC( GetSoundStepRight, "The surface's right step sound." )
|
||||
DEFINE_SCRIPTFUNC( GetSoundImpactSoft, "The surface's soft impact sound." )
|
||||
DEFINE_SCRIPTFUNC( GetSoundImpactHard, "The surface's hard impact sound." )
|
||||
DEFINE_SCRIPTFUNC( GetSoundScrapeSmooth, "The surface's smooth scrape sound." )
|
||||
DEFINE_SCRIPTFUNC( GetSoundScrapeRough, "The surface's rough scrape sound." )
|
||||
DEFINE_SCRIPTFUNC( GetSoundBulletImpact, "The surface's bullet impact sound." )
|
||||
DEFINE_SCRIPTFUNC( GetSoundRolling, "The surface's rolling sound." )
|
||||
DEFINE_SCRIPTFUNC( GetSoundBreak, "The surface's break sound." )
|
||||
DEFINE_SCRIPTFUNC( GetSoundStrain, "The surface's strain sound." )
|
||||
DEFINE_SCRIPTFUNC( GetSoundStepLeft, "" )
|
||||
DEFINE_SCRIPTFUNC( GetSoundStepRight, "" )
|
||||
DEFINE_SCRIPTFUNC( GetSoundImpactSoft, "" )
|
||||
DEFINE_SCRIPTFUNC( GetSoundImpactHard, "" )
|
||||
DEFINE_SCRIPTFUNC( GetSoundScrapeSmooth, "" )
|
||||
DEFINE_SCRIPTFUNC( GetSoundScrapeRough, "" )
|
||||
DEFINE_SCRIPTFUNC( GetSoundBulletImpact, "" )
|
||||
DEFINE_SCRIPTFUNC( GetSoundRolling, "" )
|
||||
DEFINE_SCRIPTFUNC( GetSoundBreak, "" )
|
||||
DEFINE_SCRIPTFUNC( GetSoundStrain, "" )
|
||||
END_SCRIPTDESC();
|
||||
|
||||
const char* scriptsurfacedata_t::GetSoundStepLeft() { return physprops->GetString( sounds.stepleft ); }
|
||||
const char* scriptsurfacedata_t::GetSoundStepRight() { return physprops->GetString( sounds.stepright ); }
|
||||
const char* scriptsurfacedata_t::GetSoundImpactSoft() { return physprops->GetString( sounds.impactSoft ); }
|
||||
const char* scriptsurfacedata_t::GetSoundImpactHard() { return physprops->GetString( sounds.impactHard ); }
|
||||
const char* scriptsurfacedata_t::GetSoundScrapeSmooth() { return physprops->GetString( sounds.scrapeSmooth ); }
|
||||
const char* scriptsurfacedata_t::GetSoundScrapeRough() { return physprops->GetString( sounds.scrapeRough ); }
|
||||
const char* scriptsurfacedata_t::GetSoundBulletImpact() { return physprops->GetString( sounds.bulletImpact ); }
|
||||
const char* scriptsurfacedata_t::GetSoundRolling() { return physprops->GetString( sounds.rolling ); }
|
||||
const char* scriptsurfacedata_t::GetSoundBreak() { return physprops->GetString( sounds.breakSound ); }
|
||||
const char* scriptsurfacedata_t::GetSoundStrain() { return physprops->GetString( sounds.strainSound ); }
|
||||
|
||||
BEGIN_SCRIPTDESC_ROOT_NAMED( CSurfaceScriptAccessor, "csurface_t", "Handle for accessing csurface_t info." )
|
||||
DEFINE_SCRIPTFUNC( Name, "The surface's name." )
|
||||
BEGIN_SCRIPTDESC_ROOT_NAMED( CSurfaceScriptHelper, "csurface_t", "" )
|
||||
DEFINE_SCRIPTFUNC( Name, "" )
|
||||
DEFINE_SCRIPTFUNC( SurfaceProps, "The surface's properties." )
|
||||
|
||||
DEFINE_SCRIPTFUNC( Destroy, "Deletes this instance. Important for preventing memory leaks." )
|
||||
END_SCRIPTDESC();
|
||||
|
||||
CPlaneTInstanceHelper g_PlaneTInstanceHelper;
|
||||
|
||||
BEGIN_SCRIPTDESC_ROOT( cplane_t, "Handle for accessing cplane_t info." )
|
||||
BEGIN_SCRIPTDESC_ROOT( cplane_t, "" )
|
||||
DEFINE_SCRIPT_INSTANCE_HELPER( &g_PlaneTInstanceHelper )
|
||||
END_SCRIPTDESC();
|
||||
|
||||
static HSCRIPT ScriptTraceLineComplex( const Vector &vecStart, const Vector &vecEnd, HSCRIPT entIgnore, int iMask, int iCollisionGroup )
|
||||
{
|
||||
// The script is responsible for deleting this via Destroy().
|
||||
CTraceInfoAccessor *traceInfo = new CTraceInfoAccessor();
|
||||
HSCRIPT hScript = g_pScriptVM->RegisterInstance( traceInfo, true );
|
||||
CScriptGameTrace *tr = new CScriptGameTrace();
|
||||
|
||||
CBaseEntity *pLooker = ToEnt(entIgnore);
|
||||
UTIL_TraceLine( vecStart, vecEnd, iMask, pLooker, iCollisionGroup, &traceInfo->GetTrace());
|
||||
CBaseEntity *pIgnore = ToEnt( entIgnore );
|
||||
UTIL_TraceLine( vecStart, vecEnd, iMask, pIgnore, iCollisionGroup, tr );
|
||||
|
||||
// The trace's destruction should destroy this automatically
|
||||
CSurfaceScriptAccessor *surfaceInfo = new CSurfaceScriptAccessor( traceInfo->GetTrace().surface );
|
||||
HSCRIPT hSurface = g_pScriptVM->RegisterInstance( surfaceInfo );
|
||||
traceInfo->SetSurface( hSurface );
|
||||
tr->RegisterSurface();
|
||||
tr->RegisterPlane();
|
||||
|
||||
HSCRIPT hPlane = g_pScriptVM->RegisterInstance( &(traceInfo->GetTrace().plane) );
|
||||
traceInfo->SetPlane( hPlane );
|
||||
|
||||
return hScript;
|
||||
return tr->GetScriptInstance();
|
||||
}
|
||||
|
||||
static HSCRIPT ScriptTraceHullComplex( const Vector &vecStart, const Vector &vecEnd, const Vector &hullMin, const Vector &hullMax,
|
||||
HSCRIPT entIgnore, int iMask, int iCollisionGroup )
|
||||
{
|
||||
// The script is responsible for deleting this via Destroy().
|
||||
CTraceInfoAccessor *traceInfo = new CTraceInfoAccessor();
|
||||
HSCRIPT hScript = g_pScriptVM->RegisterInstance( traceInfo, true );
|
||||
CScriptGameTrace *tr = new CScriptGameTrace();
|
||||
|
||||
CBaseEntity *pLooker = ToEnt(entIgnore);
|
||||
UTIL_TraceHull( vecStart, vecEnd, hullMin, hullMax, iMask, pLooker, iCollisionGroup, &traceInfo->GetTrace());
|
||||
CBaseEntity *pIgnore = ToEnt( entIgnore );
|
||||
UTIL_TraceHull( vecStart, vecEnd, hullMin, hullMax, iMask, pIgnore, iCollisionGroup, tr );
|
||||
|
||||
// The trace's destruction should destroy this automatically
|
||||
CSurfaceScriptAccessor *surfaceInfo = new CSurfaceScriptAccessor( traceInfo->GetTrace().surface );
|
||||
HSCRIPT hSurface = g_pScriptVM->RegisterInstance( surfaceInfo );
|
||||
traceInfo->SetSurface( hSurface );
|
||||
tr->RegisterSurface();
|
||||
tr->RegisterPlane();
|
||||
|
||||
HSCRIPT hPlane = g_pScriptVM->RegisterInstance( &(traceInfo->GetTrace().plane) );
|
||||
traceInfo->SetPlane( hPlane );
|
||||
|
||||
return hScript;
|
||||
return tr->GetScriptInstance();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
BEGIN_SCRIPTDESC_ROOT( FireBulletsInfo_t, "Handle for accessing FireBulletsInfo_t info." )
|
||||
BEGIN_SCRIPTDESC_ROOT( FireBulletsInfo_t, "" )
|
||||
DEFINE_SCRIPT_CONSTRUCTOR()
|
||||
|
||||
DEFINE_SCRIPTFUNC( GetShots, "Gets the number of shots which should be fired." )
|
||||
DEFINE_SCRIPTFUNC( SetShots, "Sets the number of shots which should be fired." )
|
||||
|
||||
DEFINE_SCRIPTFUNC( GetSource, "Gets the source of the bullets." )
|
||||
DEFINE_SCRIPTFUNC( SetSource, "Sets the source of the bullets." )
|
||||
DEFINE_SCRIPTFUNC( GetDirShooting, "Gets the direction of the bullets." )
|
||||
DEFINE_SCRIPTFUNC( SetDirShooting, "Sets the direction of the bullets." )
|
||||
DEFINE_SCRIPTFUNC( GetSpread, "Gets the spread of the bullets." )
|
||||
DEFINE_SCRIPTFUNC( SetSpread, "Sets the spread of the bullets." )
|
||||
DEFINE_SCRIPTFUNC( GetSource, "" )
|
||||
DEFINE_SCRIPTFUNC( SetSource, "" )
|
||||
DEFINE_SCRIPTFUNC( GetDirShooting, "" )
|
||||
DEFINE_SCRIPTFUNC( SetDirShooting, "" )
|
||||
DEFINE_SCRIPTFUNC( GetSpread, "" )
|
||||
DEFINE_SCRIPTFUNC( SetSpread, "" )
|
||||
|
||||
DEFINE_SCRIPTFUNC( GetDistance, "Gets the distance the bullets should travel." )
|
||||
DEFINE_SCRIPTFUNC( SetDistance, "Sets the distance the bullets should travel." )
|
||||
|
||||
DEFINE_SCRIPTFUNC( GetAmmoType, "Gets the ammo type the bullets should use." )
|
||||
DEFINE_SCRIPTFUNC( SetAmmoType, "Sets the ammo type the bullets should use." )
|
||||
DEFINE_SCRIPTFUNC( GetAmmoType, "" )
|
||||
DEFINE_SCRIPTFUNC( SetAmmoType, "" )
|
||||
|
||||
DEFINE_SCRIPTFUNC( GetTracerFreq, "Gets the tracer frequency." )
|
||||
DEFINE_SCRIPTFUNC( SetTracerFreq, "Sets the tracer frequency." )
|
||||
DEFINE_SCRIPTFUNC( GetTracerFreq, "" )
|
||||
DEFINE_SCRIPTFUNC( SetTracerFreq, "" )
|
||||
|
||||
DEFINE_SCRIPTFUNC( GetDamage, "Gets the damage the bullets should deal. 0 = use ammo type" )
|
||||
DEFINE_SCRIPTFUNC( SetDamage, "Sets the damage the bullets should deal. 0 = use ammo type" )
|
||||
@ -441,18 +442,16 @@ BEGIN_SCRIPTDESC_ROOT( FireBulletsInfo_t, "Handle for accessing FireBulletsInfo_
|
||||
DEFINE_SCRIPTFUNC( GetFlags, "Gets the flags the bullets should use." )
|
||||
DEFINE_SCRIPTFUNC( SetFlags, "Sets the flags the bullets should use." )
|
||||
|
||||
DEFINE_SCRIPTFUNC( GetDamageForceScale, "Gets the scale of the damage force applied by the bullets." )
|
||||
DEFINE_SCRIPTFUNC( SetDamageForceScale, "Sets the scale of the damage force applied by the bullets." )
|
||||
DEFINE_SCRIPTFUNC( GetDamageForceScale, "" )
|
||||
DEFINE_SCRIPTFUNC( SetDamageForceScale, "" )
|
||||
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetAttacker, "GetAttacker", "Gets the entity considered to be the one who fired the bullets." )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptSetAttacker, "SetAttacker", "Sets the entity considered to be the one who fired the bullets." )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetAdditionalIgnoreEnt, "GetAdditionalIgnoreEnt", "Gets the optional entity which the bullets should ignore." )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptSetAdditionalIgnoreEnt, "SetAdditionalIgnoreEnt", "Sets the optional entity which the bullets should ignore." )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetAttacker, "GetAttacker", "" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptSetAttacker, "SetAttacker", "" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetAdditionalIgnoreEnt, "GetAdditionalIgnoreEnt", "" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptSetAdditionalIgnoreEnt, "SetAdditionalIgnoreEnt", "" )
|
||||
|
||||
DEFINE_SCRIPTFUNC( GetPrimaryAttack, "Gets whether the bullets came from a primary attack." )
|
||||
DEFINE_SCRIPTFUNC( SetPrimaryAttack, "Sets whether the bullets came from a primary attack." )
|
||||
|
||||
//DEFINE_SCRIPTFUNC( Destroy, "Deletes this instance. Important for preventing memory leaks." )
|
||||
END_SCRIPTDESC();
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -483,7 +482,7 @@ static HSCRIPT CreateFireBulletsInfo( int cShots, const Vector &vecSrc, const Ve
|
||||
{
|
||||
// The script is responsible for deleting this via DestroyFireBulletsInfo().
|
||||
FireBulletsInfo_t *info = new FireBulletsInfo_t();
|
||||
HSCRIPT hScript = g_pScriptVM->RegisterInstance( info, true );
|
||||
HSCRIPT hScript = g_pScriptVM->RegisterInstance( info );
|
||||
|
||||
info->SetShots( cShots );
|
||||
info->SetSource( vecSrc );
|
||||
@ -497,13 +496,12 @@ static HSCRIPT CreateFireBulletsInfo( int cShots, const Vector &vecSrc, const Ve
|
||||
|
||||
static void DestroyFireBulletsInfo( HSCRIPT hBulletsInfo )
|
||||
{
|
||||
g_pScriptVM->RemoveInstance( hBulletsInfo );
|
||||
}
|
||||
|
||||
// For the function in baseentity.cpp
|
||||
FireBulletsInfo_t *GetFireBulletsInfoFromInfo( HSCRIPT hBulletsInfo )
|
||||
{
|
||||
return HScriptToClass<FireBulletsInfo_t>( hBulletsInfo );
|
||||
FireBulletsInfo_t *pInfo = HScriptToClass< FireBulletsInfo_t >( hBulletsInfo );
|
||||
if ( pInfo )
|
||||
{
|
||||
g_pScriptVM->RemoveInstance( hBulletsInfo );
|
||||
delete pInfo;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -511,20 +509,20 @@ FireBulletsInfo_t *GetFireBulletsInfoFromInfo( HSCRIPT hBulletsInfo )
|
||||
//-----------------------------------------------------------------------------
|
||||
CAnimEventTInstanceHelper g_AnimEventTInstanceHelper;
|
||||
|
||||
BEGIN_SCRIPTDESC_ROOT( scriptanimevent_t, "Handle for accessing animevent_t info." )
|
||||
BEGIN_SCRIPTDESC_ROOT( scriptanimevent_t, "" )
|
||||
DEFINE_SCRIPT_INSTANCE_HELPER( &g_AnimEventTInstanceHelper )
|
||||
|
||||
DEFINE_SCRIPTFUNC( GetEvent, "Gets the event number." )
|
||||
DEFINE_SCRIPTFUNC( SetEvent, "Sets the event number." )
|
||||
DEFINE_SCRIPTFUNC( GetEvent, "" )
|
||||
DEFINE_SCRIPTFUNC( SetEvent, "" )
|
||||
|
||||
DEFINE_SCRIPTFUNC( GetOptions, "Gets the event's options/parameters." )
|
||||
DEFINE_SCRIPTFUNC( SetOptions, "Sets the event's options/parameters." )
|
||||
DEFINE_SCRIPTFUNC( GetOptions, "" )
|
||||
DEFINE_SCRIPTFUNC( SetOptions, "" )
|
||||
|
||||
DEFINE_SCRIPTFUNC( GetCycle, "Gets the cycle at which the event happens." )
|
||||
DEFINE_SCRIPTFUNC( SetCycle, "Sets the cycle at which the event happens." )
|
||||
DEFINE_SCRIPTFUNC( GetCycle, "" )
|
||||
DEFINE_SCRIPTFUNC( SetCycle, "" )
|
||||
|
||||
DEFINE_SCRIPTFUNC( GetEventTime, "Gets the time the event plays." )
|
||||
DEFINE_SCRIPTFUNC( SetEventTime, "Sets the time the event plays." )
|
||||
DEFINE_SCRIPTFUNC( GetEventTime, "" )
|
||||
DEFINE_SCRIPTFUNC( SetEventTime, "" )
|
||||
|
||||
DEFINE_SCRIPTFUNC( GetType, "Gets the event's type flags. See the 'AE_TYPE_' set of constants for valid flags." )
|
||||
DEFINE_SCRIPTFUNC( SetType, "Sets the event's type flags. See the 'AE_TYPE_' set of constants for valid flags." )
|
||||
@ -586,26 +584,26 @@ bool CAnimEventTInstanceHelper::Set( void *p, const char *pszKey, ScriptVariant_
|
||||
//-----------------------------------------------------------------------------
|
||||
// EmitSound_t
|
||||
//-----------------------------------------------------------------------------
|
||||
BEGIN_SCRIPTDESC_ROOT_NAMED( ScriptEmitSound_t, "EmitSound_t", "Handle for accessing EmitSound_t info." )
|
||||
BEGIN_SCRIPTDESC_ROOT_NAMED( ScriptEmitSound_t, "EmitSound_t", "" )
|
||||
DEFINE_SCRIPT_CONSTRUCTOR()
|
||||
|
||||
DEFINE_SCRIPTFUNC( GetChannel, "Gets the sound's channel." )
|
||||
DEFINE_SCRIPTFUNC( SetChannel, "Gets the sound's channel." )
|
||||
DEFINE_SCRIPTFUNC( GetChannel, "" )
|
||||
DEFINE_SCRIPTFUNC( SetChannel, "" )
|
||||
|
||||
DEFINE_SCRIPTFUNC( GetSoundName, "Gets the sound's file path or soundscript name." )
|
||||
DEFINE_SCRIPTFUNC( SetSoundName, "Sets the sound's file path or soundscript name." )
|
||||
|
||||
DEFINE_SCRIPTFUNC( GetVolume, "Gets the sound's volume. (Note that this may not apply to soundscripts)" )
|
||||
DEFINE_SCRIPTFUNC( SetVolume, "Sets the sound's volume. (Note that this may not apply to soundscripts)" )
|
||||
DEFINE_SCRIPTFUNC( GetVolume, "(Note that this may not apply to soundscripts)" )
|
||||
DEFINE_SCRIPTFUNC( SetVolume, "(Note that this may not apply to soundscripts)" )
|
||||
|
||||
DEFINE_SCRIPTFUNC( GetSoundLevel, "Gets the sound's level in decibels. (Note that this may not apply to soundscripts)" )
|
||||
DEFINE_SCRIPTFUNC( SetSoundLevel, "Sets the sound's level in decibels. (Note that this may not apply to soundscripts)" )
|
||||
|
||||
DEFINE_SCRIPTFUNC( GetFlags, "Gets the sound's flags. See the 'SND_' set of constants for more information." )
|
||||
DEFINE_SCRIPTFUNC( SetFlags, "Sets the sound's flags. See the 'SND_' set of constants for more information." )
|
||||
DEFINE_SCRIPTFUNC( GetFlags, "Gets the sound's flags. See the 'SND_' set of constants." )
|
||||
DEFINE_SCRIPTFUNC( SetFlags, "Sets the sound's flags. See the 'SND_' set of constants." )
|
||||
|
||||
DEFINE_SCRIPTFUNC( GetSpecialDSP, "Gets the sound's special DSP setting." )
|
||||
DEFINE_SCRIPTFUNC( SetSpecialDSP, "Sets the sound's special DSP setting." )
|
||||
DEFINE_SCRIPTFUNC( GetSpecialDSP, "" )
|
||||
DEFINE_SCRIPTFUNC( SetSpecialDSP, "" )
|
||||
|
||||
DEFINE_SCRIPTFUNC( HasOrigin, "Returns true if the sound has an origin override." )
|
||||
DEFINE_SCRIPTFUNC( GetOrigin, "Gets the sound's origin override." )
|
||||
@ -627,14 +625,14 @@ BEGIN_SCRIPTDESC_ROOT_NAMED( ScriptEmitSound_t, "EmitSound_t", "Handle for acces
|
||||
DEFINE_SCRIPTFUNC( GetSpeakerEntity, "Gets the sound's original source if it is being transmitted by a microphone." )
|
||||
DEFINE_SCRIPTFUNC( SetSpeakerEntity, "Sets the sound's original source if it is being transmitted by a microphone." )
|
||||
|
||||
DEFINE_SCRIPTFUNC( GetSoundScriptHandle, "Gets the sound's script handle." )
|
||||
DEFINE_SCRIPTFUNC( SetSoundScriptHandle, "Sets the sound's script handle." )
|
||||
DEFINE_SCRIPTFUNC( GetSoundScriptHandle, "" )
|
||||
DEFINE_SCRIPTFUNC( SetSoundScriptHandle, "" )
|
||||
END_SCRIPTDESC();
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
BEGIN_SCRIPTDESC_ROOT_NAMED( CScriptUserCmd, "CUserCmd", "Handle for accessing CUserCmd info." )
|
||||
BEGIN_SCRIPTDESC_ROOT_NAMED( CScriptUserCmd, "CUserCmd", "" )
|
||||
DEFINE_SCRIPTFUNC( GetCommandNumber, "For matching server and client commands for debugging." )
|
||||
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetTickCount, "GetTickCount", "The tick the client created this command." )
|
||||
@ -642,15 +640,15 @@ BEGIN_SCRIPTDESC_ROOT_NAMED( CScriptUserCmd, "CUserCmd", "Handle for accessing C
|
||||
DEFINE_SCRIPTFUNC( GetViewAngles, "Player instantaneous view angles." )
|
||||
DEFINE_SCRIPTFUNC( SetViewAngles, "Sets player instantaneous view angles." )
|
||||
|
||||
DEFINE_SCRIPTFUNC( GetForwardMove, "Forward velocity." )
|
||||
DEFINE_SCRIPTFUNC( SetForwardMove, "Sets forward velocity." )
|
||||
DEFINE_SCRIPTFUNC( GetSideMove, "Side velocity." )
|
||||
DEFINE_SCRIPTFUNC( SetSideMove, "Sets side velocity." )
|
||||
DEFINE_SCRIPTFUNC( GetUpMove, "Up velocity." )
|
||||
DEFINE_SCRIPTFUNC( SetUpMove, "Sets up velocity." )
|
||||
DEFINE_SCRIPTFUNC( GetForwardMove, "" )
|
||||
DEFINE_SCRIPTFUNC( SetForwardMove, "" )
|
||||
DEFINE_SCRIPTFUNC( GetSideMove, "" )
|
||||
DEFINE_SCRIPTFUNC( SetSideMove, "" )
|
||||
DEFINE_SCRIPTFUNC( GetUpMove, "" )
|
||||
DEFINE_SCRIPTFUNC( SetUpMove, "" )
|
||||
|
||||
DEFINE_SCRIPTFUNC( GetButtons, "Attack button states." )
|
||||
DEFINE_SCRIPTFUNC( SetButtons, "Sets attack button states." )
|
||||
DEFINE_SCRIPTFUNC( GetButtons, "Input button state." )
|
||||
DEFINE_SCRIPTFUNC( SetButtons, "Sets input button state." )
|
||||
DEFINE_SCRIPTFUNC( GetImpulse, "Impulse command issued." )
|
||||
DEFINE_SCRIPTFUNC( SetImpulse, "Sets impulse command issued." )
|
||||
|
||||
@ -676,19 +674,19 @@ END_SCRIPTDESC();
|
||||
DEFINE_SCRIPTFUNC( Set##name, "Set " desc )
|
||||
|
||||
BEGIN_SCRIPTDESC_ROOT_NAMED( Script_AI_EnemyInfo_t, "AI_EnemyInfo_t", "Accessor for information about an enemy." )
|
||||
DEFINE_SCRIPTFUNC( Enemy, "Get the enemy." )
|
||||
DEFINE_SCRIPTFUNC( SetEnemy, "Set the enemy." )
|
||||
DEFINE_ENEMY_INFO_SCRIPTFUNCS( LastKnownLocation, "the enemy's last known location." )
|
||||
DEFINE_ENEMY_INFO_SCRIPTFUNCS( LastSeenLocation, "the enemy's last seen location." )
|
||||
DEFINE_ENEMY_INFO_SCRIPTFUNCS( TimeLastSeen, "the last time the enemy was seen." )
|
||||
DEFINE_ENEMY_INFO_SCRIPTFUNCS( TimeFirstSeen, "the first time the enemy was seen." )
|
||||
DEFINE_ENEMY_INFO_SCRIPTFUNCS( TimeLastReacquired, "the last time the enemy was reaquired." )
|
||||
DEFINE_SCRIPTFUNC( Enemy, "" )
|
||||
DEFINE_SCRIPTFUNC( SetEnemy, "" )
|
||||
DEFINE_ENEMY_INFO_SCRIPTFUNCS( LastKnownLocation, "" )
|
||||
DEFINE_ENEMY_INFO_SCRIPTFUNCS( LastSeenLocation, "" )
|
||||
DEFINE_ENEMY_INFO_SCRIPTFUNCS( TimeLastSeen, "" )
|
||||
DEFINE_ENEMY_INFO_SCRIPTFUNCS( TimeFirstSeen, "" )
|
||||
DEFINE_ENEMY_INFO_SCRIPTFUNCS( TimeLastReacquired, "" )
|
||||
DEFINE_ENEMY_INFO_SCRIPTFUNCS( TimeValidEnemy, "the time at which the enemy can be selected (reaction delay)." )
|
||||
DEFINE_ENEMY_INFO_SCRIPTFUNCS( TimeLastReceivedDamageFrom, "the last time damage was received from this enemy." )
|
||||
DEFINE_ENEMY_INFO_SCRIPTFUNCS( TimeAtFirstHand, "the time at which the enemy was seen firsthand." )
|
||||
DEFINE_ENEMY_INFO_SCRIPTFUNCS( DangerMemory, "the memory of danger position w/o enemy pointer." )
|
||||
DEFINE_ENEMY_INFO_SCRIPTFUNCS( EludedMe, "whether the enemy is not at the last known location." )
|
||||
DEFINE_ENEMY_INFO_SCRIPTFUNCS( Unforgettable, "whether the enemy is unforgettable." )
|
||||
DEFINE_ENEMY_INFO_SCRIPTFUNCS( Unforgettable, "" )
|
||||
DEFINE_ENEMY_INFO_SCRIPTFUNCS( MobbedMe, "whether the enemy was part of a mob at some point." )
|
||||
END_SCRIPTDESC();
|
||||
#endif
|
||||
@ -844,8 +842,11 @@ static void ScriptEntitiesInSphere( HSCRIPT hTable, int listMax, const Vector &c
|
||||
|
||||
static void ScriptDecalTrace( HSCRIPT hTrace, const char *decalName )
|
||||
{
|
||||
CTraceInfoAccessor *traceInfo = HScriptToClass<CTraceInfoAccessor>(hTrace);
|
||||
UTIL_DecalTrace( &traceInfo->GetTrace(), decalName );
|
||||
CScriptGameTrace *tr = HScriptToClass< CScriptGameTrace >( hTrace );
|
||||
if ( tr )
|
||||
{
|
||||
UTIL_DecalTrace( tr, decalName );
|
||||
}
|
||||
}
|
||||
|
||||
static HSCRIPT ScriptCreateRope( HSCRIPT hStart, HSCRIPT hEnd, int iStartAttachment, int iEndAttachment, float ropeWidth, const char *pMaterialName, int numSegments, int ropeFlags )
|
||||
@ -1004,15 +1005,15 @@ void RegisterSharedScriptFunctions()
|
||||
ScriptRegisterFunctionNamed( g_pScriptVM, ScriptDispatchSpawn, "DispatchSpawn", "Spawns an unspawned entity." );
|
||||
#endif
|
||||
|
||||
ScriptRegisterFunction( g_pScriptVM, CreateDamageInfo, "Creates damage info." );
|
||||
ScriptRegisterFunction( g_pScriptVM, DestroyDamageInfo, "Destroys damage info." );
|
||||
ScriptRegisterFunction( g_pScriptVM, CreateDamageInfo, "" );
|
||||
ScriptRegisterFunction( g_pScriptVM, DestroyDamageInfo, "" );
|
||||
ScriptRegisterFunctionNamed( g_pScriptVM, ScriptCalculateExplosiveDamageForce, "CalculateExplosiveDamageForce", "Fill out a damage info handle with a damage force for an explosive." );
|
||||
ScriptRegisterFunctionNamed( g_pScriptVM, ScriptCalculateBulletDamageForce, "CalculateBulletDamageForce", "Fill out a damage info handle with a damage force for a bullet impact." );
|
||||
ScriptRegisterFunctionNamed( g_pScriptVM, ScriptCalculateMeleeDamageForce, "CalculateMeleeDamageForce", "Fill out a damage info handle with a damage force for a melee impact." );
|
||||
ScriptRegisterFunctionNamed( g_pScriptVM, ScriptGuessDamageForce, "GuessDamageForce", "Try and guess the physics force to use." );
|
||||
|
||||
ScriptRegisterFunction( g_pScriptVM, CreateFireBulletsInfo, "Creates FireBullets info." );
|
||||
ScriptRegisterFunction( g_pScriptVM, DestroyFireBulletsInfo, "Destroys FireBullets info." );
|
||||
ScriptRegisterFunction( g_pScriptVM, CreateFireBulletsInfo, "" );
|
||||
ScriptRegisterFunction( g_pScriptVM, DestroyFireBulletsInfo, "" );
|
||||
|
||||
ScriptRegisterFunctionNamed( g_pScriptVM, ScriptTraceLineComplex, "TraceLineComplex", "Complex version of TraceLine which takes 2 points, an ent to ignore, a trace mask, and a collision group. Returns a handle which can access all trace info." );
|
||||
ScriptRegisterFunctionNamed( g_pScriptVM, ScriptTraceHullComplex, "TraceHullComplex", "Takes 2 points, min/max hull bounds, an ent to ignore, a trace mask, and a collision group to trace to a point using a hull. Returns a handle which can access all trace info." );
|
||||
|
@ -21,42 +21,52 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
struct scriptsurfacedata_t : public surfacedata_t
|
||||
{
|
||||
float GetFriction() { return physics.friction; }
|
||||
float GetThickness() { return physics.thickness; }
|
||||
public:
|
||||
float GetFriction() const { return physics.friction; }
|
||||
float GetThickness() const { return physics.thickness; }
|
||||
|
||||
float GetJumpFactor() { return game.jumpFactor; }
|
||||
char GetMaterialChar() { return game.material; }
|
||||
float GetJumpFactor() const { return game.jumpFactor; }
|
||||
char GetMaterialChar() const { return game.material; }
|
||||
|
||||
const char* GetSoundStepLeft();
|
||||
const char* GetSoundStepRight();
|
||||
const char* GetSoundImpactSoft();
|
||||
const char* GetSoundImpactHard();
|
||||
const char* GetSoundScrapeSmooth();
|
||||
const char* GetSoundScrapeRough();
|
||||
const char* GetSoundBulletImpact();
|
||||
const char* GetSoundRolling();
|
||||
const char* GetSoundBreak();
|
||||
const char* GetSoundStrain();
|
||||
const char* GetSoundStepLeft() const { return physprops->GetString( sounds.stepleft ); }
|
||||
const char* GetSoundStepRight() const { return physprops->GetString( sounds.stepright ); }
|
||||
const char* GetSoundImpactSoft() const { return physprops->GetString( sounds.impactSoft ); }
|
||||
const char* GetSoundImpactHard() const { return physprops->GetString( sounds.impactHard ); }
|
||||
const char* GetSoundScrapeSmooth() const { return physprops->GetString( sounds.scrapeSmooth ); }
|
||||
const char* GetSoundScrapeRough() const { return physprops->GetString( sounds.scrapeRough ); }
|
||||
const char* GetSoundBulletImpact() const { return physprops->GetString( sounds.bulletImpact ); }
|
||||
const char* GetSoundRolling() const { return physprops->GetString( sounds.rolling ); }
|
||||
const char* GetSoundBreak() const { return physprops->GetString( sounds.breakSound ); }
|
||||
const char* GetSoundStrain() const { return physprops->GetString( sounds.strainSound ); }
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Exposes csurface_t to VScript
|
||||
//-----------------------------------------------------------------------------
|
||||
class CSurfaceScriptAccessor
|
||||
class CSurfaceScriptHelper
|
||||
{
|
||||
public:
|
||||
CSurfaceScriptAccessor( csurface_t &surf ) { m_surf = &surf; m_surfaceData = g_pScriptVM->RegisterInstance( reinterpret_cast<scriptsurfacedata_t*>(physprops->GetSurfaceData( m_surf->surfaceProps )) ); }
|
||||
~CSurfaceScriptAccessor() { delete m_surfaceData; }
|
||||
// This class is owned by CScriptGameTrace, and cannot be accessed without being initialised in CScriptGameTrace::RegisterSurface()
|
||||
//CSurfaceScriptHelper() : m_pSurface(NULL), m_hSurfaceData(NULL) {}
|
||||
|
||||
// cplane_t stuff
|
||||
const char* Name() const { return m_surf->name; }
|
||||
HSCRIPT SurfaceProps() const { return m_surfaceData; }
|
||||
~CSurfaceScriptHelper()
|
||||
{
|
||||
g_pScriptVM->RemoveInstance( m_hSurfaceData );
|
||||
}
|
||||
|
||||
void Destroy() { delete this; }
|
||||
void Init( csurface_t *surf )
|
||||
{
|
||||
m_pSurface = surf;
|
||||
m_hSurfaceData = g_pScriptVM->RegisterInstance(
|
||||
reinterpret_cast< scriptsurfacedata_t* >( physprops->GetSurfaceData( m_pSurface->surfaceProps ) ) );
|
||||
}
|
||||
|
||||
const char* Name() const { return m_pSurface->name; }
|
||||
HSCRIPT SurfaceProps() const { return m_hSurfaceData; }
|
||||
|
||||
private:
|
||||
csurface_t *m_surf;
|
||||
HSCRIPT m_surfaceData;
|
||||
csurface_t *m_pSurface;
|
||||
HSCRIPT m_hSurfaceData;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -83,70 +93,80 @@ class CPlaneTInstanceHelper : public IScriptInstanceHelper
|
||||
//-----------------------------------------------------------------------------
|
||||
// Exposes trace_t to VScript
|
||||
//-----------------------------------------------------------------------------
|
||||
class CTraceInfoAccessor
|
||||
class CScriptGameTrace : public CGameTrace
|
||||
{
|
||||
public:
|
||||
~CTraceInfoAccessor()
|
||||
CScriptGameTrace() : m_surfaceAccessor(NULL), m_planeAccessor(NULL)
|
||||
{
|
||||
if (m_surfaceAccessor)
|
||||
{
|
||||
CSurfaceScriptAccessor *pScriptSurface = HScriptToClass<CSurfaceScriptAccessor>( m_surfaceAccessor );
|
||||
//g_pScriptVM->RemoveInstance( m_surfaceAccessor );
|
||||
delete pScriptSurface;
|
||||
}
|
||||
|
||||
//if (m_planeAccessor)
|
||||
//{
|
||||
// g_pScriptVM->RemoveInstance( m_planeAccessor );
|
||||
//}
|
||||
m_hScriptInstance = g_pScriptVM->RegisterInstance( this );
|
||||
}
|
||||
|
||||
// CGrameTrace stuff
|
||||
bool DidHitWorld() const { return m_tr.DidHitWorld(); }
|
||||
bool DidHitNonWorldEntity() const { return m_tr.DidHitNonWorldEntity(); }
|
||||
int GetEntityIndex() const { return m_tr.GetEntityIndex(); }
|
||||
bool DidHit() const { return m_tr.DidHit(); }
|
||||
~CScriptGameTrace()
|
||||
{
|
||||
if ( m_hScriptInstance )
|
||||
{
|
||||
g_pScriptVM->RemoveInstance( m_hScriptInstance );
|
||||
}
|
||||
|
||||
float FractionLeftSolid() const { return m_tr.fractionleftsolid; }
|
||||
int HitGroup() const { return m_tr.hitgroup; }
|
||||
int PhysicsBone() const { return m_tr.physicsbone; }
|
||||
if ( m_surfaceAccessor )
|
||||
{
|
||||
g_pScriptVM->RemoveInstance( m_surfaceAccessor );
|
||||
}
|
||||
|
||||
HSCRIPT Entity() const { return ToHScript(m_tr.m_pEnt); }
|
||||
if ( m_planeAccessor )
|
||||
{
|
||||
g_pScriptVM->RemoveInstance( m_planeAccessor );
|
||||
}
|
||||
}
|
||||
|
||||
int HitBox() const { return m_tr.hitbox; }
|
||||
void RegisterSurface()
|
||||
{
|
||||
m_surfaceHelper.Init( &surface );
|
||||
m_surfaceAccessor = g_pScriptVM->RegisterInstance( &m_surfaceHelper );
|
||||
}
|
||||
|
||||
// CBaseTrace stuff
|
||||
bool IsDispSurface() { return m_tr.IsDispSurface(); }
|
||||
bool IsDispSurfaceWalkable() { return m_tr.IsDispSurfaceWalkable(); }
|
||||
bool IsDispSurfaceBuildable() { return m_tr.IsDispSurfaceBuildable(); }
|
||||
bool IsDispSurfaceProp1() { return m_tr.IsDispSurfaceProp1(); }
|
||||
bool IsDispSurfaceProp2() { return m_tr.IsDispSurfaceProp2(); }
|
||||
void RegisterPlane()
|
||||
{
|
||||
m_planeAccessor = g_pScriptVM->RegisterInstance( &plane );
|
||||
}
|
||||
|
||||
const Vector& StartPos() const { return m_tr.startpos; }
|
||||
const Vector& EndPos() const { return m_tr.endpos; }
|
||||
HSCRIPT GetScriptInstance() const
|
||||
{
|
||||
return m_hScriptInstance;
|
||||
}
|
||||
|
||||
float Fraction() const { return m_tr.fraction; }
|
||||
public:
|
||||
float FractionLeftSolid() const { return fractionleftsolid; }
|
||||
int HitGroup() const { return hitgroup; }
|
||||
int PhysicsBone() const { return physicsbone; }
|
||||
|
||||
int Contents() const { return m_tr.contents; }
|
||||
int DispFlags() const { return m_tr.dispFlags; }
|
||||
HSCRIPT Entity() const { return ToHScript( m_pEnt ); }
|
||||
int HitBox() const { return hitbox; }
|
||||
|
||||
bool AllSolid() const { return m_tr.allsolid; }
|
||||
bool StartSolid() const { return m_tr.startsolid; }
|
||||
const Vector& StartPos() const { return startpos; }
|
||||
const Vector& EndPos() const { return endpos; }
|
||||
|
||||
HSCRIPT Surface() { return m_surfaceAccessor; }
|
||||
void SetSurface( HSCRIPT hSurfAccessor ) { m_surfaceAccessor = hSurfAccessor; }
|
||||
float Fraction() const { return fraction; }
|
||||
|
||||
HSCRIPT Plane() { return m_planeAccessor; }
|
||||
void SetPlane( HSCRIPT hPlaneAccessor ) { m_planeAccessor = hPlaneAccessor; }
|
||||
int Contents() const { return contents; }
|
||||
int DispFlags() const { return dispFlags; }
|
||||
|
||||
trace_t &GetTrace() { return m_tr; }
|
||||
void Destroy() { delete this; }
|
||||
bool AllSolid() const { return allsolid; }
|
||||
bool StartSolid() const { return startsolid; }
|
||||
|
||||
HSCRIPT Surface() const { return m_surfaceAccessor; }
|
||||
HSCRIPT Plane() const { return m_planeAccessor; }
|
||||
|
||||
void Destroy() { delete this; }
|
||||
|
||||
private:
|
||||
trace_t m_tr;
|
||||
|
||||
HSCRIPT m_surfaceAccessor;
|
||||
HSCRIPT m_planeAccessor;
|
||||
HSCRIPT m_hScriptInstance;
|
||||
|
||||
CSurfaceScriptHelper m_surfaceHelper;
|
||||
|
||||
CScriptGameTrace( const CScriptGameTrace& v );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -1263,9 +1263,88 @@ CNetMsgScriptHelper *g_ScriptNetMsg = &scriptnetmsg;
|
||||
#define DLL_LOC_STR "[Client]"
|
||||
#endif
|
||||
|
||||
#ifdef GAME_DLL
|
||||
#define SCRIPT_NETMSG_WRITE_FUNC
|
||||
#else
|
||||
#define SCRIPT_NETMSG_WRITE_FUNC if ( m_bWriteIgnore ) { return; }
|
||||
#endif
|
||||
|
||||
#ifdef _DEBUG
|
||||
#ifdef GAME_DLL
|
||||
#define DebugNetMsg( l, ... ) do { extern ConVar developer; if (developer.GetInt() >= l) ConColorMsg( Color(100, 225, 255, 255), __VA_ARGS__ ); } while (0);
|
||||
#else
|
||||
#define DebugNetMsg( l, ... ) do { extern ConVar developer; if (developer.GetInt() >= l) ConColorMsg( Color(100, 225, 175, 255), __VA_ARGS__ ); } while (0);
|
||||
#endif
|
||||
#define DebugWarning(...) Warning( __VA_ARGS__ )
|
||||
#else
|
||||
#define DebugNetMsg(...) (void)(0)
|
||||
#define DebugWarning(...) (void)(0)
|
||||
#endif
|
||||
|
||||
|
||||
// Keep track of message names to print on failure
|
||||
#ifdef _DEBUG
|
||||
struct NetMsgHook_t
|
||||
{
|
||||
void Set( const char *s )
|
||||
{
|
||||
hash = CNetMsgScriptHelper::Hash( s );
|
||||
name = strdup(s);
|
||||
}
|
||||
|
||||
~NetMsgHook_t()
|
||||
{
|
||||
free( name );
|
||||
}
|
||||
|
||||
int hash;
|
||||
char *name;
|
||||
};
|
||||
|
||||
CUtlVector< NetMsgHook_t > g_NetMsgHooks;
|
||||
|
||||
static const char *GetNetMsgName( int hash )
|
||||
{
|
||||
FOR_EACH_VEC( g_NetMsgHooks, i )
|
||||
{
|
||||
if ( g_NetMsgHooks[i].hash == hash )
|
||||
return g_NetMsgHooks[i].name;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char *HasNetMsgCollision( int hash, const char *ignore )
|
||||
{
|
||||
FOR_EACH_VEC( g_NetMsgHooks, i )
|
||||
{
|
||||
if ( g_NetMsgHooks[i].hash == hash && V_strcmp( g_NetMsgHooks[i].name, ignore ) != 0 )
|
||||
{
|
||||
return g_NetMsgHooks[i].name;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif // _DEBUG
|
||||
|
||||
|
||||
|
||||
inline int CNetMsgScriptHelper::Hash( const char *key )
|
||||
{
|
||||
int hash = HashStringCaseless( key );
|
||||
Assert( hash < (1 << SCRIPT_NETMSG_HEADER_BITS) );
|
||||
return hash;
|
||||
}
|
||||
|
||||
void CNetMsgScriptHelper::WriteToBuffer( bf_write *bf )
|
||||
{
|
||||
#ifdef CLIENT_DLL
|
||||
Assert( m_nQueueCount < ( 1 << SCRIPT_NETMSG_QUEUE_BITS ) );
|
||||
bf->WriteUBitLong( m_nQueueCount, SCRIPT_NETMSG_QUEUE_BITS );
|
||||
|
||||
DebugNetMsg( 2, DLL_LOC_STR " CNetMsgScriptHelper::WriteToBuffer() count(%d) size(%d)\n",
|
||||
m_nQueueCount, m_MsgOut.GetNumBitsWritten() + SCRIPT_NETMSG_QUEUE_BITS );
|
||||
#endif
|
||||
|
||||
bf->WriteBits( m_MsgOut.GetData(), m_MsgOut.GetNumBitsWritten() );
|
||||
}
|
||||
|
||||
@ -1278,8 +1357,7 @@ void CNetMsgScriptHelper::Reset()
|
||||
#ifdef GAME_DLL
|
||||
m_filter.Reset();
|
||||
#else
|
||||
m_MsgIn_()Reset();
|
||||
m_bWriteReady = false;
|
||||
m_iLastBit = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1291,9 +1369,6 @@ void CNetMsgScriptHelper::InitPostVM()
|
||||
{
|
||||
ScriptVariant_t hHooks;
|
||||
g_pScriptVM->CreateTable( hHooks );
|
||||
#if _DEBUG
|
||||
g_pScriptVM->SetValue( NULL, "__NetMsg_hooks", hHooks );
|
||||
#endif
|
||||
m_Hooks = (HSCRIPT)hHooks;
|
||||
}
|
||||
|
||||
@ -1301,10 +1376,19 @@ void CNetMsgScriptHelper::LevelShutdownPreVM()
|
||||
{
|
||||
Reset();
|
||||
if ( m_Hooks )
|
||||
{
|
||||
g_pScriptVM->ReleaseScript( m_Hooks );
|
||||
}
|
||||
m_Hooks = NULL;
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
m_bWriteReady = m_bWriteIgnore = false;
|
||||
m_MsgIn.Reset();
|
||||
#else
|
||||
m_MsgIn = NULL;
|
||||
#endif
|
||||
|
||||
#ifdef _DEBUG
|
||||
g_NetMsgHooks.Purge();
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
@ -1338,7 +1422,7 @@ void CNetMsgScriptHelper::ReceiveMessage( bf_read &msg )
|
||||
m_MsgIn.StartReading( msg.m_pData, msg.m_nDataBytes );
|
||||
#endif
|
||||
|
||||
word hash = m_MsgIn_()ReadWord();
|
||||
DebugNetMsg( 2, DLL_LOC_STR " " __FUNCTION__ "()\n" );
|
||||
|
||||
// Don't do anything if there's no VM here. This can happen if a message from the server goes to a VM-less client, or vice versa.
|
||||
if ( !g_pScriptVM )
|
||||
@ -1347,22 +1431,42 @@ void CNetMsgScriptHelper::ReceiveMessage( bf_read &msg )
|
||||
return;
|
||||
}
|
||||
|
||||
ScriptVariant_t hfn;
|
||||
if ( g_pScriptVM->GetValue( m_Hooks, hash, &hfn ) )
|
||||
{
|
||||
#ifdef GAME_DLL
|
||||
if ( g_pScriptVM->Call( hfn, NULL, true, NULL, pPlayer->m_hScriptInstance ) == SCRIPT_ERROR )
|
||||
#else
|
||||
if ( g_pScriptVM->ExecuteFunction( hfn, NULL, 0, NULL, NULL, true ) == SCRIPT_ERROR )
|
||||
int count = m_MsgIn_()ReadUBitLong( SCRIPT_NETMSG_QUEUE_BITS );
|
||||
DebugNetMsg( 2, " msg count %d\n", count );
|
||||
while ( count-- )
|
||||
#endif
|
||||
{
|
||||
DevWarning( 2, DLL_LOC_STR " NetMsg: invalid callback [%d]\n", hash );
|
||||
}
|
||||
g_pScriptVM->ReleaseValue( hfn );
|
||||
}
|
||||
else
|
||||
{
|
||||
DevWarning( 2, DLL_LOC_STR " NetMsg hook not found [%d]\n", hash );
|
||||
int hash = m_MsgIn_()ReadWord();
|
||||
|
||||
#ifdef _DEBUG
|
||||
const char *msgName = GetNetMsgName( hash );
|
||||
DebugNetMsg( 2, " -- begin msg [%d]%s\n", hash, msgName );
|
||||
#endif
|
||||
|
||||
ScriptVariant_t hfn;
|
||||
if ( g_pScriptVM->GetValue( m_Hooks, hash, &hfn ) )
|
||||
{
|
||||
#ifdef GAME_DLL
|
||||
if ( g_pScriptVM->Call( hfn, NULL, true, NULL, pPlayer->m_hScriptInstance ) == SCRIPT_ERROR )
|
||||
#else
|
||||
if ( g_pScriptVM->ExecuteFunction( hfn, NULL, 0, NULL, NULL, true ) == SCRIPT_ERROR )
|
||||
#endif
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
DevWarning( 1, DLL_LOC_STR " NetMsg: invalid callback '%s'\n", GetNetMsgName( hash ) );
|
||||
#else
|
||||
DevWarning( 1, DLL_LOC_STR " NetMsg: invalid callback [%d]\n", hash );
|
||||
#endif
|
||||
}
|
||||
g_pScriptVM->ReleaseValue( hfn );
|
||||
}
|
||||
else
|
||||
{
|
||||
DevWarning( 1, DLL_LOC_STR " NetMsg hook not found [%d]\n", hash );
|
||||
}
|
||||
|
||||
DebugNetMsg( 2, " -- end msg\n" );
|
||||
}
|
||||
}
|
||||
|
||||
@ -1371,18 +1475,50 @@ void CNetMsgScriptHelper::ReceiveMessage( bf_read &msg )
|
||||
//-----------------------------------------------------------------------------
|
||||
void CNetMsgScriptHelper::Start( const char *msg )
|
||||
{
|
||||
if ( !msg || !msg[0] )
|
||||
{
|
||||
g_pScriptVM->RaiseException( DLL_LOC_STR "NetMsg: invalid message name" );
|
||||
return;
|
||||
}
|
||||
|
||||
DebugNetMsg( 1, DLL_LOC_STR " " __FUNCTION__ "() [%d]%s\n", Hash( msg ), msg );
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
// Client can write multiple messages in a frame before the usercmd is sent,
|
||||
// this queue system ensures client messages are written to the cmd all at once.
|
||||
// NOTE: All messages share the same buffer.
|
||||
if ( !m_bWriteReady )
|
||||
{
|
||||
Reset();
|
||||
m_nQueueCount = 0;
|
||||
m_bWriteIgnore = false;
|
||||
}
|
||||
else if ( m_nQueueCount == ((1<<SCRIPT_NETMSG_QUEUE_BITS)-1) )
|
||||
{
|
||||
Warning( DLL_LOC_STR " NetMsg queue is full, cannot write '%s'!\n", msg );
|
||||
|
||||
m_bWriteIgnore = true;
|
||||
return;
|
||||
}
|
||||
|
||||
++m_nQueueCount;
|
||||
#else
|
||||
Reset();
|
||||
m_MsgOut.WriteWord( HashStringCaseless(msg) );
|
||||
#endif
|
||||
|
||||
m_MsgOut.WriteWord( Hash( msg ) );
|
||||
}
|
||||
|
||||
#ifdef GAME_DLL
|
||||
//-----------------------------------------------------------------------------
|
||||
// server -> client
|
||||
//
|
||||
// Sends an exclusive usermessage.
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifdef GAME_DLL
|
||||
void CNetMsgScriptHelper::Send( HSCRIPT player, bool bReliable )
|
||||
{
|
||||
DebugNetMsg( 1, DLL_LOC_STR " " __FUNCTION__ "() size(%d)\n", GetNumBitsWritten() );
|
||||
|
||||
CBaseEntity *pPlayer = ToEnt(player);
|
||||
if ( pPlayer )
|
||||
{
|
||||
@ -1406,6 +1542,8 @@ void CNetMsgScriptHelper::Send( HSCRIPT player, bool bReliable )
|
||||
//-----------------------------------------------------------------------------
|
||||
void CNetMsgScriptHelper::Send()
|
||||
{
|
||||
DebugNetMsg( 1, DLL_LOC_STR " " __FUNCTION__ "() size(%d)\n", m_bWriteIgnore ? 0 : GetNumBitsWritten() );
|
||||
|
||||
m_bWriteReady = true;
|
||||
}
|
||||
#endif
|
||||
@ -1415,10 +1553,30 @@ void CNetMsgScriptHelper::Send()
|
||||
//-----------------------------------------------------------------------------
|
||||
void CNetMsgScriptHelper::Receive( const char *msg, HSCRIPT func )
|
||||
{
|
||||
if ( !msg || !msg[0] )
|
||||
{
|
||||
g_pScriptVM->RaiseException( DLL_LOC_STR "NetMsg: invalid message name" );
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
int hash = Hash( msg );
|
||||
|
||||
const char *psz = HasNetMsgCollision( hash, msg );
|
||||
AssertMsg3( !psz, DLL_LOC_STR " NetMsg hash collision! [%d] '%s', '%s'\n", hash, msg, psz );
|
||||
|
||||
NetMsgHook_t &hook = g_NetMsgHooks[ g_NetMsgHooks.AddToTail() ];
|
||||
hook.Set( msg );
|
||||
#endif
|
||||
|
||||
if ( func )
|
||||
g_pScriptVM->SetValue( m_Hooks, int( HashStringCaseless(msg) ), func );
|
||||
{
|
||||
g_pScriptVM->SetValue( m_Hooks, Hash( msg ), func );
|
||||
}
|
||||
else
|
||||
g_pScriptVM->ClearValue( m_Hooks, int( HashStringCaseless(msg) ) );
|
||||
{
|
||||
g_pScriptVM->ClearValue( m_Hooks, Hash( msg ) );
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef GAME_DLL
|
||||
@ -1485,114 +1643,109 @@ void CNetMsgScriptHelper::DispatchUserMessage( const char *msg )
|
||||
}
|
||||
#endif // GAME_DLL
|
||||
|
||||
#ifdef GAME_DLL
|
||||
void CNetMsgScriptHelper::AddRecipient( HSCRIPT player )
|
||||
{
|
||||
CBaseEntity *pPlayer = ToEnt(player);
|
||||
if ( pPlayer )
|
||||
{
|
||||
m_filter.AddRecipient( (CBasePlayer*)pPlayer );
|
||||
}
|
||||
}
|
||||
|
||||
void CNetMsgScriptHelper::AddRecipientsByPVS( const Vector &pos )
|
||||
{
|
||||
m_filter.AddRecipientsByPVS(pos);
|
||||
}
|
||||
|
||||
void CNetMsgScriptHelper::AddRecipientsByPAS( const Vector &pos )
|
||||
{
|
||||
m_filter.AddRecipientsByPAS(pos);
|
||||
}
|
||||
|
||||
void CNetMsgScriptHelper::AddAllPlayers()
|
||||
{
|
||||
m_filter.AddAllPlayers();
|
||||
}
|
||||
#endif // GAME_DLL
|
||||
|
||||
void CNetMsgScriptHelper::WriteInt( int iValue, int bits )
|
||||
{
|
||||
SCRIPT_NETMSG_WRITE_FUNC
|
||||
m_MsgOut.WriteSBitLong( iValue, bits );
|
||||
}
|
||||
|
||||
void CNetMsgScriptHelper::WriteUInt( int iValue, int bits )
|
||||
{
|
||||
SCRIPT_NETMSG_WRITE_FUNC
|
||||
m_MsgOut.WriteUBitLong( iValue, bits );
|
||||
}
|
||||
|
||||
void CNetMsgScriptHelper::WriteByte( int iValue )
|
||||
{
|
||||
SCRIPT_NETMSG_WRITE_FUNC
|
||||
m_MsgOut.WriteByte( iValue );
|
||||
}
|
||||
|
||||
void CNetMsgScriptHelper::WriteChar( int iValue )
|
||||
{
|
||||
SCRIPT_NETMSG_WRITE_FUNC
|
||||
m_MsgOut.WriteChar( iValue );
|
||||
}
|
||||
|
||||
void CNetMsgScriptHelper::WriteShort( int iValue )
|
||||
{
|
||||
SCRIPT_NETMSG_WRITE_FUNC
|
||||
m_MsgOut.WriteShort( iValue );
|
||||
}
|
||||
|
||||
void CNetMsgScriptHelper::WriteWord( int iValue )
|
||||
{
|
||||
SCRIPT_NETMSG_WRITE_FUNC
|
||||
m_MsgOut.WriteWord( iValue );
|
||||
}
|
||||
|
||||
void CNetMsgScriptHelper::WriteLong( int iValue )
|
||||
{
|
||||
SCRIPT_NETMSG_WRITE_FUNC
|
||||
m_MsgOut.WriteLong( iValue );
|
||||
}
|
||||
|
||||
void CNetMsgScriptHelper::WriteFloat( float flValue )
|
||||
{
|
||||
SCRIPT_NETMSG_WRITE_FUNC
|
||||
m_MsgOut.WriteFloat( flValue );
|
||||
}
|
||||
|
||||
void CNetMsgScriptHelper::WriteNormal( float flValue )
|
||||
{
|
||||
SCRIPT_NETMSG_WRITE_FUNC
|
||||
m_MsgOut.WriteBitNormal( flValue );
|
||||
}
|
||||
|
||||
void CNetMsgScriptHelper::WriteAngle( float flValue )
|
||||
{
|
||||
SCRIPT_NETMSG_WRITE_FUNC
|
||||
m_MsgOut.WriteBitAngle( flValue, 8 );
|
||||
}
|
||||
|
||||
void CNetMsgScriptHelper::WriteCoord( float flValue )
|
||||
{
|
||||
SCRIPT_NETMSG_WRITE_FUNC
|
||||
m_MsgOut.WriteBitCoord( flValue );
|
||||
}
|
||||
|
||||
void CNetMsgScriptHelper::WriteVec3Coord( const Vector& rgflValue )
|
||||
{
|
||||
SCRIPT_NETMSG_WRITE_FUNC
|
||||
m_MsgOut.WriteBitVec3Coord( rgflValue );
|
||||
}
|
||||
|
||||
void CNetMsgScriptHelper::WriteVec3Normal( const Vector& rgflValue )
|
||||
{
|
||||
SCRIPT_NETMSG_WRITE_FUNC
|
||||
m_MsgOut.WriteBitVec3Normal( rgflValue );
|
||||
}
|
||||
|
||||
void CNetMsgScriptHelper::WriteAngles( const QAngle& rgflValue )
|
||||
{
|
||||
SCRIPT_NETMSG_WRITE_FUNC
|
||||
m_MsgOut.WriteBitAngles( rgflValue );
|
||||
}
|
||||
|
||||
void CNetMsgScriptHelper::WriteString( const char *sz )
|
||||
{
|
||||
SCRIPT_NETMSG_WRITE_FUNC
|
||||
|
||||
// Larger strings can be written but cannot be read
|
||||
Assert( V_strlen(sz) < SCRIPT_NETMSG_STRING_SIZE );
|
||||
|
||||
m_MsgOut.WriteString( sz );
|
||||
}
|
||||
|
||||
void CNetMsgScriptHelper::WriteBool( bool bValue )
|
||||
{
|
||||
SCRIPT_NETMSG_WRITE_FUNC
|
||||
m_MsgOut.WriteOneBit( bValue ? 1 : 0 );
|
||||
}
|
||||
|
||||
void CNetMsgScriptHelper::WriteEntity( HSCRIPT hEnt )
|
||||
{
|
||||
SCRIPT_NETMSG_WRITE_FUNC
|
||||
CBaseEntity *p = ToEnt(hEnt);
|
||||
int i = p ? p->entindex() : -1;
|
||||
m_MsgOut.WriteSBitLong( i, MAX_EDICT_BITS );
|
||||
@ -1600,6 +1753,7 @@ void CNetMsgScriptHelper::WriteEntity( HSCRIPT hEnt )
|
||||
|
||||
void CNetMsgScriptHelper::WriteEHandle( HSCRIPT hEnt )
|
||||
{
|
||||
SCRIPT_NETMSG_WRITE_FUNC
|
||||
CBaseEntity *pEnt = ToEnt( hEnt );
|
||||
long iEncodedEHandle;
|
||||
if ( pEnt )
|
||||
@ -1673,7 +1827,6 @@ float CNetMsgScriptHelper::ReadCoord()
|
||||
const Vector& CNetMsgScriptHelper::ReadVec3Coord()
|
||||
{
|
||||
static Vector vec3;
|
||||
//vec3.Init();
|
||||
m_MsgIn_()ReadBitVec3Coord(vec3);
|
||||
return vec3;
|
||||
}
|
||||
@ -1681,7 +1834,6 @@ const Vector& CNetMsgScriptHelper::ReadVec3Coord()
|
||||
const Vector& CNetMsgScriptHelper::ReadVec3Normal()
|
||||
{
|
||||
static Vector vec3;
|
||||
//vec3.Init();
|
||||
m_MsgIn_()ReadBitVec3Normal(vec3);
|
||||
return vec3;
|
||||
}
|
||||
@ -1689,14 +1841,13 @@ const Vector& CNetMsgScriptHelper::ReadVec3Normal()
|
||||
const QAngle& CNetMsgScriptHelper::ReadAngles()
|
||||
{
|
||||
static QAngle vec3;
|
||||
//vec3.Init();
|
||||
m_MsgIn_()ReadBitAngles(vec3);
|
||||
return vec3;
|
||||
}
|
||||
|
||||
const char* CNetMsgScriptHelper::ReadString()
|
||||
{
|
||||
static char buf[512];
|
||||
static char buf[ SCRIPT_NETMSG_STRING_SIZE ];
|
||||
m_MsgIn_()ReadString( buf, sizeof(buf) );
|
||||
return buf;
|
||||
}
|
||||
@ -1734,23 +1885,23 @@ HSCRIPT CNetMsgScriptHelper::ReadEHandle()
|
||||
return ToHScript( EHANDLE( iEntry, iSerialNum ) );
|
||||
}
|
||||
|
||||
int CNetMsgScriptHelper::GetNumBitsWritten()
|
||||
inline int CNetMsgScriptHelper::GetNumBitsWritten()
|
||||
{
|
||||
return m_MsgOut.GetNumBitsWritten();
|
||||
#ifdef GAME_DLL
|
||||
return m_MsgOut.GetNumBitsWritten() - SCRIPT_NETMSG_HEADER_BITS;
|
||||
#else
|
||||
return m_MsgOut.m_iCurBit - m_iLastBit - SCRIPT_NETMSG_HEADER_BITS;
|
||||
#endif
|
||||
}
|
||||
|
||||
#undef m_MsgIn_
|
||||
|
||||
BEGIN_SCRIPTDESC_ROOT_NAMED( CNetMsgScriptHelper, "CNetMsg", SCRIPT_SINGLETON "Network messages" )
|
||||
|
||||
#ifdef GAME_DLL
|
||||
DEFINE_SCRIPTFUNC( SendUserMessage, "Send a usermessage from the server to the client" )
|
||||
DEFINE_SCRIPTFUNC( SendEntityMessage, "Send a message from a server side entity to its client side counterpart" )
|
||||
DEFINE_SCRIPTFUNC( AddRecipient, "" )
|
||||
//DEFINE_SCRIPTFUNC( RemoveRecipient, "" )
|
||||
DEFINE_SCRIPTFUNC( AddRecipientsByPVS, "" )
|
||||
DEFINE_SCRIPTFUNC( AddRecipientsByPAS, "" )
|
||||
DEFINE_SCRIPTFUNC( AddAllPlayers, "" )
|
||||
|
||||
// TODO: multiplayer
|
||||
#else
|
||||
DEFINE_SCRIPTFUNC( DispatchUserMessage, "Dispatch a usermessage on client" )
|
||||
#endif
|
||||
@ -1762,7 +1913,7 @@ BEGIN_SCRIPTDESC_ROOT_NAMED( CNetMsgScriptHelper, "CNetMsg", SCRIPT_SINGLETON "N
|
||||
#ifdef GAME_DLL
|
||||
DEFINE_SCRIPTFUNC( Send, "Send a custom network message from the server to the client (max 252 bytes)" )
|
||||
#else
|
||||
DEFINE_SCRIPTFUNC( Send, "Send a custom network message from the client to the server (max 2045 bytes)" )
|
||||
DEFINE_SCRIPTFUNC( Send, "Send a custom network message from the client to the server (max 2044 bytes)" )
|
||||
#endif
|
||||
|
||||
DEFINE_SCRIPTFUNC( WriteInt, "variable bit signed int" )
|
||||
@ -1779,7 +1930,7 @@ BEGIN_SCRIPTDESC_ROOT_NAMED( CNetMsgScriptHelper, "CNetMsg", SCRIPT_SINGLETON "N
|
||||
DEFINE_SCRIPTFUNC( WriteVec3Coord, "" )
|
||||
DEFINE_SCRIPTFUNC( WriteVec3Normal, "27 bit" )
|
||||
DEFINE_SCRIPTFUNC( WriteAngles, "" )
|
||||
DEFINE_SCRIPTFUNC( WriteString, "" )
|
||||
DEFINE_SCRIPTFUNC( WriteString, "max 512 bytes at once" )
|
||||
DEFINE_SCRIPTFUNC( WriteBool, "1 bit" )
|
||||
DEFINE_SCRIPTFUNC( WriteEntity, "11 bit (entindex)" )
|
||||
DEFINE_SCRIPTFUNC( WriteEHandle, "32 bit long" )
|
||||
@ -1798,7 +1949,7 @@ BEGIN_SCRIPTDESC_ROOT_NAMED( CNetMsgScriptHelper, "CNetMsg", SCRIPT_SINGLETON "N
|
||||
DEFINE_SCRIPTFUNC( ReadVec3Coord, "" )
|
||||
DEFINE_SCRIPTFUNC( ReadVec3Normal, "" )
|
||||
DEFINE_SCRIPTFUNC( ReadAngles, "" )
|
||||
DEFINE_SCRIPTFUNC( ReadString, "max 512 bytes at once" )
|
||||
DEFINE_SCRIPTFUNC( ReadString, "" )
|
||||
DEFINE_SCRIPTFUNC( ReadBool, "" )
|
||||
DEFINE_SCRIPTFUNC( ReadEntity, "" )
|
||||
DEFINE_SCRIPTFUNC( ReadEHandle, "" )
|
||||
@ -2290,9 +2441,18 @@ public:
|
||||
{
|
||||
if ( val.m_type == FIELD_CSTRING )
|
||||
{
|
||||
CUtlString s = val.m_pszString;
|
||||
//s.SetLength( COMMAND_COMPLETION_ITEM_LENGTH - 1 );
|
||||
commands.AddToTail( s );
|
||||
CUtlString &s = commands.Element( commands.AddToTail() );
|
||||
int len = V_strlen( val.m_pszString );
|
||||
|
||||
if ( len <= COMMAND_COMPLETION_ITEM_LENGTH - 1 )
|
||||
{
|
||||
s.Set( val.m_pszString );
|
||||
}
|
||||
else
|
||||
{
|
||||
s.SetDirect( val.m_pszString, COMMAND_COMPLETION_ITEM_LENGTH - 1 );
|
||||
}
|
||||
|
||||
++count;
|
||||
}
|
||||
g_pScriptVM->ReleaseValue(val);
|
||||
@ -3008,6 +3168,23 @@ END_SCRIPTDESC();
|
||||
class CScriptSteamAPI
|
||||
{
|
||||
public:
|
||||
const char *GetSteam2ID()
|
||||
{
|
||||
if ( !steamapicontext || !steamapicontext->SteamUser() )
|
||||
return NULL;
|
||||
|
||||
CSteamID id = steamapicontext->SteamUser()->GetSteamID();
|
||||
|
||||
uint32 accountID = id.GetAccountID();
|
||||
uint32 steamInstanceID = 0;
|
||||
uint32 high32bits = accountID % 2;
|
||||
uint32 low32bits = accountID / 2;
|
||||
|
||||
static char ret[48];
|
||||
V_snprintf( ret, sizeof(ret), "STEAM_%u:%u:%u", steamInstanceID, high32bits, low32bits );
|
||||
return ret;
|
||||
}
|
||||
|
||||
int GetSecondsSinceComputerActive()
|
||||
{
|
||||
if ( !steamapicontext || !steamapicontext->SteamUtils() )
|
||||
@ -3023,7 +3200,7 @@ public:
|
||||
|
||||
return steamapicontext->SteamUtils()->GetCurrentBatteryPower();
|
||||
}
|
||||
|
||||
#if 0
|
||||
const char *GetIPCountry()
|
||||
{
|
||||
if ( !steamapicontext || !steamapicontext->SteamUtils() )
|
||||
@ -3038,7 +3215,7 @@ public:
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
||||
const char *GetCurrentGameLanguage()
|
||||
{
|
||||
if ( !steamapicontext || !steamapicontext->SteamApps() )
|
||||
@ -3057,6 +3234,7 @@ public:
|
||||
} g_ScriptSteamAPI;
|
||||
|
||||
BEGIN_SCRIPTDESC_ROOT_NAMED( CScriptSteamAPI, "CSteamAPI", SCRIPT_SINGLETON "" )
|
||||
DEFINE_SCRIPTFUNC( GetSteam2ID, "" )
|
||||
//DEFINE_SCRIPTFUNC( IsVACBanned, "" )
|
||||
DEFINE_SCRIPTFUNC( GetSecondsSinceComputerActive, "Returns the number of seconds since the user last moved the mouse." )
|
||||
DEFINE_SCRIPTFUNC( GetCurrentBatteryPower, "Return the amount of battery power left in the current system in % [0..100], 255 for being on AC power" )
|
||||
|
@ -17,12 +17,17 @@ void RegisterScriptSingletons();
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
// usercmd
|
||||
#define SCRIPT_NETMSG_DATA_SIZE ( ( 1 << 11 ) - 1 )
|
||||
#define SCRIPT_NETMSG_DATA_SIZE ( ( 1 << 11 ) - 1 )
|
||||
#else
|
||||
// usermsg
|
||||
#define SCRIPT_NETMSG_DATA_SIZE MAX_USER_MSG_DATA
|
||||
#define SCRIPT_NETMSG_DATA_SIZE MAX_USER_MSG_DATA
|
||||
#endif
|
||||
|
||||
#define SCRIPT_NETMSG_QUEUE_BITS 3 // determines the number of custom messages client can write to a usercmd
|
||||
#define SCRIPT_NETMSG_HEADER_BITS (sizeof(word) << 3)
|
||||
#define SCRIPT_NETMSG_STRING_SIZE 512
|
||||
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
class CNetMsgScriptHelper : public CAutoGameSystem
|
||||
#else
|
||||
@ -40,18 +45,28 @@ private:
|
||||
CRecipientFilter m_filter;
|
||||
#else
|
||||
bf_read m_MsgIn;
|
||||
unsigned int m_nQueueCount;
|
||||
bool m_bWriteIgnore;
|
||||
#endif
|
||||
HSCRIPT m_Hooks;
|
||||
bf_write m_MsgOut;
|
||||
byte m_MsgData[ PAD_NUMBER( SCRIPT_NETMSG_DATA_SIZE, 4 ) ];
|
||||
|
||||
public:
|
||||
#ifdef CLIENT_DLL
|
||||
CNetMsgScriptHelper() : m_Hooks(NULL), m_bWriteReady(false) {}
|
||||
#else
|
||||
CNetMsgScriptHelper() : m_Hooks(NULL) {}
|
||||
int m_iLastBit;
|
||||
#endif
|
||||
|
||||
public:
|
||||
CNetMsgScriptHelper() : m_Hooks(NULL)
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
, m_bWriteReady(0), m_bWriteIgnore(0), m_nQueueCount(0), m_iLastBit(0)
|
||||
#else
|
||||
, m_MsgIn(0)
|
||||
#endif
|
||||
|
||||
{}
|
||||
|
||||
public:
|
||||
#ifdef CLIENT_DLL
|
||||
bool Init(); // IGameSystem
|
||||
@ -87,14 +102,6 @@ public:
|
||||
void DispatchUserMessage( const char *msg );
|
||||
#endif
|
||||
|
||||
#ifdef GAME_DLL
|
||||
public:
|
||||
void AddRecipient( HSCRIPT player );
|
||||
void AddRecipientsByPVS( const Vector &pos );
|
||||
void AddRecipientsByPAS( const Vector &pos );
|
||||
void AddAllPlayers();
|
||||
#endif // GAME_DLL
|
||||
|
||||
public:
|
||||
void WriteInt( int iValue, int bits );
|
||||
void WriteUInt( int iValue, int bits );
|
||||
@ -135,6 +142,8 @@ public:
|
||||
//int GetNumBitsLeft(); // unreliable on server because of usercmds. so just do away with it
|
||||
int GetNumBitsWritten();
|
||||
|
||||
public:
|
||||
static inline int Hash( const char *key );
|
||||
};
|
||||
|
||||
extern CNetMsgScriptHelper *g_ScriptNetMsg;
|
||||
|
@ -170,12 +170,22 @@ bool VScriptRunScript( const char *pszScriptName, HSCRIPT hScope, bool bWarnMiss
|
||||
return bSuccess;
|
||||
}
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
CON_COMMAND( script_client, "Run the text as a script" )
|
||||
|
||||
#ifdef GAME_DLL
|
||||
#define IsCommandIssuedByServerAdmin() UTIL_IsCommandIssuedByServerAdmin()
|
||||
#else
|
||||
CON_COMMAND( script, "Run the text as a script" )
|
||||
#define IsCommandIssuedByServerAdmin() true
|
||||
#endif
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
CON_COMMAND_F( script_client, "Run the text as a script", FCVAR_CHEAT )
|
||||
#else
|
||||
CON_COMMAND_F( script, "Run the text as a script", FCVAR_CHEAT )
|
||||
#endif
|
||||
{
|
||||
if ( !IsCommandIssuedByServerAdmin() )
|
||||
return;
|
||||
|
||||
if ( !*args[1] )
|
||||
{
|
||||
CGWarning( 0, CON_GROUP_VSCRIPT, "No function name specified\n" );
|
||||
@ -228,9 +238,15 @@ CON_COMMAND( script, "Run the text as a script" )
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CON_COMMAND_SHARED( script_execute, "Run a vscript file" )
|
||||
#ifdef CLIENT_DLL
|
||||
CON_COMMAND_F( script_execute_client, "Run a vscript file", FCVAR_CHEAT )
|
||||
#else
|
||||
CON_COMMAND_F( script_execute, "Run a vscript file", FCVAR_CHEAT )
|
||||
#endif
|
||||
{
|
||||
if ( !IsCommandIssuedByServerAdmin() )
|
||||
return;
|
||||
|
||||
if ( !*args[1] )
|
||||
{
|
||||
CGWarning( 0, CON_GROUP_VSCRIPT, "No script specified\n" );
|
||||
@ -246,8 +262,15 @@ CON_COMMAND_SHARED( script_execute, "Run a vscript file" )
|
||||
VScriptRunScript( args[1], true );
|
||||
}
|
||||
|
||||
CON_COMMAND_SHARED( script_debug, "Connect the vscript VM to the script debugger" )
|
||||
#ifdef CLIENT_DLL
|
||||
CON_COMMAND_F( script_debug_client, "Connect the vscript VM to the script debugger", FCVAR_CHEAT )
|
||||
#else
|
||||
CON_COMMAND_F( script_debug, "Connect the vscript VM to the script debugger", FCVAR_CHEAT )
|
||||
#endif
|
||||
{
|
||||
if ( !IsCommandIssuedByServerAdmin() )
|
||||
return;
|
||||
|
||||
if ( !g_pScriptVM )
|
||||
{
|
||||
CGWarning( 0, CON_GROUP_VSCRIPT, "Scripting disabled or no server running\n" );
|
||||
@ -256,8 +279,15 @@ CON_COMMAND_SHARED( script_debug, "Connect the vscript VM to the script debugger
|
||||
g_pScriptVM->ConnectDebugger();
|
||||
}
|
||||
|
||||
CON_COMMAND_SHARED( script_help, "Output help for script functions, optionally with a search string" )
|
||||
#ifdef CLIENT_DLL
|
||||
CON_COMMAND_F( script_help_client, "Output help for script functions, optionally with a search string", FCVAR_CHEAT )
|
||||
#else
|
||||
CON_COMMAND_F( script_help, "Output help for script functions, optionally with a search string", FCVAR_CHEAT )
|
||||
#endif
|
||||
{
|
||||
if ( !IsCommandIssuedByServerAdmin() )
|
||||
return;
|
||||
|
||||
if ( !g_pScriptVM )
|
||||
{
|
||||
CGWarning( 0, CON_GROUP_VSCRIPT, "Scripting disabled or no server running\n" );
|
||||
@ -272,8 +302,15 @@ CON_COMMAND_SHARED( script_help, "Output help for script functions, optionally w
|
||||
g_pScriptVM->Run( CFmtStr( "__Documentation.PrintHelp( \"%s\" );", pszArg1 ) );
|
||||
}
|
||||
|
||||
CON_COMMAND_SHARED( script_dump_all, "Dump the state of the VM to the console" )
|
||||
#ifdef CLIENT_DLL
|
||||
CON_COMMAND_F( script_dump_all_client, "Dump the state of the VM to the console", FCVAR_CHEAT )
|
||||
#else
|
||||
CON_COMMAND_F( script_dump_all, "Dump the state of the VM to the console", FCVAR_CHEAT )
|
||||
#endif
|
||||
{
|
||||
if ( !IsCommandIssuedByServerAdmin() )
|
||||
return;
|
||||
|
||||
if ( !g_pScriptVM )
|
||||
{
|
||||
CGWarning( 0, CON_GROUP_VSCRIPT, "Scripting disabled or no server running\n" );
|
||||
|
@ -1091,7 +1091,8 @@ bool CreateParamCheck(const ScriptFunctionBinding_t& func, char* output)
|
||||
switch (func.m_desc.m_Parameters[i])
|
||||
{
|
||||
case FIELD_FLOAT:
|
||||
*output++ = 'n'; // NOTE: Can be int or float
|
||||
case FIELD_INTEGER:
|
||||
*output++ = 'n';
|
||||
break;
|
||||
case FIELD_CSTRING:
|
||||
*output++ = 's';
|
||||
@ -1099,9 +1100,6 @@ bool CreateParamCheck(const ScriptFunctionBinding_t& func, char* output)
|
||||
case FIELD_VECTOR:
|
||||
*output++ = 'x'; // Generic instance, we validate on arrival
|
||||
break;
|
||||
case FIELD_INTEGER:
|
||||
*output++ = 'i'; // could use 'n' also which is int or float
|
||||
break;
|
||||
case FIELD_BOOLEAN:
|
||||
*output++ = 'b';
|
||||
break;
|
||||
@ -1701,7 +1699,9 @@ struct SquirrelSafeCheck
|
||||
|
||||
~SquirrelSafeCheck()
|
||||
{
|
||||
if (top_ != (sq_gettop(vm_) - outputCount_))
|
||||
SQInteger curtop = sq_gettop(vm_);
|
||||
SQInteger diff = curtop - outputCount_;
|
||||
if ( top_ != diff )
|
||||
{
|
||||
Assert(!"Squirrel VM stack is not consistent");
|
||||
Error("Squirrel VM stack is not consistent\n");
|
||||
@ -2354,6 +2354,8 @@ bool SquirrelVM::ScopeIsHooked( HSCRIPT hScope, const char *pszEventName )
|
||||
if (!hScope)
|
||||
return true;
|
||||
|
||||
SquirrelSafeCheck safeCheck(vm_);
|
||||
|
||||
Assert(hScope != INVALID_HSCRIPT);
|
||||
|
||||
sq_pushroottable(vm_);
|
||||
@ -2373,7 +2375,7 @@ bool SquirrelVM::ScopeIsHooked( HSCRIPT hScope, const char *pszEventName )
|
||||
return false;
|
||||
}
|
||||
|
||||
sq_pop(vm_, 3);
|
||||
sq_pop(vm_, 4);
|
||||
return val ? true : false;
|
||||
}
|
||||
|
||||
@ -2393,6 +2395,8 @@ HSCRIPT SquirrelVM::LookupHookFunction(const char *pszEventName, HSCRIPT hScope,
|
||||
if (!ScopeIsHooked(hScope, pszEventName))
|
||||
return nullptr;
|
||||
|
||||
SquirrelSafeCheck safeCheck(vm_);
|
||||
|
||||
sq_pushroottable(vm_);
|
||||
sq_pushstring(vm_, "Hooks", -1);
|
||||
sq_get(vm_, -2);
|
||||
@ -2403,7 +2407,7 @@ HSCRIPT SquirrelVM::LookupHookFunction(const char *pszEventName, HSCRIPT hScope,
|
||||
sq_resetobject(&obj);
|
||||
sq_getstackobj(vm_, -1, &obj);
|
||||
sq_addref(vm_, &obj);
|
||||
sq_pop(vm_, 2);
|
||||
sq_pop(vm_, 3);
|
||||
|
||||
HSQOBJECT* pObj = new HSQOBJECT;
|
||||
*pObj = obj;
|
||||
@ -3527,7 +3531,7 @@ void SquirrelVM::WriteObject(CUtlBuffer* pBuffer, WriteStateMap& writeState, SQI
|
||||
}
|
||||
else
|
||||
{
|
||||
Warning("SquirrelVM::WriteObject: Unable to find instanceID for object of type %s, unable to serialize\n",
|
||||
DevWarning("SquirrelVM::WriteObject: Unable to find instanceID for object of type %s, unable to serialize\n",
|
||||
pClassInstanceData->desc->m_pszClassname);
|
||||
pBuffer->PutString("");
|
||||
}
|
||||
|
@ -215,16 +215,17 @@ Hooks <-
|
||||
|
||||
function Call( scope, event, ... )
|
||||
{
|
||||
local firstReturn = null
|
||||
local firstReturn
|
||||
|
||||
if ( scope == null )
|
||||
// global hook; call all scopes
|
||||
if ( !scope )
|
||||
{
|
||||
// null scope = global hook; call all scopes
|
||||
vargv.insert(0,this)
|
||||
foreach ( t in s_List )
|
||||
vargv.insert( 0, null )
|
||||
foreach( sc,t in s_List )
|
||||
{
|
||||
if ( event in t )
|
||||
{
|
||||
vargv[0] = sc
|
||||
foreach( context, callback in t[event] )
|
||||
{
|
||||
//printf( "(%.4f) Calling hook '%s' of context '%s' in static iteration\n", Time(), event, context )
|
||||
@ -241,7 +242,7 @@ Hooks <-
|
||||
local t = s_List[scope]
|
||||
if ( event in t )
|
||||
{
|
||||
vargv.insert(0,scope)
|
||||
vargv.insert( 0, scope )
|
||||
foreach( context, callback in t[event] )
|
||||
{
|
||||
//printf( "(%.4f) Calling hook '%s' of context '%s'\n", Time(), event, context )
|
||||
@ -258,13 +259,7 @@ Hooks <-
|
||||
|
||||
function ScopeHookedToEvent( scope, event )
|
||||
{
|
||||
if ( scope in s_List )
|
||||
{
|
||||
if (event in s_List[scope])
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
return ( scope in s_List ) && ( event in s_List[scope] )
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user