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

be_interface.c File Reference

#include "../game/q_shared.h"
#include "l_memory.h"
#include "l_log.h"
#include "l_libvar.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_aas_def.h"
#include "be_interface.h"
#include "../game/be_ea.h"
#include "be_ai_weight.h"
#include "../game/be_ai_goal.h"
#include "../game/be_ai_move.h"
#include "../game/be_ai_weap.h"
#include "../game/be_ai_chat.h"
#include "../game/be_ai_char.h"
#include "../game/be_ai_gen.h"

Include dependency graph for be_interface.c:

Include dependency graph

Go to the source code of this file.

Functions

void AAS_FloodAreas (vec3_t origin)
int AAS_PointLight (vec3_t origin, int *red, int *green, int *blue)
int AAS_Reachability_WeaponJump (int area1num, int area2num)
void AAS_TestMovementPrediction (int entnum, vec3_t origin, vec3_t dir)
int AAS_TraceAreas (vec3_t start, vec3_t end, int *areas, vec3_t *points, int maxareas)
int BotExportTest (int parm0, char *parm1, vec3_t parm2, vec3_t parm3)
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)
qboolean BotLibSetup (char *str)
void ElevatorBottomCenter (aas_reachability_t *reach, vec3_t bottomcenter)
int Export_BotLibLoadMap (const char *mapname)
int Export_BotLibSetup (void)
int Export_BotLibShutdown (void)
int Export_BotLibStartFrame (float time)
int Export_BotLibUpdateEntity (int ent, bot_entitystate_t *state)
int Export_BotLibVarGet (char *var_name, char *value, int size)
int Export_BotLibVarSet (char *var_name, char *value)
botlib_export_tGetBotLibAPI (int apiVersion, botlib_import_t *import)
void Init_AAS_Export (aas_export_t *aas)
void Init_AI_Export (ai_export_t *ai)
void Init_EA_Export (ea_export_t *ea)
int Sys_MilliSeconds (void)
qboolean ValidClientNumber (int num, char *str)
qboolean ValidEntityNumber (int num, char *str)

Variables

botlib_export_t be_botlib_export
int bot_developer
botlib_import_t botimport
botlib_globals_t botlibglobals
int botlibsetup = qfalse


Function Documentation

void AAS_FloodAreas vec3_t  origin  ) 
 

Definition at line 769 of file be_aas_debug.c.

References AAS_AreaCluster(), AAS_FloodAreas_r(), AAS_PointAreaNum(), aasworld, GetClearedMemory(), and aas_s::numareas.

Referenced by BotExportTest().

00770 {
00771     int areanum, cluster, *done;
00772 
00773     done = (int *) GetClearedMemory(aasworld.numareas * sizeof(int));
00774     areanum = AAS_PointAreaNum(origin);
00775     cluster = AAS_AreaCluster(areanum);
00776     AAS_FloodAreas_r(areanum, cluster, done);
00777 }

Here is the call graph for this function:

int AAS_PointLight vec3_t  origin,
int *  red,
int *  green,
int *  blue
 

int AAS_Reachability_WeaponJump int  area1num,
int  area2num
 

Definition at line 4006 of file be_aas_reach.c.

References AAS_AllocReachability(), aas_area_t, AAS_AreaGrounded(), AAS_AreaSwim(), AAS_BFGJumpZVelocity(), aas_clientmove_t, aas_face_t, AAS_FaceCenter(), AAS_HorizontalVelocityForJump(), aas_lreachability_t, AAS_PointAreaNum(), AAS_PredictClientMovement(), AAS_RocketJumpZVelocity(), aas_trace_t, AAS_TraceClientBBox(), aassettings, aasworld, abs(), aas_areasettings_s::areaflags, aas_lreachability_s::areanum, areareachability, aas_s::areas, aas_s::areasettings, aas_area_s::center, aas_lreachability_s::edgenum, aas_lreachability_s::end, aas_trace_s::endpos, f, aas_face_s::faceflags, aas_s::faceindex, aas_lreachability_s::facenum, aas_s::faces, aas_area_s::firstface, aas_clientmove_s::frames, i, Log_Write(), aas_area_s::maxs, aas_area_s::mins, move(), n, aas_lreachability_s::next, aas_area_s::numfaces, PRESENCE_CROUCH, PRESENCE_NORMAL, qtrue, reach_rocketjump, aas_settings_s::rs_bfgjump, aas_settings_s::rs_rocketjump, SE_ENTERLAVA, SE_ENTERSLIME, SE_ENTERWATER, SE_HITGROUND, SE_HITGROUNDAREA, SE_HITGROUNDDAMAGE, SE_TOUCHJUMPPAD, aas_lreachability_s::start, aas_trace_s::startsolid, aas_clientmove_s::stopevent, aas_lreachability_s::traveltime, aas_lreachability_s::traveltype, vec3_t, VectorCopy, VectorNormalize(), VectorScale, VectorSet, and VectorSubtract.

Referenced by AAS_ContinueInitReachability().

