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
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#include "cbase.h"
#include "hl1mp_basecombatweapon_shared.h"
#include "effect_dispatch_data.h"
#ifdef CLIENT_DLL
#include "c_te_effect_dispatch.h"
#else
#include "te_effect_dispatch.h"
#endif
#include "hl1_player_shared.h"
LINK_ENTITY_TO_CLASS( basehl1mpcombatweapon, CBaseHL1MPCombatWeapon );
IMPLEMENT_NETWORKCLASS_ALIASED( BaseHL1MPCombatWeapon , DT_BaseHL1MPCombatWeapon )
BEGIN_NETWORK_TABLE( CBaseHL1MPCombatWeapon , DT_BaseHL1MPCombatWeapon )
END_NETWORK_TABLE()
BEGIN_PREDICTION_DATA( CBaseHL1MPCombatWeapon )
END_PREDICTION_DATA()
CBaseHL1MPCombatWeapon::CBaseHL1MPCombatWeapon()
{
SetPredictionEligible( true );
AddSolidFlags( FSOLID_TRIGGER ); // Nothing collides with these but it gets touches.
}
void CBaseHL1MPCombatWeapon::EjectShell( CBaseEntity *pPlayer, int iType )
{
QAngle angShellAngles = pPlayer->GetAbsAngles();
Vector vecForward, vecRight, vecUp;
AngleVectors( angShellAngles, &vecForward, &vecRight, &vecUp );
Vector vecShellPosition = pPlayer->GetAbsOrigin() + pPlayer->GetViewOffset();
switch ( iType )
{
case 0:
default:
vecShellPosition += vecRight * 4;
vecShellPosition += vecUp * -12;
vecShellPosition += vecForward * 20;
break;
case 1:
vecShellPosition += vecRight * 6;
vecShellPosition += vecUp * -12;
vecShellPosition += vecForward * 32;
break;
}
Vector vecShellVelocity = vec3_origin; // pPlayer->GetAbsVelocity();
vecShellVelocity += vecRight * random->RandomFloat( 50, 70 );
vecShellVelocity += vecUp * random->RandomFloat( 100, 150 );
vecShellVelocity += vecForward * 25;
angShellAngles.x = 0;
angShellAngles.z = 0;
CEffectData data;
data.m_vStart = vecShellVelocity;
data.m_vOrigin = vecShellPosition;
data.m_vAngles = angShellAngles;
data.m_fFlags = iType;
DispatchEffect( "HL1ShellEject", data );
}
#ifdef CLIENT_DLL
void CBaseHL1MPCombatWeapon::OnDataChanged( DataUpdateType_t type )
{
BaseClass::OnDataChanged( type );
if ( GetPredictable() && !ShouldPredict() )
ShutdownPredictable();
}
bool CBaseHL1MPCombatWeapon::ShouldPredict()
{
if ( GetOwner() && GetOwner() == C_BasePlayer::GetLocalPlayer() )
return true;
return BaseClass::ShouldPredict();
}
void CBaseHL1MPCombatWeapon::ApplyBoneMatrixTransform( matrix3x4_t& transform )
{
BaseClass::ApplyBoneMatrixTransform( transform );
}
#endif
bool CBaseHL1MPCombatWeapon::IsPredicted() const
{
return true;
}
CBasePlayer* CBaseHL1MPCombatWeapon::GetPlayerOwner() const
{
return dynamic_cast< CBasePlayer* >( GetOwner() );
}
void CBaseHL1MPCombatWeapon::WeaponSound( WeaponSound_t sound_type, float soundtime /* = 0.0f */ )
{
#ifdef CLIENT_DLL
// If we have some sounds from the weapon classname.txt file, play a random one of them
const char *shootsound = GetWpnData().aShootSounds[ sound_type ];
if ( !shootsound || !shootsound[0] )
return;
CBroadcastRecipientFilter filter; // this is client side only
if ( !te->CanPredict() )
return;
CBaseEntity::EmitSound( filter, GetPlayerOwner()->entindex(), shootsound, &GetPlayerOwner()->GetAbsOrigin() );
#else
BaseClass::WeaponSound( sound_type, soundtime );
#endif
}
|