summaryrefslogtreecommitdiff
path: root/game/server/cstrike/func_buy_zone.cpp
blob: a982fe4a1fd76c4b28a39952543de63965ae5456 (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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
//=============================================================================//

#include "cbase.h"
#include "triggers.h"
#include "cs_player.h"


//======================================
// Bomb target area
//
//

class CBuyZone : public CBaseTrigger
{
public:
	DECLARE_CLASS( CBuyZone, CBaseTrigger );
	DECLARE_DATADESC();

	CBuyZone();
	void Spawn();
	void EXPORT BuyZoneTouch( CBaseEntity* pOther );

public:
	int m_LegacyTeamNum;
};


LINK_ENTITY_TO_CLASS( func_buyzone, CBuyZone );

BEGIN_DATADESC( CBuyZone )
	DEFINE_FUNCTION( BuyZoneTouch ),
	
	// This is here to support maps that haven't updated to using "teamnum" yet.
	DEFINE_INPUT( m_LegacyTeamNum, FIELD_INTEGER, "team" )
END_DATADESC()


CBuyZone::CBuyZone()
{
	m_LegacyTeamNum = -1;
}


void CBuyZone::Spawn()
{
	InitTrigger();
	SetTouch( &CBuyZone::BuyZoneTouch );

	// Support for legacy-style teamnums.
	if ( m_LegacyTeamNum == 1 )
	{
		ChangeTeam( TEAM_TERRORIST );
	}
	else if ( m_LegacyTeamNum == 2 )
	{
		ChangeTeam( TEAM_CT );
	}
}

	
void CBuyZone::BuyZoneTouch( CBaseEntity* pOther )
{
	CCSPlayer *p = dynamic_cast< CCSPlayer* >( pOther );
	if ( p )
	{
		// compare player team with buy zone team number
		if ( p->GetTeamNumber() == GetTeamNumber() )
		{
			p->m_bInBuyZone = true;
		}
	}
}