Create manage_bots_fill

This commit is contained in:
Resxt 2022-09-18 17:42:20 +02:00
parent 0fea8f023d
commit c920a76681
2 changed files with 86 additions and 0 deletions

View File

@ -57,6 +57,13 @@ This checks for bots kills and deaths every 30 seconds. If they didn't do any ki
Obviously a better way to do this would be checking for their positions or removing bad spawns on the map or creating waypoints for the map. Obviously a better way to do this would be checking for their positions or removing bad spawns on the map or creating waypoints for the map.
This is just a quick temporary solution that works for me. This is just a quick temporary solution that works for me.
## manage_bots_fill.gsc
Simple script that changes the Bot Warfare `bots_manage_fill` dvar dynamically to avoid using resource for an empty server.
Whenever a player connects or disconnects the script checks the amount of human players and the value of `bots_manage_fill` and sets it accordingly.
If the first player joins, it sets the dvar to the value you configured for that specific server (set in `InitServersDvar()` with the server port).
If the last player leaves it sets back the dvar to 0 so that no bots will be playing, saving some resources on that server.
## remove_heavy_weapon_slow.gsc ## remove_heavy_weapon_slow.gsc
Set back your speed scale to default whenever you have an heavy weapon equipped. Set back your speed scale to default whenever you have an heavy weapon equipped.

View File

@ -0,0 +1,79 @@
#include maps\mp\bots\_bot_utility;
Init()
{
InitManageBotsFill();
}
InitManageBotsFill()
{
InitServersDvar();
SetDvar("bots_manage_fill_kick", 1);
level thread OnPlayerConnect();
}
OnPlayerConnect()
{
for (;;)
{
level waittill("connected", player);
if (!player IsBot())
{
TryUpdateBotsManageFill();
player thread OnPlayerDisconnect();
}
}
}
OnPlayerDisconnect()
{
self waittill("disconnect");
TryUpdateBotsManageFill();
}
InitServersDvar()
{
level.manage_bots_fill = [];
level.manage_bots_fill["27017"] = "12";
}
TryUpdateBotsManageFill()
{
wait 1;
if (HasHumanPlayers())
{
if (GetDvar("bots_manage_fill") != level.manage_bots_fill[GetDvar("net_port")])
{
SetDvar("bots_manage_fill", level.manage_bots_fill[GetDvar("net_port")]);
}
}
else
{
SetDvar("bots_manage_fill", 0);
}
}
IsBot()
{
return IsDefined(self.pers["isBot"]) && self.pers["isBot"];
}
HasHumanPlayers()
{
foreach (player in level.players)
{
if (!player IsBot())
{
return true;
}
}
return false;
}