blob: 9b1038a24a1b6f77d53f138eb6453bf70f213300 (
plain) (
blame)
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
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================//
#include "cbase.h"
#include "fx_dod_shared.h"
#include "weapon_dodfireselect.h"
#ifdef CLIENT_DLL
#include "prediction.h"
#endif
IMPLEMENT_NETWORKCLASS_ALIASED( DODFireSelectWeapon, DT_FireSelectWeapon )
BEGIN_NETWORK_TABLE( CDODFireSelectWeapon, DT_FireSelectWeapon )
#ifdef CLIENT_DLL
RecvPropBool( RECVINFO( m_bSemiAuto ) )
#else
SendPropBool( SENDINFO( m_bSemiAuto ) )
#endif
END_NETWORK_TABLE()
BEGIN_PREDICTION_DATA( CDODFireSelectWeapon )
END_PREDICTION_DATA()
CDODFireSelectWeapon::CDODFireSelectWeapon()
{
}
void CDODFireSelectWeapon::Spawn( void )
{
m_bSemiAuto = false;
#ifdef CLIENT_DLL
ResetViewModelAnimDir();
#endif
m_iAltFireHint = HINT_USE_SEMI_AUTO;
BaseClass::Spawn();
}
void CDODFireSelectWeapon::PrimaryAttack( void )
{
if ( IsSemiAuto() )
{
// If semi auto, set this flag which will prevent us from
// attacking again until the button is released.
m_bInAttack = true;
}
BaseClass::PrimaryAttack();
}
float CDODFireSelectWeapon::GetFireDelay( void )
{
if ( IsSemiAuto() )
{
return m_pWeaponInfo->m_flSecondaryFireDelay;
}
else
{
return m_pWeaponInfo->m_flFireDelay;
}
}
void CDODFireSelectWeapon::SecondaryAttack( void )
{
// toggle fire mode ( full auto, semi auto )
m_bSemiAuto = !m_bSemiAuto;
#ifndef CLIENT_DLL
CDODPlayer *pPlayer = GetDODPlayerOwner();
if ( pPlayer )
{
pPlayer->RemoveHintTimer( m_iAltFireHint );
}
#endif
if ( m_bSemiAuto )
{
#ifdef CLIENT_DLL
if ( prediction->IsFirstTimePredicted() )
{
m_flPosChangeTimer = gpGlobals->curtime;
m_bAnimToSemiAuto = false;
}
#endif
SendWeaponAnim( ACT_VM_UNDEPLOY );
}
else
{
#ifdef CLIENT_DLL
if ( prediction->IsFirstTimePredicted() )
{
m_flPosChangeTimer = gpGlobals->curtime;
m_bAnimToSemiAuto = true;
}
#endif
SendWeaponAnim( ACT_VM_DEPLOY );
}
#ifdef CLIENT_DLL
if ( prediction->IsFirstTimePredicted() )
{
m_flPosChangeTimer = gpGlobals->curtime;
}
#endif
m_flNextSecondaryAttack = gpGlobals->curtime + SequenceDuration();
m_flNextPrimaryAttack = gpGlobals->curtime + SequenceDuration();
}
bool CDODFireSelectWeapon::IsSemiAuto( void )
{
return m_bSemiAuto;
}
float CDODFireSelectWeapon::GetWeaponAccuracy( float flPlayerSpeed )
{
float flSpread;
if ( IsSemiAuto() )
flSpread = m_pWeaponInfo->m_flSecondaryAccuracy;
else
flSpread = m_pWeaponInfo->m_flAccuracy;
if( flPlayerSpeed > 45 )
flSpread += m_pWeaponInfo->m_flAccuracyMovePenalty;
return flSpread;
}
Activity CDODFireSelectWeapon::GetIdleActivity( void )
{
if ( !IsSemiAuto() )
return ACT_VM_IDLE_DEPLOYED;
return BaseClass::GetIdleActivity();
}
Activity CDODFireSelectWeapon::GetPrimaryAttackActivity( void )
{
if ( !IsSemiAuto() )
return ACT_VM_PRIMARYATTACK_DEPLOYED;
return BaseClass::GetPrimaryAttackActivity();
}
Activity CDODFireSelectWeapon::GetReloadActivity( void )
{
if ( !IsSemiAuto() )
return ACT_VM_RELOAD_DEPLOYED;
return BaseClass::GetReloadActivity();
}
Activity CDODFireSelectWeapon::GetDrawActivity( void )
{
if ( !IsSemiAuto() )
return ACT_VM_DRAW_DEPLOYED;
return BaseClass::GetDrawActivity();
}
void CDODFireSelectWeapon::Drop( const Vector &vecVelocity )
{
// always full auto when you pick up a weapon
m_bSemiAuto = false;
return BaseClass::Drop( vecVelocity );
}
#ifdef CLIENT_DLL
Vector CDODFireSelectWeapon::GetDesiredViewModelOffset( C_DODPlayer *pOwner )
{
Vector viewOffset = pOwner->GetViewOffset();
float flPercent = ( viewOffset.z - VEC_PRONE_VIEW_SCALED( pOwner ).z ) / ( VEC_VIEW_SCALED( pOwner ).z - VEC_PRONE_VIEW_SCALED( pOwner ).z );
Vector offset = ( flPercent * GetDODWpnData().m_vecViewNormalOffset +
( 1.0 - flPercent ) * GetDODWpnData().m_vecViewProneOffset );
static float flLastPercent = 0;
if ( prediction->InPrediction() )
{
return ( flLastPercent * offset +
( 1.0 - flLastPercent ) * GetDODWpnData().m_vecViewProneOffset );
}
float timer = gpGlobals->curtime - m_flPosChangeTimer;
// how long since we changed iron sight mode
float flPosChangePercent = clamp( ( timer / ( 0.3 ) ), 0.0, 1.0 );
float flZoomPercent = ( m_bAnimToSemiAuto ? ( 1.0 - flPosChangePercent ) : flPosChangePercent );
// store this value to use when called in prediction
flLastPercent = flZoomPercent;
return ( flZoomPercent * GetDODWpnData().m_vecIronSightOffset +
( 1.0 - flZoomPercent ) * offset );
}
#endif
|