04007 {
04008     int face2num, i, n, ret, visualize;
04009     float speed, zvel, hordist;
04010     aas_face_t *face2;
04011     aas_area_t *area1, *area2;
04012     aas_lreachability_t *lreach;
04013     vec3_t areastart, facecenter, start, end, dir, cmdmove;// teststart;
04014     vec3_t velocity;
04015     aas_clientmove_t move;
04016     aas_trace_t trace;
04017 
04018     visualize = qfalse;
04019 //  if (area1num == 4436 && area2num == 4318)
04020 //  {
04021 //      visualize = qtrue;
04022 //  }
04023     if (!AAS_AreaGrounded(area1num) || AAS_AreaSwim(area1num)) return qfalse;
04024     if (!AAS_AreaGrounded(area2num)) return qfalse;
04025     //NOTE: only weapon jump towards areas with an interesting item in it??
04026     if (!(aasworld.areasettings[area2num].areaflags & AREA_WEAPONJUMP)) return qfalse;
04027     //
04028     area1 = &aasworld.areas[area1num];
04029     area2 = &aasworld.areas[area2num];
04030     //don't weapon jump towards way lower areas
04031     if (area2->maxs[2] < area1->mins[2]) return qfalse;
04032     //
04033     VectorCopy(aasworld.areas[area1num].center, start);
04034     //if not a swim area
04035     if (!AAS_PointAreaNum(start)) Log_Write("area %d center %f %f %f in solid?\r\n", area1num,
04036                             start[0], start[1], start[2]);
04037     VectorCopy(start, end);
04038     end[2] -= 1000;
04039     trace = AAS_TraceClientBBox(start, end, PRESENCE_CROUCH, -1);
04040     if (trace.startsolid) return qfalse;
04041     VectorCopy(trace.endpos, areastart);
04042     //
04043     //areastart is now the start point
04044     //
04045     for (i = 0; i < area2->numfaces; i++)
04046     {
04047         face2num = aasworld.faceindex[area2->firstface + i];
04048         face2 = &aasworld.faces[abs(face2num)];
04049         //if it is not a solid face
04050         if (!(face2->faceflags & FACE_GROUND)) continue;
04051         //get the center of the face
04052         AAS_FaceCenter(face2num, facecenter);
04053         //only go higher up with weapon jumps
04054         if (facecenter[2] < areastart[2] + 64) continue;
04055         //NOTE: set to 2 to allow bfg jump reachabilities
04056         for (n = 0; n < 1/*2*/; n++)
04057         {
04058             //get the rocket jump z velocity
04059             if (n) zvel = AAS_BFGJumpZVelocity(areastart);
04060             else zvel = AAS_RocketJumpZVelocity(areastart);
04061             //get the horizontal speed for the jump, if it isn't possible to calculate this
04062             //speed (the jump is not possible) then there's no jump reachability created
04063             ret = AAS_HorizontalVelocityForJump(zvel, areastart, facecenter, &speed);
04064             if (ret && speed < 300)
04065             {
04066                 //direction towards the face center
04067                 VectorSubtract(facecenter, areastart, dir);
04068                 dir[2] = 0;
04069                 hordist = VectorNormalize(dir);
04070                 //if (hordist < 1.6 * (facecenter[2] - areastart[2]))
04071                 {
04072                     //get command movement
04073                     VectorScale(dir, speed, cmdmove);
04074                     VectorSet(velocity, 0, 0, zvel);
04075                     /*
04076                     //get command movement
04077                     VectorScale(dir, speed, velocity);
04078                     velocity[2] = zvel;
04079                     VectorSet(cmdmove, 0, 0, 0);
04080                     */
04081                     //
04082                     AAS_PredictClientMovement(&move, -1, areastart, PRESENCE_NORMAL, qtrue,
04083                                                 velocity, cmdmove, 30, 30, 0.1f,
04084                                                 SE_ENTERWATER|SE_ENTERSLIME|
04085                                                 SE_ENTERLAVA|SE_HITGROUNDDAMAGE|
04086                                                 SE_TOUCHJUMPPAD|SE_HITGROUND|SE_HITGROUNDAREA, area2num, visualize);
04087                     //if prediction time wasn't enough to fully predict the movement
04088                     //don't enter slime or lava and don't fall from too high
04089                     if (move.frames < 30 && 
04090                             !(move.stopevent & (SE_ENTERSLIME|SE_ENTERLAVA|SE_HITGROUNDDAMAGE))
04091                                 && (move.stopevent & (SE_HITGROUNDAREA|SE_TOUCHJUMPPAD)))
04092                     {
04093                         //create a rocket or bfg jump reachability from area1 to area2
04094                         lreach = AAS_AllocReachability();
04095                         if (!lreach) return qfalse;
04096                         lreach->areanum = area2num;
04097                         lreach->facenum = 0;
04098                         lreach->edgenum = 0;
04099                         VectorCopy(areastart, lreach->start);
04100                         VectorCopy(facecenter, lreach->end);
04101                         if (n)
04102                         {
04103                             lreach->traveltype = TRAVEL_BFGJUMP;
04104                             lreach->traveltime = aassettings.rs_bfgjump;
04105                         } //end if
04106                         else
04107                         {
04108                             lreach->traveltype = TRAVEL_ROCKETJUMP;
04109                             lreach->traveltime = aassettings.rs_rocketjump;
04110                         } //end else
04111                         lreach->next = areareachability[area1num];
04112                         areareachability[area1num] = lreach;
04113                         //
04114                         reach_rocketjump++;
04115                         return qtrue;
04116                     } //end if
04117                 } //end if
04118             } //end if
04119         } //end for
04120     } //end for
04121     //
04122     return qfalse;
04123 } //end of the function AAS_Reachability_WeaponJump

Here is the call graph for this function:

void AAS_TestMovementPrediction int  entnum,
vec3_t  origin,
vec3_t  dir
 

Definition at line 1033 of file be_aas_move.c.

References AAS_ClearShownDebugLines(), aas_clientmove_t, AAS_PredictClientMovement(), AAS_Swimming(), botimport, f, move(), PRESENCE_NORMAL, PRT_MESSAGE, qtrue, SE_HITGROUND, aas_clientmove_s::stopevent, vec3_t, VectorClear, VectorNormalize(), and VectorScale.

01034 {
01035     vec3_t velocity, cmdmove;
01036     aas_clientmove_t move;
01037 
01038     VectorClear(velocity);
01039     if (!AAS_Swimming(origin)) dir[2] = 0;
01040     VectorNormalize(dir);
01041     VectorScale(dir, 400, cmdmove);
01042     cmdmove[2] = 224;
01043     AAS_ClearShownDebugLines();
01044     AAS_PredictClientMovement(&move, entnum, origin, PRESENCE_NORMAL, qtrue,
01045                                     velocity, cmdmove, 13, 13, 0.1f, SE_HITGROUND, 0, qtrue);//SE_LEAVEGROUND);
01046     if (move.stopevent & SE_LEAVEGROUND)
01047     {
01048         botimport.Print(PRT_MESSAGE, "leave ground\n");
01049     } //end if
01050 } //end of the function TestMovementPrediction

