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

be_aas_route.h File Reference

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Functions

int AAS_AreaContentsTravelFlags (int areanum)
unsigned short int AAS_AreaTravelTime (int areanum, vec3_t start, vec3_t end)
int AAS_AreaTravelTimeToGoalArea (int areanum, vec3_t origin, int goalareanum, int travelflags)
int AAS_EnableRoutingArea (int areanum, int enable)
int AAS_NextAreaReachability (int areanum, int reachnum)
int AAS_PredictRoute (struct aas_predictroute_s *route, int areanum, vec3_t origin, int goalareanum, int travelflags, int maxareas, int maxtime, int stopevent, int stopcontents, int stoptfl, int stopareanum)
int AAS_RandomGoalArea (int areanum, int travelflags, int *goalareanum, vec3_t goalorigin)
void AAS_ReachabilityFromNum (int num, struct aas_reachability_s *reach)
int AAS_TravelFlagForType (int traveltype)


Function Documentation

int AAS_AreaContentsTravelFlags int  areanum  ) 
 

Definition at line 392 of file be_aas_route.c.

References aasworld, and aas_s::areacontentstravelflags.

Referenced by BotValidTravel().

00393 {
00394     return aasworld.areacontentstravelflags[areanum];
00395 } //end of the function AAS_AreaContentsTravelFlags

unsigned short int AAS_AreaTravelTime int  areanum,
vec3_t  start,
vec3_t  end
 

Definition at line 474 of file be_aas_route.c.

References AAS_AreaCrouch(), AAS_AreaSwim(), vec3_t, VectorLength(), and VectorSubtract.

Referenced by AAS_AreaRouteToGoalArea(), AAS_CalculateAreaTravelTimes(), AAS_NearestHideArea(), and AAS_PredictRoute().

00475 {
00476     int intdist;
00477     float dist;
00478     vec3_t dir;
00479 
00480     VectorSubtract(start, end, dir);
00481     dist = VectorLength(dir);
00482     //if crouch only area
00483     if (AAS_AreaCrouch(areanum)) dist *= DISTANCEFACTOR_CROUCH;
00484     //if swim area
00485     else if (AAS_AreaSwim(areanum)) dist *= DISTANCEFACTOR_SWIM;
00486     //normal walk area
00487     else dist *= DISTANCEFACTOR_WALK;
00488     //
00489     intdist = (int) dist;
00490     //make sure the distance isn't zero
00491     if (intdist <= 0) intdist = 1;
00492     return intdist;
00493 } //end of the function AAS_AreaTravelTime

Here is the call graph for this function:

int AAS_AreaTravelTimeToGoalArea int  areanum,
vec3_t  origin,
int  goalareanum,
int  travelflags
 

Definition at line 1767 of file be_aas_route.c.

References AAS_AreaRouteToGoalArea().

Referenced by AAS_AlternativeRouteGoals(), AAS_CreateAllRoutingCache(), AAS_RandomGoalArea(), BotChooseLTGItem(), BotChooseNBGItem(), BotExportTest(), and BotGetReachabilityToGoal().

01768 {
01769     int traveltime, reachnum;
01770 
01771     if (AAS_AreaRouteToGoalArea(areanum, origin, goalareanum, travelflags, &traveltime, &reachnum))
01772     {
01773         return traveltime;
01774     }
01775     return 0;
01776 } //end of the function AAS_AreaTravelTimeToGoalArea

Here is the call graph for this function:

int AAS_EnableRoutingArea int  areanum,
int  enable
 

Definition at line 308 of file be_aas_route.c.

References AAS_RemoveRoutingCacheUsingArea(), aasworld, aas_areasettings_s::areaflags, aas_s::areasettings, botimport, aas_s::numareas, and PRT_ERROR.

