summaryrefslogtreecommitdiff
path: root/game/server/tf2/order_resupply.cpp
blob: 54ddfc7f091f7cbdc342c73a5937666a22066ecd (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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
// $NoKeywords: $
//=============================================================================//

#include "cbase.h"
#include "order_resupply.h"
#include "tf_team.h"
#include "tf_playerclass.h"
#include "order_helpers.h"


// Orders to build resupplies near objects come in within this range.
#define RESUPPLY_ORDER_MAXDIST		2000


IMPLEMENT_SERVERCLASS_ST( COrderResupply, DT_OrderResupply )
END_SEND_TABLE()


bool COrderResupply::CreateOrder( CPlayerClass *pClass )
{
	COrderResupply *pOrder = new COrderResupply;
	if ( OrderCreator_GenericObject( pClass, OBJ_RESUPPLY, RESUPPLY_ORDER_MAXDIST, pOrder ) )
	{
		return true;
	}
	else
	{
		UTIL_RemoveImmediate( pOrder );
		return false;
	}
}


bool COrderResupply::Update()
{
	CBaseEntity *pEnt = GetTargetEntity();
	if( !pEnt )
		return true;

	if ( !m_hOwningPlayer.Get() || m_hOwningPlayer->CanBuild( OBJ_RESUPPLY ) != CB_CAN_BUILD )
		return true;

	CTFTeam *pTeam = m_hOwningPlayer->GetTFTeam();
	if ( pTeam->GetNumResuppliesCoveringPosition( pEnt->GetAbsOrigin() ) )
		return true;

	return BaseClass::Update();	
}