Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

be_ai_move.c File Reference

#include "../game/q_shared.h"
#include "l_memory.h"
#include "l_libvar.h"
#include "l_utils.h"
#include "l_script.h"
#include "l_precomp.h"
#include "l_struct.h"
#include "aasfile.h"
#include "../game/botlib.h"
#include "../game/be_aas.h"
#include "be_aas_funcs.h"
#include "be_interface.h"
#include "../game/be_ea.h"
#include "../game/be_ai_goal.h"
#include "../game/be_ai_move.h"

Include dependency graph for be_ai_move.c:

Include dependency graph

Go to the source code of this file.

Data Structures

struct  bot_movestate_s

Defines

#define AVOIDREACH
#define AVOIDREACH_TIME   6
#define AVOIDREACH_TRIES   4
#define MODELTYPE_FUNC_BOB   2
#define MODELTYPE_FUNC_DOOR   3
#define MODELTYPE_FUNC_PLAT   1
#define MODELTYPE_FUNC_STATIC   4
#define PREDICTIONTIME_JUMP   3
#define PREDICTIONTIME_MOVE   2
#define WEAPONINDEX_BFG   9
#define WEAPONINDEX_ROCKET_LAUNCHER   5

Typedefs

typedef bot_movestate_s bot_movestate_t

Functions

