summaryrefslogtreecommitdiff
path: root/game/client/tf/halloween/c_merasmus.cpp
blob: 6e287dc09182b7be7896c839c786975648395c32 (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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
//
//
//=============================================================================
#include "cbase.h"
#include "NextBot/C_NextBot.h"
#include "c_merasmus.h"

// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"

#undef NextBot

//-----------------------------------------------------------------------------
IMPLEMENT_CLIENTCLASS_DT( C_Merasmus, DT_Merasmus, CMerasmus )
	RecvPropBool( RECVINFO( m_bRevealed ) ),
	RecvPropBool( RECVINFO( m_bIsDoingAOEAttack ) ),
	RecvPropBool( RECVINFO( m_bStunned ) ),
END_RECV_TABLE()


//-----------------------------------------------------------------------------
C_Merasmus::C_Merasmus()
{
	m_ghostEffect = NULL;
	m_aoeEffect = NULL;
	m_stunEffect = NULL;
	m_bRevealed = false;
	m_bWasRevealed = false;
	m_bIsDoingAOEAttack = false;
	m_bStunned = false;
}


//-----------------------------------------------------------------------------
C_Merasmus::~C_Merasmus()
{
	if ( m_ghostEffect )
	{
		ParticleProp()->StopEmission( m_ghostEffect );
		m_ghostEffect = NULL;
	}

	if ( m_aoeEffect )
	{
		ParticleProp()->StopEmission( m_aoeEffect );
		m_aoeEffect = NULL;
	}

	if ( m_stunEffect )
	{
		ParticleProp()->StopEmission( m_stunEffect );
		m_stunEffect = NULL;
	}
}


//-----------------------------------------------------------------------------
void C_Merasmus::Spawn( void )
{
	BaseClass::Spawn();

	m_vecViewOffset = Vector( 0, 0, 100.0f );
}


//-----------------------------------------------------------------------------
// Return the origin for player observers tracking this target
Vector C_Merasmus::GetObserverCamOrigin( void ) 
{ 
	return EyePosition();
}


//-----------------------------------------------------------------------------
void C_Merasmus::OnPreDataChanged( DataUpdateType_t updateType )
{
	BaseClass::OnPreDataChanged( updateType );

	m_bWasRevealed = m_bRevealed;
}


//-----------------------------------------------------------------------------
void C_Merasmus::OnDataChanged( DataUpdateType_t updateType )
{
	BaseClass::OnDataChanged( updateType );

	if ( m_bRevealed != m_bWasRevealed )
	{
		if ( m_bRevealed )
		{
			if ( !m_ghostEffect )
			{
				m_ghostEffect = ParticleProp()->Create( "merasmus_ambient_body", PATTACH_ABSORIGIN_FOLLOW );
			}
		}
		else
		{
			if ( m_ghostEffect )
			{
				ParticleProp()->StopEmission( m_ghostEffect );
				m_ghostEffect = NULL;
			}
		}
	}

	// book attack
	if ( m_bIsDoingAOEAttack )
	{
		if ( !m_aoeEffect )
		{
			m_aoeEffect = ParticleProp()->Create( "merasmus_book_attack", PATTACH_POINT_FOLLOW, LookupAttachment( "effect_hand_R" ), Vector( 16.f, 0.f, 0.f ) );
		}
	}
	else
	{
		if ( m_aoeEffect )
		{
			ParticleProp()->StopEmission( m_aoeEffect );
			m_aoeEffect = NULL;
		}
	}

	// stunned
	if ( m_bStunned )
	{
		if ( !m_stunEffect )
		{
			m_stunEffect = ParticleProp()->Create( "merasmus_dazed", PATTACH_POINT_FOLLOW, LookupAttachment( "head" ) );
		}
	}
	else
	{
		if ( m_stunEffect )
		{
			ParticleProp()->StopEmission( m_stunEffect );
			m_stunEffect = NULL;
		}
	}
}


int C_Merasmus::GetSkin()
{
	return ( m_bIsDoingAOEAttack || m_bStunned ) ? 0 : 1;
}