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
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================//
#ifndef AI_BEHAVIOR_POLICE_H
#define AI_BEHAVIOR_POLICE_H
#ifdef _WIN32
#pragma once
#endif
#include "ai_behavior.h"
#include "ai_goal_police.h"
#include "ai_sentence.h"
#define PATROL_RADIUS_RATIO 2.0f
#define POLICE_MAX_WARNINGS 4
class CAI_PolicingBehavior : public CAI_SimpleBehavior
{
DECLARE_CLASS( CAI_PolicingBehavior, CAI_SimpleBehavior );
public:
DECLARE_DATADESC();
CAI_PolicingBehavior();
enum
{
// Schedules
SCHED_POLICE_RETURN_FROM_HARASS = BaseClass::NEXT_SCHEDULE,
SCHED_POLICE_WARN_TARGET,
SCHED_POLICE_HARASS_TARGET,
SCHED_POLICE_SUPPRESS_TARGET,
SCHED_POLICE_FACE_ALONG_GOAL,
SCHED_POLICE_TRACK_TARGET,
NEXT_SCHEDULE,
// Tasks
TASK_POLICE_GET_PATH_TO_HARASS_GOAL = BaseClass::NEXT_TASK,
TASK_POLICE_GET_PATH_TO_POLICE_GOAL,
TASK_POLICE_FACE_ALONG_GOAL,
TASK_POLICE_ANNOUNCE_HARASS,
NEXT_TASK,
// Conditions
COND_POLICE_TARGET_TOO_CLOSE_HARASS = BaseClass::NEXT_CONDITION,
COND_POLICE_TARGET_TOO_CLOSE_SUPPRESS,
NEXT_CONDITION,
};
virtual const char *GetName() { return "Policing"; }
void Enable( CAI_PoliceGoal *pGoal );
void Disable( void );
bool CanSelectSchedule( void );
void BuildScheduleTestBits( void );
bool IsEnabled( void ) { return m_bEnabled; }
bool TargetIsHostile( void );
bool ShouldKnockOutTarget( CBaseEntity *pTarget );
void KnockOutTarget( CBaseEntity *pTarget );
int SelectFailSchedule( int failedSchedule, int failedTask, AI_TaskFailureCode_t taskFailCode );
CBaseEntity *GetGoalTarget( void );
private:
void HostSpeakSentence( const char *pSentence, SentencePriority_t nSoundPriority, SentenceCriteria_t nCriteria );
int TranslateSchedule( int scheduleType );
int SelectSchedule( void );
int SelectSuppressSchedule( void );
int SelectHarassSchedule( void );
Activity NPC_TranslateActivity( Activity newActivity );
void GatherConditions( void );
bool OverrideMoveFacing( const AILocalMoveGoal_t &move, float flInterval );
void StartTask( const Task_t *pTask );
void RunTask( const Task_t *pTask );
void AnnouncePolicing( void );
void HostSetBatonState( bool state );
bool HostBatonIsOn( void );
void SetTargetHostileDuration( float time );
bool MaintainGoalPosition( void );
protected:
bool m_bEnabled;
bool m_bStartPolicing;
float m_flNextHarassTime;
float m_flAggressiveTime;
int m_nNumWarnings;
bool m_bTargetIsHostile;
float m_flTargetHostileTime;
CHandle<CAI_PoliceGoal> m_hPoliceGoal;
DEFINE_CUSTOM_SCHEDULE_PROVIDER;
};
#endif // AI_BEHAVIOR_POLICE_H
|