This repository has been archived by the owner on May 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 42
Add headless client component #1
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b1ddbff
Add headless client component
thojkooi b354d45
Fix paths in headless component
thojkooi 8ab1b56
Replace EGVAR and EFUNC by full versions
thojkooi b017d1f
Fix incorrect stringtable entry for author
thojkooi 4697221
Fix headless client component port
thojkooi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
z\acex\addons\headless |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
class ACE_Settings { | ||
class GVAR(Enabled) { | ||
value = 0; | ||
typeName = "BOOL"; | ||
displayName = ECSTRING(common,Enabled); | ||
description = CSTRING(EnabledDesc); | ||
}; | ||
class GVAR(Delay) { | ||
value = DELAY_DEFAULT; | ||
typeName = "SCALAR"; | ||
displayName = CSTRING(Delay); | ||
description = CSTRING(DelayDesc); | ||
}; | ||
class GVAR(Log) { | ||
value = 0; | ||
typeName = "BOOL"; | ||
displayName = CSTRING(Log); | ||
description = CSTRING(LogDesc); | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
class Extended_PreInit_EventHandlers { | ||
class ADDON { | ||
init = QUOTE(call COMPILE_FILE(XEH_preInit)); | ||
}; | ||
}; | ||
|
||
class Extended_PostInit_EventHandlers { | ||
class ADDON { | ||
init = QUOTE(call COMPILE_FILE(XEH_postInit)); | ||
}; | ||
}; | ||
|
||
class Extended_InitPost_EventHandlers { | ||
class AllVehicles { | ||
class ADDON { | ||
serverInit = QUOTE(_this call FUNC(handleInitPost)); | ||
}; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
class CfgVehicles { | ||
class ACE_Module; | ||
class GVAR(module): ACE_Module { | ||
author = "STR_ACE_common_ACETeam"; | ||
category = "ACE_missionModules"; | ||
displayName = CSTRING(Module); | ||
function = QFUNC(moduleInit); | ||
scope = 2; | ||
isGlobal = 1; // Global | ||
isTriggerActivated = 0; | ||
isDisposable = 0; | ||
icon = QUOTE(PATHTOF(UI\Icon_Module_Headless_ca.paa)); | ||
class Arguments { | ||
class Enabled { | ||
displayName = ECSTRING(common,Enabled); | ||
description = CSTRING(EnabledDesc); | ||
typeName = "BOOL"; | ||
defaultValue = 0; | ||
}; | ||
class Delay { | ||
displayName = CSTRING(Delay); | ||
description = CSTRING(DelayDesc); | ||
typeName = "NUMBER"; | ||
defaultValue = DELAY_DEFAULT; | ||
}; | ||
class Log { | ||
displayName = CSTRING(Log); | ||
description = CSTRING(LogDesc); | ||
typeName = "BOOL"; | ||
defaultValue = 0; | ||
}; | ||
}; | ||
class ModuleDescription { | ||
description = CSTRING(ModuleDesc); | ||
}; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
acex_headless | ||
============ | ||
|
||
Adds automatic passing of AI groups to (up to 3) Headless Clients. | ||
- Automatic Headless Client recognition | ||
- Event-based transferring (on unit spawn, Headless Client connect and disconnect) | ||
- Round-robin transferring when more than 1 Headless Client is present | ||
- Mission makers can use the following to prevent a group from transferring to a Headless Client: | ||
`this setVariable ["acex_headless_blacklist", true, true];` | ||
|
||
|
||
## Maintainers | ||
|
||
The people responsible for merging changes to this component or answering potential questions. | ||
|
||
- [Jonpas](http://github.com/jonpas) |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include "script_component.hpp" | ||
|
||
// Exit on player clients that are not hosts | ||
if (hasInterface && !isServer) exitWith {}; | ||
|
||
["SettingsInitialized", { | ||
if (isServer) then { | ||
// Add disconnect EH if HC transferring enabled | ||
if (GVAR(Enabled)) then { | ||
addMissionEventHandler ["HandleDisconnect", {_this call FUNC(handleDisconnect)}]; | ||
}; | ||
} else { | ||
// Register HC (this part happens on HC only) | ||
["ACE_HeadlessClientJoined", [player]] call (ace_common_globalEvent); | ||
}; | ||
}] call (ace_common_addEventHandler); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include "script_component.hpp" | ||
|
||
ADDON = false; | ||
|
||
PREP(handleConnectHC); | ||
PREP(handleDisconnect); | ||
PREP(handleInitPost); | ||
PREP(moduleInit); | ||
PREP(rebalance); | ||
PREP(transferGroups); | ||
|
||
if (isServer) then { | ||
GVAR(headlessClients) = []; | ||
GVAR(inRebalance) = false; | ||
["ACE_HeadlessClientJoined", FUNC(handleConnectHC)] call (ace_common_addEventHandler); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
}; | ||
|
||
ADDON = true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include "script_component.hpp" | ||
|
||
class CfgPatches { | ||
class ADDON { | ||
units[] = {}; | ||
weapons[] = {}; | ||
requiredVersion = REQUIRED_VERSION; | ||
requiredAddons[] = {"acex_main"}; | ||
author[]= {"Jonpas"}; | ||
authorUrl = "https://github.com/jonpas"; | ||
VERSION_CONFIG; | ||
}; | ||
}; | ||
|
||
#include "ACE_Settings.hpp" | ||
#include "CfgEventHandlers.hpp" | ||
#include "CfgVehicles.hpp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Author: Jonpas | ||
* Registers connected Headless Client for use. | ||
* | ||
* Arguments: | ||
* 0: Headless Client <OBJECT> | ||
* | ||
* Return Value: | ||
* None | ||
* | ||
* Example: | ||
* [headlessClient] call ace_headless_handleConnectHC; | ||
* | ||
* Public: No | ||
*/ | ||
#include "script_component.hpp" | ||
|
||
params ["_headlessClient"]; | ||
|
||
// Delay until settings are initialized (for checking if HC trasnferring is enabled) | ||
if (!(ace_common_settingsInitFinished)) exitWith { | ||
(ace_common_runAtSettingsInitialized) pushBack [FUNC(handleConnectHC), _this]; | ||
}; | ||
|
||
// Exit if HC transferring disabled or HC already registered | ||
if (!GVAR(Enabled) || {_headlessClient in GVAR(headlessClients)}) exitWith {}; | ||
|
||
// Register for use | ||
GVAR(headlessClients) pushBack _headlessClient; | ||
|
||
if (GVAR(Log)) then { | ||
ACE_LOGINFO_1("Registered HC: %1",_headlessClient); | ||
}; | ||
|
||
// Rebalance | ||
[true] call FUNC(rebalance); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Author: Jonpas | ||
* Removes Headless Client from use. | ||
* | ||
* Arguments: | ||
* 0: Object <OBJECT> | ||
* | ||
* Return Value: | ||
* Transfer To Server <BOOL> | ||
* | ||
* Example: | ||
* [unit] call ace_headless_handleDisconnect; | ||
* | ||
* Public: No | ||
*/ | ||
#include "script_component.hpp" | ||
|
||
params ["_object"]; | ||
|
||
// Exit if not HC | ||
if !(_object in GVAR(headlessClients)) exitWith {}; | ||
|
||
// Remove HC | ||
GVAR(headlessClients) deleteAt (GVAR(headlessClients) find _object); | ||
|
||
if (GVAR(Log)) then { | ||
ACE_LOGINFO_1("Removed HC: %1",_object); | ||
}; | ||
|
||
// Rebalance | ||
[true] call FUNC(rebalance); | ||
|
||
// Prevent transferring of HC to server | ||
false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Author: Jonpas | ||
* Request a rebalance. | ||
* | ||
* Arguments: | ||
* 0: Object <OBJECT> | ||
* | ||
* Return Value: | ||
* None | ||
* | ||
* Example: | ||
* [object] call ace_headless_handleInitPost; | ||
* | ||
* Public: No | ||
*/ | ||
#include "script_component.hpp" | ||
|
||
params ["_object"]; | ||
|
||
TRACE_1("InitPost",_object); | ||
|
||
// Delay until settings are initialized (for checking if HC trasnferring is enabled) | ||
if (!(ace_common_settingsInitFinished)) exitWith { | ||
(ace_common_runAtSettingsInitialized) pushBack [FUNC(handleInitPost), _this]; | ||
}; | ||
|
||
// Exit if HC transferring disabled or object not a unit (including unit inside vehicle) or is player | ||
if (!GVAR(Enabled) || {!(_object in allUnits)} || {isPlayer _object}) exitWith {}; | ||
|
||
// Rebalance | ||
[false] call FUNC(rebalance); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Author: Jonpas | ||
* Initializes the Headless module. | ||
* | ||
* Arguments: | ||
* 0: The module logic <LOGIC> | ||
* 1: Units <ARRAY> (Unused) | ||
* 2: Activated <BOOL> | ||
* | ||
* Return Value: | ||
* None | ||
* | ||
* Public: No | ||
*/ | ||
#include "script_component.hpp" | ||
|
||
if (!isServer) exitWith {}; | ||
|
||
params ["_logic", "", "_activated"]; | ||
|
||
if (!_activated) exitWith {}; | ||
|
||
[_logic, QGVAR(Enabled), "Enabled"] call (ace_common_readSettingFromModule); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
[_logic, QGVAR(Delay), "Delay"] call (ace_common_readSettingFromModule); | ||
[_logic, QGVAR(Log), "Log"] call (ace_common_readSettingFromModule); | ||
|
||
ACE_LOGINFO("Headless Module Initialized."); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Author: Jonpas | ||
* Rebalance AI groups accross HCs. | ||
* | ||
* Arguments: | ||
* 0: Force <BOOL> | ||
* | ||
* Return Value: | ||
* None | ||
* | ||
* Example: | ||
* [false] call ace_headless_rebalance; | ||
* | ||
* Public: No | ||
*/ | ||
#include "script_component.hpp" | ||
|
||
params ["_force"]; | ||
|
||
TRACE_3("Rebalance",GVAR(inRebalance),GVAR(headlessClients),_force); | ||
|
||
// Exit if waiting for rebalance or no HCs present | ||
if (GVAR(inRebalance) || {GVAR(headlessClients) isEqualTo []}) exitWith {}; | ||
|
||
// Transfer after rebalance delay | ||
[FUNC(transferGroups), [_force], GVAR(Delay)] call (ace_common_waitAndExecute); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
// Currently in rebalance flag | ||
GVAR(inRebalance) = true; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ace_common_fnc_globalEvent