Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions src/botlib/ai_move/bot_move.c
Original file line number Diff line number Diff line change
Expand Up @@ -1511,3 +1511,36 @@ void BotMove_ResetAvoidReach(int movestate)
memset(ms->avoidreachtries, 0, sizeof(ms->avoidreachtries));
}

/*
=============
BotAddAvoidSpot

Adds or clears avoid spots for the movement state.
=============
*/
void BotAddAvoidSpot(int movestate, vec3_t origin, float radius, int type)
{
bot_movestate_t *ms;

ms = BotMoveStateFromHandle(movestate);
if (ms == NULL)
{
return;
}

if (type == AVOID_CLEAR)
{
ms->numavoidspots = 0;
return;
}

if (ms->numavoidspots >= MAX_AVOIDSPOTS)
{
return;
}

VectorCopy(origin, ms->avoidspots[ms->numavoidspots].origin);
ms->avoidspots[ms->numavoidspots].radius = radius;
ms->avoidspots[ms->numavoidspots].type = type;
ms->numavoidspots++;
}
2 changes: 1 addition & 1 deletion src/botlib/ai_move/bot_move.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ void BotMoveToGoal(bot_moveresult_t *result,
int BotMoveInDirection(int movestate, const vec3_t dir, float speed, int type);

void BotMove_ResetAvoidReach(int movestate);
void BotAddAvoidSpot(int movestate, vec3_t origin, float radius, int type);

void AI_MoveFrame(bot_moveresult_t *result,
int movestate,
Expand All @@ -176,4 +177,3 @@ bot_moveresult_t BotTravel_Grapple(bot_movestate_t *ms, const struct aas_reachab
#ifdef __cplusplus
} /* extern "C" */
#endif

19 changes: 18 additions & 1 deletion src/botlib/interface/bot_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -3170,6 +3170,23 @@ static void BotInterface_BotResetAvoidReach(int movestate)
BotMove_ResetAvoidReach(movestate);
}

/*
=============
BotInterface_BotAddAvoidSpot

Passes avoid spot requests to the bot movement subsystem.
=============
*/
static void BotInterface_BotAddAvoidSpot(int movestate, vec3_t origin, float radius, int type)
{
if (!BotInterface_EnsureLibraryReady("BotAddAvoidSpot"))
{
return;
}

BotAddAvoidSpot(movestate, origin, radius, type);
}

static int BotInterface_BotAllocWeaponState(void)
{
if (!BotInterface_EnsureLibraryReady("BotAllocWeaponState"))
Expand Down Expand Up @@ -3454,6 +3471,7 @@ GLADIATOR_API bot_export_t *GetBotAPI(bot_import_t *import)
exportTable.BotMoveToGoal = BotInterface_BotMoveToGoal;
exportTable.BotMoveInDirection = BotInterface_BotMoveInDirection;
exportTable.BotResetAvoidReach = BotInterface_BotResetAvoidReach;
exportTable.BotAddAvoidSpot = BotInterface_BotAddAvoidSpot;
exportTable.BotLoadCharacter = BotLoadCharacter;
exportTable.BotFreeCharacter = BotFreeCharacter;
exportTable.BotLoadCharacterSkill = BotLoadCharacterSkill;
Expand Down Expand Up @@ -3485,4 +3503,3 @@ GLADIATOR_API bot_export_t *GetBotAPI(bot_import_t *import)

return &exportTable;
}

1 change: 1 addition & 0 deletions src/q2bridge/botlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ typedef struct bot_export_s {
void (*BotMoveToGoal)(bot_moveresult_t *result, int movestate, const bot_goal_t *goal, int travelflags);
int (*BotMoveInDirection)(int movestate, const vec3_t dir, float speed, int type);
void (*BotResetAvoidReach)(int movestate);
void (*BotAddAvoidSpot)(int movestate, vec3_t origin, float radius, int type);
int (*BotLoadCharacter)(const char *character_file, float skill);
void (*BotFreeCharacter)(int handle);
int (*BotLoadCharacterSkill)(const char *character_file, float skill);
Expand Down
Loading