Here is the call graph for this function:

int AAS_TraceAreas vec3_t  start,
vec3_t  end,
int *  areas,
vec3_t points,
int  maxareas
 

Definition at line 726 of file be_aas_sample.c.

References aas_node_t, aas_plane_t, aas_tracestack_t, aasworld, botimport, aas_node_s::children, aas_plane_s::dist, DotProduct, aas_tracestack_s::end, aas_s::loaded, aas_tracestack_s::nodenum, aas_s::nodes, aas_plane_s::normal, numareas, aas_s::numareasettings, aas_s::numnodes, aas_node_s::planenum, aas_tracestack_s::planenum, aas_s::planes, points, PRT_ERROR, aas_tracestack_s::start, aas_plane_s::type, vec3_t, and VectorCopy.

Referenced by AAS_ClientMovementPrediction(), AAS_InitReachabilityAreas(), AAS_Reachability_FuncBobbing(), AAS_Reachability_Grapple(), AAS_Reachability_Jump(), AAS_Reachability_Step_Barrier_WaterJump_WalkOffLedge(), AAS_Reachability_WalkOffLedge(), BotFuzzyPointReachabilityArea(), and BotMoveToGoal().

00727 {
00728     int side, nodenum, tmpplanenum;
00729     int numareas;
00730     float front, back, frac;
00731     vec3_t cur_start, cur_end, cur_mid;
00732     aas_tracestack_t tracestack[127];
00733     aas_tracestack_t *tstack_p;
00734     aas_node_t *aasnode;
00735     aas_plane_t *plane;
00736 
00737     numareas = 0;
00738     areas[0] = 0;
00739     if (!aasworld.loaded) return numareas;
00740 
00741     tstack_p = tracestack;
00742     //we start with the whole line on the stack
00743     VectorCopy(start, tstack_p->start);
00744     VectorCopy(end, tstack_p->end);
00745     tstack_p->planenum = 0;
00746     //start with node 1 because node zero is a dummy for a solid leaf
00747     tstack_p->nodenum = 1;      //starting at the root of the tree
00748     tstack_p++;
00749 
00750     while (1)
00751     {
00752         //pop up the stack
00753         tstack_p--;
00754         //if the trace stack is empty (ended up with a piece of the
00755         //line to be traced in an area)
00756         if (tstack_p < tracestack)
00757         {
00758             return numareas;
00759         } //end if
00760         //number of the current node to test the line against
00761         nodenum = tstack_p->nodenum;
00762         //if it is an area
00763         if (nodenum < 0)
00764         {
00765 #ifdef AAS_SAMPLE_DEBUG
00766             if (-nodenum > aasworld.numareasettings)
00767             {
00768                 botimport.Print(PRT_ERROR, "AAS_TraceAreas: -nodenum = %d out of range\n", -nodenum);
00769                 return numareas;
00770             } //end if
00771 #endif //AAS_SAMPLE_DEBUG
00772             //botimport.Print(PRT_MESSAGE, "areanum = %d, must be %d\n", -nodenum, AAS_PointAreaNum(start));
00773             areas[numareas] = -nodenum;
00774             if (points) VectorCopy(tstack_p->start, points[numareas]);
00775             numareas++;
00776             if (numareas >= maxareas) return numareas;
00777             continue;
00778         } //end if
00779         //if it is a solid leaf
00780         if (!nodenum)
00781         {
00782             continue;
00783         } //end if
00784 #ifdef AAS_SAMPLE_DEBUG
00785         if (nodenum > aasworld.numnodes)
00786         {
00787             botimport.Print(PRT_ERROR, "AAS_TraceAreas: nodenum out of range\n");
00788             return numareas;
00789         } //end if
00790 #endif //AAS_SAMPLE_DEBUG
00791         //the node to test against
00792         aasnode = &aasworld.nodes[nodenum];
00793         //start point of current line to test against node
00794         VectorCopy(tstack_p->start, cur_start);
00795         //end point of the current line to test against node
00796         VectorCopy(tstack_p->end, cur_end);
00797         //the current node plane
00798         plane = &aasworld.planes[aasnode->planenum];
00799 
00800         switch(plane->type)
00801         {/*FIXME: wtf doesn't this work? obviously the node planes aren't always facing positive!!!
00802             //check for axial planes
00803             case PLANE_X:
00804             {
00805                 front = cur_start[0] - plane->dist;
00806                 back = cur_end[0] - plane->dist;
00807                 break;
00808             } //end case
00809             case PLANE_Y:
00810             {
00811                 front = cur_start[1] - plane->dist;
00812                 back = cur_end[1] - plane->dist;
00813                 break;
00814             } //end case
00815             case PLANE_Z:
00816             {
00817                 front = cur_start[2] - plane->dist;
00818                 back = cur_end[2] - plane->dist;
00819                 break;
00820             } //end case*/
00821             default: //gee it's not an axial plane
00822             {
00823                 front = DotProduct(cur_start, plane->normal) - plane->dist;
00824                 back = DotProduct(cur_end, plane->normal) - plane->dist;
00825                 break;
00826             } //end default
00827         } //end switch
00828 
00829         //if the whole to be traced line is totally at the front of this node
00830         //only go down the tree with the front child
00831         if (front > 0 && back > 0)
00832         {
00833             //keep the current start and end point on the stack
00834             //and go down the tree with the front child
00835             tstack_p->nodenum = aasnode->children[0];
00836             tstack_p++;
00837             if (tstack_p >= &tracestack[127])
00838             {
00839                 botimport.Print(PRT_ERROR, "AAS_TraceAreas: stack overflow\n");
00840                 return numareas;
00841             } //end if
00842         } //end if
00843         //if the whole to be traced line is totally at the back of this node
00844         //only go down the tree with the back child
00845         else if (front <= 0 && back <= 0)
00846         {
00847             //keep the current start and end point on the stack
00848             //and go down the tree with the back child
00849             tstack_p->nodenum = aasnode->children[1];
00850             tstack_p++;
00851             if (tstack_p >= &tracestack[127])
00852             {
00853                 botimport.Print(PRT_ERROR, "AAS_TraceAreas: stack overflow\n");
00854                 return numareas;
00855             } //end if
00856         } //end if
00857         //go down the tree both at the front and back of the node
00858         else
00859         {
00860             tmpplanenum = tstack_p->planenum;
00861             //calculate the hitpoint with the node (split point of the line)
00862             //put the crosspoint TRACEPLANE_EPSILON pixels on the near side
00863             if (front < 0) frac = (front)/(front-back);
00864             else frac = (front)/(front-back);
00865             if (frac < 0) frac = 0;
00866             else if (frac > 1) frac = 1;
00867             //frac = front / (front-back);
00868             //
00869             cur_mid[0] = cur_start[0] + (cur_end[0] - cur_start[0]) * frac;
00870             cur_mid[1] = cur_start[1] + (cur_end[1] - cur_start[1]) * frac;
00871             cur_mid[2] = cur_start[2] + (cur_end[2] - cur_start[2]) * frac;
00872 
00873 //          AAS_DrawPlaneCross(cur_mid, plane->normal, plane->dist, plane->type, LINECOLOR_RED);
00874             //side the front part of the line is on
00875             side = front < 0;
00876             //first put the end part of the line on the stack (back side)
00877             VectorCopy(cur_mid, tstack_p->start);
00878             //not necesary to store because still on stack
00879             //VectorCopy(cur_end, tstack_p->end);
00880             tstack_p->planenum = aasnode->planenum;
00881             tstack_p->nodenum = aasnode->children[!side];
00882             tstack_p++;
00883             if (tstack_p >= &tracestack[127])
00884             {
00885                 botimport.Print(PRT_ERROR, "AAS_TraceAreas: stack overflow\n");
00886                 return numareas;
00887             } //end if
00888             //now put the part near the start of the line on the stack so we will
00889             //continue with thats part first. This way we'll find the first
00890             //hit of the bbox
00891             VectorCopy(cur_start, tstack_p->start);
00892             VectorCopy(cur_mid, tstack_p->end);
00893             tstack_p->planenum = tmpplanenum;
00894             tstack_p->nodenum = aasnode->children[side];
00895             tstack_p++;
00896             if (tstack_p >= &tracestack[127])
00897             {
00898                 botimport.Print(PRT_ERROR, "AAS_TraceAreas: stack overflow\n");
00899                 return numareas;
00900             } //end if
00901         } //end else
00902     } //end while
00903 //  return numareas;
00904 } //end of the function AAS_TraceAreas

