Skip to content

Fix bots selecting invalid weapons

Juhu requested to merge Juhu/bot_weapcomplain into master

Bots cycle through weapons before the game starts until they find a valid one. If there is no valid weapon they will try to switch their current weapon unsuccessfully on every think repeatedly until the game starts. Furthermore if a bot tries to select an invalid weapon the weapon select code will try to send a weapon complain message to it which results in QC warnings and weapon complaints being sent to every connected real player instead because the weapon selection code misses a bot client check.

The following cvars are required to reproduce the QC warning and weapon complaint spam:

g_weaponarena none
g_start_delay 20

or

g_balance_blaster_weaponstart 0
g_balance_shotgun_weaponstart 0
g_balance_machinegun_weaponstart 1
g_balance_machinegun_reload_ammo 0
g_start_delay 20

for the case where a weapon exists but it cannot be switched to due to missing ammo.

This MR fixes the networking part by making bot client checks where necessary and also the weapon switch spam by only switching the bot weapon once when the bot joins instead of repeatedly during the countdown.

Edited by Juhu

Merge request reports