Jump to content
fathersarge

Headless Client Script for all AI

Recommended Posts

So I'm using this script (aitohc, in spoiler) but it kicks back all kinds of errors (in second spoiler) and from what I've read it is causing the server performance to degrade over (mission)time.

 

Does anyone have any insight on a way to fix it? Or a new method for moving all AI (Zeus, script spawned, etc) units to HCs during a mission?

 

Script

Spoiler

/*
 * aitohc.sqf
 *
 * By VCRPlayer
 *
 * This script will move ANY ai (ie: zeus-spawned, etc)         to the headless client for processing on every frame
 * 
 * In init.sqf, put "[] execVM "aitohc.sqf";" (without outer quotes)
 *
 * In the description of the HeadlessClient virtual unit, put HC
 */
if (!isServer) exitWith {};
_HC = owner "HC"; //"HC" denotes the name of the unit in-game
waitUntil {!isNil "HC"};

 ["HCS_addToHC", "onEachFrame", {
    if ((isPlayer)||(_x in units group _HC)) exitWith {};
    if (isNull _HC) ExitWith{};

    { _x setGroupOwner _HC; //adding all units that aren't player or aren't already under HC to HC
    }forEach allUnits;

}] call BIS_fnc_addStackedEventHandler;

 

 

 

Errors

Spoiler

20:11:50 Error in expression <addToHC", "onEachFrame", {
if ((isPlayer)||(_x in units group _HC)) exitWith {};>
20:11:50   Error position: <)||(_x in units group _HC)) exitWith {};>
20:11:50   Error unexpected )
20:11:50 File mpmissions\Training_Map_Redux.Sara\aitohc.sqf, line 17
20:11:50 Error in expression <addToHC", "onEachFrame", {
if ((isPlayer)||(_x in units group _HC)) exitWith {};>
20:11:50   Error position: <)||(_x in units group _HC)) exitWith {};>
20:11:50   Error unexpected )
20:11:50 File mpmissions\Training_Map_Redux.Sara\aitohc.sqf, line 17
20:12:15 Error compiling '' in 'HitPelvis'
20:12:15 Error compiling '' in 'HitAbdomen'
20:12:15 Error compiling '' in 'HitDiaphragm'
20:12:15 Error compiling '' in 'HitChest'
20:12:15 Error compiling '' in 'HitArms'
20:12:15 Error compiling '' in 'HitLegs'
20:12:15 [ACE] (interact_menu) ERROR: Failed to add action - action (murshun_cigs_start_someones_cig) to parent ["ACE_Head"] on object VirtualMan_F [0] z\ace\addons\interact_menu\functions\fnc_addActionToClass.sqf:67
20:12:15  Mission id: b19572955627b481c0f96296a1cf534a27701df8
20:12:16 Error in expression <

if (!isServer) exitWith {};
_HC = owner "HC"; 
waitUntil {!isNil "HC"};

