Improve bot stability and teammate support - #37
Open
Angry-Bishop wants to merge 2 commits into
Open
Angry-Bishop wants to merge 2 commits into
Angry-Bishop wants to merge 2 commits into
Conversation
Author
|
Added a follow-up commit addressing bots that retained primed grenades after combat ended. The investigation identified several paths where grenade maintenance could stop after the enemy became invalid, during early bot-think exits, or when the grenade-disposal job was rejected because no current waypoint existed. The update adds an independent safety check, centralizes grenade release and state cleanup, permits emergency disposal without a waypoint, and coordinates the frame-level release deadline with the existing disposal job. The full problem description, implementation details, preserved beta3 behavior, and validation status have been added to the PR description. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This pull request combines a broad stability and memory-safety review with improvements to flag handling, Medic healing, Engineer armor repair, and Metamod engine hooks.
The changes were transplanted onto the current upstream beta 3 source and reconciled with overlapping upstream work. Existing
1.0-beta3version identifiers are retained.Major changes
Stability and memory safety
botcommand cvar.Flag tracking and human handoff
client slot - 1.dropitemscommand.Configuration:
Medic healing bug fixes and teammate support
FoXBot already contained a
JOB_BUFF_ALLYhealing implementation, but several discovery, scheduling, navigation, and combat interactions could prevent it from running reliably.Corrected problems include:
IN_ATTACKset or reselect a firearm after urgent healing had been selected.currentJob.The corrected behavior:
savemerequests increased priority for five seconds.Engineer teammate support
Metamod engine hooks
ClientCommandpaths that could return without settingmeta_result.MRES_IGNORED; fake or invalid client destinations retain the intended suppression behavior.FL_FAKECLIENTflag.Follow-up: Prevent bots from holding primed grenades after combat
Observed problem
Bots could prime a grenade while fighting, eliminate or lose their opponent, and then continue holding the live grenade until it exploded in their hand. This caused avoidable self-damage and occasional bot suicides after an otherwise successful fight.
Problems discovered
The investigation found several related control-flow gaps:
JOB_BIN_GRENADE.JOB_BIN_GRENADEcould be rejected when the bot temporarily had no current waypoint, even though safely releasing a live grenade should not require valid route data.nadePrimedandnadeTypestate resets were duplicated across multiple paths, increasing the possibility of the engine command and internal bot state becoming inconsistent.Changes made
Added
BotCheckPrimedGrenade()to maintain an already-live grenade independently of ordinary combat processing.Calls the safety check before early stationary/blinded exits and again after environment sensing, where an enemy pointer may be cleared immediately following a kill.
Submits
JOB_BIN_GRENADEas soon as a primed bot no longer has a valid enemy, allowing the bot more time to select and face a safe throw direction.Preserves the existing grenade-type and health-dependent release deadline:
Ensures that the final release deadline remains active even if normal combat processing stops or grenade use is disabled after the grenade has already been primed.
Added
BotReleasePrimedGrenade()to centralize:nadePrimed.nadeType.Allows
JOB_BIN_GRENADEto run without a current waypoint.Updates the disposal job so that, if the frame-level safety check releases the grenade while the bot is still turning, the job stops aiming and enters its normal retreat phase.
Reuses the centralized release helper for normal timed throws, untimed throws, underwater release, and the disposal job’s emergency fallback.
Existing beta3 behavior preserved
The change was ported into the current beta3 source rather than copying the older beta2 files over it. The following newer beta3 behavior remains intact:
Gameplay scope
This does not give bots extraordinary awareness or abilities. The bot only responds to its own known primed-grenade state, the existing enemy state, and the existing disposal job. It does not locate unseen opponents or obtain information unavailable through normal bot processing.
Normal grenade selection, targeting, cooking, and close-range emergency behavior remain unchanged.
Concussion-jump behavior is also unaffected because the dedicated concussion-jump job does not use the ordinary
nadePrimedstate monitored by this safety path.Validation
The original correction was tested extensively on the deployed beta2-based server build.
The change was separately ported onto the beta3 source used by PR Improve bot stability and teammate support #37.
Only the five relevant source files were changed:
bot.cppbot_combat.cppbot_func.hbot_job_functions.cppbot_job_think.cppAll C++ translation units passed syntax validation.
The Win32 DLL compiled successfully and loaded through Metamod as:
FoXBot v1.0-beta3, Sep 26 2026Runtime testing of the beta3 build is continuing, with particular attention to opponent loss, missing waypoints, interrupted disposal jobs, and normal grenade and concussion-jump behavior.
Files and principal functions changed
bot.cppBotCreate,BotFindItem,PlayerArmorPercent,BotAttackerCheck,BotSoundSense,BotRoleCheck,BotComms,BotThink,BotSenseEnvironment,BotFight,BotCombatThink; per-frame primed-grenade safety checksbot.hbot_client.cppbot_combat.cppBotNadeHandler,BotCheckPrimedGrenade,BotReleasePrimedGrenade, and grenade-release timingbot_func.hbot_compress.hbot_ga.cppbot_job_assessors.cppassess_JobBuffAllysupport priorities, range limits, and threat handlingbot_job_functions.cppJobBuffAllyhealing/repair execution and weapon confirmation;JobBinGrenadedisposal, emergency release, and retreat handlingbot_job_think.cppSubmitNewJob, Engineer support discovery, and support for grenade-disposal jobs without a current waypointbot_neuralnet.cppdll.cppClientCommand,StartFrame,FakeClientCommand, bot-cfg processing, server-command pollingengine.cpppfnClientCommand,pfnClientPrintf,pfnServerPrint, hook registration, name/message validationlist.hutil.cppUTIL_GetTeamColor,UTIL_GetClass, filename construction, line readingwaypoint.cppValidation
Transplanted onto current upstream beta 3 rather than copying beta 2 files directly.
Tested changes using current V1 Beta 2 and the working Beta 3 exetensively
git diff --checkcompletes without errors.Visual Studio
Release | Win32rebuild completed successfully.Verified required DLL exports, including:
GiveFnptrsToDllMeta_QueryMeta_AttachGetEntityAPIGetEntityAPI_PostRuntime smoke-tested over two rounds on a Windows TFC dedicated server.
Bot creation, ordinary bot behavior, and server bot commands operated as expected.
The cumulative flag-handoff and teammate-support behavior was also exercised using the beta 2 development builds.
Generated DLL is not included in this pull request but can be provided on request.
Test-build SHA-256:
229b7f20329c28ea33bebdec96032e7988f48d5391572eb614f9717c2b2fd502