00309 {
00310     int flags;
00311 
00312     if (areanum <= 0 || areanum >= aasworld.numareas)
00313     {
00314         if (bot_developer)
00315         {
00316             botimport.Print(PRT_ERROR, "AAS_EnableRoutingArea: areanum %d out of range\n", areanum);
00317         } //end if
00318         return 0;
00319     } //end if
00320     flags = aasworld.areasettings[areanum].areaflags & AREA_DISABLED;
00321     if (enable < 0)
00322         return !flags;
00323 
00324     if (enable)
00325         aasworld.areasettings[areanum].areaflags &= ~AREA_DISABLED;
00326     else
00327         aasworld.areasettings[areanum].areaflags |= AREA_DISABLED;
00328     // if the status of the area changed
00329     if ( (flags & AREA_DISABLED) != (aasworld.areasettings[areanum].areaflags & AREA_DISABLED) )
00330     {
00331         //remove all routing cache involving this area
00332         AAS_RemoveRoutingCacheUsingArea( areanum );
00333     } //end if
00334     return !flags;
00335 } //end of the function AAS_EnableRoutingArea

Here is the call graph for this function:

int AAS_NextAreaReachability int  areanum,
int  reachnum
 

Definition at line 1939 of file be_aas_route.c.

References aas_areasettings_t, aasworld, aas_s::areasettings, botimport, aas_areasettings_s::firstreachablearea, aas_s::initialized, aas_s::numareas, aas_areasettings_s::numreachableareas, PRT_ERROR, and PRT_FATAL.

Referenced by BotGetReachabilityToGoal(), and BotMoveToGoal().

01940 {
01941     aas_areasettings_t *settings;
01942 
01943     if (!aasworld.initialized) return 0;
01944 
01945     if (areanum <= 0 || areanum >= aasworld.numareas)
01946     {
01947         botimport.Print(PRT_ERROR, "AAS_NextAreaReachability: areanum %d out of range\n", areanum);
01948         return 0;
01949     } //end if
01950 
01951     settings = &aasworld.areasettings[areanum];
01952     if (!reachnum)
01953     {
01954         return settings->firstreachablearea;
01955     } //end if
01956     if (reachnum < settings->firstreachablearea)
01957     {
01958         botimport.Print(PRT_FATAL, "AAS_NextAreaReachability: reachnum < settings->firstreachableara");
01959         return 0;
01960     } //end if
01961     reachnum++;
01962     if (reachnum >= settings->firstreachablearea + settings->numreachableareas)
01963     {
01964         return 0;
01965     } //end if
01966     return reachnum;
01967 } //end of the function AAS_NextAreaReachability

int AAS_PredictRoute struct aas_predictroute_s route,
int  areanum,
vec3_t  origin,
int  goalareanum,
int  travelflags,
int  maxareas,
int  maxtime,
int  stopevent,
int  stopcontents,
int  stoptfl,
int  stopareanum
 

Definition at line 1800 of file be_aas_route.c.

References AAS_AreaContentsTravelFlags_inline(), AAS_AreaReachabilityToGoalArea(), AAS_AreaTravelTime(), aas_reachability_t, aas_reachabilityareas_t, AAS_TravelFlagForType_inline(), aasworld, aas_reachability_s::areanum, aas_s::areasettings, aas_areasettings_s::contents, aas_reachability_s::end, aas_predictroute_s::endarea, aas_predictroute_s::endcontents, aas_predictroute_s::endpos, aas_predictroute_s::endtravelflags, aas_reachabilityareas_s::firstarea, i, j, aas_reachabilityareas_s::numareas, aas_s::numareas, aas_s::reachability, aas_s::reachabilityareaindex, aas_s::reachabilityareas, aas_reachability_s::start, aas_predictroute_s::stopevent, aas_predictroute_s::time, aas_reachability_s::traveltime, aas_reachability_s::traveltype, vec3_t, and VectorCopy.