[>
20:12:16   Error position: <owner "HC"; 
waitUntil {!isNil "HC"};

[>
20:12:16   Error owner: Type String, expected Object
20:12:16 File mpmissions\Training_Map_Redux.Sara\aitohc.sqf, line 13

 

 

Additional background:

 

The script is originally from here: https://www.reddit.com/r/arma/comments/33q838/simple_headless_client_script/

 

I have followed all instructions, the HC module is placed and named properly. The script functions, but I can't help but want to get rid of those errors. I have done a little research and I'm not the only one who has had a problem like this.

There was this topic: https://forums.bistudio.com/forums/topic/182423-trouble-figuring-out-a-script-error/ which has given me a small insight into the issue but the solution offered I can't wrap my head around properly.

 

Thanks for any help!

Share this post


Link to post
Share on other sites

Have you considered using Werthless's headless client module instead? We have three headless clients running without issue. Also assists in transferring zeus controlled units. Server performance normally degrades after 3 hours requiring a reset, that's just arma's engine.

 

 

  • Like 1

Share this post


Link to post
Share on other sites

I have indeed looked into it and will be testing at some point but I figured I'd ask the question and see what the community had to offer

Share this post


Link to post
Share on other sites
12 hours ago, pliskin124 said:

Have you considered using Werthless's headless client module instead? We have three headless clients running without issue. Also assists in transferring zeus controlled units. Server performance normally degrades after 3 hours requiring a reset, that's just arma's engine.

 

 

3 headless clients?

Do you have any numbers on performance?

How many AI can you usually run with 3 HCs?

 

Cheers

Share this post


Link to post
Share on other sites

I would actually like to see a comparison of performance between this aitohc script and Werthles' module. I do not currently have access to our server equipment nor know how to perform such a test or I would do it myself

Share this post


Link to post
Share on other sites

I think u just need to spawn AI until average server FPS decreases below a certain value and then store the number of AI present.
After that delete all AI and run the test again.
Repeat it a hundred times and average the stored numbers of AI present. Now you know how many AI can be spawned and u can compare this value for both hc systems

sent from mobile using Tapatalk

Share this post


Link to post
Share on other sites

The problem with setting an arbitrary server FPS is that AI do indeed behave differently with server stress.  Some people say the cutoff is 20FPS however I've found AI to become less responsive as soon as you go below 40FPS!  Currently playing Total Conquest by Tvig0r0us and I'm able to get 192 soldiers on my dedi at 49FPS (no server mods, release candidate 64 bit exe)

 

I reckon that I'd need a HC if I was to push 300+ AI.

Share this post


Link to post
Share on other sites
if (!isServer) exitWith {};
_HC = owner HC; //"HC" denotes the name of the unit in-game
waitUntil {!isNil "HC"};
 ["HCS_addToHC", "onEachFrame", {
    if (isPlayer _x || (_x in units group _HC)) exitWith {};
    if (isNull _HC) ExitWith{};
    {
    	_x setGroupOwner _HC; //adding all units that aren't player or aren't already under HC to HC
    }forEach allGroups;
}] call BIS_fnc_addStackedEventHandler;

 

In theorie this shouldn't throw any 

You tried pointing to an Object with a String ("HC")

and isplayer was missing an Object.

 

No need for an onEachFrame btw. if you have CBA running there are way better options

But I would:

["HCS_addToHC", "onEachFrame", {
    {
    	if (isNull HC) ExitWith{};
   		if (!isPlayer (leader group _x)) then {
	    	(group _x) setGroupOwner HC;
    	};
    }forEach allUnits - allPlayers - entities "HeadlessClient_F";
}] call BIS_fnc_addStackedEventHandler;

Use this instead.

 

If you are using CBA:

Spoiler

[
	{
		{
			if (count (units _x select {isPlayer _x}) == 0) then {
				_x setGroupOwner owner HC;
			};
		}forEach allGroups;
	},
	30,
	[]
] call CBA_fnc_addPerFrameHandler;

No need to check every Frame and set the owner again and again. Every 30 seconds or even more should do the trick, if you are playing an mission with static units and without spawning once at mission start or, as soon as the HC joins.

 

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
On 5/10/2017 at 0:35 PM, crewt said:

-snip-

 

 
 

 

And that will add any AI to the HC? Including Zeus and ALIVE spawned enemies?

 

I just tested and no errors, but I have no way of testing the headless client move at this time (no access to the box)

Share this post


Link to post
Share on other sites

yes

As you are using Alive, I would recommend unsing the CBA version, then every 30 sec.

  • Like 1

Share this post


Link to post
Share on other sites
2 minutes ago, crewt said:

yes

As you are using Alive, I would recommend unsing the CBA version, then every 30 sec.

 

 

You are amazing. I was just about to edit my post and say I was using the CBA version. Thank you so much for the help. I'll report back if anything happens when we use it with the server :)

  • 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

×