float AngleDiff (float ang1, float ang2)
void BotAddAvoidSpot (int movestate, vec3_t origin, float radius, int type)
void BotAddToAvoidReach (bot_movestate_t *ms, int number, float avoidtime)
int BotAddToTarget (vec3_t start, vec3_t end, float maxdist, float *dist, vec3_t target)
int BotAirControl (vec3_t origin, vec3_t velocity, vec3_t goal, vec3_t dir, float *speed)
int BotAllocMoveState (void)
int BotAvoidSpots (vec3_t origin, aas_reachability_t *reach, bot_avoidspot_t *avoidspots, int numavoidspots)
int BotCheckBarrierJump (bot_movestate_t *ms, vec3_t dir, float speed)
void BotCheckBlocked (bot_movestate_t *ms, vec3_t dir, int checkbottom, bot_moveresult_t *result)
void BotClearMoveResult (bot_moveresult_t *moveresult)
bot_moveresult_t BotFinishTravel_BarrierJump (bot_movestate_t *ms, aas_reachability_t *reach)
bot_moveresult_t BotFinishTravel_Elevator (bot_movestate_t *ms, aas_reachability_t *reach)
bot_moveresult_t BotFinishTravel_FuncBobbing (bot_movestate_t *ms, aas_reachability_t *reach)
bot_moveresult_t BotFinishTravel_Jump (bot_movestate_t *ms, aas_reachability_t *reach)
bot_moveresult_t BotFinishTravel_JumpPad (bot_movestate_t *ms, aas_reachability_t *reach)
bot_moveresult_t BotFinishTravel_Walk (bot_movestate_t *ms, aas_reachability_t *reach)
bot_moveresult_t BotFinishTravel_WalkOffLedge (bot_movestate_t *ms, aas_reachability_t *reach)
bot_moveresult_t BotFinishTravel_WaterJump (bot_movestate_t *ms, aas_reachability_t *reach)
bot_moveresult_t BotFinishTravel_WeaponJump (bot_movestate_t *ms, aas_reachability_t *reach)
void BotFreeMoveState (int handle)
void BotFuncBobStartEnd (aas_reachability_t *reach, vec3_t start, vec3_t end, vec3_t origin)
int BotFuzzyPointReachabilityArea (vec3_t origin)
float BotGapDistance (vec3_t origin, vec3_t hordir, int entnum)
int BotGetReachabilityToGoal (vec3_t origin, int areanum, int lastgoalareanum, int lastareanum, int *avoidreach, float *avoidreachtimes, int *avoidreachtries, bot_goal_t *goal, int travelflags, int movetravelflags, struct bot_avoidspot_s *avoidspots, int numavoidspots, int *flags)
void BotInitMoveState (int handle, bot_initmove_t *initmove)
int BotMoveInDirection (int movestate, vec3_t dir, float speed, int type)
bot_moveresult_t BotMoveInGoalArea (bot_movestate_t *ms, bot_goal_t *goal)
int BotMovementViewTarget (int movestate, bot_goal_t *goal, int travelflags, float lookahead, vec3_t target)
bot_movestate_tBotMoveStateFromHandle (int handle)
void BotMoveToGoal (bot_moveresult_t *result, int movestate, bot_goal_t *goal, int travelflags)
int BotOnMover (vec3_t origin, int entnum, aas_reachability_t *reach)
int BotOnTopOfEntity (bot_movestate_t *ms)
int BotPredictVisiblePosition (vec3_t origin, int areanum, bot_goal_t *goal, int travelflags, vec3_t target)
int BotReachabilityArea (vec3_t origin, int client)
int BotReachabilityTime (aas_reachability_t *reach)
void BotResetAvoidReach (int movestate)
void BotResetGrapple (bot_movestate_t *ms)
void BotResetLastAvoidReach (int movestate)
void BotResetMoveState (int movestate)
void BotSetBrushModelTypes (void)
int BotSetupMoveAI (void)
void BotShutdownMoveAI (void)
int BotSwimInDirection (bot_movestate_t *ms, vec3_t dir, float speed, int type)
bot_moveresult_t BotTravel_BarrierJump (bot_movestate_t *ms, aas_reachability_t *reach)
bot_moveresult_t BotTravel_BFGJump (bot_movestate_t *ms, aas_reachability_t *reach)
bot_moveresult_t BotTravel_Crouch (bot_movestate_t *ms, aas_reachability_t *reach)
bot_moveresult_t BotTravel_Elevator (bot_movestate_t *ms, aas_reachability_t *reach)
bot_moveresult_t BotTravel_FuncBobbing (bot_movestate_t *ms, aas_reachability_t *reach)
bot_moveresult_t BotTravel_Grapple (bot_movestate_t *ms, aas_reachability_t *reach)
bot_moveresult_t BotTravel_Jump (bot_movestate_t *ms, aas_reachability_t *reach)
bot_moveresult_t BotTravel_JumpPad (bot_movestate_t *ms, aas_reachability_t *reach)
bot_moveresult_t BotTravel_Ladder (bot_movestate_t *ms, aas_reachability_t *reach)
bot_moveresult_t BotTravel_RocketJump (bot_movestate_t *ms, aas_reachability_t *reach)
bot_moveresult_t BotTravel_Swim (bot_movestate_t *ms, aas_reachability_t *reach)
bot_moveresult_t BotTravel_Teleport (bot_movestate_t *ms, aas_reachability_t *reach)
bot_moveresult_t BotTravel_Walk (bot_movestate_t *ms, aas_reachability_t *reach)
bot_moveresult_t BotTravel_WalkOffLedge (bot_movestate_t *ms, aas_reachability_t *reach)
bot_moveresult_t BotTravel_WaterJump (bot_movestate_t *ms, aas_reachability_t *reach)
int BotValidTravel (vec3_t origin, aas_reachability_t *reach, int travelflags)
int BotVisible (int ent, vec3_t eye, vec3_t target)
int BotWalkInDirection (bot_movestate_t *ms, vec3_t dir, float speed, int type)
float DistanceFromLineSquared (vec3_t p, vec3_t lp1, vec3_t lp2)
int GrappleState (bot_movestate_t *ms, aas_reachability_t *reach)
int Intersection (vec2_t p1, vec2_t p2, vec2_t p3, vec2_t p4, vec2_t out)
void MoverBottomCenter (aas_reachability_t *reach, vec3_t bottomcenter)
int MoverDown (aas_reachability_t *reach)
float VectorDistanceSquared (vec3_t p1, vec3_t p2)

Variables

bot_movestate_tbotmovestates [MAX_CLIENTS+1]
libvar_tcmd_grappleoff
libvar_tcmd_grappleon
libvar_tentitytypemissile
int modeltypes [MAX_MODELS]
libvar_toffhandgrapple
libvar_tsv_gravity
libvar_tsv_maxbarrier
libvar_tsv_maxstep
libvar_tweapindex_bfg10k
libvar_tweapindex_grapple
libvar_tweapindex_rocketlauncher


Define Documentation

#define AVOIDREACH
 

Definition at line 91 of file be_ai_move.c.

#define AVOIDREACH_TIME   6
 

Definition at line 92 of file be_ai_move.c.

Referenced by BotMoveToGoal().

#define AVOIDREACH_TRIES   4
 

Definition at line 93 of file be_ai_move.c.

#define MODELTYPE_FUNC_BOB   2
 

Definition at line 102 of file be_ai_move.c.

#define MODELTYPE_FUNC_DOOR   3
 