01803 {
01804     int curareanum, reachnum, i, j, testareanum;
01805     vec3_t curorigin;
01806     aas_reachability_t *reach;
01807     aas_reachabilityareas_t *reachareas;
01808 
01809     //init output
01810     route->stopevent = RSE_NONE;
01811     route->endarea = goalareanum;
01812     route->endcontents = 0;
01813     route->endtravelflags = 0;
01814     VectorCopy(origin, route->endpos);
01815     route->time = 0;
01816 
01817     curareanum = areanum;
01818     VectorCopy(origin, curorigin);
01819 
01820     for (i = 0; curareanum != goalareanum && (!maxareas || i < maxareas) && i < aasworld.numareas; i++)
01821     {
01822         reachnum = AAS_AreaReachabilityToGoalArea(curareanum, curorigin, goalareanum, travelflags);
01823         if (!reachnum)
01824         {
01825             route->stopevent = RSE_NOROUTE;
01826             return qfalse;
01827         } //end if
01828         reach = &aasworld.reachability[reachnum];
01829         //
01830         if (stopevent & RSE_USETRAVELTYPE)
01831         {
01832             if (AAS_TravelFlagForType_inline(reach->traveltype) & stoptfl)
01833             {
01834                 route->stopevent = RSE_USETRAVELTYPE;
01835                 route->endarea = curareanum;
01836                 route->endcontents = aasworld.areasettings[curareanum].contents;
01837                 route->endtravelflags = AAS_TravelFlagForType_inline(reach->traveltype);
01838                 VectorCopy(reach->start, route->endpos);
01839                 return qtrue;
01840             } //end if
01841             if (AAS_AreaContentsTravelFlags_inline(reach->areanum) & stoptfl)
01842             {
01843                 route->stopevent = RSE_USETRAVELTYPE;
01844                 route->endarea = reach->areanum;
01845                 route->endcontents = aasworld.areasettings[reach->areanum].contents;
01846                 route->endtravelflags = AAS_AreaContentsTravelFlags_inline(reach->areanum);
01847                 VectorCopy(reach->end, route->endpos);
01848                 route->time += AAS_AreaTravelTime(areanum, origin, reach->start);
01849                 route->time += reach->traveltime;
01850                 return qtrue;
01851             } //end if
01852         } //end if
01853         reachareas = &aasworld.reachabilityareas[reachnum];
01854         for (j = 0; j < reachareas->numareas + 1; j++)
01855         {
01856             if (j >= reachareas->numareas)
01857                 testareanum = reach->areanum;
01858             else
01859                 testareanum = aasworld.reachabilityareaindex[reachareas->firstarea + j];
01860             if (stopevent & RSE_ENTERCONTENTS)
01861             {
01862                 if (aasworld.areasettings[testareanum].contents & stopcontents)
01863                 {
01864                     route->stopevent = RSE_ENTERCONTENTS;
01865                     route->endarea = testareanum;
01866                     route->endcontents = aasworld.areasettings[testareanum].contents;
01867                     VectorCopy(reach->end, route->endpos);
01868                     route->time += AAS_AreaTravelTime(areanum, origin, reach->start);
01869                     route->time += reach->traveltime;
01870                     return qtrue;
01871                 } //end if
01872             } //end if
01873             if (stopevent & RSE_ENTERAREA)
01874             {
01875                 if (testareanum == stopareanum)
01876                 {
01877                     route->stopevent = RSE_ENTERAREA;
01878                     route->endarea = testareanum;
01879                     route->endcontents = aasworld.areasettings[testareanum].contents;
01880                     VectorCopy(reach->start, route->endpos);
01881                     return qtrue;
01882                 } //end if
01883             } //end if
01884         } //end for
01885 
01886         route->time += AAS_AreaTravelTime(areanum, origin, reach->start);
01887         route->time += reach->traveltime;
01888         route->endarea = reach->areanum;
01889         route->endcontents = aasworld.areasettings[reach->areanum].contents;
01890         route->endtravelflags = AAS_TravelFlagForType_inline(reach->traveltype);
01891         VectorCopy(reach->end, route->endpos);
01892         //
01893         curareanum = reach->areanum;
01894         VectorCopy(reach->end, curorigin);
01895         //
01896         if (maxtime && route->time > maxtime)
01897             break;
01898     } //end while
01899     if (curareanum != goalareanum)
01900         return qfalse;
01901     return qtrue;
01902 } //end of the function AAS_PredictRoute

Here is the call graph for this function:

int AAS_RandomGoalArea int  areanum,
int  travelflags,
int *  goalareanum,
vec3_t  goalorigin
 

Definition at line 2001 of file be_aas_route.c.

