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
|
//========= Copyright Valve Corporation, All rights reserved. ============//
// headless_hatman_emerge.cpp
// The Halloween Boss emerging from the ground
// Michael Booth, October 2010
#include "cbase.h"
#include "tf_player.h"
#include "tf_gamerules.h"
#include "tf_team.h"
#include "nav_mesh/tf_nav_area.h"
#include "particle_parse.h"
#include "../headless_hatman.h"
#include "headless_hatman_emerge.h"
#include "headless_hatman_attack.h"
#include "crybaby_boss_escape.h"
//---------------------------------------------------------------------------------------------
ActionResult< CHeadlessHatman > CHeadlessHatmanEmerge::OnStart( CHeadlessHatman *me, Action< CHeadlessHatman > *priorAction )
{
me->GetBodyInterface()->StartActivity( ACT_TRANSITION );
DispatchParticleEffect( "halloween_boss_summon", me->GetAbsOrigin(), me->GetAbsAngles() );
m_riseTimer.Start( 3.0f );
m_emergePos = me->GetAbsOrigin() + Vector( 0, 0, 10.0f );
m_height = 200.0f;
me->SetAbsOrigin( m_emergePos + Vector( 0, 0, -m_height ) );
me->EmitSound( "Halloween.HeadlessBossSpawnRumble" );
// face towards a nearby player
CUtlVector< CTFPlayer * > playerVector;
CollectPlayers( &playerVector, TF_TEAM_RED, COLLECT_ONLY_LIVING_PLAYERS );
CollectPlayers( &playerVector, TF_TEAM_BLUE, COLLECT_ONLY_LIVING_PLAYERS, APPEND_PLAYERS );
float closeRangeSq = FLT_MAX;
CTFPlayer *close = NULL;
for( int i=0; i<playerVector.Count(); ++i )
{
CTFPlayer *player = playerVector[i];
float rangeSq = me->GetRangeSquaredTo( player );
if ( rangeSq < closeRangeSq )
{
closeRangeSq = rangeSq;
close = player;
}
}
QAngle facingAngle;
if ( close )
{
Vector toPlayer = close->GetAbsOrigin() - me->GetAbsOrigin();
toPlayer.z = 0.0f;
toPlayer.NormalizeInPlace();
VectorAngles( toPlayer, Vector(0,0,1), facingAngle );
}
else
{
facingAngle.x = 0.0f;
facingAngle.y = RandomFloat( 0.0f, 360.0f );
facingAngle.z = 0.0f;
}
me->SetAbsAngles( facingAngle );
IGameEvent *event = gameeventmanager->CreateEvent( "pumpkin_lord_summoned" );
if ( event )
{
gameeventmanager->FireEvent( event );
}
return Continue();
}
//----------------------------------------------------------------------------------
ActionResult< CHeadlessHatman > CHeadlessHatmanEmerge::Update( CHeadlessHatman *me, float interval )
{
if ( !m_riseTimer.IsElapsed() )
{
me->SetAbsOrigin( m_emergePos + Vector( 0, 0, -m_height * m_riseTimer.GetRemainingTime() / m_riseTimer.GetCountdownDuration() ) );
if ( m_rumbleTimer.IsElapsed() )
{
m_rumbleTimer.Start( 0.25f );
// shake nearby players' screens.
UTIL_ScreenShake( me->GetAbsOrigin(), 15.0f, 5.0f, 1.0f, 1000.0f, SHAKE_START );
}
}
if ( me->IsActivityFinished() )
{
return ChangeTo( new CHeadlessHatmanAttack, "Here I come!" );
}
// push players away to avoid penetration issues
CUtlVector< CTFPlayer * > playerVector;
CollectPlayers( &playerVector, TF_TEAM_RED, COLLECT_ONLY_LIVING_PLAYERS );
CollectPlayers( &playerVector, TF_TEAM_BLUE, COLLECT_ONLY_LIVING_PLAYERS, APPEND_PLAYERS );
const float pushRange = 250.0f;
const float pushForce = 200.0f;
for( int i=0; i<playerVector.Count(); ++i )
{
CTFPlayer *player = playerVector[i];
Vector toPlayer = player->EyePosition() - m_emergePos;
float range = toPlayer.NormalizeInPlace();
if ( range < pushRange )
{
// make sure we push players up and away
toPlayer.z = 0.0f;
toPlayer.NormalizeInPlace();
toPlayer.z = 1.0f;
Vector push = pushForce * toPlayer;
player->ApplyAbsVelocityImpulse( push );
}
}
return Continue();
}
|