Skip to content

Commit

Permalink
Add cvar for debug_forceweapon for developers
Browse files Browse the repository at this point in the history
  • Loading branch information
thebigsleepjoe committed Feb 27, 2024
1 parent 3484f29 commit efb7c4a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lua/tttbots2/commands/sh_cvars.lua
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ bot_sh_cvar("debug_strafe", "0",
bot_sh_cvar('debug_navpopularity', '0',
'[May console spam. Development use only] Enables debug drawing for nav popularity. Requires "developer 1" first.')

bot_sh_cvar('debug_forceweapon', '', 'Forces bots to use a specific weapon. Gives it to them if they do not have it.')

-- Personality cvars
bot_sh_cvar("boredom", "1",
"Enables boredom. Bots will leave the server if they get too bored. If RDM is enabled, then some bots will be more likely RDM when (very) bored")
Expand Down
19 changes: 19 additions & 0 deletions lua/tttbots2/components/sv_inventory.lua
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,25 @@ function BotInventory:AutoManageInventory()
local SLOWDOWN = math.floor(TTTBots.Tickrate / 2) -- about twice per second
if self.tick % SLOWDOWN ~= 0 or self.disabled then return end

local forcedClass = lib.GetConVarString('debug_forceweapon')
if forcedClass ~= "" then
if not self.bot:HasWeapon(forcedClass) then
self.bot:Give(forcedClass)
end
self.bot:SelectWeapon(forcedClass)

local held = self:GetHeldWeaponInfo()
if not held then return end
if not held.needs_reload then return end

local loco = self.bot:BotLocomotor()

if not loco then return end
loco:Reload()

return
end

local special = self:GetWeaponInfo(self:GetSpecialPrimary())
local primary = self:GetWeaponInfo(self:GetPrimary())
local secondary = self:GetWeaponInfo(self:GetSecondary())
Expand Down

0 comments on commit efb7c4a

Please sign in to comment.