mirror of
https://github.com/celisej567/source-sdk-2013.git
synced 2026-09-23 20:09:45 +03:00
Mapbase v4.1
- Exposed CAmmoDef to VScript and changed ammo type functions accordingly - Added TakeHealth and IsAlive to CBaseEntity - Added $treeSway - Added several inputs to control env_wind keyvalues + a new $treeSway scale keyvalue - Added "Expanded name fixup" keyvalue to point_template which allows name fixup to fix up output parameters - Fixed the rope on rappelling NPCs causing graphical issues - Fixed prop_vehicle_prisoner_pod missing "EnterVehicle", "EnterVehicleImmediate", and "ExitVehicle" inputs - Fixed hostile citizens not damaging player - Fixed an uncommon npc_metropolice crash from when it's not in a squad - Made SetTarget input update target handling on NPCs - Changed ammo type functions to be more organized, added AmmoDef singleton - Added more precache functions - Added various misc. entity functions, like GetAllWeapons or AddOutput - Added more utility functions
This commit is contained in:
@@ -24,6 +24,21 @@ Ammo_t *CAmmoDef::GetAmmoOfIndex(int nAmmoIndex)
|
||||
return &m_AmmoType[ nAmmoIndex ];
|
||||
}
|
||||
|
||||
#ifdef MAPBASE
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input :
|
||||
// Output :
|
||||
//-----------------------------------------------------------------------------
|
||||
const char* CAmmoDef::Name(int nAmmoIndex)
|
||||
{
|
||||
if ( nAmmoIndex < 1 || nAmmoIndex >= m_nAmmoIndex )
|
||||
return NULL;
|
||||
|
||||
return m_AmmoType[nAmmoIndex].pName;
|
||||
}
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input :
|
||||
@@ -292,4 +307,22 @@ CAmmoDef::~CAmmoDef( void )
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MAPBASE_VSCRIPT
|
||||
BEGIN_SCRIPTDESC_ROOT( CAmmoDef, SCRIPT_SINGLETON "The ammo type definition manager." )
|
||||
|
||||
DEFINE_SCRIPTFUNC( Name, "Gets the name of the specified ammo type index." )
|
||||
DEFINE_SCRIPTFUNC( Index, "Gets the index of the specified ammo type name." )
|
||||
DEFINE_SCRIPTFUNC( PlrDamage, "Gets the damage players deal for the specified ammo type." )
|
||||
DEFINE_SCRIPTFUNC( NPCDamage, "Gets the damage NPCs deal for the specified ammo type." )
|
||||
DEFINE_SCRIPTFUNC( MaxCarry, "Gets the maximum amount of this ammo type which players should be able to carry." )
|
||||
DEFINE_SCRIPTFUNC( DamageType, "Gets the type of damage this ammo type deals." )
|
||||
DEFINE_SCRIPTFUNC( TracerType, "Gets the type of tracer this ammo type uses." )
|
||||
DEFINE_SCRIPTFUNC( DamageForce, "Gets the amount of force this ammo type deals." )
|
||||
DEFINE_SCRIPTFUNC( MinSplashSize, "Gets the minimum size of water splashes caused by impacts from this ammo type." )
|
||||
DEFINE_SCRIPTFUNC( MaxSplashSize, "Gets the maximum size of water splashes caused by impacts from this ammo type." )
|
||||
DEFINE_SCRIPTFUNC( Flags, "Gets the flags this ammo type uses." )
|
||||
|
||||
END_SCRIPTDESC();
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -72,6 +72,9 @@ public:
|
||||
Ammo_t m_AmmoType[MAX_AMMO_TYPES];
|
||||
|
||||
Ammo_t *GetAmmoOfIndex(int nAmmoIndex);
|
||||
#ifdef MAPBASE
|
||||
const char* Name(int nAmmoIndex);
|
||||
#endif
|
||||
int Index(const char *psz);
|
||||
int PlrDamage(int nAmmoIndex);
|
||||
int NPCDamage(int nAmmoIndex);
|
||||
|
||||
@@ -1801,22 +1801,6 @@ void CBaseCombatWeapon::InputHideWeapon( inputdata_t &inputdata )
|
||||
SetWeaponVisible( false );
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MAPBASE_VSCRIPT
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
const char *CBaseCombatWeapon::ScriptGetPrimaryAmmoType()
|
||||
{
|
||||
return GetPrimaryAmmoType() <= GetAmmoDef()->m_nAmmoIndex ? GetAmmoDef()->m_AmmoType[GetPrimaryAmmoType()].pName : NULL;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
const char *CBaseCombatWeapon::ScriptGetSecondaryAmmoType()
|
||||
{
|
||||
return GetSecondaryAmmoType() <= GetAmmoDef()->m_nAmmoIndex ? GetAmmoDef()->m_AmmoType[GetSecondaryAmmoType()].pName : NULL;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -2910,8 +2894,8 @@ BEGIN_ENT_SCRIPTDESC( CBaseCombatWeapon, CBaseAnimating, "The base class for all
|
||||
DEFINE_SCRIPTFUNC( UsesClipsForAmmo2, "Check if the weapon uses clips for secondary ammo." )
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetPrimaryAmmoType, "GetPrimaryAmmoType", "Get the weapon's primary ammo type." )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetSecondaryAmmoType, "GetSecondaryAmmoType", "Get the weapon's secondary ammo type." )
|
||||
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." )
|
||||
|
||||
@@ -519,11 +519,6 @@ public:
|
||||
|
||||
virtual CDmgAccumulator *GetDmgAccumulator( void ) { return NULL; }
|
||||
|
||||
#ifdef MAPBASE_VSCRIPT
|
||||
const char* ScriptGetPrimaryAmmoType();
|
||||
const char* ScriptGetSecondaryAmmoType();
|
||||
#endif
|
||||
|
||||
// Client only methods
|
||||
#else
|
||||
|
||||
|
||||
@@ -70,6 +70,9 @@
|
||||
#include "IEffects.h"
|
||||
#include "engine/IEngineSound.h"
|
||||
#include "sharedInterface.h"
|
||||
#ifdef CLIENT_DLL
|
||||
#include "renderparm.h"
|
||||
#endif
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
@@ -89,6 +92,7 @@ CEnvWindShared::CEnvWindShared() : m_WindAveQueue(10), m_WindVariationQueue(10)
|
||||
#ifdef MAPBASE
|
||||
s_windControllers.AddToTail( this );
|
||||
m_windRadius = -1.0f;
|
||||
m_flTreeSwayScale = 1.0f;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -180,6 +184,31 @@ void CEnvWindShared::UpdateWindSound( float flTotalWindSpeed )
|
||||
}
|
||||
|
||||
|
||||
#ifdef MAPBASE
|
||||
#define TREE_SWAY_UPDATE_TIME 2.0f
|
||||
|
||||
void CEnvWindShared::UpdateTreeSway( float flTime )
|
||||
{
|
||||
#ifdef CLIENT_DLL
|
||||
while( flTime >= m_flSwayTime )
|
||||
{
|
||||
// Since the wind is constantly changing, but we need smooth values, we cache them off here.
|
||||
m_PrevSwayVector = m_CurrentSwayVector;
|
||||
m_CurrentSwayVector = m_flTreeSwayScale != 1.0f ? (m_currentWindVector * m_flTreeSwayScale) : m_currentWindVector;
|
||||
m_flSwayTime += TREE_SWAY_UPDATE_TIME;
|
||||
}
|
||||
|
||||
// Update vertex shader
|
||||
float flPercentage = ( 1 - ( ( m_flSwayTime - flTime ) / TREE_SWAY_UPDATE_TIME ) );
|
||||
CMatRenderContextPtr pRenderContext( g_pMaterialSystem );
|
||||
// Dividing by 2 helps the numbers the shader is expecting stay in line with other expected game values.
|
||||
Vector vecWind = Lerp( flPercentage, m_PrevSwayVector, m_CurrentSwayVector ) / 25.f;
|
||||
pRenderContext->SetVectorRenderingParameter( VECTOR_RENDERPARM_WIND_DIRECTION, vecWind );
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Updates the wind speed
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -196,6 +225,14 @@ float CEnvWindShared::WindThink( float flTime )
|
||||
|
||||
ComputeWindVariation( flTime );
|
||||
|
||||
#if defined(MAPBASE) && defined(CLIENT_DLL)
|
||||
if (m_flTreeSwayScale != 0.0f)
|
||||
{
|
||||
// Update Tree Sway
|
||||
UpdateTreeSway( flTime );
|
||||
}
|
||||
#endif
|
||||
|
||||
while (true)
|
||||
{
|
||||
// First, simulate up to the next switch time...
|
||||
|
||||
@@ -183,6 +183,10 @@ public:
|
||||
|
||||
#ifdef MAPBASE
|
||||
Vector m_currentWindVector; // For all the talk of proper prediction, we ended up just storing and returning through a static vector. Now we can have multiple env_wind, so we need this in here.
|
||||
Vector m_CurrentSwayVector;
|
||||
Vector m_PrevSwayVector;
|
||||
|
||||
CNetworkVar( float, m_flTreeSwayScale );
|
||||
#endif
|
||||
|
||||
CNetworkVar( int, m_iInitialWindDir );
|
||||
@@ -211,7 +215,12 @@ private:
|
||||
// Updates the wind sound
|
||||
void UpdateWindSound( float flTotalWindSpeed );
|
||||
|
||||
#ifdef MAPBASE
|
||||
void UpdateTreeSway( float flTime );
|
||||
#endif
|
||||
|
||||
float m_flVariationTime;
|
||||
float m_flSwayTime;
|
||||
float m_flSimTime; // What's the time I last simulated up to?
|
||||
float m_flSwitchTime; // when do I actually switch from gust to not gust
|
||||
float m_flAveWindSpeed; // the average wind speed
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "cbase.h"
|
||||
#include "matchers.h"
|
||||
#include "takedamageinfo.h"
|
||||
#include "ammodef.h"
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
#include "globalstate.h"
|
||||
@@ -752,6 +753,19 @@ FireBulletsInfo_t *GetFireBulletsInfoFromInfo( HSCRIPT hBulletsInfo )
|
||||
//=============================================================================
|
||||
//=============================================================================
|
||||
|
||||
static int ScriptPrecacheModel( const char *modelname )
|
||||
{
|
||||
return CBaseEntity::PrecacheModel( modelname );
|
||||
}
|
||||
|
||||
static void ScriptPrecacheOther( const char *classname )
|
||||
{
|
||||
UTIL_PrecacheOther( classname );
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//=============================================================================
|
||||
|
||||
static void ScriptEntitiesInBox( HSCRIPT hTable, int listMax, const Vector &hullMin, const Vector &hullMax, int iMask )
|
||||
{
|
||||
CBaseEntity *list[1024];
|
||||
@@ -785,6 +799,14 @@ 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 );
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//=============================================================================
|
||||
|
||||
@@ -813,6 +835,8 @@ void RegisterSharedScriptFunctions()
|
||||
ScriptRegisterFunction( g_pScriptVM, SpawnEntityFromTable, "Native function for entity spawning." );
|
||||
#endif
|
||||
|
||||
g_pScriptVM->RegisterInstance( GetAmmoDef(), "AmmoDef" );
|
||||
|
||||
g_pScriptVM->RegisterInstance( &g_ScriptConvarLookup, "Convars" );
|
||||
g_pScriptVM->RegisterInstance( &g_ScriptNetPropManager, "NetProps" );
|
||||
|
||||
@@ -839,10 +863,23 @@ void RegisterSharedScriptFunctions()
|
||||
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." );
|
||||
|
||||
//
|
||||
// Precaching
|
||||
//
|
||||
ScriptRegisterFunctionNamed( g_pScriptVM, ScriptPrecacheModel, "PrecacheModel", "Precaches a model for later usage." );
|
||||
ScriptRegisterFunction( g_pScriptVM, PrecacheMaterial, "Precaches a material for later usage." );
|
||||
ScriptRegisterFunction( g_pScriptVM, PrecacheParticleSystem, "Precaches a particle system for later usage." );
|
||||
ScriptRegisterFunctionNamed( g_pScriptVM, ScriptPrecacheOther, "PrecacheOther", "Precaches an entity class for later usage." );
|
||||
|
||||
//
|
||||
// Misc. Utility
|
||||
//
|
||||
ScriptRegisterFunctionNamed( g_pScriptVM, ScriptEntitiesInBox, "EntitiesInBox", "Gets all entities which are within a worldspace box." );
|
||||
ScriptRegisterFunctionNamed( g_pScriptVM, ScriptEntitiesAtPoint, "EntitiesAtPoint", "Gets all entities which are intersecting a point in space." );
|
||||
ScriptRegisterFunctionNamed( g_pScriptVM, ScriptEntitiesInSphere, "EntitiesInSphere", "Gets all entities which are within a sphere." );
|
||||
|
||||
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, 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, AppearsToBeANumber, "Checks if the given string appears to be a number." );
|
||||
|
||||
Reference in New Issue
Block a user