Inexor
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Enumerations | Functions | Variables
ai Namespace Reference

Classes

struct  waypoint
 
struct  avoidset
 
struct  interest
 
struct  aistate
 
struct  aiinfo
 
struct  wpcache
 
struct  wpcachestack
 

Enumerations

enum  {
  AI_S_WAIT = 0, AI_S_DEFEND, AI_S_PURSUE, AI_S_INTEREST,
  AI_S_MAX
}
 
enum  {
  AI_T_NODE, AI_T_PLAYER, AI_T_AFFINITY, AI_T_ENTITY,
  AI_T_MAX
}
 
enum  { WPCACHE_STATIC = 0, WPCACHE_DYNAMIC, NUMWPCACHES }
 

Functions

 VAR (aidebug, 0, 0, 6)
 
 VAR (aiforcegun,-1,-1, NUMGUNS-1)
 
 ICOMMAND (addbot,"s",(char *s), addmsg(N_ADDBOT,"ri",*s?clamp(parseint(s), 1, 101):-1))
 
 ICOMMAND (botbalance,"i",(int *n), addmsg(N_BOTBALANCE,"ri",*n))
 
 ICOMMAND (botlimit,"i",(int *n), addmsg(N_BOTLIMIT,"ri",*n))
 
 ICOMMAND (delbot,"",(), addmsg(N_DELBOT,"r"))
 
float viewdist (int x)
 
float viewfieldx (int x)
 
float viewfieldy (int x)
 
bool canmove (fpsent *d)
 
float weapmindist (int weap)
 
float weapmaxdist (int weap)
 
bool weaprange (fpsent *d, int weap, float dist)
 
bool targetable (fpsent *d, fpsent *e)
 
bool getsight (vec &o, float yaw, float pitch, vec &q, vec &v, float mdist, float fovx, float fovy)
 
bool cansee (fpsent *d, vec &x, vec &y, vec &targ)
 
bool canshoot (fpsent *d, fpsent *e)
 
bool canshoot (fpsent *d)
 
bool hastarget (fpsent *d, aistate &b, fpsent *e, float yaw, float pitch, float dist)
 
vec getaimpos (fpsent *d, fpsent *e)
 
void create (fpsent *d)
 
void destroy (fpsent *d)
 
void init (fpsent *d, int at, int ocn, int sk, int bn, int pm, const char *name, const char *team, const char *tag)
 
void update ()
 
bool checkothers (vector< int > &targets, fpsent *d, int state, int targtype, int target, bool teams, int *members)
 
bool makeroute (fpsent *d, aistate &b, int node, bool changed, int retries)
 
bool makeroute (fpsent *d, aistate &b, const vec &pos, bool changed, int retries)
 
bool randomnode (fpsent *d, aistate &b, const vec &pos, float guard, float wander)
 
bool randomnode (fpsent *d, aistate &b, float guard, float wander)
 
bool badhealth (fpsent *d)
 
bool enemy (fpsent *d, aistate &b, const vec &pos, float guard=SIGHTMIN, int pursue=0)
 
bool patrol (fpsent *d, aistate &b, const vec &pos, float guard, float wander, int walk, bool retry)
 
bool defend (fpsent *d, aistate &b, const vec &pos, float guard, float wander, int walk)
 
bool violence (fpsent *d, aistate &b, fpsent *e, int pursue)
 
bool target (fpsent *d, aistate &b, int pursue=0, bool force=false, float mindist=0.f)
 
int isgoodammo (int gun)
 
bool hasgoodammo (fpsent *d)
 
void assist (fpsent *d, aistate &b, vector< interest > &interests, bool all, bool force)
 
static void tryitem (fpsent *d, extentity &e, int id, aistate &b, vector< interest > &interests, bool force=false)
 
void items (fpsent *d, aistate &b, vector< interest > &interests, bool force=false)
 
bool parseinterests (fpsent *d, aistate &b, vector< interest > &interests, bool override, bool ignore)
 
bool find (fpsent *d, aistate &b, bool override=false)
 
bool findassist (fpsent *d, aistate &b, bool override=false)
 
void damaged (fpsent *d, fpsent *e)
 
void findorientation (vec &o, float yaw, float pitch, vec &pos)
 
void setup (fpsent *d)
 
void spawned (fpsent *d)
 
void killed (fpsent *d, fpsent *e)
 
void itemspawned (int ent)
 
bool check (fpsent *d, aistate &b)
 
int dowait (fpsent *d, aistate &b)
 
int dodefend (fpsent *d, aistate &b)
 
int dointerest (fpsent *d, aistate &b)
 
