Difference between revisions of "Arma 3 Headless Client"

From Bohemia Interactive Community
Jump to navigation Jump to search
(Prepare mission for Headless Client: Added alternate method of running the script)
m (Preparing a headless client compatible mission: - Fixed error in existing code)
Line 26: Line 26:
 
#;Run the script only on the Headless Client
 
#;Run the script only on the Headless Client
 
#*Note that this method will make your mission spawn the AI '''only if''' the HC is present. However it is the most simple to set up.
 
#*Note that this method will make your mission spawn the AI '''only if''' the HC is present. However it is the most simple to set up.
##Add the following to init.sqf:<br/><code>playerName = name player;<br />if (playerName == "hc") then {<br />  execVM "init_HC.sqf";<br />};</code>
+
##Add the following to init.sqf:<br/><code>if (player == "hc") then {<br />  execVM "init_HC.sqf";<br />};</code>
 
##Replace "hc" with whatever name you gave to your headless client unit
 
##Replace "hc" with whatever name you gave to your headless client unit
 
#;Run the script contextually on the Headless Client or Server
 
#;Run the script contextually on the Headless Client or Server

Revision as of 13:47, 19 November 2014

Headless Client Overview

  • headless client is used to offload AI calculation from server
  • headless client is integrated into game client and dedicated server executable (WIndows and Linux, use -client parameter)
  • server doesn't allow to connect arbitrary headless client because headless clients are not verified on Steam, so server.cfg contains list of allowed headless clients IPs headlessClients[]={"xxx.xxx.xxx.xxx", ...}
  • mission needs 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

Preparing a headless client compatible mission

  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, the name can be used to identify headless client in scripts and it is used to connect the headless client to the proper headless client slot
    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 and run it on the headless client (in the examples below we will use "init_HC.sqf"). Here you have the two following options.
    Run the script only on the Headless Client
    • Note that this method will make your mission spawn the AI only if the HC is present. However it is the most simple to set up.
    1. Add the following to init.sqf:
      if (player == "hc") then {
      execVM "init_HC.sqf";
      };
    2. Replace "hc" with whatever name you gave to your headless client unit
    Run the script contextually on the Headless Client or Server
    • Note that 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. Set up a function with the postInit attribute set to 1. (We must do this postInit since public variables don't work preInit and init.sqf is ran too late for our needs).
    2. Add the following to the function:
      if !(hasInterface or isServer) then {
      HeadlessVariable = true;
      publicVariable "HeadlessVariable";
      execVM "init_HC.sqf";
      };
    3. Add the following to init.sqf:
      if (isServer) then {
      if (isNil "HeadlessVariable") then {
      execVM "init_HC.sqf";
      };
      };
  3. Put packed mission into MPMissions folder

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 -name=hc -password=yourpass
    Windows: arma3.exe -client -connect=xxx.xxx.xxx.xxx -name=hc -password=yourpass
    Linux: arma3server -client -connect=xxx.xxx.xxx.xxx -name=hc -password=yourpass
  2. your client will be automatically connected to the headless client slot with the same name
  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

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

  • Does not support BattlEye yet
  • 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)