game_shared/baseentity_shared.cpp
181920212223242526
#include "mapentities_shared.h"
#include "debugoverlay_shared.h"
#include "coordsize.h"
#ifdef CLIENT_DLL
#include "c_te_effect_dispatch.h"
#else
#include "te_effect_dispatch.h"
#include "soundent.h"
18192021222324252627282930
#include "mapentities_shared.h"
#include "debugoverlay_shared.h"
#include "coordsize.h"
#include "filesystem.h"
#ifdef CLIENT_DLL
#include "c_te_effect_dispatch.h"
// not ideal but I need this to be able to do ToFFPlayer for the team blood stuff
#include "c_ff_player.h"
#else
#include "te_effect_dispatch.h"
#include "soundent.h"
272829303132
#include "iservervehicle.h"
#include "player_pickup.h"
#include "waterbullet.h"
#ifdef HL2MP
#include "te_hl2mp_shotgun_shot.h"
31323334353637383940
#include "iservervehicle.h"
#include "player_pickup.h"
#include "waterbullet.h"
// not ideal but I need this to be able to do ToFFPlayer for the team blood stuff
#include "ff_player.h"
#ifdef HL2MP
#include "te_hl2mp_shotgun_shot.h"
57585960616263
ConVar ai_shot_bias_max( "ai_shot_bias_max", "1.0", FCVAR_REPLICATED );
ConVar ai_debug_shoot_positions( "ai_debug_shoot_positions", "0", FCVAR_REPLICATED | FCVAR_CHEAT );
//-----------------------------------------------------------------------------
// Purpose: Spawn some blood particles
//-----------------------------------------------------------------------------
656667686970
ConVar ai_shot_bias_max( "ai_shot_bias_max", "1.0", FCVAR_REPLICATED );
ConVar ai_debug_shoot_positions( "ai_debug_shoot_positions", "0", FCVAR_REPLICATED | FCVAR_CHEAT );
//-----------------------------------------------------------------------------
// Purpose: Spawn some blood particles
//-----------------------------------------------------------------------------
276277278279280281
}
while ( mapData->GetNextKey(keyName, value) );
}
}
//-----------------------------------------------------------------------------
283284285286287288289290291292293294295296297298299300301302303304305306307308309
}
while ( mapData->GetNextKey(keyName, value) );
}
#ifdef GAME_DLL
// setup the event action for the output
// this is necessary for routing the ouputs to lua
for ( datamap_t *dmap = GetDataDescMap(); dmap != NULL; dmap = dmap->baseMap )
{
// search through all the actions in the data description, looking for a match
for ( int i = 0; i < dmap->dataNumFields; i++ )
{
if ( dmap->dataDesc[i].flags & FTYPEDESC_OUTPUT )
{
const char* szEntName = STRING(GetEntityName());
COutputEvent* pEvent = (COutputEvent*)(((int)this) + dmap->dataDesc[i].fieldOffset[TD_OFFSET_NORMAL]);
char szEvent[2048];
Q_snprintf(szEvent, sizeof(szEvent), "%s,%s", szEntName, dmap->dataDesc[i].externalName);
pEvent->ParseEventAction(szEvent);
}
}
}
#endif
}
//-----------------------------------------------------------------------------
512513514515516517518519
//------------------------------------------------------------------------------
// Purpose : Base implimentation for entity handling decals
//------------------------------------------------------------------------------
void CBaseEntity::DecalTrace( trace_t *pTrace, char const *decalName )
{
int index = decalsystem->GetDecalIndexForName( decalName );
if ( index < 0 )
return;
540541542543544545546547548549550551552553554555
//------------------------------------------------------------------------------
// Purpose : Base implimentation for entity handling decals
//------------------------------------------------------------------------------
ConVar ffdev_disableentitydecals( "ffdev_disableentitydecals", "1", FCVAR_CHEAT | FCVAR_REPLICATED );
void CBaseEntity::DecalTrace( trace_t *pTrace, char const *decalName )
{
if(ffdev_disableentitydecals.GetBool())
{
if(Classify() != CLASS_NONE && Classify() < NUM_AI_CLASSES)
return;
}
int index = decalsystem->GetDecalIndexForName( decalName );
if ( index < 0 )
return;
137813791380138113821383
CAmmoDef* pAmmoDef = GetAmmoDef();
int nDamageType = pAmmoDef->DamageType(info.m_iAmmoType);
int nAmmoFlags = pAmmoDef->Flags(info.m_iAmmoType);
bool bDoServerEffects = true;
14141415141614171418141914201421
CAmmoDef* pAmmoDef = GetAmmoDef();
int nDamageType = pAmmoDef->DamageType(info.m_iAmmoType);
int nAmmoFlags = pAmmoDef->Flags(info.m_iAmmoType);
float flDmg = (info.m_iShots ? (float) info.m_iDamage / info.m_iShots : info.m_iDamage); // |-- Mirv: Split damage up into shots
bool bDoServerEffects = true;
1433143414351436143714381439
Vector vecEnd;
Vector vecFinalDir; // bullet's final direction can be changed by passing through a portal
CTraceFilterSkipTwoEntities traceFilter( this, info.m_pAdditionalIgnoreEnt, COLLISION_GROUP_NONE );
bool bUnderwaterBullets = ShouldDrawUnderwaterBulletBubbles();
bool bStartedInWater = false;
14711472147314741475147614771478
Vector vecEnd;
Vector vecFinalDir; // bullet's final direction can be changed by passing through a portal
//Testing if this is what makes sentryguns not damage players with projectile clipping -Green Mushy
CTraceFilterSkipTwoEntities traceFilter( this, info.m_pAdditionalIgnoreEnt, COLLISION_GROUP_NONE /*COLLISION_GROUP_PROJECTILE*/ ); // |-- Mirv: Count bullets as projectiles so they don't hit weapon bags
bool bUnderwaterBullets = ShouldDrawUnderwaterBulletBubbles();
bool bStartedInWater = false;
1513151415151516151715181519152015211522
// Now hit all triggers along the ray that respond to shots...
// Clip the ray to the first collided solid returned from traceline
CTakeDamageInfo triggerInfo( pAttacker, pAttacker, info.m_iDamage, nDamageType );
CalculateBulletDamageForce( &triggerInfo, info.m_iAmmoType, vecFinalDir, tr.endpos );
triggerInfo.ScaleDamageForce( info.m_flDamageForceScale );
triggerInfo.SetAmmoType( info.m_iAmmoType );
#ifdef GAME_DLL
TraceAttackToTriggers( triggerInfo, tr.startpos, tr.endpos, vecFinalDir );
#endif
15521553155415551556155715581559156015611562
// Now hit all triggers along the ray that respond to shots...
// Clip the ray to the first collided solid returned from traceline
CTakeDamageInfo triggerInfo( this, pAttacker, /*info.m_iDamage*/flDmg, nDamageType ); // |-- Mirv: Split damage into shots
CalculateBulletDamageForce( &triggerInfo, info.m_iAmmoType, vecFinalDir, tr.endpos );
triggerInfo.ScaleDamageForce( info.m_flDamageForceScale );
triggerInfo.SetAmmoType( info.m_iAmmoType );
#ifdef GAME_DLL
TraceAttackToTriggers( triggerInfo, tr.startpos, tr.endpos, vecFinalDir );
#endif
1548154915501551155215531554
bHitWater = HandleShotImpactingWater( info, vecEnd, &traceFilter, &vecTracerDest );
}
float flActualDamage = info.m_iDamage;
// If we hit a player, and we have player damage specified, use that instead
// Adrian: Make sure to use the currect value if we hit a vehicle the player is currently driving.
1588158915901591159215931594
bHitWater = HandleShotImpactingWater( info, vecEnd, &traceFilter, &vecTracerDest );
}
float flActualDamage = /*info.m_iDamage*/ flDmg; // |-- Mirv: Split damage into shots
// If we hit a player, and we have player damage specified, use that instead
// Adrian: Make sure to use the currect value if we hit a vehicle the player is currently driving.
158615871588158915901591
CalculateBulletDamageForce( &dmgInfo, info.m_iAmmoType, vecFinalDir, tr.endpos );
dmgInfo.ScaleDamageForce( info.m_flDamageForceScale );
dmgInfo.SetAmmoType( info.m_iAmmoType );
tr.m_pEnt->DispatchTraceAttack( dmgInfo, vecFinalDir, &tr );
if ( bStartedInWater || !bHitWater || (info.m_nFlags & FIRE_BULLETS_ALLOW_WATER_SURFACE_IMPACTS) )
1626162716281629163016311632163316341635163616371638
CalculateBulletDamageForce( &dmgInfo, info.m_iAmmoType, vecFinalDir, tr.endpos );
dmgInfo.ScaleDamageForce( info.m_flDamageForceScale );
dmgInfo.SetAmmoType( info.m_iAmmoType );
// --> Mirv: Quick hack, fix this tomorrow
if (tr.m_pEnt->IsPlayer())
{
dmgInfo.ScaleDamageForce(0.01f);
}
// <-- Mirv
tr.m_pEnt->DispatchTraceAttack( dmgInfo, vecFinalDir, &tr );
if ( bStartedInWater || !bHitWater || (info.m_nFlags & FIRE_BULLETS_ALLOW_WATER_SURFACE_IMPACTS) )
17701771177217731774177517761777
if ( blood != DONT_BLEED )
{
SpawnBlood( vecOrigin, vecDir, blood, info.GetDamage() );// a little surface blood.
TraceBleed( info.GetDamage(), vecDir, ptr, info.GetDamageType() );
}
}
}
181718181819182018211822182318241825182618271828
if ( blood != DONT_BLEED )
{
// Fix blood showing for teammates when FF is off.
if ( IsPlayer() && g_pGameRules->FCanTakeDamage( ToFFPlayer(this), info.GetAttacker()))
{
SpawnBlood( vecOrigin, vecDir, blood, info.GetDamage() );// a little surface blood.
TraceBleed( info.GetDamage(), vecDir, ptr, info.GetDamageType() );
}
}
}
}
212921302131
#endif
}
#endif
2180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213
#endif
}
#endif
#ifdef CLIENT_DLL
ConVar dump_deletes_cl( "dump_deletes_cl", "0" );
ConVar dump_deletes_flush( "dump_deletes_flush", "0" );
#endif
void CBaseEntity::PrintDeleteInfo()
{
static FileHandle_t m_hClassNameFile = NULL;
#ifdef CLIENT_DLL
if(dump_deletes_cl.GetBool())
{
if(!m_hClassNameFile)
{
m_hClassNameFile = filesystem->Open("classdump_client.txt", "wt", "MOD");
}
if(m_hClassNameFile)
{
const char *classname = _GetClassName();
char buffer[1024] = {};
V_snprintf(buffer, 1024, "%.2f deleted %s, index %d\n",
gpGlobals->curtime, classname?classname:"unknown",entindex());
filesystem->Write(buffer,V_strlen(buffer),m_hClassNameFile);
if( dump_deletes_flush.GetBool() )
filesystem->Flush(m_hClassNameFile);
}
}
#endif
}