int dopursue (fpsent *d, aistate &b)
 
int closenode (fpsent *d)
 
int wpspot (fpsent *d, int n, bool check=false)
 
int randomlink (fpsent *d, int n)
 
bool anynode (fpsent *d, aistate &b, int len=NUMPREVNODES)
 
bool checkroute (fpsent *d, int n)
 
bool hunt (fpsent *d, aistate &b)
 
void jumpto (fpsent *d, aistate &b, const vec &pos)
 
void fixfullrange (float &yaw, float &pitch, float &roll, bool full)
 
void fixrange (float &yaw, float &pitch)
 
void getyawpitch (const vec &from, const vec &pos, float &yaw, float &pitch)
 
void scaleyawpitch (float &yaw, float &pitch, float targyaw, float targpitch, float frame, float scale)
 
bool lockon (fpsent *d, fpsent *e, float maxdist)
 
int process (fpsent *d, aistate &b)
 
bool hasrange (fpsent *d, fpsent *e, int weap)
 
bool request (fpsent *d, aistate &b)
 
void timeouts (fpsent *d, aistate &b)
 
void logic (fpsent *d, aistate &b, bool run)
 
void avoid ()
 
void think (fpsent *d, bool run)
 
void drawroute (fpsent *d, float amt=1.f)
 
 VAR (showwaypoints, 0, 0, 1)
 
 VAR (showwaypointsradius, 0, 200, 10000)
 
void render ()
 
static bool iswaypoint (int n)
 
int closestwaypoint (const vec &pos, float mindist, bool links, fpsent *d=nullptr)
 
void findwaypointswithin (const vec &pos, float mindist, float maxdist, vector< int > &results)
 
void inferwaypoints (fpsent *d, const vec &o, const vec &v, float mindist=ai::CLOSEDIST)
 
bool route (fpsent *d, int node, int goal, vector< int > &route, const avoidset &obstacles, int retries=0)
 
void navigate ()
 
void clearwaypoints (bool full=false)
 
void seedwaypoints ()
 
void loadwaypoints (bool force=false, const char *mname=nullptr)
 
void savewaypoints (bool force=false, const char *mname=nullptr)
 
bool clipped (const vec &o)
 
int getweight (const vec &o)
 
static void invalidatewpcache (int wp)
 
void clearwpcache (bool full=true)
 
 ICOMMAND (clearwpcache,"",(), clearwpcache())
 
void buildwpcache ()
 
static float heapscore (waypoint *q)
 
 VARF (dropwaypoints, 0, 0, 1,{player1->lastnode=-1;})
 
int addwaypoint (const vec &o, int weight=-1)
 
void linkwaypoint (waypoint &a, int n)
 
static bool shouldnavigate ()
 
static bool shoulddrop (fpsent *d)
 
void navigate (fpsent *d)
 
 ICOMMAND (clearwaypoints,"",(), clearwaypoints())
 
void remapwaypoints ()
 
bool cleanwaypoints ()
 
bool getwaypointfile (const char *mname, char *wptname)
 
 ICOMMAND (loadwaypoints,"s",(char *mname), loadwaypoints(true, mname))
 
 ICOMMAND (savewaypoints,"s",(char *mname), savewaypoints(true, mname))
 
void delselwaypoints ()
 
 COMMAND (delselwaypoints,"")
 
void movewaypoints (const vec &d)
 
 ICOMMAND (movewaypoints,"iii",(int *dx, int *dy, int *dz), movewaypoints(vec(*dx,*dy,*dz)))
 

Variables

avoidset obstacles
 
int updatemillis = 0
 
int iteration = 0
 
int itermillis = 0
 
int forcegun = -1
 
vec aitarget (0, 0, 0)
 
static vector< int > targets
 
const char * stnames [AI_S_MAX]
 
const char * sttypes [AI_T_MAX+1]
 
const int MAXWAYPOINTS = USHRT_MAX - 2
 
const int MAXWAYPOINTLINKS = 6
 
const int WAYPOINTRADIUS = 16
 
const float MINWPDIST = 4.f
 
const float CLOSEDIST = 32.f
 
const float FARDIST = 128.f
 
const float JUMPMIN = 4.f
 
const float JUMPMAX = 32.f
 
const float SIGHTMIN = 64.f
 
const float SIGHTMAX = 1024.f
 
const float VIEWMIN = 90.f
 
const float VIEWMAX = 180.f
 
vector< waypointwaypoints
 
SharedVar< int > showwaypoints
 
SharedVar< int > dropwaypoints
 
const int NUMPREVNODES = 6
 
