blob: 8efc3219cfa21e60e6368acd0ceed74c0139d30e (
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
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
//
//
//=============================================================================
#include "cbase.h"
#include "../merasmus.h"
#include "merasmus_stunned.h"
#include "merasmus_teleport.h"
#include "tf_player.h"
ActionResult< CMerasmus > CMerasmusStunned::OnStart( CMerasmus *me, Action< CMerasmus > *priorAction )
{
m_nStunStage = STUN_BEGIN;
int iLayer = me->AddGesture( ACT_MP_STUN_BEGIN );
float flDuration = me->GetLayerDuration( iLayer );
m_stunAnimationTimer.Start( flDuration );
me->OnBeginStun();
return Continue();
}
ActionResult< CMerasmus > CMerasmusStunned::Update( CMerasmus *me, float interval )
{
// finished?
if ( m_nStunStage == STUN_END && m_stunFinishTimer.IsElapsed() )
{
if ( me->ShouldDisguise() )
{
return Done();
}
if ( me->GetBombHitCount() >= 3 )
{
return ChangeTo( new CMerasmusTeleport( true, true ), "Teleport AOE!" );
}
else
{
return ChangeTo( new CMerasmusTeleport( false, false ), "Teleport to new area!" );
}
}
if ( m_stunAnimationTimer.IsElapsed() )
{
bool bStunned = me->HasStunTimer();
// reset animation if stunned
if ( bStunned )
{
m_nStunStage = STUN_BEGIN;
}
switch ( m_nStunStage )
{
case STUN_BEGIN:
{
int iLayer = me->AddGesture( ACT_MP_STUN_MIDDLE );
float flDuration = me->GetLayerDuration( iLayer );
m_stunAnimationTimer.Start( flDuration );
if ( !bStunned )
{
m_nStunStage = STUN_MID;
}
}
break;
case STUN_MID:
{
int iLayer = me->AddGesture( ACT_MP_STUN_END );
float flDuration = me->GetLayerDuration( iLayer );
m_stunAnimationTimer.Start( flDuration );
m_nStunStage = STUN_END;
m_stunFinishTimer.Start( flDuration + 0.5f );
}
break;
}
}
return Continue();
}
void CMerasmusStunned::OnEnd( CMerasmus *me, Action< CMerasmus > *nextAction )
{
me->OnEndStun();
}
|