summaryrefslogtreecommitdiff
path: root/game/server/tf/halloween/zombie/zombie_behavior/zombie_special_attack.cpp
blob: ee2ca3c02d7a1597b951513e96284f00bbaaa8b2 (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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
//
//
//=============================================================================
#include "cbase.h"

#include "tf_player.h"
#include "tf_gamerules.h"
#include "tf_fx.h"

#include "../zombie.h"
#include "zombie_special_attack.h"

ActionResult< CZombie >	CZombieSpecialAttack::OnStart( CZombie *me, Action< CZombie > *priorAction )
{
	me->GetBodyInterface()->StartActivity( ACT_SPECIAL_ATTACK1 );

	m_stompTimer.Start( 1 );

	return Continue();
}


ActionResult< CZombie >	CZombieSpecialAttack::Update( CZombie *me, float interval )
{
	if ( m_stompTimer.HasStarted() && m_stompTimer.IsElapsed() )
	{
		DoSpecialAttack( me );
		m_stompTimer.Invalidate();
	}

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

	return Continue();
}


void CZombieSpecialAttack::DoSpecialAttack( CZombie *me )
{
	CPVSFilter filter( me->GetAbsOrigin() );
	TE_TFParticleEffect( filter, 0.0, "bomibomicon_ring", me->GetAbsOrigin(), vec3_angle );

	int nTargetTeam = TEAM_ANY;
	if ( me->GetTeamNumber() != TF_TEAM_HALLOWEEN )
	{
		nTargetTeam = me->GetTeamNumber() == TF_TEAM_RED ? TF_TEAM_BLUE : TF_TEAM_RED;
	}

	CUtlVector< CTFPlayer* > pushedPlayers;
	TFGameRules()->PushAllPlayersAway( me->GetAbsOrigin(), 200.f, 500.f, nTargetTeam, &pushedPlayers );

	CBaseEntity *pAttacker = me->GetOwnerEntity() ? me->GetOwnerEntity() : me;
	for ( int i=0; i<pushedPlayers.Count(); ++i )
	{
		Vector toVictim = pushedPlayers[i]->WorldSpaceCenter() - me->WorldSpaceCenter();
		toVictim.NormalizeInPlace();

		// hit!
		CTakeDamageInfo info( pAttacker, pAttacker, me->GetAttackDamage(), DMG_SLASH );
		info.SetDamageCustom( TF_DMG_CUSTOM_SPELL_SKELETON );
		CalculateMeleeDamageForce( &info, toVictim, me->WorldSpaceCenter(), 5.0f );
		pushedPlayers[i]->TakeDamage( info );
	}
}