Skip to content

Commit d015787

Browse files
authored
Merge pull request #857 from ReactiveDrop/vindinade-effects
fix vindinade particles and sound disappearing with packet loss
2 parents e2eb63a + d092224 commit d015787

6 files changed

Lines changed: 125 additions & 49 deletions

File tree

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#include "cbase.h"
2+
#include "c_asw_grenade_vindicator.h"
3+
4+
// memdbgon must be the last include file in a .cpp file!!!
5+
#include "tier0/memdbgon.h"
6+
7+
IMPLEMENT_NETWORKCLASS_ALIASED( ASW_Grenade_Vindicator, DT_ASW_Grenade_Vindicator )
8+
9+
BEGIN_NETWORK_TABLE( C_ASW_Grenade_Vindicator, DT_ASW_Grenade_Vindicator )
10+
RecvPropVector( RECVINFO( m_vecDetonateOrigin ) ),
11+
END_NETWORK_TABLE()
12+
13+
14+
C_ASW_Grenade_Vindicator::C_ASW_Grenade_Vindicator()
15+
{
16+
m_bDetonated = false;
17+
m_pSmokeTrail = NULL;
18+
m_vecDetonateOrigin = Vector( 0.0, 0.0, 0.0 );
19+
}
20+
21+
void C_ASW_Grenade_Vindicator::Spawn()
22+
{
23+
CreateSmokeTrail();
24+
}
25+
26+
void C_ASW_Grenade_Vindicator::OnDataChanged(DataUpdateType_t updateType)
27+
{
28+
if ( updateType == DATA_UPDATE_DATATABLE_CHANGED )
29+
{
30+
if ( !m_bDetonated && m_vecDetonateOrigin != Vector( 0.0, 0.0, 0.0 ) )
31+
{
32+
Detonate();
33+
m_bDetonated = true;
34+
}
35+
}
36+
}
37+
38+
void C_ASW_Grenade_Vindicator::CreateSmokeTrail()
39+
{
40+
if ( m_pSmokeTrail )
41+
return;
42+
43+
m_pSmokeTrail = ParticleProp()->Create( "rocket_trail_small", PATTACH_ABSORIGIN_FOLLOW, -1, Vector( 0, 0, 0 ) );
44+
}
45+
46+
void C_ASW_Grenade_Vindicator::Detonate()
47+
{
48+
if ( m_pSmokeTrail )
49+
{
50+
m_pSmokeTrail->StopEmission();
51+
m_pSmokeTrail = NULL;
52+
}
53+
54+
EmitSound( "ASWGrenade.Incendiary" );
55+
DispatchParticleEffect( "vindicator_grenade", m_vecDetonateOrigin, vec3_angle );
56+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#ifndef _INCLUDED_C_ASW_GRENADE_VINDICATOR_H
2+
#define _INCLUDED_C_ASW_GRENADE_VINDICATOR_H
3+
4+
#pragma once
5+
6+
#include "c_asw_rifle_grenade.h"
7+
8+
class C_ASW_Grenade_Vindicator : public C_ASW_Rifle_Grenade
9+
{
10+
DECLARE_CLASS( C_ASW_Grenade_Vindicator, C_ASW_Rifle_Grenade );
11+
DECLARE_CLIENTCLASS();
12+
13+
public:
14+
C_ASW_Grenade_Vindicator();
15+
virtual void Spawn();
16+
virtual void OnDataChanged(DataUpdateType_t updateType);
17+
virtual void Detonate();
18+
void CreateSmokeTrail();
19+
20+
bool m_bDetonated;
21+
22+
CNetworkVector( m_vecDetonateOrigin );
23+
24+
CUtlReference<CNewParticleEffect> m_pSmokeTrail;
25+
};
26+
27+
#endif // _INCLUDED_C_ASW_GRENADE_VINDICATOR_H

src/game/client/swarm_sdk_client.vcxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,6 +1295,7 @@ if exist ..\..\devtools\bin\postbuild.cmd ..\..\devtools\bin\postbuild.cmd clien
12951295
<ClCompile Include="swarm\c_asw_gas_grenade_projectile.cpp" />
12961296
<ClCompile Include="swarm\c_asw_generic_emitter.cpp" />
12971297
<ClCompile Include="swarm\c_asw_generic_emitter_entity.cpp" />
1298+
<ClCompile Include="swarm\c_asw_grenade_vindicator.cpp" />
12981299
<ClCompile Include="swarm\c_asw_gun_smoke_emitter.cpp" />
12991300
<ClCompile Include="swarm\c_asw_hack.cpp" />
13001301
<ClCompile Include="swarm\c_asw_hack_computer.cpp" />
@@ -3166,6 +3167,7 @@ if exist ..\..\devtools\bin\postbuild.cmd ..\..\devtools\bin\postbuild.cmd clien
31663167
<ClInclude Include="swarm\c_asw_gas_grenade_projectile.h" />
31673168
<ClInclude Include="swarm\c_asw_generic_emitter.h" />
31683169
<ClInclude Include="swarm\c_asw_generic_emitter_entity.h" />
3170+
<ClInclude Include="swarm\c_asw_grenade_vindicator.h" />
31693171
<ClInclude Include="swarm\c_asw_gun_smoke_emitter.h" />
31703172
<ClInclude Include="swarm\c_asw_hack.h" />
31713173
<ClInclude Include="swarm\c_asw_hack_computer.h" />

src/game/server/EntityFlame.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,9 @@ void CEntityFlame::AttachToEntity( CBaseEntity *pTarget )
189189
// For networking to the client.
190190
m_hEntAttached = pTarget;
191191

192+
if ( !m_hEntAttached )
193+
return;
194+
192195
if( pTarget->IsNPC() )
193196
{
194197
EmitSound( "General.BurningFlesh" );

src/game/server/swarm/asw_grenade_vindicator.cpp

Lines changed: 34 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "asw_marine_resource.h"
1010
#include "te_effect_dispatch.h"
1111
#include "particle_parse.h"
12+
#include "EntityFlame.h"
1213
#include "asw_player.h"
1314
#include "asw_achievements.h"
1415
#include "asw_boomer_blob.h"
@@ -51,6 +52,12 @@ BEGIN_DATADESC( CASW_Grenade_Vindicator )
5152
DEFINE_OUTPUT(m_OnDamaged, "OnDamaged"),
5253
END_DATADESC()
5354

55+
IMPLEMENT_NETWORKCLASS_ALIASED( ASW_Grenade_Vindicator, DT_ASW_Grenade_Vindicator )
56+
57+
BEGIN_NETWORK_TABLE( CASW_Grenade_Vindicator, DT_ASW_Grenade_Vindicator )
58+
SendPropVector( SENDINFO( m_vecDetonateOrigin ) ),
59+
END_NETWORK_TABLE()
60+
5461
extern int g_sModelIndexFireball; // (in combatweapon.cpp) holds the index for the smoke cloud
5562

5663
CASW_Grenade_Vindicator::CASW_Grenade_Vindicator()
@@ -76,10 +83,12 @@ void CASW_Grenade_Vindicator::Spawn( void )
7683
m_DmgRadius = 220.0f;
7784
m_bDamagedByExplosions = rd_vindicator_grenade_pushed_by_explosions.GetBool();
7885

79-
Ignite(3.0, false, 0, false);
86+
Ignite( 3.0, false, 0, false );
8087

8188
m_takedamage = DAMAGE_YES;
8289

90+
m_vecDetonateOrigin = Vector( 0.0, 0.0, 0.0 );
91+
8392
SetSize( -Vector(4,4,4), Vector(4,4,4) );
8493
SetSolid( SOLID_BBOX );
8594
SetGravity( asw_vindicator_grenade_gravity.GetFloat() );
@@ -232,6 +241,9 @@ void CASW_Grenade_Vindicator::Detonate()
232241
m_takedamage = DAMAGE_NO;
233242

234243
StopSound( "ASWGrenade.Alarm" );
244+
245+
m_vecDetonateOrigin = GetAbsOrigin();
246+
235247
CPASFilter filter( GetAbsOrigin() );
236248

237249
/*
@@ -245,15 +257,6 @@ void CASW_Grenade_Vindicator::Detonate()
245257
m_flDamage );
246258
*/
247259

248-
if ( !m_bSilent )
249-
{
250-
EmitSound( "ASWGrenade.Incendiary" );
251-
}
252-
// throw out some flames
253-
CEffectData data;
254-
data.m_vOrigin = GetAbsOrigin();
255-
DispatchEffect( "ASWFireBurst", data );
256-
257260
Vector vecForward = GetAbsVelocity();
258261
VectorNormalize(vecForward);
259262
trace_t tr;
@@ -345,7 +348,24 @@ void CASW_Grenade_Vindicator::Detonate()
345348
m_iClusters--;
346349
}
347350

348-
UTIL_Remove( this );
351+
// hack to remove the burning particles on the grenade itself
352+
// theres probably a better way but this has been bothering me for couple hours now
353+
CEntityFlame* pEntityFlame = dynamic_cast< CEntityFlame* >( GetEffectEntity() );
354+
if ( pEntityFlame )
355+
{
356+
pEntityFlame->AttachToEntity( NULL );
357+
SetEffectEntity( NULL );
358+
Extinguish();
359+
}
360+
361+
SetModelIndex( 0 );
362+
SetModelName( NULL_STRING );
363+
SetTouch( NULL );
364+
SetSolid( SOLID_NONE );
365+
366+
// give time for m_vecDetonateOrigin to be sent to client so it can simulate the explosion effects
367+
SetThink( &CASW_Grenade_Vindicator::SUB_Remove );
368+
SetNextThink( gpGlobals->curtime + 2.0f );
349369
}
350370