struct ai::wpcache wpcaches [NUMWPCACHES]
 
static int invalidatedwpcaches = 0
 
static int clearedwpcaches = (1<<NUMWPCACHES)-1
 
static int numinvalidatewpcaches = 0
 
static int lastwpcache = 0
 
avoidset wpavoid
 
vector< wpcache::node * > wpcachestack
 
string loadedwaypoints = ""
 

Class Documentation

struct ai::wpcachestack
Class Members
node * node
float tmax
float tmin

Enumeration Type Documentation

anonymous enum
Enumerator
AI_S_WAIT 
AI_S_DEFEND 
AI_S_PURSUE 
AI_S_INTEREST 
AI_S_MAX 
anonymous enum
Enumerator
AI_T_NODE 
AI_T_PLAYER 
AI_T_AFFINITY 
AI_T_ENTITY 
AI_T_MAX 
anonymous enum
Enumerator
WPCACHE_STATIC 
WPCACHE_DYNAMIC 
NUMWPCACHES 

Function Documentation

int ai::addwaypoint ( const vec o,
int  weight = -1 
)
bool ai::anynode ( fpsent d,
aistate &  b,
int  len = NUMPREVNODES 
)
void ai::assist ( fpsent d,
aistate &  b,
vector< interest > &  interests,
bool  all,
bool  force 
)
void ai::avoid ( )
bool ai::badhealth ( fpsent d)
void ai::buildwpcache ( )
bool ai::canmove ( fpsent d)
bool ai::cansee ( fpsent d,
vec x,
vec y,
vec targ 
)
bool ai::canshoot ( fpsent d,
fpsent e 
)
bool ai::canshoot ( fpsent d)
bool ai::check ( fpsent d,
aistate &  b 
)
bool ai::checkothers ( vector< int > &  targets,
fpsent d,
int  state,
int  targtype,
int  target,
bool  teams,
int *  members 
)
bool ai::checkroute ( fpsent d,
int  n 
)
bool ai::cleanwaypoints ( )
void ai::clearwaypoints ( bool  full = false)
void ai::clearwpcache ( bool  full = true)
bool ai::clipped ( const vec o)
int ai::closenode ( fpsent d)
int ai::closestwaypoint ( const vec pos,
float  mindist,
bool  links,
fpsent d = nullptr 
)
ai::COMMAND ( delselwaypoints  ,
""   
)
void ai::create ( fpsent d)

References fpsent::ai.

Referenced by init().

void ai::damaged ( fpsent d,
fpsent e 
)
bool ai::defend ( fpsent d,
aistate &  b,
const vec pos,
float  guard,
float  wander,
int  walk 
)
void ai::delselwaypoints ( )
void ai::destroy ( fpsent d)

References fpsent::ai, and DELETEP.

Referenced by init().

int ai::dodefend ( fpsent d,
aistate &  b 
)
int ai::dointerest ( fpsent d,
aistate &  b 
)
int ai::dopursue ( fpsent d,
aistate &  b 
)
int ai::dowait ( fpsent d,
aistate &  b 
)
void ai::drawroute ( fpsent d,
float  amt = 1.f 
)
bool ai::enemy ( fpsent d,
aistate &  b,
const vec pos,
float  guard = SIGHTMIN,
int  pursue = 0 
)
bool ai::find ( fpsent d,
aistate &  b,
bool  override = false 
)
bool ai::findassist ( fpsent d,
aistate &  b,
bool  override = false 
)
void ai::findorientation ( vec o,
float  yaw,
float  pitch,
vec pos 
)
void ai::findwaypointswithin ( const vec pos,
float  mindist,
float  maxdist,
vector< int > &  results 
)
void ai::fixfullrange ( float &  yaw,
float &  pitch,
float &  roll,
bool  full 
)

References f().

Referenced by fixrange().

void ai::fixrange ( float &  yaw,
float &  pitch 
)

References fixfullrange().

Referenced by process(), and scaleyawpitch().

vec ai::getaimpos ( fpsent d,
fpsent e 
)
bool ai::getsight ( vec o,
float  yaw,
float  pitch,
vec q,
vec v,
float  mdist,
float  fovx,
float  fovy 
)

References vec::dist(), inexor::rpc::min(), RAD, and raycubelos().

Referenced by cansee().

bool ai::getwaypointfile ( const char *  mname,
char *  wptname 
)
int ai::getweight ( const vec o)
void ai::getyawpitch ( const vec from,
const vec pos,
float &  yaw,
float &  pitch 
)

References vec::dist(), and RAD.

Referenced by process().