int BotExportTest int  parm0,
char *  parm1,
vec3_t  parm2,
vec3_t  parm3
 

Definition at line 318 of file be_interface.c.

References AAS_AreaCluster(), AAS_AreaTravelTimeToGoalArea(), AAS_ClearShownDebugLines(), AAS_ClearShownPolygons(), AAS_DrawPlaneCross(), AAS_FloodAreas(), AAS_PointPresenceType(), aas_reachability_t, AAS_ReachabilityFromNum(), AAS_ShowAreaPolygons(), AAS_ShowBoundingBox(), AAS_ShowFace(), AAS_ShowReachability(), AAS_ShowReachableAreas(), AAS_Trace(), AAS_TraceEndFace(), aasworld, AngleVectors(), aas_reachability_s::areanum, bot_goal_s::areanum, aas_s::areasettings, bot_goal_t, BotFuzzyPointReachabilityArea(), BotGetReachabilityToGoal(), botimport, botlibglobals, aas_areasettings_s::contents, botlib_import_s::DebugLineCreate, botlib_import_s::DebugLineShow, aas_reachability_s::end, aas_s::entities, aas_s::faces, i, LibVarGetValue(), line, LINECOLOR_BLUE, LINECOLOR_GREEN, LINECOLOR_RED, LINECOLOR_YELLOW, aas_s::loaded, MASK_PLAYERSOLID, NULL, bot_goal_s::origin, PRT_MESSAGE, right, TFL_DEFAULT, TFL_FUNCBOB, TFL_ROCKETJUMP, vec3_t, VectorClear, VectorCopy, and VectorMA.

