mirror of
https://github.com/mapbase-source/source-sdk-2013.git
synced 2024-12-28 07:45:29 +03:00
Added a few more VScript base entity functions to the client
This commit is contained in:
parent
5e254d19c0
commit
cb7cee6283
@ -442,6 +442,7 @@ BEGIN_ENT_SCRIPTDESC_ROOT( C_BaseEntity, "Root class of all client-side entities
|
|||||||
|
|
||||||
#ifdef MAPBASE_VSCRIPT
|
#ifdef MAPBASE_VSCRIPT
|
||||||
DEFINE_SCRIPTFUNC( ValidateScriptScope, "Ensure that an entity's script scope has been created" )
|
DEFINE_SCRIPTFUNC( ValidateScriptScope, "Ensure that an entity's script scope has been created" )
|
||||||
|
DEFINE_SCRIPTFUNC( GetOrCreatePrivateScriptScope, "Create and retrieve the script-side data associated with an entity" )
|
||||||
DEFINE_SCRIPTFUNC( GetScriptScope, "Retrieve the script-side data associated with an entity" )
|
DEFINE_SCRIPTFUNC( GetScriptScope, "Retrieve the script-side data associated with an entity" )
|
||||||
|
|
||||||
DEFINE_SCRIPTFUNC( GetHealth, "" )
|
DEFINE_SCRIPTFUNC( GetHealth, "" )
|
||||||
@ -479,6 +480,7 @@ BEGIN_ENT_SCRIPTDESC_ROOT( C_BaseEntity, "Root class of all client-side entities
|
|||||||
|
|
||||||
DEFINE_SCRIPTFUNC( GetWaterLevel, "Get current level of water submergence" )
|
DEFINE_SCRIPTFUNC( GetWaterLevel, "Get current level of water submergence" )
|
||||||
|
|
||||||
|
DEFINE_SCRIPTFUNC_NAMED( ScriptSetParent, "SetParent", "" )
|
||||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetMoveParent, "GetMoveParent", "If in hierarchy, retrieves the entity's parent" )
|
DEFINE_SCRIPTFUNC_NAMED( ScriptGetMoveParent, "GetMoveParent", "If in hierarchy, retrieves the entity's parent" )
|
||||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetRootMoveParent, "GetRootMoveParent", "If in hierarchy, walks up the hierarchy to find the root parent" )
|
DEFINE_SCRIPTFUNC_NAMED( ScriptGetRootMoveParent, "GetRootMoveParent", "If in hierarchy, walks up the hierarchy to find the root parent" )
|
||||||
DEFINE_SCRIPTFUNC_NAMED( ScriptFirstMoveChild, "FirstMoveChild", "" )
|
DEFINE_SCRIPTFUNC_NAMED( ScriptFirstMoveChild, "FirstMoveChild", "" )
|
||||||
@ -489,6 +491,9 @@ BEGIN_ENT_SCRIPTDESC_ROOT( C_BaseEntity, "Root class of all client-side entities
|
|||||||
DEFINE_SCRIPTFUNC( IsFollowingEntity, "Returns true if this entity is following another entity." )
|
DEFINE_SCRIPTFUNC( IsFollowingEntity, "Returns true if this entity is following another entity." )
|
||||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetFollowedEntity, "GetFollowedEntity", "Get the entity we're following." )
|
DEFINE_SCRIPTFUNC_NAMED( ScriptGetFollowedEntity, "GetFollowedEntity", "Get the entity we're following." )
|
||||||
|
|
||||||
|
DEFINE_SCRIPTFUNC_NAMED( GetScriptOwnerEntity, "GetOwner", "Gets this entity's owner" )
|
||||||
|
DEFINE_SCRIPTFUNC_NAMED( SetScriptOwnerEntity, "SetOwner", "Sets this entity's owner" )
|
||||||
|
|
||||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetColorVector, "GetRenderColorVector", "Get the render color as a vector" )
|
DEFINE_SCRIPTFUNC_NAMED( ScriptGetColorVector, "GetRenderColorVector", "Get the render color as a vector" )
|
||||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetColorR, "GetRenderColorR", "Get the render color's R value" )
|
DEFINE_SCRIPTFUNC_NAMED( ScriptGetColorR, "GetRenderColorR", "Get the render color's R value" )
|
||||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetColorG, "GetRenderColorG", "Get the render color's G value" )
|
DEFINE_SCRIPTFUNC_NAMED( ScriptGetColorG, "GetRenderColorG", "Get the render color's G value" )
|
||||||
@ -537,6 +542,7 @@ BEGIN_ENT_SCRIPTDESC_ROOT( C_BaseEntity, "Root class of all client-side entities
|
|||||||
|
|
||||||
DEFINE_SCRIPTFUNC_NAMED( GetEntityIndex, "entindex", "" )
|
DEFINE_SCRIPTFUNC_NAMED( GetEntityIndex, "entindex", "" )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
END_SCRIPTDESC();
|
END_SCRIPTDESC();
|
||||||
|
|
||||||
#ifndef NO_ENTITY_PREDICTION
|
#ifndef NO_ENTITY_PREDICTION
|
||||||
|
@ -266,6 +266,7 @@ public:
|
|||||||
bool ValidateScriptScope();
|
bool ValidateScriptScope();
|
||||||
bool CallScriptFunction( const char* pFunctionName, ScriptVariant_t* pFunctionReturn );
|
bool CallScriptFunction( const char* pFunctionName, ScriptVariant_t* pFunctionReturn );
|
||||||
|
|
||||||
|
HSCRIPT GetOrCreatePrivateScriptScope();
|
||||||
HSCRIPT GetScriptScope() { return m_ScriptScope; }
|
HSCRIPT GetScriptScope() { return m_ScriptScope; }
|
||||||
|
|
||||||
HSCRIPT LookupScriptFunction(const char* pFunctionName);
|
HSCRIPT LookupScriptFunction(const char* pFunctionName);
|
||||||
@ -275,6 +276,9 @@ public:
|
|||||||
bool RunScript( const char* pScriptText, const char* pDebugFilename = "C_BaseEntity::RunScript" );
|
bool RunScript( const char* pScriptText, const char* pDebugFilename = "C_BaseEntity::RunScript" );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
HSCRIPT GetScriptOwnerEntity();
|
||||||
|
virtual void SetScriptOwnerEntity(HSCRIPT pOwner);
|
||||||
|
|
||||||
HSCRIPT GetScriptInstance();
|
HSCRIPT GetScriptInstance();
|
||||||
|
|
||||||
HSCRIPT m_hScriptInstance;
|
HSCRIPT m_hScriptInstance;
|
||||||
@ -1185,6 +1189,7 @@ public:
|
|||||||
|
|
||||||
HSCRIPT ScriptGetPhysicsObject( void );
|
HSCRIPT ScriptGetPhysicsObject( void );
|
||||||
|
|
||||||
|
void ScriptSetParent( HSCRIPT hParent, const char *szAttachment );
|
||||||
HSCRIPT ScriptGetMoveParent( void );
|
HSCRIPT ScriptGetMoveParent( void );
|
||||||
HSCRIPT ScriptGetRootMoveParent();
|
HSCRIPT ScriptGetRootMoveParent();
|
||||||
HSCRIPT ScriptFirstMoveChild( void );
|
HSCRIPT ScriptFirstMoveChild( void );
|
||||||
|
@ -8725,51 +8725,6 @@ HSCRIPT CBaseEntity::GetScriptScope()
|
|||||||
return m_ScriptScope;
|
return m_ScriptScope;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
#ifdef MAPBASE_VSCRIPT
|
|
||||||
HSCRIPT CBaseEntity::GetOrCreatePrivateScriptScope()
|
|
||||||
{
|
|
||||||
ValidateScriptScope();
|
|
||||||
return m_ScriptScope;
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
void CBaseEntity::ScriptSetParent(HSCRIPT hParent, const char *szAttachment)
|
|
||||||
{
|
|
||||||
CBaseEntity *pParent = ToEnt(hParent);
|
|
||||||
if ( !pParent )
|
|
||||||
{
|
|
||||||
SetParent(NULL);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if an attachment is specified, the parent needs to be CBaseAnimating
|
|
||||||
if ( szAttachment && szAttachment[0] != '\0' )
|
|
||||||
{
|
|
||||||
CBaseAnimating *pAnimating = pParent->GetBaseAnimating();
|
|
||||||
if ( !pAnimating )
|
|
||||||
{
|
|
||||||
Warning("ERROR: Tried to set parent for entity %s (%s), but its parent has no model.\n", GetClassname(), GetDebugName());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int iAttachment = pAnimating->LookupAttachment(szAttachment);
|
|
||||||
if ( iAttachment <= 0 )
|
|
||||||
{
|
|
||||||
Warning("ERROR: Tried to set parent for entity %s (%s), but it has no attachment named %s.\n", GetClassname(), GetDebugName(), szAttachment);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SetParent(pParent, iAttachment);
|
|
||||||
SetMoveType(MOVETYPE_NONE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SetParent(pParent);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
HSCRIPT CBaseEntity::ScriptGetMoveParent(void)
|
HSCRIPT CBaseEntity::ScriptGetMoveParent(void)
|
||||||
@ -10019,6 +9974,7 @@ void CBaseEntity::RunOnPostSpawnScripts(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef MAPBASE_VSCRIPT // This is shared now
|
||||||
HSCRIPT CBaseEntity::GetScriptOwnerEntity()
|
HSCRIPT CBaseEntity::GetScriptOwnerEntity()
|
||||||
{
|
{
|
||||||
return ToHScript(GetOwnerEntity());
|
return ToHScript(GetOwnerEntity());
|
||||||
@ -10028,6 +9984,7 @@ void CBaseEntity::SetScriptOwnerEntity(HSCRIPT pOwner)
|
|||||||
{
|
{
|
||||||
SetOwnerEntity(ToEnt(pOwner));
|
SetOwnerEntity(ToEnt(pOwner));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// VScript access to model's key values
|
// VScript access to model's key values
|
||||||
|
@ -2621,6 +2621,58 @@ bool CBaseEntity::IsToolRecording() const
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MAPBASE_VSCRIPT
|
#ifdef MAPBASE_VSCRIPT
|
||||||
|
HSCRIPT CBaseEntity::GetOrCreatePrivateScriptScope()
|
||||||
|
{
|
||||||
|
ValidateScriptScope();
|
||||||
|
return m_ScriptScope;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void CBaseEntity::ScriptSetParent(HSCRIPT hParent, const char *szAttachment)
|
||||||
|
{
|
||||||
|
CBaseEntity *pParent = ToEnt(hParent);
|
||||||
|
if ( !pParent )
|
||||||
|
{
|
||||||
|
SetParent(NULL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if an attachment is specified, the parent needs to be CBaseAnimating
|
||||||
|
if ( szAttachment && szAttachment[0] != '\0' )
|
||||||
|
{
|
||||||
|
CBaseAnimating *pAnimating = pParent->GetBaseAnimating();
|
||||||
|
if ( !pAnimating )
|
||||||
|
{
|
||||||
|
Warning("ERROR: Tried to set parent for entity %s (%s), but its parent has no model.\n", GetClassname(), GetDebugName());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int iAttachment = pAnimating->LookupAttachment(szAttachment);
|
||||||
|
if ( iAttachment <= 0 )
|
||||||
|
{
|
||||||
|
Warning("ERROR: Tried to set parent for entity %s (%s), but it has no attachment named %s.\n", GetClassname(), GetDebugName(), szAttachment);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetParent(pParent, iAttachment);
|
||||||
|
SetMoveType(MOVETYPE_NONE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetParent(pParent);
|
||||||
|
}
|
||||||
|
|
||||||
|
HSCRIPT CBaseEntity::GetScriptOwnerEntity()
|
||||||
|
{
|
||||||
|
return ToHScript(GetOwnerEntity());
|
||||||
|
}
|
||||||
|
|
||||||
|
void CBaseEntity::SetScriptOwnerEntity(HSCRIPT pOwner)
|
||||||
|
{
|
||||||
|
SetOwnerEntity(ToEnt(pOwner));
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
const Vector& CBaseEntity::ScriptGetColorVector()
|
const Vector& CBaseEntity::ScriptGetColorVector()
|
||||||
|
Loading…
Reference in New Issue
Block a user