mirror of
https://github.com/nillerusr/source-engine.git
synced 2025-04-04 07:35:25 +00:00
111 lines
3.7 KiB
C++
111 lines
3.7 KiB
C++
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======
|
|
//
|
|
// TF Nail
|
|
//
|
|
//=============================================================================
|
|
#include "cbase.h"
|
|
#include "tf_projectile_nail.h"
|
|
|
|
#ifdef CLIENT_DLL
|
|
#include "c_basetempentity.h"
|
|
#include "c_te_legacytempents.h"
|
|
#include "c_te_effect_dispatch.h"
|
|
#include "input.h"
|
|
#include "c_tf_player.h"
|
|
#include "cliententitylist.h"
|
|
#endif
|
|
|
|
//=============================================================================
|
|
//
|
|
// TF Syringe Projectile functions (Server specific).
|
|
//
|
|
#define SYRINGE_MODEL "models/weapons/w_models/w_syringe_proj.mdl"
|
|
#define SYRINGE_DISPATCH_EFFECT "ClientProjectile_Syringe"
|
|
#define SYRINGE_GRAVITY 0.3f
|
|
|
|
LINK_ENTITY_TO_CLASS( tf_projectile_syringe, CTFProjectile_Syringe );
|
|
PRECACHE_REGISTER( tf_projectile_syringe );
|
|
|
|
short g_sModelIndexSyringe;
|
|
void PrecacheSyringe(void *pUser)
|
|
{
|
|
g_sModelIndexSyringe = modelinfo->GetModelIndex( SYRINGE_MODEL );
|
|
}
|
|
|
|
PRECACHE_REGISTER_FN(PrecacheSyringe);
|
|
|
|
CTFProjectile_Syringe::CTFProjectile_Syringe()
|
|
{
|
|
}
|
|
|
|
CTFProjectile_Syringe::~CTFProjectile_Syringe()
|
|
{
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Purpose:
|
|
//-----------------------------------------------------------------------------
|
|
CTFProjectile_Syringe *CTFProjectile_Syringe::Create( const Vector &vecOrigin, const QAngle &vecAngles, CBaseEntity *pOwner, CBaseEntity *pScorer, bool bCritical )
|
|
{
|
|
return static_cast<CTFProjectile_Syringe*>( CTFBaseProjectile::Create( "tf_projectile_syringe", vecOrigin, vecAngles, pOwner, CTFProjectile_Syringe::GetInitialVelocity(), g_sModelIndexSyringe, SYRINGE_DISPATCH_EFFECT, pScorer, bCritical ) );
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Purpose:
|
|
//-----------------------------------------------------------------------------
|
|
const char *CTFProjectile_Syringe::GetProjectileModelName( void )
|
|
{
|
|
return SYRINGE_MODEL;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Purpose:
|
|
//-----------------------------------------------------------------------------
|
|
float CTFProjectile_Syringe::GetGravity( void )
|
|
{
|
|
return SYRINGE_GRAVITY;
|
|
}
|
|
|
|
#ifdef CLIENT_DLL
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Purpose:
|
|
// Output : const char
|
|
//-----------------------------------------------------------------------------
|
|
const char *GetSyringeTrailParticleName( int iTeamNumber, bool bCritical )
|
|
{
|
|
if ( iTeamNumber == TF_TEAM_BLUE )
|
|
{
|
|
return ( bCritical ? "nailtrails_medic_blue_crit" : "nailtrails_medic_blue" );
|
|
}
|
|
else
|
|
{
|
|
return ( bCritical ? "nailtrails_medic_red_crit" : "nailtrails_medic_red" );
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Purpose:
|
|
//-----------------------------------------------------------------------------
|
|
void ClientsideProjectileSyringeCallback( const CEffectData &data )
|
|
{
|
|
// Get the syringe and add it to the client entity list, so we can attach a particle system to it.
|
|
C_TFPlayer *pPlayer = dynamic_cast<C_TFPlayer*>( ClientEntityList().GetBaseEntityFromHandle( data.m_hEntity ) );
|
|
if ( pPlayer )
|
|
{
|
|
C_LocalTempEntity *pSyringe = ClientsideProjectileCallback( data, SYRINGE_GRAVITY );
|
|
if ( pSyringe )
|
|
{
|
|
pSyringe->m_nSkin = ( pPlayer->GetTeamNumber() == TF_TEAM_RED ) ? 0 : 1;
|
|
bool bCritical = ( ( data.m_nDamageType & DMG_CRITICAL ) != 0 );
|
|
pSyringe->AddParticleEffect( GetSyringeTrailParticleName( pPlayer->GetTeamNumber(), bCritical ) );
|
|
pSyringe->AddEffects( EF_NOSHADOW );
|
|
pSyringe->flags |= FTENT_USEFASTCOLLISIONS;
|
|
}
|
|
}
|
|
}
|
|
|
|
DECLARE_CLIENT_EFFECT( SYRINGE_DISPATCH_EFFECT, ClientsideProjectileSyringeCallback );
|
|
|
|
#endif
|