mirror of
https://github.com/mapbase-source/source-sdk-2013.git
synced 2025-01-06 04:05:32 +03:00
87cd9b24bb
- Added postprocess_controller entity from later versions of Source - Added env_dof_controller entity from later versions of Source - Added SDK_Engine_Post and DepthOfField shaders from the Momentum repo/Alien Swarm SDK - Fixed auto-breaking game_text/choreo text not null terminating - Fixed console groups showing up at the wrong developer levels - Added more mesages to console groups, including a new "NPC AI" console group - Fixed typos and added elaboration in various cvars, console messages, etc. - Fixed npc_metropolice not using frag grenades correctly when allowed to use them - Fixed npc_metropolice not registering stitching squad slots in AI - Fixed SetModel input late precache warning - Fixed env_global_light angles resetting upon loading a save - Fixed an issue with ScriptKeyValuesRead using the wrong name and having a memory leak - Allowed VScript functions which return null strings to actually return null instead of empty strings - Added VScript member variable documentation - Fixed VScript documentation lines sometimes mixing together - Fixed VScript singletons having a ! at the beginning of descriptions - Added Color struct to VScript and allowed color-related inputs to use it - Added more VScript functions for weapons, ammo, ragdolling, and response contexts - Added GameRules singleton for VScript - Exposed AI interaction system to VScript - Recovered some lost documentation from older revisions of the Mapbase wiki - Added a way to get the current game's load type in VScript - Fixed Precache/SpawnEntityFromTable not accounting for a few important field types - Added VScript functions for getting a player's eye vectors - Fixed a crash caused by removing the active weapon of a Combine soldier while it's firing - Changed the way metrocops deploy their manhacks so they could use their manhack death response properly - Fixed "Use Server" keyvalue on game_convar_mod not working - Adjusted CAI_Expresser in VScript
331 lines
9.7 KiB
C++
331 lines
9.7 KiB
C++
//========= Copyright Valve Corporation, All rights reserved. ============//
|
|
//
|
|
// Purpose: Base combat character with no AI
|
|
//
|
|
// $Workfile: $
|
|
// $Date: $
|
|
// $NoKeywords: $
|
|
//=============================================================================//
|
|
|
|
#include "cbase.h"
|
|
#include "ammodef.h"
|
|
|
|
// memdbgon must be the last include file in a .cpp file!!!
|
|
#include "tier0/memdbgon.h"
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Purpose: Return a pointer to the Ammo at the Index passed in
|
|
//-----------------------------------------------------------------------------
|
|
Ammo_t *CAmmoDef::GetAmmoOfIndex(int nAmmoIndex)
|
|
{
|
|
if ( nAmmoIndex >= m_nAmmoIndex )
|
|
return NULL;
|
|
|
|
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 :
|
|
// Output :
|
|
//-----------------------------------------------------------------------------
|
|
int CAmmoDef::Index(const char *psz)
|
|
{
|
|
int i;
|
|
|
|
if (!psz)
|
|
return -1;
|
|
|
|
for (i = 1; i < m_nAmmoIndex; i++)
|
|
{
|
|
if (stricmp( psz, m_AmmoType[i].pName ) == 0)
|
|
return i;
|
|
}
|
|
|
|
return -1;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Purpose:
|
|
// Input :
|
|
// Output :
|
|
//-----------------------------------------------------------------------------
|
|
int CAmmoDef::PlrDamage(int nAmmoIndex)
|
|
{
|
|
if ( nAmmoIndex < 1 || nAmmoIndex >= m_nAmmoIndex )
|
|
return 0;
|
|
|
|
if ( m_AmmoType[nAmmoIndex].pPlrDmg == USE_CVAR )
|
|
{
|
|
if ( m_AmmoType[nAmmoIndex].pPlrDmgCVar )
|
|
{
|
|
return m_AmmoType[nAmmoIndex].pPlrDmgCVar->GetFloat();
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
else
|
|
{
|
|
return m_AmmoType[nAmmoIndex].pPlrDmg;
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Purpose:
|
|
// Input :
|
|
// Output :
|
|
//-----------------------------------------------------------------------------
|
|
int CAmmoDef::NPCDamage(int nAmmoIndex)
|
|
{
|
|
if ( nAmmoIndex < 1 || nAmmoIndex >= m_nAmmoIndex )
|
|
return 0;
|
|
|
|
if ( m_AmmoType[nAmmoIndex].pNPCDmg == USE_CVAR )
|
|
{
|
|
if ( m_AmmoType[nAmmoIndex].pNPCDmgCVar )
|
|
{
|
|
return m_AmmoType[nAmmoIndex].pNPCDmgCVar->GetFloat();
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
else
|
|
{
|
|
return m_AmmoType[nAmmoIndex].pNPCDmg;
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Purpose:
|
|
// Input :
|
|
// Output :
|
|
//-----------------------------------------------------------------------------
|
|
int CAmmoDef::MaxCarry(int nAmmoIndex)
|
|
{
|
|
if ( nAmmoIndex < 1 || nAmmoIndex >= m_nAmmoIndex )
|
|
return 0;
|
|
|
|
if ( m_AmmoType[nAmmoIndex].pMaxCarry == USE_CVAR )
|
|
{
|
|
if ( m_AmmoType[nAmmoIndex].pMaxCarryCVar )
|
|
return m_AmmoType[nAmmoIndex].pMaxCarryCVar->GetFloat();
|
|
|
|
return 0;
|
|
}
|
|
else
|
|
{
|
|
return m_AmmoType[nAmmoIndex].pMaxCarry;
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Purpose:
|
|
// Input :
|
|
// Output :
|
|
//-----------------------------------------------------------------------------
|
|
int CAmmoDef::DamageType(int nAmmoIndex)
|
|
{
|
|
if (nAmmoIndex < 1 || nAmmoIndex >= m_nAmmoIndex)
|
|
return 0;
|
|
|
|
return m_AmmoType[nAmmoIndex].nDamageType;
|
|
}
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Purpose:
|
|
//-----------------------------------------------------------------------------
|
|
int CAmmoDef::Flags(int nAmmoIndex)
|
|
{
|
|
if (nAmmoIndex < 1 || nAmmoIndex >= m_nAmmoIndex)
|
|
return 0;
|
|
|
|
return m_AmmoType[nAmmoIndex].nFlags;
|
|
}
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Purpose:
|
|
// Input :
|
|
// Output :
|
|
//-----------------------------------------------------------------------------
|
|
int CAmmoDef::MinSplashSize(int nAmmoIndex)
|
|
{
|
|
if (nAmmoIndex < 1 || nAmmoIndex >= m_nAmmoIndex)
|
|
return 4;
|
|
|
|
return m_AmmoType[nAmmoIndex].nMinSplashSize;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Purpose:
|
|
// Input :
|
|
// Output :
|
|
//-----------------------------------------------------------------------------
|
|
int CAmmoDef::MaxSplashSize(int nAmmoIndex)
|
|
{
|
|
if (nAmmoIndex < 1 || nAmmoIndex >= m_nAmmoIndex)
|
|
return 8;
|
|
|
|
return m_AmmoType[nAmmoIndex].nMaxSplashSize;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Purpose:
|
|
// Input :
|
|
// Output :
|
|
//-----------------------------------------------------------------------------
|
|
int CAmmoDef::TracerType(int nAmmoIndex)
|
|
{
|
|
if (nAmmoIndex < 1 || nAmmoIndex >= m_nAmmoIndex)
|
|
return 0;
|
|
|
|
return m_AmmoType[nAmmoIndex].eTracerType;
|
|
}
|
|
|
|
float CAmmoDef::DamageForce(int nAmmoIndex)
|
|
{
|
|
if ( nAmmoIndex < 1 || nAmmoIndex >= m_nAmmoIndex )
|
|
return 0;
|
|
|
|
return m_AmmoType[nAmmoIndex].physicsForceImpulse;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Purpose: Create an Ammo type with the name, decal, and tracer.
|
|
// Does not increment m_nAmmoIndex because the functions below do so and
|
|
// are the only entry point.
|
|
//-----------------------------------------------------------------------------
|
|
bool CAmmoDef::AddAmmoType(char const* name, int damageType, int tracerType, int nFlags, int minSplashSize, int maxSplashSize )
|
|
{
|
|
if (m_nAmmoIndex == MAX_AMMO_TYPES)
|
|
return false;
|
|
|
|
int len = strlen(name);
|
|
m_AmmoType[m_nAmmoIndex].pName = new char[len+1];
|
|
Q_strncpy(m_AmmoType[m_nAmmoIndex].pName, name,len+1);
|
|
m_AmmoType[m_nAmmoIndex].nDamageType = damageType;
|
|
m_AmmoType[m_nAmmoIndex].eTracerType = tracerType;
|
|
m_AmmoType[m_nAmmoIndex].nMinSplashSize = minSplashSize;
|
|
m_AmmoType[m_nAmmoIndex].nMaxSplashSize = maxSplashSize;
|
|
m_AmmoType[m_nAmmoIndex].nFlags = nFlags;
|
|
|
|
return true;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Purpose: Add an ammo type with it's damage & carrying capability specified via cvars
|
|
//-----------------------------------------------------------------------------
|
|
void CAmmoDef::AddAmmoType(char const* name, int damageType, int tracerType,
|
|
char const* plr_cvar, char const* npc_cvar, char const* carry_cvar,
|
|
float physicsForceImpulse, int nFlags, int minSplashSize, int maxSplashSize)
|
|
{
|
|
if ( AddAmmoType( name, damageType, tracerType, nFlags, minSplashSize, maxSplashSize ) == false )
|
|
return;
|
|
|
|
if (plr_cvar)
|
|
{
|
|
m_AmmoType[m_nAmmoIndex].pPlrDmgCVar = cvar->FindVar(plr_cvar);
|
|
if (!m_AmmoType[m_nAmmoIndex].pPlrDmgCVar)
|
|
{
|
|
Msg("ERROR: Ammo (%s) found no CVar named (%s)\n",name,plr_cvar);
|
|
}
|
|
m_AmmoType[m_nAmmoIndex].pPlrDmg = USE_CVAR;
|
|
}
|
|
if (npc_cvar)
|
|
{
|
|
m_AmmoType[m_nAmmoIndex].pNPCDmgCVar = cvar->FindVar(npc_cvar);
|
|
if (!m_AmmoType[m_nAmmoIndex].pNPCDmgCVar)
|
|
{
|
|
Msg("ERROR: Ammo (%s) found no CVar named (%s)\n",name,npc_cvar);
|
|
}
|
|
m_AmmoType[m_nAmmoIndex].pNPCDmg = USE_CVAR;
|
|
}
|
|
if (carry_cvar)
|
|
{
|
|
m_AmmoType[m_nAmmoIndex].pMaxCarryCVar= cvar->FindVar(carry_cvar);
|
|
if (!m_AmmoType[m_nAmmoIndex].pMaxCarryCVar)
|
|
{
|
|
Msg("ERROR: Ammo (%s) found no CVar named (%s)\n",name,carry_cvar);
|
|
}
|
|
m_AmmoType[m_nAmmoIndex].pMaxCarry = USE_CVAR;
|
|
}
|
|
m_AmmoType[m_nAmmoIndex].physicsForceImpulse = physicsForceImpulse;
|
|
m_nAmmoIndex++;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Purpose: Add an ammo type with it's damage & carrying capability specified via integers
|
|
//-----------------------------------------------------------------------------
|
|
void CAmmoDef::AddAmmoType(char const* name, int damageType, int tracerType,
|
|
int plr_dmg, int npc_dmg, int carry, float physicsForceImpulse,
|
|
int nFlags, int minSplashSize, int maxSplashSize )
|
|
{
|
|
if ( AddAmmoType( name, damageType, tracerType, nFlags, minSplashSize, maxSplashSize ) == false )
|
|
return;
|
|
|
|
m_AmmoType[m_nAmmoIndex].pPlrDmg = plr_dmg;
|
|
m_AmmoType[m_nAmmoIndex].pNPCDmg = npc_dmg;
|
|
m_AmmoType[m_nAmmoIndex].pMaxCarry = carry;
|
|
m_AmmoType[m_nAmmoIndex].physicsForceImpulse = physicsForceImpulse;
|
|
|
|
m_nAmmoIndex++;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Purpose: Constructor
|
|
// Input :
|
|
// Output :
|
|
//-----------------------------------------------------------------------------
|
|
CAmmoDef::CAmmoDef(void)
|
|
{
|
|
// Start with an index of 1. Client assumes 0 is an invalid ammo type
|
|
m_nAmmoIndex = 1;
|
|
memset( m_AmmoType, 0, sizeof( m_AmmoType ) );
|
|
}
|
|
|
|
CAmmoDef::~CAmmoDef( void )
|
|
{
|
|
for ( int i = 1; i < MAX_AMMO_TYPES; i++ )
|
|
{
|
|
delete[] m_AmmoType[ i ].pName;
|
|
}
|
|
}
|
|
|
|
#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." )
|
|
|
|
DEFINE_SCRIPTFUNC( GetNumAmmoTypes, "Gets the number of ammo types which currently exist." )
|
|
|
|
END_SCRIPTDESC();
|
|
#endif
|
|
|
|
|