Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions src/game/client/swarm/c_asw_grenade_vindicator.cpp
Original file line number Diff line number Diff line change
@@ -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 );
}
27 changes: 27 additions & 0 deletions src/game/client/swarm/c_asw_grenade_vindicator.h
Original file line number Diff line number Diff line change
@@ -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<CNewParticleEffect> m_pSmokeTrail;
};

#endif // _INCLUDED_C_ASW_GRENADE_VINDICATOR_H
2 changes: 2 additions & 0 deletions src/game/client/swarm_sdk_client.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1295,6 +1295,7 @@ if exist ..\..\devtools\bin\postbuild.cmd ..\..\devtools\bin\postbuild.cmd clien
<ClCompile Include="swarm\c_asw_gas_grenade_projectile.cpp" />
<ClCompile Include="swarm\c_asw_generic_emitter.cpp" />
<ClCompile Include="swarm\c_asw_generic_emitter_entity.cpp" />
<ClCompile Include="swarm\c_asw_grenade_vindicator.cpp" />
<ClCompile Include="swarm\c_asw_gun_smoke_emitter.cpp" />
<ClCompile Include="swarm\c_asw_hack.cpp" />
<ClCompile Include="swarm\c_asw_hack_computer.cpp" />
Expand Down Expand Up @@ -3166,6 +3167,7 @@ if exist ..\..\devtools\bin\postbuild.cmd ..\..\devtools\bin\postbuild.cmd clien
<ClInclude Include="swarm\c_asw_gas_grenade_projectile.h" />
<ClInclude Include="swarm\c_asw_generic_emitter.h" />
<ClInclude Include="swarm\c_asw_generic_emitter_entity.h" />
<ClInclude Include="swarm\c_asw_grenade_vindicator.h" />
<ClInclude Include="swarm\c_asw_gun_smoke_emitter.h" />
<ClInclude Include="swarm\c_asw_hack.h" />
<ClInclude Include="swarm\c_asw_hack_computer.h" />
Expand Down
3 changes: 3 additions & 0 deletions src/game/server/EntityFlame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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" );
Expand Down
81 changes: 34 additions & 47 deletions src/game/server/swarm/asw_grenade_vindicator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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()
Expand All @@ -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() );
Expand Down Expand Up @@ -232,6 +241,9 @@ void CASW_Grenade_Vindicator::Detonate()
m_takedamage = DAMAGE_NO;

StopSound( "ASWGrenade.Alarm" );

m_vecDetonateOrigin = GetAbsOrigin();

CPASFilter filter( GetAbsOrigin() );

/*
Expand All @@ -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;
Expand Down Expand Up @@ -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()
Expand All @@ -360,6 +380,7 @@ void CASW_Grenade_Vindicator::Precache()
PrecacheScriptSound("ASWGrenade.Alarm");
PrecacheScriptSound("Grenade.ImpactHard");
PrecacheParticleSystem( "VindGrenade" );
PrecacheParticleSystem( "vindicator_grenade" );
PrecacheParticleSystem( "grenade_main_trail" );
}

Expand All @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions src/game/server/swarm/asw_grenade_vindicator.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -49,6 +48,8 @@ class CASW_Grenade_Vindicator : public CASW_Rifle_Grenade
bool m_bKicked;
bool m_bExplodeOnWorldContact;

CNetworkVector( m_vecDetonateOrigin );

CHandle<CSprite> m_pMainGlow;
CHandle<CSpriteTrail> m_pGlowTrail;

Expand Down