summaryrefslogtreecommitdiff
path: root/game/server/tf/func_powerupvolume.cpp
blob: 8a8ecfaf26b8ac24ce4dc65a5c4a689f21e396ab (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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: CTF Powerup Volume.
//
//=============================================================================//

#include "cbase.h"
#include "tf_player.h"
#include "tf_item.h"
#include "tf_team.h"
#include "func_powerupvolume.h"
#include "tf_gamerules.h"
#include "eventqueue.h"

LINK_ENTITY_TO_CLASS( func_powerupvolume, CPowerupVolume );

#define TF_POWERUPVOLUME_SOUND			"Powerup.Volume.Use"
#define TF_POWERUPVOLUME_ANNOUNCE		"Announcer.Powerup.Volume.Starting"

IMPLEMENT_AUTO_LIST( IFuncPowerupVolumeAutoList );

//-----------------------------------------------------------------------------
// Purpose: Constructor
//-----------------------------------------------------------------------------
CPowerupVolume::CPowerupVolume()
{
	m_bDisabled = false;
}

//-----------------------------------------------------------------------------
// Purpose: Spawn function for the entity
//-----------------------------------------------------------------------------
void CPowerupVolume::Spawn( void )
{
	Precache();
	InitTrigger();
	SetTouch( &CPowerupVolume::Touch );
}

//-----------------------------------------------------------------------------
// Purpose: Precache function for the entity
//-----------------------------------------------------------------------------
void CPowerupVolume::Precache( void )
{
	PrecacheScriptSound( TF_POWERUPVOLUME_SOUND );
	PrecacheScriptSound( TF_POWERUPVOLUME_ANNOUNCE );
}

//-----------------------------------------------------------------------------
// Purpose:		
//-----------------------------------------------------------------------------
void CPowerupVolume::Touch( CBaseEntity *pOther )
{
	if ( !IsDisabled() && pOther->IsPlayer() )
	{
		CTFPlayer *pPlayer = ToTFPlayer( pOther );
		if ( pPlayer && !( pPlayer->m_Shared.InCond( TF_COND_RUNE_IMBALANCE ) ) )
		{
			if ( pPlayer->IsTaunting() )
				return;

			if ( TFGameRules()->State_Get() == GR_STATE_TEAM_WIN )
				return;

			if ( TFGameRules()->InStalemate() )
				return;

			int iTeam = GetTeamNumber();
			
			if ( iTeam && ( pPlayer->GetTeamNumber() != iTeam ) )
					return;

			// call think function here so the first time the volume is used, it starts its timeout delay, and fires the tf_gamerules outputs when it times out
			
			pPlayer->m_Shared.AddCond( TF_COND_RUNE_IMBALANCE, 20.f );
			pPlayer->m_Shared.AddCond( TF_COND_CRITBOOSTED_RUNE_TEMP, 20.f );
			pPlayer->EmitSound( TF_POWERUPVOLUME_SOUND );
			m_nNumberOfTimesUsed++;
		}
	}
}

//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
bool CPowerupVolume::IsDisabled( void )
{
	return m_bDisabled;
}

//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CPowerupVolume::SetDisabled( bool bDisabled )
{
	m_bDisabled = bDisabled;
}