From 7e0a2c27d30eda5363e93df37fe73daf97b2e9f5 Mon Sep 17 00:00:00 2001 From: themuffinator Date: Tue, 30 Dec 2025 21:29:43 +0000 Subject: [PATCH] Add BotAddAvoidSpot support --- src/botlib/ai_move/bot_move.c | 33 ++++++++++++++++++++++++++++ src/botlib/ai_move/bot_move.h | 2 +- src/botlib/interface/bot_interface.c | 19 +++++++++++++++- src/q2bridge/botlib.h | 1 + 4 files changed, 53 insertions(+), 2 deletions(-) diff --git a/src/botlib/ai_move/bot_move.c b/src/botlib/ai_move/bot_move.c index 2b3d722..1ecbe04 100644 --- a/src/botlib/ai_move/bot_move.c +++ b/src/botlib/ai_move/bot_move.c @@ -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++; +} diff --git a/src/botlib/ai_move/bot_move.h b/src/botlib/ai_move/bot_move.h index 8f2600c..50aef60 100644 --- a/src/botlib/ai_move/bot_move.h +++ b/src/botlib/ai_move/bot_move.h @@ -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, @@ -176,4 +177,3 @@ bot_moveresult_t BotTravel_Grapple(bot_movestate_t *ms, const struct aas_reachab #ifdef __cplusplus } /* extern "C" */ #endif - diff --git a/src/botlib/interface/bot_interface.c b/src/botlib/interface/bot_interface.c index c3d1bba..06a753a 100644 --- a/src/botlib/interface/bot_interface.c +++ b/src/botlib/interface/bot_interface.c @@ -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")) @@ -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; @@ -3485,4 +3503,3 @@ GLADIATOR_API bot_export_t *GetBotAPI(bot_import_t *import) return &exportTable; } - diff --git a/src/q2bridge/botlib.h b/src/q2bridge/botlib.h index c5e92c3..65cd0bc 100644 --- a/src/q2bridge/botlib.h +++ b/src/q2bridge/botlib.h @@ -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);