Definition at line 103 of file be_ai_move.c.

#define MODELTYPE_FUNC_PLAT   1
 

Definition at line 101 of file be_ai_move.c.

Referenced by BotReachabilityArea().

#define MODELTYPE_FUNC_STATIC   4
 

Definition at line 104 of file be_ai_move.c.

Referenced by BotMoveToGoal().

#define PREDICTIONTIME_JUMP   3
 

Definition at line 95 of file be_ai_move.c.

Referenced by BotWalkInDirection().

#define PREDICTIONTIME_MOVE   2
 

Definition at line 96 of file be_ai_move.c.

#define WEAPONINDEX_BFG   9
 

Definition at line 99 of file be_ai_move.c.

#define WEAPONINDEX_ROCKET_LAUNCHER   5
 

Definition at line 98 of file be_ai_move.c.


Typedef Documentation

typedef struct bot_movestate_s bot_movestate_t
 

Referenced by BotAddAvoidSpot(), BotAddToAvoidReach(), BotAllocMoveState(), BotCheckBarrierJump(), BotCheckBlocked(), BotFinishTravel_BarrierJump(), BotFinishTravel_Elevator(), BotFinishTravel_FuncBobbing(), BotFinishTravel_Jump(), BotFinishTravel_JumpPad(), BotFinishTravel_Walk(), BotFinishTravel_WalkOffLedge(), BotFinishTravel_WaterJump(), BotFinishTravel_WeaponJump(), BotInitMoveState(), BotMoveInDirection(), BotMoveInGoalArea(), BotMovementViewTarget(), BotMoveStateFromHandle(), BotMoveToGoal(), BotOnTopOfEntity(), BotResetAvoidReach(), BotResetGrapple(), BotResetLastAvoidReach(), BotResetMoveState(), BotSwimInDirection(), BotTravel_BarrierJump(), BotTravel_BFGJump(), BotTravel_Crouch(), BotTravel_Elevator(), BotTravel_FuncBobbing(), BotTravel_Grapple(), BotTravel_Jump(), BotTravel_JumpPad(), BotTravel_Ladder(), BotTravel_RocketJump(), BotTravel_Swim(), BotTravel_Teleport(), BotTravel_Walk(), BotTravel_WalkOffLedge(), BotTravel_WaterJump(), BotWalkInDirection(), and GrappleState().


Function Documentation

float AngleDiff float  ang1,
float  ang2
 

Definition at line 220 of file be_ai_move.c.

Referenced by BotTravel_BFGJump(), BotTravel_Grapple(), and BotTravel_RocketJump().

00221 {
00222     float diff;
00223 
00224     diff = ang1 - ang2;
00225     if (ang1 > ang2)
00226     {
00227         if (diff > 180.0) diff -= 360.0;
00228     } //end if
00229     else
00230     {
00231         if (diff < -180.0) diff += 360.0;
00232     } //end else
00233     return diff;
00234 } //end of the function AngleDiff

void BotAddAvoidSpot int  movestate,
vec3_t  origin,
float  radius,
int  type
 

Definition at line 719 of file be_ai_move.c.

References bot_movestate_s::avoidspots, bot_movestate_t, BotMoveStateFromHandle(), bot_movestate_s::numavoidspots, bot_movestate_s::origin, bot_avoidspot_s::radius, type, bot_avoidspot_s::type, and VectorCopy.

00720 {
00721     bot_movestate_t *ms;
00722 
00723     ms = BotMoveStateFromHandle(movestate);
00724     if (!ms) return;
00725     if (type == AVOID_CLEAR)
00726     {
00727         ms->numavoidspots = 0;
00728         return;
00729     } //end if
00730 
00731     if (ms->numavoidspots >= MAX_AVOIDSPOTS)
00732         return;
00733     VectorCopy(origin, ms->avoidspots[ms->numavoidspots].origin);
00734     ms->avoidspots[ms->numavoidspots].radius = radius;
00735     ms->avoidspots[ms->numavoidspots].type = type;
00736     ms->numavoidspots++;
00737 } //end of the function BotAddAvoidSpot

Here is the call graph for this function:

void BotAddToAvoidReach bot_movestate_t ms,
int  number,
float  avoidtime
 

Definition at line 583 of file be_ai_move.c.

References AAS_Time(), bot_movestate_s::avoidreach, bot_movestate_s::avoidreachtimes, bot_movestate_s::avoidreachtries, bot_movestate_t, and i.