00319 {
00320 
00321 //  return AAS_PointLight(parm2, NULL, NULL, NULL);
00322 
00323 #ifdef DEBUG
00324     static int area = -1;
00325     static int line[2];
00326     int newarea, i, highlightarea, flood;
00327 //  int reachnum;
00328     vec3_t eye, forward, right, end, origin;
00329 //  vec3_t bottomcenter;
00330 //  aas_trace_t trace;
00331 //  aas_face_t *face;
00332 //  aas_entity_t *ent;
00333 //  bsp_trace_t bsptrace;
00334 //  aas_reachability_t reach;
00335 //  bot_goal_t goal;
00336 
00337     // clock_t start_time, end_time;
00338     vec3_t mins = {-16, -16, -24};
00339     vec3_t maxs = {16, 16, 32};
00340 
00341 //  int areas[10], numareas;
00342 
00343 
00344     //return 0;
00345 
00346     if (!aasworld.loaded) return 0;
00347 
00348     /*
00349     if (parm0 & 1)
00350     {
00351         AAS_ClearShownPolygons();
00352         AAS_FloodAreas(parm2);
00353     } //end if
00354     return 0;
00355     */
00356     for (i = 0; i < 2; i++) if (!line[i]) line[i] = botimport.DebugLineCreate();
00357 
00358 //  AAS_ClearShownDebugLines();
00359 
00360     //if (AAS_AgainstLadder(parm2)) botimport.Print(PRT_MESSAGE, "against ladder\n");
00361     //BotOnGround(parm2, PRESENCE_NORMAL, 1, &newarea, &newarea);
00362     //botimport.Print(PRT_MESSAGE, "%f %f %f\n", parm2[0], parm2[1], parm2[2]);
00363     //*
00364     highlightarea = LibVarGetValue("bot_highlightarea");
00365     if (highlightarea > 0)
00366     {
00367         newarea = highlightarea;
00368     } //end if
00369     else
00370     {
00371         VectorCopy(parm2, origin);
00372         origin[2] += 0.5;
00373         //newarea = AAS_PointAreaNum(origin);
00374         newarea = BotFuzzyPointReachabilityArea(origin);
00375     } //end else
00376 
00377     botimport.Print(PRT_MESSAGE, "\rtravel time to goal (%d) = %d  ", botlibglobals.goalareanum,
00378         AAS_AreaTravelTimeToGoalArea(newarea, origin, botlibglobals.goalareanum, TFL_DEFAULT));
00379     //newarea = BotReachabilityArea(origin, qtrue);
00380     if (newarea != area)
00381     {
00382         botimport.Print(PRT_MESSAGE, "origin = %f, %f, %f\n", origin[0], origin[1], origin[2]);
00383         area = newarea;
00384         botimport.Print(PRT_MESSAGE, "new area %d, cluster %d, presence type %d\n",
00385                     area, AAS_AreaCluster(area), AAS_PointPresenceType(origin));
00386         botimport.Print(PRT_MESSAGE, "area contents: ");
00387         if (aasworld.areasettings[area].contents & AREACONTENTS_WATER)
00388         {
00389             botimport.Print(PRT_MESSAGE, "water &");
00390         } //end if
00391         if (aasworld.areasettings[area].contents & AREACONTENTS_LAVA)
00392         {
00393             botimport.Print(PRT_MESSAGE, "lava &");
00394         } //end if
00395         if (aasworld.areasettings[area].contents & AREACONTENTS_SLIME)
00396         {
00397             botimport.Print(PRT_MESSAGE, "slime &");
00398         } //end if
00399         if (aasworld.areasettings[area].contents & AREACONTENTS_JUMPPAD)
00400         {
00401             botimport.Print(PRT_MESSAGE, "jump pad &");
00402         } //end if
00403         if (aasworld.areasettings[area].contents & AREACONTENTS_CLUSTERPORTAL)
00404         {
00405             botimport.Print(PRT_MESSAGE, "cluster portal &");
00406         } //end if
00407         if (aasworld.areasettings[area].contents & AREACONTENTS_VIEWPORTAL)
00408         {
00409             botimport.Print(PRT_MESSAGE, "view portal &");
00410         } //end if
00411         if (aasworld.areasettings[area].contents & AREACONTENTS_DONOTENTER)
00412         {
00413             botimport.Print(PRT_MESSAGE, "do not enter &");
00414         } //end if
00415         if (aasworld.areasettings[area].contents & AREACONTENTS_MOVER)
00416         {
00417             botimport.Print(PRT_MESSAGE, "mover &");
00418         } //end if
00419         if (!aasworld.areasettings[area].contents)
00420         {
00421             botimport.Print(PRT_MESSAGE, "empty");
00422         } //end if
00423         botimport.Print(PRT_MESSAGE, "\n");
00424         botimport.Print(PRT_MESSAGE, "travel time to goal (%d) = %d\n", botlibglobals.goalareanum,
00425                     AAS_AreaTravelTimeToGoalArea(newarea, origin, botlibglobals.goalareanum, TFL_DEFAULT|TFL_ROCKETJUMP));
00426         /*
00427         VectorCopy(origin, end);
00428         end[2] += 5;
00429         numareas = AAS_TraceAreas(origin, end, areas, NULL, 10);
00430         AAS_TraceClientBBox(origin, end, PRESENCE_CROUCH, -1);
00431         botimport.Print(PRT_MESSAGE, "num areas = %d, area = %d\n", numareas, areas[0]);
00432         */
00433         /*
00434         botlibglobals.goalareanum = newarea;
00435         VectorCopy(parm2, botlibglobals.goalorigin);
00436         botimport.Print(PRT_MESSAGE, "new goal %2.1f %2.1f %2.1f area %d\n",
00437                                 origin[0], origin[1], origin[2], newarea);
00438         */
00439     } //end if
00440     //*
00441     flood = LibVarGetValue("bot_flood");
00442     if (parm0 & 1)
00443     {
00444         if (flood)
00445         {
00446             AAS_ClearShownPolygons();
00447             AAS_ClearShownDebugLines();
00448             AAS_FloodAreas(parm2);
00449         }
00450         else
00451         {
00452             botlibglobals.goalareanum = newarea;
00453             VectorCopy(parm2, botlibglobals.goalorigin);
00454             botimport.Print(PRT_MESSAGE, "new goal %2.1f %2.1f %2.1f area %d\n",
00455                                     origin[0], origin[1], origin[2], newarea);
00456         }
00457     } //end if*/
00458     if (flood)
00459         return 0;
00460 //  if (parm0 & BUTTON_USE)
00461 //  {
00462 //      botlibglobals.runai = !botlibglobals.runai;
00463 //      if (botlibglobals.runai) botimport.Print(PRT_MESSAGE, "started AI\n");
00464 //      else botimport.Print(PRT_MESSAGE, "stopped AI\n");
00465         //* /
00466         /*
00467         goal.areanum = botlibglobals.goalareanum;
00468         reachnum = BotGetReachabilityToGoal(parm2, newarea, 1,
00469                                         ms.avoidreach, ms.avoidreachtimes,
00470                                         &goal, TFL_DEFAULT);
00471         if (!reachnum)
00472         {
00473             botimport.Print(PRT_MESSAGE, "goal not reachable\n");
00474         } //end if
00475         else
00476         {
00477             AAS_ReachabilityFromNum(reachnum, &reach);
00478             AAS_ClearShownDebugLines();
00479             AAS_ShowArea(area, qtrue);
00480             AAS_ShowArea(reach.areanum, qtrue);
00481             AAS_DrawCross(reach.start, 6, LINECOLOR_BLUE);
00482             AAS_DrawCross(reach.end, 6, LINECOLOR_RED);
00483             //
00484             if ((reach.traveltype & TRAVELTYPE_MASK) == TRAVEL_ELEVATOR)
00485             {
00486                 ElevatorBottomCenter(&reach, bottomcenter);
00487                 AAS_DrawCross(bottomcenter, 10, LINECOLOR_GREEN);
00488             } //end if
00489         } //end else*/
00490 //      botimport.Print(PRT_MESSAGE, "travel time to goal = %d\n",
00491 //                  AAS_AreaTravelTimeToGoalArea(area, origin, botlibglobals.goalareanum, TFL_DEFAULT));
00492 //      botimport.Print(PRT_MESSAGE, "test rj from 703 to 716\n");
00493 //      AAS_Reachability_WeaponJump(703, 716);
00494 //  } //end if*/
00495 
00496 /*  face = AAS_AreaGroundFace(newarea, parm2);
00497     if (face)
00498     {
00499         AAS_ShowFace(face - aasworld.faces);
00500     } //end if*/
00501     /*
00502     AAS_ClearShownDebugLines();
00503     AAS_ShowArea(newarea, parm0 & BUTTON_USE);
00504     AAS_ShowReachableAreas(area);
00505     */
00506     AAS_ClearShownPolygons();
00507     AAS_ClearShownDebugLines();
00508     AAS_ShowAreaPolygons(newarea, 1, parm0 & 4);
00509     if (parm0 & 2) AAS_ShowReachableAreas(area);
00510     else
00511     {
00512         static int lastgoalareanum, lastareanum;
00513         static int avoidreach[MAX_AVOIDREACH];
00514         static float avoidreachtimes[MAX_AVOIDREACH];
00515         static int avoidreachtries[MAX_AVOIDREACH];
00516         int reachnum, resultFlags;
00517         bot_goal_t goal;
00518         aas_reachability_t reach;
00519 
00520         /*
00521         goal.areanum = botlibglobals.goalareanum;
00522         VectorCopy(botlibglobals.goalorigin, goal.origin);
00523         reachnum = BotGetReachabilityToGoal(origin, newarea,
00524                                       lastgoalareanum, lastareanum,
00525                                       avoidreach, avoidreachtimes, avoidreachtries,
00526                                       &goal, TFL_DEFAULT|TFL_FUNCBOB|TFL_ROCKETJUMP, TFL_DEFAULT|TFL_FUNCBOB|TFL_ROCKETJUMP,
00527                                       NULL, 0, &resultFlags);
00528         AAS_ReachabilityFromNum(reachnum, &reach);
00529         AAS_ShowReachability(&reach);
00530         */
00531         int curarea;
00532         vec3_t curorigin;
00533 
00534         goal.areanum = botlibglobals.goalareanum;
00535         VectorCopy(botlibglobals.goalorigin, goal.origin);
00536         VectorCopy(origin, curorigin);
00537         curarea = newarea;
00538         for ( i = 0; i < 100; i++ ) {
00539             if ( curarea == goal.areanum ) {
00540                 break;
00541             }
00542             reachnum = BotGetReachabilityToGoal(curorigin, curarea,
00543                                           lastgoalareanum, lastareanum,
00544                                           avoidreach, avoidreachtimes, avoidreachtries,
00545                                           &goal, TFL_DEFAULT|TFL_FUNCBOB|TFL_ROCKETJUMP, TFL_DEFAULT|TFL_FUNCBOB|TFL_ROCKETJUMP,
00546                                           NULL, 0, &resultFlags);
00547             AAS_ReachabilityFromNum(reachnum, &reach);
00548             AAS_ShowReachability(&reach);
00549             VectorCopy(reach.end, origin);
00550             lastareanum = curarea;
00551             curarea = reach.areanum;
00552         }
00553     } //end else
00554     VectorClear(forward);
00555     //BotGapDistance(origin, forward, 0);
00556     /*
00557     if (parm0 & BUTTON_USE)
00558     {
00559         botimport.Print(PRT_MESSAGE, "test rj from 703 to 716\n");
00560         AAS_Reachability_WeaponJump(703, 716);
00561     } //end if*/
00562 
00563     AngleVectors(parm3, forward, right, NULL);
00564     //get the eye 16 units to the right of the origin
00565     VectorMA(parm2, 8, right, eye);
00566     //get the eye 24 units up
00567     eye[2] += 24;
00568     //get the end point for the line to be traced
00569     VectorMA(eye, 800, forward, end);
00570 
00571 //  AAS_TestMovementPrediction(1, parm2, forward);
00572 /*
00573     //trace the line to find the hit point
00574     trace = AAS_TraceClientBBox(eye, end, PRESENCE_NORMAL, 1);
00575     if (!line[0]) line[0] = botimport.DebugLineCreate();
00576     botimport.DebugLineShow(line[0], eye, trace.endpos, LINECOLOR_BLUE);
00577     //
00578     AAS_ClearShownDebugLines();
00579     if (trace.ent)
00580     {
00581         ent = &aasworld.entities[trace.ent];
00582         AAS_ShowBoundingBox(ent->origin, ent->mins, ent->maxs);
00583     } //end if
00584 */
00585 
00586 /*
00587     start_time = clock();
00588     for (i = 0; i < 2000; i++)
00589     {
00590         AAS_Trace2(eye, mins, maxs, end, 1, MASK_PLAYERSOLID);
00591 //      AAS_TraceClientBBox(eye, end, PRESENCE_NORMAL, 1);
00592     } //end for
00593     end_time = clock();
00594     botimport.Print(PRT_MESSAGE, "me %lu clocks, %lu CLOCKS_PER_SEC\n", end_time - start_time, CLOCKS_PER_SEC);
00595     start_time = clock();
00596     for (i = 0; i < 2000; i++)
00597     {
00598         AAS_Trace(eye, mins, maxs, end, 1, MASK_PLAYERSOLID);
00599     } //end for
00600     end_time = clock();
00601     botimport.Print(PRT_MESSAGE, "id %lu clocks, %lu CLOCKS_PER_SEC\n", end_time - start_time, CLOCKS_PER_SEC);
00602 */
00603 
00604     // TTimo: nested comments are BAD for gcc -Werror, use #if 0 instead..
00605 #if 0
00606     AAS_ClearShownDebugLines();
00607     //bsptrace = AAS_Trace(eye, NULL, NULL, end, 1, MASK_PLAYERSOLID);
00608     bsptrace = AAS_Trace(eye, mins, maxs, end, 1, MASK_PLAYERSOLID);
00609     if (!line[0]) line[0] = botimport.DebugLineCreate();
00610     botimport.DebugLineShow(line[0], eye, bsptrace.endpos, LINECOLOR_YELLOW);
00611     if (bsptrace.fraction < 1.0)
00612     {
00613         face = AAS_TraceEndFace(&trace);
00614         if (face)
00615         {
00616             AAS_ShowFace(face - aasworld.faces);
00617         } //end if
00618         
00619         AAS_DrawPlaneCross(bsptrace.endpos,
00620                                     bsptrace.plane.normal,
00621                                     bsptrace.plane.dist + bsptrace.exp_dist,
00622                                     bsptrace.plane.type, LINECOLOR_GREEN);
00623         if (trace.ent)
00624         {
00625             ent = &aasworld.entities[trace.ent];
00626             AAS_ShowBoundingBox(ent->origin, ent->mins, ent->maxs);
00627         } //end if
00628     } //end if
00629     //bsptrace = AAS_Trace2(eye, NULL, NULL, end, 1, MASK_PLAYERSOLID);
00630     bsptrace = AAS_Trace2(eye, mins, maxs, end, 1, MASK_PLAYERSOLID);
00631     botimport.DebugLineShow(line[1], eye, bsptrace.endpos, LINECOLOR_BLUE);
00632     if (bsptrace.fraction < 1.0)
00633     {
00634         AAS_DrawPlaneCross(bsptrace.endpos,
00635                                     bsptrace.plane.normal,
00636                                     bsptrace.plane.dist,// + bsptrace.exp_dist,
00637                                     bsptrace.plane.type, LINECOLOR_RED);
00638         if (bsptrace.ent)
00639         {
00640             ent = &aasworld.entities[bsptrace.ent];
00641             AAS_ShowBoundingBox(ent->origin, ent->mins, ent->maxs);
00642         } //end if
00643     } //end if
00644 #endif
00645 #endif
00646     return 0;
00647 } //end of the function BotExportTest

