diff --git a/src/game/client/swarm/c_asw_grenade_vindicator.cpp b/src/game/client/swarm/c_asw_grenade_vindicator.cpp new file mode 100644 index 000000000..90d25d205 --- /dev/null +++ b/src/game/client/swarm/c_asw_grenade_vindicator.cpp @@ -0,0 +1,56 @@ +#include "cbase.h" +#include "c_asw_grenade_vindicator.h" + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + +IMPLEMENT_NETWORKCLASS_ALIASED( ASW_Grenade_Vindicator, DT_ASW_Grenade_Vindicator ) + +BEGIN_NETWORK_TABLE( C_ASW_Grenade_Vindicator, DT_ASW_Grenade_Vindicator ) + RecvPropVector( RECVINFO( m_vecDetonateOrigin ) ), +END_NETWORK_TABLE() + + +C_ASW_Grenade_Vindicator::C_ASW_Grenade_Vindicator() +{ + m_bDetonated = false; + m_pSmokeTrail = NULL; + m_vecDetonateOrigin = Vector( 0.0, 0.0, 0.0 ); +} + +void C_ASW_Grenade_Vindicator::Spawn() +{ + CreateSmokeTrail(); +} + +void C_ASW_Grenade_Vindicator::OnDataChanged(DataUpdateType_t updateType) +{ + if ( updateType == DATA_UPDATE_DATATABLE_CHANGED ) + { + if ( !m_bDetonated && m_vecDetonateOrigin != Vector( 0.0, 0.0, 0.0 ) ) + { + Detonate(); + m_bDetonated = true; + } + } +} + +void C_ASW_Grenade_Vindicator::CreateSmokeTrail() +{ + if ( m_pSmokeTrail ) + return; + + m_pSmokeTrail = ParticleProp()->Create( "rocket_trail_small", PATTACH_ABSORIGIN_FOLLOW, -1, Vector( 0, 0, 0 ) ); +} + +void C_ASW_Grenade_Vindicator::Detonate() +{ + if ( m_pSmokeTrail ) + { + m_pSmokeTrail->StopEmission(); + m_pSmokeTrail = NULL; + } + + EmitSound( "ASWGrenade.Incendiary" ); + DispatchParticleEffect( "vindicator_grenade", m_vecDetonateOrigin, vec3_angle ); +} diff --git a/src/game/client/swarm/c_asw_grenade_vindicator.h b/src/game/client/swarm/c_asw_grenade_vindicator.h new file mode 100644 index 000000000..c41a80b9a --- /dev/null +++ b/src/game/client/swarm/c_asw_grenade_vindicator.h @@ -0,0 +1,27 @@ +#ifndef _INCLUDED_C_ASW_GRENADE_VINDICATOR_H +#define _INCLUDED_C_ASW_GRENADE_VINDICATOR_H + +#pragma once + +#include "c_asw_rifle_grenade.h" + +class C_ASW_Grenade_Vindicator : public C_ASW_Rifle_Grenade +{ + DECLARE_CLASS( C_ASW_Grenade_Vindicator, C_ASW_Rifle_Grenade ); + DECLARE_CLIENTCLASS(); + +public: + C_ASW_Grenade_Vindicator(); + virtual void Spawn(); + virtual void OnDataChanged(DataUpdateType_t updateType); + virtual void Detonate(); + void CreateSmokeTrail(); + + bool m_bDetonated; + + CNetworkVector( m_vecDetonateOrigin ); + + CUtlReference m_pSmokeTrail; +}; + +#endif // _INCLUDED_C_ASW_GRENADE_VINDICATOR_H diff --git a/src/game/client/swarm_sdk_client.vcxproj b/src/game/client/swarm_sdk_client.vcxproj index b0d660543..bdae3ac07 100644 --- a/src/game/client/swarm_sdk_client.vcxproj +++ b/src/game/client/swarm_sdk_client.vcxproj @@ -1295,6 +1295,7 @@ if exist ..\..\devtools\bin\postbuild.cmd ..\..\devtools\bin\postbuild.cmd clien + @@ -3166,6 +3167,7 @@ if exist ..\..\devtools\bin\postbuild.cmd ..\..\devtools\bin\postbuild.cmd clien + diff --git a/src/game/server/EntityFlame.cpp b/src/game/server/EntityFlame.cpp index 1d6e9dd08..c083e48c8 100644 --- a/src/game/server/EntityFlame.cpp +++ b/src/game/server/EntityFlame.cpp @@ -189,6 +189,9 @@ void CEntityFlame::AttachToEntity( CBaseEntity *pTarget ) // For networking to the client. m_hEntAttached = pTarget; + if ( !m_hEntAttached ) + return; + if( pTarget->IsNPC() ) { EmitSound( "General.BurningFlesh" ); diff --git a/src/game/server/swarm/asw_grenade_vindicator.cpp b/src/game/server/swarm/asw_grenade_vindicator.cpp index edb4e12c8..c92e41560 100644 --- a/src/game/server/swarm/asw_grenade_vindicator.cpp +++ b/src/game/server/swarm/asw_grenade_vindicator.cpp @@ -9,6 +9,7 @@ #include "asw_marine_resource.h" #include "te_effect_dispatch.h" #include "particle_parse.h" +#include "EntityFlame.h" #include "asw_player.h" #include "asw_achievements.h" #include "asw_boomer_blob.h" @@ -51,6 +52,12 @@ BEGIN_DATADESC( CASW_Grenade_Vindicator ) DEFINE_OUTPUT(m_OnDamaged, "OnDamaged"), END_DATADESC() +IMPLEMENT_NETWORKCLASS_ALIASED( ASW_Grenade_Vindicator, DT_ASW_Grenade_Vindicator ) + +BEGIN_NETWORK_TABLE( CASW_Grenade_Vindicator, DT_ASW_Grenade_Vindicator ) + SendPropVector( SENDINFO( m_vecDetonateOrigin ) ), +END_NETWORK_TABLE() + extern int g_sModelIndexFireball; // (in combatweapon.cpp) holds the index for the smoke cloud CASW_Grenade_Vindicator::CASW_Grenade_Vindicator() @@ -76,10 +83,12 @@ void CASW_Grenade_Vindicator::Spawn( void ) m_DmgRadius = 220.0f; m_bDamagedByExplosions = rd_vindicator_grenade_pushed_by_explosions.GetBool(); - Ignite(3.0, false, 0, false); + Ignite( 3.0, false, 0, false ); m_takedamage = DAMAGE_YES; + m_vecDetonateOrigin = Vector( 0.0, 0.0, 0.0 ); + SetSize( -Vector(4,4,4), Vector(4,4,4) ); SetSolid( SOLID_BBOX ); SetGravity( asw_vindicator_grenade_gravity.GetFloat() ); @@ -232,6 +241,9 @@ void CASW_Grenade_Vindicator::Detonate() m_takedamage = DAMAGE_NO; StopSound( "ASWGrenade.Alarm" ); + + m_vecDetonateOrigin = GetAbsOrigin(); + CPASFilter filter( GetAbsOrigin() ); /* @@ -245,15 +257,6 @@ void CASW_Grenade_Vindicator::Detonate() m_flDamage ); */ - if ( !m_bSilent ) - { - EmitSound( "ASWGrenade.Incendiary" ); - } - // throw out some flames - CEffectData data; - data.m_vOrigin = GetAbsOrigin(); - DispatchEffect( "ASWFireBurst", data ); - Vector vecForward = GetAbsVelocity(); VectorNormalize(vecForward); trace_t tr; @@ -345,7 +348,24 @@ void CASW_Grenade_Vindicator::Detonate() m_iClusters--; } - UTIL_Remove( this ); + // hack to remove the burning particles on the grenade itself + // theres probably a better way but this has been bothering me for couple hours now + CEntityFlame* pEntityFlame = dynamic_cast< CEntityFlame* >( GetEffectEntity() ); + if ( pEntityFlame ) + { + pEntityFlame->AttachToEntity( NULL ); + SetEffectEntity( NULL ); + Extinguish(); + } + + SetModelIndex( 0 ); + SetModelName( NULL_STRING ); + SetTouch( NULL ); + SetSolid( SOLID_NONE ); + + // give time for m_vecDetonateOrigin to be sent to client so it can simulate the explosion effects + SetThink( &CASW_Grenade_Vindicator::SUB_Remove ); + SetNextThink( gpGlobals->curtime + 2.0f ); } void CASW_Grenade_Vindicator::Precache() @@ -360,6 +380,7 @@ void CASW_Grenade_Vindicator::Precache() PrecacheScriptSound("ASWGrenade.Alarm"); PrecacheScriptSound("Grenade.ImpactHard"); PrecacheParticleSystem( "VindGrenade" ); + PrecacheParticleSystem( "vindicator_grenade" ); PrecacheParticleSystem( "grenade_main_trail" ); } @@ -370,44 +391,10 @@ void CASW_Grenade_Vindicator::KillEffects() void CASW_Grenade_Vindicator::CreateEffects() { - // Start up the eye glow - /* - m_pMainGlow = CSprite::SpriteCreate( "sprites/redglow1.vmt", GetLocalOrigin(), false ); - - int nAttachment = LookupAttachment( "fuse" ); - - if ( m_pMainGlow != NULL ) - { - m_pMainGlow->FollowEntity( this ); - m_pMainGlow->SetAttachment( this, nAttachment ); - m_pMainGlow->SetTransparency( kRenderGlow, 255, 255, 255, 200, kRenderFxNoDissipation ); - m_pMainGlow->SetScale( 0.2f ); - m_pMainGlow->SetGlowProxySize( 4.0f ); - } - - // Start up the eye trail - m_pGlowTrail = CSpriteTrail::SpriteTrailCreate( "sprites/bluelaser1.vmt", GetLocalOrigin(), false ); - - if ( m_pGlowTrail != NULL ) - { - m_pGlowTrail->FollowEntity( this ); - m_pGlowTrail->SetAttachment( this, nAttachment ); - m_pGlowTrail->SetTransparency( kRenderTransAdd, 255, 0, 0, 255, kRenderFxNone ); - m_pGlowTrail->SetStartWidth( 8.0f ); - m_pGlowTrail->SetEndWidth( 1.0f ); - m_pGlowTrail->SetLifeTime( 0.5f ); - } - */ - - CEffectData data; - data.m_vOrigin = GetAbsOrigin(); - //data.m_vNormal = dir; - //data.m_flScale = (float)amount; - CPASFilter filter( data.m_vOrigin ); - filter.SetIgnorePredictionCull(true); - DispatchParticleEffect( "rocket_trail_small", PATTACH_ABSORIGIN_FOLLOW, this, "fuse", false, -1, &filter ); + } + int CASW_Grenade_Vindicator::OnTakeDamage_Dying( const CTakeDamageInfo &info ) { return BaseClass::OnTakeDamage_Dying(info); diff --git a/src/game/server/swarm/asw_grenade_vindicator.h b/src/game/server/swarm/asw_grenade_vindicator.h index 1dfd7d17e..2eded828a 100644 --- a/src/game/server/swarm/asw_grenade_vindicator.h +++ b/src/game/server/swarm/asw_grenade_vindicator.h @@ -13,9 +13,8 @@ class CASW_Grenade_Vindicator : public CASW_Rifle_Grenade public: DECLARE_CLASS( CASW_Grenade_Vindicator, CASW_Rifle_Grenade ); -#if !defined( CLIENT_DLL ) + DECLARE_SERVERCLASS(); DECLARE_DATADESC(); -#endif CASW_Grenade_Vindicator(); virtual ~CASW_Grenade_Vindicator( void ); @@ -49,6 +48,8 @@ class CASW_Grenade_Vindicator : public CASW_Rifle_Grenade bool m_bKicked; bool m_bExplodeOnWorldContact; + CNetworkVector( m_vecDetonateOrigin ); + CHandle m_pMainGlow; CHandle m_pGlowTrail;