Referenced by BotMoveToGoal().

00584 {
00585     int i;
00586 
00587     for (i = 0; i < MAX_AVOIDREACH; i++)
00588     {
00589         if (ms->avoidreach[i] == number)
00590         {
00591             if (ms->avoidreachtimes[i] > AAS_Time()) ms->avoidreachtries[i]++;
00592             else ms->avoidreachtries[i] = 1;
00593             ms->avoidreachtimes[i] = AAS_Time() + avoidtime;
00594             return;
00595         } //end if
00596     } //end for
00597     //add the reachability to the reachabilities to avoid for a while
00598     for (i = 0; i < MAX_AVOIDREACH; i++)
00599     {
00600         if (ms->avoidreachtimes[i] < AAS_Time())
00601         {
00602             ms->avoidreach[i] = number;
00603             ms->avoidreachtimes[i] = AAS_Time() + avoidtime;
00604             ms->avoidreachtries[i] = 1;
00605             return;
00606         } //end if
00607     } //end for
00608 } //end of the function BotAddToAvoidReach

Here is the call graph for this function:

int BotAddToTarget vec3_t  start,
vec3_t  end,
float  maxdist,
float *  dist,
vec3_t  target
 

Definition at line 822 of file be_ai_move.c.

References vec3_t, VectorCopy, VectorMA, VectorNormalize(), and VectorSubtract.

Referenced by BotMovementViewTarget().

00823 {
00824     vec3_t dir;
00825     float curdist;
00826 
00827     VectorSubtract(end, start, dir);
00828     curdist = VectorNormalize(dir);
00829     if (*dist + curdist < maxdist)
00830     {
00831         VectorCopy(end, target);
00832         *dist += curdist;
00833         return qfalse;
00834     } //end if
00835     else
00836     {
00837         VectorMA(start, maxdist - *dist, dir, target);
00838         *dist = maxdist;
00839         return qtrue;
00840     } //end else
00841 } //end of the function BotAddToTarget

Here is the call graph for this function:

int BotAirControl vec3_t  origin,
vec3_t  velocity,
vec3_t  goal,
vec3_t  dir,
float *  speed
 

Definition at line 1692 of file be_ai_move.c.

References i, sv_gravity, libvar_s::value, vec3_t, VectorAdd, VectorCopy, VectorNormalize(), VectorScale, VectorSet, and VectorSubtract.

Referenced by BotFinishTravel_JumpPad(), BotFinishTravel_WalkOffLedge(), and BotFinishTravel_WeaponJump().

01693 {
01694     vec3_t org, vel;
01695     float dist;
01696     int i;
01697 
01698     VectorCopy(origin, org);
01699     VectorScale(velocity, 0.1, vel);
01700     for (i = 0; i < 50; i++)
01701     {
01702         vel[2] -= sv_gravity->value * 0.01;
01703         //if going down and next position would be below the goal
01704         if (vel[2] < 0 && org[2] + vel[2] < goal[2])
01705         {
01706             VectorScale(vel, (goal[2] - org[2]) / vel[2], vel);
01707             VectorAdd(org, vel, org);
01708             VectorSubtract(goal, org, dir);
01709             dist = VectorNormalize(dir);
01710             if (dist > 32) dist = 32;
01711             *speed = 400 - (400 - 13 * dist);
01712             return qtrue;
01713         } //end if
01714         else
01715         {
01716             VectorAdd(org, vel, org);
01717         } //end else
01718     } //end for
01719     VectorSet(dir, 0, 0, 0);
01720     *speed = 400;
01721     return qfalse;
01722 } //end of the function BotAirControl

Here is the call graph for this function:

int BotAllocMoveState void   ) 
 

Definition at line 127 of file be_ai_move.c.

References bot_movestate_t, botmovestates, GetClearedMemory(), and i.

00128 {
00129     int i;
00130 
00131     for (i = 1; i <= MAX_CLIENTS; i++)
00132     {
00133         if (!botmovestates[i])
00134         {
00135             botmovestates[i] = GetClearedMemory(sizeof(bot_movestate_t));
00136             return i;
00137         } //end if
00138     } //end for
00139     return 0;
00140 } //end of the function BotAllocMoveState

Here is the call graph for this function:

int BotAvoidSpots vec3_t  origin,
aas_reachability_t reach,
bot_avoidspot_t avoidspots,
int  numavoidspots
 

Definition at line 653 of file be_ai_move.c.