Here is the call graph for this function:

int BotFuzzyPointReachabilityArea vec3_t  origin  ) 
 

Definition at line 241 of file be_ai_move.c.

References AAS_AreaReachability(), AAS_PointAreaNum(), AAS_TraceAreas(), j, numareas, points, v, vec3_t, VectorCopy, VectorLength(), VectorSubtract, x, y, and z.

Referenced by BotExportTest(), BotMoveToGoal(), and BotReachabilityArea().

00242 {
00243     int firstareanum, j, x, y, z;
00244     int areas[10], numareas, areanum, bestareanum;
00245     float dist, bestdist;
00246     vec3_t points[10], v, end;
00247 
00248     firstareanum = 0;
00249     areanum = AAS_PointAreaNum(origin);
00250     if (areanum)
00251     {
00252         firstareanum = areanum;
00253         if (AAS_AreaReachability(areanum)) return areanum;
00254     } //end if
00255     VectorCopy(origin, end);
00256     end[2] += 4;
00257     numareas = AAS_TraceAreas(origin, end, areas, points, 10);
00258     for (j = 0; j < numareas; j++)
00259     {
00260         if (AAS_AreaReachability(areas[j])) return areas[j];
00261     } //end for
00262     bestdist = 999999;
00263     bestareanum = 0;
00264     for (z = 1; z >= -1; z -= 1)
00265     {
00266         for (x = 1; x >= -1; x -= 1)
00267         {
00268             for (y = 1; y >= -1; y -= 1)
00269             {
00270                 VectorCopy(origin, end);
00271                 end[0] += x * 8;
00272                 end[1] += y * 8;
00273                 end[2] += z * 12;
00274                 numareas = AAS_TraceAreas(origin, end, areas, points, 10);
00275                 for (j = 0; j < numareas; j++)
00276                 {
00277                     if (AAS_AreaReachability(areas[j]))
00278                     {
00279                         VectorSubtract(points[j], origin, v);
00280                         dist = VectorLength(v);
00281                         if (dist < bestdist)
00282                         {
00283                             bestareanum = areas[j];
00284                             bestdist = dist;
00285                         } //end if
00286                     } //end if
00287                     if (!firstareanum) firstareanum = areas[j];
00288                 } //end for
00289             } //end for
00290         } //end for
00291         if (bestareanum) return bestareanum;
00292     } //end for
00293     return firstareanum;
00294 } //end of the function BotFuzzyPointReachabilityArea

