Headless Client – Arma 3

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Page presentation update)
Line 1: Line 1:
=Headless Client Overview=
{{SideTOC}}
 
 
== Headless Client Overview ==
 
* Headless Client is used to offload AI calculations from the server instance
* Headless Client is used to offload AI calculations from the server instance
* Headless Client is integrated into game client and dedicated server executable (WIndows and Linux, use -client parameter)
* Headless Client is integrated into game client and dedicated server executable (WIndows and Linux, use -client parameter)
* The server doesn't allow arbitrary connections from headless clients if you do not define the headless clients IPs in the '''server.cfg''',  
* The server doesn't allow arbitrary connections from headless clients if you do not define the headless clients IPs in the '''server.cfg''', the below value defines accepted IP Addresses from Headless Clients.
<br> the below value defines accepted IP Addresses from Headless Clients.  
 
<br>Multiple Connections and Addresses are allowed in the case of more than one Headless Client
Multiple Connections and Addresses are allowed in the case of more than one Headless Client
<code>headlessClients[]={"xxx.xxx.xxx.xxx", ...}</code>
<syntaxhighlight lang="cpp">headlessClients[] = { "xxx.xxx.xxx.xxx", ... };</syntaxhighlight>
* Additionally to define clients with ''unlimited'' bandwidth and ''nearly no latency'' you must include theirs IPs in the '''server.cfg''' too
* Additionally to define clients with ''unlimited'' bandwidth and ''nearly no latency'' you must include theirs IPs in the '''server.cfg''' too:
<code>localClient[]={"127.0.0.1", ...}; </code>
<syntaxhighlight lang="cpp">localClient[] = { "127.0.0.1", ... };</syntaxhighlight>


* Missions need to be changed a little to support headless clients:
* Missions need to be changed a little to support headless clients:
Line 16: Line 20:
* next sections will show you how to use Headless Client
* next sections will show you how to use Headless Client


=Prerequisites=
 
== Prerequisites ==
 
* read these tutorials (at least the first one):
* read these tutorials (at least the first one):
** [https://www.dropbox.com/s/1n5a8entg3hvj5z/A3_hc_tutorial.pdf?dl=0 HC Guide by Monsoon]
** [https://www.dropbox.com/s/1n5a8entg3hvj5z/A3_hc_tutorial.pdf?dl=0 HC Guide by Monsoon]
** [http://forums.bistudio.com/showthread.php?146708-A-comprehensive-guide-to-creating-a-headless-client-compatible-mission  BIS Forum HC Guide]
** [http://forums.bistudio.com/showthread.php?146708-A-comprehensive-guide-to-creating-a-headless-client-compatible-mission  BIS Forum HC Guide]


=Spawning the AI=
 
== Spawning the AI ==
 
# Add a '''Headless Client''' entity to the mission:
# Add a '''Headless Client''' entity to the mission:
## Add a player unit
## Add a player unit
## Then you can insert a Headless Client unit:<code>SIDE: '''Game Logic''', CLASS: '''Virtual Entities''', UNIT: '''Headless Client''', CONTROL: '''Playable''', NAME: ''somename''</code>
## Then you can insert a Headless Client unit: <code>SIDE: '''Game Logic''', CLASS: '''Virtual Entities''', UNIT: '''Headless Client''', CONTROL: '''Playable''', NAME: ''somename''</code>
## Don't forget to set NAME property as the name can be used to identify Headless Clients in scripts (by checking it against [[player]])
## Don't forget to set NAME property as the name can be used to identify Headless Clients in scripts (by checking it against [[player]])
## Each Headless Client unit will add one Headless Client slot - missions may contain multiple Headless Client units
## Each Headless Client unit will add one Headless Client slot - missions may contain multiple Headless Client units
Line 30: Line 38:
#;Execute the script at mission start
#;Execute the script at mission start
#*This method will make your mission spawn the AI '''only if''' a Headless Client is present. However it is the most simple to set up.
#*This method will make your mission spawn the AI '''only if''' a Headless Client is present. However it is the most simple to set up.
##Add the following to  the beginning of init.sqf:<br/><code>if (!hasInterface && !isServer) then {<br /> execVM "init_HC.sqf";<br />};</code>
##Add the following to  the beginning of init.sqf:<br><code>[[if]] (![[hasInterface]] && ![[isServer]]) [[then]]<br>{<br> [[execVM]] "init_HC.sqf";<br>};</code>
#;Execute the script via a mission parameter
#;Execute the script via a mission parameter
#*If you intend to share your mission this method is more desirable as it means players do not need a Headless Client to play it.
#*If you intend to share your mission this method is more desirable as it means players do not need a Headless Client to play it.
##First define a [[Functions_Library_(Arma_3)|function]] to be used to run the headless client script file. Here's what it should look like in [[description.ext]]:<code>class cfgFunctions<br>{<br>    class myTag<br>    {<br>        class myCategory<br>        {<br>            class myFunction{};<br>        };<br>    };<br>};</code>The reason we want to define a function is because it can be used within the mission parameter framework to execute the AI spawning script as soon as possible while still allowing the mission to reliably work with or without a headless client.
##First define a [[Functions Library (Arma 3)|function]] to be used to run the headless client script file. Here's what it should look like in [[description.ext]]: <syntaxhighlight lang="cpp">
##Add the following code to your function:<code>if ((_this select 0) == 1) then {<br>   // Run on the HC only<br>   if !(isServer or hasInterface) then {<br>       execVM "init_HC.sqf";<br>   };<br>} else {<br>   // Run on the server only<br>   if isServer then {<br>       execVM "init_HC.sqf";<br>   };<br>};</code>This code will be passed the value of the mission parameter defined in the next step, which is where the magic variable _this comes from. It executes the AI spawning script based on the value of the parameter and whether the local machine is the server or a headless client.
class cfgFunctions
##Finally define a [[Arma_3_Mission_Parameters|mission parameter]] that players can use to enable/disable use of the headless client. Here's what it should look like in [[description.ext]]:<code>class params<br>{<br>    class headlessClient<br>    {<br>        title="Headless Client"<br>        texts[]={"Disabled","Enabled"};<br>        values[]={0,1};<br>        default=0;<br>        function="myTag_fnc_myFunction";<br>        isGlobal=1;<br>    };<br>};</code>The two important values here are "function" and "isGlobal". The function value must correspond to the name of the function defined in step 1. The isGlobal value must be set to 1 so that the function is ran by all machines. This means that the function is executed on any headless clients as well as the server so that it can decide where it is suitable to execute the AI spawning script (based on the value of the parameter).  
{
class myTag
{
class myCategory
{
class myFunction {};
};
};
};</syntaxhighlight>The reason we want to define a function is because it can be used within the mission parameter framework to execute the AI spawning script as soon as possible while still allowing the mission to reliably work with or without a headless client.
##Add the following code to your function: <code>[[if]] (([[_this]] [[select]] 0) == 1) [[then]]<br>{ {{codecomment|// Run on the HC only}}<br> [[if]] !([[isServer]] [[or]] [[hasInterface]]) [[then]]<br> {<br> [[execVM]] "init_HC.sqf";<br> };<br>} [[else]] {<br> {{codecomment|// Run on the server only}}<br> [[if]] ([[isServer]]) [[then]]<br> {<br> [[execVM]] "init_HC.sqf";<br> };<br>};</code>This code will be passed the value of the mission parameter defined in the next step, which is where the magic variable _this comes from. It executes the AI spawning script based on the value of the parameter and whether the local machine is the server or a headless client.
##Finally define a [[Arma 3 Mission Parameters|mission parameter]] that players can use to enable/disable use of the headless client. Here's what it should look like in [[description.ext]]: <syntaxhighlight lang="cpp">
class params
{
class headlessClient
{
title = "Headless Client";
texts[] = {"Disabled","Enabled"};
values[] = {0, 1};
default = 0;
function = "myTag_fnc_myFunction";
isGlobal = 1;
};
};
</syntaxhighlight>
The two important values here are "function" and "isGlobal". The function value must correspond to the name of the function defined in step 1. The isGlobal value must be set to 1 so that the function is ran by all machines. This means that the function is executed on any headless clients as well as the server so that it can decide where it is suitable to execute the AI spawning script (based on the value of the parameter).  
# Repeat step 1 for the amount of Headless Clients your mission is designed to use. For multiple you must use the NAME property from step 1 to identify them individually within init_HC.sqf
# Repeat step 1 for the amount of Headless Clients your mission is designed to use. For multiple you must use the NAME property from step 1 to identify them individually within init_HC.sqf


=Server=
 
# add headless client IP address into server.cfg (you can use more than one address):<code>headlessClients[]={"xxx.xxx.xxx.xxx", "xxx.xxx.xxx.xxx", "xxx.xxx.xxx.xxx"}</code>
== Server ==
 
# add headless client IP address into server.cfg (you can use more than one address):<syntaxhighlight lang="cpp">headlessClients[] = { "xxx.xxx.xxx.xxx", "xxx.xxx.xxx.xxx", "xxx.xxx.xxx.xxx" };</syntaxhighlight>
# to run Arma3 Dedicated Server use one of these commands:<code>Windows: arma3server.exe -config=server.cfg<br />Windows: arma3.exe -server -config=server.cfg<br />Linux: arma3server -config=server.cfg</code>
# to run Arma3 Dedicated Server use one of these commands:<code>Windows: arma3server.exe -config=server.cfg<br />Windows: arma3.exe -server -config=server.cfg<br />Linux: arma3server -config=server.cfg</code>


=Headless Client=
 
== Headless Client ==
 
# to run Arma3 Headless Client use one of these commands:<code>Windows: arma3server.exe -client -connect=xxx.xxx.xxx.xxx -password=yourpass<br />Windows: arma3.exe -client -connect=xxx.xxx.xxx.xxx -password=yourpass<br />Linux: arma3server -client -connect=xxx.xxx.xxx.xxx -password=yourpass</code>
# to run Arma3 Headless Client use one of these commands:<code>Windows: arma3server.exe -client -connect=xxx.xxx.xxx.xxx -password=yourpass<br />Windows: arma3.exe -client -connect=xxx.xxx.xxx.xxx -password=yourpass<br />Linux: arma3server -client -connect=xxx.xxx.xxx.xxx -password=yourpass</code>
# your client will be automatically connected to a free headless client slot
# your client will be automatically connected to a free headless client slot
# you can run arbitrary number of headless clients on the same machine
# you can run arbitrary number of headless clients on the same machine


=Overview of running options=
 
== Overview of running options ==
 
* Main game executable (windows only)<code>arma3.exe<br />arma3.exe -server<br />arma3.exe -client</code>
* Main game executable (windows only)<code>arma3.exe<br />arma3.exe -server<br />arma3.exe -client</code>
* Windows server executable<code>arma3server.exe<br />arma3server.exe -client</code>
* Windows server executable<code>arma3server.exe<br />arma3server.exe -client</code>
* Linux server executable<code>arma3server<br />arma3server -client</code>
* Linux server executable<code>arma3server<br />arma3server -client</code>


=Mods=
 
== Mods ==
 
Headless clients are excluded from signature verification, therefore any mod can be used with the "-mod=" option.
Headless clients are excluded from signature verification, therefore any mod can be used with the "-mod=" option.


"-serverMod=" does not work when used alongside "-client".
"-serverMod=" does not work when used alongside "-client".


=GUI=
 
== GUI ==
 
* Headless clients can be seen in the Role assignment display when creating a MP game
* Headless clients can be seen in the Role assignment display when creating a MP game
** If you are admin (host)
** If you are admin (host)
Line 69: Line 111:
** HCs are listed with other players only if you are admin (map, tasks, kill statistics, ...)
** HCs are listed with other players only if you are admin (map, tasks, kill statistics, ...)


=Known issues=
 
== Known issues ==
 
* what needs to be somewhat tested/determined/improved/changed is disconnect & reconnect of HC and all related to that
* what needs to be somewhat tested/determined/improved/changed is disconnect & reconnect of HC and all related to that


=Feedback=
 
== Feedback ==
 
http://forums.bistudio.com/showthread.php?183918-Dedicated-Client-Headless-Client-feedback-(dev-branch)
http://forums.bistudio.com/showthread.php?183918-Dedicated-Client-Headless-Client-feedback-(dev-branch)


=See Also=
 
*[[server.cfg]]
== See Also ==
 
* [[server.cfg]]


[[Category:Arma 3: Tutorials]]
[[Category:Arma 3: Tutorials]]
[[Category:Arma 3: Multiplayer]]
[[Category:Arma 3: Multiplayer]]

Revision as of 13:08, 21 June 2019

Template:SideTOC


Headless Client Overview

  • Headless Client is used to offload AI calculations from the server instance
  • Headless Client is integrated into game client and dedicated server executable (WIndows and Linux, use -client parameter)
  • The server doesn't allow arbitrary connections from headless clients if you do not define the headless clients IPs in the server.cfg, the below value defines accepted IP Addresses from Headless Clients.

Multiple Connections and Addresses are allowed in the case of more than one Headless Client

headlessClients[] = { "xxx.xxx.xxx.xxx", ... };
  • Additionally to define clients with unlimited bandwidth and nearly no latency you must include theirs IPs in the server.cfg too:
localClient[] = { "127.0.0.1", ... };
  • Missions need to be changed a little to support headless clients:
    • extract AI to separate AI script
    • edit init.sqf to execute an extracted AI on headless client
    • place headless client unit
  • in scripts the headless clients may be identified by its name, multiple headless clients are supported
  • next sections will show you how to use Headless Client


Prerequisites


Spawning the AI

  1. Add a Headless Client entity to the mission:
    1. Add a player unit
    2. Then you can insert a Headless Client unit: SIDE: Game Logic, CLASS: Virtual Entities, UNIT: Headless Client, CONTROL: Playable, NAME: somename
    3. Don't forget to set NAME property as the name can be used to identify Headless Clients in scripts (by checking it against player)
    4. Each Headless Client unit will add one Headless Client slot - missions may contain multiple Headless Client units
  2. Create a script that will spawn AI (in the examples below we will use "init_HC.sqf"). To execute it on the Headless Client you have the two following options.
    Execute the script at mission start
    • This method will make your mission spawn the AI only if a Headless Client is present. However it is the most simple to set up.
    1. Add the following to the beginning of init.sqf:
      if (!hasInterface && !isServer) then
      {
      execVM "init_HC.sqf";
      };
    Execute the script via a mission parameter
    • If you intend to share your mission this method is more desirable as it means players do not need a Headless Client to play it.
    1. First define a function to be used to run the headless client script file. Here's what it should look like in description.ext:
      class cfgFunctions
      {
      	class myTag
      	{
      		class myCategory
      		{
      			class myFunction {};
      		};
      	};
      };
      
      The reason we want to define a function is because it can be used within the mission parameter framework to execute the AI spawning script as soon as possible while still allowing the mission to reliably work with or without a headless client.
    2. Add the following code to your function: if ((_this select 0) == 1) then
      { // Run on the HC only
      if !(isServer or hasInterface) then
      {
      execVM "init_HC.sqf";
      };
      } else {
      // Run on the server only
      if (isServer) then
      {
      execVM "init_HC.sqf";
      };
      };
      This code will be passed the value of the mission parameter defined in the next step, which is where the magic variable _this comes from. It executes the AI spawning script based on the value of the parameter and whether the local machine is the server or a headless client.
    3. Finally define a mission parameter that players can use to enable/disable use of the headless client. Here's what it should look like in description.ext:
      class params
      {
      	class headlessClient
      	{
      		title = "Headless Client";
      		texts[] = {"Disabled","Enabled"};
      		values[] = {0, 1};
      		default = 0;
      		function = "myTag_fnc_myFunction";
      		isGlobal = 1;
      	};
      };
      

The two important values here are "function" and "isGlobal". The function value must correspond to the name of the function defined in step 1. The isGlobal value must be set to 1 so that the function is ran by all machines. This means that the function is executed on any headless clients as well as the server so that it can decide where it is suitable to execute the AI spawning script (based on the value of the parameter).

  1. Repeat step 1 for the amount of Headless Clients your mission is designed to use. For multiple you must use the NAME property from step 1 to identify them individually within init_HC.sqf


Server

  1. add headless client IP address into server.cfg (you can use more than one address):
    headlessClients[] = { "xxx.xxx.xxx.xxx", "xxx.xxx.xxx.xxx", "xxx.xxx.xxx.xxx" };
    
  2. to run Arma3 Dedicated Server use one of these commands:Windows: arma3server.exe -config=server.cfg
    Windows: arma3.exe -server -config=server.cfg
    Linux: arma3server -config=server.cfg


Headless Client

  1. to run Arma3 Headless Client use one of these commands:Windows: arma3server.exe -client -connect=xxx.xxx.xxx.xxx -password=yourpass
    Windows: arma3.exe -client -connect=xxx.xxx.xxx.xxx -password=yourpass
    Linux: arma3server -client -connect=xxx.xxx.xxx.xxx -password=yourpass
  2. your client will be automatically connected to a free headless client slot
  3. you can run arbitrary number of headless clients on the same machine


Overview of running options

  • Main game executable (windows only)arma3.exe
    arma3.exe -server
    arma3.exe -client
  • Windows server executablearma3server.exe
    arma3server.exe -client
  • Linux server executablearma3server
    arma3server -client


Mods

Headless clients are excluded from signature verification, therefore any mod can be used with the "-mod=" option.

"-serverMod=" does not work when used alongside "-client".


GUI

  • Headless clients can be seen in the Role assignment display when creating a MP game
    • If you are admin (host)
      • You will see HCs listed in the Players list on the right
      • You will see a category called Virtual (it can contain both Zeus and HCs) on the left
      • Note: HCs are automatically assigned to their slots
    • If you are normal player
      • You won't see any HCs anywhere
      • You won't see any Virtual category (if the mission contains Zeus then there will be Zeus category)
  • In-game UI
    • HCs are listed with other players only if you are admin (map, tasks, kill statistics, ...)


Known issues

  • what needs to be somewhat tested/determined/improved/changed is disconnect & reconnect of HC and all related to that


Feedback

http://forums.bistudio.com/showthread.php?183918-Dedicated-Client-Headless-Client-feedback-(dev-branch)


See Also