References aas_reachability_t, bot_avoidspot_t, DistanceFromLineSquared(), aas_reachability_s::end, i, Square, aas_reachability_s::start, TRAVEL_BARRIERJUMP, TRAVEL_BFGJUMP, TRAVEL_CROUCH, TRAVEL_ELEVATOR, TRAVEL_FUNCBOB, TRAVEL_GRAPPLEHOOK, TRAVEL_JUMP, TRAVEL_JUMPPAD, TRAVEL_LADDER, TRAVEL_ROCKETJUMP, TRAVEL_SWIM, TRAVEL_TELEPORT, TRAVEL_WALK, TRAVEL_WALKOFFLEDGE, TRAVEL_WATERJUMP, aas_reachability_s::traveltype, bot_avoidspot_s::type, type, and VectorDistanceSquared().

Referenced by BotGetReachabilityToGoal().

00654 {
00655     int checkbetween, i, type;
00656     float squareddist, squaredradius;
00657 
00658     switch(reach->traveltype & TRAVELTYPE_MASK)
00659     {
00660         case TRAVEL_WALK: checkbetween = qtrue; break;
00661         case TRAVEL_CROUCH: checkbetween = qtrue; break;
00662         case TRAVEL_BARRIERJUMP: checkbetween = qtrue; break;
00663         case TRAVEL_LADDER: checkbetween = qtrue; break;
00664         case TRAVEL_WALKOFFLEDGE: checkbetween = qfalse; break;
00665         case TRAVEL_JUMP: checkbetween = qfalse; break;
00666         case TRAVEL_SWIM: checkbetween = qtrue; break;
00667         case TRAVEL_WATERJUMP: checkbetween = qtrue; break;
00668         case TRAVEL_TELEPORT: checkbetween = qfalse; break;
00669         case TRAVEL_ELEVATOR: checkbetween = qfalse; break;
00670         case TRAVEL_GRAPPLEHOOK: checkbetween = qfalse; break;
00671         case TRAVEL_ROCKETJUMP: checkbetween = qfalse; break;
00672         case TRAVEL_BFGJUMP: checkbetween = qfalse; break;
00673         case TRAVEL_JUMPPAD: checkbetween = qfalse; break;
00674         case TRAVEL_FUNCBOB: checkbetween = qfalse; break;
00675         default: checkbetween = qtrue; break;
00676     } //end switch
00677 
00678     type = AVOID_CLEAR;
00679     for (i = 0; i < numavoidspots; i++)
00680     {
00681         squaredradius = Square(avoidspots[i].radius);
00682         squareddist = DistanceFromLineSquared(avoidspots[i].origin, origin, reach->start);
00683         // if moving towards the avoid spot
00684         if (squareddist < squaredradius &&
00685             VectorDistanceSquared(avoidspots[i].origin, origin) > squareddist)
00686         {
00687             type = avoidspots[i].type;
00688         } //end if
00689         else if (checkbetween) {
00690             squareddist = DistanceFromLineSquared(avoidspots[i].origin, reach->start, reach->end);
00691             // if moving towards the avoid spot
00692             if (squareddist < squaredradius &&
00693                 VectorDistanceSquared(avoidspots[i].origin, reach->start) > squareddist)
00694             {
00695                 type = avoidspots[i].type;
00696             } //end if
00697         } //end if
00698         else
00699         {
00700             VectorDistanceSquared(avoidspots[i].origin, reach->end);
00701             // if the reachability leads closer to the avoid spot
00702             if (squareddist < squaredradius && 
00703                 VectorDistanceSquared(avoidspots[i].origin, reach->start) > squareddist)
00704             {
00705                 type = avoidspots[i].type;
00706             } //end if
00707         } //end else
00708         if (type == AVOID_ALWAYS)
00709             return type;
00710     } //end for
00711     return type;
00712 } //end of the function BotAvoidSpots

Here is the call graph for this function:

int BotCheckBarrierJump bot_movestate_t ms,
vec3_t  dir,
float  speed
 

Definition at line 1049 of file be_ai_move.c.

References aas_trace_t, AAS_TraceClientBBox(), bot_movestate_t, bot_movestate_s::client, EA_Jump(), EA_Move(), aas_trace_s::endpos, bot_movestate_s::entitynum, aas_trace_s::fraction, bot_movestate_s::moveflags, bot_movestate_s::origin, PRESENCE_NORMAL, aas_trace_s::startsolid, sv_maxbarrier, sv_maxstep, bot_movestate_s::thinktime, libvar_s::value, vec3_t, VectorCopy, VectorMA, and VectorNormalize().