Here is the call graph for this function:

float BotGapDistance vec3_t  origin,
vec3_t  hordir,
int  entnum
 

Definition at line 1000 of file be_ai_move.c.

References AAS_PointContents(), aas_trace_t, AAS_TraceClientBBox(), aas_trace_s::endpos, aas_trace_s::fraction, PRESENCE_CROUCH, aas_trace_s::startsolid, sv_maxbarrier, sv_maxstep, libvar_s::value, vec3_t, VectorCopy, and VectorMA.

Referenced by BotTravel_Walk(), and BotWalkInDirection().

01001 {
01002     float dist, startz;
01003     vec3_t start, end;
01004     aas_trace_t trace;
01005 
01006     //do gap checking
01007     startz = origin[2];
01008     //this enables walking down stairs more fluidly
01009     {
01010         VectorCopy(origin, start);
01011         VectorCopy(origin, end);
01012         end[2] -= 60;
01013         trace = AAS_TraceClientBBox(start, end, PRESENCE_CROUCH, entnum);
01014         if (trace.fraction >= 1) return 1;
01015         startz = trace.endpos[2] + 1;
01016     }
01017     //
01018     for (dist = 8; dist <= 100; dist += 8)
01019     {
01020         VectorMA(origin, dist, hordir, start);
01021         start[2] = startz + 24;
01022         VectorCopy(start, end);
01023         end[2] -= 48 + sv_maxbarrier->value;
01024         trace = AAS_TraceClientBBox(start, end, PRESENCE_CROUCH, entnum);
01025         //if solid is found the bot can't walk any further and fall into a gap
01026         if (!trace.startsolid)
01027         {
01028             //if it is a gap
01029             if (trace.endpos[2] < startz - sv_maxstep->value - 8)
01030             {
01031                 VectorCopy(trace.endpos, end);
01032                 end[2] -= 20;
01033                 if (AAS_PointContents(end) & CONTENTS_WATER) break;
01034                 //if a gap is found slow down
01035                 //botimport.Print(PRT_MESSAGE, "gap at %f\n", dist);
01036                 return dist;
01037             } //end if
01038             startz = trace.endpos[2];
01039         } //end if
01040     } //end for
01041     return 0;
01042 } //end of the function BotGapDistance

