Headless Client – Arma 3
Jump to navigation
Jump to search
Dazhbog bi (talk | contribs) |
SilentSpike (talk | contribs) (→Spawning the AI: - Added descriptions to the code, also note about multiple HC) |
||
Line 25: | Line 25: | ||
## 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 | ||
# 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. | # 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. | ||
#* Note that both options below are designed for use with a single Headless Client. If you intend to use multiple then the same basic ideas apply, but you will have to modify the code to suit your needs. | |||
#;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. | ||
Line 32: | Line 33: | ||
#*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. | #*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. | ||
##Set up a [[Functions_Library_(Arma_3)|function]] with the postInit attribute set to 1. (We must do this postInit since public variables don't work preInit and [[Event Scripts]] are ran in the scheduled environment which is subject to delay). | ##Set up a [[Functions_Library_(Arma_3)|function]] with the postInit attribute set to 1. (We must do this postInit since public variables don't work preInit and [[Event Scripts]] are ran in the scheduled environment which is subject to delay). | ||
##Add the following to the function: | ##Add the following to the function:<code>if !(hasInterface or isServer) then {<br> HeadlessVariable = true;<br> publicVariable "HeadlessVariable";<br> execVM "init_HC.sqf";<br>};</code>The code block above will run only on a Headless Client and it first sends out a variable so that other machines (most importantly the server) can detect the Headless Client's presence. After doing so the AI spawning script is immediately executed since the Headless Client doesn't need to do anything else. | ||
##Add the following to the beginning of init.sqf: | ##Add the following to the beginning of init.sqf:<code>if (isServer) then {<br> if (isNil "HeadlessVariable") then {<br> execVM "init_HC.sqf";<br> };<br>};</code>The above code block runs only on the server and it first checks if a Headless Client is present. Only if a Headless Client isn't present does the server execute the AI spawning script. | ||
=Server= | =Server= |
Revision as of 22:20, 6 December 2014
Headless Client Overview
- Headless Client is used to offload AI calculations from the server
- 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", ...}
- 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
- read these tutorials (at least the first one):
Spawning the AI
- Add a Headless Client entity to the mission:
- Add a player unit
- Then you can insert a Headless Client unit:
SIDE: Game Logic, CLASS: Virtual Entities, UNIT: Headless Client, CONTROL: Playable, NAME: somename
- Don't forget to set NAME property as the name can be used to identify headless client in scripts
- Each Headless Client unit will add one headless client slot - missions may contain multiple Headless Client units
- 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.
- Note that both options below are designed for use with a single Headless Client. If you intend to use multiple then the same basic ideas apply, but you will have to modify the code to suit your needs.
- 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.
- Add the following to the beginning of init.sqf:
if (player == hc) then {
execVM "init_HC.sqf";
}; - 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.
- Set up a function with the postInit attribute set to 1. (We must do this postInit since public variables don't work preInit and Event Scripts are ran in the scheduled environment which is subject to delay).
- Add the following to the function:
if !(hasInterface or isServer) then {
The code block above will run only on a Headless Client and it first sends out a variable so that other machines (most importantly the server) can detect the Headless Client's presence. After doing so the AI spawning script is immediately executed since the Headless Client doesn't need to do anything else.
HeadlessVariable = true;
publicVariable "HeadlessVariable";
execVM "init_HC.sqf";
}; - Add the following to the beginning of init.sqf:
if (isServer) then {
The above code block runs only on the server and it first checks if a Headless Client is present. Only if a Headless Client isn't present does the server execute the AI spawning script.
if (isNil "HeadlessVariable") then {
execVM "init_HC.sqf";
};
};
Server
- 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"}
- 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
- 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 - your client will be automatically connected to a free headless client slot
- 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 executable
arma3server.exe
arma3server.exe -client - Linux server executable
arma3server
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)
- If you are admin (host)
- 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