Referenced by BotTravel_Elevator(), BotTravel_FuncBobbing(), and BotWalkInDirection().

01050 {
01051     vec3_t start, hordir, end;
01052     aas_trace_t trace;
01053 
01054     VectorCopy(ms->origin, end);
01055     end[2] += sv_maxbarrier->value;
01056     //trace right up
01057     trace = AAS_TraceClientBBox(ms->origin, end, PRESENCE_NORMAL, ms->entitynum);
01058     //this shouldn't happen... but we check anyway
01059     if (trace.startsolid) return qfalse;
01060     //if very low ceiling it isn't possible to jump up to a barrier
01061     if (trace.endpos[2] - ms->origin[2] < sv_maxstep->value) return qfalse;
01062     //
01063     hordir[0] = dir[0];
01064     hordir[1] = dir[1];
01065     hordir[2] = 0;
01066     VectorNormalize(hordir);
01067     VectorMA(ms->origin, ms->thinktime * speed * 0.5, hordir, end);
01068     VectorCopy(trace.endpos, start);
01069     end[2] = trace.endpos[2];
01070     //trace from previous trace end pos horizontally in the move direction
01071     trace = AAS_TraceClientBBox(start, end, PRESENCE_NORMAL, ms->entitynum);
01072     //again this shouldn't happen
01073     if (trace.startsolid) return qfalse;
01074     //
01075     VectorCopy(trace.endpos, start);
01076     VectorCopy(trace.endpos, end);
01077     end[2] = ms->origin[2];
01078     //trace down from the previous trace end pos
01079     trace = AAS_TraceClientBBox(start, end, PRESENCE_NORMAL, ms->entitynum);
01080     //if solid
01081     if (trace.startsolid) return qfalse;
01082     //if no obstacle at all
01083     if (trace.fraction >= 1.0) return qfalse;
01084     //if less than the maximum step height
01085     if (trace.endpos[2] - ms->origin[2] < sv_maxstep->value) return qfalse;
01086     //
01087     EA_Jump(ms->client);
01088     EA_Move(ms->client, hordir, speed);
01089     ms->moveflags |= MFL_BARRIERJUMP;
01090     //there is a barrier
01091     return qtrue;
01092 } //end of the function BotCheckBarrierJump

Here is the call graph for this function:

void BotCheckBlocked bot_movestate_t ms,
vec3_t  dir,
int  checkbottom,
bot_moveresult_t result
 

Definition at line 1282 of file be_ai_move.c.

References AAS_AreaReachability(), AAS_PresenceTypeBoundingBox(), AAS_Trace(), bot_movestate_s::areanum, bot_moveresult_s::blocked, bot_moveresult_s::blockentity, bot_moveresult_t, bot_movestate_t, bsp_trace_t, CONTENTS_BODY, CONTENTS_PLAYERCLIP, CONTENTS_SOLID, DotProduct, bsp_trace_s::ent, bot_movestate_s::entitynum, ENTITYNUM_WORLD, fabs(), bot_moveresult_s::flags, bot_movestate_s::origin, bot_movestate_s::presencetype, bsp_trace_s::startsolid, sv_maxstep, up, libvar_s::value, vec3_t, and VectorMA.

Referenced by BotFinishTravel_BarrierJump(), BotFinishTravel_JumpPad(), BotFinishTravel_WalkOffLedge(), BotMoveInGoalArea(), BotTravel_BarrierJump(), BotTravel_Crouch(), BotTravel_Elevator(), BotTravel_FuncBobbing(), BotTravel_Grapple(), BotTravel_JumpPad(), BotTravel_Swim(), BotTravel_Teleport(), BotTravel_Walk(), and BotTravel_WalkOffLedge().