References AAS_AreaGroundFaceArea(), AAS_AreaReachability(), AAS_AreaSwim(), AAS_AreaTravelTimeToGoalArea(), AAS_PointAreaNum(), aas_trace_t, AAS_TraceClientBBox(), aasworld, aas_s::areas, aas_area_s::center, aas_trace_s::endpos, aas_trace_s::fraction, i, Log_Write(), n, aas_s::numareas, PRESENCE_CROUCH, random, aas_trace_s::startsolid, t, vec3_t, and VectorCopy.

02002 {
02003     int i, n, t;
02004     vec3_t start, end;
02005     aas_trace_t trace;
02006 
02007     //if the area has no reachabilities
02008     if (!AAS_AreaReachability(areanum)) return qfalse;
02009     //
02010     n = aasworld.numareas * random();
02011     for (i = 0; i < aasworld.numareas; i++)
02012     {
02013         if (n <= 0) n = 1;
02014         if (n >= aasworld.numareas) n = 1;
02015         if (AAS_AreaReachability(n))
02016         {
02017             t = AAS_AreaTravelTimeToGoalArea(areanum, aasworld.areas[areanum].center, n, travelflags);
02018             //if the goal is reachable
02019             if (t > 0)
02020             {
02021                 if (AAS_AreaSwim(n))
02022                 {
02023                     *goalareanum = n;
02024                     VectorCopy(aasworld.areas[n].center, goalorigin);
02025                     //botimport.Print(PRT_MESSAGE, "found random goal area %d\n", *goalareanum);
02026                     return qtrue;
02027                 } //end if
02028                 VectorCopy(aasworld.areas[n].center, start);
02029                 if (!AAS_PointAreaNum(start))
02030                     Log_Write("area %d center %f %f %f in solid?", n, start[0], start[1], start[2]);
02031                 VectorCopy(start, end);
02032                 end[2] -= 300;
02033                 trace = AAS_TraceClientBBox(start, end, PRESENCE_CROUCH, -1);
02034                 if (!trace.startsolid && trace.fraction < 1 && AAS_PointAreaNum(trace.endpos) == n)
02035                 {
02036                     if (AAS_AreaGroundFaceArea(n) > 300)
02037                     {
02038                         *goalareanum = n;
02039                         VectorCopy(trace.endpos, goalorigin);
02040                         //botimport.Print(PRT_MESSAGE, "found random goal area %d\n", *goalareanum);
02041                         return qtrue;
02042                     } //end if
02043                 } //end if
02044             } //end if
02045         } //end if
02046         n++;
02047     } //end for
02048     return qfalse;
02049 } //end of the function AAS_RandomGoalArea

Here is the call graph for this function:

void AAS_ReachabilityFromNum int  num,
struct aas_reachability_s reach
 

Definition at line 1919 of file be_aas_route.c.

References aas_reachability_t, aasworld, Com_Memcpy(), Com_Memset(), aas_s::initialized, aas_s::reachability, and aas_s::reachabilitysize.

Referenced by BotExportTest(), BotGetReachabilityToGoal(), BotMovementViewTarget(), BotMoveToGoal(), BotPredictVisiblePosition(), BotReachabilityArea(), and BotResetGrapple().

01920 {
01921     if (!aasworld.initialized)
01922     {
01923         Com_Memset(reach, 0, sizeof(aas_reachability_t));
01924         return;
01925     } //end if
01926     if (num < 0 || num >= aasworld.reachabilitysize)
01927     {
01928         Com_Memset(reach, 0, sizeof(aas_reachability_t));
01929         return;
01930     } //end if
01931     Com_Memcpy(reach, &aasworld.reachability[num], sizeof(aas_reachability_t));;
01932 } //end of the function AAS_ReachabilityFromNum

Here is the call graph for this function:

int AAS_TravelFlagForType int  traveltype  ) 
 

Definition at line 190 of file be_aas_route.c.

References AAS_TravelFlagForType_inline().

Referenced by BotMoveToGoal(), and BotValidTravel().

00191 {
00192     return AAS_TravelFlagForType_inline(traveltype);
00193 } //end of the function AAS_TravelFlagForType_inline

Here is the call graph for this function:


Generated on Thu Aug 25 12:40:26 2005 for Quake III Arena by  doxygen 1.3.9.1