blob: 81a58b028943acd0c7226e7a8e59a4ad72938744 (
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
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: CTF Armor.
//
//=============================================================================//
#include "cbase.h"
#include "items.h"
#include "tf_gamerules.h"
#include "tf_shareddefs.h"
#include "tf_player.h"
#include "tf_team.h"
#include "engine/IEngineSound.h"
#include "entity_armor.h"
//=============================================================================
//
// CTF Armor defines.
//
#define TF_ARMOR_PICKUP_SOUND "Armor.Touch"
#define TF_ARMOR_CAPACITY 200
LINK_ENTITY_TO_CLASS( item_armor, CArmor );
//=============================================================================
//
// CTF Armor functions.
//
//-----------------------------------------------------------------------------
// Purpose: Spawn function for the armor
//-----------------------------------------------------------------------------
void CArmor::Spawn( void )
{
BaseClass::Spawn();
}
//-----------------------------------------------------------------------------
// Purpose: Precache function for the armor
//-----------------------------------------------------------------------------
void CArmor::Precache( void )
{
PrecacheScriptSound( TF_ARMOR_PICKUP_SOUND );
BaseClass::Precache();
}
//-----------------------------------------------------------------------------
// Purpose: MyTouch function for the armor
//-----------------------------------------------------------------------------
bool CArmor::MyTouch( CBasePlayer *pPlayer )
{
bool bSuccess = false;
if ( ValidTouch( pPlayer ) )
{
CTFPlayer *pCTFPlayer = ToTFPlayer(pPlayer);
if ( pCTFPlayer )
{
int iMaxArmor = pCTFPlayer->GetPlayerClass()->GetMaxArmor();
int iCurrentArmor = pCTFPlayer->ArmorValue();
if ( iCurrentArmor < iMaxArmor )
{
if ( iCurrentArmor + TF_ARMOR_CAPACITY >= iMaxArmor )
{
pCTFPlayer->SetArmorValue( iMaxArmor );
}
else
{
pCTFPlayer->SetArmorValue( iCurrentArmor + TF_ARMOR_CAPACITY );
}
CSingleUserRecipientFilter user( pPlayer );
user.MakeReliable();
UserMessageBegin( user, "ItemPickup" );
WRITE_STRING( GetClassname() );
MessageEnd();
CPASAttenuationFilter filter( this, TF_ARMOR_PICKUP_SOUND );
EmitSound( filter, entindex(), TF_ARMOR_PICKUP_SOUND );
bSuccess = true;
}
}
}
return bSuccess;
}
|