blob: b6f3343a76b40fdd41d4be9ca78f5d26b7a1e5a9 (
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
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: Defuser kit that drops from counter-strike CTS
//
//=============================================================================//
#include "cbase.h"
#include "items.h"
#include "cs_player.h"
class CItemDefuser : public CItem
{
public:
DECLARE_CLASS( CItemDefuser, CItem );
void Spawn( void );
void Precache( void );
void DefuserTouch( CBaseEntity *pOther );
void ActivateThink( void );
DECLARE_DATADESC();
};
LINK_ENTITY_TO_CLASS( item_defuser, CItemDefuser );
PRECACHE_REGISTER(item_defuser);
BEGIN_DATADESC( CItemDefuser )
//Functions
DEFINE_THINKFUNC( ActivateThink ),
DEFINE_ENTITYFUNC( DefuserTouch ),
END_DATADESC()
void CItemDefuser::Spawn( void )
{
Precache( );
SetModel( "models/weapons/w_defuser.mdl" );
BaseClass::Spawn();
SetNextThink( gpGlobals->curtime + 0.5f );
SetThink( &CItemDefuser::ActivateThink );
SetTouch( NULL );
}
void CItemDefuser::Precache( void )
{
PrecacheModel( "models/weapons/w_defuser.mdl" );
PrecacheScriptSound( "BaseCombatCharacter.ItemPickup2" );
}
void CItemDefuser::ActivateThink( void )
{
//since we can't stop the item from being touched while its in the air,
//activate 1 second after being dropped
SetTouch( &CItemDefuser::DefuserTouch );
SetThink( NULL );
}
void CItemDefuser::DefuserTouch( CBaseEntity *pOther )
{
if ( !pOther->IsPlayer() )
{
return;
}
//if( GetFlags() & FL_ONGROUND )
{
CCSPlayer *pPlayer = (CCSPlayer *)pOther;
if ( !pPlayer )
{
Assert( false );
return;
}
if( pPlayer->GetTeamNumber() == TEAM_CT && !pPlayer->HasDefuser() )
{
//=============================================================================
// HPE_BEGIN:
// [dwenger] Added for fun-fact support
//=============================================================================
pPlayer->GiveDefuser( true );
//=============================================================================
// HPE_END
//=============================================================================
if ( pPlayer->IsDead() == false )
{
CPASAttenuationFilter filter( pPlayer );
EmitSound( filter, entindex(), "BaseCombatCharacter.ItemPickup2" );
}
UTIL_Remove( this );
return;
}
}
}
|