mirror of
https://github.com/mapbase-source/source-sdk-2013.git
synced 2024-12-28 15:55:31 +03:00
Added CreateProp() function for VScript, allowing the creation of exclusively client-side dynamic props
This commit is contained in:
parent
4861893235
commit
55cbdf49aa
@ -24,6 +24,11 @@ BEGIN_NETWORK_TABLE( CDynamicProp, DT_DynamicProp )
|
|||||||
RecvPropBool(RECVINFO(m_bUseHitboxesForRenderBox)),
|
RecvPropBool(RECVINFO(m_bUseHitboxesForRenderBox)),
|
||||||
END_NETWORK_TABLE()
|
END_NETWORK_TABLE()
|
||||||
|
|
||||||
|
#ifdef MAPBASE_VSCRIPT
|
||||||
|
// Allows client-side VScript to create dynamic props via CreateProp()
|
||||||
|
LINK_ENTITY_TO_CLASS( prop_dynamic, C_DynamicProp );
|
||||||
|
#endif
|
||||||
|
|
||||||
C_DynamicProp::C_DynamicProp( void )
|
C_DynamicProp::C_DynamicProp( void )
|
||||||
{
|
{
|
||||||
m_iCachedFrameCount = -1;
|
m_iCachedFrameCount = -1;
|
||||||
|
@ -431,6 +431,35 @@ bool DoIncludeScript( const char *pszScript, HSCRIPT hScope )
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef MAPBASE_VSCRIPT
|
||||||
|
// Creates a client-side prop
|
||||||
|
HSCRIPT CreateProp( const char *pszEntityName, const Vector &vOrigin, const char *pszModelName, int iAnim )
|
||||||
|
{
|
||||||
|
C_BaseAnimating *pBaseEntity = (C_BaseAnimating *)CreateEntityByName( pszEntityName );
|
||||||
|
if (!pBaseEntity)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
pBaseEntity->SetAbsOrigin( vOrigin );
|
||||||
|
pBaseEntity->SetModelName( pszModelName );
|
||||||
|
if (!pBaseEntity->InitializeAsClientEntity( pszModelName, RENDER_GROUP_OPAQUE_ENTITY ))
|
||||||
|
{
|
||||||
|
Warning("Can't initialize %s as client entity\n", pszEntityName);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
pBaseEntity->SetPlaybackRate( 1.0f );
|
||||||
|
|
||||||
|
int iSequence = pBaseEntity->SelectWeightedSequence( (Activity)iAnim );
|
||||||
|
|
||||||
|
if ( iSequence != -1 )
|
||||||
|
{
|
||||||
|
pBaseEntity->SetSequence( iSequence );
|
||||||
|
}
|
||||||
|
|
||||||
|
return ToHScript( pBaseEntity );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool VScriptClientInit()
|
bool VScriptClientInit()
|
||||||
{
|
{
|
||||||
VMPROF_START
|
VMPROF_START
|
||||||
@ -494,6 +523,9 @@ bool VScriptClientInit()
|
|||||||
ScriptRegisterFunction( g_pScriptVM, GetMapName, "Get the name of the map.");
|
ScriptRegisterFunction( g_pScriptVM, GetMapName, "Get the name of the map.");
|
||||||
ScriptRegisterFunction( g_pScriptVM, Time, "Get the current server time" );
|
ScriptRegisterFunction( g_pScriptVM, Time, "Get the current server time" );
|
||||||
ScriptRegisterFunction( g_pScriptVM, DoIncludeScript, "Execute a script (internal)" );
|
ScriptRegisterFunction( g_pScriptVM, DoIncludeScript, "Execute a script (internal)" );
|
||||||
|
#ifdef MAPBASE_VSCRIPT
|
||||||
|
ScriptRegisterFunction( g_pScriptVM, CreateProp, "Create an animating prop" );
|
||||||
|
#endif
|
||||||
|
|
||||||
if ( GameRules() )
|
if ( GameRules() )
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user