Skip to content
Merged
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
41 changes: 41 additions & 0 deletions src/botlib/ai_move/bot_move.c
Original file line number Diff line number Diff line change
Expand Up @@ -1696,6 +1696,47 @@ void BotMove_ResetAvoidReach(int movestate)
memset(ms->avoidreachtries, 0, sizeof(ms->avoidreachtries));
}

/*
=============
BotResetLastAvoidReach

Clear the most recent avoid reach entry.
=============
*/
void BotResetLastAvoidReach(int movestate)
{
int i;
int latest;
float latesttime;
bot_movestate_t *ms;

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

latesttime = 0.0f;
latest = 0;
for (i = 0; i < MAX_AVOIDREACH; i++)
{
if (ms->avoidreachtimes[i] > latesttime)
{
latesttime = ms->avoidreachtimes[i];
latest = i;
}
}

if (latesttime != 0.0f)
{
ms->avoidreachtimes[latest] = 0.0f;
if (ms->avoidreachtries[i] > 0)
{
ms->avoidreachtries[latest]--;
}
}
}

/*
=============
BotReachabilityArea
Expand Down
1 change: 1 addition & 0 deletions 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 BotResetLastAvoidReach(int movestate);
int BotReachabilityArea(const vec3_t origin, int client);
int BotMovementViewTarget(int movestate,
const bot_goal_t *goal,
Expand Down
18 changes: 18 additions & 0 deletions src/botlib/interface/bot_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -3358,6 +3358,23 @@ static void BotInterface_BotResetAvoidReach(int movestate)
BotMove_ResetAvoidReach(movestate);
}

/*
=============
BotInterface_BotResetLastAvoidReach

Bridge reset helper for the most recent avoided reachability.
=============
*/
static void BotInterface_BotResetLastAvoidReach(int movestate)
{
if (!BotInterface_EnsureLibraryReady("BotResetLastAvoidReach"))
{
return;
}

BotResetLastAvoidReach(movestate);
}

/*
=============
BotInterface_BotReachabilityArea
Expand Down Expand Up @@ -3715,6 +3732,7 @@ GLADIATOR_API bot_export_t *GetBotAPI(bot_import_t *import)
exportTable.BotMoveToGoal = BotInterface_BotMoveToGoal;
exportTable.BotMoveInDirection = BotInterface_BotMoveInDirection;
exportTable.BotResetAvoidReach = BotInterface_BotResetAvoidReach;
exportTable.BotResetLastAvoidReach = BotInterface_BotResetLastAvoidReach;
exportTable.BotReachabilityArea = BotInterface_BotReachabilityArea;
exportTable.BotMovementViewTarget = BotInterface_BotMovementViewTarget;
exportTable.BotPredictVisiblePosition = BotInterface_BotPredictVisiblePosition;
Expand Down
1 change: 1 addition & 0 deletions src/q2bridge/botlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,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 (*BotResetLastAvoidReach)(int movestate);
int (*BotReachabilityArea)(vec3_t origin, int client);
int (*BotMovementViewTarget)(int movestate, const bot_goal_t *goal, int travelflags, float lookahead, vec3_t target);
int (*BotPredictVisiblePosition)(vec3_t origin, int areanum, const bot_goal_t *goal, int travelflags, vec3_t target);
Expand Down
Loading