01283 {
01284     vec3_t mins, maxs, end, up = {0, 0, 1};
01285     bsp_trace_t trace;
01286 
01287     //test for entities obstructing the bot's path
01288     AAS_PresenceTypeBoundingBox(ms->presencetype, mins, maxs);
01289     //
01290     if (fabs(DotProduct(dir, up)) < 0.7)
01291     {
01292         mins[2] += sv_maxstep->value; //if the bot can step on
01293         maxs[2] -= 10; //a little lower to avoid low ceiling
01294     } //end if
01295     VectorMA(ms->origin, 3, dir, end);
01296     trace = AAS_Trace(ms->origin, mins, maxs, end, ms->entitynum, CONTENTS_SOLID|CONTENTS_PLAYERCLIP|CONTENTS_BODY);
01297     //if not started in solid and not hitting the world entity
01298     if (!trace.startsolid && (trace.ent != ENTITYNUM_WORLD && trace.ent != ENTITYNUM_NONE) )
01299     {
01300         result->blocked = qtrue;
01301         result->blockentity = trace.ent;
01302 #ifdef DEBUG
01303         //botimport.Print(PRT_MESSAGE, "%d: BotCheckBlocked: I'm blocked\n", ms->client);
01304 #endif //DEBUG
01305     } //end if
01306     //if not in an area with reachability
01307     else if (checkbottom && !AAS_AreaReachability(ms->areanum))
01308     {
01309         //check if the bot is standing on something
01310         AAS_PresenceTypeBoundingBox(ms->presencetype, mins, maxs);
01311         VectorMA(ms->origin, -3, up, end);
01312         trace = AAS_Trace(ms->origin, mins, maxs, end, ms->entitynum, CONTENTS_SOLID|CONTENTS_PLAYERCLIP);
01313         if (!trace.startsolid && (trace.ent != ENTITYNUM_WORLD && trace.ent != ENTITYNUM_NONE) )
01314         {
01315             result->blocked = qtrue;
01316             result->blockentity = trace.ent;
01317             result->flags |= MOVERESULT_ONTOPOFOBSTACLE;
01318 #ifdef DEBUG
01319             //botimport.Print(PRT_MESSAGE, "%d: BotCheckBlocked: I'm blocked\n", ms->client);
01320 #endif //DEBUG
01321         } //end if
01322     } //end else
01323 } //end of the function BotCheckBlocked

Here is the call graph for this function:

void BotClearMoveResult bot_moveresult_t moveresult  ) 
 

Definition at line 1330 of file be_ai_move.c.

References bot_moveresult_s::blocked, bot_moveresult_s::blockentity, bot_moveresult_t, bot_moveresult_s::failure, bot_moveresult_s::flags, bot_moveresult_s::traveltype, and bot_moveresult_s::type.

Referenced by BotFinishTravel_BarrierJump(), BotFinishTravel_Elevator(), BotFinishTravel_FuncBobbing(), BotFinishTravel_Jump(), BotFinishTravel_JumpPad(), BotFinishTravel_Walk(), BotFinishTravel_WalkOffLedge(), BotFinishTravel_WaterJump(), BotFinishTravel_WeaponJump(), BotMoveInGoalArea(), BotMoveToGoal(), BotTravel_BarrierJump(), BotTravel_BFGJump(), BotTravel_Crouch(), BotTravel_Elevator(), BotTravel_FuncBobbing(), BotTravel_Grapple(), BotTravel_Jump(), BotTravel_JumpPad(), BotTravel_Ladder(), BotTravel_RocketJump(), BotTravel_Swim(), BotTravel_Teleport(), BotTravel_Walk(), BotTravel_WalkOffLedge(), and BotTravel_WaterJump().

01331 {
01332     moveresult->failure = qfalse;
01333     moveresult->type = 0;
01334     moveresult->blocked = qfalse;
01335     moveresult->blockentity = 0;
01336     moveresult->traveltype = 0;
01337     moveresult->flags = 0;
01338 } //end of the function BotClearMoveResult

bot_moveresult_t BotFinishTravel_BarrierJump bot_movestate_t ms,
aas_reachability_t reach
 

Definition at line 1503 of file be_ai_move.c.

References aas_reachability_t, bot_moveresult_t, bot_movestate_t, BotCheckBlocked(), BotClearMoveResult(), bot_movestate_s::client, EA_Move(), aas_reachability_s::end, bot_moveresult_s::movedir, bot_movestate_s::origin, qtrue, vec3_t, VectorCopy, VectorNormalize(), and bot_movestate_s::velocity.

Referenced by BotMoveToGoal().

01504 {
01505     float dist;
01506     vec3_t hordir;
01507     bot_moveresult_t result;
01508 
01509     BotClearMoveResult(&result);
01510     //if near the top or going down
01511     if (ms->velocity[2] < 250)
01512     {
01513         hordir[0] = reach->end[0] - ms->origin[0];
01514         hordir[1] = reach->end[1] - ms->origin[1];
01515         hordir[2] = 0;
01516         dist = VectorNormalize(hordir);
01517         //
01518         BotCheckBlocked(ms, hordir, qtrue, &result);
01519         //
01520         EA_Move(ms->client, hordir, 400);
01521         VectorCopy(hordir, result.movedir);
01522     } //end if
01523     //
01524     return result;
01525 } //end of the function BotFinishTravel_BarrierJump

