BotPlayerBalance~DynamicBotCount

Search, find and discuss about Mutators!
ProAsm
Skilled
Posts: 177
Joined: Sun Sep 29, 2013 7:12 am

Re: BotsBalanceTeams~DynamicBotCount

Post by ProAsm » Mon Mar 08, 2021 7:10 pm

Accessed None each tick if DM it's missing
This happens because you remove destroy :)
Everything uses DeathMatchPlus except some foreign type games because if you got a access none for no DM, that means the Disable'Tick' did not work, the reason a Destroy is often better.
Anyways its yours to play with and you are going to get many requests from Admin for all sorts of additions :)
Good luck :wink:

User avatar
sektor2111
Godlike
Posts: 5209
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: BotsBalanceTeams~DynamicBotCount

Post by sektor2111 » Mon Mar 08, 2021 7:39 pm

Nah, I added "disable tick" because I removed destroy and preventing DM access when this is not available + returning code if environment it's wild - of course I don't have more plans with those "UnrealI" games combined here. I'm not going to delete a mutator from chain just like that. A Bool value can stop execution and the check to a bool it's almost instant - else this can be indeed destroyed after ending game... if won't mess some other stuff.
What I like it's previous code and I added a small configurable pause - I don't think this controller needs to check things each tick, it's a waste.
You are setting up DMGame each tick, when this is still None - Your code will do null access, my code is disabling tick and then Tick will be silenced. Comment was explaining why I was disabling tick - when NOT USING Destroy. I'll bet on 3$ that here won't be any accessed none after disabling tick. Else this is doable in Tick itself, either way code supports extra adds using whatever mutate but... I'm for simple things... and then I made it Actor without "remoterole".

Edit: It also logs when changes are done (adjusting players charge). So far it looks normal and then I go to mess with some map because I think I'm done here, for me goal is being completed.

User avatar
sektor2111
Godlike
Posts: 5209
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: BotPlayerBalance~DynamicBotCount

Post by sektor2111 » Tue Mar 09, 2021 7:02 am

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
PS: I broke the rule with 37 minutes...
You do not have the required permissions to view the files attached to this post.