diff --git a/Makefile b/Makefile
index be06ad095..7c43433c8 100644
--- a/Makefile
+++ b/Makefile
@@ -1561,11 +1561,6 @@ Q3OBJ = \
$(B)/client/be_ai_char.o \
$(B)/client/be_ai_chat.o \
$(B)/client/be_ai_gen.o \
- $(B)/client/be_ai_goal.o \
- $(B)/client/be_ai_move.o \
- $(B)/client/be_ai_weap.o \
- $(B)/client/be_ai_weight.o \
- $(B)/client/be_ea.o \
$(B)/client/be_interface.o \
$(B)/client/l_crc.o \
$(B)/client/l_libvar.o \
@@ -2159,11 +2154,6 @@ Q3DOBJ = \
$(B)/ded/be_ai_char.o \
$(B)/ded/be_ai_chat.o \
$(B)/ded/be_ai_gen.o \
- $(B)/ded/be_ai_goal.o \
- $(B)/ded/be_ai_move.o \
- $(B)/ded/be_ai_weap.o \
- $(B)/ded/be_ai_weight.o \
- $(B)/ded/be_ea.o \
$(B)/ded/be_interface.o \
$(B)/ded/l_crc.o \
$(B)/ded/l_libvar.o \
@@ -2353,8 +2343,13 @@ Q3GOBJ_ = \
$(B)/$(BASEGAME)/game/ai_cmd.o \
$(B)/$(BASEGAME)/game/ai_dmnet.o \
$(B)/$(BASEGAME)/game/ai_dmq3.o \
+ $(B)/$(BASEGAME)/game/ai_ea.o \
+ $(B)/$(BASEGAME)/game/ai_goal.o \
$(B)/$(BASEGAME)/game/ai_main.o \
+ $(B)/$(BASEGAME)/game/ai_move.o \
$(B)/$(BASEGAME)/game/ai_team.o \
+ $(B)/$(BASEGAME)/game/ai_weap.o \
+ $(B)/$(BASEGAME)/game/ai_weight.o \
$(B)/$(BASEGAME)/game/ai_vcmd.o \
$(B)/$(BASEGAME)/game/bg_misc.o \
$(B)/$(BASEGAME)/game/bg_pmove.o \
@@ -2405,8 +2400,13 @@ MPGOBJ_ = \
$(B)/$(MISSIONPACK)/game/ai_cmd.o \
$(B)/$(MISSIONPACK)/game/ai_dmnet.o \
$(B)/$(MISSIONPACK)/game/ai_dmq3.o \
+ $(B)/$(MISSIONPACK)/game/ai_ea.o \
+ $(B)/$(MISSIONPACK)/game/ai_goal.o \
$(B)/$(MISSIONPACK)/game/ai_main.o \
+ $(B)/$(MISSIONPACK)/game/ai_move.o \
$(B)/$(MISSIONPACK)/game/ai_team.o \
+ $(B)/$(MISSIONPACK)/game/ai_weap.o \
+ $(B)/$(MISSIONPACK)/game/ai_weight.o \
$(B)/$(MISSIONPACK)/game/ai_vcmd.o \
$(B)/$(MISSIONPACK)/game/bg_misc.o \
$(B)/$(MISSIONPACK)/game/bg_pmove.o \
diff --git a/code/botlib/be_aas.h b/code/botlib/be_aas.h
index 4f3a64b15..d9411d11c 100644
--- a/code/botlib/be_aas.h
+++ b/code/botlib/be_aas.h
@@ -38,6 +38,8 @@ Suite 120, Rockville, Maryland 20850 USA.
*
*****************************************************************************/
+#define MAX_EPAIRKEY 128
+
#ifndef MAX_STRINGFIELD
#define MAX_STRINGFIELD 80
#endif
@@ -127,34 +129,6 @@ typedef struct bsp_trace_s
//
*/
-//entity info
-typedef struct aas_entityinfo_s
-{
- int valid; // true if updated this frame
- int type; // entity type
- int flags; // entity flags
- float ltime; // local time
- float update_time; // time between last and current update
- int number; // number of the entity
- vec3_t origin; // origin of the entity
- vec3_t angles; // angles of the model
- vec3_t old_origin; // for lerping
- vec3_t lastvisorigin; // last visible origin
- vec3_t mins; // bounding box minimums
- vec3_t maxs; // bounding box maximums
- int groundent; // ground entity
- int solid; // solid type
- int modelindex; // model used
- int modelindex2; // weapons, CTF flags, etc
- int frame; // model frame number
- int event; // impulse events -- muzzle flashes, footsteps, etc
- int eventParm; // even parameter
- int powerups; // bit flags
- int weapon; // determines weapon and flash model, etc
- int legsAnim; // mask off ANIM_TOGGLEBIT
- int torsoAnim; // mask off ANIM_TOGGLEBIT
-} aas_entityinfo_t;
-
// area info
typedef struct aas_areainfo_s
{
diff --git a/code/botlib/be_aas_bsp.h b/code/botlib/be_aas_bsp.h
index 1f5c5fe78..8891d5330 100644
--- a/code/botlib/be_aas_bsp.h
+++ b/code/botlib/be_aas_bsp.h
@@ -63,8 +63,6 @@ void AAS_PrintFreeBSPLinks(char *str);
//
#endif //AASINTERN
-#define MAX_EPAIRKEY 128
-
//trace through the world
bsp_trace_t AAS_Trace( vec3_t start,
vec3_t mins,
diff --git a/code/botlib/be_aas_def.h b/code/botlib/be_aas_def.h
index 13c0a69b8..375ed2318 100644
--- a/code/botlib/be_aas_def.h
+++ b/code/botlib/be_aas_def.h
@@ -82,8 +82,8 @@ typedef struct bsp_entdata_s
//entity
typedef struct aas_entity_s
{
- //entity info
- aas_entityinfo_t i;
+ //entity updated this frame
+ qboolean valid;
//links into the AAS areas
aas_link_t *areas;
//links into the BSP leaves
diff --git a/code/botlib/be_aas_entity.c b/code/botlib/be_aas_entity.c
index 251c260eb..79921a19c 100644
--- a/code/botlib/be_aas_entity.c
+++ b/code/botlib/be_aas_entity.c
@@ -52,8 +52,6 @@ Suite 120, Rockville, Maryland 20850 USA.
#include "be_interface.h"
#include "be_aas_def.h"
-#define MASK_SOLID CONTENTS_PLAYERCLIP
-
//===========================================================================
//
// Parameter: -
@@ -62,9 +60,8 @@ Suite 120, Rockville, Maryland 20850 USA.
//===========================================================================
int AAS_UpdateEntity(int entnum, bot_entitystate_t *state)
{
- int relink;
+ qboolean relink;
aas_entity_t *ent;
- vec3_t absmins, absmaxs;
if (!aasworld.loaded)
{
@@ -86,239 +83,31 @@ int AAS_UpdateEntity(int entnum, bot_entitystate_t *state)
return BLERR_NOERROR;
}
- ent->i.update_time = AAS_Time() - ent->i.ltime;
- ent->i.type = state->type;
- ent->i.flags = state->flags;
- ent->i.ltime = AAS_Time();
- VectorCopy(ent->i.origin, ent->i.lastvisorigin);
- VectorCopy(state->old_origin, ent->i.old_origin);
- ent->i.solid = state->solid;
- ent->i.groundent = state->groundent;
- ent->i.modelindex = state->modelindex;
- ent->i.modelindex2 = state->modelindex2;
- ent->i.frame = state->frame;
- ent->i.event = state->event;
- ent->i.eventParm = state->eventParm;
- ent->i.powerups = state->powerups;
- ent->i.weapon = state->weapon;
- ent->i.legsAnim = state->legsAnim;
- ent->i.torsoAnim = state->torsoAnim;
- //number of the entity
- ent->i.number = entnum;
//updated so set valid flag
- ent->i.valid = qtrue;
+ ent->valid = qtrue;
//link everything the first frame
if (aasworld.numframes == 1) relink = qtrue;
- else relink = qfalse;
- //
- if (ent->i.solid == SOLID_BSP)
- {
- //if the angles of the model changed
- if (!VectorCompare(state->angles, ent->i.angles))
- {
- VectorCopy(state->angles, ent->i.angles);
- relink = qtrue;
- } //end if
- //get the mins and maxs of the model
- //FIXME: rotate mins and maxs
- AAS_BSPModelMinsMaxsOrigin(ent->i.modelindex, ent->i.angles, ent->i.mins, ent->i.maxs, NULL);
- } //end if
- else if (ent->i.solid == SOLID_BBOX)
- {
- //if the bounding box size changed
- if (!VectorCompare(state->mins, ent->i.mins) ||
- !VectorCompare(state->maxs, ent->i.maxs))
- {
- VectorCopy(state->mins, ent->i.mins);
- VectorCopy(state->maxs, ent->i.maxs);
- relink = qtrue;
- } //end if
- VectorCopy(state->angles, ent->i.angles);
- } //end if
- //if the origin changed
- if (!VectorCompare(state->origin, ent->i.origin))
- {
- VectorCopy(state->origin, ent->i.origin);
- relink = qtrue;
- } //end if
+ else relink = state->relink;
//if the entity should be relinked
if (relink)
{
//don't link the world model
if (entnum != ENTITYNUM_WORLD)
{
- //absolute mins and maxs
- VectorAdd(ent->i.mins, ent->i.origin, absmins);
- VectorAdd(ent->i.maxs, ent->i.origin, absmaxs);
//unlink the entity
AAS_UnlinkFromAreas(ent->areas);
//relink the entity to the AAS areas (use the larges bbox)
- ent->areas = AAS_LinkEntityClientBBox(absmins, absmaxs, entnum, PRESENCE_NORMAL);
+ ent->areas = AAS_LinkEntityClientBBox(state->absmins, state->absmaxs, entnum, PRESENCE_NORMAL);
//unlink the entity from the BSP leaves
AAS_UnlinkFromBSPLeaves(ent->leaves);
//link the entity to the world BSP tree
- ent->leaves = AAS_BSPLinkEntity(absmins, absmaxs, entnum, 0);
+ ent->leaves = AAS_BSPLinkEntity(state->absmins, state->absmaxs, entnum, 0);
} //end if
} //end if
return BLERR_NOERROR;
} //end of the function AAS_UpdateEntity
//===========================================================================
//
-// Parameter: -
-// Returns: -
-// Changes Globals: -
-//===========================================================================
-void AAS_EntityInfo(int entnum, aas_entityinfo_t *info)
-{
- if (!aasworld.initialized)
- {
- botimport.Print(PRT_FATAL, "AAS_EntityInfo: aasworld not initialized\n");
- Com_Memset(info, 0, sizeof(aas_entityinfo_t));
- return;
- } //end if
-
- if (entnum < 0 || entnum >= aasworld.maxentities)
- {
- botimport.Print(PRT_FATAL, "AAS_EntityInfo: entnum %d out of range\n", entnum);
- Com_Memset(info, 0, sizeof(aas_entityinfo_t));
- return;
- } //end if
-
- Com_Memcpy(info, &aasworld.entities[entnum].i, sizeof(aas_entityinfo_t));
-} //end of the function AAS_EntityInfo
-//===========================================================================
-//
-// Parameter: -
-// Returns: -
-// Changes Globals: -
-//===========================================================================
-void AAS_EntityOrigin(int entnum, vec3_t origin)
-{
- if (entnum < 0 || entnum >= aasworld.maxentities)
- {
- botimport.Print(PRT_FATAL, "AAS_EntityOrigin: entnum %d out of range\n", entnum);
- VectorClear(origin);
- return;
- } //end if
-
- VectorCopy(aasworld.entities[entnum].i.origin, origin);
-} //end of the function AAS_EntityOrigin
-//===========================================================================
-//
-// Parameter: -
-// Returns: -
-// Changes Globals: -
-//===========================================================================
-int AAS_EntityModelindex(int entnum)
-{
- if (entnum < 0 || entnum >= aasworld.maxentities)
- {
- botimport.Print(PRT_FATAL, "AAS_EntityModelindex: entnum %d out of range\n", entnum);
- return 0;
- } //end if
- return aasworld.entities[entnum].i.modelindex;
-} //end of the function AAS_EntityModelindex
-//===========================================================================
-//
-// Parameter: -
-// Returns: -
-// Changes Globals: -
-//===========================================================================
-int AAS_EntityType(int entnum)
-{
- if (!aasworld.initialized) return 0;
-
- if (entnum < 0 || entnum >= aasworld.maxentities)
- {
- botimport.Print(PRT_FATAL, "AAS_EntityType: entnum %d out of range\n", entnum);
- return 0;
- } //end if
- return aasworld.entities[entnum].i.type;
-} //end of the AAS_EntityType
-//===========================================================================
-//
-// Parameter: -
-// Returns: -
-// Changes Globals: -
-//===========================================================================
-int AAS_EntityModelNum(int entnum)
-{
- if (!aasworld.initialized) return 0;
-
- if (entnum < 0 || entnum >= aasworld.maxentities)
- {
- botimport.Print(PRT_FATAL, "AAS_EntityModelNum: entnum %d out of range\n", entnum);
- return 0;
- } //end if
- return aasworld.entities[entnum].i.modelindex;
-} //end of the function AAS_EntityModelNum
-//===========================================================================
-//
-// Parameter: -
-// Returns: -
-// Changes Globals: -
-//===========================================================================
-int AAS_OriginOfMoverWithModelNum(int modelnum, vec3_t origin)
-{
- int i;
- aas_entity_t *ent;
-
- for (i = 0; i < aasworld.maxentities; i++)
- {
- ent = &aasworld.entities[i];
- if (ent->i.type == ET_MOVER)
- {
- if (ent->i.modelindex == modelnum)
- {
- VectorCopy(ent->i.origin, origin);
- return qtrue;
- } //end if
- } //end if
- } //end for
- return qfalse;
-} //end of the function AAS_OriginOfMoverWithModelNum
-//===========================================================================
-//
-// Parameter: -
-// Returns: -
-// Changes Globals: -
-//===========================================================================
-void AAS_EntitySize(int entnum, vec3_t mins, vec3_t maxs)
-{
- aas_entity_t *ent;
-
- if (!aasworld.initialized) return;
-
- if (entnum < 0 || entnum >= aasworld.maxentities)
- {
- botimport.Print(PRT_FATAL, "AAS_EntitySize: entnum %d out of range\n", entnum);
- return;
- } //end if
-
- ent = &aasworld.entities[entnum];
- VectorCopy(ent->i.mins, mins);
- VectorCopy(ent->i.maxs, maxs);
-} //end of the function AAS_EntitySize
-//===========================================================================
-//
-// Parameter: -
-// Returns: -
-// Changes Globals: -
-//===========================================================================
-void AAS_EntityBSPData(int entnum, bsp_entdata_t *entdata)
-{
- aas_entity_t *ent;
-
- ent = &aasworld.entities[entnum];
- VectorCopy(ent->i.origin, entdata->origin);
- VectorCopy(ent->i.angles, entdata->angles);
- VectorAdd(ent->i.origin, ent->i.mins, entdata->absmins);
- VectorAdd(ent->i.origin, ent->i.maxs, entdata->absmaxs);
- entdata->solid = ent->i.solid;
- entdata->modelnum = ent->i.modelindex - 1;
-} //end of the function AAS_EntityBSPData
-//===========================================================================
-//
// Parameter: -
// Returns: -
// Changes Globals: -
@@ -343,8 +132,7 @@ void AAS_InvalidateEntities(void)
int i;
for (i = 0; i < aasworld.maxentities; i++)
{
- aasworld.entities[i].i.valid = qfalse;
- aasworld.entities[i].i.number = i;
+ aasworld.entities[i].valid = qfalse;
} //end for
} //end of the function AAS_InvalidateEntities
//===========================================================================
@@ -361,7 +149,7 @@ void AAS_UnlinkInvalidEntities(void)
for (i = 0; i < aasworld.maxentities; i++)
{
ent = &aasworld.entities[i];
- if (!ent->i.valid)
+ if (!ent->valid)
{
AAS_UnlinkFromAreas( ent->areas );
ent->areas = NULL;
@@ -372,54 +160,6 @@ void AAS_UnlinkInvalidEntities(void)
} //end of the function AAS_UnlinkInvalidEntities
//===========================================================================
//
-// Parameter: -
-// Returns: -
-// Changes Globals: -
-//===========================================================================
-int AAS_NearestEntity(vec3_t origin, int modelindex)
-{
- int i, bestentnum;
- float dist, bestdist;
- aas_entity_t *ent;
- vec3_t dir;
-
- bestentnum = 0;
- bestdist = 99999;
- for (i = 0; i < aasworld.maxentities; i++)
- {
- ent = &aasworld.entities[i];
- if (ent->i.modelindex != modelindex) continue;
- VectorSubtract(ent->i.origin, origin, dir);
- if (abs(dir[0]) < 40)
- {
- if (abs(dir[1]) < 40)
- {
- dist = VectorLength(dir);
- if (dist < bestdist)
- {
- bestdist = dist;
- bestentnum = i;
- } //end if
- } //end if
- } //end if
- } //end for
- return bestentnum;
-} //end of the function AAS_NearestEntity
-//===========================================================================
-//
-// Parameter: -
-// Returns: -
-// Changes Globals: -
-//===========================================================================
-int AAS_BestReachableEntityArea(int entnum)
-{
- aas_entity_t *ent;
-
- ent = &aasworld.entities[entnum];
- return AAS_BestReachableLinkArea(ent->areas);
-} //end of the function AAS_BestReachableEntityArea
-//===========================================================================
-//
// Parameter: -
// Returns: -
// Changes Globals: -
@@ -431,7 +171,7 @@ int AAS_NextEntity(int entnum)
if (entnum < 0) entnum = -1;
while(++entnum < aasworld.maxentities)
{
- if (aasworld.entities[entnum].i.valid) return entnum;
+ if (aasworld.entities[entnum].valid) return entnum;
} //end while
return 0;
} //end of the function AAS_NextEntity
diff --git a/code/botlib/be_aas_entity.h b/code/botlib/be_aas_entity.h
index 7438caa4b..e675737ad 100644
--- a/code/botlib/be_aas_entity.h
+++ b/code/botlib/be_aas_entity.h
@@ -46,26 +46,5 @@ void AAS_UnlinkInvalidEntities(void);
void AAS_ResetEntityLinks(void);
//updates an entity
int AAS_UpdateEntity(int ent, bot_entitystate_t *state);
-//gives the entity data used for collision detection
-void AAS_EntityBSPData(int entnum, bsp_entdata_t *entdata);
#endif //AASINTERN
-//returns the size of the entity bounding box in mins and maxs
-void AAS_EntitySize(int entnum, vec3_t mins, vec3_t maxs);
-//returns the BSP model number of the entity
-int AAS_EntityModelNum(int entnum);
-//returns the origin of an entity with the given model number
-int AAS_OriginOfMoverWithModelNum(int modelnum, vec3_t origin);
-//returns the best reachable area the entity is situated in
-int AAS_BestReachableEntityArea(int entnum);
-//returns the info of the given entity
-void AAS_EntityInfo(int entnum, aas_entityinfo_t *info);
-//returns the next entity
-int AAS_NextEntity(int entnum);
-//returns the origin of the entity
-void AAS_EntityOrigin(int entnum, vec3_t origin);
-//returns the entity type
-int AAS_EntityType(int entnum);
-//returns the model index of the entity
-int AAS_EntityModelindex(int entnum);
-
diff --git a/code/botlib/be_ai_chat.c b/code/botlib/be_ai_chat.c
index b5617c3d8..e45ac080f 100644
--- a/code/botlib/be_ai_chat.c
+++ b/code/botlib/be_ai_chat.c
@@ -50,7 +50,6 @@ Suite 120, Rockville, Maryland 20850 USA.
#include "be_aas.h"
#include "be_aas_funcs.h"
#include "be_interface.h"
-#include "be_ea.h"
#include "be_ai_chat.h"
@@ -2828,13 +2827,13 @@ void BotEnterChat(int chatstate, int clientto, int sendto)
else {
switch(sendto) {
case CHAT_TEAM:
- EA_Command(cs->client, va("say_team %s", cs->chatmessage));
+ botimport.BotClientCommand(cs->client, va("say_team %s", cs->chatmessage));
break;
case CHAT_TELL:
- EA_Command(cs->client, va("tell %d %s", clientto, cs->chatmessage));
+ botimport.BotClientCommand(cs->client, va("tell %d %s", clientto, cs->chatmessage));
break;
default: //CHAT_ALL
- EA_Command(cs->client, va("say %s", cs->chatmessage));
+ botimport.BotClientCommand(cs->client, va("say %s", cs->chatmessage));
break;
}
}
diff --git a/code/botlib/be_interface.c b/code/botlib/be_interface.c
index ef784941b..b518c512f 100644
--- a/code/botlib/be_interface.c
+++ b/code/botlib/be_interface.c
@@ -51,11 +51,6 @@ Suite 120, Rockville, Maryland 20850 USA.
#include "be_aas_def.h"
#include "be_interface.h"
-#include "be_ea.h"
-#include "be_ai_weight.h"
-#include "be_ai_goal.h"
-#include "be_ai_move.h"
-#include "be_ai_weap.h"
#include "be_ai_chat.h"
#include "be_ai_char.h"
#include "be_ai_gen.h"
@@ -181,16 +176,8 @@ int Export_BotLibSetup(void)
errnum = AAS_Setup(); //be_aas_main.c
if (errnum != BLERR_NOERROR) return errnum;
- errnum = EA_Setup(); //be_ea.c
- if (errnum != BLERR_NOERROR) return errnum;
- errnum = BotSetupWeaponAI(); //be_ai_weap.c
- if (errnum != BLERR_NOERROR)return errnum;
- errnum = BotSetupGoalAI(); //be_ai_goal.c
- if (errnum != BLERR_NOERROR) return errnum;
errnum = BotSetupChatAI(); //be_ai_chat.c
if (errnum != BLERR_NOERROR) return errnum;
- errnum = BotSetupMoveAI(); //be_ai_move.c
- if (errnum != BLERR_NOERROR) return errnum;
botlibsetup = qtrue;
botlibglobals.botlibsetup = qtrue;
@@ -211,15 +198,9 @@ int Export_BotLibShutdown(void)
#endif //DEMO
//
BotShutdownChatAI(); //be_ai_chat.c
- BotShutdownMoveAI(); //be_ai_move.c
- BotShutdownGoalAI(); //be_ai_goal.c
- BotShutdownWeaponAI(); //be_ai_weap.c
- BotShutdownWeights(); //be_ai_weight.c
BotShutdownCharacters(); //be_ai_char.c
//shud down aas
AAS_Shutdown();
- //shut down bot elemantary actions
- EA_Shutdown();
//free all libvars
LibVarDeAllocAll();
//remove all global defines from the pre compiler
@@ -296,9 +277,6 @@ int Export_BotLibLoadMap(const char *mapname)
//startup AAS for the current map, model and sound index
errnum = AAS_LoadMap(mapname);
if (errnum != BLERR_NOERROR) return errnum;
- //initialize the items in the level
- BotInitLevelItems(); //be_ai_goal.h
- BotSetBrushModelTypes(); //be_ai_move.h
//
botimport.Print(PRT_DEVELOPER, "-------------------------------------\n");
#ifdef DEBUG
@@ -326,6 +304,21 @@ int Export_BotLibUpdateEntity(int ent, bot_entitystate_t *state)
// Returns: -
// Changes Globals: -
//===========================================================================
+void Export_AAS_TraceClientBBox(struct aas_trace_s *trace, vec3_t start, vec3_t end, int presencetype, int passent)
+{
+ aas_trace_t tr;
+ if ( !trace ) return;
+ tr = AAS_TraceClientBBox(start, end, presencetype, passent);
+ Com_Memcpy(trace, &tr, sizeof (aas_trace_t));
+} //end of the function Export_AAS_TraceClientBBox
+//===========================================================================
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+// ZTM: FIXME: Botlib's Test function is broken, move to game?
+#ifdef DEBUG
void AAS_TestMovementPrediction(int entnum, vec3_t origin, vec3_t dir);
void ElevatorBottomCenter(aas_reachability_t *reach, vec3_t bottomcenter);
int BotGetReachabilityToGoal(vec3_t origin, int areanum,
@@ -345,6 +338,7 @@ int BotFuzzyPointReachabilityArea(vec3_t origin);
float BotGapDistance(vec3_t origin, vec3_t hordir, int entnum);
void AAS_FloodAreas(vec3_t origin);
+#endif
int BotExportTest(int parm0, char *parm1, vec3_t parm2, vec3_t parm3)
{
@@ -685,13 +679,10 @@ Init_AAS_Export
============
*/
static void Init_AAS_Export( aas_export_t *aas ) {
- //--------------------------------------------
- // be_aas_entity.c
- //--------------------------------------------
- aas->AAS_EntityInfo = AAS_EntityInfo;
//--------------------------------------------
// be_aas_main.c
//--------------------------------------------
+ aas->AAS_Loaded = AAS_Loaded;
aas->AAS_Initialized = AAS_Initialized;
aas->AAS_PresenceTypeBoundingBox = AAS_PresenceTypeBoundingBox;
aas->AAS_Time = AAS_Time;
@@ -700,6 +691,7 @@ static void Init_AAS_Export( aas_export_t *aas ) {
//--------------------------------------------
aas->AAS_PointAreaNum = AAS_PointAreaNum;
aas->AAS_PointReachabilityAreaIndex = AAS_PointReachabilityAreaIndex;
+ aas->AAS_TraceClientBBox = Export_AAS_TraceClientBBox;
aas->AAS_TraceAreas = AAS_TraceAreas;
aas->AAS_BBoxAreas = AAS_BBoxAreas;
aas->AAS_AreaInfo = AAS_AreaInfo;
@@ -717,11 +709,29 @@ static void Init_AAS_Export( aas_export_t *aas ) {
//--------------------------------------------
aas->AAS_AreaReachability = AAS_AreaReachability;
aas->AAS_BestReachableArea = AAS_BestReachableArea;
+ aas->AAS_BestReachableFromJumpPadArea = AAS_BestReachableFromJumpPadArea;
+ aas->AAS_NextModelReachability = AAS_NextModelReachability;
+ aas->AAS_AreaGroundFaceArea = AAS_AreaGroundFaceArea;
+ aas->AAS_AreaCrouch = AAS_AreaCrouch;
+ aas->AAS_AreaSwim = AAS_AreaSwim;
+ aas->AAS_AreaLiquid = AAS_AreaLiquid;
+ aas->AAS_AreaLava = AAS_AreaLava;
+ aas->AAS_AreaSlime = AAS_AreaSlime;
+ aas->AAS_AreaGrounded = AAS_AreaGrounded;
+ aas->AAS_AreaLadder = AAS_AreaLadder;
+ aas->AAS_AreaJumpPad = AAS_AreaJumpPad;
+ aas->AAS_AreaDoNotEnter = AAS_AreaDoNotEnter;
//--------------------------------------------
// be_aas_route.c
//--------------------------------------------
- aas->AAS_AreaTravelTimeToGoalArea = AAS_AreaTravelTimeToGoalArea;
+ aas->AAS_TravelFlagForType = AAS_TravelFlagForType;
+ aas->AAS_AreaContentsTravelFlags = AAS_AreaContentsTravelFlags;
+ aas->AAS_NextAreaReachability = AAS_NextAreaReachability;
+ aas->AAS_ReachabilityFromNum = AAS_ReachabilityFromNum;
+ aas->AAS_RandomGoalArea = AAS_RandomGoalArea;
aas->AAS_EnableRoutingArea = AAS_EnableRoutingArea;
+ aas->AAS_AreaTravelTime = AAS_AreaTravelTime;
+ aas->AAS_AreaTravelTimeToGoalArea = AAS_AreaTravelTimeToGoalArea;
aas->AAS_PredictRoute = AAS_PredictRoute;
//--------------------------------------------
// be_aas_altroute.c
@@ -730,47 +740,16 @@ static void Init_AAS_Export( aas_export_t *aas ) {
//--------------------------------------------
// be_aas_move.c
//--------------------------------------------
- aas->AAS_Swimming = AAS_Swimming;
aas->AAS_PredictClientMovement = AAS_PredictClientMovement;
+ aas->AAS_OnGround = AAS_OnGround;
+ aas->AAS_Swimming = AAS_Swimming;
+ aas->AAS_JumpReachRunStart = AAS_JumpReachRunStart;
+ aas->AAS_AgainstLadder = AAS_AgainstLadder;
+ aas->AAS_HorizontalVelocityForJump = AAS_HorizontalVelocityForJump;
+ aas->AAS_DropToFloor = AAS_DropToFloor;
}
-/*
-============
-Init_EA_Export
-============
-*/
-static void Init_EA_Export( ea_export_t *ea ) {
- //ClientCommand elementary actions
- ea->EA_Command = EA_Command;
- ea->EA_Say = EA_Say;
- ea->EA_SayTeam = EA_SayTeam;
-
- ea->EA_Action = EA_Action;
- ea->EA_Gesture = EA_Gesture;
- ea->EA_Talk = EA_Talk;
- ea->EA_Attack = EA_Attack;
- ea->EA_Use = EA_Use;
- ea->EA_Respawn = EA_Respawn;
- ea->EA_Crouch = EA_Crouch;
- ea->EA_MoveUp = EA_MoveUp;
- ea->EA_MoveDown = EA_MoveDown;
- ea->EA_MoveForward = EA_MoveForward;
- ea->EA_MoveBack = EA_MoveBack;
- ea->EA_MoveLeft = EA_MoveLeft;
- ea->EA_MoveRight = EA_MoveRight;
-
- ea->EA_SelectWeapon = EA_SelectWeapon;
- ea->EA_Jump = EA_Jump;
- ea->EA_DelayedJump = EA_DelayedJump;
- ea->EA_Move = EA_Move;
- ea->EA_View = EA_View;
- ea->EA_GetInput = EA_GetInput;
- ea->EA_EndRegular = EA_EndRegular;
- ea->EA_ResetInput = EA_ResetInput;
-}
-
-
/*
============
Init_AI_Export
@@ -811,62 +790,6 @@ static void Init_AI_Export( ai_export_t *ai ) {
ai->BotSetChatGender = BotSetChatGender;
ai->BotSetChatName = BotSetChatName;
//-----------------------------------
- // be_ai_goal.h
- //-----------------------------------
- ai->BotResetGoalState = BotResetGoalState;
- ai->BotResetAvoidGoals = BotResetAvoidGoals;
- ai->BotRemoveFromAvoidGoals = BotRemoveFromAvoidGoals;
- ai->BotPushGoal = BotPushGoal;
- ai->BotPopGoal = BotPopGoal;
- ai->BotEmptyGoalStack = BotEmptyGoalStack;
- ai->BotDumpAvoidGoals = BotDumpAvoidGoals;
- ai->BotDumpGoalStack = BotDumpGoalStack;
- ai->BotGoalName = BotGoalName;
- ai->BotGetTopGoal = BotGetTopGoal;
- ai->BotGetSecondGoal = BotGetSecondGoal;
- ai->BotChooseLTGItem = BotChooseLTGItem;
- ai->BotChooseNBGItem = BotChooseNBGItem;
- ai->BotTouchingGoal = BotTouchingGoal;
- ai->BotItemGoalInVisButNotVisible = BotItemGoalInVisButNotVisible;
- ai->BotGetLevelItemGoal = BotGetLevelItemGoal;
- ai->BotGetNextCampSpotGoal = BotGetNextCampSpotGoal;
- ai->BotGetMapLocationGoal = BotGetMapLocationGoal;
- ai->BotAvoidGoalTime = BotAvoidGoalTime;
- ai->BotSetAvoidGoalTime = BotSetAvoidGoalTime;
- ai->BotInitLevelItems = BotInitLevelItems;
- ai->BotUpdateEntityItems = BotUpdateEntityItems;
- ai->BotLoadItemWeights = BotLoadItemWeights;
- ai->BotFreeItemWeights = BotFreeItemWeights;
- ai->BotInterbreedGoalFuzzyLogic = BotInterbreedGoalFuzzyLogic;
- ai->BotSaveGoalFuzzyLogic = BotSaveGoalFuzzyLogic;
- ai->BotMutateGoalFuzzyLogic = BotMutateGoalFuzzyLogic;
- ai->BotAllocGoalState = BotAllocGoalState;
- ai->BotFreeGoalState = BotFreeGoalState;
- //-----------------------------------
- // be_ai_move.h
- //-----------------------------------
- ai->BotResetMoveState = BotResetMoveState;
- ai->BotMoveToGoal = BotMoveToGoal;
- ai->BotMoveInDirection = BotMoveInDirection;
- ai->BotResetAvoidReach = BotResetAvoidReach;
- ai->BotResetLastAvoidReach = BotResetLastAvoidReach;
- ai->BotReachabilityArea = BotReachabilityArea;
- ai->BotMovementViewTarget = BotMovementViewTarget;
- ai->BotPredictVisiblePosition = BotPredictVisiblePosition;
- ai->BotAllocMoveState = BotAllocMoveState;
- ai->BotFreeMoveState = BotFreeMoveState;
- ai->BotInitMoveState = BotInitMoveState;
- ai->BotAddAvoidSpot = BotAddAvoidSpot;
- //-----------------------------------
- // be_ai_weap.h
- //-----------------------------------
- ai->BotChooseBestFightWeapon = BotChooseBestFightWeapon;
- ai->BotGetWeaponInfo = BotGetWeaponInfo;
- ai->BotLoadWeaponWeights = BotLoadWeaponWeights;
- ai->BotAllocWeaponState = BotAllocWeaponState;
- ai->BotFreeWeaponState = BotFreeWeaponState;
- ai->BotResetWeaponState = BotResetWeaponState;
- //-----------------------------------
// be_ai_gen.h
//-----------------------------------
ai->GeneticParentsAndChildSelection = GeneticParentsAndChildSelection;
@@ -891,7 +814,6 @@ botlib_export_t *GetBotLibAPI(int apiVersion, botlib_import_t *import) {
}
Init_AAS_Export(&be_botlib_export.aas);
- Init_EA_Export(&be_botlib_export.ea);
Init_AI_Export(&be_botlib_export.ai);
be_botlib_export.BotLibSetup = Export_BotLibSetup;
diff --git a/code/botlib/botlib.h b/code/botlib/botlib.h
index 9165ad3ae..40ddad913 100644
--- a/code/botlib/botlib.h
+++ b/code/botlib/botlib.h
@@ -37,12 +37,13 @@ Suite 120, Rockville, Maryland 20850 USA.
*
*****************************************************************************/
-#define BOTLIB_API_VERSION 2
+#define BOTLIB_API_VERSION 3
struct aas_clientmove_s;
-struct aas_entityinfo_s;
struct aas_areainfo_s;
+struct aas_trace_s;
struct aas_altroutegoal_s;
+struct aas_reachability_s;
struct aas_predictroute_s;
struct bot_consolemessage_s;
struct bot_match_s;
@@ -87,41 +88,6 @@ struct weaponinfo_s;
#define BLERR_CANNOTLOADWEAPONWEIGHTS 11 //cannot load weapon weights
#define BLERR_CANNOTLOADWEAPONCONFIG 12 //cannot load weapon config
-//action flags
-#define ACTION_ATTACK 0x00000001
-#define ACTION_USE 0x00000002
-#define ACTION_RESPAWN 0x00000008
-#define ACTION_JUMP 0x00000010
-#define ACTION_MOVEUP 0x00000020
-#define ACTION_CROUCH 0x00000080
-#define ACTION_MOVEDOWN 0x00000100
-#define ACTION_MOVEFORWARD 0x00000200
-#define ACTION_MOVEBACK 0x00000800
-#define ACTION_MOVELEFT 0x00001000
-#define ACTION_MOVERIGHT 0x00002000
-#define ACTION_DELAYEDJUMP 0x00008000
-#define ACTION_TALK 0x00010000
-#define ACTION_GESTURE 0x00020000
-#define ACTION_WALK 0x00080000
-#define ACTION_AFFIRMATIVE 0x00100000
-#define ACTION_NEGATIVE 0x00200000
-#define ACTION_GETFLAG 0x00800000
-#define ACTION_GUARDBASE 0x01000000
-#define ACTION_PATROL 0x02000000
-#define ACTION_FOLLOWME 0x08000000
-#define ACTION_JUMPEDLASTFRAME 0x10000000
-
-//the bot input, will be converted to a usercmd_t
-typedef struct bot_input_s
-{
- float thinktime; //time since last output (in seconds)
- vec3_t dir; //movement direction
- float speed; //speed in the range [0, 400]
- vec3_t viewangles; //the view angles
- int actionflags; //one of the ACTION_? flags
- int weapon; //weapon to use
-} bot_input_t;
-
#ifndef BSPTRACE
#define BSPTRACE
@@ -155,24 +121,14 @@ typedef struct bsp_trace_s
//entity state
typedef struct bot_entitystate_s
{
- int type; // entity type
- int flags; // entity flags
- vec3_t origin; // origin of the entity
- vec3_t angles; // angles of the model
- vec3_t old_origin; // for lerping
- vec3_t mins; // bounding box minimums
- vec3_t maxs; // bounding box maximums
- int groundent; // ground entity
- int solid; // solid type
- int modelindex; // model used
- int modelindex2; // weapons, CTF flags, etc
- int frame; // model frame number
- int event; // impulse events -- muzzle flashes, footsteps, etc
- int eventParm; // even parameter
- int powerups; // bit flags
- int weapon; // determines weapon and flash model, etc
- int legsAnim; // mask off ANIM_TOGGLEBIT
- int torsoAnim; // mask off ANIM_TOGGLEBIT
+ int type; // entity type
+ int flags; // entity flags
+ vec3_t origin; // origin of the entity
+ vec3_t angles; // angles of the model
+ vec3_t absmins; // absolute bounding box minimums
+ vec3_t absmaxs; // absolute bounding box maximums
+ int solid; // solid type
+ qboolean relink; // relink entity
} bot_entitystate_t;
//bot AI library exported functions
@@ -193,7 +149,7 @@ typedef struct botlib_import_s
//
void (*BSPModelMinsMaxsOrigin)(int modelnum, vec3_t angles, vec3_t mins, vec3_t maxs, vec3_t origin);
//send a bot client command
- void (*BotClientCommand)(int client, char *command);
+ void (*BotClientCommand)(int client, const char *command);
//memory allocation
void *(*GetMemory)(int size); // allocate from Zone
void (*FreeMemory)(void *ptr); // free memory from Zone
@@ -217,12 +173,9 @@ typedef struct botlib_import_s
typedef struct aas_export_s
{
//-----------------------------------
- // be_aas_entity.h
- //-----------------------------------
- void (*AAS_EntityInfo)(int entnum, struct aas_entityinfo_s *info);
- //-----------------------------------
- // be_aas_main.h
+ // be_aas_main.c
//-----------------------------------
+ int (*AAS_Loaded)(void);
int (*AAS_Initialized)(void);
void (*AAS_PresenceTypeBoundingBox)(int presencetype, vec3_t mins, vec3_t maxs);
float (*AAS_Time)(void);
@@ -231,6 +184,7 @@ typedef struct aas_export_s
//--------------------------------------------
int (*AAS_PointAreaNum)(vec3_t point);
int (*AAS_PointReachabilityAreaIndex)( vec3_t point );
+ void (*AAS_TraceClientBBox)(struct aas_trace_s *trace, vec3_t start, vec3_t end, int presencetype, int passent);
int (*AAS_TraceAreas)(vec3_t start, vec3_t end, int *areas, vec3_t *points, int maxareas);
int (*AAS_BBoxAreas)(vec3_t absmins, vec3_t absmaxs, int *areas, int maxareas);
int (*AAS_AreaInfo)( int areanum, struct aas_areainfo_s *info );
@@ -248,11 +202,29 @@ typedef struct aas_export_s
//--------------------------------------------
int (*AAS_AreaReachability)(int areanum);
int (*AAS_BestReachableArea)(vec3_t origin, vec3_t mins, vec3_t maxs, vec3_t goalorigin);
+ int (*AAS_BestReachableFromJumpPadArea)(vec3_t origin, vec3_t mins, vec3_t maxs);
+ int (*AAS_NextModelReachability)(int num, int modelnum);
+ float (*AAS_AreaGroundFaceArea)(int areanum);
+ int (*AAS_AreaCrouch)(int areanum);
+ int (*AAS_AreaSwim)(int areanum);
+ int (*AAS_AreaLiquid)(int areanum);
+ int (*AAS_AreaLava)(int areanum);
+ int (*AAS_AreaSlime)(int areanum);
+ int (*AAS_AreaGrounded)(int areanum);
+ int (*AAS_AreaLadder)(int areanum);
+ int (*AAS_AreaJumpPad)(int areanum);
+ int (*AAS_AreaDoNotEnter)(int areanum);
//--------------------------------------------
// be_aas_route.c
//--------------------------------------------
- int (*AAS_AreaTravelTimeToGoalArea)(int areanum, vec3_t origin, int goalareanum, int travelflags);
+ int (*AAS_TravelFlagForType)(int traveltype);
+ int (*AAS_AreaContentsTravelFlags)(int areanum);
+ int (*AAS_NextAreaReachability)(int areanum, int reachnum);
+ void (*AAS_ReachabilityFromNum)(int num, struct aas_reachability_s *reach);
+ int (*AAS_RandomGoalArea)(int areanum, int travelflags, int *goalareanum, vec3_t goalorigin);
int (*AAS_EnableRoutingArea)(int areanum, int enable);
+ 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_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);
@@ -265,7 +237,6 @@ typedef struct aas_export_s
//--------------------------------------------
// be_aas_move.c
//--------------------------------------------
- int (*AAS_Swimming)(vec3_t origin);
int (*AAS_PredictClientMovement)(struct aas_clientmove_s *move,
int entnum, vec3_t origin,
int presencetype, int onground,
@@ -273,40 +244,14 @@ typedef struct aas_export_s
int cmdframes,
int maxframes, float frametime,
int stopevent, int stopareanum, int visualize);
+ int (*AAS_OnGround)(vec3_t origin, int presencetype, int passent);
+ int (*AAS_Swimming)(vec3_t origin);
+ void (*AAS_JumpReachRunStart)(struct aas_reachability_s *reach, vec3_t runstart);
+ int (*AAS_AgainstLadder)(vec3_t origin);
+ int (*AAS_HorizontalVelocityForJump)(float zvel, vec3_t start, vec3_t end, float *velocity);
+ int (*AAS_DropToFloor)(vec3_t origin, vec3_t mins, vec3_t maxs);
} aas_export_t;
-typedef struct ea_export_s
-{
- //ClientCommand elementary actions
- void (*EA_Command)(int client, char *command );
- void (*EA_Say)(int client, char *str);
- void (*EA_SayTeam)(int client, char *str);
- //
- void (*EA_Action)(int client, int action);
- void (*EA_Gesture)(int client);
- void (*EA_Talk)(int client);
- void (*EA_Attack)(int client);
- void (*EA_Use)(int client);
- void (*EA_Respawn)(int client);
- void (*EA_MoveUp)(int client);
- void (*EA_MoveDown)(int client);
- void (*EA_MoveForward)(int client);
- void (*EA_MoveBack)(int client);
- void (*EA_MoveLeft)(int client);
- void (*EA_MoveRight)(int client);
- void (*EA_Crouch)(int client);
-
- void (*EA_SelectWeapon)(int client, int weapon);
- void (*EA_Jump)(int client);
- void (*EA_DelayedJump)(int client);
- void (*EA_Move)(int client, vec3_t dir, float speed);
- void (*EA_View)(int client, vec3_t viewangles);
- //send regular input to the server
- void (*EA_EndRegular)(int client, float thinktime);
- void (*EA_GetInput)(int client, float thinktime, bot_input_t *input);
- void (*EA_ResetInput)(int client);
-} ea_export_t;
-
typedef struct ai_export_s
{
//-----------------------------------
@@ -343,63 +288,6 @@ typedef struct ai_export_s
void (*BotSetChatGender)(int chatstate, int gender);
void (*BotSetChatName)(int chatstate, char *name, int client);
//-----------------------------------
- // be_ai_goal.h
- //-----------------------------------
- void (*BotResetGoalState)(int goalstate);
- void (*BotResetAvoidGoals)(int goalstate);
- void (*BotRemoveFromAvoidGoals)(int goalstate, int number);
- void (*BotPushGoal)(int goalstate, struct bot_goal_s *goal);
- void (*BotPopGoal)(int goalstate);
- void (*BotEmptyGoalStack)(int goalstate);
- void (*BotDumpAvoidGoals)(int goalstate);
- void (*BotDumpGoalStack)(int goalstate);
- void (*BotGoalName)(int number, char *name, int size);
- int (*BotGetTopGoal)(int goalstate, struct bot_goal_s *goal);
- int (*BotGetSecondGoal)(int goalstate, struct bot_goal_s *goal);
- int (*BotChooseLTGItem)(int goalstate, vec3_t origin, int *inventory, int travelflags);
- int (*BotChooseNBGItem)(int goalstate, vec3_t origin, int *inventory, int travelflags,
- struct bot_goal_s *ltg, float maxtime);
- int (*BotTouchingGoal)(vec3_t origin, struct bot_goal_s *goal);
- int (*BotItemGoalInVisButNotVisible)(int viewer, vec3_t eye, vec3_t viewangles, struct bot_goal_s *goal);
- int (*BotGetLevelItemGoal)(int index, char *classname, struct bot_goal_s *goal);
- int (*BotGetNextCampSpotGoal)(int num, struct bot_goal_s *goal);
- int (*BotGetMapLocationGoal)(char *name, struct bot_goal_s *goal);
- float (*BotAvoidGoalTime)(int goalstate, int number);
- void (*BotSetAvoidGoalTime)(int goalstate, int number, float avoidtime);
- void (*BotInitLevelItems)(void);
- void (*BotUpdateEntityItems)(void);
- int (*BotLoadItemWeights)(int goalstate, char *filename);
- void (*BotFreeItemWeights)(int goalstate);
- void (*BotInterbreedGoalFuzzyLogic)(int parent1, int parent2, int child);
- void (*BotSaveGoalFuzzyLogic)(int goalstate, char *filename);
- void (*BotMutateGoalFuzzyLogic)(int goalstate, float range);
- int (*BotAllocGoalState)(int client);
- void (*BotFreeGoalState)(int handle);
- //-----------------------------------
- // be_ai_move.h
- //-----------------------------------
- void (*BotResetMoveState)(int movestate);
- void (*BotMoveToGoal)(struct bot_moveresult_s *result, int movestate, struct bot_goal_s *goal, int travelflags);
- int (*BotMoveInDirection)(int movestate, vec3_t dir, float speed, int type);
- void (*BotResetAvoidReach)(int movestate);
- void (*BotResetLastAvoidReach)(int movestate);
- int (*BotReachabilityArea)(vec3_t origin, int testground);
- int (*BotMovementViewTarget)(int movestate, struct bot_goal_s *goal, int travelflags, float lookahead, vec3_t target);
- int (*BotPredictVisiblePosition)(vec3_t origin, int areanum, struct bot_goal_s *goal, int travelflags, vec3_t target);
- int (*BotAllocMoveState)(void);
- void (*BotFreeMoveState)(int handle);
- void (*BotInitMoveState)(int handle, struct bot_initmove_s *initmove);
- void (*BotAddAvoidSpot)(int movestate, vec3_t origin, float radius, int type);
- //-----------------------------------
- // be_ai_weap.h
- //-----------------------------------
- int (*BotChooseBestFightWeapon)(int weaponstate, int *inventory);
- void (*BotGetWeaponInfo)(int weaponstate, int weapon, struct weaponinfo_s *weaponinfo);
- int (*BotLoadWeaponWeights)(int weaponstate, char *filename);
- int (*BotAllocWeaponState)(void);
- void (*BotFreeWeaponState)(int weaponstate);
- void (*BotResetWeaponState)(int weaponstate);
- //-----------------------------------
// be_ai_gen.h
//-----------------------------------
int (*GeneticParentsAndChildSelection)(int numranks, float *ranks, int *parent1, int *parent2, int *child);
@@ -410,8 +298,6 @@ typedef struct botlib_export_s
{
//Area Awareness System functions
aas_export_t aas;
- //Elementary Action functions
- ea_export_t ea;
//AI functions
ai_export_t ai;
//setup the bot library, returns BLERR_
@@ -426,7 +312,7 @@ typedef struct botlib_export_s
//sets a C-like define returns BLERR_
int (*PC_AddGlobalDefine)(char *string);
void (*PC_RemoveAllGlobalDefines)(void);
- int (*PC_LoadSourceHandle)(const char *filename);
+ int (*PC_LoadSourceHandle)(const char *filename, const char *basepath);
int (*PC_FreeSourceHandle)(int handle);
int (*PC_ReadTokenHandle)(int handle, pc_token_t *pc_token);
void (*PC_UnreadLastTokenHandle)(int handle);
@@ -504,26 +390,11 @@ name: default: module(s): description:
"bot_visualizejumppads" "0" be_aas_reach.c visualize jump pads
"bot_reloadcharacters" "0" - reload bot character files
-"ai_gametype" "0" be_ai_goal.c game type
-"droppedweight" "1000" be_ai_goal.c additional dropped item weight
-"weapindex_rocketlauncher" "5" be_ai_move.c rl weapon index for rocket jumping
-"weapindex_bfg10k" "9" be_ai_move.c bfg weapon index for bfg jumping
-"weapindex_grapple" "10" be_ai_move.c grapple weapon index for grappling
-"entitytypemissile" "3" be_ai_move.c ET_MISSILE
-"offhandgrapple" "0" be_ai_move.c enable off hand grapple hook
-"cmd_grappleon" "grappleon" be_ai_move.c command to activate off hand grapple
-"cmd_grappleoff" "grappleoff" be_ai_move.c command to deactivate off hand grapple
-"itemconfig" "items.c" be_ai_goal.c item configuration file
-"weaponconfig" "weapons.c" be_ai_weap.c weapon configuration file
"synfile" "syn.c" be_ai_chat.c file with synonyms
"rndfile" "rnd.c" be_ai_chat.c file with random strings
"matchfile" "match.c" be_ai_chat.c file with match strings
"nochat" "0" be_ai_chat.c disable chats
"max_messages" "1024" be_ai_chat.c console message heap size
-"max_weaponinfo" "32" be_ai_weap.c maximum number of weapon info
-"max_projectileinfo" "32" be_ai_weap.c maximum number of projectile info
-"max_iteminfo" "256" be_ai_goal.c maximum number of item info
-"max_levelitems" "256" be_ai_goal.c maximum number of level items
*/
diff --git a/code/botlib/l_precomp.c b/code/botlib/l_precomp.c
index 35e5e461e..4e6e94df9 100644
--- a/code/botlib/l_precomp.c
+++ b/code/botlib/l_precomp.c
@@ -3120,7 +3120,7 @@ void FreeSource(source_t *source)
source_t *sourceFiles[MAX_SOURCEFILES];
-int PC_LoadSourceHandle(const char *filename)
+int PC_LoadSourceHandle(const char *filename, const char *basepath)
{
source_t *source;
int i;
@@ -3132,7 +3132,7 @@ int PC_LoadSourceHandle(const char *filename)
} //end for
if (i >= MAX_SOURCEFILES)
return 0;
- PS_SetBaseFolder("");
+ PS_SetBaseFolder(basepath);
source = LoadSourceFile(filename);
if (!source)
return 0;
@@ -3180,6 +3180,8 @@ int PC_ReadTokenHandle(int handle, pc_token_t *pc_token)
pc_token->floatvalue = token.floatvalue;
if (pc_token->type == TT_STRING)
StripDoubleQuotes(pc_token->string);
+ if (pc_token->type == TT_LITERAL)
+ StripSingleQuotes(pc_token->string);
return ret;
} //end of the function PC_ReadTokenHandle
//============================================================================
@@ -3224,7 +3226,7 @@ int PC_SourceFileAndLine(int handle, char *filename, int *line)
// Returns: -
// Changes Globals: -
//============================================================================
-void PC_SetBaseFolder(char *path)
+void PC_SetBaseFolder(const char *path)
{
PS_SetBaseFolder(path);
} //end of the function PC_SetBaseFolder
diff --git a/code/botlib/l_precomp.h b/code/botlib/l_precomp.h
index aae2dd43d..1095cd700 100644
--- a/code/botlib/l_precomp.h
+++ b/code/botlib/l_precomp.h
@@ -152,7 +152,7 @@ void PC_SetIncludePath(source_t *source, char *path);
//set the punction set
void PC_SetPunctuations(source_t *source, punctuation_t *p);
//set the base folder to load files from
-void PC_SetBaseFolder(char *path);
+void PC_SetBaseFolder(const char *path);
//load a source file
source_t *LoadSourceFile(const char *filename);
//load a source from memory
@@ -181,7 +181,7 @@ typedef struct pc_token_s
#endif //BSPC
//
-int PC_LoadSourceHandle(const char *filename);
+int PC_LoadSourceHandle(const char *filename, const char *basepath);
int PC_FreeSourceHandle(int handle);
int PC_ReadTokenHandle(int handle, pc_token_t *pc_token);
void PC_UnreadLastTokenHandle( int handle );
diff --git a/code/botlib/l_script.c b/code/botlib/l_script.c
index 1597cf825..00f59c417 100644
--- a/code/botlib/l_script.c
+++ b/code/botlib/l_script.c
@@ -1446,7 +1446,10 @@ void FreeScript(script_t *script)
// Returns: -
// Changes Globals: -
//============================================================================
-void PS_SetBaseFolder(char *path)
+void PS_SetBaseFolder(const char *path)
{
- Com_sprintf(basefolder, sizeof(basefolder), "%s", path);
+ if (path)
+ Com_sprintf(basefolder, sizeof(basefolder), "%s", path);
+ else
+ basefolder[0] = '\0';
} //end of the function PS_SetBaseFolder
diff --git a/code/botlib/l_script.h b/code/botlib/l_script.h
index e5143f58e..5b79b5c01 100644
--- a/code/botlib/l_script.h
+++ b/code/botlib/l_script.h
@@ -246,7 +246,7 @@ script_t *LoadScriptMemory(char *ptr, int length, char *name);
//free a script
void FreeScript(script_t *script);
//set the base folder to load files from
-void PS_SetBaseFolder(char *path);
+void PS_SetBaseFolder(const char *path);
//print a script error with filename and line number
void QDECL ScriptError(script_t *script, char *str, ...) __attribute__ ((format (printf, 2, 3)));
//print a script warning with filename and line number
diff --git a/code/cgame/cg_main.c b/code/cgame/cg_main.c
index 9609cde65..062dbdab6 100644
--- a/code/cgame/cg_main.c
+++ b/code/cgame/cg_main.c
@@ -1666,9 +1666,9 @@ void CG_ParseMenu(const char *menuFile) {
pc_token_t token;
int handle;
- handle = trap_PC_LoadSource(menuFile);
+ handle = trap_PC_LoadSource(menuFile, NULL);
if (!handle)
- handle = trap_PC_LoadSource("ui/testhud.menu");
+ handle = trap_PC_LoadSource("ui/testhud.menu", NULL);
if (!handle)
return;
diff --git a/code/cgame/cg_syscalls.c b/code/cgame/cg_syscalls.c
index 16e9042c7..4163880a1 100644
--- a/code/cgame/cg_syscalls.c
+++ b/code/cgame/cg_syscalls.c
@@ -635,8 +635,8 @@ void trap_PC_RemoveAllGlobalDefines( void ) {
syscall( CG_PC_REMOVE_ALL_GLOBAL_DEFINES );
}
-int trap_PC_LoadSource( const char *filename ) {
- return syscall( CG_PC_LOAD_SOURCE, filename );
+int trap_PC_LoadSource( const char *filename, const char *basepath ) {
+ return syscall( CG_PC_LOAD_SOURCE, filename, basepath );
}
int trap_PC_FreeSource( int handle ) {
diff --git a/code/client/cl_cgame.c b/code/client/cl_cgame.c
index 8444c2a44..2750b842c 100644
--- a/code/client/cl_cgame.c
+++ b/code/client/cl_cgame.c
@@ -1485,7 +1485,7 @@ intptr_t CL_CgameSystemCalls( intptr_t *args ) {
botlib_export->PC_RemoveAllGlobalDefines();
return 0;
case CG_PC_LOAD_SOURCE:
- return botlib_export->PC_LoadSourceHandle( VMA(1) );
+ return botlib_export->PC_LoadSourceHandle( VMA(1), VMA(2) );
case CG_PC_FREE_SOURCE:
return botlib_export->PC_FreeSourceHandle( args[1] );
case CG_PC_READ_TOKEN:
diff --git a/code/game/ai_chat.c b/code/game/ai_chat.c
index fe7e2573d..6c005065e 100644
--- a/code/game/ai_chat.c
+++ b/code/game/ai_chat.c
@@ -41,19 +41,22 @@ Suite 120, Rockville, Maryland 20850 USA.
#include "g_local.h"
#include "../botlib/botlib.h"
#include "../botlib/be_aas.h"
-#include "../botlib/be_ea.h"
#include "../botlib/be_ai_char.h"
#include "../botlib/be_ai_chat.h"
#include "../botlib/be_ai_gen.h"
-#include "../botlib/be_ai_goal.h"
-#include "../botlib/be_ai_move.h"
-#include "../botlib/be_ai_weap.h"
+//
+#include "ai_ea.h"
+#include "ai_goal.h"
+#include "ai_move.h"
+#include "ai_weap.h"
//
#include "ai_main.h"
#include "ai_dmq3.h"
#include "ai_chat.h"
#include "ai_cmd.h"
+#include "ai_vcmd.h"
#include "ai_dmnet.h"
+#include "ai_team.h"
//
#include "chars.h" //characteristics
#include "inv.h" //indexes into the inventory
diff --git a/code/game/ai_cmd.c b/code/game/ai_cmd.c
index ac48383b6..9bb006f3d 100644
--- a/code/game/ai_cmd.c
+++ b/code/game/ai_cmd.c
@@ -41,18 +41,20 @@ Suite 120, Rockville, Maryland 20850 USA.
#include "g_local.h"
#include "../botlib/botlib.h"
#include "../botlib/be_aas.h"
-#include "../botlib/be_ea.h"
#include "../botlib/be_ai_char.h"
#include "../botlib/be_ai_chat.h"
#include "../botlib/be_ai_gen.h"
-#include "../botlib/be_ai_goal.h"
-#include "../botlib/be_ai_move.h"
-#include "../botlib/be_ai_weap.h"
+//
+#include "ai_ea.h"
+#include "ai_goal.h"
+#include "ai_move.h"
+#include "ai_weap.h"
//
#include "ai_main.h"
#include "ai_dmq3.h"
#include "ai_chat.h"
#include "ai_cmd.h"
+#include "ai_vcmd.h"
#include "ai_dmnet.h"
#include "ai_team.h"
//
diff --git a/code/game/ai_dmnet.c b/code/game/ai_dmnet.c
index e51fcbe6e..caecca261 100644
--- a/code/game/ai_dmnet.c
+++ b/code/game/ai_dmnet.c
@@ -41,25 +41,27 @@ Suite 120, Rockville, Maryland 20850 USA.
#include "g_local.h"
#include "../botlib/botlib.h"
#include "../botlib/be_aas.h"
-#include "../botlib/be_ea.h"
#include "../botlib/be_ai_char.h"
#include "../botlib/be_ai_chat.h"
#include "../botlib/be_ai_gen.h"
-#include "../botlib/be_ai_goal.h"
-#include "../botlib/be_ai_move.h"
-#include "../botlib/be_ai_weap.h"
+//
+#include "ai_ea.h"
+#include "ai_goal.h"
+#include "ai_move.h"
+#include "ai_weap.h"
//
#include "ai_main.h"
#include "ai_dmq3.h"
#include "ai_chat.h"
#include "ai_cmd.h"
+#include "ai_vcmd.h"
#include "ai_dmnet.h"
#include "ai_team.h"
-//data file headers
-#include "chars.h" //characteristics
-#include "inv.h" //indexes into the inventory
-#include "syn.h" //synonyms
-#include "match.h" //string matching types and vars
+//
+#include "chars.h" //characteristics
+#include "inv.h" //indexes into the inventory
+#include "syn.h" //synonyms
+#include "match.h" //string matching types and vars
// for the voice chats
#include "../../ui/menudef.h"
diff --git a/code/game/ai_dmq3.c b/code/game/ai_dmq3.c
index 00d202476..99006551a 100644
--- a/code/game/ai_dmq3.c
+++ b/code/game/ai_dmq3.c
@@ -42,18 +42,20 @@ Suite 120, Rockville, Maryland 20850 USA.
#include "g_local.h"
#include "../botlib/botlib.h"
#include "../botlib/be_aas.h"
-#include "../botlib/be_ea.h"
#include "../botlib/be_ai_char.h"
#include "../botlib/be_ai_chat.h"
#include "../botlib/be_ai_gen.h"
-#include "../botlib/be_ai_goal.h"
-#include "../botlib/be_ai_move.h"
-#include "../botlib/be_ai_weap.h"
+//
+#include "ai_ea.h"
+#include "ai_goal.h"
+#include "ai_move.h"
+#include "ai_weap.h"
//
#include "ai_main.h"
#include "ai_dmq3.h"
#include "ai_chat.h"
#include "ai_cmd.h"
+#include "ai_vcmd.h"
#include "ai_dmnet.h"
#include "ai_team.h"
//
@@ -89,10 +91,10 @@ vmCvar_t bot_nochat;
vmCvar_t bot_testrchat;
vmCvar_t bot_challenge;
vmCvar_t bot_predictobstacles;
+vmCvar_t bot_droppedweight;
+vmCvar_t bot_offhandgrapple;
vmCvar_t g_spSkill;
-extern vmCvar_t bot_developer;
-
vec3_t lastteleport_origin; //last teleport event origin
float lastteleport_time; //last teleport event time
int max_bspmodelindex; //maximum BSP model index
@@ -5405,6 +5407,8 @@ void BotSetupDeathmatchAI(void) {
trap_Cvar_Register(&bot_testrchat, "bot_testrchat", "0", 0);
trap_Cvar_Register(&bot_challenge, "bot_challenge", "0", 0);
trap_Cvar_Register(&bot_predictobstacles, "bot_predictobstacles", "1", 0);
+ trap_Cvar_Register(&bot_offhandgrapple, "bot_offhandgrapple", "0", 0);
+ trap_Cvar_Register(&bot_droppedweight, "bot_droppedweight", "1000", 0);
trap_Cvar_Register(&g_spSkill, "g_spSkill", "2", 0);
//
if (gametype == GT_CTF) {
diff --git a/code/game/ai_dmq3.h b/code/game/ai_dmq3.h
index 9ab2cb2f6..c6ec73de5 100644
--- a/code/game/ai_dmq3.h
+++ b/code/game/ai_dmq3.h
@@ -203,6 +203,8 @@ extern vmCvar_t bot_fastchat;
extern vmCvar_t bot_nochat;
extern vmCvar_t bot_testrchat;
extern vmCvar_t bot_challenge;
+extern vmCvar_t bot_droppedweight;
+extern vmCvar_t bot_offhandgrapple;
extern bot_goal_t ctf_redflag;
extern bot_goal_t ctf_blueflag;
diff --git a/code/botlib/be_ea.c b/code/game/ai_ea.c
similarity index 92%
rename from code/botlib/be_ea.c
rename to code/game/ai_ea.c
index 832111936..b597fb387 100644
--- a/code/botlib/be_ea.c
+++ b/code/game/ai_ea.c
@@ -37,19 +37,36 @@ Suite 120, Rockville, Maryland 20850 USA.
*
*****************************************************************************/
-#include "../qcommon/q_shared.h"
-#include "l_memory.h"
-#include "l_script.h"
-#include "l_precomp.h"
-#include "l_struct.h"
-#include "botlib.h"
-#include "be_interface.h"
-#include "be_ea.h"
+#include "g_local.h"
+#include "../botlib/botlib.h"
+#include "../botlib/be_aas.h"
+#include "../botlib/be_ai_char.h"
+#include "../botlib/be_ai_chat.h"
+#include "../botlib/be_ai_gen.h"
+//
+#include "ai_ea.h"
+#include "ai_goal.h"
+#include "ai_move.h"
+#include "ai_weap.h"
+#include "ai_weight.h"
+//
+#include "ai_main.h"
+#include "ai_dmq3.h"
+#include "ai_chat.h"
+#include "ai_cmd.h"
+#include "ai_vcmd.h"
+#include "ai_dmnet.h"
+#include "ai_team.h"
+//
+#include "chars.h" //characteristics
+#include "inv.h" //indexes into the inventory
+#include "syn.h" //synonyms
+#include "match.h" //string matching types and vars
#define MAX_USERMOVE 400
#define MAX_COMMANDARGUMENTS 10
-bot_input_t *botinputs;
+bot_input_t botinputs[MAX_CLIENTS];
//===========================================================================
//
@@ -59,7 +76,7 @@ bot_input_t *botinputs;
//===========================================================================
void EA_Say(int client, char *str)
{
- botimport.BotClientCommand(client, va("say %s", str) );
+ trap_ClientCommand(client, va("say %s", str));
} //end of the function EA_Say
//===========================================================================
//
@@ -69,7 +86,7 @@ void EA_Say(int client, char *str)
//===========================================================================
void EA_SayTeam(int client, char *str)
{
- botimport.BotClientCommand(client, va("say_team %s", str));
+ trap_ClientCommand(client, va("say_team %s", str));
} //end of the function EA_SayTeam
//===========================================================================
//
@@ -79,7 +96,7 @@ void EA_SayTeam(int client, char *str)
//===========================================================================
void EA_Tell(int client, int clientto, char *str)
{
- botimport.BotClientCommand(client, va("tell %d, %s", clientto, str));
+ trap_ClientCommand(client, va("tell %d, %s", clientto, str));
} //end of the function EA_SayTeam
//===========================================================================
//
@@ -89,7 +106,7 @@ void EA_Tell(int client, int clientto, char *str)
//===========================================================================
void EA_UseItem(int client, char *it)
{
- botimport.BotClientCommand(client, va("use %s", it));
+ trap_ClientCommand(client, va("use %s", it));
} //end of the function EA_UseItem
//===========================================================================
//
@@ -99,7 +116,7 @@ void EA_UseItem(int client, char *it)
//===========================================================================
void EA_DropItem(int client, char *it)
{
- botimport.BotClientCommand(client, va("drop %s", it));
+ trap_ClientCommand(client, va("drop %s", it));
} //end of the function EA_DropItem
//===========================================================================
//
@@ -109,7 +126,7 @@ void EA_DropItem(int client, char *it)
//===========================================================================
void EA_UseInv(int client, char *inv)
{
- botimport.BotClientCommand(client, va("invuse %s", inv));
+ trap_ClientCommand(client, va("invuse %s", inv));
} //end of the function EA_UseInv
//===========================================================================
//
@@ -119,7 +136,7 @@ void EA_UseInv(int client, char *inv)
//===========================================================================
void EA_DropInv(int client, char *inv)
{
- botimport.BotClientCommand(client, va("invdrop %s", inv));
+ trap_ClientCommand(client, va("invdrop %s", inv));
} //end of the function EA_DropInv
//===========================================================================
//
@@ -143,7 +160,7 @@ void EA_Gesture(int client)
//===========================================================================
void EA_Command(int client, char *command)
{
- botimport.BotClientCommand(client, command);
+ trap_ClientCommand(client, command);
} //end of the function EA_Command
//===========================================================================
//
@@ -467,8 +484,7 @@ void EA_ResetInput(int client)
int EA_Setup(void)
{
//initialize the bot inputs
- botinputs = (bot_input_t *) GetClearedHunkMemory(
- botlibglobals.maxclients * sizeof(bot_input_t));
+ Com_Memset(botinputs, 0, sizeof (botinputs));
return BLERR_NOERROR;
} //end of the function EA_Setup
//===========================================================================
@@ -479,6 +495,5 @@ int EA_Setup(void)
//===========================================================================
void EA_Shutdown(void)
{
- FreeMemory(botinputs);
- botinputs = NULL;
+
} //end of the function EA_Shutdown
diff --git a/code/botlib/be_ea.h b/code/game/ai_ea.h
similarity index 68%
rename from code/botlib/be_ea.h
rename to code/game/ai_ea.h
index 91df8e140..d46fd9522 100644
--- a/code/botlib/be_ea.h
+++ b/code/game/ai_ea.h
@@ -38,6 +38,44 @@ Suite 120, Rockville, Maryland 20850 USA.
*
*****************************************************************************/
+#ifndef __AI_EA_H__
+#define __AI_EA_H__
+
+//action flags
+#define ACTION_ATTACK 0x00000001
+#define ACTION_USE 0x00000002
+#define ACTION_RESPAWN 0x00000008
+#define ACTION_JUMP 0x00000010
+#define ACTION_MOVEUP 0x00000020
+#define ACTION_CROUCH 0x00000080
+#define ACTION_MOVEDOWN 0x00000100
+#define ACTION_MOVEFORWARD 0x00000200
+#define ACTION_MOVEBACK 0x00000800
+#define ACTION_MOVELEFT 0x00001000
+#define ACTION_MOVERIGHT 0x00002000
+#define ACTION_DELAYEDJUMP 0x00008000
+#define ACTION_TALK 0x00010000
+#define ACTION_GESTURE 0x00020000
+#define ACTION_WALK 0x00080000
+#define ACTION_AFFIRMATIVE 0x00100000
+#define ACTION_NEGATIVE 0x00200000
+#define ACTION_GETFLAG 0x00800000
+#define ACTION_GUARDBASE 0x01000000
+#define ACTION_PATROL 0x02000000
+#define ACTION_FOLLOWME 0x08000000
+#define ACTION_JUMPEDLASTFRAME 0x10000000
+
+//the bot input, will be converted to a usercmd_t
+typedef struct bot_input_s
+{
+ float thinktime; //time since last output (in seconds)
+ vec3_t dir; //movement direction
+ float speed; //speed in the range [0, 400]
+ vec3_t viewangles; //the view angles
+ int actionflags; //one of the ACTION_? flags
+ int weapon; //weapon to use
+} bot_input_t;
+
//ClientCommand elementary actions
void EA_Say(int client, char *str);
void EA_SayTeam(int client, char *str);
@@ -72,3 +110,5 @@ void EA_ResetInput(int client);
//setup and shutdown routines
int EA_Setup(void);
void EA_Shutdown(void);
+
+#endif // __AI_EA_H__
diff --git a/code/botlib/be_ai_goal.c b/code/game/ai_goal.c
similarity index 78%
rename from code/botlib/be_ai_goal.c
rename to code/game/ai_goal.c
index 2af921ff8..2686d1cc1 100644
--- a/code/botlib/be_ai_goal.c
+++ b/code/game/ai_goal.c
@@ -37,23 +37,34 @@ Suite 120, Rockville, Maryland 20850 USA.
*
*****************************************************************************/
-#include "../qcommon/q_shared.h"
-#include "../game/bg_public.h"
-#include "l_utils.h"
-#include "l_libvar.h"
-#include "l_memory.h"
-#include "l_log.h"
-#include "l_script.h"
-#include "l_precomp.h"
-#include "l_struct.h"
-#include "aasfile.h"
-#include "botlib.h"
-#include "be_aas.h"
-#include "be_aas_funcs.h"
-#include "be_interface.h"
-#include "be_ai_weight.h"
-#include "be_ai_goal.h"
-#include "be_ai_move.h"
+#include "g_local.h"
+#include "../botlib/botlib.h"
+#include "../botlib/be_aas.h"
+#include "../botlib/be_ai_char.h"
+#include "../botlib/be_ai_chat.h"
+#include "../botlib/be_ai_gen.h"
+//
+#include "ai_ea.h"
+#include "ai_goal.h"
+#include "ai_move.h"
+#include "ai_weap.h"
+#include "ai_weight.h"
+//
+#include "ai_main.h"
+#include "ai_dmq3.h"
+#include "ai_chat.h"
+#include "ai_cmd.h"
+#include "ai_vcmd.h"
+#include "ai_dmnet.h"
+#include "ai_team.h"
+//
+#include "chars.h" //characteristics
+#include "inv.h" //indexes into the inventory
+#include "syn.h" //synonyms
+#include "match.h" //string matching types and vars
+
+entityType_t trap_AAS_EntityType(int ent);
+int trap_AAS_EntityModelindex(int ent);
//#define DEBUG_AI_GOAL
#ifdef RANDOMIZE
@@ -75,15 +86,6 @@ Suite 120, Rockville, Maryland 20850 USA.
#define IFL_NOTBOT 8 //bot should never go for this
#define IFL_ROAM 16 //bot roam goal
-//location in the map "target_location"
-typedef struct maplocation_s
-{
- vec3_t origin;
- int areanum;
- char name[MAX_EPAIRKEY];
- struct maplocation_s *next;
-} maplocation_t;
-
//camp spots "info_camp"
typedef struct campspot_s
{
@@ -148,43 +150,20 @@ structdef_t iteminfo_struct =
typedef struct itemconfig_s
{
int numiteminfo;
- iteminfo_t *iteminfo;
+ iteminfo_t iteminfo[MAX_ITEMS];
} itemconfig_t;
-//goal state
-typedef struct bot_goalstate_s
-{
- struct weightconfig_s *itemweightconfig; //weight config
- int *itemweightindex; //index from item to weight
- //
- int client; //client using this goal state
- int lastreachabilityarea; //last area with reachabilities the bot was in
- //
- bot_goal_t goalstack[MAX_GOALSTACK]; //goal stack
- int goalstacktop; //the top of the goal stack
- //
- int avoidgoals[MAX_AVOIDGOALS]; //goals to avoid
- float avoidgoaltimes[MAX_AVOIDGOALS]; //times to avoid the goals
-} bot_goalstate_t;
-
-bot_goalstate_t *botgoalstates[MAX_CLIENTS + 1]; // FIXME: init?
+static bot_goalstate_t botgoalstates[MAX_CLIENTS + 1]; // FIXME: init?
//item configuration
+static itemconfig_t bot_itemconfig;
itemconfig_t *itemconfig = NULL;
//level items
levelitem_t *levelitemheap = NULL;
levelitem_t *freelevelitems = NULL;
levelitem_t *levelitems = NULL;
int numlevelitems = 0;
-//map locations
-maplocation_t *maplocations = NULL;
//camp spots
campspot_t *campspots = NULL;
-//use single player entities
-qboolean g_singlePlayerEntities = qfalse;
-//use team gametype entities
-qboolean g_teamplayEntities = qfalse;
-//additional dropped item weight
-libvar_t *droppedweight = NULL;
//========================================================================
//
@@ -196,15 +175,17 @@ bot_goalstate_t *BotGoalStateFromHandle(int handle)
{
if (handle <= 0 || handle > MAX_CLIENTS)
{
- botimport.Print(PRT_FATAL, "goal state handle %d out of range\n", handle);
+ BotAI_Print(PRT_FATAL, "goal state handle %d out of range\n", handle);
return NULL;
} //end if
+ /*
if (!botgoalstates[handle])
{
- botimport.Print(PRT_FATAL, "invalid goal state %d\n", handle);
+ BotAI_Print(PRT_FATAL, "invalid goal state %d\n", handle);
return NULL;
} //end if
- return botgoalstates[handle];
+ */
+ return &botgoalstates[handle];
} //end of the function BotGoalStateFromHandle
//===========================================================================
//
@@ -259,59 +240,44 @@ void BotMutateGoalFuzzyLogic(int goalstate, float range)
//===========================================================================
itemconfig_t *LoadItemConfig(char *filename)
{
- int max_iteminfo;
- token_t token;
- char path[MAX_PATH];
- source_t *source;
+ pc_token_t token;
+ char path[MAX_QPATH];
+ int source;
itemconfig_t *ic;
iteminfo_t *ii;
- max_iteminfo = (int) LibVarValue("max_iteminfo", "256");
- if (max_iteminfo < 0)
- {
- botimport.Print(PRT_ERROR, "max_iteminfo = %d\n", max_iteminfo);
- max_iteminfo = 256;
- LibVarSet( "max_iteminfo", "256" );
- }
-
- strncpy( path, filename, MAX_PATH );
- PC_SetBaseFolder(BOTFILESBASEFOLDER);
- source = LoadSourceFile( path );
+ strncpy( path, filename, MAX_QPATH );
+ source = trap_PC_LoadSource( path, BOTFILESBASEFOLDER );
if( !source ) {
- botimport.Print( PRT_ERROR, "counldn't load %s\n", path );
+ BotAI_Print( PRT_ERROR, "counldn't load %s\n", path );
return NULL;
} //end if
//initialize item config
- ic = (itemconfig_t *) GetClearedHunkMemory(sizeof(itemconfig_t) +
- max_iteminfo * sizeof(iteminfo_t));
- ic->iteminfo = (iteminfo_t *) ((char *) ic + sizeof(itemconfig_t));
+ ic = &bot_itemconfig;
+ Com_Memset( ic, 0, sizeof (itemconfig_t) );
ic->numiteminfo = 0;
//parse the item config file
- while(PC_ReadToken(source, &token))
+ while(trap_PC_ReadToken(source, &token))
{
if (!strcmp(token.string, "iteminfo"))
{
- if (ic->numiteminfo >= max_iteminfo)
+ if (ic->numiteminfo >= MAX_ITEMS)
{
- SourceError(source, "more than %d item info defined", max_iteminfo);
- FreeMemory(ic);
- FreeSource(source);
+ PC_SourceError(source, "more than %d item info defined", MAX_ITEMS);
+ trap_PC_FreeSource(source);
return NULL;
} //end if
ii = &ic->iteminfo[ic->numiteminfo];
Com_Memset(ii, 0, sizeof(iteminfo_t));
if (!PC_ExpectTokenType(source, TT_STRING, 0, &token))
{
- FreeMemory(ic);
- FreeSource(source);
+ trap_PC_FreeSource(source);
return NULL;
} //end if
- StripDoubleQuotes(token.string);
strncpy(ii->classname, token.string, sizeof(ii->classname)-1);
- if (!ReadStructure(source, &iteminfo_struct, (char *) ii))
+ if (!PC_ReadStructure(source, &iteminfo_struct, (void *) ii))
{
- FreeMemory(ic);
- FreeSource(source);
+ trap_PC_FreeSource(source);
return NULL;
} //end if
ii->number = ic->numiteminfo;
@@ -319,16 +285,15 @@ itemconfig_t *LoadItemConfig(char *filename)
} //end if
else
{
- SourceError(source, "unknown definition %s", token.string);
- FreeMemory(ic);
- FreeSource(source);
+ PC_SourceError(source, "unknown definition %s", token.string);
+ trap_PC_FreeSource(source);
return NULL;
} //end else
} //end while
- FreeSource(source);
+ trap_PC_FreeSource(source);
//
- if (!ic->numiteminfo) botimport.Print(PRT_WARNING, "no item info loaded\n");
- botimport.Print(PRT_DEVELOPER, "loaded %s\n", path);
+ if (!ic->numiteminfo) BotAI_Print(PRT_WARNING, "no item info loaded\n");
+ BotAI_Print(PRT_DEVELOPER, "loaded %s\n", path);
return ic;
} //end of the function LoadItemConfig
//===========================================================================
@@ -338,22 +303,23 @@ itemconfig_t *LoadItemConfig(char *filename)
// Returns: -
// Changes Globals: -
//===========================================================================
-int *ItemWeightIndex(weightconfig_t *iwc, itemconfig_t *ic)
+void ItemWeightIndex(const itemconfig_t *ic, weightconfig_t *iwc, int *index)
{
- int *index, i;
-
- //initialize item weight index
- index = (int *) GetClearedMemory(sizeof(int) * ic->numiteminfo);
+ int i;
for (i = 0; i < ic->numiteminfo; i++)
{
index[i] = FindFuzzyWeight(iwc, ic->iteminfo[i].classname);
- if (index[i] < 0)
+ if (index[i] < 0 && bot_developer.integer)
{
- Log_Write("item info %d \"%s\" has no fuzzy weight\r\n", i, ic->iteminfo[i].classname);
+ G_Printf("item info %d \"%s\" has no fuzzy weight\r\n", i, ic->iteminfo[i].classname);
} //end if
} //end for
- return index;
+ for ( ; i < MAX_ITEMS; i++ )
+ {
+ index[i] = -1;
+ } //end for
+ return;
} //end of the function ItemWeightIndex
//===========================================================================
//
@@ -363,18 +329,16 @@ int *ItemWeightIndex(weightconfig_t *iwc, itemconfig_t *ic)
//===========================================================================
void InitLevelItemHeap(void)
{
- int i, max_levelitems;
-
- if (levelitemheap) FreeMemory(levelitemheap);
+ int i;
+ static levelitem_t bot_levelitemheap[MAX_ITEMS];
- max_levelitems = (int) LibVarValue("max_levelitems", "256");
- levelitemheap = (levelitem_t *) GetClearedMemory(max_levelitems * sizeof(levelitem_t));
+ levelitemheap = bot_levelitemheap;
- for (i = 0; i < max_levelitems-1; i++)
+ for (i = 0; i < MAX_ITEMS-1; i++)
{
levelitemheap[i].next = &levelitemheap[i + 1];
} //end for
- levelitemheap[max_levelitems-1].next = NULL;
+ levelitemheap[MAX_ITEMS-1].next = NULL;
//
freelevelitems = levelitemheap;
} //end of the function InitLevelItemHeap
@@ -391,7 +355,7 @@ levelitem_t *AllocLevelItem(void)
li = freelevelitems;
if (!li)
{
- botimport.Print(PRT_FATAL, "out of level items\n");
+ BotAI_Print(PRT_FATAL, "out of level items\n");
return NULL;
} //end if
//
@@ -441,82 +405,54 @@ void RemoveLevelItemFromList(levelitem_t *li)
// Returns: -
// Changes Globals: -
//===========================================================================
-void BotFreeInfoEntities(void)
-{
- maplocation_t *ml, *nextml;
- campspot_t *cs, *nextcs;
-
- for (ml = maplocations; ml; ml = nextml)
- {
- nextml = ml->next;
- FreeMemory(ml);
- } //end for
- maplocations = NULL;
- for (cs = campspots; cs; cs = nextcs)
- {
- nextcs = cs->next;
- FreeMemory(cs);
- } //end for
- campspots = NULL;
-} //end of the function BotFreeInfoEntities
-//===========================================================================
-//
-// Parameter: -
-// Returns: -
-// Changes Globals: -
-//===========================================================================
void BotInitInfoEntities(void)
{
+ static qboolean bot_loadedInfoEntities = qfalse;
char classname[MAX_EPAIRKEY];
- maplocation_t *ml;
campspot_t *cs;
- int ent, numlocations, numcampspots;
+ int ent, numcampspots;
- BotFreeInfoEntities();
+ if ( bot_loadedInfoEntities ) {
+ return;
+ }
+ bot_loadedInfoEntities = qtrue;
//
- numlocations = 0;
numcampspots = 0;
- for (ent = AAS_NextBSPEntity(0); ent; ent = AAS_NextBSPEntity(ent))
+ for (ent = trap_AAS_NextBSPEntity(0); ent; ent = trap_AAS_NextBSPEntity(ent))
{
- if (!AAS_ValueForBSPEpairKey(ent, "classname", classname, MAX_EPAIRKEY)) continue;
+ if (!trap_AAS_ValueForBSPEpairKey(ent, "classname", classname, MAX_EPAIRKEY)) continue;
- //map locations
- if (!strcmp(classname, "target_location"))
+ if (!strcmp(classname, "info_camp"))
{
- ml = (maplocation_t *) GetClearedMemory(sizeof(maplocation_t));
- AAS_VectorForBSPEpairKey(ent, "origin", ml->origin);
- AAS_ValueForBSPEpairKey(ent, "message", ml->name, sizeof(ml->name));
- ml->areanum = AAS_PointAreaNum(ml->origin);
- ml->next = maplocations;
- maplocations = ml;
- numlocations++;
- } //end if
- //camp spots
- else if (!strcmp(classname, "info_camp"))
- {
- cs = (campspot_t *) GetClearedMemory(sizeof(campspot_t));
- AAS_VectorForBSPEpairKey(ent, "origin", cs->origin);
- //cs->origin[2] += 16;
- AAS_ValueForBSPEpairKey(ent, "message", cs->name, sizeof(cs->name));
- AAS_FloatForBSPEpairKey(ent, "range", &cs->range);
- AAS_FloatForBSPEpairKey(ent, "weight", &cs->weight);
- AAS_FloatForBSPEpairKey(ent, "wait", &cs->wait);
- AAS_FloatForBSPEpairKey(ent, "random", &cs->random);
- cs->areanum = AAS_PointAreaNum(cs->origin);
- if (!cs->areanum)
+ vec3_t origin;
+ int areanum;
+
+ trap_AAS_VectorForBSPEpairKey(ent, "origin", origin);
+ //origin[2] += 16;
+
+ areanum = trap_AAS_PointAreaNum(origin);
+ if (!areanum)
{
- botimport.Print(PRT_MESSAGE, "camp spot at %1.1f %1.1f %1.1f in solid\n", cs->origin[0], cs->origin[1], cs->origin[2]);
- FreeMemory(cs);
+ BotAI_Print(PRT_MESSAGE, "camp spot at %1.1f %1.1f %1.1f in solid\n", origin[0], origin[1], origin[2]);
continue;
} //end if
+
+ cs = (campspot_t *) G_Alloc(sizeof(campspot_t));
+ VectorCopy(origin, cs->origin);
+ trap_AAS_ValueForBSPEpairKey(ent, "message", cs->name, sizeof(cs->name));
+ trap_AAS_FloatForBSPEpairKey(ent, "range", &cs->range);
+ trap_AAS_FloatForBSPEpairKey(ent, "weight", &cs->weight);
+ trap_AAS_FloatForBSPEpairKey(ent, "wait", &cs->wait);
+ trap_AAS_FloatForBSPEpairKey(ent, "random", &cs->random);
+ cs->areanum = areanum;
+ //
cs->next = campspots;
campspots = cs;
//AAS_DrawPermanentCross(cs->origin, 4, LINECOLOR_YELLOW);
numcampspots++;
} //end else if
} //end for
- botimport.Print(PRT_DEVELOPER, "%d map locations\n", numlocations);
- botimport.Print(PRT_DEVELOPER, "%d camp spots\n", numcampspots);
+ BotAI_Print(PRT_DEVELOPER, "%d camp spots\n", numcampspots);
} //end of the function BotInitInfoEntities
//===========================================================================
//
@@ -532,7 +468,7 @@ void BotInitLevelItems(void)
int ent, goalareanum;
itemconfig_t *ic;
levelitem_t *li;
- bsp_trace_t trace;
+ trace_t trace;
//initialize the map locations and camp spots
BotInitInfoEntities();
@@ -546,23 +482,23 @@ void BotInitLevelItems(void)
if (!ic) return;
//if there's no AAS file loaded
- if (!AAS_Loaded()) return;
+ if (!trap_AAS_Loaded()) return;
//validate the modelindexes of the item info
for (i = 0; i < ic->numiteminfo; i++)
{
if (!ic->iteminfo[i].modelindex)
{
- Log_Write("item %s has modelindex 0", ic->iteminfo[i].classname);
+ BotAI_Print(PRT_DEVELOPER, "item %s has modelindex 0", ic->iteminfo[i].classname);
} //end if
} //end for
- for (ent = AAS_NextBSPEntity(0); ent; ent = AAS_NextBSPEntity(ent))
+ for (ent = trap_AAS_NextBSPEntity(0); ent; ent = trap_AAS_NextBSPEntity(ent))
{
- if (!AAS_ValueForBSPEpairKey(ent, "classname", classname, MAX_EPAIRKEY)) continue;
+ if (!trap_AAS_ValueForBSPEpairKey(ent, "classname", classname, MAX_EPAIRKEY)) continue;
//
spawnflags = 0;
- AAS_IntForBSPEpairKey(ent, "spawnflags", &spawnflags);
+ trap_AAS_IntForBSPEpairKey(ent, "spawnflags", &spawnflags);
//
for (i = 0; i < ic->numiteminfo; i++)
{
@@ -570,13 +506,13 @@ void BotInitLevelItems(void)
} //end for
if (i >= ic->numiteminfo)
{
- Log_Write("entity %s unknown item\r\n", classname);
+ BotAI_Print(PRT_DEVELOPER, "entity %s unknown item\r\n", classname);
continue;
} //end if
//get the origin of the item
- if (!AAS_VectorForBSPEpairKey(ent, "origin", origin))
+ if (!trap_AAS_VectorForBSPEpairKey(ent, "origin", origin))
{
- botimport.Print(PRT_ERROR, "item %s without origin\n", classname);
+ BotAI_Print(PRT_ERROR, "item %s without origin\n", classname);
continue;
} //end else
//
@@ -585,18 +521,17 @@ void BotInitLevelItems(void)
if (spawnflags & 1)
{
//if the item is not floating in water
- if (!(AAS_PointContents(origin) & CONTENTS_WATER))
+ if (!(trap_AAS_PointContents(origin) & CONTENTS_WATER))
{
VectorCopy(origin, end);
end[2] -= 32;
- trace = AAS_Trace(origin, ic->iteminfo[i].mins, ic->iteminfo[i].maxs, end, -1, CONTENTS_SOLID|CONTENTS_PLAYERCLIP);
+ trap_Trace(&trace, origin, ic->iteminfo[i].mins, ic->iteminfo[i].maxs, end, -1, CONTENTS_SOLID|CONTENTS_PLAYERCLIP);
//if the item not near the ground
if (trace.fraction >= 1)
{
//if the item is not reachable from a jumppad
- goalareanum = AAS_BestReachableFromJumpPadArea(origin, ic->iteminfo[i].mins, ic->iteminfo[i].maxs);
- Log_Write("item %s reachable from jumppad area %d\r\n", ic->iteminfo[i].classname, goalareanum);
- //botimport.Print(PRT_MESSAGE, "item %s reachable from jumppad area %d\r\n", ic->iteminfo[i].classname, goalareanum);
+ goalareanum = trap_AAS_BestReachableFromJumpPadArea(origin, ic->iteminfo[i].mins, ic->iteminfo[i].maxs);
+ BotAI_Print(PRT_DEVELOPER, "item %s reachable from jumppad area %d\r\n", ic->iteminfo[i].classname, goalareanum);
if (!goalareanum) continue;
} //end if
} //end if
@@ -610,25 +545,25 @@ void BotInitLevelItems(void)
li->entitynum = 0;
//
li->flags = 0;
- AAS_IntForBSPEpairKey(ent, "notfree", &value);
+ trap_AAS_IntForBSPEpairKey(ent, "notfree", &value);
if (value) li->flags |= IFL_NOTFREE;
- AAS_IntForBSPEpairKey(ent, "notteam", &value);
+ trap_AAS_IntForBSPEpairKey(ent, "notteam", &value);
if (value) li->flags |= IFL_NOTTEAM;
- AAS_IntForBSPEpairKey(ent, "notsingle", &value);
+ trap_AAS_IntForBSPEpairKey(ent, "notsingle", &value);
if (value) li->flags |= IFL_NOTSINGLE;
- AAS_IntForBSPEpairKey(ent, "notbot", &value);
+ trap_AAS_IntForBSPEpairKey(ent, "notbot", &value);
if (value) li->flags |= IFL_NOTBOT;
if (!strcmp(classname, "item_botroam"))
{
li->flags |= IFL_ROAM;
- AAS_FloatForBSPEpairKey(ent, "weight", &li->weight);
+ trap_AAS_FloatForBSPEpairKey(ent, "weight", &li->weight);
} //end if
//if not a stationary item
if (!(spawnflags & 1))
{
- if (!AAS_DropToFloor(origin, ic->iteminfo[i].mins, ic->iteminfo[i].maxs))
+ if (!trap_AAS_DropToFloor(origin, ic->iteminfo[i].mins, ic->iteminfo[i].maxs))
{
- botimport.Print(PRT_MESSAGE, "%s in solid at (%1.1f %1.1f %1.1f)\n",
+ BotAI_Print(PRT_MESSAGE, "%s in solid at (%1.1f %1.1f %1.1f)\n",
classname, origin[0], origin[1], origin[2]);
} //end if
} //end if
@@ -645,19 +580,19 @@ void BotInitLevelItems(void)
else
{
//get the item goal area and goal origin
- li->goalareanum = AAS_BestReachableArea(origin,
+ li->goalareanum = trap_AAS_BestReachableArea(origin,
ic->iteminfo[i].mins, ic->iteminfo[i].maxs,
li->goalorigin);
if (!li->goalareanum)
{
- botimport.Print(PRT_MESSAGE, "%s not reachable for bots at (%1.1f %1.1f %1.1f)\n",
+ BotAI_Print(PRT_MESSAGE, "%s not reachable for bots at (%1.1f %1.1f %1.1f)\n",
classname, origin[0], origin[1], origin[2]);
} //end if
} //end else
//
AddLevelItemToList(li);
} //end for
- botimport.Print(PRT_DEVELOPER, "found %d level items\n", numlevelitems);
+ BotAI_Print(PRT_DEVELOPER, "found %d level items\n", numlevelitems);
} //end of the function BotInitLevelItems
//===========================================================================
//
@@ -714,11 +649,11 @@ void BotDumpAvoidGoals(int goalstate)
if (!gs) return;
for (i = 0; i < MAX_AVOIDGOALS; i++)
{
- if (gs->avoidgoaltimes[i] >= AAS_Time())
+ if (gs->avoidgoaltimes[i] >= trap_AAS_Time())
{
BotGoalName(gs->avoidgoals[i], name, 32);
- Log_Write("avoid goal %s, number %d for %f seconds", name,
- gs->avoidgoals[i], gs->avoidgoaltimes[i] - AAS_Time());
+ BotAI_Print(PRT_DEVELOPER, "avoid goal %s, number %d for %f seconds", name,
+ gs->avoidgoals[i], gs->avoidgoaltimes[i] - trap_AAS_Time());
} //end if
} //end for
} //end of the function BotDumpAvoidGoals
@@ -738,7 +673,7 @@ void BotAddToAvoidGoals(bot_goalstate_t *gs, int number, float avoidtime)
if (gs->avoidgoals[i] == number)
{
gs->avoidgoals[i] = number;
- gs->avoidgoaltimes[i] = AAS_Time() + avoidtime;
+ gs->avoidgoaltimes[i] = trap_AAS_Time() + avoidtime;
return;
} //end if
} //end for
@@ -746,10 +681,10 @@ void BotAddToAvoidGoals(bot_goalstate_t *gs, int number, float avoidtime)
for (i = 0; i < MAX_AVOIDGOALS; i++)
{
//if this avoid goal has expired
- if (gs->avoidgoaltimes[i] < AAS_Time())
+ if (gs->avoidgoaltimes[i] < trap_AAS_Time())
{
gs->avoidgoals[i] = number;
- gs->avoidgoaltimes[i] = AAS_Time() + avoidtime;
+ gs->avoidgoaltimes[i] = trap_AAS_Time() + avoidtime;
return;
} //end if
} //end for
@@ -770,7 +705,7 @@ void BotRemoveFromAvoidGoals(int goalstate, int number)
//don't use the goals the bot wants to avoid
for (i = 0; i < MAX_AVOIDGOALS; i++)
{
- if (gs->avoidgoals[i] == number && gs->avoidgoaltimes[i] >= AAS_Time())
+ if (gs->avoidgoals[i] == number && gs->avoidgoaltimes[i] >= trap_AAS_Time())
{
gs->avoidgoaltimes[i] = 0;
return;
@@ -793,9 +728,9 @@ float BotAvoidGoalTime(int goalstate, int number)
//don't use the goals the bot wants to avoid
for (i = 0; i < MAX_AVOIDGOALS; i++)
{
- if (gs->avoidgoals[i] == number && gs->avoidgoaltimes[i] >= AAS_Time())
+ if (gs->avoidgoals[i] == number && gs->avoidgoaltimes[i] >= trap_AAS_Time())
{
- return gs->avoidgoaltimes[i] - AAS_Time();
+ return gs->avoidgoaltimes[i] - trap_AAS_Time();
} //end if
} //end for
return 0;
@@ -865,10 +800,10 @@ int BotGetLevelItemGoal(int index, char *name, bot_goal_t *goal)
for (; li; li = li->next)
{
//
- if (g_singlePlayerEntities) {
+ if (g_gametype.integer == GT_SINGLE_PLAYER) {
if (li->flags & IFL_NOTSINGLE) continue;
}
- if (g_teamplayEntities) {
+ if (g_gametype.integer >= GT_TEAM) {
if (li->flags & IFL_NOTTEAM) continue;
}
else {
@@ -886,7 +821,7 @@ int BotGetLevelItemGoal(int index, char *name, bot_goal_t *goal)
goal->number = li->number;
goal->flags = GFL_ITEM;
if (li->timeout) goal->flags |= GFL_DROPPED;
- //botimport.Print(PRT_MESSAGE, "found li %s\n", itemconfig->iteminfo[li->iteminfo].name);
+ //BotAI_Print(PRT_MESSAGE, "found li %s\n", itemconfig->iteminfo[li->iteminfo].name);
return li->number;
} //end if
} //end for
@@ -900,15 +835,18 @@ int BotGetLevelItemGoal(int index, char *name, bot_goal_t *goal)
//===========================================================================
int BotGetMapLocationGoal(char *name, bot_goal_t *goal)
{
- maplocation_t *ml;
+ gentity_t *eloc;
vec3_t mins = {-8, -8, -8}, maxs = {8, 8, 8};
- for (ml = maplocations; ml; ml = ml->next)
+ if (!level.locationLinked)
+ return qfalse;
+
+ for (eloc = level.locationHead; eloc; eloc = eloc->nextTrain)
{
- if (!Q_stricmp(ml->name, name))
+ if (!Q_stricmp(eloc->message, name))
{
- goal->areanum = ml->areanum;
- VectorCopy(ml->origin, goal->origin);
+ goal->areanum = eloc->areanum;
+ VectorCopy(eloc->r.currentOrigin, goal->origin);
goal->entitynum = 0;
VectorCopy(mins, goal->mins);
VectorCopy(maxs, goal->maxs);
@@ -960,14 +898,14 @@ void BotFindEntityForLevelItem(levelitem_t *li)
ic = itemconfig;
if (!itemconfig) return;
- for (ent = AAS_NextEntity(0); ent; ent = AAS_NextEntity(ent))
+ for (ent = BotNextEntity(0); ent; ent = BotNextEntity(ent))
{
//get the model index of the entity
- modelindex = AAS_EntityModelindex(ent);
+ modelindex = trap_AAS_EntityModelindex(ent);
//
if (!modelindex) continue;
//get info about the entity
- AAS_EntityInfo(ent, &entinfo);
+ BotEntityInfo(ent, &entinfo);
//if the entity is still moving
if (entinfo.origin[0] != entinfo.lastvisorigin[0] ||
entinfo.origin[1] != entinfo.lastvisorigin[1] ||
@@ -1007,7 +945,7 @@ void BotUpdateEntityItems(void)
if (li->timeout)
{
//timeout the item
- if (li->timeout < AAS_Time())
+ if (li->timeout < trap_AAS_Time())
{
RemoveLevelItemFromList(li);
FreeLevelItem(li);
@@ -1018,15 +956,15 @@ void BotUpdateEntityItems(void)
ic = itemconfig;
if (!itemconfig) return;
//
- for (ent = AAS_NextEntity(0); ent; ent = AAS_NextEntity(ent))
+ for (ent = BotNextEntity(0); ent; ent = BotNextEntity(ent))
{
- if (AAS_EntityType(ent) != ET_ITEM) continue;
+ if (trap_AAS_EntityType(ent) != ET_ITEM) continue;
//get the model index of the entity
- modelindex = AAS_EntityModelindex(ent);
+ modelindex = trap_AAS_EntityModelindex(ent);
//
if (!modelindex) continue;
//get info about the entity
- AAS_EntityInfo(ent, &entinfo);
+ BotEntityInfo(ent, &entinfo);
//FIXME: don't do this
//skip all floating items for now
//if (entinfo.groundent != ENTITYNUM_WORLD) continue;
@@ -1057,7 +995,7 @@ void BotUpdateEntityItems(void)
{
VectorCopy(entinfo.origin, li->origin);
//also update the goal area number
- li->goalareanum = AAS_BestReachableArea(li->origin,
+ li->goalareanum = trap_AAS_BestReachableArea(li->origin,
ic->iteminfo[li->iteminfo].mins, ic->iteminfo[li->iteminfo].maxs,
li->goalorigin);
} //end if
@@ -1072,10 +1010,10 @@ void BotUpdateEntityItems(void)
//if this level item is already linked
if (li->entitynum) continue;
//
- if (g_singlePlayerEntities) {
+ if (g_gametype.integer == GT_SINGLE_PLAYER) {
if (li->flags & IFL_NOTSINGLE) continue;
}
- if (g_teamplayEntities) {
+ if (g_gametype.integer >= GT_TEAM) {
if (li->flags & IFL_NOTTEAM) continue;
}
else {
@@ -1098,12 +1036,12 @@ void BotUpdateEntityItems(void)
//update the level item origin
VectorCopy(entinfo.origin, li->origin);
//also update the goal area number
- li->goalareanum = AAS_BestReachableArea(li->origin,
+ li->goalareanum = trap_AAS_BestReachableArea(li->origin,
ic->iteminfo[li->iteminfo].mins, ic->iteminfo[li->iteminfo].maxs,
li->goalorigin);
} //end if
#ifdef DEBUG
- Log_Write("linked item %s to an entity", ic->iteminfo[li->iteminfo].classname);
+ BotAI_Print(PRT_DEVELOPER, "linked item %s to an entity", ic->iteminfo[li->iteminfo].classname);
#endif //DEBUG
break;
} //end if
@@ -1133,21 +1071,21 @@ void BotUpdateEntityItems(void)
//origin of the item
VectorCopy(entinfo.origin, li->origin);
//get the item goal area and goal origin
- li->goalareanum = AAS_BestReachableArea(li->origin,
+ li->goalareanum = trap_AAS_BestReachableArea(li->origin,
ic->iteminfo[i].mins, ic->iteminfo[i].maxs,
li->goalorigin);
//never go for items dropped into jumppads
- if (AAS_AreaJumpPad(li->goalareanum))
+ if (trap_AAS_AreaJumpPad(li->goalareanum))
{
FreeLevelItem(li);
continue;
} //end if
//time this item out after 30 seconds
//dropped items disappear after 30 seconds
- li->timeout = AAS_Time() + 30;
+ li->timeout = trap_AAS_Time() + 30;
//add the level item to the list
AddLevelItemToList(li);
- //botimport.Print(PRT_MESSAGE, "found new level item %s\n", ic->iteminfo[i].classname);
+ //BotAI_Print(PRT_MESSAGE, "found new level item %s\n", ic->iteminfo[i].classname);
} //end for
/*
for (li = levelitems; li; li = li->next)
@@ -1175,7 +1113,7 @@ void BotDumpGoalStack(int goalstate)
for (i = 1; i <= gs->goalstacktop; i++)
{
BotGoalName(gs->goalstack[i].number, name, 32);
- Log_Write("%d: %s", i, name);
+ BotAI_Print(PRT_MESSAGE, "%d: %s", i, name);
} //end for
} //end of the function BotDumpGoalStack
//===========================================================================
@@ -1192,7 +1130,7 @@ void BotPushGoal(int goalstate, bot_goal_t *goal)
if (!gs) return;
if (gs->goalstacktop >= MAX_GOALSTACK-1)
{
- botimport.Print(PRT_ERROR, "goal heap overflow\n");
+ BotAI_Print(PRT_ERROR, "goal heap overflow\n");
BotDumpGoalStack(goalstate);
return;
} //end if
@@ -1284,7 +1222,7 @@ int BotChooseLTGItem(int goalstate, vec3_t origin, int *inventory, int travelfla
//get the area the bot is in
areanum = BotReachabilityArea(origin, gs->client);
//if the bot is in solid or if the area the bot is in has no reachability links
- if (!areanum || !AAS_AreaReachability(areanum))
+ if (!areanum || !trap_AAS_AreaReachability(areanum))
{
//use the last valid area the bot was in
areanum = gs->lastreachabilityarea;
@@ -1305,11 +1243,11 @@ int BotChooseLTGItem(int goalstate, vec3_t origin, int *inventory, int travelfla
//go through the items in the level
for (li = levelitems; li; li = li->next)
{
- if (g_singlePlayerEntities) {
+ if (g_gametype.integer == GT_SINGLE_PLAYER) {
if (li->flags & IFL_NOTSINGLE)
continue;
}
- if (g_teamplayEntities) {
+ if (g_gametype.integer >= GT_TEAM) {
if (li->flags & IFL_NOTTEAM)
continue;
}
@@ -1339,7 +1277,7 @@ int BotChooseLTGItem(int goalstate, vec3_t origin, int *inventory, int travelfla
#ifdef DROPPEDWEIGHT
//HACK: to make dropped items more attractive
if (li->timeout)
- weight += droppedweight->value;
+ weight += bot_droppedweight.value;
#endif //DROPPEDWEIGHT
//use weight scale for item_botroam
if (li->flags & IFL_ROAM) weight *= li->weight;
@@ -1347,7 +1285,7 @@ int BotChooseLTGItem(int goalstate, vec3_t origin, int *inventory, int travelfla
if (weight > 0)
{
//get the travel time towards the goal area
- t = AAS_AreaTravelTimeToGoalArea(areanum, origin, li->goalareanum, travelflags);
+ t = trap_AAS_AreaTravelTimeToGoalArea(areanum, origin, li->goalareanum, travelflags);
//if the goal is reachable
if (t > 0)
{
@@ -1382,10 +1320,10 @@ int BotChooseLTGItem(int goalstate, vec3_t origin, int *inventory, int travelfla
goal.flags = GFL_ROAM;
goal.iteminfo = 0;
//push the goal on the stack
- BotPushGoal(goalstate, &goal);
+ BotPushGoal(gs, &goal);
//
#ifdef DEBUG
- botimport.Print(PRT_MESSAGE, "chosen roam goal area %d\n", goal.areanum);
+ BotAI_Print(PRT_MESSAGE, "chosen roam goal area %d\n", goal.areanum);
#endif //DEBUG
return qtrue;
} //end if
@@ -1452,7 +1390,7 @@ int BotChooseNBGItem(int goalstate, vec3_t origin, int *inventory, int travelfla
//get the area the bot is in
areanum = BotReachabilityArea(origin, gs->client);
//if the bot is in solid or if the area the bot is in has no reachability links
- if (!areanum || !AAS_AreaReachability(areanum))
+ if (!areanum || !trap_AAS_AreaReachability(areanum))
{
//use the last valid area the bot was in
areanum = gs->lastreachabilityarea;
@@ -1463,7 +1401,7 @@ int BotChooseNBGItem(int goalstate, vec3_t origin, int *inventory, int travelfla
if (!areanum)
return qfalse;
//
- if (ltg) ltg_time = AAS_AreaTravelTimeToGoalArea(areanum, origin, ltg->areanum, travelflags);
+ if (ltg) ltg_time = trap_AAS_AreaTravelTimeToGoalArea(areanum, origin, ltg->areanum, travelflags);
else ltg_time = 99999;
//the item configuration
ic = itemconfig;
@@ -1476,11 +1414,11 @@ int BotChooseNBGItem(int goalstate, vec3_t origin, int *inventory, int travelfla
//go through the items in the level
for (li = levelitems; li; li = li->next)
{
- if (g_singlePlayerEntities) {
+ if (g_gametype.integer == GT_SINGLE_PLAYER) {
if (li->flags & IFL_NOTSINGLE)
continue;
}
- if (g_teamplayEntities) {
+ if (g_gametype.integer >= GT_TEAM) {
if (li->flags & IFL_NOTTEAM)
continue;
}
@@ -1510,7 +1448,7 @@ int BotChooseNBGItem(int goalstate, vec3_t origin, int *inventory, int travelfla
#ifdef DROPPEDWEIGHT
//HACK: to make dropped items more attractive
if (li->timeout)
- weight += droppedweight->value;
+ weight += bot_droppedweight.value;
#endif //DROPPEDWEIGHT
//use weight scale for item_botroam
if (li->flags & IFL_ROAM) weight *= li->weight;
@@ -1518,7 +1456,7 @@ int BotChooseNBGItem(int goalstate, vec3_t origin, int *inventory, int travelfla
if (weight > 0)
{
//get the travel time towards the goal area
- t = AAS_AreaTravelTimeToGoalArea(areanum, origin, li->goalareanum, travelflags);
+ t = trap_AAS_AreaTravelTimeToGoalArea(areanum, origin, li->goalareanum, travelflags);
//if the goal is reachable
if (t > 0 && t < maxtime)
{
@@ -1535,7 +1473,7 @@ int BotChooseNBGItem(int goalstate, vec3_t origin, int *inventory, int travelfla
if (ltg && !li->timeout)
{
//get the travel time from the goal to the long term goal
- t = AAS_AreaTravelTimeToGoalArea(li->goalareanum, li->goalorigin, ltg->areanum, travelflags);
+ t = trap_AAS_AreaTravelTimeToGoalArea(li->goalareanum, li->goalorigin, ltg->areanum, travelflags);
} //end if
//if the travel back is possible and doesn't take too long
if (t <= ltg_time)
@@ -1598,7 +1536,7 @@ int BotTouchingGoal(vec3_t origin, bot_goal_t *goal)
vec3_t safety_maxs = {0, 0, 0}; //{4, 4, 10};
vec3_t safety_mins = {0, 0, 0}; //{-4, -4, 0};
- AAS_PresenceTypeBoundingBox(PRESENCE_NORMAL, boxmins, boxmaxs);
+ trap_AAS_PresenceTypeBoundingBox(PRESENCE_NORMAL, boxmins, boxmaxs);
VectorSubtract(goal->mins, boxmaxs, absmins);
VectorSubtract(goal->maxs, boxmins, absmaxs);
VectorAdd(absmins, goal->origin, absmins);
@@ -1622,7 +1560,7 @@ int BotTouchingGoal(vec3_t origin, bot_goal_t *goal)
int BotItemGoalInVisButNotVisible(int viewer, vec3_t eye, vec3_t viewangles, bot_goal_t *goal)
{
aas_entityinfo_t entinfo;
- bsp_trace_t trace;
+ trace_t trace;
vec3_t middle;
if (!(goal->flags & GFL_ITEM)) return qfalse;
@@ -1631,7 +1569,7 @@ int BotItemGoalInVisButNotVisible(int viewer, vec3_t eye, vec3_t viewangles, bot
VectorScale(middle, 0.5, middle);
VectorAdd(goal->origin, middle, middle);
//
- trace = AAS_Trace(eye, NULL, NULL, middle, viewer, CONTENTS_SOLID);
+ trap_Trace(&trace, eye, NULL, NULL, middle, viewer, CONTENTS_SOLID);
//if the goal middle point is visible
if (trace.fraction >= 1)
{
@@ -1641,11 +1579,11 @@ int BotItemGoalInVisButNotVisible(int viewer, vec3_t eye, vec3_t viewangles, bot
return qfalse;
//
//if the entity data isn't valid
- AAS_EntityInfo(goal->entitynum, &entinfo);
+ BotEntityInfo(goal->entitynum, &entinfo);
//NOTE: for some wacko reason entities are sometimes
// not updated
//if (!entinfo.valid) return qtrue;
- if (entinfo.ltime < AAS_Time() - 0.5)
+ if (entinfo.ltime < trap_AAS_Time() - 0.5)
return qtrue;
} //end if
return qfalse;
@@ -1682,13 +1620,13 @@ int BotLoadItemWeights(int goalstate, char *filename)
gs->itemweightconfig = ReadWeightConfig(filename);
if (!gs->itemweightconfig)
{
- botimport.Print(PRT_FATAL, "couldn't load weights\n");
+ BotAI_Print(PRT_FATAL, "couldn't load weights\n");
return BLERR_CANNOTLOADITEMWEIGHTS;
} //end if
//if there's no item configuration
if (!itemconfig) return BLERR_CANNOTLOADITEMWEIGHTS;
//create the item weight index
- gs->itemweightindex = ItemWeightIndex(gs->itemweightconfig, itemconfig);
+ ItemWeightIndex(itemconfig, gs->itemweightconfig, gs->itemweightindex);
//everything went ok
return BLERR_NOERROR;
} //end of the function BotLoadItemWeights
@@ -1705,7 +1643,6 @@ void BotFreeItemWeights(int goalstate)
gs = BotGoalStateFromHandle(goalstate);
if (!gs) return;
if (gs->itemweightconfig) FreeWeightConfig(gs->itemweightconfig);
- if (gs->itemweightindex) FreeMemory(gs->itemweightindex);
} //end of the function BotFreeItemWeights
//===========================================================================
//
@@ -1715,18 +1652,8 @@ void BotFreeItemWeights(int goalstate)
//===========================================================================
int BotAllocGoalState(int client)
{
- int i;
-
- for (i = 1; i <= MAX_CLIENTS; i++)
- {
- if (!botgoalstates[i])
- {
- botgoalstates[i] = GetClearedMemory(sizeof(bot_goalstate_t));
- botgoalstates[i]->client = client;
- return i;
- } //end if
- } //end for
- return 0;
+ botgoalstates[client+1].client = client;
+ return client+1;
} //end of the function BotAllocGoalState
//========================================================================
//
@@ -1738,17 +1665,10 @@ void BotFreeGoalState(int handle)
{
if (handle <= 0 || handle > MAX_CLIENTS)
{
- botimport.Print(PRT_FATAL, "goal state handle %d out of range\n", handle);
- return;
- } //end if
- if (!botgoalstates[handle])
- {
- botimport.Print(PRT_FATAL, "invalid goal state handle %d\n", handle);
+ BotAI_Print(PRT_FATAL, "goal state handle %d out of range\n", handle);
return;
} //end if
BotFreeItemWeights(handle);
- FreeMemory(botgoalstates[handle]);
- botgoalstates[handle] = NULL;
} //end of the function BotFreeGoalState
//===========================================================================
//
@@ -1758,23 +1678,14 @@ void BotFreeGoalState(int handle)
//===========================================================================
int BotSetupGoalAI(void)
{
- char *filename;
-
- //check if single player
- g_singlePlayerEntities = LibVarValue("singleplayerentities", "0");
- //check if teamplay is on
- g_teamplayEntities = LibVarValue("teamplayentities", "0");
- //item configuration file
- filename = LibVarString("itemconfig", "items.c");
//load the item configuration
- itemconfig = LoadItemConfig(filename);
+ itemconfig = LoadItemConfig("items.c");
if (!itemconfig)
{
- botimport.Print(PRT_FATAL, "couldn't load item config\n");
+ BotAI_Print(PRT_FATAL, "couldn't load item config\n");
return BLERR_CANNOTLOADITEMCONFIG;
} //end if
- //
- droppedweight = LibVar("droppedweight", "1000");
+
//everything went ok
return BLERR_NOERROR;
} //end of the function BotSetupGoalAI
@@ -1786,23 +1697,10 @@ int BotSetupGoalAI(void)
//===========================================================================
void BotShutdownGoalAI(void)
{
- int i;
-
- if (itemconfig) FreeMemory(itemconfig);
itemconfig = NULL;
- if (levelitemheap) FreeMemory(levelitemheap);
levelitemheap = NULL;
+
freelevelitems = NULL;
levelitems = NULL;
numlevelitems = 0;
-
- BotFreeInfoEntities();
-
- for (i = 1; i <= MAX_CLIENTS; i++)
- {
- if (botgoalstates[i])
- {
- BotFreeGoalState(i);
- } //end if
- } //end for
} //end of the function BotShutdownGoalAI
diff --git a/code/botlib/be_ai_goal.h b/code/game/ai_goal.h
similarity index 71%
rename from code/botlib/be_ai_goal.h
rename to code/game/ai_goal.h
index cec2c06b8..570f87e3e 100644
--- a/code/botlib/be_ai_goal.h
+++ b/code/game/ai_goal.h
@@ -57,6 +57,22 @@ typedef struct bot_goal_s
int iteminfo; //item information
} bot_goal_t;
+//goal state
+typedef struct bot_goalstate_s
+{
+ struct weightconfig_s *itemweightconfig; //weight config
+ int itemweightindex[MAX_ITEMS]; //index from item to weight
+ //
+ int client; //client using this goal state
+ int lastreachabilityarea; //last area with reachabilities the bot was in
+ //
+ bot_goal_t goalstack[MAX_GOALSTACK]; //goal stack
+ int goalstacktop; //the top of the goal stack
+ //
+ int avoidgoals[MAX_AVOIDGOALS]; //goals to avoid
+ float avoidgoaltimes[MAX_AVOIDGOALS]; //times to avoid the goals
+} bot_goalstate_t;
+
//reset the whole goal state, but keep the item weights
void BotResetGoalState(int goalstate);
//reset avoid goals
@@ -124,3 +140,34 @@ void BotFreeGoalState(int handle);
int BotSetupGoalAI(void);
//shut down the goal AI
void BotShutdownGoalAI(void);
+
+#define trap_BotAllocGoalState BotAllocGoalState
+#define trap_BotFreeGoalState BotFreeGoalState
+#define trap_BotResetGoalState BotResetGoalState
+#define trap_BotRemoveFromAvoidGoals BotRemoveFromAvoidGoals
+#define trap_BotResetAvoidGoals BotResetAvoidGoals
+#define trap_BotPushGoal BotPushGoal
+#define trap_BotPopGoal BotPopGoal
+#define trap_BotEmptyGoalStack BotEmptyGoalStack
+#define trap_BotDumpAvoidGoals BotDumpAvoidGoals
+#define trap_BotDumpGoalStack BotDumpGoalStack
+#define trap_BotGoalName BotGoalName
+#define trap_BotGetTopGoal BotGetTopGoal
+#define trap_BotGetSecondGoal BotGetSecondGoal
+#define trap_BotChooseLTGItem BotChooseLTGItem
+#define trap_BotChooseNBGItem BotChooseNBGItem
+#define trap_BotTouchingGoal BotTouchingGoal
+#define trap_BotItemGoalInVisButNotVisible BotItemGoalInVisButNotVisible
+#define trap_BotGetNextCampSpotGoal BotGetNextCampSpotGoal
+#define trap_BotGetMapLocationGoal BotGetMapLocationGoal
+#define trap_BotGetLevelItemGoal BotGetLevelItemGoal
+#define trap_BotAvoidGoalTime BotAvoidGoalTime
+#define trap_BotSetAvoidGoalTime BotSetAvoidGoalTime
+#define trap_BotInitLevelItems BotInitLevelItems
+#define trap_BotUpdateEntityItems BotUpdateEntityItems
+#define trap_BotLoadItemWeights BotLoadItemWeights
+#define trap_BotFreeItemWeights BotFreeItemWeights
+#define trap_BotInterbreedGoalFuzzyLogic BotInterbreedGoalFuzzyLogic
+#define trap_BotSaveGoalFuzzyLogic BotSaveGoalFuzzyLogic
+#define trap_BotMutateGoalFuzzyLogic BotMutateGoalFuzzyLogic
+
diff --git a/code/game/ai_main.c b/code/game/ai_main.c
index 95e6b8e4a..b1f441ca7 100644
--- a/code/game/ai_main.c
+++ b/code/game/ai_main.c
@@ -40,28 +40,30 @@ Suite 120, Rockville, Maryland 20850 USA.
#include "g_local.h"
-#include "../qcommon/q_shared.h"
-#include "../botlib/botlib.h" //bot lib interface
+#include "../botlib/botlib.h"
#include "../botlib/be_aas.h"
-#include "../botlib/be_ea.h"
#include "../botlib/be_ai_char.h"
#include "../botlib/be_ai_chat.h"
#include "../botlib/be_ai_gen.h"
-#include "../botlib/be_ai_goal.h"
-#include "../botlib/be_ai_move.h"
-#include "../botlib/be_ai_weap.h"
+//
+#include "ai_ea.h"
+#include "ai_goal.h"
+#include "ai_move.h"
+#include "ai_weap.h"
+#include "ai_weight.h"
//
#include "ai_main.h"
#include "ai_dmq3.h"
#include "ai_chat.h"
#include "ai_cmd.h"
-#include "ai_dmnet.h"
#include "ai_vcmd.h"
-
+#include "ai_dmnet.h"
+#include "ai_team.h"
//
-#include "chars.h"
-#include "inv.h"
-#include "syn.h"
+#include "chars.h" //characteristics
+#include "inv.h" //indexes into the inventory
+#include "syn.h" //synonyms
+#include "match.h" //string matching types and vars
#ifndef MAX_PATH
#define MAX_PATH 144
@@ -111,6 +113,12 @@ void QDECL BotAI_Print(int type, char *fmt, ...) {
va_end(ap);
switch(type) {
+ case PRT_DEVELOPER: {
+ if (bot_developer.integer) {
+ G_Printf("%s", str);
+ }
+ break;
+ }
case PRT_MESSAGE: {
G_Printf("%s", str);
break;
@@ -686,13 +694,78 @@ void BotInterbreeding(void) {
bot_interbreed = qtrue;
}
+/*
+==============
+BotNextEntity
+==============
+*/
+int BotNextEntity(int entnum) {
+ if (entnum < 0) entnum = -1;
+ while(++entnum < level.num_entities)
+ {
+ if (level.gentities[entnum].botvalid) return entnum;
+ }
+ return 0;
+}
+
/*
==============
BotEntityInfo
==============
*/
void BotEntityInfo(int entnum, aas_entityinfo_t *info) {
- trap_AAS_EntityInfo(entnum, info);
+ gentity_t *ent;
+
+ if (entnum < 0 || entnum >= level.num_entities)
+ {
+ BotAI_Print(PRT_FATAL, "BotEntityInfo: entnum %d out of range\n", entnum);
+ Com_Memset(info, 0, sizeof(aas_entityinfo_t));
+ return;
+ } //end if
+
+ ent = &g_entities[entnum];
+
+ info->valid = ent->botvalid;
+ info->type = ent->s.eType;
+ info->flags = ent->s.eFlags;
+ info->update_time = ent->update_time;
+ info->ltime = ent->ltime;
+ info->number = entnum;
+ VectorCopy(ent->r.currentOrigin, info->origin);
+ if (entnum < MAX_CLIENTS) {
+ VectorCopy(ent->s.apos.trBase, info->angles);
+ } else {
+ VectorCopy(ent->r.currentAngles, info->angles);
+ }
+ VectorCopy(ent->s.origin2, info->old_origin);
+ VectorCopy(ent->lastvisorigin, info->lastvisorigin);
+ VectorCopy(ent->s.mins, info->mins);
+ VectorCopy(ent->s.maxs, info->maxs);
+ info->groundent = ent->s.groundEntityNum;
+ if (ent->s.bmodel) info->solid = SOLID_BSP;
+ else info->solid = SOLID_BBOX;
+ info->modelindex = ent->s.modelindex;
+ info->modelindex2 = ent->s.modelindex2;
+ info->frame = ent->s.frame;
+ info->event = ent->s.event;
+ info->eventParm = ent->s.eventParm;
+ info->powerups = ent->s.powerups;
+ info->weapon = ent->s.weapon;
+ info->legsAnim = ent->s.legsAnim;
+ info->torsoAnim = ent->s.torsoAnim;
+}
+
+/*
+==============
+BotLibVarGetValue
+==============
+*/
+float BotLibVarGetValue( const char *name ) {
+ char value[20];
+
+ trap_BotLibVarGet( name, value, sizeof (value) );
+
+ return atof( value );
}
/*
@@ -1210,7 +1283,7 @@ int BotAISetupClient(int client, struct bot_settings_s *settings, qboolean resta
return qfalse;
}
//allocate a weapon state
- bs->ws = trap_BotAllocWeaponState();
+ bs->ws = trap_BotAllocWeaponState(client);
//load the weapon weights
trap_Characteristic_String(bs->character, CHARACTERISTIC_WEAPONWEIGHTS, filename, MAX_PATH);
errnum = trap_BotLoadWeaponWeights(bs->ws, filename);
@@ -1243,7 +1316,7 @@ int BotAISetupClient(int client, struct bot_settings_s *settings, qboolean resta
bs->entitynum = client;
bs->setupcount = 4;
bs->entergame_time = FloatTime();
- bs->ms = trap_BotAllocMoveState();
+ bs->ms = trap_BotAllocMoveState(client);
bs->walker = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_WALKER, 0, 1);
numbots++;
@@ -1376,6 +1449,9 @@ int BotAILoadMap( int restart ) {
if (!restart) {
trap_Cvar_Register( &mapname, "mapname", "", CVAR_SERVERINFO | CVAR_ROM );
trap_BotLibLoadMap( mapname.string );
+ //initialize the items in the level
+ BotInitLevelItems(); //ai_goal.h
+ BotSetBrushModelTypes(); //ai_move.h
}
for (i = 0; i < MAX_CLIENTS; i++) {
@@ -1420,6 +1496,8 @@ int BotAIStartFrame(int time) {
trap_Cvar_Update(&bot_saveroutingcache);
trap_Cvar_Update(&bot_pause);
trap_Cvar_Update(&bot_report);
+ trap_Cvar_Update(&bot_droppedweight);
+ trap_Cvar_Update(&bot_offhandgrapple);
if (bot_report.integer) {
// BotTeamplayReport();
@@ -1485,6 +1563,7 @@ int BotAIStartFrame(int time) {
//update entities in the botlib
for (i = 0; i < MAX_GENTITIES; i++) {
ent = &g_entities[i];
+ ent->botvalid = qfalse;
if (!ent->inuse) {
trap_BotLibUpdateEntity(i, NULL);
continue;
@@ -1516,6 +1595,10 @@ int BotAIStartFrame(int time) {
}
}
#endif
+ //
+ ent->botvalid = qtrue;
+ ent->update_time = trap_AAS_Time() - ent->ltime;
+ ent->ltime = trap_AAS_Time();
//
memset(&state, 0, sizeof(bot_entitystate_t));
//
@@ -1525,23 +1608,35 @@ int BotAIStartFrame(int time) {
} else {
VectorCopy(ent->r.currentAngles, state.angles);
}
- VectorCopy(ent->s.origin2, state.old_origin);
- VectorCopy(ent->s.mins, state.mins);
- VectorCopy(ent->s.maxs, state.maxs);
+ VectorCopy( ent->r.absmin, state.absmins );
+ VectorCopy( ent->r.absmax, state.absmaxs );
state.type = ent->s.eType;
state.flags = ent->s.eFlags;
- if (ent->s.bmodel) state.solid = SOLID_BSP;
- else state.solid = SOLID_BBOX;
- state.groundent = ent->s.groundEntityNum;
- state.modelindex = ent->s.modelindex;
- state.modelindex2 = ent->s.modelindex2;
- state.frame = ent->s.frame;
- state.event = ent->s.event;
- state.eventParm = ent->s.eventParm;
- state.powerups = ent->s.powerups;
- state.legsAnim = ent->s.legsAnim;
- state.torsoAnim = ent->s.torsoAnim;
- state.weapon = ent->s.weapon;
+ //
+ if (ent->s.bmodel) {
+ state.solid = SOLID_BSP;
+ //if the angles of the model changed
+ if ( !VectorCompare( state.angles, ent->lastAngles ) ) {
+ VectorCopy(state.angles, ent->lastAngles);
+ state.relink = qtrue;
+ }
+ } else {
+ state.solid = SOLID_BBOX;
+ VectorCopy(state.angles, ent->lastAngles);
+ }
+ //if the origin changed
+ if ( !VectorCompare( state.origin, ent->lastvisorigin ) ) {
+ VectorCopy( state.origin, ent->lastvisorigin );
+ state.relink = qtrue;
+ }
+ //if the bounding box size changed
+ if (!VectorCompare(ent->s.mins, ent->lastMins) ||
+ !VectorCompare(ent->s.maxs, ent->lastMaxs))
+ {
+ VectorCopy( ent->s.mins, ent->lastMins );
+ VectorCopy( ent->s.maxs, ent->lastMaxs );
+ state.relink = qtrue;
+ }
//
trap_BotLibUpdateEntity(i, &state);
}
@@ -1607,21 +1702,6 @@ int BotInitLibrary(void) {
//maximum number of aas links
trap_Cvar_VariableStringBuffer("max_aaslinks", buf, sizeof(buf));
if (strlen(buf)) trap_BotLibVarSet("max_aaslinks", buf);
- //maximum number of items in a level
- trap_Cvar_VariableStringBuffer("max_levelitems", buf, sizeof(buf));
- if (strlen(buf)) trap_BotLibVarSet("max_levelitems", buf);
- //single player entities
- if (g_gametype.integer == GT_SINGLE_PLAYER) {
- trap_BotLibVarSet("singleplayerentities", "1");
- } else {
- trap_BotLibVarSet("singleplayerentities", "0");
- }
- //team play entities
- if (g_gametype.integer > GT_TEAM) {
- trap_BotLibVarSet("teamplayentities", "1");
- } else {
- trap_BotLibVarSet("teamplayentities", "0");
- }
//bot developer mode and log file
trap_BotLibVarSet("bot_developer", bot_developer.string);
trap_Cvar_VariableStringBuffer("logfile", buf, sizeof(buf));
@@ -1699,6 +1779,14 @@ int BotAISetup( int restart ) {
errnum = BotInitLibrary();
if (errnum != BLERR_NOERROR) return qfalse;
+ errnum = EA_Setup(); //ai_ea.c
+ if (errnum != BLERR_NOERROR) return qfalse;
+ errnum = BotSetupWeaponAI(); //ai_weap.c
+ if (errnum != BLERR_NOERROR)return qfalse;
+ errnum = BotSetupGoalAI(); //ai_goal.c
+ if (errnum != BLERR_NOERROR) return qfalse;
+ errnum = BotSetupMoveAI(); //ai_move.c
+ if (errnum != BLERR_NOERROR) return qfalse;
return qtrue;
}
@@ -1723,6 +1811,13 @@ int BotAIShutdown( int restart ) {
}
else {
trap_BotLibShutdown();
+ //
+ BotShutdownMoveAI(); //ai_move.c
+ BotShutdownGoalAI(); //ai_goal.c
+ BotShutdownWeaponAI(); //ai_weap.c
+ BotShutdownWeights(); //ai_weight.c
+ //shut down bot elemantary actions
+ EA_Shutdown();
}
return qtrue;
}
diff --git a/code/game/ai_main.h b/code/game/ai_main.h
index 9af30bf3a..b2401ba98 100644
--- a/code/game/ai_main.h
+++ b/code/game/ai_main.h
@@ -281,12 +281,44 @@ typedef struct bot_state_s
int patrolflags; //patrol flags
} bot_state_t;
+//entity info
+typedef struct aas_entityinfo_s
+{
+ int valid; // true if updated this frame
+ int type; // entity type
+ int flags; // entity flags
+ float ltime; // local time
+ float update_time; // time between last and current update
+ int number; // number of the entity
+ vec3_t origin; // origin of the entity
+ vec3_t angles; // angles of the model
+ vec3_t old_origin; // for lerping
+ vec3_t lastvisorigin; // last visible origin
+ vec3_t mins; // bounding box minimums
+ vec3_t maxs; // bounding box maximums
+ int groundent; // ground entity
+ int solid; // solid type
+ int modelindex; // model used
+ int modelindex2; // weapons, CTF flags, etc
+ int frame; // model frame number
+ int event; // impulse events -- muzzle flashes, footsteps, etc
+ int eventParm; // even parameter
+ int powerups; // bit flags
+ int weapon; // determines weapon and flash model, etc
+ int legsAnim; // mask off ANIM_TOGGLEBIT
+ int torsoAnim; // mask off ANIM_TOGGLEBIT
+} aas_entityinfo_t;
+
//resets the whole bot state
void BotResetState(bot_state_t *bs);
//returns the number of bots in the game
int NumBots(void);
//returns info about the entity
void BotEntityInfo(int entnum, aas_entityinfo_t *info);
+//returns next entity number that's valid for bot AI or 0 if no more entities left
+int BotNextEntity(int entnum);
+//returns float valud of a libvar
+float BotLibVarGetValue(const char *name);
extern float floattime;
#define FloatTime() floattime
@@ -299,3 +331,5 @@ int BotAI_GetClientState( int clientNum, playerState_t *state );
int BotAI_GetEntityState( int entityNum, entityState_t *state );
int BotAI_GetSnapshotEntity( int clientNum, int sequence, entityState_t *state );
int BotTeamLeader(bot_state_t *bs);
+
+extern vmCvar_t bot_developer;
diff --git a/code/botlib/be_ai_move.c b/code/game/ai_move.c
similarity index 82%
rename from code/botlib/be_ai_move.c
rename to code/game/ai_move.c
index d63bdecc9..a606349e9 100644
--- a/code/botlib/be_ai_move.c
+++ b/code/game/ai_move.c
@@ -29,70 +29,58 @@ Suite 120, Rockville, Maryland 20850 USA.
*/
/*****************************************************************************
- * name: be_ai_move.c
+ * name: ai_move.c
*
* desc: bot movement AI
*
- * $Archive: /MissionPack/code/botlib/be_ai_move.c $
+ * $Archive: /MissionPack/code/game/ai_move.c $
*
*****************************************************************************/
-#include "../qcommon/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 "botlib.h"
-#include "be_aas.h"
-#include "be_aas_funcs.h"
-#include "be_interface.h"
-
-#include "be_ea.h"
-#include "be_ai_goal.h"
-#include "be_ai_move.h"
-
+#include "g_local.h"
+#include "../botlib/botlib.h"
+#include "../botlib/aasfile.h"
+#include "../botlib/be_aas.h"
+#include "../botlib/be_ai_char.h"
+#include "../botlib/be_ai_chat.h"
+#include "../botlib/be_ai_gen.h"
+//
+#include "ai_ea.h"
+#include "ai_goal.h"
+#include "ai_move.h"
+#include "ai_weap.h"
+#include "ai_weight.h"
+//
+#include "ai_main.h"
+#include "ai_dmq3.h"
+#include "ai_chat.h"
+#include "ai_cmd.h"
+#include "ai_vcmd.h"
+#include "ai_dmnet.h"
+#include "ai_team.h"
+//
+#include "chars.h" //characteristics
+#include "inv.h" //indexes into the inventory
+#include "syn.h" //synonyms
+#include "match.h" //string matching types and vars
+
+entityType_t trap_AAS_EntityType(int ent) { if (ent < 0 || ent >= MAX_GENTITIES) return 0; else return g_entities[ent].s.eType; }
+int trap_AAS_EntityModelindex(int ent) { if (ent < 0 || ent >= MAX_GENTITIES) return 0; else return g_entities[ent].s.modelindex; }
+#define trap_AAS_EntityModelNum trap_AAS_EntityModelindex
+
+// ai_dmnet.c just uses vectoangles directly
+#define Vector2Angles(v,a) vectoangles(v,a)
+
+// Moved function to game instead of adding trap
+#define trap_AAS_OriginOfMoverWithModelNum BotOriginOfMoverWithModelNum
+#define trap_AAS_BSPModelMinsMaxsOrigin BotBSPModelMinsMaxsOrigin
+
+static int trap_AAS_AreaPresenceType(int areanum) { aas_areainfo_t areainfo; trap_AAS_AreaInfo(areanum, &areainfo); return areainfo.presencetype; }
//#define DEBUG_AI_MOVE
//#define DEBUG_ELEVATOR
//#define DEBUG_GRAPPLE
-//movement state
-//NOTE: the moveflags MFL_ONGROUND, MFL_TELEPORTED, MFL_WATERJUMP and
-// MFL_GRAPPLEPULL must be set outside the movement code
-typedef struct bot_movestate_s
-{
- //input vars (all set outside the movement code)
- vec3_t origin; //origin of the bot
- vec3_t velocity; //velocity of the bot
- vec3_t viewoffset; //view offset
- int entitynum; //entity number of the bot
- int client; //client number of the bot
- float thinktime; //time the bot thinks
- int presencetype; //presencetype of the bot
- vec3_t viewangles; //view angles of the bot
- //state vars
- int areanum; //area the bot is in
- int lastareanum; //last area the bot was in
- int lastgoalareanum; //last goal area number
- int lastreachnum; //last reachability number
- vec3_t lastorigin; //origin previous cycle
- int reachareanum; //area number of the reachabilty
- int moveflags; //movement flags
- int jumpreach; //set when jumped
- float grapplevisible_time; //last time the grapple was visible
- float lastgrappledist; //last distance to the grapple end
- float reachability_time; //time to use current reachability
- int avoidreach[MAX_AVOIDREACH]; //reachabilities to avoid
- float avoidreachtimes[MAX_AVOIDREACH]; //times to avoid the reachabilities
- int avoidreachtries[MAX_AVOIDREACH]; //number of tries before avoiding
- //
- bot_avoidspot_t avoidspots[MAX_AVOIDSPOTS]; //spots to avoid
- int numavoidspots;
-} bot_movestate_t;
-
//used to avoid reachability links for some time after being used
#define AVOIDREACH
#define AVOIDREACH_TIME 6 //avoid links for 6 seconds after use
@@ -100,68 +88,21 @@ typedef struct bot_movestate_s
//prediction times
#define PREDICTIONTIME_JUMP 3 //in seconds
#define PREDICTIONTIME_MOVE 2 //in seconds
-
+//grapple commands
+#define CMD_GRAPPLEOFF "grappleoff"
+#define CMD_GRAPPLEON "grappleon"
+//
#define MODELTYPE_FUNC_PLAT 1
#define MODELTYPE_FUNC_BOB 2
#define MODELTYPE_FUNC_DOOR 3
#define MODELTYPE_FUNC_STATIC 4
-libvar_t *sv_maxstep;
-libvar_t *sv_maxbarrier;
-libvar_t *sv_gravity;
-libvar_t *weapindex_rocketlauncher;
-libvar_t *weapindex_bfg10k;
-libvar_t *weapindex_grapple;
-libvar_t *entitytypemissile;
-libvar_t *offhandgrapple;
-libvar_t *cmd_grappleoff;
-libvar_t *cmd_grappleon;
+float phys_maxbarrier;
//type of model, func_plat or func_bobbing
int modeltypes[MAX_MODELS];
-bot_movestate_t *botmovestates[MAX_CLIENTS+1];
+static bot_movestate_t botmovestates[MAX_CLIENTS+1];
-//========================================================================
-//
-// Parameter: -
-// Returns: -
-// Changes Globals: -
-//========================================================================
-int BotAllocMoveState(void)
-{
- int i;
-
- for (i = 1; i <= MAX_CLIENTS; i++)
- {
- if (!botmovestates[i])
- {
- botmovestates[i] = GetClearedMemory(sizeof(bot_movestate_t));
- return i;
- } //end if
- } //end for
- return 0;
-} //end of the function BotAllocMoveState
-//========================================================================
-//
-// Parameter: -
-// Returns: -
-// Changes Globals: -
-//========================================================================
-void BotFreeMoveState(int handle)
-{
- if (handle <= 0 || handle > MAX_CLIENTS)
- {
- botimport.Print(PRT_FATAL, "move state handle %d out of range\n", handle);
- return;
- } //end if
- if (!botmovestates[handle])
- {
- botimport.Print(PRT_FATAL, "invalid move state %d\n", handle);
- return;
- } //end if
- FreeMemory(botmovestates[handle]);
- botmovestates[handle] = NULL;
-} //end of the function BotFreeMoveState
//========================================================================
//
// Parameter: -
@@ -172,15 +113,17 @@ bot_movestate_t *BotMoveStateFromHandle(int handle)
{
if (handle <= 0 || handle > MAX_CLIENTS)
{
- botimport.Print(PRT_FATAL, "move state handle %d out of range\n", handle);
+ BotAI_Print(PRT_FATAL, "move state handle %d out of range\n", handle);
return NULL;
} //end if
+ /*
if (!botmovestates[handle])
{
- botimport.Print(PRT_FATAL, "invalid move state %d\n", handle);
+ BotAI_Print(PRT_FATAL, "invalid move state %d\n", handle);
return NULL;
} //end if
- return botmovestates[handle];
+ */
+ return &botmovestates[handle];
} //end of the function BotMoveStateFromHandle
//========================================================================
//
@@ -249,18 +192,18 @@ int BotFuzzyPointReachabilityArea(vec3_t origin)
vec3_t points[10], v, end;
firstareanum = 0;
- areanum = AAS_PointAreaNum(origin);
+ areanum = trap_AAS_PointAreaNum(origin);
if (areanum)
{
firstareanum = areanum;
- if (AAS_AreaReachability(areanum)) return areanum;
+ if (trap_AAS_AreaReachability(areanum)) return areanum;
} //end if
VectorCopy(origin, end);
end[2] += 4;
- numareas = AAS_TraceAreas(origin, end, areas, points, 10);
+ numareas = trap_AAS_TraceAreas(origin, end, areas, points, 10);
for (j = 0; j < numareas; j++)
{
- if (AAS_AreaReachability(areas[j])) return areas[j];
+ if (trap_AAS_AreaReachability(areas[j])) return areas[j];
} //end for
bestdist = 999999;
bestareanum = 0;
@@ -274,10 +217,10 @@ int BotFuzzyPointReachabilityArea(vec3_t origin)
end[0] += x * 8;
end[1] += y * 8;
end[2] += z * 12;
- numareas = AAS_TraceAreas(origin, end, areas, points, 10);
+ numareas = trap_AAS_TraceAreas(origin, end, areas, points, 10);
for (j = 0; j < numareas; j++)
{
- if (AAS_AreaReachability(areas[j]))
+ if (trap_AAS_AreaReachability(areas[j]))
{
VectorSubtract(points[j], origin, v);
dist = VectorLength(v);
@@ -306,50 +249,50 @@ int BotReachabilityArea(vec3_t origin, int client)
int modelnum, modeltype, reachnum, areanum;
aas_reachability_t reach;
vec3_t org, end, mins, maxs, up = {0, 0, 1};
- bsp_trace_t bsptrace;
+ trace_t bsptrace;
aas_trace_t trace;
//check if the bot is standing on something
- AAS_PresenceTypeBoundingBox(PRESENCE_CROUCH, mins, maxs);
+ trap_AAS_PresenceTypeBoundingBox(PRESENCE_CROUCH, mins, maxs);
VectorMA(origin, -3, up, end);
- bsptrace = AAS_Trace(origin, mins, maxs, end, client, CONTENTS_SOLID|CONTENTS_PLAYERCLIP);
- if (!bsptrace.startsolid && bsptrace.fraction < 1 && bsptrace.ent != ENTITYNUM_NONE)
+ trap_Trace(&bsptrace, origin, mins, maxs, end, client, CONTENTS_SOLID|CONTENTS_PLAYERCLIP);
+ if (!bsptrace.startsolid && bsptrace.fraction < 1 && bsptrace.entityNum != ENTITYNUM_NONE)
{
//if standing on the world the bot should be in a valid area
- if (bsptrace.ent == ENTITYNUM_WORLD)
+ if (bsptrace.entityNum == ENTITYNUM_WORLD)
{
return BotFuzzyPointReachabilityArea(origin);
} //end if
- modelnum = AAS_EntityModelindex(bsptrace.ent);
+ modelnum = trap_AAS_EntityModelindex(bsptrace.entityNum);
modeltype = modeltypes[modelnum];
//if standing on a func_plat or func_bobbing then the bot is assumed to be
//in the area the reachability points to
if (modeltype == MODELTYPE_FUNC_PLAT || modeltype == MODELTYPE_FUNC_BOB)
{
- reachnum = AAS_NextModelReachability(0, modelnum);
+ reachnum = trap_AAS_NextModelReachability(0, modelnum);
if (reachnum)
{
- AAS_ReachabilityFromNum(reachnum, &reach);
+ trap_AAS_ReachabilityFromNum(reachnum, &reach);
return reach.areanum;
} //end if
} //end else if
//if the bot is swimming the bot should be in a valid area
- if (AAS_Swimming(origin))
+ if (trap_AAS_Swimming(origin))
{
return BotFuzzyPointReachabilityArea(origin);
} //end if
//
areanum = BotFuzzyPointReachabilityArea(origin);
//if the bot is in an area with reachabilities
- if (areanum && AAS_AreaReachability(areanum)) return areanum;
+ if (areanum && trap_AAS_AreaReachability(areanum)) return areanum;
//trace down till the ground is hit because the bot is standing on some other entity
VectorCopy(origin, org);
VectorCopy(org, end);
end[2] -= 800;
- trace = AAS_TraceClientBBox(org, end, PRESENCE_CROUCH, -1);
+ trap_AAS_TraceClientBBox(&trace, org, end, PRESENCE_CROUCH, -1);
if (!trace.startsolid)
{
VectorCopy(trace.endpos, org);
@@ -385,7 +328,7 @@ int BotReachabilityArea(vec3_t origin, int testground)
{
VectorCopy(origin, end);
end[2] -= 800;
- trace = AAS_TraceClientBBox(origin, end, PRESENCE_CROUCH, -1);
+ trap_AAS_TraceClientBBox(&trace, origin, end, PRESENCE_CROUCH, -1);
if (!trace.startsolid)
{
VectorCopy(trace.endpos, org);
@@ -393,11 +336,11 @@ int BotReachabilityArea(vec3_t origin, int testground)
} //end if
firstareanum = 0;
- areanum = AAS_PointAreaNum(org);
+ areanum = trap_AAS_PointAreaNum(org);
if (areanum)
{
firstareanum = areanum;
- if (AAS_AreaReachability(areanum)) return areanum;
+ if (trap_AAS_AreaReachability(areanum)) return areanum;
} //end if
bestdist = 999999;
bestareanum = 0;
@@ -411,10 +354,10 @@ int BotReachabilityArea(vec3_t origin, int testground)
end[0] += x * 8;
end[1] += y * 8;
end[2] += z * 12;
- numareas = AAS_TraceAreas(org, end, areas, points, 10);
+ numareas = trap_AAS_TraceAreas(org, end, areas, points, 10);
for (j = 0; j < numareas; j++)
{
- if (AAS_AreaReachability(areas[j]))
+ if (trap_AAS_AreaReachability(areas[j]))
{
VectorSubtract(points[j], org, v);
dist = VectorLength(v);
@@ -432,12 +375,71 @@ int BotReachabilityArea(vec3_t origin, int testground)
if (!testground) break;
} //end for
//#ifdef DEBUG
- //botimport.Print(PRT_MESSAGE, "no reachability area\n");
+ //BotAI_Print(PRT_MESSAGE, "no reachability area\n");
//#endif //DEBUG
return firstareanum;
} //end of the function BotReachabilityArea*/
//===========================================================================
//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+int BotOriginOfMoverWithModelNum(int modelnum, vec3_t origin)
+{
+ int i;
+ gentity_t *ent;
+
+ for (i = 0; i < level.num_entities; i++)
+ {
+ ent = &level.gentities[i];
+ if (ent->s.eType == ET_MOVER)
+ {
+ if (ent->s.modelindex == modelnum)
+ {
+ VectorCopy(ent->r.currentOrigin, origin);
+ return qtrue;
+ } //end if
+ } //end if
+ } //end for
+ return qfalse;
+} //end of the function BotOriginOfMoverWithModelNum
+//===========================================================================
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+void BotBSPModelMinsMaxsOrigin(int modelnum, vec3_t angles, vec3_t mins, vec3_t maxs, vec3_t origin) {
+ int i;
+ gentity_t *ent;
+
+ for (i = 0; i < level.num_entities; i++)
+ {
+ ent = &level.gentities[i];
+ if (ent->s.eType == ET_MOVER)
+ {
+ if (ent->s.modelindex == modelnum)
+ {
+ if (angles) {
+ VectorCopy(ent->r.currentAngles, angles);
+ }
+ if (mins) {
+ VectorCopy(ent->s.mins, mins);
+ }
+ if (maxs) {
+ VectorCopy(ent->s.maxs, maxs);
+ }
+ if (origin) {
+ VectorCopy(ent->r.currentOrigin, origin);
+ }
+ return;
+ } //end if
+ } //end if
+ } //end for
+} //end of the function BotBSPModelMinsMaxsOrigin
+//===========================================================================
+//
// Parameter: -
// Returns: -
// Changes Globals: -
@@ -448,15 +450,15 @@ int BotOnMover(vec3_t origin, int entnum, aas_reachability_t *reach)
vec3_t mins, maxs, modelorigin, org, end;
vec3_t angles = {0, 0, 0};
vec3_t boxmins = {-16, -16, -8}, boxmaxs = {16, 16, 8};
- bsp_trace_t trace;
+ trace_t trace;
modelnum = reach->facenum & 0x0000FFFF;
//get some bsp model info
- AAS_BSPModelMinsMaxsOrigin(modelnum, angles, mins, maxs, NULL);
+ trap_AAS_BSPModelMinsMaxsOrigin(modelnum, angles, mins, maxs, NULL);
//
- if (!AAS_OriginOfMoverWithModelNum(modelnum, modelorigin))
+ if (!trap_AAS_OriginOfMoverWithModelNum(modelnum, modelorigin))
{
- botimport.Print(PRT_MESSAGE, "no entity with model %d\n", modelnum);
+ BotAI_Print(PRT_MESSAGE, "no entity with model %d\n", modelnum);
return qfalse;
} //end if
//
@@ -471,11 +473,11 @@ int BotOnMover(vec3_t origin, int entnum, aas_reachability_t *reach)
VectorCopy(origin, end);
end[2] -= 48;
//
- trace = AAS_Trace(org, boxmins, boxmaxs, end, entnum, CONTENTS_SOLID|CONTENTS_PLAYERCLIP);
+ trap_Trace(&trace, org, boxmins, boxmaxs, end, entnum, CONTENTS_SOLID|CONTENTS_PLAYERCLIP);
if (!trace.startsolid && !trace.allsolid)
{
//NOTE: the reachability face number is the model number of the elevator
- if (trace.ent != ENTITYNUM_NONE && AAS_EntityModelNum(trace.ent) == modelnum)
+ if (trace.entityNum != ENTITYNUM_NONE && trap_AAS_EntityModelNum(trace.entityNum) == modelnum)
{
return qtrue;
} //end if
@@ -496,11 +498,11 @@ int MoverDown(aas_reachability_t *reach)
modelnum = reach->facenum & 0x0000FFFF;
//get some bsp model info
- AAS_BSPModelMinsMaxsOrigin(modelnum, angles, mins, maxs, origin);
+ trap_AAS_BSPModelMinsMaxsOrigin(modelnum, angles, mins, maxs, origin);
//
- if (!AAS_OriginOfMoverWithModelNum(modelnum, origin))
+ if (!trap_AAS_OriginOfMoverWithModelNum(modelnum, origin))
{
- botimport.Print(PRT_MESSAGE, "no entity with model %d\n", modelnum);
+ BotAI_Print(PRT_MESSAGE, "no entity with model %d\n", modelnum);
return qfalse;
} //end if
//if the top of the plat is below the reachability start point
@@ -520,16 +522,16 @@ void BotSetBrushModelTypes(void)
Com_Memset(modeltypes, 0, MAX_MODELS * sizeof(int));
//
- for (ent = AAS_NextBSPEntity(0); ent; ent = AAS_NextBSPEntity(ent))
+ for (ent = trap_AAS_NextBSPEntity(0); ent; ent = trap_AAS_NextBSPEntity(ent))
{
- if (!AAS_ValueForBSPEpairKey(ent, "classname", classname, MAX_EPAIRKEY)) continue;
- if (!AAS_ValueForBSPEpairKey(ent, "model", model, MAX_EPAIRKEY)) continue;
+ if (!trap_AAS_ValueForBSPEpairKey(ent, "classname", classname, MAX_EPAIRKEY)) continue;
+ if (!trap_AAS_ValueForBSPEpairKey(ent, "model", model, MAX_EPAIRKEY)) continue;
if (model[0]) modelnum = atoi(model+1);
else modelnum = 0;
if (modelnum < 0 || modelnum >= MAX_MODELS)
{
- botimport.Print(PRT_MESSAGE, "entity %s model number out of range\n", classname);
+ BotAI_Print(PRT_MESSAGE, "entity %s model number out of range\n", classname);
continue;
} //end if
@@ -552,14 +554,14 @@ void BotSetBrushModelTypes(void)
int BotOnTopOfEntity(bot_movestate_t *ms)
{
vec3_t mins, maxs, end, up = {0, 0, 1};
- bsp_trace_t trace;
+ trace_t trace;
- AAS_PresenceTypeBoundingBox(ms->presencetype, mins, maxs);
+ trap_AAS_PresenceTypeBoundingBox(ms->presencetype, mins, maxs);
VectorMA(ms->origin, -3, up, end);
- trace = AAS_Trace(ms->origin, mins, maxs, end, ms->entitynum, CONTENTS_SOLID|CONTENTS_PLAYERCLIP);
- if (!trace.startsolid && (trace.ent != ENTITYNUM_WORLD && trace.ent != ENTITYNUM_NONE) )
+ trap_Trace(&trace, ms->origin, mins, maxs, end, ms->entitynum, CONTENTS_SOLID|CONTENTS_PLAYERCLIP);
+ if (!trace.startsolid && (trace.entityNum != ENTITYNUM_WORLD && trace.entityNum != ENTITYNUM_NONE) )
{
- return trace.ent;
+ return trace.entityNum;
} //end if
return -1;
} //end of the function BotOnTopOfEntity
@@ -572,9 +574,9 @@ int BotOnTopOfEntity(bot_movestate_t *ms)
int BotValidTravel(vec3_t origin, aas_reachability_t *reach, int travelflags)
{
//if the reachability uses an unwanted travel type
- if (AAS_TravelFlagForType(reach->traveltype) & ~travelflags) return qfalse;
+ if (trap_AAS_TravelFlagForType(reach->traveltype) & ~travelflags) return qfalse;
//don't go into areas with bad travel types
- if (AAS_AreaContentsTravelFlags(reach->areanum) & ~travelflags) return qfalse;
+ if (trap_AAS_AreaContentsTravelFlags(reach->areanum) & ~travelflags) return qfalse;
return qtrue;
} //end of the function BotValidTravel
//===========================================================================
@@ -591,19 +593,19 @@ void BotAddToAvoidReach(bot_movestate_t *ms, int number, float avoidtime)
{
if (ms->avoidreach[i] == number)
{
- if (ms->avoidreachtimes[i] > AAS_Time()) ms->avoidreachtries[i]++;
+ if (ms->avoidreachtimes[i] > trap_AAS_Time()) ms->avoidreachtries[i]++;
else ms->avoidreachtries[i] = 1;
- ms->avoidreachtimes[i] = AAS_Time() + avoidtime;
+ ms->avoidreachtimes[i] = trap_AAS_Time() + avoidtime;
return;
} //end if
} //end for
//add the reachability to the reachabilities to avoid for a while
for (i = 0; i < MAX_AVOIDREACH; i++)
{
- if (ms->avoidreachtimes[i] < AAS_Time())
+ if (ms->avoidreachtimes[i] < trap_AAS_Time())
{
ms->avoidreach[i] = number;
- ms->avoidreachtimes[i] = AAS_Time() + avoidtime;
+ ms->avoidreachtimes[i] = trap_AAS_Time() + avoidtime;
ms->avoidreachtries[i] = 1;
return;
} //end if
@@ -615,12 +617,28 @@ void BotAddToAvoidReach(bot_movestate_t *ms, int number, float avoidtime)
// Returns: -
// Changes Globals: -
//===========================================================================
+void ProjectPointOntoVector( vec3_t point, vec3_t vStart, vec3_t vEnd, vec3_t vProj )
+{
+ vec3_t pVec, vec;
+
+ VectorSubtract( point, vStart, pVec );
+ VectorSubtract( vEnd, vStart, vec );
+ VectorNormalize( vec );
+ // project onto the directional vector for this segment
+ VectorMA( vStart, DotProduct( pVec, vec ), vec, vProj );
+} //end of the function ProjectPointOntoVector
+//===========================================================================
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
float DistanceFromLineSquared(vec3_t p, vec3_t lp1, vec3_t lp2)
{
vec3_t proj, dir;
int j;
- AAS_ProjectPointOntoVector(p, lp1, lp2, proj);
+ ProjectPointOntoVector(p, lp1, lp2, proj);
for (j = 0; j < 3; j++)
if ((proj[j] > lp1[j] && proj[j] > lp2[j]) ||
(proj[j] < lp1[j] && proj[j] < lp2[j]))
@@ -756,7 +774,7 @@ int BotGetReachabilityToGoal(vec3_t origin, int areanum,
//if not in a valid area
if (!areanum) return 0;
//
- if (AAS_AreaDoNotEnter(areanum) || AAS_AreaDoNotEnter(goal->areanum))
+ if (trap_AAS_AreaDoNotEnter(areanum) || trap_AAS_AreaDoNotEnter(goal->areanum))
{
travelflags |= TFL_DONOTENTER;
} //end if
@@ -764,33 +782,33 @@ int BotGetReachabilityToGoal(vec3_t origin, int areanum,
besttime = 0;
bestreachnum = 0;
//
- for (reachnum = AAS_NextAreaReachability(areanum, 0); reachnum;
- reachnum = AAS_NextAreaReachability(areanum, reachnum))
+ for (reachnum = trap_AAS_NextAreaReachability(areanum, 0); reachnum;
+ reachnum = trap_AAS_NextAreaReachability(areanum, reachnum))
{
#ifdef AVOIDREACH
//check if it isn't a reachability to avoid
for (i = 0; i < MAX_AVOIDREACH; i++)
{
- if (avoidreach[i] == reachnum && avoidreachtimes[i] >= AAS_Time()) break;
+ if (avoidreach[i] == reachnum && avoidreachtimes[i] >= trap_AAS_Time()) break;
} //end for
if (i != MAX_AVOIDREACH && avoidreachtries[i] > AVOIDREACH_TRIES)
{
#ifdef DEBUG
- botimport.Print(PRT_DEVELOPER, "avoiding reachability %d\n", avoidreach[i]);
+ BotAI_Print(PRT_DEVELOPER, "avoiding reachability %d\n", avoidreach[i]);
#endif //DEBUG
continue;
} //end if
#endif //AVOIDREACH
//get the reachability from the number
- AAS_ReachabilityFromNum(reachnum, &reach);
+ trap_AAS_ReachabilityFromNum(reachnum, &reach);
//NOTE: do not go back to the previous area if the goal didn't change
//NOTE: is this actually avoidance of local routing minima between two areas???
if (lastgoalareanum == goal->areanum && reach.areanum == lastareanum) continue;
- //if (AAS_AreaContentsTravelFlags(reach.areanum) & ~travelflags) continue;
+ //if (trap_AAS_AreaContentsTravelFlags(reach.areanum) & ~travelflags) continue;
//if the travel isn't valid
if (!BotValidTravel(origin, &reach, travelflags)) continue;
//get the travel time
- t = AAS_AreaTravelTimeToGoalArea(reach.areanum, reach.end, goal->areanum, travelflags);
+ t = trap_AAS_AreaTravelTimeToGoalArea(reach.areanum, reach.end, goal->areanum, travelflags);
//if the goal area isn't reachable from the reachable area
if (!t) continue;
//if the bot should not use this reachability to avoid bad spots
@@ -801,7 +819,7 @@ int BotGetReachabilityToGoal(vec3_t origin, int areanum,
continue;
}
//add the travel time towards the area
- t += reach.traveltime;// + AAS_AreaTravelTime(areanum, origin, reach.start);
+ t += reach.traveltime;// + trap_AAS_AreaTravelTime(areanum, origin, reach.start);
//if the travel time is better than the ones already found
if (!besttime || t < besttime)
{
@@ -858,7 +876,7 @@ int BotMovementViewTarget(int movestate, bot_goal_t *goal, int travelflags, floa
dist = 0;
while(reachnum && dist < lookahead)
{
- AAS_ReachabilityFromNum(reachnum, &reach);
+ trap_AAS_ReachabilityFromNum(reachnum, &reach);
if (BotAddToTarget(end, reach.start, lookahead, &dist, target)) return qtrue;
//never look beyond teleporters
if ((reach.traveltype & TRAVELTYPE_MASK) == TRAVEL_TELEPORT) return qtrue;
@@ -895,9 +913,9 @@ int BotMovementViewTarget(int movestate, bot_goal_t *goal, int travelflags, floa
//===========================================================================
int BotVisible(int ent, vec3_t eye, vec3_t target)
{
- bsp_trace_t trace;
+ trace_t trace;
- trace = AAS_Trace(eye, NULL, NULL, target, ent, CONTENTS_SOLID|CONTENTS_PLAYERCLIP);
+ trap_Trace(&trace, eye, NULL, NULL, target, ent, CONTENTS_SOLID|CONTENTS_PLAYERCLIP);
if (trace.fraction >= 1) return qtrue;
return qfalse;
} //end of the function BotVisible
@@ -936,7 +954,7 @@ int BotPredictVisiblePosition(vec3_t origin, int areanum, bot_goal_t *goal, int
avoidreach, avoidreachtimes, avoidreachtries,
goal, travelflags, NULL, 0, NULL);
if (!reachnum) return qfalse;
- AAS_ReachabilityFromNum(reachnum, &reach);
+ trap_AAS_ReachabilityFromNum(reachnum, &reach);
//
if (BotVisible(goal->entitynum, goal->origin, reach.start))
{
@@ -978,11 +996,11 @@ void MoverBottomCenter(aas_reachability_t *reach, vec3_t bottomcenter)
modelnum = reach->facenum & 0x0000FFFF;
//get some bsp model info
- AAS_BSPModelMinsMaxsOrigin(modelnum, angles, mins, maxs, origin);
+ trap_AAS_BSPModelMinsMaxsOrigin(modelnum, angles, mins, maxs, origin);
//
- if (!AAS_OriginOfMoverWithModelNum(modelnum, origin))
+ if (!trap_AAS_OriginOfMoverWithModelNum(modelnum, origin))
{
- botimport.Print(PRT_MESSAGE, "no entity with model %d\n", modelnum);
+ BotAI_Print(PRT_MESSAGE, "no entity with model %d\n", modelnum);
} //end if
//get a point just above the plat in the bottom position
VectorAdd(mins, maxs, mids);
@@ -1009,7 +1027,7 @@ float BotGapDistance(vec3_t origin, vec3_t hordir, int entnum)
VectorCopy(origin, start);
VectorCopy(origin, end);
end[2] -= 60;
- trace = AAS_TraceClientBBox(start, end, PRESENCE_CROUCH, entnum);
+ trap_AAS_TraceClientBBox(&trace, start, end, PRESENCE_CROUCH, entnum);
if (trace.fraction >= 1) return 1;
startz = trace.endpos[2] + 1;
}
@@ -1019,19 +1037,19 @@ float BotGapDistance(vec3_t origin, vec3_t hordir, int entnum)
VectorMA(origin, dist, hordir, start);
start[2] = startz + 24;
VectorCopy(start, end);
- end[2] -= 48 + sv_maxbarrier->value;
- trace = AAS_TraceClientBBox(start, end, PRESENCE_CROUCH, entnum);
+ end[2] -= 48 + phys_maxbarrier;
+ trap_AAS_TraceClientBBox(&trace, start, end, PRESENCE_CROUCH, entnum);
//if solid is found the bot can't walk any further and fall into a gap
if (!trace.startsolid)
{
//if it is a gap
- if (trace.endpos[2] < startz - sv_maxstep->value - 8)
+ if (trace.endpos[2] < startz - STEPSIZE - 8)
{
VectorCopy(trace.endpos, end);
end[2] -= 20;
- if (AAS_PointContents(end) & CONTENTS_WATER) break;
+ if (trap_AAS_PointContents(end) & CONTENTS_WATER) break;
//if a gap is found slow down
- //botimport.Print(PRT_MESSAGE, "gap at %i\n", dist);
+ //BotAI_Print(PRT_MESSAGE, "gap at %i\n", dist);
return dist;
} //end if
startz = trace.endpos[2];
@@ -1051,13 +1069,13 @@ int BotCheckBarrierJump(bot_movestate_t *ms, vec3_t dir, float speed)
aas_trace_t trace;
VectorCopy(ms->origin, end);
- end[2] += sv_maxbarrier->value;
+ end[2] += phys_maxbarrier;
//trace right up
- trace = AAS_TraceClientBBox(ms->origin, end, PRESENCE_NORMAL, ms->entitynum);
+ trap_AAS_TraceClientBBox(&trace, ms->origin, end, PRESENCE_NORMAL, ms->entitynum);
//this shouldn't happen... but we check anyway
if (trace.startsolid) return qfalse;
//if very low ceiling it isn't possible to jump up to a barrier
- if (trace.endpos[2] - ms->origin[2] < sv_maxstep->value) return qfalse;
+ if (trace.endpos[2] - ms->origin[2] < STEPSIZE) return qfalse;
//
hordir[0] = dir[0];
hordir[1] = dir[1];
@@ -1067,7 +1085,7 @@ int BotCheckBarrierJump(bot_movestate_t *ms, vec3_t dir, float speed)
VectorCopy(trace.endpos, start);
end[2] = trace.endpos[2];
//trace from previous trace end pos horizontally in the move direction
- trace = AAS_TraceClientBBox(start, end, PRESENCE_NORMAL, ms->entitynum);
+ trap_AAS_TraceClientBBox(&trace, start, end, PRESENCE_NORMAL, ms->entitynum);
//again this shouldn't happen
if (trace.startsolid) return qfalse;
//
@@ -1075,13 +1093,13 @@ int BotCheckBarrierJump(bot_movestate_t *ms, vec3_t dir, float speed)
VectorCopy(trace.endpos, end);
end[2] = ms->origin[2];
//trace down from the previous trace end pos
- trace = AAS_TraceClientBBox(start, end, PRESENCE_NORMAL, ms->entitynum);
+ trap_AAS_TraceClientBBox(&trace, start, end, PRESENCE_NORMAL, ms->entitynum);
//if solid
if (trace.startsolid) return qfalse;
//if no obstacle at all
if (trace.fraction >= 1.0) return qfalse;
//if less than the maximum step height
- if (trace.endpos[2] - ms->origin[2] < sv_maxstep->value) return qfalse;
+ if (trace.endpos[2] - ms->origin[2] < STEPSIZE) return qfalse;
//
EA_Jump(ms->client);
EA_Move(ms->client, hordir, speed);
@@ -1117,7 +1135,7 @@ int BotWalkInDirection(bot_movestate_t *ms, vec3_t dir, float speed, int type)
aas_clientmove_t move;
float dist;
- if (AAS_OnGround(ms->origin, ms->presencetype, ms->entitynum)) ms->moveflags |= MFL_ONGROUND;
+ if (trap_AAS_OnGround(ms->origin, ms->presencetype, ms->entitynum)) ms->moveflags |= MFL_ONGROUND;
//if the bot is on the ground
if (ms->moveflags & MFL_ONGROUND)
{
@@ -1145,7 +1163,7 @@ int BotWalkInDirection(bot_movestate_t *ms, vec3_t dir, float speed, int type)
//
if (type & MOVE_JUMP)
{
- //botimport.Print(PRT_MESSAGE, "trying jump\n");
+ //BotAI_Print(PRT_MESSAGE, "trying jump\n");
cmdmove[2] = 400;
maxframes = PREDICTIONTIME_JUMP / 0.1;
cmdframes = 1;
@@ -1159,26 +1177,26 @@ int BotWalkInDirection(bot_movestate_t *ms, vec3_t dir, float speed, int type)
stopevent = SE_HITGROUNDDAMAGE|
SE_ENTERWATER|SE_ENTERSLIME|SE_ENTERLAVA;
} //end else
- //AAS_ClearShownDebugLines();
+ //trap_AAS_ClearShownDebugLines();
//
VectorCopy(ms->origin, origin);
origin[2] += 0.5;
- AAS_PredictClientMovement(&move, ms->entitynum, origin, presencetype, qtrue,
+ trap_AAS_PredictClientMovement(&move, ms->entitynum, origin, presencetype, qtrue,
velocity, cmdmove, cmdframes, maxframes, 0.1f,
stopevent, 0, qfalse);//qtrue);
//if prediction time wasn't enough to fully predict the movement
if (move.frames >= maxframes && (type & MOVE_JUMP))
{
- //botimport.Print(PRT_MESSAGE, "client %d: max prediction frames\n", ms->client);
+ //BotAI_Print(PRT_MESSAGE, "client %d: max prediction frames\n", ms->client);
return qfalse;
} //end if
//don't enter slime or lava and don't fall from too high
if (move.stopevent & (SE_ENTERSLIME|SE_ENTERLAVA|SE_HITGROUNDDAMAGE))
{
- //botimport.Print(PRT_MESSAGE, "client %d: would be hurt ", ms->client);
- //if (move.stopevent & SE_ENTERSLIME) botimport.Print(PRT_MESSAGE, "slime\n");
- //if (move.stopevent & SE_ENTERLAVA) botimport.Print(PRT_MESSAGE, "lava\n");
- //if (move.stopevent & SE_HITGROUNDDAMAGE) botimport.Print(PRT_MESSAGE, "hitground\n");
+ //BotAI_Print(PRT_MESSAGE, "client %d: would be hurt ", ms->client);
+ //if (move.stopevent & SE_ENTERSLIME) BotAI_Print(PRT_MESSAGE, "slime\n");
+ //if (move.stopevent & SE_ENTERLAVA) BotAI_Print(PRT_MESSAGE, "lava\n");
+ //if (move.stopevent & SE_HITGROUNDDAMAGE) BotAI_Print(PRT_MESSAGE, "hitground\n");
return qfalse;
} //end if
//if ground was hit
@@ -1197,7 +1215,7 @@ int BotWalkInDirection(bot_movestate_t *ms, vec3_t dir, float speed, int type)
tmpdir[1] = move.endpos[1] - ms->origin[1];
tmpdir[2] = 0;
//
- //AAS_DrawCross(move.endpos, 4, LINECOLOR_BLUE);
+ //trap_AAS_DrawCross(move.endpos, 4, LINECOLOR_BLUE);
//the bot is blocked by something
if (VectorLength(tmpdir) < speed * ms->thinktime * 0.5) return qfalse;
//perform the movement
@@ -1234,7 +1252,7 @@ int BotMoveInDirection(int movestate, vec3_t dir, float speed, int type)
ms = BotMoveStateFromHandle(movestate);
if (!ms) return qfalse;
//if swimming
- if (AAS_Swimming(ms->origin))
+ if (trap_AAS_Swimming(ms->origin))
{
return BotSwimInDirection(ms, dir, speed, type);
} //end if
@@ -1281,41 +1299,41 @@ int Intersection(vec2_t p1, vec2_t p2, vec2_t p3, vec2_t p4, vec2_t out)
void BotCheckBlocked(bot_movestate_t *ms, vec3_t dir, int checkbottom, bot_moveresult_t *result)
{
vec3_t mins, maxs, end, up = {0, 0, 1};
- bsp_trace_t trace;
+ trace_t trace;
//test for entities obstructing the bot's path
- AAS_PresenceTypeBoundingBox(ms->presencetype, mins, maxs);
+ trap_AAS_PresenceTypeBoundingBox(ms->presencetype, mins, maxs);
//
if (fabs(DotProduct(dir, up)) < 0.7)
{
- mins[2] += sv_maxstep->value; //if the bot can step on
+ mins[2] += STEPSIZE; //if the bot can step on
maxs[2] -= 10; //a little lower to avoid low ceiling
} //end if
VectorMA(ms->origin, 3, dir, end);
- trace = AAS_Trace(ms->origin, mins, maxs, end, ms->entitynum, CONTENTS_SOLID|CONTENTS_PLAYERCLIP|CONTENTS_BODY);
+ trap_Trace(&trace, ms->origin, mins, maxs, end, ms->entitynum, CONTENTS_SOLID|CONTENTS_PLAYERCLIP|CONTENTS_BODY);
//if not started in solid and not hitting the world entity
- if (!trace.startsolid && (trace.ent != ENTITYNUM_WORLD && trace.ent != ENTITYNUM_NONE) )
+ if (!trace.startsolid && (trace.entityNum != ENTITYNUM_WORLD && trace.entityNum != ENTITYNUM_NONE) )
{
result->blocked = qtrue;
- result->blockentity = trace.ent;
+ result->blockentity = trace.entityNum;
#ifdef DEBUG
- //botimport.Print(PRT_MESSAGE, "%d: BotCheckBlocked: I'm blocked\n", ms->client);
+ //BotAI_Print(PRT_MESSAGE, "%d: BotCheckBlocked: I'm blocked\n", ms->client);
#endif //DEBUG
} //end if
//if not in an area with reachability
- else if (checkbottom && !AAS_AreaReachability(ms->areanum))
+ else if (checkbottom && !trap_AAS_AreaReachability(ms->areanum))
{
//check if the bot is standing on something
- AAS_PresenceTypeBoundingBox(ms->presencetype, mins, maxs);
+ trap_AAS_PresenceTypeBoundingBox(ms->presencetype, mins, maxs);
VectorMA(ms->origin, -3, up, end);
- trace = AAS_Trace(ms->origin, mins, maxs, end, ms->entitynum, CONTENTS_SOLID|CONTENTS_PLAYERCLIP);
- if (!trace.startsolid && (trace.ent != ENTITYNUM_WORLD && trace.ent != ENTITYNUM_NONE) )
+ trap_Trace(&trace, ms->origin, mins, maxs, end, ms->entitynum, CONTENTS_SOLID|CONTENTS_PLAYERCLIP);
+ if (!trace.startsolid && (trace.entityNum != ENTITYNUM_WORLD && trace.entityNum != ENTITYNUM_NONE) )
{
result->blocked = qtrue;
- result->blockentity = trace.ent;
+ result->blockentity = trace.entityNum;
result->flags |= MOVERESULT_ONTOPOFOBSTACLE;
#ifdef DEBUG
- //botimport.Print(PRT_MESSAGE, "%d: BotCheckBlocked: I'm blocked\n", ms->client);
+ //BotAI_Print(PRT_MESSAGE, "%d: BotCheckBlocked: I'm blocked\n", ms->client);
#endif //DEBUG
} //end if
} //end else
@@ -1349,7 +1367,7 @@ bot_moveresult_t BotTravel_Walk(bot_movestate_t *ms, aas_reachability_t *reach)
dist = VectorNormalize(hordir);
} //end if
//if going towards a crouch area
- if (!(AAS_AreaPresenceType(reach->areanum) & PRESENCE_NORMAL))
+ if (!(trap_AAS_AreaPresenceType(reach->areanum) & PRESENCE_NORMAL))
{
//if pretty close to the reachable area
if (dist < 20) EA_Crouch(ms->client);
@@ -1392,7 +1410,7 @@ bot_moveresult_t BotFinishTravel_Walk(bot_movestate_t *ms, aas_reachability_t *r
if (ms->areanum == reach->areanum)
{
#ifdef DEBUG
- botimport.Print(PRT_MESSAGE, "BotFinishTravel_Walk: already in reach area\n");
+ BotAI_Print(PRT_MESSAGE, "BotFinishTravel_Walk: already in reach area\n");
#endif //DEBUG
return result;
} //end if*/
@@ -1541,7 +1559,7 @@ bot_moveresult_t BotTravel_WaterJump(bot_movestate_t *ms, aas_reachability_t *re
VectorCopy(dir, hordir);
hordir[2] = 0;
dir[2] += 15 + crandom() * 40;
- //botimport.Print(PRT_MESSAGE, "BotTravel_WaterJump: dir[2] = %f\n", dir[2]);
+ //BotAI_Print(PRT_MESSAGE, "BotTravel_WaterJump: dir[2] = %f\n", dir[2]);
VectorNormalize(dir);
dist = VectorNormalize(hordir);
//elemantary actions
@@ -1568,14 +1586,14 @@ bot_moveresult_t BotFinishTravel_WaterJump(bot_movestate_t *ms, aas_reachability
vec3_t dir, pnt;
bot_moveresult_t_cleared( result );
- //botimport.Print(PRT_MESSAGE, "BotFinishTravel_WaterJump\n");
+ //BotAI_Print(PRT_MESSAGE, "BotFinishTravel_WaterJump\n");
//if waterjumping there's nothing to do
if (ms->moveflags & MFL_WATERJUMP) return result;
//if not touching any water anymore don't do anything
//otherwise the bot sometimes keeps jumping?
VectorCopy(ms->origin, pnt);
pnt[2] -= 32; //extra for q2dm4 near red armor/mega health
- if (!(AAS_PointContents(pnt) & (CONTENTS_LAVA|CONTENTS_SLIME|CONTENTS_WATER))) return result;
+ if (!(trap_AAS_PointContents(pnt) & (CONTENTS_LAVA|CONTENTS_SLIME|CONTENTS_WATER))) return result;
//swim straight to reachability end
VectorSubtract(reach->end, ms->origin, dir);
dir[0] += crandom() * 10;
@@ -1628,7 +1646,7 @@ bot_moveresult_t BotTravel_WalkOffLedge(bot_movestate_t *ms, aas_reachability_t
{
speed = 100;
} //end if
- else if (!AAS_HorizontalVelocityForJump(0, reach->start, reach->end, &speed))
+ else if (!trap_AAS_HorizontalVelocityForJump(0, reach->start, reach->end, &speed))
{
speed = 400;
} //end if
@@ -1669,7 +1687,7 @@ int BotAirControl(vec3_t origin, vec3_t velocity, vec3_t goal, vec3_t dir, float
VectorScale(velocity, 0.1, vel);
for (i = 0; i < 50; i++)
{
- vel[2] -= sv_gravity->value * 0.01;
+ vel[2] -= g_gravity.value * 0.01;
//if going down and next position would be below the goal
if (vel[2] < 0 && org[2] + vel[2] < goal[2])
{
@@ -1754,7 +1772,7 @@ bot_moveresult_t BotTravel_Jump(bot_movestate_t *ms, aas_reachability_t *reach)
if (dist < 50 || (gapdist && gapdist < 50))
{
//NOTE: using max speed (400) works best
- //if (AAS_HorizontalVelocityForJump(sv_jumpvel, ms->origin, reach->end, &horspeed))
+ //if (trap_AAS_HorizontalVelocityForJump(sv_jumpvel, ms->origin, reach->end, &horspeed))
//{
// speed = horspeed * 400 / botlibglobals.sv_maxwalkvelocity->value;
//} //end if
@@ -1769,7 +1787,7 @@ bot_moveresult_t BotTravel_Jump(bot_movestate_t *ms, aas_reachability_t *reach)
} //end if
else
{
- if (AAS_HorizontalVelocityForJump(sv_jumpvel, reach->start, reach->end, &horspeed))
+ if (trap_AAS_HorizontalVelocityForJump(sv_jumpvel, reach->start, reach->end, &horspeed))
{
speed = horspeed * 400 / botlibglobals.sv_maxwalkvelocity->value;
} //end if
@@ -1787,7 +1805,7 @@ bot_moveresult_t BotTravel_Jump(bot_movestate_t *ms, aas_reachability_t *reach)
int gapdist;
float dist1, dist2, speed;
bot_moveresult_t_cleared( result );
- bsp_trace_t trace;
+ trace_t trace;
//
hordir[0] = reach->start[0] - reach->end[0];
@@ -1800,16 +1818,16 @@ bot_moveresult_t BotTravel_Jump(bot_movestate_t *ms, aas_reachability_t *reach)
//minus back the bouding box size plus 16
VectorMA(reach->start, 80, hordir, end);
//
- AAS_PresenceTypeBoundingBox(PRESENCE_NORMAL, mins, maxs);
+ trap_AAS_PresenceTypeBoundingBox(PRESENCE_NORMAL, mins, maxs);
//check for solids
- trace = AAS_Trace(start, mins, maxs, end, ms->entitynum, MASK_PLAYERSOLID);
+ trap_Trace(&trace, start, mins, maxs, end, ms->entitynum, MASK_PLAYERSOLID);
if (trace.startsolid) VectorCopy(start, trace.endpos);
//check for a gap
for (gapdist = 0; gapdist < 80; gapdist += 10)
{
VectorMA(start, gapdist+10, hordir, end);
end[2] += 1;
- if (AAS_PointAreaNum(end) != ms->reachareanum) break;
+ if (trap_AAS_PointAreaNum(end) != ms->reachareanum) break;
} //end for
if (gapdist < 80) VectorMA(reach->start, gapdist, hordir, trace.endpos);
// dist1 = BotGapDistance(start, hordir, ms->entitynum);
@@ -1824,7 +1842,7 @@ bot_moveresult_t BotTravel_Jump(bot_movestate_t *ms, aas_reachability_t *reach)
//if just before the reachability start
if (DotProduct(dir1, dir2) < -0.8 || dist2 < 5)
{
- //botimport.Print(PRT_MESSAGE, "between jump start and run to point\n");
+ //BotAI_Print(PRT_MESSAGE, "between jump start and run to point\n");
hordir[0] = reach->end[0] - ms->origin[0];
hordir[1] = reach->end[1] - ms->origin[1];
hordir[2] = 0;
@@ -1838,7 +1856,7 @@ bot_moveresult_t BotTravel_Jump(bot_movestate_t *ms, aas_reachability_t *reach)
} //end if
else
{
- //botimport.Print(PRT_MESSAGE, "going towards run to point\n");
+ //BotAI_Print(PRT_MESSAGE, "going towards run to point\n");
hordir[0] = trace.endpos[0] - ms->origin[0];
hordir[1] = trace.endpos[1] - ms->origin[1];
hordir[2] = 0;
@@ -1862,7 +1880,7 @@ bot_moveresult_t BotTravel_Jump(bot_movestate_t *ms, aas_reachability_t *reach)
bot_moveresult_t_cleared( result );
//
- AAS_JumpReachRunStart(reach, runstart);
+ trap_AAS_JumpReachRunStart(reach, runstart);
//*
hordir[0] = runstart[0] - reach->start[0];
hordir[1] = runstart[1] - reach->start[1];
@@ -1877,7 +1895,7 @@ bot_moveresult_t BotTravel_Jump(bot_movestate_t *ms, aas_reachability_t *reach)
{
VectorMA(start, gapdist+10, hordir, end);
end[2] += 1;
- if (AAS_PointAreaNum(end) != ms->reachareanum) break;
+ if (trap_AAS_PointAreaNum(end) != ms->reachareanum) break;
} //end for
if (gapdist < 80) VectorMA(reach->start, gapdist, hordir, runstart);
//
@@ -1890,7 +1908,7 @@ bot_moveresult_t BotTravel_Jump(bot_movestate_t *ms, aas_reachability_t *reach)
//if just before the reachability start
if (DotProduct(dir1, dir2) < -0.8 || dist2 < 5)
{
-// botimport.Print(PRT_MESSAGE, "between jump start and run start point\n");
+// BotAI_Print(PRT_MESSAGE, "between jump start and run start point\n");
hordir[0] = reach->end[0] - ms->origin[0];
hordir[1] = reach->end[1] - ms->origin[1];
hordir[2] = 0;
@@ -1904,7 +1922,7 @@ bot_moveresult_t BotTravel_Jump(bot_movestate_t *ms, aas_reachability_t *reach)
} //end if
else
{
-// botimport.Print(PRT_MESSAGE, "going towards run start point\n");
+// BotAI_Print(PRT_MESSAGE, "going towards run start point\n");
hordir[0] = runstart[0] - ms->origin[0];
hordir[1] = runstart[1] - ms->origin[1];
hordir[2] = 0;
@@ -1971,7 +1989,7 @@ bot_moveresult_t BotTravel_Ladder(bot_movestate_t *ms, aas_reachability_t *reach
//NOTE: not a good idea for ladders starting in water
// || !(ms->moveflags & MFL_ONGROUND))
{
- //botimport.Print(PRT_MESSAGE, "against ladder or not on ground\n");
+ //BotAI_Print(PRT_MESSAGE, "against ladder or not on ground\n");
VectorSubtract(reach->end, ms->origin, dir);
VectorNormalize(dir);
//set the ideal view angles, facing the ladder up or down
@@ -1987,7 +2005,7 @@ bot_moveresult_t BotTravel_Ladder(bot_movestate_t *ms, aas_reachability_t *reach
} //end if
/* else
{
- //botimport.Print(PRT_MESSAGE, "moving towards ladder\n");
+ //BotAI_Print(PRT_MESSAGE, "moving towards ladder\n");
VectorSubtract(reach->end, ms->origin, dir);
//make sure the horizontal movement is large enough
VectorCopy(dir, hordir);
@@ -2053,13 +2071,13 @@ bot_moveresult_t BotTravel_Elevator(bot_movestate_t *ms, aas_reachability_t *rea
if (BotOnMover(ms->origin, ms->entitynum, reach))
{
#ifdef DEBUG_ELEVATOR
- botimport.Print(PRT_MESSAGE, "bot on elevator\n");
+ BotAI_Print(PRT_MESSAGE, "bot on elevator\n");
#endif //DEBUG_ELEVATOR
//if vertically not too far from the end point
- if (abs(ms->origin[2] - reach->end[2]) < sv_maxbarrier->value)
+ if (abs(ms->origin[2] - reach->end[2]) < phys_maxbarrier)
{
#ifdef DEBUG_ELEVATOR
- botimport.Print(PRT_MESSAGE, "bot moving to end\n");
+ BotAI_Print(PRT_MESSAGE, "bot moving to end\n");
#endif //DEBUG_ELEVATOR
//move to the end point
VectorSubtract(reach->end, ms->origin, hordir);
@@ -2082,7 +2100,7 @@ bot_moveresult_t BotTravel_Elevator(bot_movestate_t *ms, aas_reachability_t *rea
if (dist > 10)
{
#ifdef DEBUG_ELEVATOR
- botimport.Print(PRT_MESSAGE, "bot moving to center\n");
+ BotAI_Print(PRT_MESSAGE, "bot moving to center\n");
#endif //DEBUG_ELEVATOR
//move to the center of the plat
if (dist > 100) dist = 100;
@@ -2096,7 +2114,7 @@ bot_moveresult_t BotTravel_Elevator(bot_movestate_t *ms, aas_reachability_t *rea
else
{
#ifdef DEBUG_ELEVATOR
- botimport.Print(PRT_MESSAGE, "bot not on elevator\n");
+ BotAI_Print(PRT_MESSAGE, "bot not on elevator\n");
#endif //DEBUG_ELEVATOR
//if very near the reachability end
VectorSubtract(reach->end, ms->origin, dir);
@@ -2125,7 +2143,7 @@ bot_moveresult_t BotTravel_Elevator(bot_movestate_t *ms, aas_reachability_t *rea
if (!MoverDown(reach))
{
#ifdef DEBUG_ELEVATOR
- botimport.Print(PRT_MESSAGE, "elevator not down\n");
+ BotAI_Print(PRT_MESSAGE, "elevator not down\n");
#endif //DEBUG_ELEVATOR
dist = dist1;
VectorCopy(dir1, dir);
@@ -2158,7 +2176,7 @@ bot_moveresult_t BotTravel_Elevator(bot_movestate_t *ms, aas_reachability_t *rea
if (dist1 < 20 || dist2 < dist1 || DotProduct(dir1, dir2) < 0)
{
#ifdef DEBUG_ELEVATOR
- botimport.Print(PRT_MESSAGE, "bot moving to center\n");
+ BotAI_Print(PRT_MESSAGE, "bot moving to center\n");
#endif //DEBUG_ELEVATOR
dist = dist2;
VectorCopy(dir2, dir);
@@ -2166,7 +2184,7 @@ bot_moveresult_t BotTravel_Elevator(bot_movestate_t *ms, aas_reachability_t *rea
else //closer to the reachability start
{
#ifdef DEBUG_ELEVATOR
- botimport.Print(PRT_MESSAGE, "bot moving to start\n");
+ BotAI_Print(PRT_MESSAGE, "bot moving to start\n");
#endif //DEBUG_ELEVATOR
dist = dist1;
VectorCopy(dir1, dir);
@@ -2229,14 +2247,14 @@ void BotFuncBobStartEnd(aas_reachability_t *reach, vec3_t start, vec3_t end, vec
int num0, num1;
modelnum = reach->facenum & 0x0000FFFF;
- if (!AAS_OriginOfMoverWithModelNum(modelnum, origin))
+ if (!trap_AAS_OriginOfMoverWithModelNum(modelnum, origin))
{
- botimport.Print(PRT_MESSAGE, "BotFuncBobStartEnd: no entity with model %d\n", modelnum);
+ BotAI_Print(PRT_MESSAGE, "BotFuncBobStartEnd: no entity with model %d\n", modelnum);
VectorSet(start, 0, 0, 0);
VectorSet(end, 0, 0, 0);
return;
} //end if
- AAS_BSPModelMinsMaxsOrigin(modelnum, angles, mins, maxs, NULL);
+ trap_AAS_BSPModelMinsMaxsOrigin(modelnum, angles, mins, maxs, NULL);
VectorAdd(mins, maxs, mid);
VectorScale(mid, 0.5, mid);
VectorCopy(mid, start);
@@ -2292,14 +2310,14 @@ bot_moveresult_t BotTravel_FuncBobbing(bot_movestate_t *ms, aas_reachability_t *
if (BotOnMover(ms->origin, ms->entitynum, reach))
{
#ifdef DEBUG_FUNCBOB
- botimport.Print(PRT_MESSAGE, "bot on func_bobbing\n");
+ BotAI_Print(PRT_MESSAGE, "bot on func_bobbing\n");
#endif
//if near end point of reachability
VectorSubtract(bob_origin, bob_end, dir);
if (VectorLength(dir) < 24)
{
#ifdef DEBUG_FUNCBOB
- botimport.Print(PRT_MESSAGE, "bot moving to reachability end\n");
+ BotAI_Print(PRT_MESSAGE, "bot moving to reachability end\n");
#endif
//move to the end point
VectorSubtract(reach->end, ms->origin, hordir);
@@ -2322,7 +2340,7 @@ bot_moveresult_t BotTravel_FuncBobbing(bot_movestate_t *ms, aas_reachability_t *
if (dist > 10)
{
#ifdef DEBUG_FUNCBOB
- botimport.Print(PRT_MESSAGE, "bot moving to func_bobbing center\n");
+ BotAI_Print(PRT_MESSAGE, "bot moving to func_bobbing center\n");
#endif
//move to the center of the plat
if (dist > 100) dist = 100;
@@ -2336,7 +2354,7 @@ bot_moveresult_t BotTravel_FuncBobbing(bot_movestate_t *ms, aas_reachability_t *
else
{
#ifdef DEBUG_FUNCBOB
- botimport.Print(PRT_MESSAGE, "bot not ontop of func_bobbing\n");
+ BotAI_Print(PRT_MESSAGE, "bot not ontop of func_bobbing\n");
#endif
//if very near the reachability end
VectorSubtract(reach->end, ms->origin, dir);
@@ -2344,7 +2362,7 @@ bot_moveresult_t BotTravel_FuncBobbing(bot_movestate_t *ms, aas_reachability_t *
if (dist < 64)
{
#ifdef DEBUG_FUNCBOB
- botimport.Print(PRT_MESSAGE, "bot moving to end\n");
+ BotAI_Print(PRT_MESSAGE, "bot moving to end\n");
#endif
if (dist > 60) dist = 60;
speed = 360 - (360 - 6 * dist);
@@ -2369,7 +2387,7 @@ bot_moveresult_t BotTravel_FuncBobbing(bot_movestate_t *ms, aas_reachability_t *
if (VectorLength(dir) > 16)
{
#ifdef DEBUG_FUNCBOB
- botimport.Print(PRT_MESSAGE, "func_bobbing not at start\n");
+ BotAI_Print(PRT_MESSAGE, "func_bobbing not at start\n");
#endif
dist = dist1;
VectorCopy(dir1, dir);
@@ -2402,7 +2420,7 @@ bot_moveresult_t BotTravel_FuncBobbing(bot_movestate_t *ms, aas_reachability_t *
if (dist1 < 20 || dist2 < dist1 || DotProduct(dir1, dir2) < 0)
{
#ifdef DEBUG_FUNCBOB
- botimport.Print(PRT_MESSAGE, "bot moving to func_bobbing center\n");
+ BotAI_Print(PRT_MESSAGE, "bot moving to func_bobbing center\n");
#endif
dist = dist2;
VectorCopy(dir2, dir);
@@ -2410,7 +2428,7 @@ bot_moveresult_t BotTravel_FuncBobbing(bot_movestate_t *ms, aas_reachability_t *
else //closer to the reachability start
{
#ifdef DEBUG_FUNCBOB
- botimport.Print(PRT_MESSAGE, "bot moving to reachability start\n");
+ BotAI_Print(PRT_MESSAGE, "bot moving to reachability start\n");
#endif
dist = dist1;
VectorCopy(dir1, dir);
@@ -2501,12 +2519,12 @@ int GrappleState(bot_movestate_t *ms, aas_reachability_t *reach)
return 2;
//check for a visible grapple missile entity
//or visible grapple entity
- for (i = AAS_NextEntity(0); i; i = AAS_NextEntity(i))
+ for (i = BotNextEntity(0); i; i = BotNextEntity(i))
{
- if (AAS_EntityType(i) == (int) entitytypemissile->value)
+ if (trap_AAS_EntityType(i) == ET_MISSILE)
{
- AAS_EntityInfo(i, &entinfo);
- if (entinfo.weapon == (int) weapindex_grapple->value)
+ BotEntityInfo(i, &entinfo);
+ if (entinfo.weapon == WP_GRAPPLING_HOOK)
{
return 1;
} //end if
@@ -2525,18 +2543,18 @@ void BotResetGrapple(bot_movestate_t *ms)
{
aas_reachability_t reach;
- AAS_ReachabilityFromNum(ms->lastreachnum, &reach);
+ trap_AAS_ReachabilityFromNum(ms->lastreachnum, &reach);
//if not using the grapple hook reachability anymore
if ((reach.traveltype & TRAVELTYPE_MASK) != TRAVEL_GRAPPLEHOOK)
{
if ((ms->moveflags & MFL_ACTIVEGRAPPLE) || ms->grapplevisible_time)
{
- if (offhandgrapple->value)
- EA_Command(ms->client, cmd_grappleoff->string);
+ if (bot_offhandgrapple.integer)
+ EA_Command(ms->client, CMD_GRAPPLEOFF);
ms->moveflags &= ~MFL_ACTIVEGRAPPLE;
ms->grapplevisible_time = 0;
#ifdef DEBUG_GRAPPLE
- botimport.Print(PRT_MESSAGE, "reset grapple\n");
+ BotAI_Print(PRT_MESSAGE, "reset grapple\n");
#endif //DEBUG_GRAPPLE
} //end if
} //end if
@@ -2553,7 +2571,7 @@ bot_moveresult_t BotTravel_Grapple(bot_movestate_t *ms, aas_reachability_t *reac
float dist, speed;
vec3_t dir, viewdir, org;
int state, areanum;
- bsp_trace_t trace;
+ trace_t trace;
#ifdef DEBUG_GRAPPLE
static int debugline;
@@ -2564,22 +2582,22 @@ bot_moveresult_t BotTravel_Grapple(bot_movestate_t *ms, aas_reachability_t *reac
//
if (ms->moveflags & MFL_GRAPPLERESET)
{
- if (offhandgrapple->value)
- EA_Command(ms->client, cmd_grappleoff->string);
+ if (bot_offhandgrapple.integer)
+ EA_Command(ms->client, CMD_GRAPPLEOFF);
ms->moveflags &= ~MFL_ACTIVEGRAPPLE;
return result;
} //end if
//
- if (!(int) offhandgrapple->value)
+ if (!bot_offhandgrapple.integer)
{
- result.weapon = weapindex_grapple->value;
+ result.weapon = WP_GRAPPLING_HOOK;
result.flags |= MOVERESULT_MOVEMENTWEAPON;
} //end if
//
if (ms->moveflags & MFL_ACTIVEGRAPPLE)
{
#ifdef DEBUG_GRAPPLE
- botimport.Print(PRT_MESSAGE, "BotTravel_Grapple: active grapple\n");
+ BotAI_Print(PRT_MESSAGE, "BotTravel_Grapple: active grapple\n");
#endif //DEBUG_GRAPPLE
//
state = GrappleState(ms, reach);
@@ -2594,10 +2612,10 @@ bot_moveresult_t BotTravel_Grapple(bot_movestate_t *ms, aas_reachability_t *reac
if (ms->lastgrappledist - dist < 1)
{
#ifdef DEBUG_GRAPPLE
- botimport.Print(PRT_ERROR, "grapple normal end\n");
+ BotAI_Print(PRT_ERROR, "grapple normal end\n");
#endif //DEBUG_GRAPPLE
- if (offhandgrapple->value)
- EA_Command(ms->client, cmd_grappleoff->string);
+ if (bot_offhandgrapple.integer)
+ EA_Command(ms->client, CMD_GRAPPLEOFF);
ms->moveflags &= ~MFL_ACTIVEGRAPPLE;
ms->moveflags |= MFL_GRAPPLERESET;
ms->reachability_time = 0; //end the reachability
@@ -2608,13 +2626,13 @@ bot_moveresult_t BotTravel_Grapple(bot_movestate_t *ms, aas_reachability_t *reac
//isn't moving anymore
else if (!state || (state == 2 && dist > ms->lastgrappledist - 2))
{
- if (ms->grapplevisible_time < AAS_Time() - 0.4)
+ if (ms->grapplevisible_time < trap_AAS_Time() - 0.4)
{
#ifdef DEBUG_GRAPPLE
- botimport.Print(PRT_ERROR, "grapple not visible\n");
+ BotAI_Print(PRT_ERROR, "grapple not visible\n");
#endif //DEBUG_GRAPPLE
- if (offhandgrapple->value)
- EA_Command(ms->client, cmd_grappleoff->string);
+ if (bot_offhandgrapple.integer)
+ EA_Command(ms->client, CMD_GRAPPLEOFF);
ms->moveflags &= ~MFL_ACTIVEGRAPPLE;
ms->moveflags |= MFL_GRAPPLERESET;
ms->reachability_time = 0; //end the reachability
@@ -2623,10 +2641,10 @@ bot_moveresult_t BotTravel_Grapple(bot_movestate_t *ms, aas_reachability_t *reac
} //end if
else
{
- ms->grapplevisible_time = AAS_Time();
+ ms->grapplevisible_time = trap_AAS_Time();
} //end else
//
- if (!(int) offhandgrapple->value)
+ if (!bot_offhandgrapple.integer)
{
EA_Attack(ms->client);
} //end if
@@ -2636,10 +2654,10 @@ bot_moveresult_t BotTravel_Grapple(bot_movestate_t *ms, aas_reachability_t *reac
else
{
#ifdef DEBUG_GRAPPLE
- botimport.Print(PRT_MESSAGE, "BotTravel_Grapple: inactive grapple\n");
+ BotAI_Print(PRT_MESSAGE, "BotTravel_Grapple: inactive grapple\n");
#endif //DEBUG_GRAPPLE
//
- ms->grapplevisible_time = AAS_Time();
+ ms->grapplevisible_time = trap_AAS_Time();
//
VectorSubtract(reach->start, ms->origin, dir);
if (!(ms->moveflags & MFL_SWIMMING)) dir[2] = 0;
@@ -2655,11 +2673,11 @@ bot_moveresult_t BotTravel_Grapple(bot_movestate_t *ms, aas_reachability_t *reac
fabs(AngleDiff(result.ideal_viewangles[1], ms->viewangles[1])) < 2)
{
#ifdef DEBUG_GRAPPLE
- botimport.Print(PRT_MESSAGE, "BotTravel_Grapple: activating grapple\n");
+ BotAI_Print(PRT_MESSAGE, "BotTravel_Grapple: activating grapple\n");
#endif //DEBUG_GRAPPLE
//check if the grapple missile path is clear
VectorAdd(ms->origin, ms->viewoffset, org);
- trace = AAS_Trace(org, NULL, NULL, reach->end, ms->entitynum, CONTENTS_SOLID);
+ trap_Trace(&trace, org, NULL, NULL, reach->end, ms->entitynum, CONTENTS_SOLID);
VectorSubtract(reach->end, trace.endpos, dir);
if (VectorLength(dir) > 16)
{
@@ -2667,9 +2685,9 @@ bot_moveresult_t BotTravel_Grapple(bot_movestate_t *ms, aas_reachability_t *reac
return result;
} //end if
//activate the grapple
- if (offhandgrapple->value)
+ if (bot_offhandgrapple.integer)
{
- EA_Command(ms->client, cmd_grappleon->string);
+ EA_Command(ms->client, CMD_GRAPPLEON);
} //end if
else
{
@@ -2689,7 +2707,7 @@ bot_moveresult_t BotTravel_Grapple(bot_movestate_t *ms, aas_reachability_t *reac
VectorCopy(dir, result.movedir);
} //end else
//if in another area before actually grappling
- areanum = AAS_PointAreaNum(ms->origin);
+ areanum = trap_AAS_PointAreaNum(ms->origin);
if (areanum && areanum != ms->reachareanum) ms->reachability_time = 0;
} //end else
return result;
@@ -2706,7 +2724,7 @@ bot_moveresult_t BotTravel_RocketJump(bot_movestate_t *ms, aas_reachability_t *r
float dist, speed;
bot_moveresult_t_cleared( result );
- //botimport.Print(PRT_MESSAGE, "BotTravel_RocketJump: bah\n");
+ //BotAI_Print(PRT_MESSAGE, "BotTravel_RocketJump: bah\n");
//
hordir[0] = reach->start[0] - ms->origin[0];
hordir[1] = reach->start[1] - ms->origin[1];
@@ -2722,7 +2740,7 @@ bot_moveresult_t BotTravel_RocketJump(bot_movestate_t *ms, aas_reachability_t *r
fabs(AngleDiff(result.ideal_viewangles[0], ms->viewangles[0])) < 5 &&
fabs(AngleDiff(result.ideal_viewangles[1], ms->viewangles[1])) < 5)
{
- //botimport.Print(PRT_MESSAGE, "between jump start and run start point\n");
+ //BotAI_Print(PRT_MESSAGE, "between jump start and run start point\n");
hordir[0] = reach->end[0] - ms->origin[0];
hordir[1] = reach->end[1] - ms->origin[1];
hordir[2] = 0;
@@ -2749,9 +2767,9 @@ bot_moveresult_t BotTravel_RocketJump(bot_movestate_t *ms, aas_reachability_t *r
//view is important for the movment
result.flags |= MOVERESULT_MOVEMENTVIEWSET;
//select the rocket launcher
- EA_SelectWeapon(ms->client, (int) weapindex_rocketlauncher->value);
+ EA_SelectWeapon(ms->client, WP_ROCKET_LAUNCHER);
//weapon is used for movement
- result.weapon = (int) weapindex_rocketlauncher->value;
+ result.weapon = WP_ROCKET_LAUNCHER;
result.flags |= MOVERESULT_MOVEMENTWEAPON;
//
VectorCopy(hordir, result.movedir);
@@ -2770,7 +2788,7 @@ bot_moveresult_t BotTravel_BFGJump(bot_movestate_t *ms, aas_reachability_t *reac
float dist, speed;
bot_moveresult_t_cleared( result );
- //botimport.Print(PRT_MESSAGE, "BotTravel_BFGJump: bah\n");
+ //BotAI_Print(PRT_MESSAGE, "BotTravel_BFGJump: bah\n");
//
hordir[0] = reach->start[0] - ms->origin[0];
hordir[1] = reach->start[1] - ms->origin[1];
@@ -2782,7 +2800,7 @@ bot_moveresult_t BotTravel_BFGJump(bot_movestate_t *ms, aas_reachability_t *reac
fabs(AngleDiff(result.ideal_viewangles[0], ms->viewangles[0])) < 5 &&
fabs(AngleDiff(result.ideal_viewangles[1], ms->viewangles[1])) < 5)
{
- //botimport.Print(PRT_MESSAGE, "between jump start and run start point\n");
+ //BotAI_Print(PRT_MESSAGE, "between jump start and run start point\n");
hordir[0] = reach->end[0] - ms->origin[0];
hordir[1] = reach->end[1] - ms->origin[1];
hordir[2] = 0;
@@ -2809,9 +2827,9 @@ bot_moveresult_t BotTravel_BFGJump(bot_movestate_t *ms, aas_reachability_t *reac
//view is important for the movment
result.flags |= MOVERESULT_MOVEMENTVIEWSET;
//select the rocket launcher
- EA_SelectWeapon(ms->client, (int) weapindex_bfg10k->value);
+ EA_SelectWeapon(ms->client, WP_BFG);
//weapon is used for movement
- result.weapon = (int) weapindex_bfg10k->value;
+ result.weapon = WP_BFG;
result.flags |= MOVERESULT_MOVEMENTWEAPON;
//
VectorCopy(hordir, result.movedir);
@@ -2935,7 +2953,7 @@ int BotReachabilityTime(aas_reachability_t *reach)
case TRAVEL_FUNCBOB: return 10;
default:
{
- botimport.Print(PRT_ERROR, "travel type %d not implemented yet\n", reach->traveltype);
+ BotAI_Print(PRT_ERROR, "travel type %d not implemented yet\n", reach->traveltype);
return 8;
} //end case
} //end switch
@@ -2953,9 +2971,9 @@ bot_moveresult_t BotMoveInGoalArea(bot_movestate_t *ms, bot_goal_t *goal)
float dist, speed;
#ifdef DEBUG
- //botimport.Print(PRT_MESSAGE, "%s: moving straight to goal\n", ClientName(ms->entitynum-1));
- //AAS_ClearShownDebugLines();
- //AAS_DebugLine(ms->origin, goal->origin, LINECOLOR_RED);
+ //BotAI_Print(PRT_MESSAGE, "%s: moving straight to goal\n", ClientName(ms->entitynum-1));
+ //trap_AAS_ClearShownDebugLines();
+ //trap_AAS_DebugLine(ms->origin, goal->origin, LINECOLOR_RED);
#endif //DEBUG
//walk straight to the goal origin
dir[0] = goal->origin[0] - ms->origin[0];
@@ -3008,7 +3026,7 @@ void BotMoveToGoal(bot_moveresult_t *result, int movestate, bot_goal_t *goal, in
aas_reachability_t reach, lastreach;
bot_movestate_t *ms;
//vec3_t mins, maxs, up = {0, 0, 1};
- //bsp_trace_t trace;
+ //trace_t trace;
//static int debugline;
result->failure = qfalse;
@@ -3028,17 +3046,17 @@ void BotMoveToGoal(bot_moveresult_t *result, int movestate, bot_goal_t *goal, in
if (!goal)
{
#ifdef DEBUG
- botimport.Print(PRT_MESSAGE, "client %d: movetogoal -> no goal\n", ms->client);
+ BotAI_Print(PRT_MESSAGE, "client %d: movetogoal -> no goal\n", ms->client);
#endif //DEBUG
result->failure = qtrue;
return;
} //end if
- //botimport.Print(PRT_MESSAGE, "numavoidreach = %d\n", ms->numavoidreach);
+ //BotAI_Print(PRT_MESSAGE, "numavoidreach = %d\n", ms->numavoidreach);
//remove some of the move flags
ms->moveflags &= ~(MFL_SWIMMING|MFL_AGAINSTLADDER);
//set some of the move flags
//NOTE: the MFL_ONGROUND flag is also set in the higher AI
- if (AAS_OnGround(ms->origin, ms->presencetype, ms->entitynum)) ms->moveflags |= MFL_ONGROUND;
+ if (trap_AAS_OnGround(ms->origin, ms->presencetype, ms->entitynum)) ms->moveflags |= MFL_ONGROUND;
//
if (ms->moveflags & MFL_ONGROUND)
{
@@ -3048,30 +3066,30 @@ void BotMoveToGoal(bot_moveresult_t *result, int movestate, bot_goal_t *goal, in
if (ent != -1)
{
- modelnum = AAS_EntityModelindex(ent);
+ modelnum = trap_AAS_EntityModelindex(ent);
if (modelnum >= 0 && modelnum < MAX_MODELS)
{
modeltype = modeltypes[modelnum];
if (modeltype == MODELTYPE_FUNC_PLAT)
{
- AAS_ReachabilityFromNum(ms->lastreachnum, &reach);
+ trap_AAS_ReachabilityFromNum(ms->lastreachnum, &reach);
//if the bot is Not using the elevator
if ((reach.traveltype & TRAVELTYPE_MASK) != TRAVEL_ELEVATOR ||
//NOTE: the face number is the plat model number
(reach.facenum & 0x0000FFFF) != modelnum)
{
- reachnum = AAS_NextModelReachability(0, modelnum);
+ reachnum = trap_AAS_NextModelReachability(0, modelnum);
if (reachnum)
{
- //botimport.Print(PRT_MESSAGE, "client %d: accidentally ended up on func_plat\n", ms->client);
- AAS_ReachabilityFromNum(reachnum, &reach);
+ //BotAI_Print(PRT_MESSAGE, "client %d: accidentally ended up on func_plat\n", ms->client);
+ trap_AAS_ReachabilityFromNum(reachnum, &reach);
ms->lastreachnum = reachnum;
- ms->reachability_time = AAS_Time() + BotReachabilityTime(&reach);
+ ms->reachability_time = trap_AAS_Time() + BotReachabilityTime(&reach);
} //end if
else
{
- botimport.Print(PRT_DEVELOPER, "client %d: on func_plat without reachability\n", ms->client);
+ BotAI_Print(PRT_DEVELOPER, "client %d: on func_plat without reachability\n", ms->client);
result->blocked = qtrue;
result->blockentity = ent;
result->flags |= MOVERESULT_ONTOPOFOBSTACLE;
@@ -3082,23 +3100,23 @@ void BotMoveToGoal(bot_moveresult_t *result, int movestate, bot_goal_t *goal, in
} //end if
else if (modeltype == MODELTYPE_FUNC_BOB)
{
- AAS_ReachabilityFromNum(ms->lastreachnum, &reach);
+ trap_AAS_ReachabilityFromNum(ms->lastreachnum, &reach);
//if the bot is Not using the func bobbing
if ((reach.traveltype & TRAVELTYPE_MASK) != TRAVEL_FUNCBOB ||
//NOTE: the face number is the func_bobbing model number
(reach.facenum & 0x0000FFFF) != modelnum)
{
- reachnum = AAS_NextModelReachability(0, modelnum);
+ reachnum = trap_AAS_NextModelReachability(0, modelnum);
if (reachnum)
{
- //botimport.Print(PRT_MESSAGE, "client %d: accidentally ended up on func_bobbing\n", ms->client);
- AAS_ReachabilityFromNum(reachnum, &reach);
+ //BotAI_Print(PRT_MESSAGE, "client %d: accidentally ended up on func_bobbing\n", ms->client);
+ trap_AAS_ReachabilityFromNum(reachnum, &reach);
ms->lastreachnum = reachnum;
- ms->reachability_time = AAS_Time() + BotReachabilityTime(&reach);
+ ms->reachability_time = trap_AAS_Time() + BotReachabilityTime(&reach);
} //end if
else
{
- botimport.Print(PRT_DEVELOPER, "client %d: on func_bobbing without reachability\n", ms->client);
+ BotAI_Print(PRT_DEVELOPER, "client %d: on func_bobbing without reachability\n", ms->client);
result->blocked = qtrue;
result->blockentity = ent;
result->flags |= MOVERESULT_ONTOPOFOBSTACLE;
@@ -3112,7 +3130,7 @@ void BotMoveToGoal(bot_moveresult_t *result, int movestate, bot_goal_t *goal, in
// check if ontop of a door bridge ?
ms->areanum = BotFuzzyPointReachabilityArea(ms->origin);
// if not in a reachability area
- if (!AAS_AreaReachability(ms->areanum))
+ if (!trap_AAS_AreaReachability(ms->areanum))
{
result->blocked = qtrue;
result->blockentity = ent;
@@ -3131,15 +3149,15 @@ void BotMoveToGoal(bot_moveresult_t *result, int movestate, bot_goal_t *goal, in
} //end if
} //end if
//if swimming
- if (AAS_Swimming(ms->origin)) ms->moveflags |= MFL_SWIMMING;
+ if (trap_AAS_Swimming(ms->origin)) ms->moveflags |= MFL_SWIMMING;
//if against a ladder
- if (AAS_AgainstLadder(ms->origin)) ms->moveflags |= MFL_AGAINSTLADDER;
+ if (trap_AAS_AgainstLadder(ms->origin)) ms->moveflags |= MFL_AGAINSTLADDER;
//if the bot is on the ground, swimming or against a ladder
if (ms->moveflags & (MFL_ONGROUND|MFL_SWIMMING|MFL_AGAINSTLADDER))
{
- //botimport.Print(PRT_MESSAGE, "%s: onground, swimming or against ladder\n", ClientName(ms->entitynum-1));
+ //BotAI_Print(PRT_MESSAGE, "%s: onground, swimming or against ladder\n", ClientName(ms->entitynum-1));
//
- AAS_ReachabilityFromNum(ms->lastreachnum, &lastreach);
+ trap_AAS_ReachabilityFromNum(ms->lastreachnum, &lastreach);
//reachability area the bot is in
//ms->areanum = BotReachabilityArea(ms->origin, ((lastreach.traveltype & TRAVELTYPE_MASK) != TRAVEL_ELEVATOR));
ms->areanum = BotFuzzyPointReachabilityArea(ms->origin);
@@ -3163,16 +3181,16 @@ void BotMoveToGoal(bot_moveresult_t *result, int movestate, bot_goal_t *goal, in
//if there is a last reachability
if (reachnum)
{
- AAS_ReachabilityFromNum(reachnum, &reach);
+ trap_AAS_ReachabilityFromNum(reachnum, &reach);
//check if the reachability is still valid
- if (!(AAS_TravelFlagForType(reach.traveltype) & travelflags))
+ if (!(trap_AAS_TravelFlagForType(reach.traveltype) & travelflags))
{
reachnum = 0;
} //end if
//special grapple hook case
else if ((reach.traveltype & TRAVELTYPE_MASK) == TRAVEL_GRAPPLEHOOK)
{
- if (ms->reachability_time < AAS_Time() ||
+ if (ms->reachability_time < trap_AAS_Time() ||
(ms->moveflags & MFL_GRAPPLERESET))
{
reachnum = 0;
@@ -3185,11 +3203,11 @@ void BotMoveToGoal(bot_moveresult_t *result, int movestate, bot_goal_t *goal, in
if ((result->flags & MOVERESULT_ONTOPOF_ELEVATOR) ||
(result->flags & MOVERESULT_ONTOPOF_FUNCBOB))
{
- ms->reachability_time = AAS_Time() + 5;
+ ms->reachability_time = trap_AAS_Time() + 5;
} //end if
//if the bot was going for an elevator and reached the reachability area
if (ms->areanum == reach.areanum ||
- ms->reachability_time < AAS_Time())
+ ms->reachability_time < trap_AAS_Time())
{
reachnum = 0;
} //end if
@@ -3197,29 +3215,29 @@ void BotMoveToGoal(bot_moveresult_t *result, int movestate, bot_goal_t *goal, in
else
{
#ifdef DEBUG
- if (botDeveloper)
+ if (bot_developer.integer)
{
- if (ms->reachability_time < AAS_Time())
+ if (ms->reachability_time < trap_AAS_Time())
{
- botimport.Print(PRT_MESSAGE, "client %d: reachability timeout in ", ms->client);
- AAS_PrintTravelType(reach.traveltype & TRAVELTYPE_MASK);
- botimport.Print(PRT_MESSAGE, "\n");
+ BotAI_Print(PRT_MESSAGE, "client %d: reachability timeout in ", ms->client);
+ trap_AAS_PrintTravelType(reach.traveltype & TRAVELTYPE_MASK);
+ BotAI_Print(PRT_MESSAGE, "\n");
} //end if
/*
if (ms->lastareanum != ms->areanum)
{
- botimport.Print(PRT_MESSAGE, "changed from area %d to %d\n", ms->lastareanum, ms->areanum);
+ BotAI_Print(PRT_MESSAGE, "changed from area %d to %d\n", ms->lastareanum, ms->areanum);
} //end if*/
} //end if
#endif //DEBUG
//if the goal area changed or the reachability timed out
//or the area changed
if (ms->lastgoalareanum != goal->areanum ||
- ms->reachability_time < AAS_Time() ||
+ ms->reachability_time < trap_AAS_Time() ||
ms->lastareanum != ms->areanum)
{
reachnum = 0;
- //botimport.Print(PRT_MESSAGE, "area change or timeout\n");
+ //BotAI_Print(PRT_MESSAGE, "area change or timeout\n");
} //end else if
} //end else
} //end if
@@ -3228,10 +3246,10 @@ void BotMoveToGoal(bot_moveresult_t *result, int movestate, bot_goal_t *goal, in
if (!reachnum)
{
//if the area has no reachability links
- if (!AAS_AreaReachability(ms->areanum))
+ if (!trap_AAS_AreaReachability(ms->areanum))
{
#ifdef DEBUG
- botimport.Print(PRT_DEVELOPER, "area %d no reachability\n", ms->areanum);
+ BotAI_Print(PRT_DEVELOPER, "area %d no reachability\n", ms->areanum);
#endif //DEBUG
} //end if
//get a new reachability leading towards the goal
@@ -3248,9 +3266,9 @@ void BotMoveToGoal(bot_moveresult_t *result, int movestate, bot_goal_t *goal, in
//if there is a reachability to the goal
if (reachnum)
{
- AAS_ReachabilityFromNum(reachnum, &reach);
+ trap_AAS_ReachabilityFromNum(reachnum, &reach);
//set a timeout for this reachability
- ms->reachability_time = AAS_Time() + BotReachabilityTime(&reach);
+ ms->reachability_time = trap_AAS_Time() + BotReachabilityTime(&reach);
//
#ifdef AVOIDREACH
//add the reachability to the reachabilities to avoid for a while
@@ -3259,19 +3277,19 @@ void BotMoveToGoal(bot_moveresult_t *result, int movestate, bot_goal_t *goal, in
} //end if
#ifdef DEBUG
- else if (botDeveloper)
+ else if (bot_developer.integer)
{
- botimport.Print(PRT_MESSAGE, "goal not reachable\n");
+ BotAI_Print(PRT_MESSAGE, "goal not reachable\n");
Com_Memset(&reach, 0, sizeof(aas_reachability_t)); //make compiler happy
} //end else
- if (botDeveloper)
+ if (bot_developer.integer)
{
//if still going for the same goal
if (ms->lastgoalareanum == goal->areanum)
{
if (ms->lastareanum == reach.areanum)
{
- botimport.Print(PRT_MESSAGE, "same goal, going back to previous area\n");
+ BotAI_Print(PRT_MESSAGE, "same goal, going back to previous area\n");
} //end if
} //end if
} //end if
@@ -3285,19 +3303,19 @@ void BotMoveToGoal(bot_moveresult_t *result, int movestate, bot_goal_t *goal, in
if (reachnum)
{
//get the reachability from the number
- AAS_ReachabilityFromNum(reachnum, &reach);
+ trap_AAS_ReachabilityFromNum(reachnum, &reach);
result->traveltype = reach.traveltype;
//
#ifdef DEBUG_AI_MOVE
- AAS_ClearShownDebugLines();
- AAS_PrintTravelType(reach.traveltype & TRAVELTYPE_MASK);
- AAS_ShowReachability(&reach);
+ trap_AAS_ClearShownDebugLines();
+ trap_AAS_PrintTravelType(reach.traveltype & TRAVELTYPE_MASK);
+ trap_AAS_ShowReachability(&reach);
#endif //DEBUG_AI_MOVE
//
#ifdef DEBUG
- //botimport.Print(PRT_MESSAGE, "client %d: ", ms->client);
- //AAS_PrintTravelType(reach.traveltype);
- //botimport.Print(PRT_MESSAGE, "\n");
+ //BotAI_Print(PRT_MESSAGE, "client %d: ", ms->client);
+ //trap_AAS_PrintTravelType(reach.traveltype);
+ //BotAI_Print(PRT_MESSAGE, "\n");
#endif //DEBUG
switch(reach.traveltype & TRAVELTYPE_MASK)
{
@@ -3318,7 +3336,7 @@ void BotMoveToGoal(bot_moveresult_t *result, int movestate, bot_goal_t *goal, in
case TRAVEL_FUNCBOB: *result = BotTravel_FuncBobbing(ms, &reach); break;
default:
{
- botimport.Print(PRT_FATAL, "travel type %d not implemented yet\n", (reach.traveltype & TRAVELTYPE_MASK));
+ BotAI_Print(PRT_FATAL, "travel type %d not implemented yet\n", (reach.traveltype & TRAVELTYPE_MASK));
break;
} //end case
} //end switch
@@ -3332,13 +3350,13 @@ void BotMoveToGoal(bot_moveresult_t *result, int movestate, bot_goal_t *goal, in
Com_Memset(&reach, 0, sizeof(aas_reachability_t));
} //end else
#ifdef DEBUG
- if (botDeveloper)
+ if (bot_developer.integer)
{
if (result->failure)
{
- botimport.Print(PRT_MESSAGE, "client %d: movement failure in ", ms->client);
- AAS_PrintTravelType(reach.traveltype & TRAVELTYPE_MASK);
- botimport.Print(PRT_MESSAGE, "\n");
+ BotAI_Print(PRT_MESSAGE, "client %d: movement failure in ", ms->client);
+ trap_AAS_PrintTravelType(reach.traveltype & TRAVELTYPE_MASK);
+ BotAI_Print(PRT_MESSAGE, "\n");
} //end if
} //end if
#endif //DEBUG
@@ -3351,12 +3369,12 @@ void BotMoveToGoal(bot_moveresult_t *result, int movestate, bot_goal_t *goal, in
//special handling of jump pads when the bot uses a jump pad without knowing it
foundjumppad = qfalse;
VectorMA(ms->origin, -2 * ms->thinktime, ms->velocity, end);
- numareas = AAS_TraceAreas(ms->origin, end, areas, NULL, 16);
+ numareas = trap_AAS_TraceAreas(ms->origin, end, areas, NULL, 16);
for (i = numareas-1; i >= 0; i--)
{
- if (AAS_AreaJumpPad(areas[i]))
+ if (trap_AAS_AreaJumpPad(areas[i]))
{
- //botimport.Print(PRT_MESSAGE, "client %d used a jumppad without knowing, area %d\n", ms->client, areas[i]);
+ //BotAI_Print(PRT_MESSAGE, "client %d used a jumppad without knowing, area %d\n", ms->client, areas[i]);
foundjumppad = qtrue;
lastreachnum = BotGetReachabilityToGoal(end, areas[i],
ms->lastgoalareanum, ms->lastareanum,
@@ -3366,45 +3384,45 @@ void BotMoveToGoal(bot_moveresult_t *result, int movestate, bot_goal_t *goal, in
{
ms->lastreachnum = lastreachnum;
ms->lastareanum = areas[i];
- //botimport.Print(PRT_MESSAGE, "found jumppad reachability\n");
+ //BotAI_Print(PRT_MESSAGE, "found jumppad reachability\n");
break;
} //end if
else
{
- for (lastreachnum = AAS_NextAreaReachability(areas[i], 0); lastreachnum;
- lastreachnum = AAS_NextAreaReachability(areas[i], lastreachnum))
+ for (lastreachnum = trap_AAS_NextAreaReachability(areas[i], 0); lastreachnum;
+ lastreachnum = trap_AAS_NextAreaReachability(areas[i], lastreachnum))
{
//get the reachability from the number
- AAS_ReachabilityFromNum(lastreachnum, &reach);
+ trap_AAS_ReachabilityFromNum(lastreachnum, &reach);
if ((reach.traveltype & TRAVELTYPE_MASK) == TRAVEL_JUMPPAD)
{
ms->lastreachnum = lastreachnum;
ms->lastareanum = areas[i];
- //botimport.Print(PRT_MESSAGE, "found jumppad reachability hard!!\n");
+ //BotAI_Print(PRT_MESSAGE, "found jumppad reachability hard!!\n");
} //end if
} //end for
if (lastreachnum) break;
} //end else
} //end if
} //end for
- if (botDeveloper)
+ if (bot_developer.integer)
{
//if a jumppad is found with the trace but no reachability is found
if (foundjumppad && !ms->lastreachnum)
{
- botimport.Print(PRT_MESSAGE, "client %d didn't find jumppad reachability\n", ms->client);
+ BotAI_Print(PRT_MESSAGE, "client %d didn't find jumppad reachability\n", ms->client);
} //end if
} //end if
//
if (ms->lastreachnum)
{
- //botimport.Print(PRT_MESSAGE, "%s: NOT onground, swimming or against ladder\n", ClientName(ms->entitynum-1));
- AAS_ReachabilityFromNum(ms->lastreachnum, &reach);
+ //BotAI_Print(PRT_MESSAGE, "%s: NOT onground, swimming or against ladder\n", ClientName(ms->entitynum-1));
+ trap_AAS_ReachabilityFromNum(ms->lastreachnum, &reach);
result->traveltype = reach.traveltype;
#ifdef DEBUG
- //botimport.Print(PRT_MESSAGE, "client %d finish: ", ms->client);
- //AAS_PrintTravelType(reach.traveltype & TRAVELTYPE_MASK);
- //botimport.Print(PRT_MESSAGE, "\n");
+ //BotAI_Print(PRT_MESSAGE, "client %d finish: ", ms->client);
+ //trap_AAS_PrintTravelType(reach.traveltype & TRAVELTYPE_MASK);
+ //BotAI_Print(PRT_MESSAGE, "\n");
#endif //DEBUG
//
switch(reach.traveltype & TRAVELTYPE_MASK)
@@ -3426,19 +3444,19 @@ void BotMoveToGoal(bot_moveresult_t *result, int movestate, bot_goal_t *goal, in
case TRAVEL_FUNCBOB: *result = BotFinishTravel_FuncBobbing(ms, &reach); break;
default:
{
- botimport.Print(PRT_FATAL, "(last) travel type %d not implemented yet\n", (reach.traveltype & TRAVELTYPE_MASK));
+ BotAI_Print(PRT_FATAL, "(last) travel type %d not implemented yet\n", (reach.traveltype & TRAVELTYPE_MASK));
break;
} //end case
} //end switch
result->traveltype = reach.traveltype;
#ifdef DEBUG
- if (botDeveloper)
+ if (bot_developer.integer)
{
if (result->failure)
{
- botimport.Print(PRT_MESSAGE, "client %d: movement failure in finish ", ms->client);
- AAS_PrintTravelType(reach.traveltype & TRAVELTYPE_MASK);
- botimport.Print(PRT_MESSAGE, "\n");
+ BotAI_Print(PRT_MESSAGE, "client %d: movement failure in finish ", ms->client);
+ trap_AAS_PrintTravelType(reach.traveltype & TRAVELTYPE_MASK);
+ BotAI_Print(PRT_MESSAGE, "\n");
} //end if
} //end if
#endif //DEBUG
@@ -3520,16 +3538,9 @@ void BotResetMoveState(int movestate)
int BotSetupMoveAI(void)
{
BotSetBrushModelTypes();
- sv_maxstep = LibVar("sv_step", "18");
- sv_maxbarrier = LibVar("sv_maxbarrier", "32");
- sv_gravity = LibVar("sv_gravity", "800");
- weapindex_rocketlauncher = LibVar("weapindex_rocketlauncher", "5");
- weapindex_bfg10k = LibVar("weapindex_bfg10k", "9");
- weapindex_grapple = LibVar("weapindex_grapple", "10");
- entitytypemissile = LibVar("entitytypemissile", "3");
- offhandgrapple = LibVar("offhandgrapple", "0");
- cmd_grappleon = LibVar("cmd_grappleon", "grappleon");
- cmd_grappleoff = LibVar("cmd_grappleoff", "grappleoff");
+
+ phys_maxbarrier = BotLibVarGetValue("phys_maxbarrier");
+
return BLERR_NOERROR;
} //end of the function BotSetupMoveAI
//===========================================================================
@@ -3540,16 +3551,7 @@ int BotSetupMoveAI(void)
//===========================================================================
void BotShutdownMoveAI(void)
{
- int i;
- for (i = 1; i <= MAX_CLIENTS; i++)
- {
- if (botmovestates[i])
- {
- FreeMemory(botmovestates[i]);
- botmovestates[i] = NULL;
- } //end if
- } //end for
} //end of the function BotShutdownMoveAI
diff --git a/code/botlib/be_ai_move.h b/code/game/ai_move.h
similarity index 73%
rename from code/botlib/be_ai_move.h
rename to code/game/ai_move.h
index c4680eac8..021520686 100644
--- a/code/botlib/be_ai_move.h
+++ b/code/game/ai_move.h
@@ -30,11 +30,11 @@ Suite 120, Rockville, Maryland 20850 USA.
//
/*****************************************************************************
- * name: be_ai_move.h
+ * name: ai_move.h
*
* desc: movement AI
*
- * $Archive: /source/code/botlib/be_ai_move.h $
+ * $Archive: /source/code/game/ai_move.h $
*
*****************************************************************************/
@@ -117,6 +117,40 @@ typedef struct bot_avoidspot_s
int type;
} bot_avoidspot_t;
+//movement state
+//NOTE: the moveflags MFL_ONGROUND, MFL_TELEPORTED, MFL_WATERJUMP and
+// MFL_GRAPPLEPULL must be set outside the movement code
+typedef struct bot_movestate_s
+{
+ //input vars (all set outside the movement code)
+ vec3_t origin; //origin of the bot
+ vec3_t velocity; //velocity of the bot
+ vec3_t viewoffset; //view offset
+ int entitynum; //entity number of the bot
+ int client; //client number of the bot
+ float thinktime; //time the bot thinks
+ int presencetype; //presencetype of the bot
+ vec3_t viewangles; //view angles of the bot
+ //state vars
+ int areanum; //area the bot is in
+ int lastareanum; //last area the bot was in
+ int lastgoalareanum; //last goal area number
+ int lastreachnum; //last reachability number
+ vec3_t lastorigin; //origin previous cycle
+ int reachareanum; //area number of the reachabilty
+ int moveflags; //movement flags
+ int jumpreach; //set when jumped
+ float grapplevisible_time; //last time the grapple was visible
+ float lastgrappledist; //last distance to the grapple end
+ float reachability_time; //time to use current reachability
+ int avoidreach[MAX_AVOIDREACH]; //reachabilities to avoid
+ float avoidreachtimes[MAX_AVOIDREACH]; //times to avoid the reachabilities
+ int avoidreachtries[MAX_AVOIDREACH]; //number of tries before avoiding
+ //
+ bot_avoidspot_t avoidspots[MAX_AVOIDSPOTS]; //spots to avoid
+ int numavoidspots;
+} bot_movestate_t;
+
//resets the whole move state
void BotResetMoveState(int movestate);
//moves the bot to the given goal
@@ -133,10 +167,6 @@ int BotReachabilityArea(vec3_t origin, int client);
int BotMovementViewTarget(int movestate, bot_goal_t *goal, int travelflags, float lookahead, vec3_t target);
//predict the position of a player based on movement towards a goal
int BotPredictVisiblePosition(vec3_t origin, int areanum, bot_goal_t *goal, int travelflags, vec3_t target);
-//returns the handle of a newly allocated movestate
-int BotAllocMoveState(void);
-//frees the movestate with the given handle
-void BotFreeMoveState(int handle);
//initialize movement state before performing any movement
void BotInitMoveState(int handle, bot_initmove_t *initmove);
//add a spot to avoid (if type == AVOID_CLEAR all spots are removed)
@@ -148,3 +178,16 @@ int BotSetupMoveAI(void);
//shutdown movement AI
void BotShutdownMoveAI(void);
+#define trap_BotAllocMoveState(_client) (_client+1)
+#define trap_BotFreeMoveState(_client) // nothing
+#define trap_BotResetMoveState BotResetMoveState
+#define trap_BotMoveToGoal BotMoveToGoal
+#define trap_BotMoveInDirection BotMoveInDirection
+#define trap_BotResetAvoidReach BotResetAvoidReach
+#define trap_BotResetLastAvoidReach BotResetLastAvoidReach
+#define trap_BotReachabilityArea BotReachabilityArea
+#define trap_BotMovementViewTarget BotMovementViewTarget
+#define trap_BotPredictVisiblePosition BotPredictVisiblePosition
+#define trap_BotInitMoveState BotInitMoveState
+#define trap_BotAddAvoidSpot BotAddAvoidSpot
+
diff --git a/code/game/ai_team.c b/code/game/ai_team.c
index 74c3a67fe..a5baa80f8 100644
--- a/code/game/ai_team.c
+++ b/code/game/ai_team.c
@@ -41,23 +41,28 @@ Suite 120, Rockville, Maryland 20850 USA.
#include "g_local.h"
#include "../botlib/botlib.h"
#include "../botlib/be_aas.h"
-#include "../botlib/be_ea.h"
#include "../botlib/be_ai_char.h"
#include "../botlib/be_ai_chat.h"
#include "../botlib/be_ai_gen.h"
-#include "../botlib/be_ai_goal.h"
-#include "../botlib/be_ai_move.h"
-#include "../botlib/be_ai_weap.h"
+//
+#include "ai_ea.h"
+#include "ai_goal.h"
+#include "ai_move.h"
+#include "ai_weap.h"
+#include "ai_weight.h"
//
#include "ai_main.h"
#include "ai_dmq3.h"
#include "ai_chat.h"
#include "ai_cmd.h"
+#include "ai_vcmd.h"
#include "ai_dmnet.h"
#include "ai_team.h"
-#include "ai_vcmd.h"
-
-#include "match.h"
+//
+#include "chars.h" //characteristics
+#include "inv.h" //indexes into the inventory
+#include "syn.h" //synonyms
+#include "match.h" //string matching types and vars
// for the voice chats
#include "../../ui/menudef.h"
diff --git a/code/game/ai_vcmd.c b/code/game/ai_vcmd.c
index a15628ddb..8f325eeac 100644
--- a/code/game/ai_vcmd.c
+++ b/code/game/ai_vcmd.c
@@ -41,21 +41,23 @@ Suite 120, Rockville, Maryland 20850 USA.
#include "g_local.h"
#include "../botlib/botlib.h"
#include "../botlib/be_aas.h"
-#include "../botlib/be_ea.h"
#include "../botlib/be_ai_char.h"
#include "../botlib/be_ai_chat.h"
#include "../botlib/be_ai_gen.h"
-#include "../botlib/be_ai_goal.h"
-#include "../botlib/be_ai_move.h"
-#include "../botlib/be_ai_weap.h"
+//
+#include "ai_ea.h"
+#include "ai_goal.h"
+#include "ai_move.h"
+#include "ai_weap.h"
+#include "ai_weight.h"
//
#include "ai_main.h"
#include "ai_dmq3.h"
#include "ai_chat.h"
#include "ai_cmd.h"
+#include "ai_vcmd.h"
#include "ai_dmnet.h"
#include "ai_team.h"
-#include "ai_vcmd.h"
//
#include "chars.h" //characteristics
#include "inv.h" //indexes into the inventory
diff --git a/code/botlib/be_ai_weap.c b/code/game/ai_weap.c
similarity index 68%
rename from code/botlib/be_ai_weap.c
rename to code/game/ai_weap.c
index 245c30877..1696f67ca 100644
--- a/code/botlib/be_ai_weap.c
+++ b/code/game/ai_weap.c
@@ -37,21 +37,32 @@ Suite 120, Rockville, Maryland 20850 USA.
*
*****************************************************************************/
-#include "../qcommon/q_shared.h"
-#include "l_libvar.h"
-#include "l_log.h"
-#include "l_memory.h"
-#include "l_utils.h"
-#include "l_script.h"
-#include "l_precomp.h"
-#include "l_struct.h"
-#include "aasfile.h"
-#include "botlib.h"
-#include "be_aas.h"
-#include "be_aas_funcs.h"
-#include "be_interface.h"
-#include "be_ai_weight.h" //fuzzy weights
-#include "be_ai_weap.h"
+#include "g_local.h"
+#include "../botlib/botlib.h"
+#include "../botlib/be_aas.h"
+#include "../botlib/be_ai_char.h"
+#include "../botlib/be_ai_chat.h"
+#include "../botlib/be_ai_gen.h"
+//
+#include "ai_ea.h"
+#include "ai_goal.h"
+#include "ai_move.h"
+#include "ai_weap.h"
+#include "ai_weight.h"
+//
+#include "ai_main.h"
+#include "ai_dmq3.h"
+#include "ai_chat.h"
+#include "ai_cmd.h"
+#include "ai_vcmd.h"
+#include "ai_dmnet.h"
+#include "ai_team.h"
+//
+#include "chars.h" //characteristics
+#include "inv.h" //indexes into the inventory
+#include "syn.h" //synonyms
+#include "match.h" //string matching types and vars
+
//#define DEBUG_AI_WEAP
@@ -117,24 +128,8 @@ static structdef_t projectileinfo_struct =
sizeof(projectileinfo_t), projectileinfo_fields
};
-//weapon configuration: set of weapons with projectiles
-typedef struct weaponconfig_s
-{
- int numweapons;
- int numprojectiles;
- projectileinfo_t *projectileinfo;
- weaponinfo_t *weaponinfo;
-} weaponconfig_t;
-
-//the bot weapon state
-typedef struct bot_weaponstate_s
-{
- struct weightconfig_s *weaponweightconfig; //weapon weight configuration
- int *weaponweightindex; //weapon weight index
-} bot_weaponstate_t;
-
-static bot_weaponstate_t *botweaponstates[MAX_CLIENTS+1];
-static weaponconfig_t *weaponconfig;
+static bot_weaponstate_t botweaponstates[MAX_CLIENTS+1];
+static weaponconfig_t weaponconfig;
//========================================================================
//
@@ -144,9 +139,9 @@ static weaponconfig_t *weaponconfig;
//========================================================================
int BotValidWeaponNumber(int weaponnum)
{
- if (weaponnum <= 0 || weaponnum > weaponconfig->numweapons)
+ if (weaponnum <= 0 || weaponnum > weaponconfig.numweapons)
{
- botimport.Print(PRT_ERROR, "weapon number out of range\n");
+ BotAI_Print(PRT_ERROR, "weapon number out of range\n");
return qfalse;
} //end if
return qtrue;
@@ -161,15 +156,10 @@ bot_weaponstate_t *BotWeaponStateFromHandle(int handle)
{
if (handle <= 0 || handle > MAX_CLIENTS)
{
- botimport.Print(PRT_FATAL, "weapon state handle %d out of range\n", handle);
- return NULL;
- } //end if
- if (!botweaponstates[handle])
- {
- botimport.Print(PRT_FATAL, "invalid weapon state %d\n", handle);
+ BotAI_Print(PRT_FATAL, "weapon state handle %d out of range\n", handle);
return NULL;
} //end if
- return botweaponstates[handle];
+ return &botweaponstates[handle];
} //end of the function BotWeaponStateFromHandle
//===========================================================================
//
@@ -203,111 +193,84 @@ void DumpWeaponConfig(weaponconfig_t *wc)
// Returns: -
// Changes Globals: -
//===========================================================================
-weaponconfig_t *LoadWeaponConfig(char *filename)
+qboolean LoadWeaponConfig(char *filename)
{
- int max_weaponinfo, max_projectileinfo;
- token_t token;
- char path[MAX_PATH];
+ pc_token_t token;
+ char path[MAX_QPATH];
int i, j;
- source_t *source;
+ int source;
weaponconfig_t *wc;
weaponinfo_t weaponinfo;
- max_weaponinfo = (int) LibVarValue("max_weaponinfo", "32");
- if (max_weaponinfo < 0)
- {
- botimport.Print(PRT_ERROR, "max_weaponinfo = %d\n", max_weaponinfo);
- max_weaponinfo = 32;
- LibVarSet("max_weaponinfo", "32");
- } //end if
- max_projectileinfo = (int) LibVarValue("max_projectileinfo", "32");
- if (max_projectileinfo < 0)
- {
- botimport.Print(PRT_ERROR, "max_projectileinfo = %d\n", max_projectileinfo);
- max_projectileinfo = 32;
- LibVarSet("max_projectileinfo", "32");
- } //end if
- strncpy(path, filename, MAX_PATH);
- PC_SetBaseFolder(BOTFILESBASEFOLDER);
- source = LoadSourceFile(path);
+ strncpy(path, filename, MAX_QPATH);
+ source = trap_PC_LoadSource(path, BOTFILESBASEFOLDER);
if (!source)
{
- botimport.Print(PRT_ERROR, "counldn't load %s\n", path);
- return NULL;
+ BotAI_Print(PRT_ERROR, "counldn't load %s\n", path);
+ return qfalse;
} //end if
//initialize weapon config
- wc = (weaponconfig_t *) GetClearedHunkMemory(sizeof(weaponconfig_t) +
- max_weaponinfo * sizeof(weaponinfo_t) +
- max_projectileinfo * sizeof(projectileinfo_t));
- wc->weaponinfo = (weaponinfo_t *) ((char *) wc + sizeof(weaponconfig_t));
- wc->projectileinfo = (projectileinfo_t *) ((char *) wc->weaponinfo +
- max_weaponinfo * sizeof(weaponinfo_t));
- wc->numweapons = max_weaponinfo;
+ wc = &weaponconfig;
+ memset(wc, 0, sizeof (weaponconfig_t) );
+ wc->numweapons = MAX_WEAPONS;
wc->numprojectiles = 0;
//parse the source file
- while(PC_ReadToken(source, &token))
+ while(trap_PC_ReadToken(source, &token))
{
if (!strcmp(token.string, "weaponinfo"))
{
Com_Memset(&weaponinfo, 0, sizeof(weaponinfo_t));
- if (!ReadStructure(source, &weaponinfo_struct, (char *) &weaponinfo))
+ if (!PC_ReadStructure(source, &weaponinfo_struct, (void *) &weaponinfo))
{
- FreeMemory(wc);
- FreeSource(source);
- return NULL;
+ trap_PC_FreeSource(source);
+ return qfalse;
} //end if
- if (weaponinfo.number < 0 || weaponinfo.number >= max_weaponinfo)
+ if (weaponinfo.number < 0 || weaponinfo.number >= MAX_WEAPONS)
{
- botimport.Print(PRT_ERROR, "weapon info number %d out of range in %s\n", weaponinfo.number, path);
- FreeMemory(wc);
- FreeSource(source);
- return NULL;
+ BotAI_Print(PRT_ERROR, "weapon info number %d out of range in %s\n", weaponinfo.number, path);
+ trap_PC_FreeSource(source);
+ return qfalse;
} //end if
Com_Memcpy(&wc->weaponinfo[weaponinfo.number], &weaponinfo, sizeof(weaponinfo_t));
wc->weaponinfo[weaponinfo.number].valid = qtrue;
} //end if
else if (!strcmp(token.string, "projectileinfo"))
{
- if (wc->numprojectiles >= max_projectileinfo)
+ if (wc->numprojectiles >= MAX_WEAPONS)
{
- botimport.Print(PRT_ERROR, "more than %d projectiles defined in %s\n", max_projectileinfo, path);
- FreeMemory(wc);
- FreeSource(source);
- return NULL;
+ BotAI_Print(PRT_ERROR, "more than %d projectiles defined in %s\n", MAX_WEAPONS, path);
+ trap_PC_FreeSource(source);
+ return qfalse;
} //end if
Com_Memset(&wc->projectileinfo[wc->numprojectiles], 0, sizeof(projectileinfo_t));
- if (!ReadStructure(source, &projectileinfo_struct, (char *) &wc->projectileinfo[wc->numprojectiles]))
+ if (!PC_ReadStructure(source, &projectileinfo_struct, (void *) &wc->projectileinfo[wc->numprojectiles]))
{
- FreeMemory(wc);
- FreeSource(source);
- return NULL;
+ trap_PC_FreeSource(source);
+ return qfalse;
} //end if
wc->numprojectiles++;
} //end if
else
{
- botimport.Print(PRT_ERROR, "unknown definition %s in %s\n", token.string, path);
- FreeMemory(wc);
- FreeSource(source);
- return NULL;
+ BotAI_Print(PRT_ERROR, "unknown definition %s in %s\n", token.string, path);
+ trap_PC_FreeSource(source);
+ return qfalse;
} //end else
} //end while
- FreeSource(source);
+ trap_PC_FreeSource(source);
//fix up weapons
for (i = 0; i < wc->numweapons; i++)
{
if (!wc->weaponinfo[i].valid) continue;
if (!wc->weaponinfo[i].name[0])
{
- botimport.Print(PRT_ERROR, "weapon %d has no name in %s\n", i, path);
- FreeMemory(wc);
- return NULL;
+ BotAI_Print(PRT_ERROR, "weapon %d has no name in %s\n", i, path);
+ return qfalse;
} //end if
if (!wc->weaponinfo[i].projectile[0])
{
- botimport.Print(PRT_ERROR, "weapon %s has no projectile in %s\n", wc->weaponinfo[i].name, path);
- FreeMemory(wc);
- return NULL;
+ BotAI_Print(PRT_ERROR, "weapon %s has no projectile in %s\n", wc->weaponinfo[i].name, path);
+ return qfalse;
} //end if
//find the projectile info and copy it to the weapon info
for (j = 0; j < wc->numprojectiles; j++)
@@ -320,14 +283,14 @@ weaponconfig_t *LoadWeaponConfig(char *filename)
} //end for
if (j == wc->numprojectiles)
{
- botimport.Print(PRT_ERROR, "weapon %s uses undefined projectile in %s\n", wc->weaponinfo[i].name, path);
- FreeMemory(wc);
- return NULL;
+ BotAI_Print(PRT_ERROR, "weapon %s uses undefined projectile in %s\n", wc->weaponinfo[i].name, path);
+ return qfalse;
} //end if
} //end for
- if (!wc->numweapons) botimport.Print(PRT_WARNING, "no weapon info loaded\n");
- botimport.Print(PRT_DEVELOPER, "loaded %s\n", path);
- return wc;
+ if (!wc->numweapons) BotAI_Print(PRT_WARNING, "no weapon info loaded\n");
+ BotAI_Print(PRT_DEVELOPER, "loaded %s\n", path);
+ wc->valid = qtrue;
+ return qtrue;
} //end of the function LoadWeaponConfig
//===========================================================================
//
@@ -335,18 +298,18 @@ weaponconfig_t *LoadWeaponConfig(char *filename)
// Returns: -
// Changes Globals: -
//===========================================================================
-int *WeaponWeightIndex(weightconfig_t *wwc, weaponconfig_t *wc)
+void WeaponWeightIndex(const weaponconfig_t *wc, weightconfig_t *wwc, int *index)
{
- int *index, i;
-
- //initialize item weight index
- index = (int *) GetClearedMemory(sizeof(int) * wc->numweapons);
+ int i;
for (i = 0; i < wc->numweapons; i++)
{
index[i] = FindFuzzyWeight(wwc, wc->weaponinfo[i].name);
} //end for
- return index;
+ for ( ; i < MAX_WEAPONS; i++)
+ {
+ index[i] = -1;
+ } //end for
} //end of the function WeaponWeightIndex
//===========================================================================
//
@@ -361,7 +324,6 @@ void BotFreeWeaponWeights(int weaponstate)
ws = BotWeaponStateFromHandle(weaponstate);
if (!ws) return;
if (ws->weaponweightconfig) FreeWeightConfig(ws->weaponweightconfig);
- if (ws->weaponweightindex) FreeMemory(ws->weaponweightindex);
} //end of the function BotFreeWeaponWeights
//===========================================================================
//
@@ -380,11 +342,10 @@ int BotLoadWeaponWeights(int weaponstate, char *filename)
ws->weaponweightconfig = ReadWeightConfig(filename);
if (!ws->weaponweightconfig)
{
- botimport.Print(PRT_FATAL, "couldn't load weapon config %s\n", filename);
+ BotAI_Print(PRT_FATAL, "couldn't load weapon config %s\n", filename);
return BLERR_CANNOTLOADWEAPONWEIGHTS;
} //end if
- if (!weaponconfig) return BLERR_CANNOTLOADWEAPONCONFIG;
- ws->weaponweightindex = WeaponWeightIndex(ws->weaponweightconfig, weaponconfig);
+ WeaponWeightIndex(&weaponconfig, ws->weaponweightconfig, ws->weaponweightindex);
return BLERR_NOERROR;
} //end of the function BotLoadWeaponWeights
//===========================================================================
@@ -395,13 +356,10 @@ int BotLoadWeaponWeights(int weaponstate, char *filename)
//===========================================================================
void BotGetWeaponInfo(int weaponstate, int weapon, weaponinfo_t *weaponinfo)
{
- bot_weaponstate_t *ws;
-
+ (void)weaponstate;
if (!BotValidWeaponNumber(weapon)) return;
- ws = BotWeaponStateFromHandle(weaponstate);
- if (!ws) return;
- if (!weaponconfig) return;
- Com_Memcpy(weaponinfo, &weaponconfig->weaponinfo[weapon], sizeof(weaponinfo_t));
+ if (!weaponconfig.valid) return;
+ Com_Memcpy(weaponinfo, &weaponconfig.weaponinfo[weapon], sizeof(weaponinfo_t));
} //end of the function BotGetWeaponInfo
//===========================================================================
//
@@ -418,8 +376,8 @@ int BotChooseBestFightWeapon(int weaponstate, int *inventory)
ws = BotWeaponStateFromHandle(weaponstate);
if (!ws) return 0;
- wc = weaponconfig;
- if (!weaponconfig) return 0;
+ wc = &weaponconfig;
+ if (!weaponconfig.valid) return 0;
//if the bot has no weapon weight configuration
if (!ws->weaponweightconfig) return 0;
@@ -455,41 +413,9 @@ void BotResetWeaponState(int weaponstate)
// Returns: -
// Changes Globals: -
//========================================================================
-int BotAllocWeaponState(void)
-{
- int i;
-
- for (i = 1; i <= MAX_CLIENTS; i++)
- {
- if (!botweaponstates[i])
- {
- botweaponstates[i] = GetClearedMemory(sizeof(bot_weaponstate_t));
- return i;
- } //end if
- } //end for
- return 0;
-} //end of the function BotAllocWeaponState
-//========================================================================
-//
-// Parameter: -
-// Returns: -
-// Changes Globals: -
-//========================================================================
void BotFreeWeaponState(int handle)
{
- if (handle <= 0 || handle > MAX_CLIENTS)
- {
- botimport.Print(PRT_FATAL, "weapon state handle %d out of range\n", handle);
- return;
- } //end if
- if (!botweaponstates[handle])
- {
- botimport.Print(PRT_FATAL, "invalid weapon state %d\n", handle);
- return;
- } //end if
BotFreeWeaponWeights(handle);
- FreeMemory(botweaponstates[handle]);
- botweaponstates[handle] = NULL;
} //end of the function BotFreeWeaponState
//===========================================================================
//
@@ -499,13 +425,9 @@ void BotFreeWeaponState(int handle)
//===========================================================================
int BotSetupWeaponAI(void)
{
- char *file;
-
- file = LibVarString("weaponconfig", "weapons.c");
- weaponconfig = LoadWeaponConfig(file);
- if (!weaponconfig)
+ if (!LoadWeaponConfig("weapons.c"))
{
- botimport.Print(PRT_FATAL, "couldn't load the weapon config\n");
+ BotAI_Print(PRT_FATAL, "couldn't load the weapon config\n");
return BLERR_CANNOTLOADWEAPONCONFIG;
} //end if
@@ -523,17 +445,6 @@ int BotSetupWeaponAI(void)
//===========================================================================
void BotShutdownWeaponAI(void)
{
- int i;
-
- if (weaponconfig) FreeMemory(weaponconfig);
- weaponconfig = NULL;
-
- for (i = 1; i <= MAX_CLIENTS; i++)
- {
- if (botweaponstates[i])
- {
- BotFreeWeaponState(i);
- } //end if
- } //end for
+ weaponconfig.valid = qfalse;
} //end of the function BotShutdownWeaponAI
diff --git a/code/botlib/be_ai_weap.h b/code/game/ai_weap.h
similarity index 81%
rename from code/botlib/be_ai_weap.h
rename to code/game/ai_weap.h
index a5d29bc99..03db62ed3 100644
--- a/code/botlib/be_ai_weap.h
+++ b/code/game/ai_weap.h
@@ -94,6 +94,23 @@ typedef struct weaponinfo_s
projectileinfo_t proj; //pointer to the used projectile
} weaponinfo_t;
+//weapon configuration: set of weapons with projectiles
+typedef struct weaponconfig_s
+{
+ qboolean valid;
+ int numweapons;
+ int numprojectiles;
+ projectileinfo_t projectileinfo[MAX_WEAPONS];
+ weaponinfo_t weaponinfo[MAX_WEAPONS];
+} weaponconfig_t;
+
+//the bot weapon state
+typedef struct bot_weaponstate_s
+{
+ struct weightconfig_s *weaponweightconfig; //weapon weight configuration
+ int weaponweightindex[MAX_WEAPONS]; //weapon weight index
+} bot_weaponstate_t;
+
//setup the weapon AI
int BotSetupWeaponAI(void);
//shut down the weapon AI
@@ -104,9 +121,15 @@ int BotChooseBestFightWeapon(int weaponstate, int *inventory);
void BotGetWeaponInfo(int weaponstate, int weapon, weaponinfo_t *weaponinfo);
//loads the weapon weights
int BotLoadWeaponWeights(int weaponstate, char *filename);
-//returns a handle to a newly allocated weapon state
-int BotAllocWeaponState(void);
-//frees the weapon state
-void BotFreeWeaponState(int weaponstate);
-//resets the whole weapon state
+//
void BotResetWeaponState(int weaponstate);
+//
+void BotFreeWeaponState(int weaponstate);
+
+#define trap_BotAllocWeaponState(clientNum) (clientNum+1)
+#define trap_BotFreeWeaponState BotFreeWeaponState
+#define trap_BotResetWeaponState(weap) {}// nothing
+#define trap_BotChooseBestFightWeapon BotChooseBestFightWeapon
+#define trap_BotGetWeaponInfo BotGetWeaponInfo
+#define trap_BotLoadWeaponWeights BotLoadWeaponWeights
+
diff --git a/code/botlib/be_ai_weight.c b/code/game/ai_weight.c
similarity index 81%
rename from code/botlib/be_ai_weight.c
rename to code/game/ai_weight.c
index 4572d9899..260ffbd5b 100644
--- a/code/botlib/be_ai_weight.c
+++ b/code/game/ai_weight.c
@@ -37,26 +37,38 @@ Suite 120, Rockville, Maryland 20850 USA.
*
*****************************************************************************/
-#include "../qcommon/q_shared.h"
-#include "l_memory.h"
-#include "l_log.h"
-#include "l_utils.h"
-#include "l_script.h"
-#include "l_precomp.h"
-#include "l_struct.h"
-#include "l_libvar.h"
-#include "aasfile.h"
-#include "botlib.h"
-#include "be_aas.h"
-#include "be_aas_funcs.h"
-#include "be_interface.h"
-#include "be_ai_weight.h"
+#include "g_local.h"
+#include "../botlib/botlib.h"
+#include "../botlib/be_aas.h"
+#include "../botlib/be_ai_char.h"
+#include "../botlib/be_ai_chat.h"
+#include "../botlib/be_ai_gen.h"
+//
+#include "ai_ea.h"
+#include "ai_goal.h"
+#include "ai_move.h"
+#include "ai_weap.h"
+#include "ai_weight.h"
+//
+#include "ai_main.h"
+#include "ai_dmq3.h"
+#include "ai_chat.h"
+#include "ai_cmd.h"
+#include "ai_vcmd.h"
+#include "ai_dmnet.h"
+#include "ai_team.h"
+//
+#include "chars.h" //characteristics
+#include "inv.h" //indexes into the inventory
+#include "syn.h" //synonyms
+#include "match.h" //string matching types and vars
+
#define MAX_INVENTORYVALUE 999999
#define EVALUATERECURSIVELY
#define MAX_WEIGHT_FILES 128
-weightconfig_t *weightFileList[MAX_WEIGHT_FILES];
+weightconfig_t weightFileList[MAX_WEIGHT_FILES];
//===========================================================================
//
@@ -64,25 +76,25 @@ weightconfig_t *weightFileList[MAX_WEIGHT_FILES];
// Returns: -
// Changes Globals: -
//===========================================================================
-int ReadValue(source_t *source, float *value)
+int ReadValue(int source, float *value)
{
- token_t token;
+ pc_token_t token;
if (!PC_ExpectAnyToken(source, &token)) return qfalse;
if (!strcmp(token.string, "-"))
{
- SourceWarning(source, "negative value set to zero");
+ PC_SourceWarning(source, "negative value set to zero");
if(!PC_ExpectAnyToken(source, &token))
{
- SourceError(source, "Missing return value");
+ PC_SourceError(source, "Missing return value");
return qfalse;
}
}
if (token.type != TT_NUMBER)
{
- SourceError(source, "invalid return value %s", token.string);
+ PC_SourceError(source, "invalid return value %s", token.string);
return qfalse;
}
@@ -95,7 +107,7 @@ int ReadValue(source_t *source, float *value)
// Returns: -
// Changes Globals: -
//===========================================================================
-int ReadFuzzyWeight(source_t *source, fuzzyseperator_t *fs)
+int ReadFuzzyWeight(int source, fuzzyseperator_t *fs)
{
if (PC_CheckTokenString(source, "balance"))
{
@@ -126,10 +138,12 @@ int ReadFuzzyWeight(source_t *source, fuzzyseperator_t *fs)
//===========================================================================
void FreeFuzzySeperators_r(fuzzyseperator_t *fs)
{
+#if 0 // game currently can't free memory
if (!fs) return;
if (fs->child) FreeFuzzySeperators_r(fs->child);
if (fs->next) FreeFuzzySeperators_r(fs->next);
FreeMemory(fs);
+#endif
} //end of the function FreeFuzzySeperators
//===========================================================================
//
@@ -144,9 +158,9 @@ void FreeWeightConfig2(weightconfig_t *config)
for (i = 0; i < config->numweights; i++)
{
FreeFuzzySeperators_r(config->weights[i].firstseperator);
- if (config->weights[i].name) FreeMemory(config->weights[i].name);
} //end for
- FreeMemory(config);
+ // ZTM: NOTE: weightconfig_t usually static now, and game can't free it anyway.
+ //FreeMemory(config);
} //end of the function FreeWeightConfig2
//===========================================================================
//
@@ -156,7 +170,7 @@ void FreeWeightConfig2(weightconfig_t *config)
//===========================================================================
void FreeWeightConfig(weightconfig_t *config)
{
- if (!LibVarGetValue("bot_reloadcharacters")) return;
+ if (!BotLibVarGetValue("bot_reloadcharacters")) return;
FreeWeightConfig2(config);
} //end of the function FreeWeightConfig
//===========================================================================
@@ -165,10 +179,32 @@ void FreeWeightConfig(weightconfig_t *config)
// Returns: -
// Changes Globals: -
//===========================================================================
-fuzzyseperator_t *ReadFuzzySeperators_r(source_t *source)
+void ErrorWeightConfig(weightconfig_t *config)
+{
+ // game can't free all the fuzzy separates, so error instead
+ Com_Error(ERR_DROP, "Failed loading weight file %s", config->filename );
+} //end of the function ErrorWeightConfig
+//===========================================================================
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+void ErrorFuzzySeperators_r(fuzzyseperator_t *fs)
+{
+ // game can't free all the fuzzy separates, so error instead
+ Com_Error(ERR_DROP, "Failed loading weight file" );
+} //end of the function ErrorFuzzySeperators_r
+//===========================================================================
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+fuzzyseperator_t *ReadFuzzySeperators_r(int source)
{
int newindent, index, def, founddefault;
- token_t token;
+ pc_token_t token;
fuzzyseperator_t *fs, *lastfs, *firstfs;
founddefault = qfalse;
@@ -185,7 +221,7 @@ fuzzyseperator_t *ReadFuzzySeperators_r(source_t *source)
def = !strcmp(token.string, "default");
if (def || !strcmp(token.string, "case"))
{
- fs = (fuzzyseperator_t *) GetClearedMemory(sizeof(fuzzyseperator_t));
+ fs = (fuzzyseperator_t *) G_Alloc(sizeof(fuzzyseperator_t));
fs->index = index;
if (lastfs) lastfs->next = fs;
else firstfs = fs;
@@ -194,8 +230,8 @@ fuzzyseperator_t *ReadFuzzySeperators_r(source_t *source)
{
if (founddefault)
{
- SourceError(source, "switch already has a default");
- FreeFuzzySeperators_r(firstfs);
+ PC_SourceError(source, "switch already has a default");
+ ErrorFuzzySeperators_r(firstfs);
return NULL;
} //end if
fs->value = MAX_INVENTORYVALUE;
@@ -205,14 +241,14 @@ fuzzyseperator_t *ReadFuzzySeperators_r(source_t *source)
{
if (!PC_ExpectTokenType(source, TT_NUMBER, TT_INTEGER, &token))
{
- FreeFuzzySeperators_r(firstfs);
+ ErrorFuzzySeperators_r(firstfs);
return NULL;
} //end if
fs->value = token.intvalue;
} //end else
if (!PC_ExpectTokenString(source, ":") || !PC_ExpectAnyToken(source, &token))
{
- FreeFuzzySeperators_r(firstfs);
+ ErrorFuzzySeperators_r(firstfs);
return NULL;
} //end if
newindent = qfalse;
@@ -221,7 +257,7 @@ fuzzyseperator_t *ReadFuzzySeperators_r(source_t *source)
newindent = qtrue;
if (!PC_ExpectAnyToken(source, &token))
{
- FreeFuzzySeperators_r(firstfs);
+ ErrorFuzzySeperators_r(firstfs);
return NULL;
} //end if
} //end if
@@ -229,7 +265,7 @@ fuzzyseperator_t *ReadFuzzySeperators_r(source_t *source)
{
if (!ReadFuzzyWeight(source, fs))
{
- FreeFuzzySeperators_r(firstfs);
+ ErrorFuzzySeperators_r(firstfs);
return NULL;
} //end if
} //end if
@@ -238,41 +274,41 @@ fuzzyseperator_t *ReadFuzzySeperators_r(source_t *source)
fs->child = ReadFuzzySeperators_r(source);
if (!fs->child)
{
- FreeFuzzySeperators_r(firstfs);
+ ErrorFuzzySeperators_r(firstfs);
return NULL;
} //end if
} //end else if
else
{
- SourceError(source, "invalid name %s", token.string);
+ PC_SourceError(source, "invalid name %s", token.string);
return NULL;
} //end else
if (newindent)
{
if (!PC_ExpectTokenString(source, "}"))
{
- FreeFuzzySeperators_r(firstfs);
+ ErrorFuzzySeperators_r(firstfs);
return NULL;
} //end if
} //end if
} //end if
else
{
- FreeFuzzySeperators_r(firstfs);
- SourceError(source, "invalid name %s", token.string);
+ ErrorFuzzySeperators_r(firstfs);
+ PC_SourceError(source, "invalid name %s", token.string);
return NULL;
} //end else
if (!PC_ExpectAnyToken(source, &token))
{
- FreeFuzzySeperators_r(firstfs);
+ ErrorFuzzySeperators_r(firstfs);
return NULL;
} //end if
} while(strcmp(token.string, "}"));
//
if (!founddefault)
{
- SourceWarning(source, "switch without default");
- fs = (fuzzyseperator_t *) GetClearedMemory(sizeof(fuzzyseperator_t));
+ PC_SourceWarning(source, "switch without default");
+ fs = (fuzzyseperator_t *) G_Alloc(sizeof(fuzzyseperator_t));
fs->index = index;
fs->value = MAX_INVENTORYVALUE;
fs->weight = 0;
@@ -293,8 +329,8 @@ fuzzyseperator_t *ReadFuzzySeperators_r(source_t *source)
weightconfig_t *ReadWeightConfig(char *filename)
{
int newindent, avail = 0, n;
- token_t token;
- source_t *source;
+ pc_token_t token;
+ int source;
fuzzyseperator_t *fs;
weightconfig_t *config = NULL;
#ifdef DEBUG
@@ -303,13 +339,13 @@ weightconfig_t *ReadWeightConfig(char *filename)
starttime = Sys_MilliSeconds();
#endif //DEBUG
- if (!LibVarGetValue("bot_reloadcharacters"))
+ if (!BotLibVarGetValue("bot_reloadcharacters"))
{
avail = -1;
for( n = 0; n < MAX_WEIGHT_FILES; n++ )
{
- config = weightFileList[n];
- if( !config )
+ config = &weightFileList[n];
+ if( !config->valid )
{
if( avail == -1 )
{
@@ -319,52 +355,58 @@ weightconfig_t *ReadWeightConfig(char *filename)
} //end if
if( strcmp( filename, config->filename ) == 0 )
{
- //botimport.Print( PRT_MESSAGE, "retained %s\n", filename );
+ //BotAI_Print( PRT_MESSAGE, "retained %s\n", filename );
return config;
} //end if
} //end for
if( avail == -1 )
{
- botimport.Print( PRT_ERROR, "weightFileList was full trying to load %s\n", filename );
+ BotAI_Print( PRT_ERROR, "weightFileList was full trying to load %s\n", filename );
return NULL;
} //end if
} //end if
- PC_SetBaseFolder(BOTFILESBASEFOLDER);
- source = LoadSourceFile(filename);
+ source = trap_PC_LoadSource(filename, BOTFILESBASEFOLDER);
if (!source)
{
- botimport.Print(PRT_ERROR, "counldn't load %s\n", filename);
+ BotAI_Print(PRT_ERROR, "counldn't load %s\n", filename);
return NULL;
} //end if
//
- config = (weightconfig_t *) GetClearedMemory(sizeof(weightconfig_t));
+ if (!BotLibVarGetValue("bot_reloadcharacters"))
+ {
+ config = &weightFileList[avail];
+ }
+ else
+ {
+ config = (weightconfig_t *) G_Alloc(sizeof(weightconfig_t));
+ }
+ //
+ config->valid = qfalse;
config->numweights = 0;
Q_strncpyz( config->filename, filename, sizeof(config->filename) );
//parse the item config file
- while(PC_ReadToken(source, &token))
+ while(trap_PC_ReadToken(source, &token))
{
if (!strcmp(token.string, "weight"))
{
if (config->numweights >= MAX_WEIGHTS)
{
- SourceWarning(source, "too many fuzzy weights");
+ PC_SourceWarning(source, "too many fuzzy weights");
break;
} //end if
if (!PC_ExpectTokenType(source, TT_STRING, 0, &token))
{
- FreeWeightConfig(config);
- FreeSource(source);
+ ErrorWeightConfig(config);
+ trap_PC_FreeSource(source);
return NULL;
} //end if
- StripDoubleQuotes(token.string);
- config->weights[config->numweights].name = (char *) GetClearedMemory(strlen(token.string) + 1);
- strcpy(config->weights[config->numweights].name, token.string);
+ Q_strncpyz(config->weights[config->numweights].name, token.string, sizeof (config->weights[config->numweights].name));
if (!PC_ExpectAnyToken(source, &token))
{
- FreeWeightConfig(config);
- FreeSource(source);
+ ErrorWeightConfig(config);
+ trap_PC_FreeSource(source);
return NULL;
} //end if
newindent = qfalse;
@@ -373,8 +415,8 @@ weightconfig_t *ReadWeightConfig(char *filename)
newindent = qtrue;
if (!PC_ExpectAnyToken(source, &token))
{
- FreeWeightConfig(config);
- FreeSource(source);
+ ErrorWeightConfig(config);
+ trap_PC_FreeSource(source);
return NULL;
} //end if
} //end if
@@ -383,41 +425,44 @@ weightconfig_t *ReadWeightConfig(char *filename)
fs = ReadFuzzySeperators_r(source);
if (!fs)
{
- FreeWeightConfig(config);
- FreeSource(source);
+ ErrorWeightConfig(config);
+ trap_PC_FreeSource(source);
return NULL;
} //end if
config->weights[config->numweights].firstseperator = fs;
} //end if
else if (!strcmp(token.string, "return"))
{
- fs = (fuzzyseperator_t *) GetClearedMemory(sizeof(fuzzyseperator_t));
- fs->index = 0;
- fs->value = MAX_INVENTORYVALUE;
- fs->next = NULL;
- fs->child = NULL;
- if (!ReadFuzzyWeight(source, fs))
+ fuzzyseperator_t fuzzy;
+
+ Com_Memset(&fuzzy, 0, sizeof (fuzzyseperator_t));
+ fuzzy.index = 0;
+ fuzzy.value = MAX_INVENTORYVALUE;
+ fuzzy.next = NULL;
+ fuzzy.child = NULL;
+ if (!ReadFuzzyWeight(source, &fuzzy))
{
- FreeMemory(fs);
- FreeWeightConfig(config);
- FreeSource(source);
+ ErrorWeightConfig(config);
+ trap_PC_FreeSource(source);
return NULL;
} //end if
+ fs = (fuzzyseperator_t *) G_Alloc(sizeof(fuzzyseperator_t));
+ Com_Memcpy(fs, &fuzzy, sizeof (fuzzyseperator_t));
config->weights[config->numweights].firstseperator = fs;
} //end else if
else
{
- SourceError(source, "invalid name %s", token.string);
- FreeWeightConfig(config);
- FreeSource(source);
+ PC_SourceError(source, "invalid name %s", token.string);
+ ErrorWeightConfig(config);
+ trap_PC_FreeSource(source);
return NULL;
} //end else
if (newindent)
{
if (!PC_ExpectTokenString(source, "}"))
{
- FreeWeightConfig(config);
- FreeSource(source);
+ ErrorWeightConfig(config);
+ trap_PC_FreeSource(source);
return NULL;
} //end if
} //end if
@@ -425,24 +470,21 @@ weightconfig_t *ReadWeightConfig(char *filename)
} //end if
else
{
- SourceError(source, "invalid name %s", token.string);
- FreeWeightConfig(config);
- FreeSource(source);
+ PC_SourceError(source, "invalid name %s", token.string);
+ ErrorWeightConfig(config);
+ trap_PC_FreeSource(source);
return NULL;
} //end else
} //end while
//free the source at the end of a pass
- FreeSource(source);
+ trap_PC_FreeSource(source);
//if the file was located in a pak file
- botimport.Print(PRT_DEVELOPER, "loaded %s\n", filename);
+ BotAI_Print(PRT_DEVELOPER, "loaded %s\n", filename);
#ifdef DEBUG
- botimport.Print(PRT_DEVELOPER, "weights loaded in %d msec\n", Sys_MilliSeconds() - starttime);
+ BotAI_Print(PRT_DEVELOPER, "weights loaded in %d msec\n", Sys_MilliSeconds() - starttime);
#endif //DEBUG
//
- if (!LibVarGetValue("bot_reloadcharacters"))
- {
- weightFileList[avail] = config;
- } //end if
+ config->valid = qtrue;
//
return config;
} //end of the function ReadWeightConfig
@@ -565,7 +607,7 @@ qboolean WriteWeightConfig(char *filename, weightconfig_t *config)
// Returns: -
// Changes Globals: -
//===========================================================================
-int FindFuzzyWeight(weightconfig_t *wc, char *name)
+int FindFuzzyWeight(weightconfig_t *wc, const char *name)
{
int i;
@@ -850,7 +892,7 @@ int InterbreedFuzzySeperator_r(fuzzyseperator_t *fs1, fuzzyseperator_t *fs2,
{
if (!fs2->child || !fsout->child)
{
- botimport.Print(PRT_ERROR, "cannot interbreed weight configs, unequal child\n");
+ BotAI_Print(PRT_ERROR, "cannot interbreed weight configs, unequal child\n");
return qfalse;
} //end if
if (!InterbreedFuzzySeperator_r(fs2->child, fs2->child, fsout->child))
@@ -862,7 +904,7 @@ int InterbreedFuzzySeperator_r(fuzzyseperator_t *fs1, fuzzyseperator_t *fs2,
{
if (fs2->type != WT_BALANCE || fsout->type != WT_BALANCE)
{
- botimport.Print(PRT_ERROR, "cannot interbreed weight configs, unequal balance\n");
+ BotAI_Print(PRT_ERROR, "cannot interbreed weight configs, unequal balance\n");
return qfalse;
} //end if
fsout->weight = (fs1->weight + fs2->weight) / 2;
@@ -873,7 +915,7 @@ int InterbreedFuzzySeperator_r(fuzzyseperator_t *fs1, fuzzyseperator_t *fs2,
{
if (!fs2->next || !fsout->next)
{
- botimport.Print(PRT_ERROR, "cannot interbreed weight configs, unequal next\n");
+ BotAI_Print(PRT_ERROR, "cannot interbreed weight configs, unequal next\n");
return qfalse;
} //end if
if (!InterbreedFuzzySeperator_r(fs1->next, fs2->next, fsout->next))
@@ -898,7 +940,7 @@ void InterbreedWeightConfigs(weightconfig_t *config1, weightconfig_t *config2,
if (config1->numweights != config2->numweights ||
config1->numweights != configout->numweights)
{
- botimport.Print(PRT_ERROR, "cannot interbreed weight configs, unequal numweights\n");
+ BotAI_Print(PRT_ERROR, "cannot interbreed weight configs, unequal numweights\n");
return;
} //end if
for (i = 0; i < config1->numweights; i++)
@@ -920,10 +962,9 @@ void BotShutdownWeights(void)
for( i = 0; i < MAX_WEIGHT_FILES; i++ )
{
- if (weightFileList[i])
+ if (weightFileList[i].valid)
{
- FreeWeightConfig2(weightFileList[i]);
- weightFileList[i] = NULL;
+ FreeWeightConfig2(&weightFileList[i]);
} //end if
} //end for
} //end of the function BotShutdownWeights
diff --git a/code/botlib/be_ai_weight.h b/code/game/ai_weight.h
similarity index 97%
rename from code/botlib/be_ai_weight.h
rename to code/game/ai_weight.h
index f68a3c497..12636674e 100644
--- a/code/botlib/be_ai_weight.h
+++ b/code/game/ai_weight.h
@@ -56,13 +56,14 @@ typedef struct fuzzyseperator_s
//fuzzy weight
typedef struct weight_s
{
- char *name;
+ char name[128];
struct fuzzyseperator_s *firstseperator;
} weight_t;
//weight configuration
typedef struct weightconfig_s
{
+ qboolean valid;
int numweights;
weight_t weights[MAX_WEIGHTS];
char filename[MAX_QPATH];
@@ -75,7 +76,7 @@ void FreeWeightConfig(weightconfig_t *config);
//writes a weight configuration, returns true if successfull
qboolean WriteWeightConfig(char *filename, weightconfig_t *config);
//find the fuzzy weight with the given name
-int FindFuzzyWeight(weightconfig_t *wc, char *name);
+int FindFuzzyWeight(weightconfig_t *wc, const char *name);
//returns the fuzzy weight for the given inventory and weight
float FuzzyWeight(int *inventory, weightconfig_t *wc, int weightnum);
float FuzzyWeightUndecided(int *inventory, weightconfig_t *wc, int weightnum);
diff --git a/code/game/bg_local.h b/code/game/bg_local.h
index 785c50f6f..dc1578937 100644
--- a/code/game/bg_local.h
+++ b/code/game/bg_local.h
@@ -32,8 +32,6 @@ Suite 120, Rockville, Maryland 20850 USA.
#define MIN_WALK_NORMAL 0.7f // can't walk on very steep slopes
-#define STEPSIZE 18
-
#define JUMP_VELOCITY 270
#define TIMER_LAND 130
diff --git a/code/game/bg_misc.c b/code/game/bg_misc.c
index 21e068f9c..acee83458 100644
--- a/code/game/bg_misc.c
+++ b/code/game/bg_misc.c
@@ -1967,3 +1967,419 @@ void BG_RegisterClientCvars(int maxSplitview) {
trap_Cvar_CheckRange("cg_viewsize", 30, 100, qtrue );
}
#endif
+
+/*
+=================
+PC_SourceWarning
+=================
+*/
+void PC_SourceWarning(int handle, char *format, ...) {
+ int line;
+ char filename[128];
+ va_list argptr;
+ static char string[4096];
+
+ va_start (argptr, format);
+ Q_vsnprintf (string, sizeof(string), format, argptr);
+ va_end (argptr);
+
+ filename[0] = '\0';
+ line = 0;
+ trap_PC_SourceFileAndLine(handle, filename, &line);
+
+ Com_Printf(S_COLOR_YELLOW "WARNING: %s, line %d: %s\n", filename, line, string);
+}
+
+/*
+=================
+PC_SourceError
+=================
+*/
+void PC_SourceError(int handle, char *format, ...) {
+ int line;
+ char filename[128];
+ va_list argptr;
+ static char string[4096];
+
+ va_start (argptr, format);
+ Q_vsnprintf (string, sizeof(string), format, argptr);
+ va_end (argptr);
+
+ filename[0] = '\0';
+ line = 0;
+ trap_PC_SourceFileAndLine(handle, filename, &line);
+
+ Com_Printf(S_COLOR_RED "ERROR: %s, line %d: %s\n", filename, line, string);
+}
+
+/*
+=================
+PC_CheckTokenString
+=================
+*/
+int PC_CheckTokenString(int handle, char *string) {
+ pc_token_t tok;
+
+ if (!trap_PC_ReadToken(handle, &tok)) return qfalse;
+ //if the token is available
+ if (!strcmp(tok.string, string)) return qtrue;
+ //
+ trap_PC_UnreadToken(handle);
+ return qfalse;
+}
+
+/*
+=================
+PC_ExpectTokenString
+=================
+*/
+int PC_ExpectTokenString(int handle, char *string) {
+ pc_token_t token;
+
+ if (!trap_PC_ReadToken(handle, &token))
+ {
+ PC_SourceError(handle, "couldn't find expected %s", string);
+ return qfalse;
+ } //end if
+
+ if (strcmp(token.string, string))
+ {
+ PC_SourceError(handle, "expected %s, found %s", string, token.string);
+ return qfalse;
+ } //end if
+ return qtrue;
+}
+
+/*
+=================
+PC_ExpectTokenType
+=================
+*/
+int PC_ExpectTokenType(int handle, int type, int subtype, pc_token_t *token) {
+ char str[MAX_TOKENLENGTH];
+
+ if (!trap_PC_ReadToken(handle, token))
+ {
+ PC_SourceError(handle, "couldn't read expected token");
+ return qfalse;
+ }
+
+ if (token->type != type)
+ {
+ strcpy(str, "");
+ if (type == TT_STRING) strcpy(str, "string");
+ if (type == TT_LITERAL) strcpy(str, "literal");
+ if (type == TT_NUMBER) strcpy(str, "number");
+ if (type == TT_NAME) strcpy(str, "name");
+ if (type == TT_PUNCTUATION) strcpy(str, "punctuation");
+ PC_SourceError(handle, "expected a %s, found %s", str, token->string);
+ return qfalse;
+ }
+ if (token->type == TT_NUMBER)
+ {
+ if ((token->subtype & subtype) != subtype)
+ {
+ if (subtype & TT_DECIMAL) strcpy(str, "decimal");
+ if (subtype & TT_HEX) strcpy(str, "hex");
+ if (subtype & TT_OCTAL) strcpy(str, "octal");
+ if (subtype & TT_BINARY) strcpy(str, "binary");
+ if (subtype & TT_LONG) strcat(str, " long");
+ if (subtype & TT_UNSIGNED) strcat(str, " unsigned");
+ if (subtype & TT_FLOAT) strcat(str, " float");
+ if (subtype & TT_INTEGER) strcat(str, " integer");
+ PC_SourceError(handle, "expected %s, found %s", str, token->string);
+ return qfalse;
+ }
+ }
+ else if (token->type == TT_PUNCTUATION)
+ {
+ if (token->subtype != subtype)
+ {
+ PC_SourceError(handle, "found %s", token->string);
+ return qfalse;
+ }
+ }
+ return qtrue;
+}
+
+/*
+=================
+PC_ExpectAnyToken
+=================
+*/
+int PC_ExpectAnyToken(int handle, pc_token_t *token) {
+ if (!trap_PC_ReadToken(handle, token)) {
+ PC_SourceError(handle, "couldn't read expected token");
+ return qfalse;
+ } else {
+ return qtrue;
+ }
+}
+
+//===========================================================================
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+fielddef_t *FindField(fielddef_t *defs, char *name)
+{
+ int i;
+
+ for (i = 0; defs[i].name; i++)
+ {
+ if (!strcmp(defs[i].name, name)) return &defs[i];
+ } //end for
+ return NULL;
+} //end of the function FindField
+//===========================================================================
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+qboolean ReadNumber(int source, fielddef_t *fd, void *p)
+{
+ pc_token_t token;
+ int negative = qfalse;
+ long int intval, intmin = 0, intmax = 0;
+ double floatval;
+
+ if (!PC_ExpectAnyToken(source, &token)) return 0;
+
+ //check for minus sign
+ if (token.type == TT_PUNCTUATION)
+ {
+ if (fd->type & FT_UNSIGNED)
+ {
+ PC_SourceError(source, "expected unsigned value, found %s", token.string);
+ return 0;
+ } //end if
+ //if not a minus sign
+ if (strcmp(token.string, "-"))
+ {
+ PC_SourceError(source, "unexpected punctuation %s", token.string);
+ return 0;
+ } //end if
+ negative = qtrue;
+ //read the number
+ if (!PC_ExpectAnyToken(source, &token)) return 0;
+ } //end if
+ //check if it is a number
+ if (token.type != TT_NUMBER)
+ {
+ PC_SourceError(source, "expected number, found %s", token.string);
+ return 0;
+ } //end if
+ //check for a float value
+ if (token.subtype & TT_FLOAT)
+ {
+ if ((fd->type & FT_TYPE) != FT_FLOAT)
+ {
+ PC_SourceError(source, "unexpected float");
+ return 0;
+ } //end if
+ floatval = token.floatvalue;
+ if (negative) floatval = -floatval;
+ if (fd->type & FT_BOUNDED)
+ {
+ if (floatval < fd->floatmin || floatval > fd->floatmax)
+ {
+ PC_SourceError(source, "float out of range [%f, %f]", fd->floatmin, fd->floatmax);
+ return 0;
+ } //end if
+ } //end if
+ *(float *) p = (float) floatval;
+ return 1;
+ } //end if
+ //
+ intval = token.intvalue;
+ if (negative) intval = -intval;
+ //check bounds
+ if ((fd->type & FT_TYPE) == FT_CHAR)
+ {
+ if (fd->type & FT_UNSIGNED) {intmin = 0; intmax = 255;}
+ else {intmin = -128; intmax = 127;}
+ } //end if
+ if ((fd->type & FT_TYPE) == FT_INT)
+ {
+ if (fd->type & FT_UNSIGNED) {intmin = 0; intmax = 65535;}
+ else {intmin = -32768; intmax = 32767;}
+ } //end else if
+ if ((fd->type & FT_TYPE) == FT_CHAR || (fd->type & FT_TYPE) == FT_INT)
+ {
+ if (fd->type & FT_BOUNDED)
+ {
+ intmin = MAX(intmin, fd->floatmin);
+ intmax = MIN(intmax, fd->floatmax);
+ } //end if
+ if (intval < intmin || intval > intmax)
+ {
+ PC_SourceError(source, "value %ld out of range [%ld, %ld]", intval, intmin, intmax);
+ return 0;
+ } //end if
+ } //end if
+ else if ((fd->type & FT_TYPE) == FT_FLOAT)
+ {
+ if (fd->type & FT_BOUNDED)
+ {
+ if (intval < fd->floatmin || intval > fd->floatmax)
+ {
+ PC_SourceError(source, "value %ld out of range [%f, %f]", intval, fd->floatmin, fd->floatmax);
+ return 0;
+ } //end if
+ } //end if
+ } //end else if
+ //store the value
+ if ((fd->type & FT_TYPE) == FT_CHAR)
+ {
+ if (fd->type & FT_UNSIGNED) *(unsigned char *) p = (unsigned char) intval;
+ else *(char *) p = (char) intval;
+ } //end if
+ else if ((fd->type & FT_TYPE) == FT_INT)
+ {
+ if (fd->type & FT_UNSIGNED) *(unsigned int *) p = (unsigned int) intval;
+ else *(int *) p = (int) intval;
+ } //end else
+ else if ((fd->type & FT_TYPE) == FT_FLOAT)
+ {
+ *(float *) p = (float) intval;
+ } //end else
+ return 1;
+} //end of the function ReadNumber
+//===========================================================================
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+qboolean ReadChar(int source, fielddef_t *fd, void *p)
+{
+ pc_token_t token;
+
+ if (!PC_ExpectAnyToken(source, &token)) return 0;
+
+ //take literals into account
+ if (token.type == TT_LITERAL)
+ {
+ *(char *) p = token.string[0];
+ } //end if
+ else
+ {
+ trap_PC_UnreadToken(source);
+ if (!ReadNumber(source, fd, p)) return 0;
+ } //end if
+ return 1;
+} //end of the function ReadChar
+//===========================================================================
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+int ReadString(int source, fielddef_t *fd, void *p)
+{
+ pc_token_t token;
+
+ if (!PC_ExpectTokenType(source, TT_STRING, 0, &token)) return 0;
+ //copy the string
+ strncpy((char *) p, token.string, MAX_STRINGFIELD);
+ //make sure the string is closed with a zero
+ ((char *)p)[MAX_STRINGFIELD-1] = '\0';
+ //
+ return 1;
+} //end of the function ReadString
+
+/*
+=================
+PC_ReadStructure
+=================
+*/
+qboolean PC_ReadStructure(int source, structdef_t *def, void *structure)
+{
+ pc_token_t token;
+ fielddef_t *fd;
+ void *p;
+ int num;
+
+ if (!PC_ExpectTokenString(source, "{")) return 0;
+ while(1)
+ {
+ if (!PC_ExpectAnyToken(source, &token)) return qfalse;
+ //if end of structure
+ if (!strcmp(token.string, "}")) break;
+ //find the field with the name
+ fd = FindField(def->fields, token.string);
+ if (!fd)
+ {
+ PC_SourceError(source, "unknown structure field %s", token.string);
+ return qfalse;
+ } //end if
+ if (fd->type & FT_ARRAY)
+ {
+ num = fd->maxarray;
+ if (!PC_ExpectTokenString(source, "{")) return qfalse;
+ } //end if
+ else
+ {
+ num = 1;
+ } //end else
+ p = (void *)((byte*)structure + fd->offset);
+ while (num-- > 0)
+ {
+ if (fd->type & FT_ARRAY)
+ {
+ if (PC_CheckTokenString(source, "}")) break;
+ } //end if
+ switch(fd->type & FT_TYPE)
+ {
+ case FT_CHAR:
+ {
+ if (!ReadChar(source, fd, p)) return qfalse;
+ p = (char *) p + sizeof(char);
+ break;
+ } //end case
+ case FT_INT:
+ {
+ if (!ReadNumber(source, fd, p)) return qfalse;
+ p = (char *) p + sizeof(int);
+ break;
+ } //end case
+ case FT_FLOAT:
+ {
+ if (!ReadNumber(source, fd, p)) return qfalse;
+ p = (char *) p + sizeof(float);
+ break;
+ } //end case
+ case FT_STRING:
+ {
+ if (!ReadString(source, fd, p)) return qfalse;
+ p = (char *) p + MAX_STRINGFIELD;
+ break;
+ } //end case
+ case FT_STRUCT:
+ {
+ if (!fd->substruct)
+ {
+ PC_SourceError(source, "BUG: no sub structure defined");
+ return qfalse;
+ } //end if
+ PC_ReadStructure(source, fd->substruct, (char *) p);
+ p = (char *) p + fd->substruct->size;
+ break;
+ } //end case
+ } //end switch
+ if (fd->type & FT_ARRAY)
+ {
+ if (!PC_ExpectAnyToken(source, &token)) return qfalse;
+ if (!strcmp(token.string, "}")) break;
+ if (strcmp(token.string, ","))
+ {
+ PC_SourceError(source, "expected a comma, found %s", token.string);
+ return qfalse;
+ } //end if
+ } //end if
+ } //end while
+ } //end while
+ return qtrue;
+} //end of the function ReadStructure
diff --git a/code/game/bg_misc.h b/code/game/bg_misc.h
index cba2f5ed1..3d80560c1 100644
--- a/code/game/bg_misc.h
+++ b/code/game/bg_misc.h
@@ -67,6 +67,8 @@ Suite 120, Rockville, Maryland 20850 USA.
#define CROUCH_VIEWHEIGHT 12
#define DEAD_VIEWHEIGHT -16
+#define STEPSIZE 18
+
//
// config strings are a general means of communicating variable length strings
// from the server to all connected clients.
@@ -1101,6 +1103,47 @@ int BG_GetTracemapGroundFloor( void );
int BG_GetTracemapGroundCeil( void );
void etpro_FinalizeTracemapClamp( int *x, int *y );
+void PC_SourceWarning(int handle, char *format, ...) __attribute__ ((format (printf, 2, 3)));
+void PC_SourceError(int handle, char *format, ...) __attribute__ ((format (printf, 2, 3)));
+int PC_CheckTokenString(int handle, char *string);
+int PC_ExpectTokenString(int handle, char *string);
+int PC_ExpectTokenType(int handle, int type, int subtype, pc_token_t *token);
+int PC_ExpectAnyToken(int handle, pc_token_t *token);
+
+#define MAX_STRINGFIELD 80
+//field types
+#define FT_CHAR 1 // char
+#define FT_INT 2 // int
+#define FT_FLOAT 3 // float
+#define FT_STRING 4 // char [MAX_STRINGFIELD]
+#define FT_STRUCT 6 // struct (sub structure)
+//type only mask
+#define FT_TYPE 0x00FF // only type, clear subtype
+//sub types
+#define FT_ARRAY 0x0100 // array of type
+#define FT_BOUNDED 0x0200 // bounded value
+#define FT_UNSIGNED 0x0400
+
+//structure field definition
+typedef struct fielddef_s
+{
+ char *name; //name of the field
+ int offset; //offset in the structure
+ int type; //type of the field
+ //type specific fields
+ int maxarray; //maximum array size
+ float floatmin, floatmax; //float min and max
+ struct structdef_s *substruct; //sub structure
+} fielddef_t;
+
+//structure definition
+typedef struct structdef_s
+{
+ int size;
+ fielddef_t *fields;
+} structdef_t;
+
+qboolean PC_ReadStructure(int source, structdef_t *def, void *structure);
//
// System calls shared by game, cgame, and ui.
@@ -1156,7 +1199,7 @@ int trap_FS_Rename( const char *from, const char *to );
int trap_PC_AddGlobalDefine( char *define );
void trap_PC_RemoveAllGlobalDefines( void );
-int trap_PC_LoadSource( const char *filename );
+int trap_PC_LoadSource( const char *filename, const char *basepath );
int trap_PC_FreeSource( int handle );
int trap_PC_ReadToken( int handle, pc_token_t *pc_token );
void trap_PC_UnreadToken( int handle );
diff --git a/code/game/g_local.h b/code/game/g_local.h
index 01ef6a08e..25da89e3f 100644
--- a/code/game/g_local.h
+++ b/code/game/g_local.h
@@ -183,6 +183,16 @@ struct gentity_s {
float random;
gitem_t *item; // for bonus items
+
+ // info for bots
+ qboolean botvalid;
+ float update_time;
+ float ltime;
+ vec3_t lastvisorigin;
+ vec3_t lastAngles;
+ vec3_t lastMins;
+ vec3_t lastMaxs;
+ int areanum;
};
@@ -801,6 +811,7 @@ int trap_BotAllocateClient( void );
void trap_BotFreeClient( int clientNum );
void trap_GetUsercmd( int clientNum, usercmd_t *cmd );
qboolean trap_GetEntityToken( char *buffer, int bufferSize );
+void trap_ClientCommand(int playerNum, const char *command);
int trap_DebugPolygonCreate(int color, int numPoints, vec3_t *points);
void trap_DebugPolygonDelete(int id);
@@ -812,8 +823,8 @@ int trap_R_LerpTag( orientation_t *tag, clipHandle_t handle, int startFrame, int
int trap_BotLibSetup( void );
int trap_BotLibShutdown( void );
-int trap_BotLibVarSet(char *var_name, char *value);
-int trap_BotLibVarGet(char *var_name, char *value, int size);
+int trap_BotLibVarSet(const char *var_name, char *value);
+int trap_BotLibVarGet(const char *var_name, char *value, int size);
int trap_BotLibStartFrame(float time);
int trap_BotLibLoadMap(const char *mapname);
int trap_BotLibUpdateEntity(int ent, void /* struct bot_updateentity_s */ *bue);
@@ -825,14 +836,15 @@ void trap_BotUserCommand(int client, usercmd_t *ucmd);
int trap_AAS_BBoxAreas(vec3_t absmins, vec3_t absmaxs, int *areas, int maxareas);
int trap_AAS_AreaInfo( int areanum, void /* struct aas_areainfo_s */ *info );
-void trap_AAS_EntityInfo(int entnum, void /* struct aas_entityinfo_s */ *info);
+int trap_AAS_Loaded(void);
int trap_AAS_Initialized(void);
void trap_AAS_PresenceTypeBoundingBox(int presencetype, vec3_t mins, vec3_t maxs);
float trap_AAS_Time(void);
int trap_AAS_PointAreaNum(vec3_t point);
int trap_AAS_PointReachabilityAreaIndex(vec3_t point);
+void trap_AAS_TraceClientBBox(void /* aas_trace_t */ *trace, vec3_t start, vec3_t end, int presencetype, int passent);
int trap_AAS_TraceAreas(vec3_t start, vec3_t end, int *areas, vec3_t *points, int maxareas);
int trap_AAS_PointContents(vec3_t point);
@@ -844,9 +856,27 @@ int trap_AAS_IntForBSPEpairKey(int ent, char *key, int *value);
int trap_AAS_AreaReachability(int areanum);
int trap_AAS_BestReachableArea(vec3_t origin, vec3_t mins, vec3_t maxs, vec3_t goalorigin);
-
-int trap_AAS_AreaTravelTimeToGoalArea(int areanum, vec3_t origin, int goalareanum, int travelflags);
+int trap_AAS_BestReachableFromJumpPadArea(vec3_t origin, vec3_t mins, vec3_t maxs);
+int trap_AAS_NextModelReachability(int num, int modelnum);
+float trap_AAS_AreaGroundFaceArea(int areanum);
+int trap_AAS_AreaCrouch(int areanum);
+int trap_AAS_AreaSwim(int areanum);
+int trap_AAS_AreaLiquid(int areanum);
+int trap_AAS_AreaLava(int areanum);
+int trap_AAS_AreaSlime(int areanum);
+int trap_AAS_AreaGrounded(int areanum);
+int trap_AAS_AreaLadder(int areanum);
+int trap_AAS_AreaJumpPad(int areanum);
+int trap_AAS_AreaDoNotEnter(int areanum);
+
+int trap_AAS_TravelFlagForType( int traveltype );
+int trap_AAS_AreaContentsTravelFlags( int areanum );
+int trap_AAS_NextAreaReachability( int areanum, int reachnum );
+int trap_AAS_ReachabilityFromNum( int num, void /*struct aas_reachability_s*/ *reach );
+int trap_AAS_RandomGoalArea( int areanum, int travelflags, int *goalareanum, vec3_t goalorigin );
int trap_AAS_EnableRoutingArea( int areanum, int enable );
+unsigned short int trap_AAS_AreaTravelTime(int areanum, vec3_t start, vec3_t end);
+int trap_AAS_AreaTravelTimeToGoalArea(int areanum, vec3_t origin, int goalareanum, int travelflags);
int trap_AAS_PredictRoute(void /*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);
@@ -854,36 +884,43 @@ int trap_AAS_PredictRoute(void /*struct aas_predictroute_s*/ *route, int areanu
int trap_AAS_AlternativeRouteGoals(vec3_t start, int startareanum, vec3_t goal, int goalareanum, int travelflags,
void /*struct aas_altroutegoal_s*/ *altroutegoals, int maxaltroutegoals,
int type);
-int trap_AAS_Swimming(vec3_t origin);
-int trap_AAS_PredictClientMovement(void /* aas_clientmove_s */ *move, int entnum, vec3_t origin, int presencetype, int onground, vec3_t velocity, vec3_t cmdmove, int cmdframes, int maxframes, float frametime, int stopevent, int stopareanum, int visualize);
-void trap_EA_Say(int client, char *str);
-void trap_EA_SayTeam(int client, char *str);
-void trap_EA_Command(int client, char *command);
-
-void trap_EA_Action(int client, int action);
-void trap_EA_Gesture(int client);
-void trap_EA_Talk(int client);
-void trap_EA_Attack(int client);
-void trap_EA_Use(int client);
-void trap_EA_Respawn(int client);
-void trap_EA_Crouch(int client);
-void trap_EA_MoveUp(int client);
-void trap_EA_MoveDown(int client);
-void trap_EA_MoveForward(int client);
-void trap_EA_MoveBack(int client);
-void trap_EA_MoveLeft(int client);
-void trap_EA_MoveRight(int client);
-void trap_EA_SelectWeapon(int client, int weapon);
-void trap_EA_Jump(int client);
-void trap_EA_DelayedJump(int client);
-void trap_EA_Move(int client, vec3_t dir, float speed);
-void trap_EA_View(int client, vec3_t viewangles);
-
-void trap_EA_EndRegular(int client, float thinktime);
-void trap_EA_GetInput(int client, float thinktime, void /* struct bot_input_s */ *input);
-void trap_EA_ResetInput(int client);
+int trap_AAS_PredictClientMovement(void /* aas_clientmove_s */ *move, int entnum, vec3_t origin, int presencetype, int onground, vec3_t velocity, vec3_t cmdmove, int cmdframes, int maxframes, float frametime, int stopevent, int stopareanum, int visualize);
+int trap_AAS_OnGround(vec3_t origin, int presencetype, int passent);
+int trap_AAS_Swimming(vec3_t origin);
+void trap_AAS_JumpReachRunStart(void /* struct aas_reachability_s */ *reach, vec3_t runstart);
+int trap_AAS_AgainstLadder(vec3_t origin);
+int trap_AAS_HorizontalVelocityForJump(float zvel, vec3_t start, vec3_t end, float *velocity);
+int trap_AAS_DropToFloor(vec3_t origin, vec3_t mins, vec3_t maxs);
+
+#include "ai_ea.h"
+#define trap_EA_Say EA_Say
+#define trap_EA_SayTeam EA_SayTeam
+#define trap_EA_Command EA_Command
+
+#define trap_EA_Action EA_Action
+#define trap_EA_Gesture EA_Gesture
+#define trap_EA_Talk EA_Talk
+#define trap_EA_Attack EA_Attack
+#define trap_EA_Use EA_Use
+#define trap_EA_Respawn EA_Respawn
+#define trap_EA_Crouch EA_Crouch
+#define trap_EA_MoveUp EA_MoveUp
+#define trap_EA_MoveDown EA_MoveDown
+#define trap_EA_MoveForward EA_MoveForward
+#define trap_EA_MoveBack EA_MoveBack
+#define trap_EA_MoveLeft EA_MoveLeft
+#define trap_EA_MoveRight EA_MoveRight
+#define trap_EA_SelectWeapon EA_SelectWeapon
+#define trap_EA_Jump EA_Jump
+#define trap_EA_DelayedJump EA_DelayedJump
+#define trap_EA_Move EA_Move
+#define trap_EA_View EA_View
+
+#define trap_EA_EndRegular EA_EndRegular
+#define trap_EA_GetInput EA_GetInput
+#define trap_EA_ResetInput EA_ResetInput
int trap_BotLoadCharacter(char *charfile, float skill);
@@ -914,54 +951,5 @@ void trap_BotReplaceSynonyms(char *string, unsigned long int context);
int trap_BotLoadChatFile(int chatstate, char *chatfile, char *chatname);
void trap_BotSetChatGender(int chatstate, int gender);
void trap_BotSetChatName(int chatstate, char *name, int client);
-void trap_BotResetGoalState(int goalstate);
-void trap_BotRemoveFromAvoidGoals(int goalstate, int number);
-void trap_BotResetAvoidGoals(int goalstate);
-void trap_BotPushGoal(int goalstate, void /* struct bot_goal_s */ *goal);
-void trap_BotPopGoal(int goalstate);
-void trap_BotEmptyGoalStack(int goalstate);
-void trap_BotDumpAvoidGoals(int goalstate);
-void trap_BotDumpGoalStack(int goalstate);
-void trap_BotGoalName(int number, char *name, int size);
-int trap_BotGetTopGoal(int goalstate, void /* struct bot_goal_s */ *goal);
-int trap_BotGetSecondGoal(int goalstate, void /* struct bot_goal_s */ *goal);
-int trap_BotChooseLTGItem(int goalstate, vec3_t origin, int *inventory, int travelflags);
-int trap_BotChooseNBGItem(int goalstate, vec3_t origin, int *inventory, int travelflags, void /* struct bot_goal_s */ *ltg, float maxtime);
-int trap_BotTouchingGoal(vec3_t origin, void /* struct bot_goal_s */ *goal);
-int trap_BotItemGoalInVisButNotVisible(int viewer, vec3_t eye, vec3_t viewangles, void /* struct bot_goal_s */ *goal);
-int trap_BotGetNextCampSpotGoal(int num, void /* struct bot_goal_s */ *goal);
-int trap_BotGetMapLocationGoal(char *name, void /* struct bot_goal_s */ *goal);
-int trap_BotGetLevelItemGoal(int index, char *classname, void /* struct bot_goal_s */ *goal);
-float trap_BotAvoidGoalTime(int goalstate, int number);
-void trap_BotSetAvoidGoalTime(int goalstate, int number, float avoidtime);
-void trap_BotInitLevelItems(void);
-void trap_BotUpdateEntityItems(void);
-int trap_BotLoadItemWeights(int goalstate, char *filename);
-void trap_BotFreeItemWeights(int goalstate);
-void trap_BotInterbreedGoalFuzzyLogic(int parent1, int parent2, int child);
-void trap_BotSaveGoalFuzzyLogic(int goalstate, char *filename);
-void trap_BotMutateGoalFuzzyLogic(int goalstate, float range);
-int trap_BotAllocGoalState(int state);
-void trap_BotFreeGoalState(int handle);
-
-void trap_BotResetMoveState(int movestate);
-void trap_BotMoveToGoal(void /* struct bot_moveresult_s */ *result, int movestate, void /* struct bot_goal_s */ *goal, int travelflags);
-int trap_BotMoveInDirection(int movestate, vec3_t dir, float speed, int type);
-void trap_BotResetAvoidReach(int movestate);
-void trap_BotResetLastAvoidReach(int movestate);
-int trap_BotReachabilityArea(vec3_t origin, int testground);
-int trap_BotMovementViewTarget(int movestate, void /* struct bot_goal_s */ *goal, int travelflags, float lookahead, vec3_t target);
-int trap_BotPredictVisiblePosition(vec3_t origin, int areanum, void /* struct bot_goal_s */ *goal, int travelflags, vec3_t target);
-int trap_BotAllocMoveState(void);
-void trap_BotFreeMoveState(int handle);
-void trap_BotInitMoveState(int handle, void /* struct bot_initmove_s */ *initmove);
-void trap_BotAddAvoidSpot(int movestate, vec3_t origin, float radius, int type);
-
-int trap_BotChooseBestFightWeapon(int weaponstate, int *inventory);
-void trap_BotGetWeaponInfo(int weaponstate, int weapon, void /* struct weaponinfo_s */ *weaponinfo);
-int trap_BotLoadWeaponWeights(int weaponstate, char *filename);
-int trap_BotAllocWeaponState(void);
-void trap_BotFreeWeaponState(int weaponstate);
-void trap_BotResetWeaponState(int weaponstate);
int trap_GeneticParentsAndChildSelection(int numranks, float *ranks, int *parent1, int *parent2, int *child);
diff --git a/code/game/g_mem.c b/code/game/g_mem.c
index d66f8d86a..6e057e5e3 100644
--- a/code/game/g_mem.c
+++ b/code/game/g_mem.c
@@ -36,7 +36,7 @@ Suite 120, Rockville, Maryland 20850 USA.
#include "g_local.h"
-#define POOLSIZE (256 * 1024)
+#define POOLSIZE (512 * 1024)
static char memoryPool[POOLSIZE];
static int allocPoint;
diff --git a/code/game/g_public.h b/code/game/g_public.h
index 0f99127b4..e6080484c 100644
--- a/code/game/g_public.h
+++ b/code/game/g_public.h
@@ -265,6 +265,8 @@ typedef enum {
G_R_LERPTAG, // ( orientation_t *tag, qhandle_t handle, int startFrame, int endFrame, float frac, const char *tagName );
G_R_MODELBOUNDS, // ( qhandle_t handle, vec3_t mins, vec3_t maxs );
+ G_CLIENT_COMMAND, // ( int playerNum, const char *command );
+
BOTLIB_SETUP = 200, // ( void );
BOTLIB_SHUTDOWN, // ( void );
BOTLIB_LIBVAR_SET,
@@ -278,16 +280,15 @@ typedef enum {
BOTLIB_GET_CONSOLE_MESSAGE, // ( int client, char *message, int size );
BOTLIB_USER_COMMAND, // ( int client, usercmd_t *ucmd );
- BOTLIB_AAS_ENABLE_ROUTING_AREA = 300,
- BOTLIB_AAS_BBOX_AREAS,
+ BOTLIB_AAS_BBOX_AREAS = 301,
BOTLIB_AAS_AREA_INFO,
- BOTLIB_AAS_ENTITY_INFO,
-
+ BOTLIB_AAS_LOADED,
BOTLIB_AAS_INITIALIZED,
BOTLIB_AAS_PRESENCE_TYPE_BOUNDING_BOX,
BOTLIB_AAS_TIME,
BOTLIB_AAS_POINT_AREA_NUM,
+ BOTLIB_AAS_TRACE_CLIENT_BBOX,
BOTLIB_AAS_TRACE_AREAS,
BOTLIB_AAS_POINT_CONTENTS,
@@ -297,44 +298,46 @@ typedef enum {
BOTLIB_AAS_FLOAT_FOR_BSP_EPAIR_KEY,
BOTLIB_AAS_INT_FOR_BSP_EPAIR_KEY,
- BOTLIB_AAS_AREA_REACHABILITY,
-
- BOTLIB_AAS_AREA_TRAVEL_TIME_TO_GOAL_AREA,
-
+ // aas_move
+ BOTLIB_AAS_PREDICT_CLIENT_MOVEMENT = 325,
+ BOTLIB_AAS_ON_GROUND,
BOTLIB_AAS_SWIMMING,
- BOTLIB_AAS_PREDICT_CLIENT_MOVEMENT,
+ BOTLIB_AAS_JUMP_REACH_RUN_START,
+ BOTLIB_AAS_AGAINST_LADDER,
+ BOTLIB_AAS_HORIZONTAL_VELOCITY_FOR_JUMP,
+ BOTLIB_AAS_DROP_TO_FLOOR,
+ // aas_reach
+ BOTLIB_AAS_AREA_REACHABILITY = 350,
BOTLIB_AAS_BEST_REACHABLE_AREA,
+ BOTLIB_AAS_BEST_REACHABLE_FROM_JUMP_PAD_AREA,
+ BOTLIB_AAS_NEXT_MODEL_REACHABILITY,
+ BOTLIB_AAS_AREA_GROUND_FACE_AREA,
+ BOTLIB_AAS_AREA_CROUCH,
+ BOTLIB_AAS_AREA_SWIM,
+ BOTLIB_AAS_AREA_LIQUID,
+ BOTLIB_AAS_AREA_LAVA,
+ BOTLIB_AAS_AREA_SLIME,
+ BOTLIB_AAS_AREA_GROUNDED,
+ BOTLIB_AAS_AREA_LADDER,
+ BOTLIB_AAS_AREA_JUMP_PAD,
+ BOTLIB_AAS_AREA_DO_NOT_ENTER,
+
+ // aas_route
+ BOTLIB_AAS_TRAVEL_FLAG_FOR_TYPE = 400,
+ BOTLIB_AAS_AREA_CONTENTS_TRAVEL_FLAGS,
+ BOTLIB_AAS_NEXT_AREA_REACHABILITY,
+ BOTLIB_AAS_REACHABILITY_FROM_NUM,
+ BOTLIB_AAS_RANDOM_GOAL_AREA,
+ BOTLIB_AAS_ENABLE_ROUTING_AREA,
+ BOTLIB_AAS_AREA_TRAVEL_TIME,
+ BOTLIB_AAS_AREA_TRAVEL_TIME_TO_GOAL_AREA,
+ BOTLIB_AAS_PREDICT_ROUTE,
- BOTLIB_EA_SAY = 400,
- BOTLIB_EA_SAY_TEAM,
- BOTLIB_EA_COMMAND,
-
- BOTLIB_EA_ACTION,
- BOTLIB_EA_GESTURE,
- BOTLIB_EA_TALK,
- BOTLIB_EA_ATTACK,
- BOTLIB_EA_USE,
- BOTLIB_EA_RESPAWN,
- BOTLIB_EA_CROUCH,
- BOTLIB_EA_MOVE_UP,
- BOTLIB_EA_MOVE_DOWN,
- BOTLIB_EA_MOVE_FORWARD,
- BOTLIB_EA_MOVE_BACK,
- BOTLIB_EA_MOVE_LEFT,
- BOTLIB_EA_MOVE_RIGHT,
-
- BOTLIB_EA_SELECT_WEAPON,
- BOTLIB_EA_JUMP,
- BOTLIB_EA_DELAYED_JUMP,
- BOTLIB_EA_MOVE,
- BOTLIB_EA_VIEW,
-
- BOTLIB_EA_END_REGULAR,
- BOTLIB_EA_GET_INPUT,
- BOTLIB_EA_RESET_INPUT,
-
+ // aas_altroute
+ BOTLIB_AAS_ALTERNATIVE_ROUTE_GOAL = 420,
+ // ai_char
BOTLIB_AI_LOAD_CHARACTER = 500,
BOTLIB_AI_FREE_CHARACTER,
BOTLIB_AI_CHARACTERISTIC_FLOAT,
@@ -343,6 +346,7 @@ typedef enum {
BOTLIB_AI_CHARACTERISTIC_BINTEGER,
BOTLIB_AI_CHARACTERISTIC_STRING,
+ // ai_chat
BOTLIB_AI_ALLOC_CHAT_STATE,
BOTLIB_AI_FREE_CHAT_STATE,
BOTLIB_AI_QUEUE_CONSOLE_MESSAGE,
@@ -361,63 +365,12 @@ typedef enum {
BOTLIB_AI_LOAD_CHAT_FILE,
BOTLIB_AI_SET_CHAT_GENDER,
BOTLIB_AI_SET_CHAT_NAME,
-
- BOTLIB_AI_RESET_GOAL_STATE,
- BOTLIB_AI_RESET_AVOID_GOALS,
- BOTLIB_AI_PUSH_GOAL,
- BOTLIB_AI_POP_GOAL,
- BOTLIB_AI_EMPTY_GOAL_STACK,
- BOTLIB_AI_DUMP_AVOID_GOALS,
- BOTLIB_AI_DUMP_GOAL_STACK,
- BOTLIB_AI_GOAL_NAME,
- BOTLIB_AI_GET_TOP_GOAL,
- BOTLIB_AI_GET_SECOND_GOAL,
- BOTLIB_AI_CHOOSE_LTG_ITEM,
- BOTLIB_AI_CHOOSE_NBG_ITEM,
- BOTLIB_AI_TOUCHING_GOAL,
- BOTLIB_AI_ITEM_GOAL_IN_VIS_BUT_NOT_VISIBLE,
- BOTLIB_AI_GET_LEVEL_ITEM_GOAL,
- BOTLIB_AI_AVOID_GOAL_TIME,
- BOTLIB_AI_INIT_LEVEL_ITEMS,
- BOTLIB_AI_UPDATE_ENTITY_ITEMS,
- BOTLIB_AI_LOAD_ITEM_WEIGHTS,
- BOTLIB_AI_FREE_ITEM_WEIGHTS,
- BOTLIB_AI_SAVE_GOAL_FUZZY_LOGIC,
- BOTLIB_AI_ALLOC_GOAL_STATE,
- BOTLIB_AI_FREE_GOAL_STATE,
-
- BOTLIB_AI_RESET_MOVE_STATE,
- BOTLIB_AI_MOVE_TO_GOAL,
- BOTLIB_AI_MOVE_IN_DIRECTION,
- BOTLIB_AI_RESET_AVOID_REACH,
- BOTLIB_AI_RESET_LAST_AVOID_REACH,
- BOTLIB_AI_REACHABILITY_AREA,
- BOTLIB_AI_MOVEMENT_VIEW_TARGET,
- BOTLIB_AI_ALLOC_MOVE_STATE,
- BOTLIB_AI_FREE_MOVE_STATE,
- BOTLIB_AI_INIT_MOVE_STATE,
-
- BOTLIB_AI_CHOOSE_BEST_FIGHT_WEAPON,
- BOTLIB_AI_GET_WEAPON_INFO,
- BOTLIB_AI_LOAD_WEAPON_WEIGHTS,
- BOTLIB_AI_ALLOC_WEAPON_STATE,
- BOTLIB_AI_FREE_WEAPON_STATE,
- BOTLIB_AI_RESET_WEAPON_STATE,
-
- BOTLIB_AI_GENETIC_PARENTS_AND_CHILD_SELECTION,
- BOTLIB_AI_INTERBREED_GOAL_FUZZY_LOGIC,
- BOTLIB_AI_MUTATE_GOAL_FUZZY_LOGIC,
- BOTLIB_AI_GET_NEXT_CAMP_SPOT_GOAL,
- BOTLIB_AI_GET_MAP_LOCATION_GOAL,
BOTLIB_AI_NUM_INITIAL_CHATS,
BOTLIB_AI_GET_CHAT_MESSAGE,
- BOTLIB_AI_REMOVE_FROM_AVOID_GOALS,
- BOTLIB_AI_PREDICT_VISIBLE_POSITION,
- BOTLIB_AI_SET_AVOID_GOAL_TIME,
- BOTLIB_AI_ADD_AVOID_SPOT,
- BOTLIB_AAS_ALTERNATIVE_ROUTE_GOAL,
- BOTLIB_AAS_PREDICT_ROUTE,
+ // gen
+ BOTLIB_AI_GENETIC_PARENTS_AND_CHILD_SELECTION,
+
BOTLIB_AAS_POINT_REACHABILITY_AREA_INDEX,
} gameImport_t;
diff --git a/code/game/g_syscalls.asm b/code/game/g_syscalls.asm
index f5c48a3a5..634091ffb 100644
--- a/code/game/g_syscalls.asm
+++ b/code/game/g_syscalls.asm
@@ -91,6 +91,7 @@ equ trap_SetNetFields -129
equ trap_R_RegisterModel -130
equ trap_R_LerpTag -131
equ trap_R_ModelBounds -132
+equ trap_ClientCommand -133
equ trap_BotLibSetup -201
@@ -107,65 +108,61 @@ equ trap_BotGetServerCommand -210
equ trap_BotUserCommand -211
-
-equ trap_AAS_EnableRoutingArea -301
-equ trap_AAS_BBoxAreas -302
-equ trap_AAS_AreaInfo -303
-equ trap_AAS_EntityInfo -304
-
+; there is no 301.
+equ trap_AAS_BBoxAreas -302
+equ trap_AAS_AreaInfo -303
+equ trap_AAS_Loaded -304
equ trap_AAS_Initialized -305
equ trap_AAS_PresenceTypeBoundingBox -306
equ trap_AAS_Time -307
equ trap_AAS_PointAreaNum -308
-equ trap_AAS_TraceAreas -309
-
-equ trap_AAS_PointContents -310
-equ trap_AAS_NextBSPEntity -311
-equ trap_AAS_ValueForBSPEpairKey -312
-equ trap_AAS_VectorForBSPEpairKey -313
-equ trap_AAS_FloatForBSPEpairKey -314
-equ trap_AAS_IntForBSPEpairKey -315
-
-equ trap_AAS_AreaReachability -316
-
-equ trap_AAS_AreaTravelTimeToGoalArea -317
-
-equ trap_AAS_Swimming -318
-equ trap_AAS_PredictClientMovement -319
-
-equ trap_AAS_BestReachableArea -320
-
-
-
-equ trap_EA_Say -401
-equ trap_EA_SayTeam -402
-equ trap_EA_Command -403
-
-equ trap_EA_Action -404
-equ trap_EA_Gesture -405
-equ trap_EA_Talk -406
-equ trap_EA_Attack -407
-equ trap_EA_Use -408
-equ trap_EA_Respawn -409
-equ trap_EA_Crouch -410
-equ trap_EA_MoveUp -411
-equ trap_EA_MoveDown -412
-equ trap_EA_MoveForward -413
-equ trap_EA_MoveBack -414
-equ trap_EA_MoveLeft -415
-equ trap_EA_MoveRight -416
-
-equ trap_EA_SelectWeapon -417
-equ trap_EA_Jump -418
-equ trap_EA_DelayedJump -419
-equ trap_EA_Move -420
-equ trap_EA_View -421
-
-equ trap_EA_EndRegular -422
-equ trap_EA_GetInput -423
-equ trap_EA_ResetInput -424
-
+equ trap_AAS_TraceClientBBox -309
+equ trap_AAS_TraceAreas -310
+
+equ trap_AAS_PointContents -311
+equ trap_AAS_NextBSPEntity -312
+equ trap_AAS_ValueForBSPEpairKey -313
+equ trap_AAS_VectorForBSPEpairKey -314
+equ trap_AAS_FloatForBSPEpairKey -315
+equ trap_AAS_IntForBSPEpairKey -316
+
+
+equ trap_AAS_PredictClientMovement -326
+equ trap_AAS_OnGround -327
+equ trap_AAS_Swimming -328
+equ trap_AAS_JumpReachRunStart -329
+equ trap_AAS_AgainstLadder -330
+equ trap_AAS_HorizontalVelocityForJump -331
+equ trap_AAS_DropToFloor -332
+
+equ trap_AAS_AreaReachability -351
+equ trap_AAS_BestReachableArea -352
+equ trap_AAS_BestReachableFromJumpPadArea -353
+equ trap_AAS_NextModelReachability -354
+equ trap_AAS_AreaGroundFaceArea -355
+equ trap_AAS_AreaCrouch -356
+equ trap_AAS_AreaSwim -357
+equ trap_AAS_AreaLiquid -358
+equ trap_AAS_AreaLava -359
+equ trap_AAS_AreaSlime -360
+equ trap_AAS_AreaGrounded -361
+equ trap_AAS_AreaLadder -362
+equ trap_AAS_AreaJumpPad -363
+equ trap_AAS_AreaDoNotEnter -364
+
+
+equ trap_AAS_TravelFlagForType -401
+equ trap_AAS_AreaContentsTravelFlags -402
+equ trap_AAS_NextAreaReachability -403
+equ trap_AAS_ReachabilityFromNum -404
+equ trap_AAS_RandomGoalArea -405
+equ trap_AAS_EnableRoutingArea -406
+equ trap_AAS_AreaTravelTime -407
+equ trap_AAS_AreaTravelTimeToGoalArea -409
+equ trap_AAS_PredictRoute -410
+
+equ trap_AAS_AlternativeRouteGoals -421
equ trap_BotLoadCharacter -501
@@ -176,6 +173,7 @@ equ trap_Characteristic_Integer -505
equ trap_Characteristic_BInteger -506
equ trap_Characteristic_String -507
+
equ trap_BotAllocChatState -508
equ trap_BotFreeChatState -509
equ trap_BotQueueConsoleMessage -510
@@ -194,60 +192,10 @@ equ trap_BotReplaceSynonyms -522
equ trap_BotLoadChatFile -523
equ trap_BotSetChatGender -524
equ trap_BotSetChatName -525
+equ trap_BotNumInitialChats -526
+equ trap_BotGetChatMessage -527
+
+equ trap_GeneticParentsAndChildSelection -528
-equ trap_BotResetGoalState -526
-equ trap_BotResetAvoidGoals -527
-equ trap_BotPushGoal -528
-equ trap_BotPopGoal -529
-equ trap_BotEmptyGoalStack -530
-equ trap_BotDumpAvoidGoals -531
-equ trap_BotDumpGoalStack -532
-equ trap_BotGoalName -533
-equ trap_BotGetTopGoal -534
-equ trap_BotGetSecondGoal -535
-equ trap_BotChooseLTGItem -536
-equ trap_BotChooseNBGItem -537
-equ trap_BotTouchingGoal -538
-equ trap_BotItemGoalInVisButNotVisible -539
-equ trap_BotGetLevelItemGoal -540
-equ trap_BotAvoidGoalTime -541
-equ trap_BotInitLevelItems -542
-equ trap_BotUpdateEntityItems -543
-equ trap_BotLoadItemWeights -544
-equ trap_BotFreeItemWeights -546
-equ trap_BotSaveGoalFuzzyLogic -546
-equ trap_BotAllocGoalState -547
-equ trap_BotFreeGoalState -548
-
-equ trap_BotResetMoveState -549
-equ trap_BotMoveToGoal -550
-equ trap_BotMoveInDirection -551
-equ trap_BotResetAvoidReach -552
-equ trap_BotResetLastAvoidReach -553
-equ trap_BotReachabilityArea -554
-equ trap_BotMovementViewTarget -555
-equ trap_BotAllocMoveState -556
-equ trap_BotFreeMoveState -557
-equ trap_BotInitMoveState -558
-
-equ trap_BotChooseBestFightWeapon -559
-equ trap_BotGetWeaponInfo -560
-equ trap_BotLoadWeaponWeights -561
-equ trap_BotAllocWeaponState -562
-equ trap_BotFreeWeaponState -563
-equ trap_BotResetWeaponState -564
-equ trap_GeneticParentsAndChildSelection -565
-equ trap_BotInterbreedGoalFuzzyLogic -566
-equ trap_BotMutateGoalFuzzyLogic -567
-equ trap_BotGetNextCampSpotGoal -568
-equ trap_BotGetMapLocationGoal -569
-equ trap_BotNumInitialChats -570
-equ trap_BotGetChatMessage -571
-equ trap_BotRemoveFromAvoidGoals -572
-equ trap_BotPredictVisiblePosition -573
-equ trap_BotSetAvoidGoalTime -574
-equ trap_BotAddAvoidSpot -575
-equ trap_AAS_AlternativeRouteGoals -576
-equ trap_AAS_PredictRoute -577
-equ trap_AAS_PointReachabilityAreaIndex -578
+equ trap_AAS_PointReachabilityAreaIndex -529
diff --git a/code/game/g_syscalls.c b/code/game/g_syscalls.c
index 62cd0c80f..6f01f2049 100644
--- a/code/game/g_syscalls.c
+++ b/code/game/g_syscalls.c
@@ -306,6 +306,10 @@ void trap_R_ModelBounds( clipHandle_t handle, vec3_t mins, vec3_t maxs ) {
syscall( G_R_MODELBOUNDS, handle, mins, maxs );
}
+void trap_ClientCommand(int playerNum, const char *command) {
+ syscall( G_CLIENT_COMMAND, playerNum, command );
+}
+
// BotLib traps start here
int trap_BotLibSetup( void ) {
return syscall( BOTLIB_SETUP );
@@ -315,11 +319,11 @@ int trap_BotLibShutdown( void ) {
return syscall( BOTLIB_SHUTDOWN );
}
-int trap_BotLibVarSet(char *var_name, char *value) {
+int trap_BotLibVarSet(const char *var_name, char *value) {
return syscall( BOTLIB_LIBVAR_SET, var_name, value );
}
-int trap_BotLibVarGet(char *var_name, char *value, int size) {
+int trap_BotLibVarGet(const char *var_name, char *value, int size) {
return syscall( BOTLIB_LIBVAR_GET, var_name, value, size );
}
@@ -351,8 +355,8 @@ void trap_BotUserCommand(int clientNum, usercmd_t *ucmd) {
syscall( BOTLIB_USER_COMMAND, clientNum, ucmd );
}
-void trap_AAS_EntityInfo(int entnum, void /* struct aas_entityinfo_s */ *info) {
- syscall( BOTLIB_AAS_ENTITY_INFO, entnum, info );
+int trap_AAS_Loaded(void) {
+ return syscall( BOTLIB_AAS_LOADED );
}
int trap_AAS_Initialized(void) {
@@ -377,6 +381,10 @@ int trap_AAS_PointReachabilityAreaIndex(vec3_t point) {
return syscall( BOTLIB_AAS_POINT_REACHABILITY_AREA_INDEX, point );
}
+void trap_AAS_TraceClientBBox(void /* aas_trace_t */ *trace, vec3_t start, vec3_t end, int presencetype, int passent) {
+ syscall( BOTLIB_AAS_TRACE_CLIENT_BBOX, trace, start, end, presencetype, passent );
+}
+
int trap_AAS_TraceAreas(vec3_t start, vec3_t end, int *areas, vec3_t *points, int maxareas) {
return syscall( BOTLIB_AAS_TRACE_AREAS, start, end, areas, points, maxareas );
}
@@ -413,6 +421,8 @@ int trap_AAS_IntForBSPEpairKey(int ent, char *key, int *value) {
return syscall( BOTLIB_AAS_INT_FOR_BSP_EPAIR_KEY, ent, key, value );
}
+
+
int trap_AAS_AreaReachability(int areanum) {
return syscall( BOTLIB_AAS_AREA_REACHABILITY, areanum );
}
@@ -421,129 +431,127 @@ int trap_AAS_BestReachableArea(vec3_t origin, vec3_t mins, vec3_t maxs, vec3_t g
return syscall( BOTLIB_AAS_BEST_REACHABLE_AREA, origin, mins, maxs, goalorigin );
}
-int trap_AAS_AreaTravelTimeToGoalArea(int areanum, vec3_t origin, int goalareanum, int travelflags) {
- return syscall( BOTLIB_AAS_AREA_TRAVEL_TIME_TO_GOAL_AREA, areanum, origin, goalareanum, travelflags );
+int trap_AAS_BestReachableFromJumpPadArea(vec3_t origin, vec3_t mins, vec3_t maxs) {
+ return syscall( BOTLIB_AAS_BEST_REACHABLE_FROM_JUMP_PAD_AREA, origin, mins, maxs );
}
-int trap_AAS_EnableRoutingArea( int areanum, int enable ) {
- return syscall( BOTLIB_AAS_ENABLE_ROUTING_AREA, areanum, enable );
+int trap_AAS_NextModelReachability(int num, int modelnum) {
+ return syscall( BOTLIB_AAS_NEXT_MODEL_REACHABILITY, num, modelnum );
}
-int trap_AAS_PredictRoute(void /*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) {
- return syscall( BOTLIB_AAS_PREDICT_ROUTE, route, areanum, origin, goalareanum, travelflags, maxareas, maxtime, stopevent, stopcontents, stoptfl, stopareanum );
+float trap_AAS_AreaGroundFaceArea(int areanum) {
+ return syscall( BOTLIB_AAS_AREA_GROUND_FACE_AREA, areanum );
}
-int trap_AAS_AlternativeRouteGoals(vec3_t start, int startareanum, vec3_t goal, int goalareanum, int travelflags,
- void /*struct aas_altroutegoal_s*/ *altroutegoals, int maxaltroutegoals,
- int type) {
- return syscall( BOTLIB_AAS_ALTERNATIVE_ROUTE_GOAL, start, startareanum, goal, goalareanum, travelflags, altroutegoals, maxaltroutegoals, type );
+int trap_AAS_AreaCrouch(int areanum) {
+ return syscall( BOTLIB_AAS_AREA_CROUCH, areanum );
}
-int trap_AAS_Swimming(vec3_t origin) {
- return syscall( BOTLIB_AAS_SWIMMING, origin );
+int trap_AAS_AreaSwim(int areanum) {
+ return syscall( BOTLIB_AAS_AREA_SWIM, areanum );
}
-int trap_AAS_PredictClientMovement(void /* struct aas_clientmove_s */ *move, int entnum, vec3_t origin, int presencetype, int onground, vec3_t velocity, vec3_t cmdmove, int cmdframes, int maxframes, float frametime, int stopevent, int stopareanum, int visualize) {
- return syscall( BOTLIB_AAS_PREDICT_CLIENT_MOVEMENT, move, entnum, origin, presencetype, onground, velocity, cmdmove, cmdframes, maxframes, PASSFLOAT(frametime), stopevent, stopareanum, visualize );
+int trap_AAS_AreaLiquid(int areanum) {
+ return syscall( BOTLIB_AAS_AREA_LIQUID, areanum );
}
-void trap_EA_Say(int client, char *str) {
- syscall( BOTLIB_EA_SAY, client, str );
+int trap_AAS_AreaLava(int areanum) {
+ return syscall( BOTLIB_AAS_AREA_LAVA, areanum );
}
-void trap_EA_SayTeam(int client, char *str) {
- syscall( BOTLIB_EA_SAY_TEAM, client, str );
+int trap_AAS_AreaSlime(int areanum) {
+ return syscall( BOTLIB_AAS_AREA_SLIME, areanum );
}
-void trap_EA_Command(int client, char *command) {
- syscall( BOTLIB_EA_COMMAND, client, command );
+int trap_AAS_AreaGrounded(int areanum) {
+ return syscall( BOTLIB_AAS_AREA_GROUNDED, areanum );
}
-void trap_EA_Action(int client, int action) {
- syscall( BOTLIB_EA_ACTION, client, action );
+int trap_AAS_AreaLadder(int areanum) {
+ return syscall( BOTLIB_AAS_AREA_LADDER, areanum );
}
-void trap_EA_Gesture(int client) {
- syscall( BOTLIB_EA_GESTURE, client );
+int trap_AAS_AreaJumpPad(int areanum) {
+ return syscall( BOTLIB_AAS_AREA_JUMP_PAD, areanum );
}
-void trap_EA_Talk(int client) {
- syscall( BOTLIB_EA_TALK, client );
+int trap_AAS_AreaDoNotEnter(int areanum) {
+ return syscall( BOTLIB_AAS_AREA_DO_NOT_ENTER, areanum );
}
-void trap_EA_Attack(int client) {
- syscall( BOTLIB_EA_ATTACK, client );
-}
-void trap_EA_Use(int client) {
- syscall( BOTLIB_EA_USE, client );
+int trap_AAS_TravelFlagForType( int traveltype ) {
+ return syscall( BOTLIB_AAS_TRAVEL_FLAG_FOR_TYPE, traveltype );
}
-void trap_EA_Respawn(int client) {
- syscall( BOTLIB_EA_RESPAWN, client );
+int trap_AAS_AreaContentsTravelFlags( int areanum ) {
+ return syscall( BOTLIB_AAS_AREA_CONTENTS_TRAVEL_FLAGS, areanum );
}
-void trap_EA_Crouch(int client) {
- syscall( BOTLIB_EA_CROUCH, client );
+int trap_AAS_NextAreaReachability( int areanum, int reachnum ) {
+ return syscall( BOTLIB_AAS_NEXT_AREA_REACHABILITY, areanum, reachnum );
}
-void trap_EA_MoveUp(int client) {
- syscall( BOTLIB_EA_MOVE_UP, client );
+int trap_AAS_ReachabilityFromNum( int num, void /*struct aas_reachability_s*/ *reach ) {
+ return syscall( BOTLIB_AAS_REACHABILITY_FROM_NUM, num, reach );
}
-void trap_EA_MoveDown(int client) {
- syscall( BOTLIB_EA_MOVE_DOWN, client );
+int trap_AAS_RandomGoalArea( int areanum, int travelflags, int *goalareanum, vec3_t goalorigin ) {
+ return syscall( BOTLIB_AAS_RANDOM_GOAL_AREA, areanum, travelflags, goalareanum, goalorigin );
}
-void trap_EA_MoveForward(int client) {
- syscall( BOTLIB_EA_MOVE_FORWARD, client );
+int trap_AAS_EnableRoutingArea( int areanum, int enable ) {
+ return syscall( BOTLIB_AAS_ENABLE_ROUTING_AREA, areanum, enable );
}
-void trap_EA_MoveBack(int client) {
- syscall( BOTLIB_EA_MOVE_BACK, client );
+unsigned short int trap_AAS_AreaTravelTime(int areanum, vec3_t start, vec3_t end) {
+ return syscall( BOTLIB_AAS_AREA_TRAVEL_TIME, areanum, start, end );
}
-void trap_EA_MoveLeft(int client) {
- syscall( BOTLIB_EA_MOVE_LEFT, client );
+int trap_AAS_AreaTravelTimeToGoalArea(int areanum, vec3_t origin, int goalareanum, int travelflags) {
+ return syscall( BOTLIB_AAS_AREA_TRAVEL_TIME_TO_GOAL_AREA, areanum, origin, goalareanum, travelflags );
}
-void trap_EA_MoveRight(int client) {
- syscall( BOTLIB_EA_MOVE_RIGHT, client );
+int trap_AAS_PredictRoute(void /*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) {
+ return syscall( BOTLIB_AAS_PREDICT_ROUTE, route, areanum, origin, goalareanum, travelflags, maxareas, maxtime, stopevent, stopcontents, stoptfl, stopareanum );
}
-void trap_EA_SelectWeapon(int client, int weapon) {
- syscall( BOTLIB_EA_SELECT_WEAPON, client, weapon );
+int trap_AAS_AlternativeRouteGoals(vec3_t start, int startareanum, vec3_t goal, int goalareanum, int travelflags,
+ void /*struct aas_altroutegoal_s*/ *altroutegoals, int maxaltroutegoals,
+ int type) {
+ return syscall( BOTLIB_AAS_ALTERNATIVE_ROUTE_GOAL, start, startareanum, goal, goalareanum, travelflags, altroutegoals, maxaltroutegoals, type );
}
-void trap_EA_Jump(int client) {
- syscall( BOTLIB_EA_JUMP, client );
-}
-void trap_EA_DelayedJump(int client) {
- syscall( BOTLIB_EA_DELAYED_JUMP, client );
+int trap_AAS_PredictClientMovement(void /* struct aas_clientmove_s */ *move, int entnum, vec3_t origin, int presencetype, int onground, vec3_t velocity, vec3_t cmdmove, int cmdframes, int maxframes, float frametime, int stopevent, int stopareanum, int visualize) {
+ return syscall( BOTLIB_AAS_PREDICT_CLIENT_MOVEMENT, move, entnum, origin, presencetype, onground, velocity, cmdmove, cmdframes, maxframes, PASSFLOAT(frametime), stopevent, stopareanum, visualize );
}
-void trap_EA_Move(int client, vec3_t dir, float speed) {
- syscall( BOTLIB_EA_MOVE, client, dir, PASSFLOAT(speed) );
+int trap_AAS_OnGround(vec3_t origin, int presencetype, int passent) {
+ return syscall( BOTLIB_AAS_ON_GROUND, origin, presencetype, passent );
}
-void trap_EA_View(int client, vec3_t viewangles) {
- syscall( BOTLIB_EA_VIEW, client, viewangles );
+int trap_AAS_Swimming(vec3_t origin) {
+ return syscall( BOTLIB_AAS_SWIMMING, origin );
}
-void trap_EA_EndRegular(int client, float thinktime) {
- syscall( BOTLIB_EA_END_REGULAR, client, PASSFLOAT(thinktime) );
+void trap_AAS_JumpReachRunStart(void /* struct aas_reachability_s */ *reach, vec3_t runstart) {
+ syscall( BOTLIB_AAS_JUMP_REACH_RUN_START, reach, runstart );
}
-void trap_EA_GetInput(int client, float thinktime, void /* struct bot_input_s */ *input) {
- syscall( BOTLIB_EA_GET_INPUT, client, PASSFLOAT(thinktime), input );
+int trap_AAS_AgainstLadder(vec3_t origin) {
+ return syscall( BOTLIB_AAS_AGAINST_LADDER, origin );
}
-void trap_EA_ResetInput(int client) {
- syscall( BOTLIB_EA_RESET_INPUT, client );
+int trap_AAS_HorizontalVelocityForJump(float zvel, vec3_t start, vec3_t end, float *velocity) {
+ return syscall( BOTLIB_AAS_HORIZONTAL_VELOCITY_FOR_JUMP, PASSFLOAT( zvel ), start, end, velocity );
}
+int trap_AAS_DropToFloor(vec3_t origin, vec3_t mins, vec3_t maxs) {
+ return syscall( BOTLIB_AAS_DROP_TO_FLOOR, origin, mins, maxs );
+}
+
int trap_BotLoadCharacter(char *charfile, float skill) {
return syscall( BOTLIB_AI_LOAD_CHARACTER, charfile, PASSFLOAT(skill));
@@ -657,195 +665,6 @@ void trap_BotSetChatName(int chatstate, char *name, int client) {
syscall( BOTLIB_AI_SET_CHAT_NAME, chatstate, name, client );
}
-void trap_BotResetGoalState(int goalstate) {
- syscall( BOTLIB_AI_RESET_GOAL_STATE, goalstate );
-}
-
-void trap_BotResetAvoidGoals(int goalstate) {
- syscall( BOTLIB_AI_RESET_AVOID_GOALS, goalstate );
-}
-
-void trap_BotRemoveFromAvoidGoals(int goalstate, int number) {
- syscall( BOTLIB_AI_REMOVE_FROM_AVOID_GOALS, goalstate, number);
-}
-
-void trap_BotPushGoal(int goalstate, void /* struct bot_goal_s */ *goal) {
- syscall( BOTLIB_AI_PUSH_GOAL, goalstate, goal );
-}
-
-void trap_BotPopGoal(int goalstate) {
- syscall( BOTLIB_AI_POP_GOAL, goalstate );
-}
-
-void trap_BotEmptyGoalStack(int goalstate) {
- syscall( BOTLIB_AI_EMPTY_GOAL_STACK, goalstate );
-}
-
-void trap_BotDumpAvoidGoals(int goalstate) {
- syscall( BOTLIB_AI_DUMP_AVOID_GOALS, goalstate );
-}
-
-void trap_BotDumpGoalStack(int goalstate) {
- syscall( BOTLIB_AI_DUMP_GOAL_STACK, goalstate );
-}
-
-void trap_BotGoalName(int number, char *name, int size) {
- syscall( BOTLIB_AI_GOAL_NAME, number, name, size );
-}
-
-int trap_BotGetTopGoal(int goalstate, void /* struct bot_goal_s */ *goal) {
- return syscall( BOTLIB_AI_GET_TOP_GOAL, goalstate, goal );
-}
-
-int trap_BotGetSecondGoal(int goalstate, void /* struct bot_goal_s */ *goal) {
- return syscall( BOTLIB_AI_GET_SECOND_GOAL, goalstate, goal );
-}
-
-int trap_BotChooseLTGItem(int goalstate, vec3_t origin, int *inventory, int travelflags) {
- return syscall( BOTLIB_AI_CHOOSE_LTG_ITEM, goalstate, origin, inventory, travelflags );
-}
-
-int trap_BotChooseNBGItem(int goalstate, vec3_t origin, int *inventory, int travelflags, void /* struct bot_goal_s */ *ltg, float maxtime) {
- return syscall( BOTLIB_AI_CHOOSE_NBG_ITEM, goalstate, origin, inventory, travelflags, ltg, PASSFLOAT(maxtime) );
-}
-
-int trap_BotTouchingGoal(vec3_t origin, void /* struct bot_goal_s */ *goal) {
- return syscall( BOTLIB_AI_TOUCHING_GOAL, origin, goal );
-}
-
-int trap_BotItemGoalInVisButNotVisible(int viewer, vec3_t eye, vec3_t viewangles, void /* struct bot_goal_s */ *goal) {
- return syscall( BOTLIB_AI_ITEM_GOAL_IN_VIS_BUT_NOT_VISIBLE, viewer, eye, viewangles, goal );
-}
-
-int trap_BotGetLevelItemGoal(int index, char *classname, void /* struct bot_goal_s */ *goal) {
- return syscall( BOTLIB_AI_GET_LEVEL_ITEM_GOAL, index, classname, goal );
-}
-
-int trap_BotGetNextCampSpotGoal(int num, void /* struct bot_goal_s */ *goal) {
- return syscall( BOTLIB_AI_GET_NEXT_CAMP_SPOT_GOAL, num, goal );
-}
-
-int trap_BotGetMapLocationGoal(char *name, void /* struct bot_goal_s */ *goal) {
- return syscall( BOTLIB_AI_GET_MAP_LOCATION_GOAL, name, goal );
-}
-
-float trap_BotAvoidGoalTime(int goalstate, int number) {
- floatint_t fi;
- fi.i = syscall( BOTLIB_AI_AVOID_GOAL_TIME, goalstate, number );
- return fi.f;
-}
-
-void trap_BotSetAvoidGoalTime(int goalstate, int number, float avoidtime) {
- syscall( BOTLIB_AI_SET_AVOID_GOAL_TIME, goalstate, number, PASSFLOAT(avoidtime));
-}
-
-void trap_BotInitLevelItems(void) {
- syscall( BOTLIB_AI_INIT_LEVEL_ITEMS );
-}
-
-void trap_BotUpdateEntityItems(void) {
- syscall( BOTLIB_AI_UPDATE_ENTITY_ITEMS );
-}
-
-int trap_BotLoadItemWeights(int goalstate, char *filename) {
- return syscall( BOTLIB_AI_LOAD_ITEM_WEIGHTS, goalstate, filename );
-}
-
-void trap_BotFreeItemWeights(int goalstate) {
- syscall( BOTLIB_AI_FREE_ITEM_WEIGHTS, goalstate );
-}
-
-void trap_BotInterbreedGoalFuzzyLogic(int parent1, int parent2, int child) {
- syscall( BOTLIB_AI_INTERBREED_GOAL_FUZZY_LOGIC, parent1, parent2, child );
-}
-
-void trap_BotSaveGoalFuzzyLogic(int goalstate, char *filename) {
- syscall( BOTLIB_AI_SAVE_GOAL_FUZZY_LOGIC, goalstate, filename );
-}
-
-void trap_BotMutateGoalFuzzyLogic(int goalstate, float range) {
- syscall( BOTLIB_AI_MUTATE_GOAL_FUZZY_LOGIC, goalstate, range );
-}
-
-int trap_BotAllocGoalState(int state) {
- return syscall( BOTLIB_AI_ALLOC_GOAL_STATE, state );
-}
-
-void trap_BotFreeGoalState(int handle) {
- syscall( BOTLIB_AI_FREE_GOAL_STATE, handle );
-}
-
-void trap_BotResetMoveState(int movestate) {
- syscall( BOTLIB_AI_RESET_MOVE_STATE, movestate );
-}
-
-void trap_BotAddAvoidSpot(int movestate, vec3_t origin, float radius, int type) {
- syscall( BOTLIB_AI_ADD_AVOID_SPOT, movestate, origin, PASSFLOAT(radius), type);
-}
-
-void trap_BotMoveToGoal(void /* struct bot_moveresult_s */ *result, int movestate, void /* struct bot_goal_s */ *goal, int travelflags) {
- syscall( BOTLIB_AI_MOVE_TO_GOAL, result, movestate, goal, travelflags );
-}
-
-int trap_BotMoveInDirection(int movestate, vec3_t dir, float speed, int type) {
- return syscall( BOTLIB_AI_MOVE_IN_DIRECTION, movestate, dir, PASSFLOAT(speed), type );
-}
-
-void trap_BotResetAvoidReach(int movestate) {
- syscall( BOTLIB_AI_RESET_AVOID_REACH, movestate );
-}
-
-void trap_BotResetLastAvoidReach(int movestate) {
- syscall( BOTLIB_AI_RESET_LAST_AVOID_REACH,movestate );
-}
-
-int trap_BotReachabilityArea(vec3_t origin, int testground) {
- return syscall( BOTLIB_AI_REACHABILITY_AREA, origin, testground );
-}
-
-int trap_BotMovementViewTarget(int movestate, void /* struct bot_goal_s */ *goal, int travelflags, float lookahead, vec3_t target) {
- return syscall( BOTLIB_AI_MOVEMENT_VIEW_TARGET, movestate, goal, travelflags, PASSFLOAT(lookahead), target );
-}
-
-int trap_BotPredictVisiblePosition(vec3_t origin, int areanum, void /* struct bot_goal_s */ *goal, int travelflags, vec3_t target) {
- return syscall( BOTLIB_AI_PREDICT_VISIBLE_POSITION, origin, areanum, goal, travelflags, target );
-}
-
-int trap_BotAllocMoveState(void) {
- return syscall( BOTLIB_AI_ALLOC_MOVE_STATE );
-}
-
-void trap_BotFreeMoveState(int handle) {
- syscall( BOTLIB_AI_FREE_MOVE_STATE, handle );
-}
-
-void trap_BotInitMoveState(int handle, void /* struct bot_initmove_s */ *initmove) {
- syscall( BOTLIB_AI_INIT_MOVE_STATE, handle, initmove );
-}
-
-int trap_BotChooseBestFightWeapon(int weaponstate, int *inventory) {
- return syscall( BOTLIB_AI_CHOOSE_BEST_FIGHT_WEAPON, weaponstate, inventory );
-}
-
-void trap_BotGetWeaponInfo(int weaponstate, int weapon, void /* struct weaponinfo_s */ *weaponinfo) {
- syscall( BOTLIB_AI_GET_WEAPON_INFO, weaponstate, weapon, weaponinfo );
-}
-
-int trap_BotLoadWeaponWeights(int weaponstate, char *filename) {
- return syscall( BOTLIB_AI_LOAD_WEAPON_WEIGHTS, weaponstate, filename );
-}
-
-int trap_BotAllocWeaponState(void) {
- return syscall( BOTLIB_AI_ALLOC_WEAPON_STATE );
-}
-
-void trap_BotFreeWeaponState(int weaponstate) {
- syscall( BOTLIB_AI_FREE_WEAPON_STATE, weaponstate );
-}
-
-void trap_BotResetWeaponState(int weaponstate) {
- syscall( BOTLIB_AI_RESET_WEAPON_STATE, weaponstate );
-}
int trap_GeneticParentsAndChildSelection(int numranks, float *ranks, int *parent1, int *parent2, int *child) {
return syscall( BOTLIB_AI_GENETIC_PARENTS_AND_CHILD_SELECTION, numranks, ranks, parent1, parent2, child );
@@ -859,8 +678,8 @@ void trap_PC_RemoveAllGlobalDefines( void ) {
syscall( G_PC_REMOVE_ALL_GLOBAL_DEFINES );
}
-int trap_PC_LoadSource( const char *filename ) {
- return syscall( G_PC_LOAD_SOURCE, filename );
+int trap_PC_LoadSource( const char *filename, const char *basepath ) {
+ return syscall( G_PC_LOAD_SOURCE, filename, basepath );
}
int trap_PC_FreeSource( int handle ) {
diff --git a/code/qcommon/q_shared.h b/code/qcommon/q_shared.h
index df216702b..571ddcbbc 100644
--- a/code/qcommon/q_shared.h
+++ b/code/qcommon/q_shared.h
@@ -766,6 +766,91 @@ void COM_ParseWarning( char *format, ... ) __attribute__ ((format (printf, 1, 2)
#define TT_NUMBER 3 // number
#define TT_NAME 4 // name
#define TT_PUNCTUATION 5 // punctuation
+
+//string sub type
+//---------------
+// the length of the string
+//literal sub type
+//----------------
+// the ASCII code of the literal
+//number sub type
+//---------------
+#define TT_DECIMAL 0x0008 // decimal number
+#define TT_HEX 0x0100 // hexadecimal number
+#define TT_OCTAL 0x0200 // octal number
+//#ifdef BINARYNUMBERS
+#define TT_BINARY 0x0400 // binary number
+//#endif //BINARYNUMBERS
+#define TT_FLOAT 0x0800 // floating point number
+#define TT_INTEGER 0x1000 // integer number
+#define TT_LONG 0x2000 // long number
+#define TT_UNSIGNED 0x4000 // unsigned number
+//punctuation sub type
+//--------------------
+#define P_RSHIFT_ASSIGN 1
+#define P_LSHIFT_ASSIGN 2
+#define P_PARMS 3
+#define P_PRECOMPMERGE 4
+
+#define P_LOGIC_AND 5
+#define P_LOGIC_OR 6
+#define P_LOGIC_GEQ 7
+#define P_LOGIC_LEQ 8
+#define P_LOGIC_EQ 9
+#define P_LOGIC_UNEQ 10
+
+#define P_MUL_ASSIGN 11
+#define P_DIV_ASSIGN 12
+#define P_MOD_ASSIGN 13
+#define P_ADD_ASSIGN 14
+#define P_SUB_ASSIGN 15
+#define P_INC 16
+#define P_DEC 17
+
+#define P_BIN_AND_ASSIGN 18
+#define P_BIN_OR_ASSIGN 19
+#define P_BIN_XOR_ASSIGN 20
+#define P_RSHIFT 21
+#define P_LSHIFT 22
+
+#define P_POINTERREF 23
+#define P_CPP1 24
+#define P_CPP2 25
+#define P_MUL 26
+#define P_DIV 27
+#define P_MOD 28
+#define P_ADD 29
+#define P_SUB 30
+#define P_ASSIGN 31
+
+#define P_BIN_AND 32
+#define P_BIN_OR 33
+#define P_BIN_XOR 34
+#define P_BIN_NOT 35
+
+#define P_LOGIC_NOT 36
+#define P_LOGIC_GREATER 37
+#define P_LOGIC_LESS 38
+
+#define P_REF 39
+#define P_COMMA 40
+#define P_SEMICOLON 41
+#define P_COLON 42
+#define P_QUESTIONMARK 43
+
+#define P_PARENTHESESOPEN 44
+#define P_PARENTHESESCLOSE 45
+#define P_BRACEOPEN 46
+#define P_BRACECLOSE 47
+#define P_SQBRACKETOPEN 48
+#define P_SQBRACKETCLOSE 49
+#define P_BACKSLASH 50
+
+#define P_PRECOMP 51
+#define P_DOLLAR 52
+//name sub type
+//-------------
+// the length of the name
#endif
typedef struct pc_token_s
diff --git a/code/qcommon/vm.c b/code/qcommon/vm.c
index e68b2d3dd..652ec543e 100644
--- a/code/qcommon/vm.c
+++ b/code/qcommon/vm.c
@@ -451,7 +451,7 @@ vmHeader_t *VM_LoadQVM( vm_t *vm, qboolean alloc, qboolean unpure)
}
dataLength = 1 << i;
- if ( dataLength - vm->dataLength < vm_minQvmHunkKB->integer * 1024 )
+ while ( dataLength - vm->dataLength < vm_minQvmHunkKB->integer * 1024 )
dataLength <<= 1;
if(alloc)
@@ -1056,17 +1056,24 @@ QVM_Alloc
*/
unsigned int QVM_Alloc( vm_t *vm, int size ) {
unsigned int pointer;
+ int allocSize;
- if ( vm->dataAlloc + size > vm->dataMask+1 ) {
+ // need to align addresses for qvm?
+ allocSize = ( size + 31 ) & ~31;
+
+ if ( allocSize < size )
+ Com_Error( ERR_DROP, "QVM_Alloc: %s failed, %d < %d", vm->name, allocSize, size );
+
+ if ( vm->dataAlloc + allocSize > vm->dataMask+1 ) {
Com_Error( ERR_DROP, "QVM_Alloc: %s failed on allocation of %i bytes", vm->name, size );
return 0;
}
pointer = vm->dataAlloc;
- vm->dataAlloc += size;
+ vm->dataAlloc += allocSize;
// only needed if it's possible to free memory, dataBase is set to 0s on QVM load.
- //Com_Memset( vm->dataBase + pointer, 0, size );
+ Com_Memset( vm->dataBase + pointer, 0, size );
return pointer;
}
diff --git a/code/server/server.h b/code/server/server.h
index a0ec194e1..52e08b596 100644
--- a/code/server/server.h
+++ b/code/server/server.h
@@ -429,6 +429,8 @@ int SV_BotGetConsoleMessage( int client, char *buf, int size );
int BotImport_DebugPolygonCreate(int color, int numPoints, vec3_t *points);
void BotImport_DebugPolygonDelete(int id);
+void SV_ForcePlayerCommand( int playerNum, const char *command );
+
void SV_BotInitBotLib(void);
//============================================================
diff --git a/code/server/sv_bot.c b/code/server/sv_bot.c
index fb2c56134..65e11df25 100644
--- a/code/server/sv_bot.c
+++ b/code/server/sv_bot.c
@@ -473,7 +473,7 @@ client_t *SV_ClientForPlayerNum( int playerNum ) {
SV_BotClientCommand
==================
*/
-static void BotClientCommand( int playerNum, char *command ) {
+void SV_ForcePlayerCommand( int playerNum, const char *command ) {
client_t *client = SV_ClientForPlayerNum( playerNum );
if ( !client )
@@ -587,7 +587,7 @@ void SV_BotInitBotLib(void) {
botlib_import.inPVS = BotImport_inPVS;
botlib_import.BSPEntityData = BotImport_BSPEntityData;
botlib_import.BSPModelMinsMaxsOrigin = BotImport_BSPModelMinsMaxsOrigin;
- botlib_import.BotClientCommand = BotClientCommand;
+ botlib_import.BotClientCommand = SV_ForcePlayerCommand;
//memory management
botlib_import.GetMemory = BotImport_GetMemory;
diff --git a/code/server/sv_game.c b/code/server/sv_game.c
index a41c0b683..7dc829439 100644
--- a/code/server/sv_game.c
+++ b/code/server/sv_game.c
@@ -442,7 +442,7 @@ intptr_t SV_GameSystemCalls( intptr_t *args ) {
botlib_export->PC_RemoveAllGlobalDefines();
return 0;
case G_PC_LOAD_SOURCE:
- return botlib_export->PC_LoadSourceHandle( VMA(1) );
+ return botlib_export->PC_LoadSourceHandle( VMA(1), VMA(2) );
case G_PC_FREE_SOURCE:
return botlib_export->PC_FreeSourceHandle( args[1] );
case G_PC_READ_TOKEN:
@@ -453,6 +453,9 @@ intptr_t SV_GameSystemCalls( intptr_t *args ) {
case G_PC_SOURCE_FILE_AND_LINE:
return botlib_export->PC_SourceFileAndLine( args[1], VMA(2), VMA(3) );
+ case G_ALLOC:
+ return VM_Alloc( args[1], VMA(2) );
+
//====================================
case G_LOCATE_GAME_DATA:
@@ -547,8 +550,9 @@ intptr_t SV_GameSystemCalls( intptr_t *args ) {
BotImport_DebugPolygonDelete( args[1] );
return 0;
- case G_ALLOC:
- return VM_Alloc( args[1], VMA(2) );
+ case G_CLIENT_COMMAND:
+ SV_ForcePlayerCommand( args[1], VMA(2) );
+ return 0;
case G_R_REGISTERMODEL:
return re.RegisterModel( VMA(1) );
@@ -592,10 +596,9 @@ intptr_t SV_GameSystemCalls( intptr_t *args ) {
return botlib_export->aas.AAS_AreaInfo( args[1], VMA(2) );
case BOTLIB_AAS_ALTERNATIVE_ROUTE_GOAL:
return botlib_export->aas.AAS_AlternativeRouteGoals( VMA(1), args[2], VMA(3), args[4], args[5], VMA(6), args[7], args[8] );
- case BOTLIB_AAS_ENTITY_INFO:
- botlib_export->aas.AAS_EntityInfo( args[1], VMA(2) );
- return 0;
+ case BOTLIB_AAS_LOADED:
+ return botlib_export->aas.AAS_Loaded();
case BOTLIB_AAS_INITIALIZED:
return botlib_export->aas.AAS_Initialized();
case BOTLIB_AAS_PRESENCE_TYPE_BOUNDING_BOX:
@@ -608,6 +611,9 @@ intptr_t SV_GameSystemCalls( intptr_t *args ) {
return botlib_export->aas.AAS_PointAreaNum( VMA(1) );
case BOTLIB_AAS_POINT_REACHABILITY_AREA_INDEX:
return botlib_export->aas.AAS_PointReachabilityAreaIndex( VMA(1) );
+ case BOTLIB_AAS_TRACE_CLIENT_BBOX:
+ botlib_export->aas.AAS_TraceClientBBox( VMA(1), VMA(2), VMA(3), args[4], args[5] );
+ return 0;
case BOTLIB_AAS_TRACE_AREAS:
return botlib_export->aas.AAS_TraceAreas( VMA(1), VMA(2), VMA(3), VMA(4), args[5] );
@@ -628,95 +634,67 @@ intptr_t SV_GameSystemCalls( intptr_t *args ) {
return botlib_export->aas.AAS_AreaReachability( args[1] );
case BOTLIB_AAS_BEST_REACHABLE_AREA:
return botlib_export->aas.AAS_BestReachableArea( VMA(1), VMA(2), VMA(3), VMA(4) );
-
- case BOTLIB_AAS_AREA_TRAVEL_TIME_TO_GOAL_AREA:
- return botlib_export->aas.AAS_AreaTravelTimeToGoalArea( args[1], VMA(2), args[3], args[4] );
+ case BOTLIB_AAS_BEST_REACHABLE_FROM_JUMP_PAD_AREA:
+ return botlib_export->aas.AAS_BestReachableFromJumpPadArea( VMA(1), VMA(2), VMA(3) );
+ case BOTLIB_AAS_NEXT_MODEL_REACHABILITY:
+ return botlib_export->aas.AAS_NextModelReachability( args[1], args[2] );
+ case BOTLIB_AAS_AREA_GROUND_FACE_AREA:
+ return FloatAsInt( botlib_export->aas.AAS_AreaGroundFaceArea( args[1] ) );
+ case BOTLIB_AAS_AREA_CROUCH:
+ return botlib_export->aas.AAS_AreaCrouch( args[1] );
+ case BOTLIB_AAS_AREA_SWIM:
+ return botlib_export->aas.AAS_AreaSwim( args[1] );
+ case BOTLIB_AAS_AREA_LIQUID:
+ return botlib_export->aas.AAS_AreaLiquid( args[1] );
+ case BOTLIB_AAS_AREA_LAVA:
+ return botlib_export->aas.AAS_AreaLava( args[1] );
+ case BOTLIB_AAS_AREA_SLIME:
+ return botlib_export->aas.AAS_AreaSlime( args[1] );
+ case BOTLIB_AAS_AREA_GROUNDED:
+ return botlib_export->aas.AAS_AreaGrounded( args[1] );
+ case BOTLIB_AAS_AREA_LADDER:
+ return botlib_export->aas.AAS_AreaLadder( args[1] );
+ case BOTLIB_AAS_AREA_JUMP_PAD:
+ return botlib_export->aas.AAS_AreaJumpPad( args[1] );
+ case BOTLIB_AAS_AREA_DO_NOT_ENTER:
+ return botlib_export->aas.AAS_AreaDoNotEnter( args[1] );
+
+ case BOTLIB_AAS_TRAVEL_FLAG_FOR_TYPE:
+ return botlib_export->aas.AAS_TravelFlagForType( args[1] );
+ case BOTLIB_AAS_AREA_CONTENTS_TRAVEL_FLAGS:
+ return botlib_export->aas.AAS_AreaContentsTravelFlags( args[1] );
+ case BOTLIB_AAS_NEXT_AREA_REACHABILITY:
+ return botlib_export->aas.AAS_NextAreaReachability( args[1], args[2] );
+ case BOTLIB_AAS_REACHABILITY_FROM_NUM:
+ botlib_export->aas.AAS_ReachabilityFromNum( args[1], VMA(2) );
+ return 0;
+ case BOTLIB_AAS_RANDOM_GOAL_AREA:
+ return botlib_export->aas.AAS_RandomGoalArea( args[1], args[2], VMA(3), VMA(4) );
case BOTLIB_AAS_ENABLE_ROUTING_AREA:
return botlib_export->aas.AAS_EnableRoutingArea( args[1], args[2] );
+ case BOTLIB_AAS_AREA_TRAVEL_TIME:
+ return botlib_export->aas.AAS_AreaTravelTime( args[1], VMA(2), VMA(3) );
+ case BOTLIB_AAS_AREA_TRAVEL_TIME_TO_GOAL_AREA:
+ return botlib_export->aas.AAS_AreaTravelTimeToGoalArea( args[1], VMA(2), args[3], args[4] );
case BOTLIB_AAS_PREDICT_ROUTE:
return botlib_export->aas.AAS_PredictRoute( VMA(1), args[2], VMA(3), args[4], args[5], args[6], args[7], args[8], args[9], args[10], args[11] );
- case BOTLIB_AAS_SWIMMING:
- return botlib_export->aas.AAS_Swimming( VMA(1) );
case BOTLIB_AAS_PREDICT_CLIENT_MOVEMENT:
return botlib_export->aas.AAS_PredictClientMovement( VMA(1), args[2], VMA(3), args[4], args[5],
VMA(6), VMA(7), args[8], args[9], VMF(10), args[11], args[12], args[13] );
-
- case BOTLIB_EA_SAY:
- botlib_export->ea.EA_Say( args[1], VMA(2) );
- return 0;
- case BOTLIB_EA_SAY_TEAM:
- botlib_export->ea.EA_SayTeam( args[1], VMA(2) );
- return 0;
- case BOTLIB_EA_COMMAND:
- botlib_export->ea.EA_Command( args[1], VMA(2) );
- return 0;
-
- case BOTLIB_EA_ACTION:
- botlib_export->ea.EA_Action( args[1], args[2] );
- return 0;
- case BOTLIB_EA_GESTURE:
- botlib_export->ea.EA_Gesture( args[1] );
- return 0;
- case BOTLIB_EA_TALK:
- botlib_export->ea.EA_Talk( args[1] );
- return 0;
- case BOTLIB_EA_ATTACK:
- botlib_export->ea.EA_Attack( args[1] );
- return 0;
- case BOTLIB_EA_USE:
- botlib_export->ea.EA_Use( args[1] );
- return 0;
- case BOTLIB_EA_RESPAWN:
- botlib_export->ea.EA_Respawn( args[1] );
- return 0;
- case BOTLIB_EA_CROUCH:
- botlib_export->ea.EA_Crouch( args[1] );
- return 0;
- case BOTLIB_EA_MOVE_UP:
- botlib_export->ea.EA_MoveUp( args[1] );
- return 0;
- case BOTLIB_EA_MOVE_DOWN:
- botlib_export->ea.EA_MoveDown( args[1] );
- return 0;
- case BOTLIB_EA_MOVE_FORWARD:
- botlib_export->ea.EA_MoveForward( args[1] );
- return 0;
- case BOTLIB_EA_MOVE_BACK:
- botlib_export->ea.EA_MoveBack( args[1] );
- return 0;
- case BOTLIB_EA_MOVE_LEFT:
- botlib_export->ea.EA_MoveLeft( args[1] );
- return 0;
- case BOTLIB_EA_MOVE_RIGHT:
- botlib_export->ea.EA_MoveRight( args[1] );
- return 0;
-
- case BOTLIB_EA_SELECT_WEAPON:
- botlib_export->ea.EA_SelectWeapon( args[1], args[2] );
- return 0;
- case BOTLIB_EA_JUMP:
- botlib_export->ea.EA_Jump( args[1] );
- return 0;
- case BOTLIB_EA_DELAYED_JUMP:
- botlib_export->ea.EA_DelayedJump( args[1] );
- return 0;
- case BOTLIB_EA_MOVE:
- botlib_export->ea.EA_Move( args[1], VMA(2), VMF(3) );
- return 0;
- case BOTLIB_EA_VIEW:
- botlib_export->ea.EA_View( args[1], VMA(2) );
- return 0;
-
- case BOTLIB_EA_END_REGULAR:
- botlib_export->ea.EA_EndRegular( args[1], VMF(2) );
- return 0;
- case BOTLIB_EA_GET_INPUT:
- botlib_export->ea.EA_GetInput( args[1], VMF(2), VMA(3) );
- return 0;
- case BOTLIB_EA_RESET_INPUT:
- botlib_export->ea.EA_ResetInput( args[1] );
+ case BOTLIB_AAS_ON_GROUND:
+ return botlib_export->aas.AAS_OnGround( VMA(1), args[2], args[3] );
+ case BOTLIB_AAS_SWIMMING:
+ return botlib_export->aas.AAS_Swimming( VMA(1) );
+ case BOTLIB_AAS_JUMP_REACH_RUN_START:
+ botlib_export->aas.AAS_JumpReachRunStart( VMA(1), VMA(2) );
return 0;
+ case BOTLIB_AAS_AGAINST_LADDER:
+ return botlib_export->aas.AAS_AgainstLadder( VMA(1) );
+ case BOTLIB_AAS_HORIZONTAL_VELOCITY_FOR_JUMP:
+ return botlib_export->aas.AAS_HorizontalVelocityForJump( VMF(1), VMA(2), VMA(3), VMA(4) );
+ case BOTLIB_AAS_DROP_TO_FLOOR:
+ return botlib_export->aas.AAS_DropToFloor( VMA(1), VMA(2), VMA(3) );
case BOTLIB_AI_LOAD_CHARACTER:
return botlib_export->ai.BotLoadCharacter( VMA(1), VMF(2) );
@@ -787,130 +765,6 @@ intptr_t SV_GameSystemCalls( intptr_t *args ) {
botlib_export->ai.BotSetChatName( args[1], VMA(2), args[3] );
return 0;
- case BOTLIB_AI_RESET_GOAL_STATE:
- botlib_export->ai.BotResetGoalState( args[1] );
- return 0;
- case BOTLIB_AI_RESET_AVOID_GOALS:
- botlib_export->ai.BotResetAvoidGoals( args[1] );
- return 0;
- case BOTLIB_AI_REMOVE_FROM_AVOID_GOALS:
- botlib_export->ai.BotRemoveFromAvoidGoals( args[1], args[2] );
- return 0;
- case BOTLIB_AI_PUSH_GOAL:
- botlib_export->ai.BotPushGoal( args[1], VMA(2) );
- return 0;
- case BOTLIB_AI_POP_GOAL:
- botlib_export->ai.BotPopGoal( args[1] );
- return 0;
- case BOTLIB_AI_EMPTY_GOAL_STACK:
- botlib_export->ai.BotEmptyGoalStack( args[1] );
- return 0;
- case BOTLIB_AI_DUMP_AVOID_GOALS:
- botlib_export->ai.BotDumpAvoidGoals( args[1] );
- return 0;
- case BOTLIB_AI_DUMP_GOAL_STACK:
- botlib_export->ai.BotDumpGoalStack( args[1] );
- return 0;
- case BOTLIB_AI_GOAL_NAME:
- botlib_export->ai.BotGoalName( args[1], VMA(2), args[3] );
- return 0;
- case BOTLIB_AI_GET_TOP_GOAL:
- return botlib_export->ai.BotGetTopGoal( args[1], VMA(2) );
- case BOTLIB_AI_GET_SECOND_GOAL:
- return botlib_export->ai.BotGetSecondGoal( args[1], VMA(2) );
- case BOTLIB_AI_CHOOSE_LTG_ITEM:
- return botlib_export->ai.BotChooseLTGItem( args[1], VMA(2), VMA(3), args[4] );
- case BOTLIB_AI_CHOOSE_NBG_ITEM:
- return botlib_export->ai.BotChooseNBGItem( args[1], VMA(2), VMA(3), args[4], VMA(5), VMF(6) );
- case BOTLIB_AI_TOUCHING_GOAL:
- return botlib_export->ai.BotTouchingGoal( VMA(1), VMA(2) );
- case BOTLIB_AI_ITEM_GOAL_IN_VIS_BUT_NOT_VISIBLE:
- return botlib_export->ai.BotItemGoalInVisButNotVisible( args[1], VMA(2), VMA(3), VMA(4) );
- case BOTLIB_AI_GET_LEVEL_ITEM_GOAL:
- return botlib_export->ai.BotGetLevelItemGoal( args[1], VMA(2), VMA(3) );
- case BOTLIB_AI_GET_NEXT_CAMP_SPOT_GOAL:
- return botlib_export->ai.BotGetNextCampSpotGoal( args[1], VMA(2) );
- case BOTLIB_AI_GET_MAP_LOCATION_GOAL:
- return botlib_export->ai.BotGetMapLocationGoal( VMA(1), VMA(2) );
- case BOTLIB_AI_AVOID_GOAL_TIME:
- return FloatAsInt( botlib_export->ai.BotAvoidGoalTime( args[1], args[2] ) );
- case BOTLIB_AI_SET_AVOID_GOAL_TIME:
- botlib_export->ai.BotSetAvoidGoalTime( args[1], args[2], VMF(3));
- return 0;
- case BOTLIB_AI_INIT_LEVEL_ITEMS:
- botlib_export->ai.BotInitLevelItems();
- return 0;
- case BOTLIB_AI_UPDATE_ENTITY_ITEMS:
- botlib_export->ai.BotUpdateEntityItems();
- return 0;
- case BOTLIB_AI_LOAD_ITEM_WEIGHTS:
- return botlib_export->ai.BotLoadItemWeights( args[1], VMA(2) );
- case BOTLIB_AI_FREE_ITEM_WEIGHTS:
- botlib_export->ai.BotFreeItemWeights( args[1] );
- return 0;
- case BOTLIB_AI_INTERBREED_GOAL_FUZZY_LOGIC:
- botlib_export->ai.BotInterbreedGoalFuzzyLogic( args[1], args[2], args[3] );
- return 0;
- case BOTLIB_AI_SAVE_GOAL_FUZZY_LOGIC:
- botlib_export->ai.BotSaveGoalFuzzyLogic( args[1], VMA(2) );
- return 0;
- case BOTLIB_AI_MUTATE_GOAL_FUZZY_LOGIC:
- botlib_export->ai.BotMutateGoalFuzzyLogic( args[1], VMF(2) );
- return 0;
- case BOTLIB_AI_ALLOC_GOAL_STATE:
- return botlib_export->ai.BotAllocGoalState( args[1] );
- case BOTLIB_AI_FREE_GOAL_STATE:
- botlib_export->ai.BotFreeGoalState( args[1] );
- return 0;
-
- case BOTLIB_AI_RESET_MOVE_STATE:
- botlib_export->ai.BotResetMoveState( args[1] );
- return 0;
- case BOTLIB_AI_ADD_AVOID_SPOT:
- botlib_export->ai.BotAddAvoidSpot( args[1], VMA(2), VMF(3), args[4] );
- return 0;
- case BOTLIB_AI_MOVE_TO_GOAL:
- botlib_export->ai.BotMoveToGoal( VMA(1), args[2], VMA(3), args[4] );
- return 0;
- case BOTLIB_AI_MOVE_IN_DIRECTION:
- return botlib_export->ai.BotMoveInDirection( args[1], VMA(2), VMF(3), args[4] );
- case BOTLIB_AI_RESET_AVOID_REACH:
- botlib_export->ai.BotResetAvoidReach( args[1] );
- return 0;
- case BOTLIB_AI_RESET_LAST_AVOID_REACH:
- botlib_export->ai.BotResetLastAvoidReach( args[1] );
- return 0;
- case BOTLIB_AI_REACHABILITY_AREA:
- return botlib_export->ai.BotReachabilityArea( VMA(1), args[2] );
- case BOTLIB_AI_MOVEMENT_VIEW_TARGET:
- return botlib_export->ai.BotMovementViewTarget( args[1], VMA(2), args[3], VMF(4), VMA(5) );
- case BOTLIB_AI_PREDICT_VISIBLE_POSITION:
- return botlib_export->ai.BotPredictVisiblePosition( VMA(1), args[2], VMA(3), args[4], VMA(5) );
- case BOTLIB_AI_ALLOC_MOVE_STATE:
- return botlib_export->ai.BotAllocMoveState();
- case BOTLIB_AI_FREE_MOVE_STATE:
- botlib_export->ai.BotFreeMoveState( args[1] );
- return 0;
- case BOTLIB_AI_INIT_MOVE_STATE:
- botlib_export->ai.BotInitMoveState( args[1], VMA(2) );
- return 0;
-
- case BOTLIB_AI_CHOOSE_BEST_FIGHT_WEAPON:
- return botlib_export->ai.BotChooseBestFightWeapon( args[1], VMA(2) );
- case BOTLIB_AI_GET_WEAPON_INFO:
- botlib_export->ai.BotGetWeaponInfo( args[1], args[2], VMA(3) );
- return 0;
- case BOTLIB_AI_LOAD_WEAPON_WEIGHTS:
- return botlib_export->ai.BotLoadWeaponWeights( args[1], VMA(2) );
- case BOTLIB_AI_ALLOC_WEAPON_STATE:
- return botlib_export->ai.BotAllocWeaponState();
- case BOTLIB_AI_FREE_WEAPON_STATE:
- botlib_export->ai.BotFreeWeaponState( args[1] );
- return 0;
- case BOTLIB_AI_RESET_WEAPON_STATE:
- botlib_export->ai.BotResetWeaponState( args[1] );
- return 0;
-
case BOTLIB_AI_GENETIC_PARENTS_AND_CHILD_SELECTION:
return botlib_export->ai.GeneticParentsAndChildSelection(args[1], VMA(2), VMA(3), VMA(4), VMA(5));
diff --git a/code/ui/ui_main.c b/code/ui/ui_main.c
index eeeab184d..a82298060 100644
--- a/code/ui/ui_main.c
+++ b/code/ui/ui_main.c
@@ -888,7 +888,7 @@ void UI_ParseMenu(const char *menuFile) {
Com_DPrintf("Parsing menu file:%s\n", menuFile);
- handle = trap_PC_LoadSource(menuFile);
+ handle = trap_PC_LoadSource(menuFile, NULL);
if (!handle) {
return;
}
@@ -963,10 +963,10 @@ void UI_LoadMenus(const char *menuFile, qboolean reset) {
start = trap_Milliseconds();
- handle = trap_PC_LoadSource( menuFile );
+ handle = trap_PC_LoadSource( menuFile, NULL );
if (!handle) {
Com_Printf( S_COLOR_YELLOW "menu file not found: %s, using default\n", menuFile );
- handle = trap_PC_LoadSource( "ui/menus.txt" );
+ handle = trap_PC_LoadSource( "ui/menus.txt", NULL );
if (!handle) {
trap_Error( S_COLOR_RED "default menu file not found: ui/menus.txt, unable to continue!" );
}
diff --git a/code/ui/ui_shared.c b/code/ui/ui_shared.c
index 915b46b6f..e5235b776 100644
--- a/code/ui/ui_shared.c
+++ b/code/ui/ui_shared.c
@@ -256,52 +256,6 @@ void String_Init(void) {
}
}
-#if 0
-/*
-=================
-PC_SourceWarning
-=================
-*/
-static __attribute__ ((format (printf, 2, 3))) void PC_SourceWarning(int handle, char *format, ...) {
- int line;
- char filename[128];
- va_list argptr;
- static char string[4096];
-
- va_start (argptr, format);
- Q_vsnprintf (string, sizeof(string), format, argptr);
- va_end (argptr);
-
- filename[0] = '\0';
- line = 0;
- trap_PC_SourceFileAndLine(handle, filename, &line);
-
- Com_Printf(S_COLOR_YELLOW "WARNING: %s, line %d: %s\n", filename, line, string);
-}
-#endif
-
-/*
-=================
-PC_SourceError
-=================
-*/
-static __attribute__ ((format (printf, 2, 3))) void PC_SourceError(int handle, char *format, ...) {
- int line;
- char filename[128];
- va_list argptr;
- static char string[4096];
-
- va_start (argptr, format);
- Q_vsnprintf (string, sizeof(string), format, argptr);
- va_end (argptr);
-
- filename[0] = '\0';
- line = 0;
- trap_PC_SourceFileAndLine(handle, filename, &line);
-
- Com_Printf(S_COLOR_RED "ERROR: %s, line %d: %s\n", filename, line, string);
-}
-
/*
=================
LerpColor
diff --git a/misc/code_blocks/game.cbp b/misc/code_blocks/game.cbp
index 9a0b2f46a..ab7bb18f7 100644
--- a/misc/code_blocks/game.cbp
+++ b/misc/code_blocks/game.cbp
@@ -213,10 +213,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
@@ -225,6 +237,14 @@
+
+
+
+
+
+
+
+
diff --git a/misc/code_blocks/quake3.cbp b/misc/code_blocks/quake3.cbp
index 800323c41..cb2224c26 100644
--- a/misc/code_blocks/quake3.cbp
+++ b/misc/code_blocks/quake3.cbp
@@ -300,26 +300,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-