constexprautoMIN_PATH_RECALC_TIME=0.33f;// How frequently can a bot recalculate its path? Default to max 3 times per second
constexprautoMAX_BOT_STUCK_TIME=30.0f;// How long a bot can be stuck, unable to move, before giving up and suiciding
constexprautoMARINE_BASE_NAV_PROFILE=0;
constexprautoSKULK_BASE_NAV_PROFILE=1;
constexprautoGORGE_BASE_NAV_PROFILE=2;
constexprautoLERK_BASE_NAV_PROFILE=3;
constexprautoFADE_BASE_NAV_PROFILE=4;
constexprautoONOS_BASE_NAV_PROFILE=5;
constexprautoSTRUCTURE_BASE_NAV_PROFILE=6;
constexprautoALL_NAV_PROFILE=7;
constexprautoMAX_PATH_POLY=512;// Max nav mesh polys that can be traversed in a path. This should be sufficient for any sized map.
// Possible area types. Water, Road, Door and Grass are not used (left-over from Detour library)
enumSamplePolyAreas
{
SAMPLE_POLYAREA_GROUND=0,// Regular ground movement
SAMPLE_POLYAREA_CROUCH=1,// Requires crouched movement
SAMPLE_POLYAREA_BLOCKED=2,// Requires a jump to get over
SAMPLE_POLYAREA_FALLDAMAGE=3,// Requires taking fall damage (if not immune to it)
SAMPLE_POLYAREA_WALLCLIMB=4,// Requires the ability to wall-stick, fly or blink
SAMPLE_POLYAREA_OBSTRUCTION=5,// There is a door or weldable object in the way
SAMPLE_POLYAREA_STRUCTUREBLOCK=6,// An enemy structure is blocking the way that must be destroyed
SAMPLE_POLYAREA_PHASEGATE=7,// Phase gate area, for area cost calculation
SAMPLE_POLYAREA_LADDER=8,// Phase gate area, for area cost calculation
SAMPLE_POLYAREA_LIFT=9,// Phase gate area, for area cost calculation
};
// Possible movement types. Swim and door are not used
enumSamplePolyFlags
{
SAMPLE_POLYFLAGS_WALK=1<<0,// Simple walk to traverse
SAMPLE_POLYFLAGS_FALL=1<<1,// Required dropping down
SAMPLE_POLYFLAGS_BLOCKED=1<<2,// Blocked by an obstruction, but can be jumped over
SAMPLE_POLYFLAGS_WALLCLIMB=1<<3,// Requires climbing a wall to traverse
SAMPLE_POLYFLAGS_LADDER=1<<4,// Requires climbing a ladder to traverse
SAMPLE_POLYFLAGS_JUMP=1<<5,// Requires a regular jump to traverse
SAMPLE_POLYFLAGS_DUCKJUMP=1<<6,// Requires a duck-jump to traverse
SAMPLE_POLYFLAGS_FLY=1<<7,// Requires lerk or jetpack to traverse
SAMPLE_POLYFLAGS_NOONOS=1<<8,// This movement is not allowed by onos
SAMPLE_POLYFLAGS_TEAM1PHASEGATE=1<<9,// Requires using a phase gate to traverse (team 1 only)
SAMPLE_POLYFLAGS_TEAM2PHASEGATE=1<<10,// Requires using a phase gate to traverse (team 2 only)
SAMPLE_POLYFLAGS_TEAM1STRUCTURE=1<<11,// A team 1 structure is in the way that cannot be jumped over. Impassable to team 1 players (assume cannot teamkill own structures)
SAMPLE_POLYFLAGS_TEAM2STRUCTURE=1<<12,// A team 2 structure is in the way that cannot be jumped over. Impassable to team 2 players (assume cannot teamkill own structures)
SAMPLE_POLYFLAGS_WELD=1<<13,// Requires a welder to get through here
SAMPLE_POLYFLAGS_DOOR=1<<14,// Requires a welder to get through here
SAMPLE_POLYFLAGS_LIFT=1<<15,// Requires using a lift or moving platform
SAMPLE_POLYFLAGS_DISABLED=1<<16,// Disabled, not usable by anyone
SAMPLE_POLYFLAGS_ALL=-1// All abilities.
};
// Door reference. Not used, but is a future feature to allow bots to track if a door is open or not, and how to open it etc.
typedefstruct_NAV_DOOR
{
CBaseToggle*DoorEntity=nullptr;
edict_t*DoorEdict=nullptr;// Reference to the func_door
unsignedintObstacleRefs[32][MAX_NAV_MESHES]={};// Dynamic obstacle ref. Used to add/remove the obstacle as the door is opened/closed
intNumObstacles=0;
vector<DoorTrigger>TriggerEnts;// Reference to the trigger edicts (e.g. func_trigger, func_button etc.)
DoorActivationTypeActivationType=DOOR_NONE;// How the door should be opened
TOGGLE_STATECurrentState=TS_AT_BOTTOM;
floatOpenDelay=0.0f;// How long the door takes to start opening after activation
vector<Vector>StopPoints;// Where does this door/platform stop when triggered?
// Door reference. Not used, but is a future feature to allow bots to track if a door is open or not, and how to open it etc.
typedefstruct_NAV_HITRESULT
{
floatflFraction=0.0f;
boolbStartOffMesh=false;
VectorTraceEndPoint=g_vecZero;
}nav_hitresult;
// Links together a tile cache, nav query and the nav mesh into one handy structure for all your querying needs
typedefstruct_NAV_MESH
{
classdtTileCache*tileCache=nullptr;
classdtNavMeshQuery*navQuery=nullptr;
classdtNavMesh*navMesh=nullptr;
}nav_mesh;
staticconstintNAVMESHSET_MAGIC='M'<<24|'S'<<16|'E'<<8|'T';//'MSET', used to confirm the nav mesh we're loading is compatible;
staticconstintNAVMESHSET_VERSION=1;
staticconstintTILECACHESET_MAGIC='T'<<24|'S'<<16|'E'<<8|'T';//'TSET', used to confirm the tile cache we're loading is compatible;
staticconstintTILECACHESET_VERSION=2;
staticconstfloatpExtents[3]={400.0f,50.0f,400.0f};// Default extents (in GoldSrc units) to find the nearest spot on the nav mesh
staticconstfloatpReachableExtents[3]={max_ai_use_reach,max_ai_use_reach,max_ai_use_reach};// Extents (in GoldSrc units) to determine if something is on the nav mesh
staticconstintMAX_NAV_PROFILES=16;// Max number of possible nav profiles. Currently 9 are used (see top of this header file)
staticconstintREGULAR_NAV_MESH=0;// Nav mesh used by all players except Onos and the AI commander
staticconstintONOS_NAV_MESH=1;// Nav mesh used by Onos (due to larger hitbox)
staticconstintBUILDING_NAV_MESH=2;// Nav mesh used by commander for building placement. Must be the last nav mesh index (see UTIL_AddStructureTemporaryObstacles)
staticconstintDT_AREA_NULL=0;// Represents a null area on the nav mesh. Not traversable and considered not on the nav mesh
staticconstintDT_AREA_BLOCKED=3;// Area occupied by an obstruction (e.g. building). Not traversable, but considered to be on the nav mesh
staticconstintMAX_OFFMESH_CONNS=1024;// Max number of dynamic connections that can be placed. Not currently used (connections are baked into the nav mesh using the external tool)
staticconstintDOOR_USE_ONLY=256;// Flag used by GoldSrc to determine if a door entity can only be used to open (i.e. can't be triggered)
staticconstintDOOR_START_OPEN=1;
staticconstfloatCHECK_STUCK_INTERVAL=0.1f;// How frequently should the bot check if it's stuck?
// Returns true if a valid nav mesh has been loaded into memory
boolNavmeshLoaded();
// Unloads all data, including loaded nav meshes, nav profiles, all the map data such as buildable structure maps and hive locations.
voidUnloadNavigationData();
// Unloads only the nav meshes, but not map data such as doors, hives and locations
voidUnloadNavMeshes();
// Searches for the corresponding .nav file for the input map name, and loads/initiatialises the nav meshes and nav profiles.
boolloadNavigationData(constchar*mapname);
// Loads the nav mesh only. Map data such as hive locations, doors etc are not loaded
boolLoadNavMesh(constchar*mapname);
// Unloads the nav meshes (UnloadNavMeshes()) and then reloads them (LoadNavMesh). Map data such as doors, hives, locations are not touched.
/* Finds any random point on the navmesh of the area type (e.g. crouch area) that is relevant for the bot within the min and max radius of the origin point,
/* Finds any random point on the navmesh of the area type (e.g. crouch area) that is relevant for the bot within the min and max radius of the origin point,
// Roughly estimates the movement cost to move between FromLocation and ToLocation. Uses simple formula of distance between points x cost modifier for that movement
// Will check for any func_breakable which might be in the way (e.g. window, vent) and make the bot aim and attack it to break it. Marines will switch to knife to break it.
/* Main function for instructing a bot to move to the destination, and what type of movement to favour. Should be called every frame you want the bot to move.
// Similar to FindPathToPoint, but you can specify a max acceptable distance for partial results. Will return a failure if it can't reach at least MaxAcceptableDistance away from the ToLocation
// If the bot has a path, it will work out how far along the path it can see and return the furthest point. Used so that the bot looks ahead along the path rather than just at its next path point
// Clears the bot's path and sets the path size to 0
voidClearBotPath(AvHAIPlayer*pBot);
// Clears just the bot's current stuck movement attempt (see PerformUnstuckMove())
voidClearBotStuckMovement(AvHAIPlayer*pBot);
voidUTIL_ClearDoorData();
voidUTIL_ClearWeldablesData();
constnav_profileGetBaseNavProfile(constintindex);
// Based on the direction the bot wants to move and it's current facing angle, sets the forward and side move, and the directional buttons to make the bot actually move
voidBotMovementInputs(AvHAIPlayer*pBot);
// Event called when a bot starts climbing a ladder