Jump to content
Drift_91

Headless-Like Script to Offload AI from Zeus's Client to Server?

Recommended Posts

On my server all enemy and friendly AI are spawned by an admin using Zeus. A common problem we have is when the Zeus spawns a large firefight between friendly and enemy AI for the players to participate in. I'll be in a vehicle with the Zeus and will be getting close to normal performance; Meanwhile his game will be nearly unplayable because of the strain that the AI he's spawned are placing on his client. At the same time the dedicated server will be performing better than any of our clients because it's under virtually no load other than forwarding network information.

I did try setting up a headless client with Werthles' Headless Kit but that proved to cause numerous problems with the server; Along with the fact that the headless client placed considerable additional overhead load on the system even when no AI were loaded onto it. Is there a way I could adapt a current headless client script to load the AI onto the server instead of an actual HC? I'm a complete noob at scripting so I probably couldn't make one from scratch without a large amount of assistance. If someone already has such a script and would be willing to share that'd be much appreciated. Or if there's an easy way to convert a current headless script like Werthles' that'd be amazing.

Thanks in advance for any assistance!

Share this post


Link to post
Share on other sites

Sorry if this is not a useful answer, it's merely my own thoughts regarding AI load balancing:

 

Would be nice if server could monitor every connected host's FPS (dedicated server, headless or player client) and when needed transfer ownership of an AI group to the machine with best reported FPS (dedicated server itself, headless or player client). Seeing as Zeus players already own their spawned AI groups, it should be possible transfer any AI groups to another machine on the fly if the previous machine is overloaded or disconnected (hopefully in a JIP compatible manner without the AI losing information on known enemies, waypoints, scripting, etc). This might reduce the need for a Headless Client. Any AI addons/scripting must then be able to continue running on the new machine where the old machine left off. Nasty.

 

I am wondering if anyone has experimented with something like this? This would be done in addition to any COOP multiplayer code optimization and AI caching (or similar temporary disables until players are nearby).

Share this post


Link to post
Share on other sites
On 2017-03-08 at 11:56 AM, sjakal said:

Sorry if this is not a useful answer, it's merely my own thoughts regarding AI load balancing:

 

Would be nice if server could monitor every connected host's FPS (dedicated server, headless or player client) and when needed transfer ownership of an AI group to the machine with best reported FPS (dedicated server itself, headless or player client). Seeing as Zeus players already own their spawned AI groups, it should be possible transfer any AI groups to another machine on the fly if the previous machine is overloaded or disconnected (hopefully in a JIP compatible manner without the AI losing information on known enemies, waypoints, scripting, etc). This might reduce the need for a Headless Client. Any AI addons/scripting must then be able to continue running on the new machine where the old machine left off. Nasty.

 

I am wondering if anyone has experimented with something like this? This would be done in addition to any COOP multiplayer code optimization and AI caching (or similar temporary disables until players are nearby).

I know that Werthles Headless Module does some load balancing between multiple HCs. I don't think it balances between curators and the server itself though. I would think normally you would want the AI off clients to avoid adding extra latency. For example if someone playing as Zeus has a ping of 800ms to the server and another player has 10ms to the server, their effective latency is 810ms. On the other hand it could be handy in a situation like mine where my server is on the same LAN as my client and the client has a somewhat more powerful CPU.

Share this post


Link to post
Share on other sites

I am almost 100% sure it is possible without any mods.

 

Is it possible to do this with an eventhandler, moving AI to the HC everytime you spawn it with Zeus? There is litterary NOTHING about this on the internet...

Share this post


Link to post
Share on other sites

Untested, something like...

//initServer.sqf

//when a player is assigned a Zeus
[ NAME_OF_CURATOR_LOGIC, "curatorUnitAssigned", {
	params[ "_curatorLogic", "_player" ];

	//Call remote function on Zeus client
	_curatorLogic remoteExec[ "TAG_fnc_addCuratorEH", _player ];
}] call BIS_fnc_addScriptedEventHandler;


TAG_fnc_assignToHC = {
	params[ "_group" ];

	//If the group is not already owned by the HC ( object placed fires multiple times for each unit in a group ) 
	if !( owner _group isEqualTo owner HC ) then {
		//Set the groups owner to the HC
		_group setGroupOwner owner HC;
	};
};
//initPlayerLocal.sqf

TAG_fnc_addCuratorEH = {
	params[ "_curatorLogic" ];

	//Add curator EH
	//Object placed as creating a single man or vehicle does not activate groupPlaced
	_curatorLogic addEventHandler [ "CuratorObjectPlaced", {
		params[ "_curatorModule", "_object" ];

		//If the object placed has crew ( true for vehicle, man, group ) 
		if ( count crew _object > 0 ) then {
			//call remote function on server
			group effectiveCommander _object remoteExec[ "TAG_fnc_assignToHC", 2 ];
		};
	}];
};

 

  • Like 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×