-
Notifications
You must be signed in to change notification settings - Fork 28
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
How to prevent bots from leaving game when killing a player? #122
Comments
The addon tries to keep the number of bots in such a way that there is a desired number of players per team. And the desired count is defined by this function: D3bot/lua/d3bot/sv_zs_bot_handler/supervisor.lua Lines 4 to 21 in 9c87dd4
Any player that willingly or unwillingly joins the zombie team, will cause the addon to kick zombie bots until the desired number is reached again. Unfortunately there is no setting to prevent bots from leaving when they kill a player. Probably the best way for now would be to modify that function. You can replace it with the following (untested) snippet, which will neither add/remove any zombie bots when the game is active: function D3bot.GetDesiredBotCount()
local wave = math.max(1, GAMEMODE:GetWave())
local minutes = (CurTime() - roundStartTime) / 60
local allowedTotal = game.MaxPlayers() - 2
local allowedBots = allowedTotal - #player.GetHumans()
local mapParams = D3bot.MapNavMesh.Params
local zombieFormula = ((mapParams.ZPP or D3bot.ZombiesPerPlayer) + (mapParams.ZPPW or D3bot.ZombiesPerPlayerWave) * wave) * #player.GetHumans() + (mapParams.ZPM or D3bot.ZombiesPerMinute) * minutes + (mapParams.ZPW or D3bot.ZombiesPerWave) * wave
local zombiesCount = math.Clamp(
math.ceil(math.min(zombieFormula, (mapParams.ZPPM or D3bot.ZombiesPerPlayerMax) * #player.GetHumans()) + D3bot.ZombiesCountAddition + (mapParams.BotMod or 0) + (D3bot.NodeZombiesCountAddition or 0)),
0,
allowedBots)
local survivorFormula = (mapParams.SPP or D3bot.SurvivorsPerPlayer) * #player.GetHumans()
local survivorsCount = math.Clamp(
math.ceil(survivorFormula + D3bot.SurvivorCountAddition + (mapParams.SCA or 0)),
0,
math.max(allowedBots - zombiesCount, 0))
if GAMEMODE:GetWave() == 0 then zombiesCount = nil end
return zombiesCount, (GAMEMODE.ZombieEscape or GAMEMODE.ObjectiveMap) and 0 or survivorsCount, allowedTotal
end You can also replace that function all together with some more simple logic. All you need to return is:
Instead of that mess of parameters that we have now, i will most likely add a function to the config file so that server owners can easily define their own custom behavior. But that is for when i find some time to continue to work on the bot. |
Bots will leave when a human player dies. I'm wondering how to prevent that from happening.
Tried setting ZombiesPerPlayerMax to a higher value but no luck.
The text was updated successfully, but these errors were encountered: