summaryrefslogtreecommitdiff
path: root/game/server/tf2/tf_class_support.cpp
blob: 9406f3cb157c8d91fa27c0a5e7c5f7da4dd42ac2 (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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: The Support/Suppression Player Class
//
// $Workfile:     $
// $Date:         $
// $NoKeywords: $
//=============================================================================//
#include "cbase.h"
#include "tf_player.h"
#include "tf_class_support.h"
#include "basecombatweapon.h"
#include "tf_obj.h"
#include "in_buttons.h"
#include "menu_base.h"
#include "tf_team.h"
#include "weapon_builder.h"

ConVar	class_support_speed( "class_support_speed","200", FCVAR_NONE, "Support movement speed" );

//=============================================================================
//
// Support Data Table
//
BEGIN_SEND_TABLE_NOBASE( CPlayerClassSupport, DT_PlayerClassSupportData )
END_SEND_TABLE()

//-----------------------------------------------------------------------------
// Purpose: 
// Output : const char
//-----------------------------------------------------------------------------
const char *CPlayerClassSupport::GetClassModelString( int nTeam )
{
	static const char *string = "models/player/alien_support.mdl";
	return string;
}


//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
CPlayerClassSupport::CPlayerClassSupport( CBaseTFPlayer *pPlayer, TFClass iClass ) : CPlayerClass( pPlayer, iClass )
{
	for (int i = 1; i <= MAX_TF_TEAMS; ++i)
	{
		SetClassModel( MAKE_STRING(GetClassModelString(i)), i ); 
	}
}

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
CPlayerClassSupport::~CPlayerClassSupport()
{
}

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CPlayerClassSupport::ClassActivate( void )
{
	BaseClass::ClassActivate();

// Any objects created/owned by class should be allocated and destroyed here
	// Setup movement data.
	SetupMoveData();

	m_pPlayer->SetCollisionBounds( SUPPORTCLASS_HULL_STAND_MIN, SUPPORTCLASS_HULL_STAND_MAX );

	memset( &m_ClassData, 0, sizeof( m_ClassData ) );
}

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CPlayerClassSupport::ClassDeactivate( void )
{
	BaseClass::ClassDeactivate();
}

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CPlayerClassSupport::CreateClass( void )
{
	BaseClass::CreateClass();

}

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
bool CPlayerClassSupport::ResupplyAmmo( float flFraction, ResupplyReason_t reason )
{
	bool bGiven = false;

	// On respawn, resupply base weapon ammo
	if ( reason == RESUPPLY_RESPAWN )
	{
	}

	if ( BaseClass::ResupplyAmmo(flFraction, reason) )
		bGiven = true;
	return bGiven;
}

//-----------------------------------------------------------------------------
// Purpose: Set support class specific movement data here.
//-----------------------------------------------------------------------------
void CPlayerClassSupport::SetupMoveData( void )
{
	// Setup Class statistics
	m_flMaxWalkingSpeed = class_support_speed.GetFloat();
}

//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CPlayerClassSupport::SetupSizeData( void )
{
	// Initially set the player to the base player class standing hull size.
	m_pPlayer->SetCollisionBounds( SUPPORTCLASS_HULL_STAND_MIN, SUPPORTCLASS_HULL_STAND_MAX );
	m_pPlayer->SetViewOffset( SUPPORTCLASS_VIEWOFFSET_STAND );
	m_pPlayer->m_Local.m_flStepSize = SUPPORTCLASS_STEPSIZE;	
}

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CPlayerClassSupport::SetPlayerHull( void )
{
	if ( m_pPlayer->GetFlags() & FL_DUCKING )
	{
		m_pPlayer->SetCollisionBounds( SUPPORTCLASS_HULL_DUCK_MIN, SUPPORTCLASS_HULL_DUCK_MAX );
	}
	else
	{
		m_pPlayer->SetCollisionBounds( SUPPORTCLASS_HULL_STAND_MIN, SUPPORTCLASS_HULL_STAND_MAX );
	}
}

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CPlayerClassSupport::ResetViewOffset( void )
{
	if ( m_pPlayer )
	{
		m_pPlayer->SetViewOffset( SUPPORTCLASS_VIEWOFFSET_STAND );
	}
}