blob: 5e9b7f48e070444ef4bbdff97136323e434c47ea (
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================//
#include "cbase.h"
#include "tf_gamerules.h"
#include "merasmus_dancer.h"
#include "animation.h"
//-----------------------------------------------------------------------------
#include "tf_fx.h"
//-----------------------------------------------------------------------------
#define POOF_SOUND "Halloween.Merasmus_Hiding_Explode"
//-----------------------------------------------------------------------------
LINK_ENTITY_TO_CLASS( merasmus_dancer, CMerasmusDancer );
IMPLEMENT_SERVERCLASS_ST( CMerasmusDancer, DT_MerasmusDancer )
END_SEND_TABLE()
//-----------------------------------------------------------------------------
#define MERASMUS_MODEL_NAME "models/bots/merasmus/merasmus.mdl"
//-----------------------------------------------------------------------------
CMerasmusDancer::CMerasmusDancer()
: m_bEmitParticleEffect( false )
{
}
//-----------------------------------------------------------------------------
CMerasmusDancer::~CMerasmusDancer()
{
}
//-----------------------------------------------------------------------------
void CMerasmusDancer::Spawn()
{
Precache();
m_DieCountdownTimer.Invalidate();
BaseClass::Spawn();
SetModel( MERASMUS_MODEL_NAME );
UseClientSideAnimation();
SetThink( &CMerasmusDancer::DanceThink );
SetNextThink( gpGlobals->curtime );
m_bEmitParticleEffect = true;
}
//-----------------------------------------------------------------------------
void CMerasmusDancer::PlaySequence( const char *pSeqName )
{
int iAnimSequence = LookupSequence( pSeqName ); // dance animation
if ( iAnimSequence )
{
SetSequence( iAnimSequence );
SetPlaybackRate( 1.0f );
SetCycle( 0 );
ResetSequenceInfo();
HideStaff();
}
}
//-----------------------------------------------------------------------------
void CMerasmusDancer::PlayActivity( int iActivity )
{
int iAnimSequence = ::SelectWeightedSequence( GetModelPtr(), iActivity, GetSequence() );
if ( iAnimSequence )
{
SetSequence( iAnimSequence );
SetPlaybackRate( 1.0f );
SetCycle( 0 );
ResetSequenceInfo();
HideStaff();
}
}
//-----------------------------------------------------------------------------
void CMerasmusDancer::HideStaff()
{
int nStaffBodyGroup = FindBodygroupByName( "staff" );
SetBodygroup( nStaffBodyGroup, 2 );
}
//-----------------------------------------------------------------------------
void CMerasmusDancer::Dance()
{
PlaySequence( "taunt06" );
}
//-----------------------------------------------------------------------------
void CMerasmusDancer::Vanish()
{
m_bEmitParticleEffect = true;
m_DieCountdownTimer.Start( 0.0f );
}
//-----------------------------------------------------------------------------
void CMerasmusDancer::BlastOff()
{
m_bEmitParticleEffect = true;
m_DieCountdownTimer.Start( 0.3f );
PlayActivity( ACT_FLY );
}
//-----------------------------------------------------------------------------
void CMerasmusDancer::Precache()
{
BaseClass::Precache();
int model = PrecacheModel( MERASMUS_MODEL_NAME );
PrecacheGibsForModel( model );
PrecacheParticleSystem( "merasmus_tp" ); // puff effect
PrecacheScriptSound( POOF_SOUND );
// We deliberately allow late precaches here.
bool bAllowPrecache = CBaseAnimating::IsPrecacheAllowed();
CBaseAnimating::SetAllowPrecache( bAllowPrecache );
}
//-----------------------------------------------------------------------------
bool CMerasmusDancer::ShouldDelete() const
{
return m_DieCountdownTimer.HasStarted() && m_DieCountdownTimer.IsElapsed();
}
//-----------------------------------------------------------------------------
void CMerasmusDancer::DanceThink()
{
// Emit the initial effect here, rather than in Spawn(), since GetAbsOrigin() and GetAbsAngles() don't return useful values then.
if ( m_bEmitParticleEffect )
{
DispatchParticleEffect( "merasmus_tp", GetAbsOrigin(), GetAbsAngles() );
m_bEmitParticleEffect = false;
EmitSound( POOF_SOUND );
}
if ( ShouldDelete() )
{
EmitSound( POOF_SOUND );
UTIL_Remove( this );
return;
}
SetNextThink( gpGlobals->curtime );
}
|