mirror of
https://github.com/mapbase-source/source-sdk-2013.git
synced 2025-01-13 23:37:58 +03:00
Added VScript functions for ropes
This commit is contained in:
parent
fc9d699fed
commit
8b699441e9
@ -73,6 +73,27 @@ IMPLEMENT_CLIENTCLASS_DT_NOBASE( C_RopeKeyframe, DT_RopeKeyframe, CRopeKeyframe
|
|||||||
RecvPropInt( RECVINFO( m_iParentAttachment ) ),
|
RecvPropInt( RECVINFO( m_iParentAttachment ) ),
|
||||||
END_RECV_TABLE()
|
END_RECV_TABLE()
|
||||||
|
|
||||||
|
#ifdef MAPBASE_VSCRIPT
|
||||||
|
BEGIN_ENT_SCRIPTDESC( C_RopeKeyframe, C_BaseEntity, "The clientside class of move_rope and keyframe_rope" )
|
||||||
|
DEFINE_SCRIPTFUNC( GetNodePosition, "Gets the position of the specified node index" )
|
||||||
|
DEFINE_SCRIPTFUNC( GetNumNodes, "Gets the number of nodes available" )
|
||||||
|
|
||||||
|
DEFINE_SCRIPTFUNC_NAMED( ScriptGetStartEntity, "GetStartEntity", "Gets the rope's start entity" )
|
||||||
|
DEFINE_SCRIPTFUNC_NAMED( ScriptGetEndEntity, "GetEndEntity", "Gets the rope's end entity" )
|
||||||
|
|
||||||
|
DEFINE_SCRIPTFUNC( SetupHangDistance, "Sets the rope's hang distance" )
|
||||||
|
DEFINE_SCRIPTFUNC( SetSlack, "Sets the rope's slack value (extra length)" )
|
||||||
|
DEFINE_SCRIPTFUNC( GetRopeFlags, "Gets the rope's flags" )
|
||||||
|
DEFINE_SCRIPTFUNC( SetRopeFlags, "Sets the rope's flags" )
|
||||||
|
|
||||||
|
DEFINE_SCRIPTFUNC( SetColorMod, "Sets the rope's color mod value" )
|
||||||
|
|
||||||
|
DEFINE_SCRIPTFUNC( ShakeRope, "Shakes the rope with the specified center, radius, and magnitude" )
|
||||||
|
|
||||||
|
DEFINE_SCRIPTFUNC( AnyPointsMoved, "Returns true if any points have moved recently" )
|
||||||
|
END_SCRIPTDESC();
|
||||||
|
#endif
|
||||||
|
|
||||||
#define ROPE_IMPULSE_SCALE 20
|
#define ROPE_IMPULSE_SCALE 20
|
||||||
#define ROPE_IMPULSE_DECAY 0.95
|
#define ROPE_IMPULSE_DECAY 0.95
|
||||||
|
|
||||||
@ -2022,6 +2043,25 @@ bool C_RopeKeyframe::GetAttachment( int number, Vector &origin, QAngle &angles )
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
const Vector &C_RopeKeyframe::GetNodePosition( int index )
|
||||||
|
{
|
||||||
|
int nNodes = m_RopePhysics.NumNodes();
|
||||||
|
if ( index >= nNodes || nNodes < 2 )
|
||||||
|
{
|
||||||
|
Warning( "C_RopeKeyframe::GetNodePosition(): Invalid node index %i (number of nodes is %i)\n", index, nNodes );
|
||||||
|
return vec3_origin;
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_RopePhysics.GetNode( index )->m_vPredicted;
|
||||||
|
}
|
||||||
|
|
||||||
|
int C_RopeKeyframe::GetNumNodes()
|
||||||
|
{
|
||||||
|
return m_RopePhysics.NumNodes();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool C_RopeKeyframe::AnyPointsMoved()
|
bool C_RopeKeyframe::AnyPointsMoved()
|
||||||
{
|
{
|
||||||
#ifdef MAPBASE
|
#ifdef MAPBASE
|
||||||
|
@ -33,6 +33,9 @@ public:
|
|||||||
DECLARE_CLASS( C_RopeKeyframe, C_BaseEntity );
|
DECLARE_CLASS( C_RopeKeyframe, C_BaseEntity );
|
||||||
DECLARE_CLIENTCLASS();
|
DECLARE_CLIENTCLASS();
|
||||||
|
|
||||||
|
#ifdef MAPBASE_VSCRIPT
|
||||||
|
DECLARE_ENT_SCRIPTDESC();
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@ -142,6 +145,11 @@ public:
|
|||||||
virtual bool GetAttachment( int number, Vector &origin );
|
virtual bool GetAttachment( int number, Vector &origin );
|
||||||
virtual bool GetAttachmentVelocity( int number, Vector &originVel, Quaternion &angleVel );
|
virtual bool GetAttachmentVelocity( int number, Vector &originVel, Quaternion &angleVel );
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
const Vector &GetNodePosition( int index );
|
||||||
|
int GetNumNodes();
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void FinishInit( const char *pMaterialName );
|
void FinishInit( const char *pMaterialName );
|
||||||
@ -166,6 +174,11 @@ private:
|
|||||||
void ReceiveMessage( int classID, bf_read &msg );
|
void ReceiveMessage( int classID, bf_read &msg );
|
||||||
bool CalculateEndPointAttachment( C_BaseEntity *pEnt, int iAttachment, Vector &vPos, QAngle *pAngles );
|
bool CalculateEndPointAttachment( C_BaseEntity *pEnt, int iAttachment, Vector &vPos, QAngle *pAngles );
|
||||||
|
|
||||||
|
#ifdef MAPBASE_VSCRIPT
|
||||||
|
HSCRIPT ScriptGetStartEntity() { return ToHScript( GetStartEntity() ); }
|
||||||
|
HSCRIPT ScriptGetEndEntity() { return ToHScript( GetEndEntity() ); }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Track which links touched something last frame. Used to prevent wind from gusting on them.
|
// Track which links touched something last frame. Used to prevent wind from gusting on them.
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include "cbase.h"
|
#include "cbase.h"
|
||||||
#include "activitylist.h"
|
#include "activitylist.h"
|
||||||
#include "in_buttons.h"
|
#include "in_buttons.h"
|
||||||
|
#include "rope_shared.h"
|
||||||
#ifdef CLIENT_DLL
|
#ifdef CLIENT_DLL
|
||||||
#include "c_ai_basenpc.h"
|
#include "c_ai_basenpc.h"
|
||||||
#else
|
#else
|
||||||
@ -310,6 +311,22 @@ void RegisterSharedScriptConstants()
|
|||||||
ScriptRegisterConstant( g_pScriptVM, MOVETYPE_OBSERVER, "Move type used in GetMoveType(), etc." );
|
ScriptRegisterConstant( g_pScriptVM, MOVETYPE_OBSERVER, "Move type used in GetMoveType(), etc." );
|
||||||
ScriptRegisterConstant( g_pScriptVM, MOVETYPE_CUSTOM, "Move type used in GetMoveType(), etc." );
|
ScriptRegisterConstant( g_pScriptVM, MOVETYPE_CUSTOM, "Move type used in GetMoveType(), etc." );
|
||||||
|
|
||||||
|
//
|
||||||
|
// Ropes
|
||||||
|
//
|
||||||
|
ScriptRegisterConstant( g_pScriptVM, ROPE_RESIZE, "Try to keep the rope dangling the same amount even as the rope length changes. (for use in rope flags)" );
|
||||||
|
ScriptRegisterConstant( g_pScriptVM, ROPE_BARBED, "Hack option to draw like a barbed wire. (for use in rope flags)" );
|
||||||
|
ScriptRegisterConstant( g_pScriptVM, ROPE_COLLIDE, "Collide with the world. (for use in rope flags)" );
|
||||||
|
ScriptRegisterConstant( g_pScriptVM, ROPE_SIMULATE, "Is the rope valid? (for use in rope flags)" );
|
||||||
|
ScriptRegisterConstant( g_pScriptVM, ROPE_BREAKABLE, "Can the endpoints detach? (for use in rope flags)" );
|
||||||
|
ScriptRegisterConstant( g_pScriptVM, ROPE_USE_WIND, "Wind simulation on this rope. (for use in rope flags)" );
|
||||||
|
ScriptRegisterConstant( g_pScriptVM, ROPE_INITIAL_HANG, "By default, ropes will simulate for a bit internally when they are created so they sag, but dynamically created ropes for things like harpoons don't want this. (for use in rope flags)" );
|
||||||
|
ScriptRegisterConstant( g_pScriptVM, ROPE_PLAYER_WPN_ATTACH, "If this flag is set, then the second attachment must be a player. The rope will attach to \"buff_attach\" on the player's active weapon. This is a flag because it requires special code on the client to find the weapon. (for use in rope flags)" );
|
||||||
|
ScriptRegisterConstant( g_pScriptVM, ROPE_NO_GRAVITY, "Disable gravity on this rope. (for use in rope flags)" );
|
||||||
|
ScriptRegisterConstant( g_pScriptVM, ROPE_NUMFLAGS, "The number of rope flags recognized by the game." );
|
||||||
|
|
||||||
|
ScriptRegisterConstantNamed( g_pScriptVM, Vector( ROPE_GRAVITY ), "ROPE_GRAVITY", "Default rope gravity vector." );
|
||||||
|
|
||||||
#ifdef GAME_DLL
|
#ifdef GAME_DLL
|
||||||
//
|
//
|
||||||
// Sound Types, Contexts, and Channels
|
// Sound Types, Contexts, and Channels
|
||||||
|
@ -22,7 +22,10 @@
|
|||||||
#include "globalstate.h"
|
#include "globalstate.h"
|
||||||
#include "vscript_server.h"
|
#include "vscript_server.h"
|
||||||
#include "soundent.h"
|
#include "soundent.h"
|
||||||
#endif // !CLIENT_DLL
|
#include "rope.h"
|
||||||
|
#else
|
||||||
|
#include "c_rope.h"
|
||||||
|
#endif // CLIENT_DLL
|
||||||
|
|
||||||
#include "con_nprint.h"
|
#include "con_nprint.h"
|
||||||
#include "particle_parse.h"
|
#include "particle_parse.h"
|
||||||
@ -738,6 +741,19 @@ static void ScriptDecalTrace( HSCRIPT hTrace, const char *decalName )
|
|||||||
UTIL_DecalTrace( &traceInfo->GetTrace(), decalName );
|
UTIL_DecalTrace( &traceInfo->GetTrace(), decalName );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static HSCRIPT ScriptCreateRope( HSCRIPT hStart, HSCRIPT hEnd, int iStartAttachment, int iEndAttachment, float ropeWidth, const char *pMaterialName, int numSegments, int ropeFlags )
|
||||||
|
{
|
||||||
|
#ifdef CLIENT_DLL
|
||||||
|
C_RopeKeyframe *pRope = C_RopeKeyframe::Create( ToEnt( hStart ), ToEnt( hEnd ), iStartAttachment, iEndAttachment, ropeWidth, pMaterialName, numSegments, ropeFlags );
|
||||||
|
#else
|
||||||
|
CRopeKeyframe *pRope = CRopeKeyframe::Create( ToEnt( hStart ), ToEnt( hEnd ), iStartAttachment, iEndAttachment, ropeWidth, pMaterialName, numSegments );
|
||||||
|
if (pRope)
|
||||||
|
pRope->m_RopeFlags |= ropeFlags; // HACKHACK
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return ToHScript( pRope );
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Simple particle effect dispatch
|
// Simple particle effect dispatch
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -902,6 +918,8 @@ void RegisterSharedScriptFunctions()
|
|||||||
ScriptRegisterFunctionNamed( g_pScriptVM, ScriptDecalTrace, "DecalTrace", "Creates a dynamic decal based on the given trace info. The trace information can be generated by TraceLineComplex() and the decal name must be from decals_subrect.txt." );
|
ScriptRegisterFunctionNamed( g_pScriptVM, ScriptDecalTrace, "DecalTrace", "Creates a dynamic decal based on the given trace info. The trace information can be generated by TraceLineComplex() and the decal name must be from decals_subrect.txt." );
|
||||||
ScriptRegisterFunctionNamed( g_pScriptVM, ScriptDispatchParticleEffect, "DoDispatchParticleEffect", SCRIPT_ALIAS( "DispatchParticleEffect", "Dispatches a one-off particle system" ) );
|
ScriptRegisterFunctionNamed( g_pScriptVM, ScriptDispatchParticleEffect, "DoDispatchParticleEffect", SCRIPT_ALIAS( "DispatchParticleEffect", "Dispatches a one-off particle system" ) );
|
||||||
|
|
||||||
|
ScriptRegisterFunctionNamed( g_pScriptVM, ScriptCreateRope, "CreateRope", "Creates a single rope between two entities. Can optionally follow specific attachments." );
|
||||||
|
|
||||||
ScriptRegisterFunctionNamed( g_pScriptVM, ScriptMatcherMatch, "Matcher_Match", "Compares a string to a query using Mapbase's matcher system, supporting wildcards, RS matchers, etc." );
|
ScriptRegisterFunctionNamed( g_pScriptVM, ScriptMatcherMatch, "Matcher_Match", "Compares a string to a query using Mapbase's matcher system, supporting wildcards, RS matchers, etc." );
|
||||||
ScriptRegisterFunction( g_pScriptVM, Matcher_NamesMatch, "Compares a string to a query using Mapbase's matcher system using wildcards only." );
|
ScriptRegisterFunction( g_pScriptVM, Matcher_NamesMatch, "Compares a string to a query using Mapbase's matcher system using wildcards only." );
|
||||||
ScriptRegisterFunction( g_pScriptVM, AppearsToBeANumber, "Checks if the given string appears to be a number." );
|
ScriptRegisterFunction( g_pScriptVM, AppearsToBeANumber, "Checks if the given string appears to be a number." );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user