blob: de9400d1693e8805c4552d04730dba6a1024b1fd (
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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================
#include "cbase.h"
#include "tf_weapon_fists.h"
#include "decals.h"
// Client specific.
#ifdef CLIENT_DLL
#include "c_tf_player.h"
#include "c_tf_gamestats.h"
// Server specific.
#else
#include "tf_player.h"
#include "tf_gamestats.h"
#endif
//=============================================================================
//
// Weapon Fists tables.
//
IMPLEMENT_NETWORKCLASS_ALIASED( TFFists, DT_TFWeaponFists )
BEGIN_NETWORK_TABLE( CTFFists, DT_TFWeaponFists )
END_NETWORK_TABLE()
BEGIN_PREDICTION_DATA( CTFFists )
END_PREDICTION_DATA()
LINK_ENTITY_TO_CLASS( tf_weapon_fists, CTFFists );
PRECACHE_WEAPON_REGISTER( tf_weapon_fists );
//=============================================================================
//
// Weapon Fists functions.
//
// -----------------------------------------------------------------------------
// Purpose:
// -----------------------------------------------------------------------------
void CTFFists::ItemPreFrame( void )
{
return BaseClass::ItemPreFrame();
}
// -----------------------------------------------------------------------------
// Purpose:
// -----------------------------------------------------------------------------
void CTFFists::PrimaryAttack()
{
if ( !CanAttack() )
return;
// Set the weapon usage mode - primary, secondary.
// reversed for 360 because the primary attack is on the right side of the controller
if ( IsX360() || IsViewModelFlipped() )
{
m_iWeaponMode = TF_WEAPON_SECONDARY_MODE;
}
else
{
m_iWeaponMode = TF_WEAPON_PRIMARY_MODE;
}
Punch();
}
// -----------------------------------------------------------------------------
// Purpose:
// -----------------------------------------------------------------------------
void CTFFists::SecondaryAttack()
{
if ( !CanAttack() )
return;
CTFPlayer *pPlayer = GetTFPlayerOwner();
if ( pPlayer && pPlayer->m_Shared.IsControlStunned() )
{
return;
}
// Set the weapon usage mode - primary, secondary.
if ( IsX360() || IsViewModelFlipped() )
{
m_iWeaponMode = TF_WEAPON_PRIMARY_MODE;
}
else
{
m_iWeaponMode = TF_WEAPON_SECONDARY_MODE;
}
Punch();
}
// -----------------------------------------------------------------------------
// Purpose:
// -----------------------------------------------------------------------------
bool CTFFists::Holster( CBaseCombatWeapon *pSwitchingTo )
{
return BaseClass::Holster( pSwitchingTo );
}
// -----------------------------------------------------------------------------
// Purpose:
// -----------------------------------------------------------------------------
void CTFFists::Punch( void )
{
// Get the current player.
CTFPlayer *pPlayer = GetTFPlayerOwner();
if ( !pPlayer )
return;
// Swing the weapon.
Swing( pPlayer );
m_flNextSecondaryAttack = m_flNextPrimaryAttack;
#if !defined( CLIENT_DLL )
pPlayer->SpeakWeaponFire();
CTF_GameStats.Event_PlayerFiredWeapon( pPlayer, IsCurrentAttackACrit() );
if ( pPlayer->m_Shared.IsStealthed() )
{
pPlayer->RemoveInvisibility();
}
#else
C_CTF_GameStats.Event_PlayerFiredWeapon( pPlayer, IsCurrentAttackACrit() );
#endif
}
//-----------------------------------------------------------------------------
// Purpose: Allow melee weapons to send different anim events
// Input : -
//-----------------------------------------------------------------------------
void CTFFists::SendPlayerAnimEvent( CTFPlayer *pPlayer )
{
// Send extra activities to the weapon for breadgloves
if ( IsCurrentAttackACrit() )
{
pPlayer->DoAnimationEvent( PLAYERANIMEVENT_ATTACK_SECONDARY );
}
else
{
pPlayer->DoAnimationEvent( PLAYERANIMEVENT_ATTACK_PRIMARY );
}
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CTFFists::DoViewModelAnimation( void )
{
Activity act;
if ( IsCurrentAttackACrit() )
{
act = ACT_VM_SWINGHARD;
}
else
{
act = ( m_iWeaponMode == TF_WEAPON_PRIMARY_MODE ) ? ACT_VM_HITLEFT : ACT_VM_HITRIGHT;
}
SendWeaponAnim( act );
// Send WeaponAnim actually sets all anims and we want an override for the world model
//int iIsBreadgloves = 0;
//CALL_ATTRIB_HOOK_INT( iIsBreadgloves, breadgloves_properties );
//if ( iIsBreadgloves )
//{
// ResetSequence( SelectWeightedSequence( ACT_BREADMONSTER_GLOVES_HITRIGHT ) );
// SetPlaybackRate( 0.0f );
// ResetClientsideFrame();
//}
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
bool CTFFists::AllowTaunts( void )
{
// Radial buff fists don't allow player to taunt manually
return ( GetFistType() != FISTTYPE_RADIAL_BUFF );
}
#ifdef GAME_DLL
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CTFFists::OnEntityHit( CBaseEntity *pEntity, CTakeDamageInfo *info )
{
CTFPlayer *pHitPlayer = ToTFPlayer( pEntity );
if ( !pHitPlayer )
return;
// Get the current player.
CTFPlayer *pPlayer = GetTFPlayerOwner();
if ( !pPlayer )
return;
if ( pHitPlayer->GetTeamNumber() == pPlayer->GetTeamNumber() )
return;
if ( pPlayer->m_Shared.InCond( TF_COND_INVULNERABLE ) )
{
int iNumHealers = pPlayer->m_Shared.GetNumHealers();
// for each medic healing me
for ( int i=0;i<iNumHealers;i++ )
{
CTFPlayer *pMedic = ToTFPlayer( pPlayer->m_Shared.GetHealerByIndex( i ) );
// if it's a medic and that medic is releasing charge
if ( pMedic && pMedic->GetChargeEffectBeingProvided() == MEDIGUN_CHARGE_INVULN )
{
// they are invulning me - add pEntity to their list of people punched
pMedic->HandleAchievement_Medic_AssistHeavy( pHitPlayer );
}
}
}
// If we've killed someone, check to see for the unique fist kill response
if ( !pEntity->IsAlive() )
{
if ( GetFistType() == FISTTYPE_RADIAL_BUFF )
{
pPlayer->Taunt();
}
}
}
#endif
|