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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================//
#ifndef ANTLION_MAKER_H
#define ANTLION_MAKER_H
#ifdef _WIN32
#pragma once
#endif
#include "npc_antlion.h"
#include "monstermaker.h"
#include "igamesystem.h"
#include "ai_hint.h"
//
// Antlion maker class
//
#define SF_ANTLIONMAKER_RANDOM_SPAWN_NODE 0x00000400
#define SF_ANTLIONMAKER_SPAWN_CLOSE_TO_TARGET 0x00000800
#define SF_ANTLIONMAKER_RANDOM_FIGHT_TARGET 0x00001000
#define SF_ANTLIONMAKER_DO_BLOCKEDEFFECTS 0x00002000
class CAntlionTemplateMaker : public CTemplateNPCMaker
{
public:
DECLARE_CLASS( CAntlionTemplateMaker, CTemplateNPCMaker );
CAntlionTemplateMaker( void );
~CAntlionTemplateMaker( void );
virtual int DrawDebugTextOverlays( void );
virtual void DrawDebugGeometryOverlays( void );
void MakeNPC( void );
void ChildPreSpawn( CAI_BaseNPC *pChild );
void ChildPostSpawn( CAI_BaseNPC *pChild );
void InputSetFightTarget( inputdata_t &inputdata );
void InputSetFollowTarget( inputdata_t &inputdata );
void InputClearFightTarget( inputdata_t &inputdata );
void InputClearFollowTarget( inputdata_t &inputdata );
void InputSetSpawnRadius( inputdata_t &inputdata );
void InputAddToPool( inputdata_t &inputdata );
void InputSetMaxPool( inputdata_t &inputdata );
void InputSetPoolRegenAmount( inputdata_t &inputdata );
void InputSetPoolRegenTime( inputdata_t &inputdata );
void InputChangeDestinationGroup( inputdata_t &inputdata );
void Activate( void );
// Do not transition
int ObjectCaps( void ) { return (BaseClass::ObjectCaps() & ~FCAP_ACROSS_TRANSITION); }
bool CanMakeNPC( bool bIgnoreSolidEntities = false );
bool ShouldAlwaysThink( void ) { return true; }
void AddChild( CNPC_Antlion *pAnt );
void RemoveChild( CNPC_Antlion *pAnt );
void FixupOrphans( void );
void UpdateChildren( void );
void CreateProxyTarget( const Vector &position );
void DestroyProxyTarget( void );
void SetFightTarget( string_t strTarget, CBaseEntity *pActivator = NULL, CBaseEntity *pCaller = NULL );
void SetFightTarget( CBaseEntity *pEntity );
void SetFightTarget( const Vector &position );
void SetFollowTarget( string_t strTarget, CBaseEntity *pActivator = NULL, CBaseEntity *pCaller = NULL );
void SetFollowTarget( CBaseEntity *pEntity );
void SetChildMoveState( AntlionMoveState_e state );
void DeathNotice( CBaseEntity *pVictim );
bool IsDepleted( void );
bool ShouldHearBugbait( void ) { return (m_bIgnoreBugbait==false); }
CBaseEntity *GetFightTarget( void );
CBaseEntity *GetFollowTarget( void );
virtual void Enable( void );
virtual void Disable( void );
void BlockedCheckFunc( void );
void FindNodesCloseToPlayer( void );
void DoBlockedEffects( CBaseEntity *pBlocker, Vector vOrigin );
CBaseEntity *AllHintsFromClusterBlocked( CAI_Hint *pNode, bool &bChosenHintBlocked );
void ActivateAllSpores( void );
void ActivateSpore( const char* sporename, Vector vOrigin );
void DisableSpore( const char* sporename );
void DisableAllSpores( void );
protected:
void PrecacheTemplateEntity( CBaseEntity *pEntity );
bool FindHintSpawnPosition( const Vector &origin, float radius, string_t hintGroupName, CAI_Hint **pHint, bool bRandom = false );
bool FindNearTargetSpawnPosition( Vector &origin, float radius, CBaseEntity *pTarget );
//These are used by FindNearTargetSpawnPosition
bool FindPositionOnFoot( Vector &origin, float radius, CBaseEntity *pTarget );
bool FindPositionOnVehicle( Vector &origin, float radius, CBaseEntity *pTarget );
bool ValidateSpawnPosition( Vector &vOrigin, CBaseEntity *pTarget = NULL );
// Pool behavior for coast
void PoolAdd( int iNumToAdd );
void PoolRegenThink( void );
protected:
// FIXME: The m_strSpawnGroup is redundant to the m_iszDestinationGroup in the base class NPC template maker
string_t m_strSpawnGroup; // if present, spawn children on the nearest node of this group (to the player)
string_t m_strSpawnTarget; // name of target to spawn near
float m_flSpawnRadius; // radius around target to attempt to spawn in
float m_flWorkerSpawnRate; // Percentage chance of spawning a worker when we spawn an antlion [0..1].
string_t m_strFightTarget; // target entity name that all children will be told to fight to
string_t m_strFollowTarget; // entity name that all children will follow
bool m_bIgnoreBugbait; // Whether or not to ignore bugbait
AntlionMoveState_e m_nChildMoveState;
EHANDLE m_hFightTarget; // A normal entity pointer for fight position
EHANDLE m_hProxyTarget; // This is a self-held target that is created and used when a vector is passed in as a fight
// goal, instead of an entity
EHANDLE m_hFollowTarget; // Target to follow
CUtlVector< CHandle< CNPC_Antlion > > m_Children;
// Pool behavior for coast
int m_iPool;
int m_iMaxPool;
int m_iPoolRegenAmount;
float m_flPoolRegenTime;
float m_flVehicleSpawnDistance;
int m_iSkinCount;
float m_flBlockedBumpTime;
bool m_bBlocked;
COutputEvent m_OnAllBlocked;
bool m_bCreateSpores;
DECLARE_DATADESC();
};
// ========================================================
// Antlion maker manager
// ========================================================
class CAntlionMakerManager : public CAutoGameSystem
{
public:
CAntlionMakerManager( char const *name ) : CAutoGameSystem( name )
{
}
void LevelInitPostEntity( void );
void BroadcastFightGoal( const Vector &vFightGoal );
void BroadcastFightGoal( CBaseEntity *pFightGoal );
void BroadcastFollowGoal( CBaseEntity *pFollowGoal );
protected:
void GatherMakers( void );
CUtlVector< CHandle< CAntlionTemplateMaker > > m_Makers;
};
extern CAntlionMakerManager g_AntlionMakerManager;
#endif // ANTLION_MAKER_H
|