For all curious server dudes, previous Mutator DynamicBotCount can be Actor like here - if is server-side and doesn't use any mutator specific function then it can be definitely Actor - and a configurable ServerActor letting admin to prepare stuff with a minimal server outage time (or without outage time... if you know what is about...).
Code: Select all
class DynamicBotCount expands Actor config(DynamicBotCount);
/*
2021 - completing brackets for saving configuration - saving INI is not always needed,
it's doable ONCE from preferences menu.
Disabling actor (not mutator) when environment it's not suitable for this,
yes, this is ServerActor now as long as it doesn't use any Mutator specific function
INT file can trigger existence of this actor in UT's preferences configurator.
It works at certain time intervals and not assigning variable each tick for no reason,
it won't even blink if game is being ended - there is nothing to balance if game is no longer running.
INT content
[Public]
Object=(Name=DynamicBotCount.DynamicBotCount,Class=Class,MetaClass=Engine.Actor,Description="Dynamic_Bot_Count")
Preferences=(Caption="Actors",Parent="Advanced Options")
Preferences=(Caption="Dynamic_Bot_Count Config",Parent="Actors",Class=DynamicBotCount.DynamicBotCount,Immediate=True)
*/
var() config int NumberOfBots[16];
var() config float WorkRate;
var DeathMatchPlus DMGame;
var bool bInactive;
var float LastSecTime;
function PreBeginPlay()
{
// SaveConfig();
DMGame = DeathMatchPlus(Level.Game);
if( DMGame == none )
{
log ("DynamicBotCount by Sp0ngeb0b went inactive. - Invalid DeathMatchPlus -");
Disable('Tick');
bInactive = True;
// Destroy();
}
else
{
if ( WorkRate < 0.2 )
WorkRate = 1.000000;
Log("DynamicBotCount by Sp0ngeb0b running. - Updated 2021 -");
}
}
function Tick (float DT)
{
if ( (Level.TimeSeconds - LastSecTime) >= WorkRate )
{
LastSecTime = Level.TimeSeconds;
if ( Level.Game != None && Level.Game.bGameEnded )
bInactive = True;
if ( bInactive )
{
Disable('Tick');
return;
}
else
{
CalibratePlayers();
}
}
}
function CalibratePlayers()
{
local int i;
i = Level.Game.NumPlayers;
if ( i >= ArrayCount(NumberOfBots) )
i = ArrayCount(NumberOfBots);
if ( DMGame.MinPlayers != Level.Game.NumPlayers + NumberOfBots[i] )
{
DMGame.MinPlayers = Level.Game.NumPlayers + NumberOfBots[i];
log("Adjusted Players Charge.",'DynamicBotCount');
}
}
defaultproperties
{
NetPriority=4.000000
RemoteRole=ROLE_None
bGameRelevant=True
WorkRate=2.000000
}
Let's see some image from lab...
- DynBC.PNG (10.63 KiB) Viewed 577 times
PS: I broke the rule with 37 minutes...