summaryrefslogtreecommitdiff
path: root/game/server/NextBot/NextBot.h
blob: ae89cab12d23c009abe508f5f64ae40b1f9a0a9c (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
92
93
94
95
96
97
98
99
100
101
102
103
104
// NextBotCombatCharacter.h
// Next generation bot system
// Author: Michael Booth, April 2005
//========= Copyright Valve Corporation, All rights reserved. ============//

#ifndef _NEXT_BOT_H_
#define _NEXT_BOT_H_

#include "NextBotInterface.h"
#include "NextBotManager.h"

#ifdef TERROR
#include "player_lagcompensation.h"
#endif

class NextBotCombatCharacter;
struct animevent_t;

extern ConVar NextBotStop;


//----------------------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------
/**
 * A Next Bot derived from CBaseCombatCharacter
 */
class NextBotCombatCharacter : public CBaseCombatCharacter, public INextBot
{
public:
	DECLARE_CLASS( NextBotCombatCharacter, CBaseCombatCharacter );
	DECLARE_SERVERCLASS();
	DECLARE_DATADESC();
	
	NextBotCombatCharacter( void );
	virtual ~NextBotCombatCharacter() { }

	virtual void Spawn( void );

	virtual Vector EyePosition( void );

	virtual INextBot *MyNextBotPointer( void ) { return this; }

	// Event hooks into NextBot system ---------------------------------------
	virtual int OnTakeDamage_Alive( const CTakeDamageInfo &info );
	virtual int OnTakeDamage_Dying( const CTakeDamageInfo &info );
	virtual void Event_Killed( const CTakeDamageInfo &info );
	virtual void HandleAnimEvent( animevent_t *event );
	virtual void OnNavAreaChanged( CNavArea *enteredArea, CNavArea *leftArea );	// invoked (by UpdateLastKnownArea) when we enter a new nav area (or it is reset to NULL)
	virtual void Touch( CBaseEntity *other );
	virtual void SetModel( const char *szModelName );
	virtual void Ignite( float flFlameLifetime, bool bNPCOnly = true, float flSize = 0.0f, bool bCalledByLevelDesigner = false );
	virtual void Ignite( float flFlameLifetime, CBaseEntity *pAttacker );
	//------------------------------------------------------------------------

	virtual bool IsUseableEntity( CBaseEntity *entity, unsigned int requiredCaps = 0 );
	void UseEntity( CBaseEntity *entity, USE_TYPE useType = USE_TOGGLE );

	// Implement this if you use MOVETYPE_CUSTOM
	virtual void PerformCustomPhysics( Vector *pNewPosition, Vector *pNewVelocity, QAngle *pNewAngles, QAngle *pNewAngVelocity );

	virtual bool BecomeRagdoll( const CTakeDamageInfo &info, const Vector &forceVector );
	
	// hook to INextBot update
	void DoThink( void );

	// expose to public
	int	GetLastHitGroup( void ) const;								// where on our body were we injured last

	virtual bool IsAreaTraversable( const CNavArea *area ) const;							// return true if we can use the given area 

	virtual CBaseCombatCharacter *GetLastAttacker( void ) const;	// return the character who last attacked me

	// begin INextBot public interface ----------------------------------------------------------------
	virtual NextBotCombatCharacter *GetEntity( void ) const			{ return const_cast< NextBotCombatCharacter * >( this ); }
	virtual NextBotCombatCharacter *GetNextBotCombatCharacter( void ) const	{ return const_cast< NextBotCombatCharacter * >( this ); }
	

private:
	EHANDLE m_lastAttacker;
	
	bool m_didModelChange;
};


inline CBaseCombatCharacter *NextBotCombatCharacter::GetLastAttacker( void ) const
{
	return ( m_lastAttacker.Get() == NULL ) ? NULL : m_lastAttacker->MyCombatCharacterPointer();
}

inline int NextBotCombatCharacter::GetLastHitGroup( void ) const
{
	return LastHitGroup();
}

//-----------------------------------------------------------------------------------------------------
class NextBotDestroyer
{
public:
	NextBotDestroyer( int team );
	bool operator() ( INextBot *bot );
	int m_team;			// the team to delete bots from, or TEAM_ANY for any team
};

#endif // _NEXT_BOT_H_