Here is the call graph for this function:

bot_moveresult_t BotFinishTravel_Elevator bot_movestate_t ms,
aas_reachability_t reach
 

Definition at line 2233 of file be_ai_move.c.

References aas_reachability_t, bot_moveresult_t, bot_movestate_t, BotClearMoveResult(), bot_movestate_s::client, EA_Move(), aas_reachability_s::end, fabs(), MoverBottomCenter(), bot_movestate_s::origin, vec3_t, VectorNormalize(), and VectorSubtract.

Referenced by BotMoveToGoal().

02234 {
02235     vec3_t bottomcenter, bottomdir, topdir;
02236     bot_moveresult_t result;
02237 
02238     BotClearMoveResult(&result);
02239     //
02240     MoverBottomCenter(reach, bottomcenter);
02241     VectorSubtract(bottomcenter, ms->origin, bottomdir);
02242     //
02243     VectorSubtract(reach->end, ms->origin, topdir);
02244     //
02245     if (fabs(bottomdir[2]) < fabs(topdir[2]))
02246     {
02247         VectorNormalize(bottomdir);
02248         EA_Move(ms->client, bottomdir, 300);
02249     } //end if
02250     else
02251     {
02252         VectorNormalize(topdir);
02253         EA_Move(ms->client, topdir, 300);
02254     } //end else
02255     return result;
02256 } //end of the function BotFinishTravel_Elevator

Here is the call graph for this function:

bot_moveresult_t BotFinishTravel_FuncBobbing bot_movestate_t ms,
aas_reachability_t reach
 

Definition at line 2479 of file be_ai_move.c.

References aas_reachability_t, bot_moveresult_t, bot_movestate_t, BotClearMoveResult(), BotFuncBobStartEnd(), bot_movestate_s::client, EA_Move(), aas_reachability_s::end, bot_moveresult_s::flags, bot_moveresult_s::movedir, bot_movestate_s::moveflags, MoverBottomCenter(), bot_movestate_s::origin, vec3_t, VectorCopy, VectorLength(), VectorNormalize(), and VectorSubtract.

Referenced by BotMoveToGoal().

02480 {
02481     vec3_t bob_origin, bob_start, bob_end, dir, hordir, bottomcenter;
02482     bot_moveresult_t result;
02483     float dist, speed;
02484 
02485     BotClearMoveResult(&result);
02486     //
02487     BotFuncBobStartEnd(reach, bob_start, bob_end, bob_origin);
02488     //
02489     VectorSubtract(bob_origin, bob_end, dir);
02490     dist = VectorLength(dir);
02491     //if the func_bobbing is near the end
02492     if (dist < 16)
02493     {
02494         VectorSubtract(reach->end, ms->origin, hordir);
02495         if (!(ms->moveflags & MFL_SWIMMING)) hordir[2] = 0;
02496         dist = VectorNormalize(hordir);
02497         //
02498         if (dist > 60) dist = 60;
02499         speed = 360 - (360 - 6 * dist);
02500         //
02501         if (speed > 5) EA_Move(ms->client, dir, speed);
02502         VectorCopy(dir, result.movedir);
02503         //
02504         if (ms->moveflags & MFL_SWIMMING) result.flags |= MOVERESULT_SWIMVIEW;
02505     } //end if
02506     else
02507     {
02508         MoverBottomCenter(reach, bottomcenter);
02509         VectorSubtract(bottomcenter, ms->origin, hordir);
02510         if (!(ms->moveflags & MFL_SWIMMING)) hordir[2] = 0;
02511         dist = VectorNormalize(hordir);
02512         //
02513         if (dist > 5)
02514         {
02515             //move to the center of the plat
02516             if (dist > 100) dist = 100;
02517             speed = 400 - (400 - 4 * dist);
02518             //
02519             EA_Move(ms->client, hordir, speed);
02520             VectorCopy(hordir, result.movedir);
02521         } //end if
02522     } //end else
02523     return result;
02524 } //end of the function BotFinishTravel_FuncBobbing

Here is the call graph for this function:

bot_moveresult_t BotFinishTravel_Jump