virtualBOOLTakeDamage(entvars_t*pevInflictor,entvars_t*pevAttacker,floatflDamage,intbitsDamageType)=0;// invoked when injured by something (EXTEND) - returns the amount of damage inflicted
virtualvoidUpdate()=0;// heavyweight algorithms, invoked less often
virtualvoidWalk()=0;
virtualboolJump(boolmustJump=false)=0;// returns true if jump was started
virtualvoidOnEvent(GameEventTypeevent,CBaseEntity*entity=NULL,CBaseEntity*other=NULL)=0;// invoked when event occurs in the game (some events have NULL entity)
#define CHECK_FOV true
virtualboolIsVisible(constVector*pos,booltestFOV=false)const=0;// return true if we can see the point
virtualboolIsVisible(CBasePlayer*player,booltestFOV=false,unsignedchar*visParts=NULL)const=0;// return true if we can see any part of the player
virtualboolIsEnemyPartVisible(VisiblePartTypepart)const=0;// if enemy is visible, return the part we see for our current enemy
public:
constVector&GetEyePosition()const
{
m_eyePos=pev->origin+pev->view_ofs;
returnm_eyePos;
}
public:
friendclassCCSBotManager;
// TODO: Get rid of these
friendclassAttackState;
friendclassBuyState;
charm_name[64];// copied from STRING(pev->netname) for debugging
// behavior properties
floatm_combatRange;// desired distance between us and them during gunplay
mutableboolm_isRogue;// if true, the bot is a "rogue" and listens to no-one
mutableCountdownTimerm_rogueTimer;
enumMoraleType
{
TERRIBLE=-3,
BAD=-2,
NEGATIVE=-1,
NEUTRAL=0,
POSITIVE=1,
GOOD=2,
EXCELLENT=3,
};
MoraleTypem_morale;// our current morale, based on our win/loss history
boolm_diedLastRound;// true if we died last round
floatm_safeTime;// duration at the beginning of the round where we feel "safe"
boolm_wasSafe;// true if we were in the safe time last update
NavRelativeDirTypem_blindMoveDir;// which way to move when we're blind
boolm_blindFire;// if true, fire weapon while blinded
// TODO: implement through CountdownTimer
floatm_surpriseDelay;// when we were surprised
floatm_surpriseTimestamp;
boolm_isFollowing;// true if we are following someone
EHANDLEm_leader;// the ID of who we are following
floatm_followTimestamp;// when we started following
floatm_allowAutoFollowTime;// time when we can auto follow
CountdownTimerm_hurryTimer;// if valid, bot is in a hurry
// instances of each possible behavior state, to avoid dynamic memory allocation during runtime
IdleStatem_idleState;
HuntStatem_huntState;
AttackStatem_attackState;
InvestigateNoiseStatem_investigateNoiseState;
BuyStatem_buyState;
MoveToStatem_moveToState;
FetchBombStatem_fetchBombState;
PlantBombStatem_plantBombState;
DefuseBombStatem_defuseBombState;
HideStatem_hideState;
EscapeFromBombStatem_escapeFromBombState;
FollowStatem_followState;
UseEntityStatem_useEntityState;
// TODO: Allow multiple simultaneous state machines (look around, etc)
BotState*m_state;// current behavior state
floatm_stateTimestamp;// time state was entered
boolm_isAttacking;// if true, special Attack state is overriding the state machine
// high-level tasks
enumTaskType
{
SEEK_AND_DESTROY,
PLANT_BOMB,
FIND_TICKING_BOMB,
DEFUSE_BOMB,
GUARD_TICKING_BOMB,
GUARD_BOMB_DEFUSER,
GUARD_LOOSE_BOMB,
GUARD_BOMB_ZONE,
ESCAPE_FROM_BOMB,
HOLD_POSITION,
FOLLOW,
VIP_ESCAPE,
GUARD_VIP_ESCAPE_ZONE,
COLLECT_HOSTAGES,
RESCUE_HOSTAGES,
GUARD_HOSTAGES,
GUARD_HOSTAGE_RESCUE_ZONE,
MOVE_TO_LAST_KNOWN_ENEMY_POSITION,
MOVE_TO_SNIPER_SPOT,
SNIPING,
NUM_TASKS
};
TaskTypem_task;// our current task
EHANDLEm_taskEntity;// an entity used for our task
// navigation
Vectorm_goalPosition;
EHANDLEm_goalEntity;
CNavArea*m_currentArea;// the nav area we are standing on
CNavArea*m_lastKnownArea;// the last area we were in
EHANDLEm_avoid;// higher priority player we need to make way for
floatm_avoidTimestamp;
boolm_isJumpCrouching;
boolm_isJumpCrouched;
floatm_jumpCrouchTimestamp;
// path navigation data
enum{_MAX_PATH_LENGTH=256};
structConnectInfo
{
CNavArea*area;// the area along the path
NavTraverseTypehow;// how to enter this area from the previous one
Vectorpos;// our movement goal position at this point in the path
constCNavLadder*ladder;// if "how" refers to a ladder, this is it
}
m_path[_MAX_PATH_LENGTH];
intm_pathLength;
intm_pathIndex;
floatm_areaEnteredTimestamp;
CountdownTimerm_repathTimer;// must have elapsed before bot can pathfind again
mutableCountdownTimerm_avoidFriendTimer;// used to throttle how often we check for friends in our path
mutableboolm_isFriendInTheWay;// true if a friend is blocking our path
CountdownTimerm_politeTimer;// we'll wait for friend to move until this runs out
boolm_isWaitingBehindFriend;// true if we are waiting for a friend to move
enumLadderNavState
{
APPROACH_ASCENDING_LADDER,// prepare to scale a ladder
APPROACH_DESCENDING_LADDER,// prepare to go down ladder
FACE_ASCENDING_LADDER,
FACE_DESCENDING_LADDER,
MOUNT_ASCENDING_LADDER,// move toward ladder until "on" it
MOUNT_DESCENDING_LADDER,// move toward ladder until "on" it
ASCEND_LADDER,// go up the ladder
DESCEND_LADDER,// go down the ladder
DISMOUNT_ASCENDING_LADDER,// get off of the ladder
DISMOUNT_DESCENDING_LADDER,// get off of the ladder
MOVE_TO_DESTINATION,// dismount ladder and move to destination area
}
m_pathLadderState;
boolm_pathLadderFaceIn;// if true, face towards ladder, otherwise face away
constCNavLadder*m_pathLadder;// the ladder we need to use to reach the next area
NavRelativeDirTypem_pathLadderDismountDir;// which way to dismount
floatm_pathLadderDismountTimestamp;// time when dismount started
floatm_pathLadderEnd;// if ascending, z of top, if descending z of bottom
floatm_pathLadderTimestamp;// time when we started using ladder - for timeout check
CountdownTimerm_mustRunTimer;// if nonzero, bot cannot walk
// game scenario mechanisms
CSGameStatem_gameState;
// hostages mechanism
bytem_hostageEscortCount;
floatm_hostageEscortCountTimestamp;
boolm_isWaitingForHostage;
CountdownTimerm_inhibitWaitingForHostageTimer;
CountdownTimerm_waitForHostageTimer;
// listening mechanism
Vectorm_noisePosition;// position we last heard non-friendly noise
floatm_noiseTimestamp;// when we heard it (can get zeroed)
CNavArea*m_noiseArea;// the nav area containing the noise
floatm_noiseCheckTimestamp;
PriorityTypem_noisePriority;// priority of currently heard noise
boolm_isNoiseTravelRangeChecked;
// "looking around" mechanism
floatm_lookAroundStateTimestamp;// time of next state change