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
|
//========= Copyright Valve Corporation, All rights reserved. ============//
#include "cbase.h"
#include "c_monster_resource.h"
#include "tf_hud_boss_health.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
void RecvProxy_UpdateBossHud( const CRecvProxyData *pData, void *pStruct, void *pOut );
IMPLEMENT_CLIENTCLASS_DT_NOBASE( C_MonsterResource, DT_MonsterResource, CMonsterResource )
RecvPropInt( RECVINFO( m_iBossHealthPercentageByte ), 0, RecvProxy_UpdateBossHud ),
RecvPropInt( RECVINFO( m_iBossStunPercentageByte ), 0, RecvProxy_UpdateBossHud ),
RecvPropInt( RECVINFO( m_iSkillShotCompleteCount ) ),
RecvPropTime( RECVINFO( m_fSkillShotComboEndTime ) ),
RecvPropInt( RECVINFO( m_iBossState ), 0, RecvProxy_UpdateBossHud ),
END_RECV_TABLE()
C_MonsterResource *g_pMonsterResource = NULL;
//-----------------------------------------------------------------------------
// Update the HUD meter when the Boss' data changes
void RecvProxy_UpdateBossHud( const CRecvProxyData *pData, void *pStruct, void *pOut )
{
int *out = (int *)pOut;
*out = pData->m_Value.m_Int;
CHudBossHealthMeter *meter = GET_HUDELEMENT( CHudBossHealthMeter );
if ( meter )
{
meter->Update();
}
}
//-----------------------------------------------------------------------------
C_MonsterResource::C_MonsterResource()
{
m_iBossHealthPercentageByte = 0;
m_iBossStunPercentageByte = 0;
m_iSkillShotCompleteCount = 0;
m_fSkillShotComboEndTime = 0;
m_iBossState = 0;
// do this here because entity is created via network messages from the server entity's creation
Assert( g_pMonsterResource == NULL );
g_pMonsterResource = this;
}
//-----------------------------------------------------------------------------
C_MonsterResource::~C_MonsterResource()
{
Assert( g_pMonsterResource == this );
g_pMonsterResource = NULL;
}
//-----------------------------------------------------------------------------
float C_MonsterResource::GetBossHealthPercentage( void )
{
return (float)m_iBossHealthPercentageByte / 255.0f;
}
//-----------------------------------------------------------------------------
float C_MonsterResource::GetBossStunPercentage( void )
{
return (float)m_iBossStunPercentageByte / 255.0f;
}
|