bool ai::hasgoodammo ( fpsent d)
bool ai::hasrange ( fpsent d,
fpsent e,
int  weap 
)
bool ai::hastarget ( fpsent d,
aistate &  b,
fpsent e,
float  yaw,
float  pitch,
float  dist 
)
static float ai::heapscore ( waypoint *  q)
inlinestatic

References ai::waypoint::score().

bool ai::hunt ( fpsent d,
aistate &  b 
)
ai::ICOMMAND ( addbot  ,
"s"  ,
(char *s)  ,
addmsg(N_ADDBOT,"ri",*s?clamp(parseint(s), 1, 101):-1)   
)
ai::ICOMMAND ( botbalance  ,
"i"  ,
(int *n)  ,
addmsg(N_BOTBALANCE,"ri",*n)   
)
ai::ICOMMAND ( botlimit  ,
"i"  ,
(int *n)  ,
addmsg(N_BOTLIMIT,"ri",*n)   
)
ai::ICOMMAND ( delbot  ,
""  ,
()  ,
addmsg(N_DELBOT,"r")   
)
ai::ICOMMAND ( clearwpcache  ,
""  ,
()  ,
clearwpcache()   
)
ai::ICOMMAND ( clearwaypoints  ,
""  ,
()  ,
clearwaypoints()   
)
ai::ICOMMAND ( loadwaypoints  ,
"s"  ,
(char *mname)  ,
loadwaypoints(true, mname)   
)
ai::ICOMMAND ( savewaypoints  ,
"s"  ,
(char *mname)  ,
savewaypoints(true, mname)   
)
ai::ICOMMAND ( movewaypoints  ,
"iii"  ,
(int *dx, int *dy, int *dz)  ,
movewaypoints(vec(*dx,*dy,*dz))   
)
void ai::inferwaypoints ( fpsent d,
const vec o,
const vec v,
float  mindist = ai::CLOSEDIST 
)
void ai::init ( fpsent d,
int  at,
int  ocn,
int  sk,
int  bn,
int  pm,
const char *  name,
const char *  team,
const char *  tag 
)
static void ai::invalidatewpcache ( int  wp)
inlinestatic
int ai::isgoodammo ( int  gun)

References GUN_GL, GUN_SG, and m_bomb.

Referenced by itemspawned(), request(), and tryitem().

static bool ai::iswaypoint ( int  n)
inlinestatic
void ai::items ( fpsent d,
aistate &  b,
vector< interest > &  interests,
bool  force = false 
)
void ai::itemspawned ( int  ent)
void ai::jumpto ( fpsent d,
aistate &  b,
const vec pos 
)
void ai::killed ( fpsent d,
fpsent e 
)
void ai::linkwaypoint ( waypoint &  a,
int  n 
)
void ai::loadwaypoints ( bool  force = false,
const char *  mname = nullptr 
)
bool ai::lockon ( fpsent d,
fpsent e,
float  maxdist 
)
void ai::logic ( fpsent d,
aistate &  b,
bool  run 
)
bool ai::makeroute ( fpsent d,
aistate &  b,
int  node,
bool  changed,
int  retries 
)
bool ai::makeroute ( fpsent d,
aistate &  b,
const vec pos,
bool  changed,
int  retries 
)
void ai::movewaypoints ( const vec d)
void ai::navigate ( )
void ai::navigate ( fpsent d)
bool ai::parseinterests ( fpsent d,
aistate &  b,
vector< interest > &  interests,
bool  override,
bool  ignore 
)
bool ai::patrol ( fpsent d,
aistate &  b,
const vec pos,
float  guard,
float  wander,
int  walk,
bool  retry 
)
int ai::process ( fpsent d,
aistate &  b 
)
int ai::randomlink ( fpsent d,
int  n 
)
bool ai::randomnode ( fpsent d,
aistate &  b,
const vec pos,
float  guard,
float  wander 
)
bool ai::randomnode ( fpsent d,
aistate &  b,
float  guard,
float  wander 
)

References physent::feetpos(), and randomnode().

void ai::remapwaypoints ( )
void ai::render ( )
bool ai::request ( fpsent d,
aistate &  b 
)
bool ai::route ( fpsent d,
int  node,
int  goal,
vector< int > &  route,
const avoidset &  obstacles,
int  retries = 0 
)
void ai::savewaypoints ( bool  force = false,
const char *  mname = nullptr 
)
void ai::scaleyawpitch ( float &  yaw,
float &  pitch,
float  targyaw,
float  targpitch,
float  frame,
float  scale 
)

References f(), and fixrange().

