summaryrefslogtreecommitdiff
path: root/game/server/tf/halloween/merasmus/merasmus_behavior/merasmus_zap.cpp
blob: 1be68225c3cd1f86452e5be81e31849b82fa7800 (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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
//
//
//=============================================================================
#include "cbase.h"

#include "../merasmus.h"
#include "merasmus_zap.h"
#include "merasmus_stunned.h"

ActionResult< CMerasmus > CMerasmusZap::OnStart( CMerasmus *me, Action< CMerasmus > *priorAction )
{
	me->GetBodyInterface()->StartActivity( ACT_RANGE_ATTACK2 );
	m_zapTimer.Start( 1.3f );

	m_spellType = SpellType_t( RandomInt( 0, SPELL_COUNT - 1 ) );
	PlayCastSound( me );

	return Continue();
}


ActionResult< CMerasmus > CMerasmusZap::Update( CMerasmus *me, float interval )
{
	// Interupt if stunned
	if ( me->HasStunTimer() )
	{
		return ChangeTo( new CMerasmusStunned, "Stun Interupt!" );
	}

	if ( m_zapTimer.HasStarted() && m_zapTimer.IsElapsed() )
	{
		m_zapTimer.Invalidate();

		const float flSpellRange = 600.f + 50.f * ( me->GetLevel() - 1 );
		const int nTargetCount = 6 + ( me->GetLevel() - 1 );
		const float flMaxDamage = 50.f + ( 5 * (me->GetLevel() - 1) );
		const float flMinDamage = 20.f + ( 5 * (me->GetLevel() - 1) );

		if ( CMerasmus::Zap( me, "effect_staff", flSpellRange, flMinDamage, flMaxDamage, nTargetCount ) )
		{
			me->EmitSound( "Halloween.Merasmus_Spell" );
		}
	}

	if ( me->IsActivityFinished() )
	{
		return Done( "Zapped!" );
	}

	return Continue();
}


void CMerasmusZap::PlayCastSound( CMerasmus* me ) const
{
	CPVSFilter filter( me->WorldSpaceCenter() );
	switch ( m_spellType )
	{
	case SPELL_FIRE:
		{
			me->PlayLowPrioritySound( filter, "Halloween.MerasmusCastFireSpell" ); 
		}
		break;
	case SPELL_LAUNCH:
		{
			me->PlayLowPrioritySound( filter, "Halloween.MerasmusLaunchSpell" );
		}
		break;
	}
}