1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: TF Concussion Grenade.
//
//=============================================================================//
#include "cbase.h"
#include "tf_weaponbase.h"
#include "tf_gamerules.h"
#include "npcevent.h"
#include "engine/IEngineSound.h"
#include "tf_weapon_grenade_concussion.h"
// Server specific.
#ifdef GAME_DLL
#include "tf_player.h"
#include "items.h"
#include "tf_weaponbase_grenadeproj.h"
#include "soundent.h"
#include "KeyValues.h"
#endif
#define GRENADE_CONCUSSION_TIMER 3.0f // seconds
//=============================================================================
//
// TF Concussion Grenade tables.
//
IMPLEMENT_NETWORKCLASS_ALIASED( TFGrenadeConcussion, DT_TFGrenadeConcussion )
BEGIN_NETWORK_TABLE( CTFGrenadeConcussion, DT_TFGrenadeConcussion )
END_NETWORK_TABLE()
BEGIN_PREDICTION_DATA( CTFGrenadeConcussion )
END_PREDICTION_DATA()
LINK_ENTITY_TO_CLASS( tf_weapon_grenade_concussion, CTFGrenadeConcussion );
PRECACHE_WEAPON_REGISTER( tf_weapon_grenade_concussion );
//=============================================================================
//
// TF Concussion Grenade functions.
//
// Server specific.
#ifdef GAME_DLL
BEGIN_DATADESC( CTFGrenadeConcussion )
END_DATADESC()
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
CTFWeaponBaseGrenadeProj *CTFGrenadeConcussion::EmitGrenade( Vector vecSrc, QAngle vecAngles, Vector vecVel,
AngularImpulse angImpulse, CBasePlayer *pPlayer, float flTime, int iflags )
{
return CTFGrenadeConcussionProjectile::Create( vecSrc, vecAngles, vecVel, angImpulse,
pPlayer, GetTFWpnData(), flTime );
}
#endif
//=============================================================================
//
// TF Concussion Grenade Projectile functions (Server specific).
//
#ifdef GAME_DLL
#define GRENADE_MODEL "models/weapons/w_models/w_grenade_conc.mdl"
LINK_ENTITY_TO_CLASS( tf_weapon_grenade_concussion_projectile, CTFGrenadeConcussionProjectile );
PRECACHE_WEAPON_REGISTER( tf_weapon_grenade_concussion_projectile );
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
CTFGrenadeConcussionProjectile* CTFGrenadeConcussionProjectile::Create( const Vector &position, const QAngle &angles,
const Vector &velocity, const AngularImpulse &angVelocity,
CBaseCombatCharacter *pOwner, const CTFWeaponInfo &weaponInfo, float timer, int iFlags )
{
CTFGrenadeConcussionProjectile *pGrenade = static_cast<CTFGrenadeConcussionProjectile*>( CTFWeaponBaseGrenadeProj::Create( "tf_weapon_grenade_concussion_projectile", position, angles, velocity, angVelocity, pOwner, weaponInfo, timer, iFlags ) );
if ( pGrenade )
{
pGrenade->ApplyLocalAngularVelocityImpulse( angVelocity );
}
return pGrenade;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CTFGrenadeConcussionProjectile::Spawn()
{
SetModel( GRENADE_MODEL );
BaseClass::Spawn();
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CTFGrenadeConcussionProjectile::Precache()
{
PrecacheModel( GRENADE_MODEL );
BaseClass::Precache();
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CTFGrenadeConcussionProjectile::BounceSound( void )
{
EmitSound( "Weapon_Grenade_Concussion.Bounce" );
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CTFGrenadeConcussionProjectile::Detonate()
{
if ( ShouldNotDetonate() )
{
RemoveGrenade();
return;
}
// The trace start/end.
Vector vecStart = GetAbsOrigin() + Vector( 0.0f, 0.0f, 8.0f );
Vector vecEnd = vecStart + Vector( 0.0f, 0.0f, -32.0f );
trace_t trace;
UTIL_TraceLine ( vecStart, vecEnd, MASK_SHOT_HULL, this, COLLISION_GROUP_NONE, &trace );
// Explode (concuss).
Explode( &trace, DMG_BLAST );
// Screen shake.
if ( GetShakeAmplitude() )
{
UTIL_ScreenShake( GetAbsOrigin(), GetShakeAmplitude(), 150.0, 1.0, GetShakeRadius(), SHAKE_START );
}
}
extern ConVar tf_grenade_show_radius;
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CTFGrenadeConcussionProjectile::Explode( trace_t *pTrace, int bitsDamageType )
{
// Server specific.
#ifdef GAME_DLL
// Invisible.
SetModelName( NULL_STRING );
AddSolidFlags( FSOLID_NOT_SOLID );
m_takedamage = DAMAGE_NO;
// Move the impact point away from the surface a little bit.
if ( pTrace->fraction != 1.0 )
{
SetLocalOrigin( pTrace->endpos + ( pTrace->plane.normal * 0.6 ) );
}
// Explosion effect on client
SendDispatchEffect();
// Explosion sound.
CSoundEnt::InsertSound( SOUND_COMBAT, GetAbsOrigin(), BASEGRENADE_EXPLOSION_VOLUME, 3.0 );
// Explosion damage, using the thrower's position as the report position.
CTFPlayer *pPlayer = ToTFPlayer( GetThrower() );
Vector vecReported = pPlayer ? pPlayer->GetAbsOrigin() : vec3_origin;
CTakeDamageInfo info( this, pPlayer, GetBlastForce(), GetAbsOrigin(), m_flDamage, bitsDamageType, 0, &vecReported );
RadiusDamage( info, GetAbsOrigin(), m_DmgRadius, CLASS_NONE, NULL );
// Concussion.
CBaseEntity *pEntityList[64];
int nEntityCount = UTIL_EntitiesInSphere( pEntityList, 64, GetAbsOrigin(), m_DmgRadius, FL_CLIENT );
for ( int iEntity = 0; iEntity < nEntityCount; ++iEntity )
{
CBaseEntity *pEntity = pEntityList[iEntity];
CTFPlayer *pTestPlayer = ToTFPlayer( pEntity );
// You can concuss yourself.
bool bIsThrower = ( pPlayer == pTestPlayer );
if ( bIsThrower || ( pTestPlayer && !InSameTeam( pTestPlayer) ) )
{
pTestPlayer->m_Shared.Concussion( this, m_DmgRadius );
}
}
if ( tf_grenade_show_radius.GetBool() )
{
DrawRadius( m_DmgRadius );
}
// Explosion decal.
UTIL_DecalTrace( pTrace, "Scorch" );
// Reset.
SetThink( &CBaseGrenade::SUB_Remove );
SetTouch( NULL );
AddEffects( EF_NODRAW );
SetAbsVelocity( vec3_origin );
SetNextThink( gpGlobals->curtime );
#endif
}
#endif
|