Referenced by process().

void ai::seedwaypoints ( )
void ai::setup ( fpsent d)
static bool ai::shoulddrop ( fpsent d)
inlinestatic

References fpsent::ai, dropwaypoints, and loadedwaypoints.

Referenced by inferwaypoints(), and navigate().

static bool ai::shouldnavigate ( )
inlinestatic

References AI_NONE, dropwaypoints, loopvrev, and game::players.

Referenced by inferwaypoints(), and navigate().

void ai::spawned ( fpsent d)
bool ai::target ( fpsent d,
aistate &  b,
int  pursue = 0,
bool  force = false,
float  mindist = 0.f 
)
bool ai::targetable ( fpsent d,
fpsent e 
)
void ai::think ( fpsent d,
bool  run 
)
void ai::timeouts ( fpsent d,
aistate &  b 
)
static void ai::tryitem ( fpsent d,
extentity e,
int  id,
aistate &  b,
vector< interest > &  interests,
bool  force = false 
)
static
void ai::update ( )
ai::VAR ( aidebug  ,
,
,
 
)
ai::VAR ( aiforcegun  ,
1,
1,
NUMGUNS 1 
)
ai::VAR ( showwaypoints  ,
,
,
 
)
ai::VAR ( showwaypointsradius  ,
,
200  ,
10000   
)
ai::VARF ( dropwaypoints  ,
,
,
,
{player1->lastnode=-1;}   
)
float ai::viewdist ( int  x)

References f(), SIGHTMAX, and SIGHTMIN.

Referenced by init().

float ai::viewfieldx ( int  x)

References f(), VIEWMAX, and VIEWMIN.

Referenced by init(), and viewfieldy().

float ai::viewfieldy ( int  x)

References viewfieldx().

Referenced by init().

bool ai::violence ( fpsent d,
aistate &  b,
fpsent e,
int  pursue 
)
float ai::weapmaxdist ( int  weap)

References guns, and guninfo::range.

Referenced by weaprange().

float ai::weapmindist ( int  weap)

References guns, and inexor::rpc::max().

Referenced by weaprange().

bool ai::weaprange ( fpsent d,
int  weap,
float  dist 
)

References weapmaxdist(), and weapmindist().

Referenced by canshoot(), hasrange(), and hastarget().

int ai::wpspot ( fpsent d,
int  n,
bool  check = false 
)

Variable Documentation

vec ai::aitarget
int ai::clearedwpcaches = (1<<NUMWPCACHES)-1
static
const float ai::CLOSEDIST = 32.f

Referenced by closenode(), and dointerest().

SharedVar<int> ai::dropwaypoints
const float ai::FARDIST = 128.f

Referenced by closenode().

int ai::forcegun = -1

Referenced by setup(), and update().

int ai::invalidatedwpcaches = 0
static
int ai::iteration = 0

Referenced by update().

int ai::itermillis = 0

Referenced by update().

const float ai::JUMPMAX = 32.f

Referenced by ai::avoidset::remap().

const float ai::JUMPMIN = 4.f

Referenced by getweight(), and jumpto().

int ai::lastwpcache = 0
static
string ai::loadedwaypoints = ""
const int ai::MAXWAYPOINTLINKS = 6
const int ai::MAXWAYPOINTS = USHRT_MAX - 2

Referenced by addwaypoint().

const float ai::MINWPDIST = 4.f

Referenced by wpspot().

int ai::numinvalidatewpcaches = 0
static

Referenced by clearwpcache(), and invalidatewpcache().

const int ai::NUMPREVNODES = 6
avoidset ai::obstacles
SharedVar<int> ai::showwaypoints

Referenced by render().

const float ai::SIGHTMAX = 1024.f

Referenced by navigate(), and viewdist().

const float ai::SIGHTMIN = 64.f
const char* ai::stnames[AI_S_MAX]
Initial value:
= {
"wait", "defend", "pursue", "interest"
}

Referenced by render().

const char * ai::sttypes[AI_T_MAX+1]
Initial value:
= {
"none", "node", "player", "affinity", "entity"
}

Referenced by render().

vector<int> ai::targets
static
int ai::updatemillis = 0

Referenced by update().

const float ai::VIEWMAX = 180.f

Referenced by viewfieldx().

const float ai::VIEWMIN = 90.f

Referenced by viewfieldx().

const int ai::WAYPOINTRADIUS = 16
vector< waypoint > ai::waypoints
avoidset ai::wpavoid

Referenced by avoid(), and buildwpcache().

struct ai::wpcache ai::wpcaches[NUMWPCACHES]