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
|
//========= Copyright Valve Corporation, All rights reserved. ============//
// headless_hatman_terrify.cpp
// The Halloween Boss leans over and yells "Boo!", terrifying nearby victims
// Michael Booth, October 2010
#include "cbase.h"
#include "tf_player.h"
#include "tf_team.h"
#include "../headless_hatman.h"
#include "headless_hatman_terrify.h"
//---------------------------------------------------------------------------------------------
ActionResult< CHeadlessHatman > CHeadlessHatmanTerrify::OnStart( CHeadlessHatman *me, Action< CHeadlessHatman > *priorAction )
{
me->AddGesture( ACT_MP_GESTURE_VC_HANDMOUTH_ITEM1 );
m_booTimer.Start( 0.25f );
m_scareTimer.Start( 0.75f );
m_timer.Start( 1.25f );
return Continue();
}
//---------------------------------------------------------------------------------------------
ActionResult< CHeadlessHatman > CHeadlessHatmanTerrify::Update( CHeadlessHatman *me, float interval )
{
if ( m_timer.IsElapsed() )
{
return Done();
}
if ( m_booTimer.HasStarted() && m_booTimer.IsElapsed() )
{
m_booTimer.Invalidate();
me->EmitSound( "Halloween.HeadlessBossBoo" );
}
if ( m_scareTimer.IsElapsed() )
{
CUtlVector< CTFPlayer * > playerVector;
CollectPlayers( &playerVector, TF_TEAM_RED, COLLECT_ONLY_LIVING_PLAYERS );
CollectPlayers( &playerVector, TF_TEAM_BLUE, COLLECT_ONLY_LIVING_PLAYERS, APPEND_PLAYERS );
for( int i=0; i<playerVector.Count(); ++i )
{
CTFPlayer *victim = playerVector[i];
if ( me->IsRangeLessThan( victim, tf_halloween_bot_terrify_radius.GetFloat() ) )
{
if ( !IsWearingPumpkinHeadOrSaxtonMask( victim ) && me->IsLineOfSightClear( victim ) )
{
// scare them!
const float scareTime = 2.0f;
const float speedReduction = 0.0f;
// "stun by trigger" results in the Halloween "yikes" effects
int stunFlags = TF_STUN_LOSER_STATE | TF_STUN_BY_TRIGGER;
victim->m_Shared.StunPlayer( scareTime, speedReduction, stunFlags, NULL );
}
}
}
}
return Continue();
}
//---------------------------------------------------------------------------------------------
bool CHeadlessHatmanTerrify::IsWearingPumpkinHeadOrSaxtonMask( CTFPlayer *player )
{
const int pumpkinHeadHat = 278;
const int saxtonMask = 277;
for( int i=0; i<player->GetNumWearables(); ++i )
{
CEconWearable *wearable = player->GetWearable( i );
if ( wearable && wearable->GetAttributeContainer() )
{
CEconItemView *item = wearable->GetAttributeContainer()->GetItem();
if ( item && item->IsValid() )
{
if ( item->GetItemDefIndex() == pumpkinHeadHat || item->GetItemDefIndex() == saxtonMask )
{
return true;
}
}
}
}
return false;
}
|