Here is the call graph for this function:

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
 

Definition at line 744 of file be_ai_move.c.

References AAS_AreaDoNotEnter(), AAS_AreaTravelTimeToGoalArea(), AAS_NextAreaReachability(), aas_reachability_t, AAS_ReachabilityFromNum(), AAS_Time(), aas_reachability_s::areanum, bot_goal_s::areanum, bot_goal_t, BotAvoidSpots(), botimport, BotValidTravel(), aas_reachability_s::end, i, MAX_AVOIDREACH, PRT_MESSAGE, t, and aas_reachability_s::traveltime.

Referenced by BotExportTest(), BotMovementViewTarget(), BotMoveToGoal(), and BotPredictVisiblePosition().

00749 {
00750     int i, t, besttime, bestreachnum, reachnum;
00751     aas_reachability_t reach;
00752 
00753     //if not in a valid area
00754     if (!areanum) return 0;
00755     //
00756     if (AAS_AreaDoNotEnter(areanum) || AAS_AreaDoNotEnter(goal->areanum))
00757     {
00758         travelflags |= TFL_DONOTENTER;
00759         movetravelflags |= TFL_DONOTENTER;
00760     } //end if
00761     //use the routing to find the next area to go to
00762     besttime = 0;
00763     bestreachnum = 0;
00764     //
00765     for (reachnum = AAS_NextAreaReachability(areanum, 0); reachnum;
00766         reachnum = AAS_NextAreaReachability(areanum, reachnum))
00767     {
00768 #ifdef AVOIDREACH
00769         //check if it isn't an reachability to avoid
00770         for (i = 0; i < MAX_AVOIDREACH; i++)
00771         {
00772             if (avoidreach[i] == reachnum && avoidreachtimes[i] >= AAS_Time()) break;
00773         } //end for
00774         if (i != MAX_AVOIDREACH && avoidreachtries[i] > AVOIDREACH_TRIES)
00775         {
00776 #ifdef DEBUG
00777             if (bot_developer)
00778             {
00779                 botimport.Print(PRT_MESSAGE, "avoiding reachability %d\n", avoidreach[i]);
00780             } //end if
00781 #endif //DEBUG
00782             continue;
00783         } //end if
00784 #endif //AVOIDREACH
00785         //get the reachability from the number
00786         AAS_ReachabilityFromNum(reachnum, &reach);
00787         //NOTE: do not go back to the previous area if the goal didn't change
00788         //NOTE: is this actually avoidance of local routing minima between two areas???
00789         if (lastgoalareanum == goal->areanum && reach.areanum == lastareanum) continue;
00790         //if (AAS_AreaContentsTravelFlags(reach.areanum) & ~travelflags) continue;
00791         //if the travel isn't valid
00792         if (!BotValidTravel(origin, &reach, movetravelflags)) continue;
00793         //get the travel time
00794         t = AAS_AreaTravelTimeToGoalArea(reach.areanum, reach.end, goal->areanum, travelflags);
00795         //if the goal area isn't reachable from the reachable area
00796         if (!t) continue;
00797         //if the bot should not use this reachability to avoid bad spots
00798         if (BotAvoidSpots(origin, &reach, avoidspots, numavoidspots)) {
00799             if (flags) {
00800                 *flags |= MOVERESULT_BLOCKEDBYAVOIDSPOT;
00801             }
00802             continue;
00803         }
00804         //add the travel time towards the area
00805         t += reach.traveltime;// + AAS_AreaTravelTime(areanum, origin, reach.start);
00806         //if the travel time is better than the ones already found
00807         if (!besttime || t < besttime)
00808         {
00809             besttime = t;
00810             bestreachnum = reachnum;
00811         } //end if
00812     } //end for
00813     //
00814     return bestreachnum;
00815 } //end of the function BotGetReachabilityToGoal

Here is the call graph for this function: