blob: a9379be6300e5023193d3271f79dda46369c6f03 (
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. ============//
// tf_bot_lurk.cpp
// Wait for victims
// Michael Booth, September 2011
#include "cbase.h"
#include "tf_player.h"
#include "tf_obj_sentrygun.h"
#include "bot/tf_bot.h"
#include "bot/behavior/spy/tf_bot_spy_lurk.h"
#include "bot/behavior/spy/tf_bot_spy_sap.h"
#include "bot/behavior/spy/tf_bot_spy_attack.h"
#include "bot/behavior/tf_bot_retreat_to_cover.h"
#include "bot/behavior/spy/tf_bot_spy_sap.h"
#include "nav_mesh.h"
extern ConVar tf_bot_path_lookahead_range;
extern ConVar tf_bot_debug_spy;
//---------------------------------------------------------------------------------------------
ActionResult< CTFBot > CTFBotSpyLurk::OnStart( CTFBot *me, Action< CTFBot > *priorAction )
{
// cloak
if ( !me->m_Shared.IsStealthed() )
{
me->PressAltFireButton();
}
// disguise as the enemy team
me->DisguiseAsMemberOfEnemyTeam();
m_lurkTimer.Start( RandomFloat( 3.0f, 5.0f ) );
return Continue();
}
//---------------------------------------------------------------------------------------------
ActionResult< CTFBot > CTFBotSpyLurk::Update( CTFBot *me, float interval )
{
const CKnownEntity *threat = me->GetVisionInterface()->GetPrimaryKnownThreat();
if ( threat && threat->GetEntity() )
{
CBaseObject *enemyObject = dynamic_cast< CBaseObject * >( threat->GetEntity() );
if ( enemyObject && !enemyObject->HasSapper() && me->IsEnemy( enemyObject ) )
{
return SuspendFor( new CTFBotSpySap( enemyObject ), "Sapping an enemy object" );
}
}
if ( me->GetEnemySentry() != NULL && !me->GetEnemySentry()->HasSapper() )
{
return SuspendFor( new CTFBotSpySap( me->GetEnemySentry() ), "Sapping a Sentry" );
}
if ( m_lurkTimer.IsElapsed() )
{
return Done( "Lost patience with my hiding spot" );
}
CTFNavArea *myArea = me->GetLastKnownArea();
if ( !myArea )
{
return Continue();
}
// go after victims we've gotten behind
if ( threat && threat->GetTimeSinceLastKnown() < 3.0f )
{
CTFPlayer *victim = ToTFPlayer( threat->GetEntity() );
if ( victim )
{
if ( !victim->IsLookingTowards( me ) )
{
return ChangeTo( new CTFBotSpyAttack( victim ), "Going after a backstab victim" );
}
}
}
return Continue();
}
//---------------------------------------------------------------------------------------------
QueryResultType CTFBotSpyLurk::ShouldAttack( const INextBot *me, const CKnownEntity *them ) const
{
return ANSWER_NO;
}
|