Skip to content

[HL2MP] Finish bot health charger support #1371

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Blixibon
Copy link

@Blixibon Blixibon commented Jun 23, 2025

HL2MP bots have unfinished support for using item_healthcharger and func_healthcharger entities to heal themselves. This pull request allows them to be supported to the same extent as regular health kits.

Specific changes made:

  • Chargers with no juice are not considered when searching for health kits.
  • Bots navigate to a point in front of the chargers, rather than directly into the chargers.
    • Positions can be displayed using hl2mp_bot_debug_health_scavenging, which was previously unused.
  • Chargers are now identified by finding item_health*/func_health* and then searching for "charger" in the classname directly, rather than through leading wildcards with *charger*/*_health*, which Source does not support by default.
    • Previously, this was causing the health entity filter to evaluate all entities, and for all health kits to be considered chargers. The latter was not noticeable due to the health kits being consumed before any charger-related actions could take place.
  • Range increased from 50 to the actual player use radius, which is 80 by default.
  • Bots drop any prop they're holding with the gravity gun before interacting with a charger.
  • Bots now look at the charger while using it.
  • Bots now press the +USE button rather than invoking the chargers' Use() functions directly, as the latter had issues.
  • Critical health now uses the correct comparison operator when deciding whether to abandon a charger.
  • Bots will only abandon a charger they're currently using due to a threat if there is a clear path between them and the threat.
  • Chargers are not considered when the bot has a visible enemy and is not at critical health. If the bot is currently moving to a charger, it will abandon it.
    • This is partially based on the existing check for when a bot is already using the charger, and this prevents the bot from getting caught in a loop.
  • Bots on "Expert" difficulty will now move left and right while using a charger to avoid standing still. This behavior can be toggled with hl2mp_bot_health_charger_weave.

Here's a video of how health scavenging behavior worked prior to this pull request:

2025-06-22.21-18-40.mp4

Here's a video showing how it works with the changes included:

2025-06-22.22-07-54.mp4

Here's a video showing a bot on "Expert" difficulty using the aforementioned "weaving" behavior:

2025-06-22.22-10-30.mp4

@Blixibon Blixibon force-pushed the hl2mp-bots/health-chargers branch from 0fdf91f to 1d18807 Compare June 23, 2025 23:16
@Blixibon
Copy link
Author

I made additional changes for bots considering threats and reflected that in the change log.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant