Skip to content
This repository was archived by the owner on May 24, 2022. It is now read-only.

Commit d9ca9b5

Browse files
committed
Merge pull request #1 from acemod/add-headless-component
Add headless client component
2 parents 8ac2baa + 4697221 commit d9ca9b5

18 files changed

+486
-0
lines changed

addons/headless/$PBOPREFIX$

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
z\acex\addons\headless

addons/headless/ACE_Settings.hpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
class ACE_Settings {
2+
class GVAR(Enabled) {
3+
value = 0;
4+
typeName = "BOOL";
5+
displayName = ECSTRING(common,Enabled);
6+
description = CSTRING(EnabledDesc);
7+
};
8+
class GVAR(Delay) {
9+
value = DELAY_DEFAULT;
10+
typeName = "SCALAR";
11+
displayName = CSTRING(Delay);
12+
description = CSTRING(DelayDesc);
13+
};
14+
class GVAR(Log) {
15+
value = 0;
16+
typeName = "BOOL";
17+
displayName = CSTRING(Log);
18+
description = CSTRING(LogDesc);
19+
};
20+
};
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
class Extended_PreInit_EventHandlers {
2+
class ADDON {
3+
init = QUOTE(call COMPILE_FILE(XEH_preInit));
4+
};
5+
};
6+
7+
class Extended_PostInit_EventHandlers {
8+
class ADDON {
9+
init = QUOTE(call COMPILE_FILE(XEH_postInit));
10+
};
11+
};
12+
13+
class Extended_InitPost_EventHandlers {
14+
class AllVehicles {
15+
class ADDON {
16+
serverInit = QUOTE(_this call FUNC(handleInitPost));
17+
};
18+
};
19+
};

addons/headless/CfgVehicles.hpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
class CfgVehicles {
2+
class ACE_Module;
3+
class GVAR(module): ACE_Module {
4+
author = "STR_ACE_common_ACETeam";
5+
category = "ACE_missionModules";
6+
displayName = CSTRING(Module);
7+
function = QFUNC(moduleInit);
8+
scope = 2;
9+
isGlobal = 1; // Global
10+
isTriggerActivated = 0;
11+
isDisposable = 0;
12+
icon = QUOTE(PATHTOF(UI\Icon_Module_Headless_ca.paa));
13+
class Arguments {
14+
class Enabled {
15+
displayName = ECSTRING(common,Enabled);
16+
description = CSTRING(EnabledDesc);
17+
typeName = "BOOL";
18+
defaultValue = 0;
19+
};
20+
class Delay {
21+
displayName = CSTRING(Delay);
22+
description = CSTRING(DelayDesc);
23+
typeName = "NUMBER";
24+
defaultValue = DELAY_DEFAULT;
25+
};
26+
class Log {
27+
displayName = CSTRING(Log);
28+
description = CSTRING(LogDesc);
29+
typeName = "BOOL";
30+
defaultValue = 0;
31+
};
32+
};
33+
class ModuleDescription {
34+
description = CSTRING(ModuleDesc);
35+
};
36+
};
37+
};

addons/headless/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
acex_headless
2+
============
3+
4+
Adds automatic passing of AI groups to (up to 3) Headless Clients.
5+
- Automatic Headless Client recognition
6+
- Event-based transferring (on unit spawn, Headless Client connect and disconnect)
7+
- Round-robin transferring when more than 1 Headless Client is present
8+
- Mission makers can use the following to prevent a group from transferring to a Headless Client:
9+
`this setVariable ["acex_headless_blacklist", true, true];`
10+
11+
12+
## Maintainers
13+
14+
The people responsible for merging changes to this component or answering potential questions.
15+
16+
- [Jonpas](http://github.com/jonpas)
5.49 KB
Binary file not shown.

addons/headless/XEH_postInit.sqf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include "script_component.hpp"
2+
3+
// Exit on player clients that are not hosts
4+
if (hasInterface && !isServer) exitWith {};
5+
6+
["SettingsInitialized", {
7+
if (isServer) then {
8+
// Add disconnect EH if HC transferring enabled
9+
if (GVAR(Enabled)) then {
10+
addMissionEventHandler ["HandleDisconnect", {_this call FUNC(handleDisconnect)}];
11+
};
12+
} else {
13+
// Register HC (this part happens on HC only)
14+
["ACE_HeadlessClientJoined", [player]] call ace_common_fnc_globalEvent;
15+
};
16+
}] call ace_common_fnc_addEventHandler;

addons/headless/XEH_preInit.sqf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include "script_component.hpp"
2+
3+
ADDON = false;
4+
5+
PREP(handleConnectHC);
6+
PREP(handleDisconnect);
7+
PREP(handleInitPost);
8+
PREP(moduleInit);
9+
PREP(rebalance);
10+
PREP(transferGroups);
11+
12+
if (isServer) then {
13+
GVAR(headlessClients) = [];
14+
GVAR(inRebalance) = false;
15+
["ACE_HeadlessClientJoined", FUNC(handleConnectHC)] call ace_common_fnc_addEventHandler;
16+
};
17+
18+
ADDON = true;

addons/headless/config.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include "script_component.hpp"
2+
3+
class CfgPatches {
4+
class ADDON {
5+
units[] = {};
6+
weapons[] = {};
7+
requiredVersion = REQUIRED_VERSION;
8+
requiredAddons[] = {"acex_main"};
9+
author[]= {"Jonpas"};
10+
authorUrl = "https://github.com/jonpas";
11+
VERSION_CONFIG;
12+
};
13+
};
14+
15+
#include "ACE_Settings.hpp"
16+
#include "CfgEventHandlers.hpp"
17+
#include "CfgVehicles.hpp"
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Author: Jonpas
3+
* Registers connected Headless Client for use.
4+
*
5+
* Arguments:
6+
* 0: Headless Client <OBJECT>
7+
*
8+
* Return Value:
9+
* None
10+
*
11+
* Example:
12+
* [headlessClient] call ace_headless_fnc_handleConnectHC;
13+
*
14+
* Public: No
15+
*/
16+
#include "script_component.hpp"
17+
18+
params ["_headlessClient"];
19+
20+
// Delay until settings are initialized (for checking if HC trasnferring is enabled)
21+
if (!(ace_common_settingsInitFinished)) exitWith {
22+
(ace_common_runAtSettingsInitialized) pushBack [FUNC(handleConnectHC), _this];
23+
};
24+
25+
// Exit if HC transferring disabled or HC already registered
26+
if (!GVAR(Enabled) || {_headlessClient in GVAR(headlessClients)}) exitWith {};
27+
28+
// Register for use
29+
GVAR(headlessClients) pushBack _headlessClient;
30+
31+
if (GVAR(Log)) then {
32+
ACE_LOGINFO_1("Registered HC: %1",_headlessClient);
33+
};
34+
35+
// Rebalance
36+
[true] call FUNC(rebalance);

0 commit comments

Comments
 (0)