351371
void CASW_Grenade_Vindicator::Precache()
@@ -360,6 +380,7 @@ void CASW_Grenade_Vindicator::Precache()
360380
PrecacheScriptSound("ASWGrenade.Alarm");
361381
PrecacheScriptSound("Grenade.ImpactHard");
362382
PrecacheParticleSystem( "VindGrenade" );
383+
PrecacheParticleSystem( "vindicator_grenade" );
363384
PrecacheParticleSystem( "grenade_main_trail" );
364385
}
365386

@@ -370,44 +391,10 @@ void CASW_Grenade_Vindicator::KillEffects()
370391

371392
void CASW_Grenade_Vindicator::CreateEffects()
372393
{
373-
// Start up the eye glow
374-
/*
375-
m_pMainGlow = CSprite::SpriteCreate( "sprites/redglow1.vmt", GetLocalOrigin(), false );
376-
377-
int nAttachment = LookupAttachment( "fuse" );
378-
379-
if ( m_pMainGlow != NULL )
380-
{
381-
m_pMainGlow->FollowEntity( this );
382-
m_pMainGlow->SetAttachment( this, nAttachment );
383-
m_pMainGlow->SetTransparency( kRenderGlow, 255, 255, 255, 200, kRenderFxNoDissipation );
384-
m_pMainGlow->SetScale( 0.2f );
385-
m_pMainGlow->SetGlowProxySize( 4.0f );
386-
}
387-
388-
// Start up the eye trail
389-
m_pGlowTrail = CSpriteTrail::SpriteTrailCreate( "sprites/bluelaser1.vmt", GetLocalOrigin(), false );
390-
391-
if ( m_pGlowTrail != NULL )
392-
{
393-
m_pGlowTrail->FollowEntity( this );
394-
m_pGlowTrail->SetAttachment( this, nAttachment );
395-
m_pGlowTrail->SetTransparency( kRenderTransAdd, 255, 0, 0, 255, kRenderFxNone );
396-
m_pGlowTrail->SetStartWidth( 8.0f );
397-
m_pGlowTrail->SetEndWidth( 1.0f );
398-
m_pGlowTrail->SetLifeTime( 0.5f );
399-
}
400-
*/
401-
402-
CEffectData data;
403-
data.m_vOrigin = GetAbsOrigin();
404-
//data.m_vNormal = dir;
405-
//data.m_flScale = (float)amount;
406-
CPASFilter filter( data.m_vOrigin );
407-
filter.SetIgnorePredictionCull(true);
408-
DispatchParticleEffect( "rocket_trail_small", PATTACH_ABSORIGIN_FOLLOW, this, "fuse", false, -1, &filter );
394+
409395
}
410396

397+
411398
int CASW_Grenade_Vindicator::OnTakeDamage_Dying( const CTakeDamageInfo &info )
412399
{
413400
return BaseClass::OnTakeDamage_Dying(info);

src/game/server/swarm/asw_grenade_vindicator.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ class CASW_Grenade_Vindicator : public CASW_Rifle_Grenade
1313
public:
1414
DECLARE_CLASS( CASW_Grenade_Vindicator, CASW_Rifle_Grenade );
1515

16-
#if !defined( CLIENT_DLL )
16+
DECLARE_SERVERCLASS();
1717
DECLARE_DATADESC();
18-
#endif
1918

2019
CASW_Grenade_Vindicator();
2120
virtual ~CASW_Grenade_Vindicator( void );
@@ -49,6 +48,8 @@ class CASW_Grenade_Vindicator : public CASW_Rifle_Grenade
4948
bool m_bKicked;
5049
bool m_bExplodeOnWorldContact;
5150

51+
CNetworkVector( m_vecDetonateOrigin );
52+
5253
CHandle<CSprite> m_pMainGlow;
5354
CHandle<CSpriteTrail> m_pGlowTrail;
5455

0 commit comments

Comments
 (0)