cl_dll/c_te_legacytempents.cpp
303132333435
#include "physpropclientside.h"
#include "vstdlib/ICommandLine.h"
#include "datacache/imdlcache.h"
// NOTE: Always include this last!
#include "tier0/memdbgon.h"
30313233343536
#include "physpropclientside.h"
#include "vstdlib/ICommandLine.h"
#include "datacache/imdlcache.h"
#include "c_te_effect_dispatch.h" // |-- Mirv: Needed for client nail
// NOTE: Always include this last!
#include "tier0/memdbgon.h"
58596061626364656667
CLIENTEFFECT_REGISTER_END()
//Whether or not to eject brass from weapons
ConVar cl_ejectbrass( "cl_ejectbrass", "1" );
ConVar func_break_max_pieces( "func_break_max_pieces", "15", FCVAR_ARCHIVE | FCVAR_REPLICATED );
#if !defined( HL1_CLIENT_DLL ) // HL1 implements a derivative of CTempEnts
// Temp entity interface
59606162636465666768697071727374
CLIENTEFFECT_REGISTER_END()
//Whether or not to eject brass from weapons
ConVar cl_ejectbrass("cl_ejectbrass", "1", FCVAR_ARCHIVE);
ConVar cl_disablemuzzleflashes("cl_disablemuzzleflashes", "0", FCVAR_ARCHIVE );
ConVar func_break_max_pieces( "func_break_max_pieces", "15", FCVAR_ARCHIVE | FCVAR_REPLICATED );
// --> Mirv: Useful effect cvars
ConVar cl_brasstime("cl_brasstime", "1.0");
ConVar cl_projectilesdetail("cl_projectilesdetail", "1", FCVAR_ARCHIVE, "Projectile lodge detail: 0 - none, 1 - cutdown, 2 - full");
// <-- Mirv
#if !defined( HL1_CLIENT_DLL ) // HL1 implements a derivative of CTempEnts
// Temp entity interface
85868788899091
}
#if defined( CSTRIKE_DLL ) || defined (SDK_DLL )
#define TE_RIFLE_SHELL 1024
#define TE_PISTOL_SHELL 2048
92939495969798
}
#if defined( CSTRIKE_DLL ) || defined (FF_DLL )
#define TE_RIFLE_SHELL 1024
#define TE_PISTOL_SHELL 2048
128129130131132133134
m_vecTempEntVelocity = vecVelocity;
}
//-----------------------------------------------------------------------------
// Purpose:
// Output : int
135136137138139140141142143144145
m_vecTempEntVelocity = vecVelocity;
}
void DrawSprite( const Vector &vecOrigin, float flWidth, float flHeight, color32 color );
void BeamDraw(IMaterial *pMaterial, const Vector &vecstart, const Vector &vecend, float widthstart, float widthend, float alphastart, float alphaend, const Vector &colorstart, const Vector &colorend);
static ConVar cl_nail_trail("cl_nail_trail", "1", FCVAR_ARCHIVE);
//-----------------------------------------------------------------------------
// Purpose:
// Output : int
146147148149150151
if ( !GetModelPtr() )
return drawn;
if ( m_pfnDrawHelper )
{
drawn = ( *m_pfnDrawHelper )( this, flags );
157158159160161162163164165166167168169170171172173174175176177178179180181182183184
if ( !GetModelPtr() )
return drawn;
/// TODO: Aftershock needs to do whatever he wants with this...
if (this->flags & FTENT_FFPROJECTILE && m_vecTempEntVelocity != vec3_origin && cl_nail_trail.GetBool())
{
Vector vecDir = CurrentViewOrigin() - GetAbsOrigin();
float flLength = vecDir.LengthSqr();
if (flLength > 2025.0f)
{
color32 col = { 255, 255, 255, 255 };
IMaterial *pMaterial = materials->FindMaterial(/*"sprites/glow2.vmt"*/ "sprites/ff_trail.vmt", TEXTURE_GROUP_CLIENT_EFFECTS);
materials->Bind(pMaterial);
Vector vecForward;
AngleVectors(GetAbsAngles(), &vecForward);
//::DrawSprite( (GetAbsOrigin() - (vecForward * 2)) , 8.0f, 8.0f, col);
::BeamDraw(pMaterial, GetAbsOrigin() - (vecForward * 2), GetAbsOrigin() - (vecForward * 40),
8.0f, 1.0f,
1.0f, 0.1f,
Vector(1.0f, 1.0f, 1.0f), Vector(0.6f, 0.6f, 0.6f));
}
}
if ( m_pfnDrawHelper )
{
drawn = ( *m_pfnDrawHelper )( this, flags );
280281282283284285
m_vecPrevLocalOrigin = GetLocalOrigin();
if ( flags & FTENT_PLYRATTACHMENT )
{
if ( IClientEntity *pClient = cl_entitylist->GetClientEntity( clientIndex ) )
313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
m_vecPrevLocalOrigin = GetLocalOrigin();
// --> Mirv: FF Projectiles like nails and darts
if (flags & FTENT_FFPROJECTILE)
{
// Start off by advancing the projectile
SetLocalOrigin( GetLocalOrigin() + m_vecTempEntVelocity * frametime );
// Stationary, fade out
if (m_vecTempEntVelocity == vec3_origin)
{
int alpha = 255 * (die - gpGlobals->curtime);
// Starting to fade out now, ensure that it's the correct rendermode for this
if (alpha < 255)
{
if (GetRenderMode() == kRenderNormal)
SetRenderMode(kRenderTransTexture);
SetRenderColorA(max(alpha, 0));
}
return true;
}
// Trace along the change in positon that we have just simulated
trace_t pm;
UTIL_TraceLine(m_vecPrevLocalOrigin, GetLocalOrigin(), MASK_SOLID, NULL, COLLISION_GROUP_PROJECTILE, &pm);
// Make sure it didn't bump into itself... (?!?)
if ((pm.fraction != 1) && ((pm.DidHitWorld()) || (pm.m_pEnt != ClientEntityList().GetEnt(clientIndex))))
{
// Are we going through breakable glass? That won't stop us.
if (pm.m_pEnt->GetCollisionGroup() == COLLISION_GROUP_BREAKABLE_GLASS)
return true;
// Place at contact point
Vector newOrigin;
VectorMA(m_vecPrevLocalOrigin, pm.fraction * frametime, m_vecTempEntVelocity, newOrigin);
SetLocalOrigin(newOrigin);
// Play an impact effect if this isn't a player who'll bleed
// Possibly we should do blood here too.
// TODO: We can reduce the changes of an effect here.
if (!pm.m_pEnt->IsPlayer())
{
CEffectData data;
data.m_vStart = m_vecPrevLocalOrigin;
data.m_vOrigin = newOrigin;
data.m_vNormal = pm.plane.normal;
data.m_nSurfaceProp = pm.surface.surfaceProps;
#ifdef GAME_DLL
data.m_nEntIndex = pm.GetEntityIndex();
#else
data.m_hEntity = pm.m_pEnt;
#endif
// The actual effect isn't needed
if (flags & FTENT_FFOPTEFFECT)
data.m_fFlags |= CEFFECT_EFFECTNOTNEEDED;
// TODO: Add the rest of these as needed
DispatchEffect("NailImpact", data);
}
// Remove straight away if its something that is movable or is the skybox
// Or is a player
if (pm.m_pEnt->IsPlayer() || pm.m_pEnt->GetMoveType() != MOVETYPE_NONE || (pm.surface.flags & SURF_SKY))
die = gpGlobals->curtime;
// Also remove straight away if their graphics are toned down
else if (cl_projectilesdetail.GetInt() == 0)
die = gpGlobals->curtime;
// And remove straight away if the effects for this is optional
else if (cl_projectilesdetail.GetInt() == 1 && flags & FTENT_FFOPTEFFECT)
die = gpGlobals->curtime;
// TODO: Remove straight away if angle with normal is too big?
// Otherwise jam into whatever we hit for a bit
else
{
m_vecTempEntVelocity = Vector(0, 0, 0);
die = gpGlobals->curtime + 4.0f;
flags &= ~FTENT_FADEOUT;
}
}
return true;
}
// <-- Mirv
if ( flags & FTENT_PLYRATTACHMENT )
{
if ( IClientEntity *pClient = cl_entitylist->GetClientEntity( clientIndex ) )
153315341535153615371538
//-----------------------------------------------------------------------------
void CTempEnts::MuzzleFlash( int type, ClientEntityHandle_t hEntity, int attachmentIndex, bool firstPerson )
{
switch( type )
{
case MUZZLEFLASH_COMBINE:
1659166016611662166316641665166616671668166916701671167216731674167516761677167816791680
//-----------------------------------------------------------------------------
void CTempEnts::MuzzleFlash( int type, ClientEntityHandle_t hEntity, int attachmentIndex, bool firstPerson )
{
// Mirv: Optionally disable'd muzzle flashes
if (cl_disablemuzzleflashes.GetBool())
return;
//DevMsg("[muzzleflash] type: %d, ent: %d, attachment: %d fp: %d\n", type, entityIndex, attachmentIndex, firstPerson );
/* if ( firstPerson )
{
MuzzleFlash_Combine_Player( entityIndex, attachmentIndex );
}
else
{
MuzzleFlash_Combine_NPC( entityIndex, attachmentIndex );
}
return;*/
switch( type )
{
case MUZZLEFLASH_COMBINE:
1597159815991600160116021603
default:
{
//NOTENOTE: This means you specified an invalid muzzleflash type, check your spelling?
Assert( 0 );
}
break;
}
1739174017411742174317441745
default:
{
//NOTENOTE: This means you specified an invalid muzzleflash type, check your spelling?
//Assert( 0 );
}
break;
}
1612161316141615161616171618161916201621
{
#ifdef CSTRIKE_DLL
return;
#else
//NOTENOTE: This function is becoming obsolete as the muzzles are moved over to being local to attachments
switch ( type )
17541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776
{
#ifdef CSTRIKE_DLL
#else
// Mirv: Optionally disable'd muzzle flashes
if (cl_disablemuzzleflashes.GetBool())
return;
//DevMsg("[muzzleflash] type: %d, ent: %d, fp: %d\n", type, entityIndex, firstPerson );
/* if ( firstPerson )
{
MuzzleFlash_AR2_Player( pos1, angles, entityIndex );
}
else
{
MuzzleFlash_AR2_NPC( pos1, angles, entityIndex );
}
return;*/
//NOTENOTE: This function is becoming obsolete as the muzzles are moved over to being local to attachments
switch ( type )
1675167616771678167916801681
default:
// There's no supported muzzle flash for the type specified!
Assert(0);
break;
}
1830183118321833183418351836
default:
// There's no supported muzzle flash for the type specified!
//Assert(0);
break;
}
21902191219221932194219521962197219821992200220122022203
m_pHL1ShotgunShell = (model_t *)engine->LoadModel( "models/shotgunshell.mdl" );
#endif
#if defined( CSTRIKE_DLL ) || defined ( SDK_DLL )
m_pCS_9MMShell = (model_t *)engine->LoadModel( "models/Shells/shell_9mm.mdl" );
m_pCS_57Shell = (model_t *)engine->LoadModel( "models/Shells/shell_57.mdl" );
m_pCS_12GaugeShell = (model_t *)engine->LoadModel( "models/Shells/shell_12gauge.mdl" );
m_pCS_556Shell = (model_t *)engine->LoadModel( "models/Shells/shell_556.mdl" );
m_pCS_762NATOShell = (model_t *)engine->LoadModel( "models/Shells/shell_762nato.mdl" );
m_pCS_338MAGShell = (model_t *)engine->LoadModel( "models/Shells/shell_338mag.mdl" );
#endif
}
23452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370
m_pHL1ShotgunShell = (model_t *)engine->LoadModel( "models/shotgunshell.mdl" );
#endif
#if defined( CSTRIKE_DLL )
m_pCS_9MMShell = (model_t *)engine->LoadModel( "models/shells/shell_9mm.mdl" );
m_pCS_57Shell = (model_t *)engine->LoadModel( "models/shells/shell_57.mdl" );
m_pCS_12GaugeShell = (model_t *)engine->LoadModel( "models/shells/shell_12gauge.mdl" );
m_pCS_556Shell = (model_t *)engine->LoadModel( "models/shells/shell_556.mdl" );
m_pCS_762NATOShell = (model_t *)engine->LoadModel( "models/shells/shell_762nato.mdl" );
m_pCS_338MAGShell = (model_t *)engine->LoadModel( "models/shells/shell_338mag.mdl" );
#endif
// --> Mirv: Load FF models
#if defined (FF_DLL)
m_pCS_9MMShell = (model_t *)engine->LoadModel( "models/shells/shell_9mm.mdl" );
m_pCS_12GaugeShell = (model_t *)engine->LoadModel( "models/shells/shell_12gauge.mdl" );
m_pFF_40MMShell = (model_t *)engine->LoadModel( "models/shells/shell_40mm.mdl" );
m_pFF_Nail = (model_t *) engine->LoadModel("models/projectiles/nail/w_nail.mdl");
m_pFF_Dart = (model_t *) engine->LoadModel("models/projectiles/dart/w_dart.mdl");
#endif
// <-- Mirv
}
2227222822292230223122322233
m_pHL1ShotgunShell = NULL;
#endif
#if defined( CSTRIKE_DLL ) || defined ( SDK_DLL )
m_pCS_9MMShell = NULL;
m_pCS_57Shell = NULL;
m_pCS_12GaugeShell = NULL;
2394239523962397239823992400
m_pHL1ShotgunShell = NULL;
#endif
#if defined( CSTRIKE_DLL )
m_pCS_9MMShell = NULL;
m_pCS_57Shell = NULL;
m_pCS_12GaugeShell = NULL;
223622372238223922402241
m_pCS_338MAGShell = NULL;
#endif
// Clear out lists to start
Clear();
}
2403240424052406240724082409241024112412241324142415241624172418
m_pCS_338MAGShell = NULL;
#endif
#if defined (FF_DLL)
m_pCS_9MMShell = NULL;
m_pCS_12GaugeShell = NULL;
m_pFF_40MMShell = NULL;
m_pFF_Dart = NULL;
m_pFF_Nail = NULL;
#endif
// Clear out lists to start
Clear();
}
26462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677
void CTempEnts::MuzzleFlash_Shotgun_Player( ClientEntityHandle_t hEntity, int attachmentIndex )
{
VPROF_BUDGET( "MuzzleFlash_Shotgun_Player", VPROF_BUDGETGROUP_PARTICLE_RENDERING );
CSmartPtr pSimple = CSimpleEmitter::Create( "MuzzleFlash_Shotgun_Player" );
pSimple->SetDrawBeforeViewModel( true );
CacheMuzzleFlashes();
Vector origin;
QAngle angles;
// Get our attachment's transformation matrix
FX_GetAttachmentTransform( hEntity, attachmentIndex, &origin, &angles );
pSimple->GetBinding().SetBBox( origin - Vector( 4, 4, 4 ), origin + Vector( 4, 4, 4 ) );
Vector forward;
AngleVectors( angles, &forward, NULL, NULL );
SimpleParticle *pParticle;
Vector offset;
float flScale = random->RandomFloat( 1.25f, 1.5f );
// Flash
for ( int i = 1; i < 6; i++ )
{
offset = origin + (forward * (i*8.0f*flScale));
pParticle = (SimpleParticle *) pSimple->AddParticle( sizeof( SimpleParticle ), m_Material_MuzzleFlash_Player[random->RandomInt(0,3)], offset );
282328242825282628272828282928302831283228332834283528362837283828392840284128422843
void CTempEnts::MuzzleFlash_Shotgun_Player( ClientEntityHandle_t hEntity, int attachmentIndex )
{
VPROF_BUDGET( "MuzzleFlash_Shotgun_Player", VPROF_BUDGETGROUP_PARTICLE_RENDERING );
CSmartPtr pSimple = CLocalSpaceEmitter::Create( "MuzzleFlash_SMG1_Player", hEntity, attachmentIndex, FLE_VIEWMODEL );
CacheMuzzleFlashes();
SimpleParticle *pParticle;
Vector forward(1,0,0), offset; //NOTENOTE: All coords are in local space
float flScale = random->RandomFloat( 1.45f, 1.7f );
pSimple->SetDrawBeforeViewModel( true );
// Flash
for ( int i = 1; i < 6; i++ )
{
offset = (forward * (i*8.0f*flScale));
pParticle = (SimpleParticle *) pSimple->AddParticle( sizeof( SimpleParticle ), m_Material_MuzzleFlash_Player[random->RandomInt(0,3)], offset );
2679268026812682268326842685
return;
pParticle->m_flLifetime = 0.0f;
pParticle->m_flDieTime = 0.0001f;
pParticle->m_vecVelocity.Init();
2845284628472848284928502851
return;
pParticle->m_flLifetime = 0.0f;
pParticle->m_flDieTime = 0.045f;
pParticle->m_vecVelocity.Init();
3101310231033104310531063107
const model_t *pModel = NULL;
int hitsound = TE_BOUNCE_SHELL;
#if defined ( CSTRIKE_DLL ) || defined ( SDK_DLL )
switch( shellType )
{
3267326832693270327132723273
const model_t *pModel = NULL;
int hitsound = TE_BOUNCE_SHELL;
#if defined ( CSTRIKE_DLL )
switch( shellType )
{
313031313132313331343135313631373138
hitsound = TE_RIFLE_SHELL;
pModel = m_pCS_338MAGShell;
break;
}
#endif
if ( pModel == NULL )
return;
329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328
hitsound = TE_RIFLE_SHELL;
pModel = m_pCS_338MAGShell;
break;
case FF_SHELL_40MM:
hitsound = TE_RIFLE_SHELL;
pModel = m_pFF_40MMShell;
}
#endif
#if defined (FF_DLL)
switch( shellType )
{
default:
case CS_SHELL_9MM:
hitsound = TE_PISTOL_SHELL;
pModel = m_pCS_9MMShell;
break;
case CS_SHELL_12GAUGE:
hitsound = TE_SHOTGUN_SHELL;
pModel = m_pCS_12GaugeShell;
break;
case FF_SHELL_40MM:
hitsound = TE_RIFLE_SHELL;
pModel = m_pFF_40MMShell;
break;
}
#endif
if ( pModel == NULL )
return;
3173317431753176317731783179318031813182
pTemp->m_vecTempEntAngVelocity[0] = random->RandomFloat(-256,256);
pTemp->m_vecTempEntAngVelocity[1] = random->RandomFloat(-256,256);
pTemp->m_vecTempEntAngVelocity[2] = 0;
pTemp->SetRenderMode( kRenderNormal );
pTemp->tempent_renderamt = 255;
pTemp->die = gpGlobals->curtime + 10;
bool bViewModelBrass = false;
336333643365336633673368336933703371337233733374337533763377
pTemp->m_vecTempEntAngVelocity[0] = random->RandomFloat(-256,256);
pTemp->m_vecTempEntAngVelocity[1] = random->RandomFloat(-256,256);
pTemp->m_vecTempEntAngVelocity[2] = 0;
#if defined ( CSTRIKE_DLL ) || defined ( FF_DLL )
if (shellType == FF_SHELL_40MM)
pTemp->m_vecTempEntAngVelocity = QAngle(0, 0, 0);
#endif
pTemp->SetRenderMode( kRenderNormal );
pTemp->tempent_renderamt = 255;
pTemp->die = gpGlobals->curtime + cl_brasstime.GetFloat();
bool bViewModelBrass = false;
320232033204320532063207
// for viewmodel brass put it in the viewmodel renderer group
pTemp->m_RenderGroup = RENDER_GROUP_VIEW_MODEL_OPAQUE;
}
}
339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465
// for viewmodel brass put it in the viewmodel renderer group
pTemp->m_RenderGroup = RENDER_GROUP_VIEW_MODEL_OPAQUE;
}
}
// --> Mirv: A FF projectile
extern bool AllowEffects(int iEntityIndex, float flNewDelay);
void CTempEnts::FFProjectile(const Vector &vecPosition, const QAngle &angVelocity, int iSpeed, int projectileType, int entIndex)
{
const model_t *pModel = NULL;
int hitsound = TE_BOUNCE_SHELL;
switch (projectileType)
{
default:
case FF_PROJECTILE_NAIL:
case FF_PROJECTILE_NAIL_NG:
//hitsound = BOUNCE_METAL;
pModel = m_pFF_Nail;
break;
case FF_PROJECTILE_DART:
pModel = m_pFF_Dart;
break;
}
if (pModel == NULL)
return;
Vector velocity;
AngleVectors(angVelocity, &velocity);
velocity *= iSpeed;
// Allocate new temporary entity
C_LocalTempEntity *pTemp = TempEntAlloc(vecPosition, (model_t *) pModel);
if (!pTemp)
return;
pTemp->SetVelocity(velocity);
pTemp->SetAbsAngles(angVelocity);
pTemp->hitSound = hitsound;
pTemp->SetGravity(0);
pTemp->m_nBody = 0;
pTemp->flags = FTENT_FFPROJECTILE; //FTENT_FADEOUT | /*FTENT_GRAVITY |*/ FTENT_COLLIDEKILL | FTENT_COLLIDEALL | FTENT_HITSOUND /*| FTENT_ROTATE | FTENT_CHANGERENDERONCOLLIDE*/;
pTemp->m_vecTempEntAngVelocity = QAngle(0, 0, 0);
pTemp->SetRenderMode(kRenderNormal);
pTemp->tempent_renderamt = 255;
pTemp->die = gpGlobals->curtime + 10;
pTemp->clientIndex = entIndex;
if (!AllowEffects(entIndex, 0.3f))
pTemp->flags |= FTENT_FFOPTEFFECT;
// Really reduce the number of effects for nailgren spam
if (projectileType == FF_PROJECTILE_NAIL_NG && random->RandomInt(0, 30))
pTemp->flags |= FTENT_FFOPTEFFECT;
}
// <-- Mirv