From 032cfdaec38c37738c8c0156d755cf4534b8eeb0 Mon Sep 17 00:00:00 2001 From: "ALLEN-PC\\acj30" Date: Fri, 3 Nov 2023 16:29:02 -0500 Subject: [PATCH] New Get/SetGroundEntity, Get/SetModelScale functions for VScript --- sp/src/game/client/c_baseentity.cpp | 3 +++ sp/src/game/client/c_baseentity.h | 5 +++++ sp/src/game/server/baseanimating.cpp | 2 ++ sp/src/game/server/baseentity.cpp | 3 +++ sp/src/game/server/baseentity.h | 5 +++++ sp/src/game/shared/baseentity_shared.cpp | 12 ++++++++++++ 6 files changed, 30 insertions(+) diff --git a/sp/src/game/client/c_baseentity.cpp b/sp/src/game/client/c_baseentity.cpp index 43471e9d..1d3de004 100644 --- a/sp/src/game/client/c_baseentity.cpp +++ b/sp/src/game/client/c_baseentity.cpp @@ -502,6 +502,9 @@ BEGIN_ENT_SCRIPTDESC_ROOT( C_BaseEntity, "Root class of all client-side entities DEFINE_SCRIPTFUNC_NAMED( GetScriptOwnerEntity, "GetOwner", "Gets this entity's owner" ) DEFINE_SCRIPTFUNC_NAMED( SetScriptOwnerEntity, "SetOwner", "Sets this entity's owner" ) + DEFINE_SCRIPTFUNC_NAMED( ScriptGetGroundEntity, "GetGroundEntity", "Get the entity we're standing on." ) + DEFINE_SCRIPTFUNC_NAMED( ScriptSetGroundEntity, "SetGroundEntity", "Set the entity we're standing on." ) + 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( ScriptGetColorG, "GetRenderColorG", "Get the render color's G value" ) diff --git a/sp/src/game/client/c_baseentity.h b/sp/src/game/client/c_baseentity.h index fe159afe..422a59d4 100644 --- a/sp/src/game/client/c_baseentity.h +++ b/sp/src/game/client/c_baseentity.h @@ -288,6 +288,11 @@ public: HSCRIPT GetScriptOwnerEntity(); virtual void SetScriptOwnerEntity(HSCRIPT pOwner); +#ifdef MAPBASE_VSCRIPT + HSCRIPT ScriptGetGroundEntity(); + void ScriptSetGroundEntity( HSCRIPT hGroundEnt ); +#endif + HSCRIPT GetScriptInstance(); HSCRIPT m_hScriptInstance; diff --git a/sp/src/game/server/baseanimating.cpp b/sp/src/game/server/baseanimating.cpp index 38b1606a..be4d6b73 100644 --- a/sp/src/game/server/baseanimating.cpp +++ b/sp/src/game/server/baseanimating.cpp @@ -335,6 +335,8 @@ BEGIN_ENT_SCRIPTDESC( CBaseAnimating, CBaseEntity, "Animating models" ) DEFINE_SCRIPTFUNC( FindBodygroupByName, "Finds a bodygroup by name" ) DEFINE_SCRIPTFUNC( GetBodygroupCount, "Gets the number of models in a bodygroup" ) DEFINE_SCRIPTFUNC( GetNumBodyGroups, "Gets the number of bodygroups" ) + DEFINE_SCRIPTFUNC( GetModelScale, "Gets the model's scale" ) + DEFINE_SCRIPTFUNC( SetModelScale, "Sets the model's scale with the specified change duration" ) DEFINE_SCRIPTFUNC( Dissolve, "Use 'sprites/blueglow1.vmt' for the default material, Time() for the default start time, false for npcOnly if you don't want it to check if the entity is a NPC first, 0 for the default dissolve type, Vector(0,0,0) for the default dissolver origin, and 0 for the default magnitude." ) DEFINE_SCRIPTFUNC( Ignite, "'NPCOnly' only lets this fall through if the entity is a NPC and 'CalledByLevelDesigner' determines whether to treat this like the Ignite input or just an internal ignition call." ) diff --git a/sp/src/game/server/baseentity.cpp b/sp/src/game/server/baseentity.cpp index 67c3b17e..d8c4b63e 100644 --- a/sp/src/game/server/baseentity.cpp +++ b/sp/src/game/server/baseentity.cpp @@ -2378,6 +2378,9 @@ BEGIN_ENT_SCRIPTDESC_ROOT( CBaseEntity, "Root class of all server-side entities" DEFINE_SCRIPTFUNC( GetContextExpireTime, "Get a response context's expiration time" ) DEFINE_SCRIPTFUNC( GetContextCount, "Get the number of response contexts" ) DEFINE_SCRIPTFUNC_NAMED( ScriptGetContextIndex, "GetContextIndex", "Get a response context at a specific index in the form of a table" ) + + DEFINE_SCRIPTFUNC_NAMED( ScriptGetGroundEntity, "GetGroundEntity", "Get the entity we're standing on." ) + DEFINE_SCRIPTFUNC_NAMED( ScriptSetGroundEntity, "SetGroundEntity", "Set the entity we're standing on." ) DEFINE_SCRIPTFUNC_NAMED( ScriptFollowEntity, "FollowEntity", "Begin following the specified entity. This makes this entity non-solid, parents it to the target entity, and teleports it to the specified entity's origin. The second parameter is whether or not to use bonemerging while following." ) DEFINE_SCRIPTFUNC( StopFollowingEntity, "Stops following an entity if we're following one." ) diff --git a/sp/src/game/server/baseentity.h b/sp/src/game/server/baseentity.h index 1453d859..acbffdb2 100644 --- a/sp/src/game/server/baseentity.h +++ b/sp/src/game/server/baseentity.h @@ -1445,6 +1445,11 @@ public: void SetGroundEntity( CBaseEntity *ground ); CBaseEntity *GetGroundEntity( void ); CBaseEntity *GetGroundEntity( void ) const { return const_cast(this)->GetGroundEntity(); } + +#ifdef MAPBASE_VSCRIPT + HSCRIPT ScriptGetGroundEntity(); + void ScriptSetGroundEntity( HSCRIPT hGroundEnt ); +#endif // Gets the velocity we impart to a player standing on us virtual void GetGroundVelocityToApply( Vector &vecGroundVel ) { vecGroundVel = vec3_origin; } diff --git a/sp/src/game/shared/baseentity_shared.cpp b/sp/src/game/shared/baseentity_shared.cpp index 3393afa8..e5588287 100644 --- a/sp/src/game/shared/baseentity_shared.cpp +++ b/sp/src/game/shared/baseentity_shared.cpp @@ -2736,6 +2736,18 @@ void CBaseEntity::SetScriptOwnerEntity(HSCRIPT pOwner) SetOwnerEntity(ToEnt(pOwner)); } +#ifdef MAPBASE_VSCRIPT +HSCRIPT CBaseEntity::ScriptGetGroundEntity() +{ + return ToHScript( m_hGroundEntity.Get() ); +} + +void CBaseEntity::ScriptSetGroundEntity( HSCRIPT hGroundEnt ) +{ + SetGroundEntity( ToEnt( hGroundEnt ) ); +} +#endif + //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- const Vector& CBaseEntity::ScriptGetColorVector()