diff --git a/addons/headless/XEH_postInit.sqf b/addons/headless/XEH_postInit.sqf index 63c7fd5038d..d1c76a332bd 100644 --- a/addons/headless/XEH_postInit.sqf +++ b/addons/headless/XEH_postInit.sqf @@ -1,12 +1,12 @@ #include "script_component.hpp" -["ace_settingsInitialized", { +["CBA_settingsInitialized", { // Register and remove HCs if not client that is not server and distribution or end mission enabled if ((!hasInterface || isServer) && {XGVAR(enabled) || XGVAR(endMission) != 0}) then { if (isServer) then { // Request rebalance on any unit spawn (only if distribution enabled) if (XGVAR(enabled)) then { - ["AllVehicles", "initPost", LINKFUNC(handleSpawn), nil, nil, true] call CBA_fnc_addClassEventHandler; + ["CAManBase", "initPost", LINKFUNC(handleSpawn), nil, nil, true] call CBA_fnc_addClassEventHandler; }; // Add disconnect EH addMissionEventHandler ["HandleDisconnect", {call FUNC(handleDisconnect)}]; diff --git a/addons/headless/XEH_preInit.sqf b/addons/headless/XEH_preInit.sqf index d3b2c8ff5cf..c51b62cf578 100644 --- a/addons/headless/XEH_preInit.sqf +++ b/addons/headless/XEH_preInit.sqf @@ -12,7 +12,6 @@ if (isServer) then { GVAR(headlessClients) = []; GVAR(inRebalance) = false; GVAR(endMissionCheckDelayed) = false; - GVAR(blacklistType) = [BLACKLIST_UAV]; [QXGVAR(headlessClientJoined), LINKFUNC(handleConnectHC)] call CBA_fnc_addEventHandler; }; diff --git a/addons/headless/functions/fnc_handleConnectHC.sqf b/addons/headless/functions/fnc_handleConnectHC.sqf index b19ef250121..e5acaf48fcb 100644 --- a/addons/headless/functions/fnc_handleConnectHC.sqf +++ b/addons/headless/functions/fnc_handleConnectHC.sqf @@ -19,17 +19,14 @@ params ["_headlessClient"]; // Exit if HC already registered // No need to check if distribution or end mission enabled, as if disabled this will never run -if (_headlessClient in GVAR(headlessClients)) exitWith {}; - -// Register for use -GVAR(headlessClients) pushBack _headlessClient; +if (GVAR(headlessClients) pushBackUnique _headlessClient == -1) exitWith {}; if (XGVAR(log)) then { INFO_1("Registered HC: %1",_headlessClient); }; // Exit if AI distribution is disabled -if (!XGVAR(enabled)) exitWith {true}; +if (!XGVAR(enabled)) exitWith {}; // Rebalance [true] call FUNC(rebalance); diff --git a/addons/headless/functions/fnc_handleDisconnect.sqf b/addons/headless/functions/fnc_handleDisconnect.sqf index c94cec2599f..a18f22a3bd3 100644 --- a/addons/headless/functions/fnc_handleDisconnect.sqf +++ b/addons/headless/functions/fnc_handleDisconnect.sqf @@ -17,7 +17,7 @@ */ params ["_object"]; -TRACE_1("HandleDisconnect",_this); +TRACE_1("HandleDisconnect",_object); // Exit if not HC if !(_object in GVAR(headlessClients)) exitWith { @@ -28,9 +28,7 @@ if !(_object in GVAR(headlessClients)) exitWith { if (CBA_missionTime < 150) then { TRACE_1("Mission start delay",CBA_missionTime); GVAR(endMissionCheckDelayed) = true; - [{ - call FUNC(endMissionNoPlayers); - }, [], 150 - CBA_missionTime] call CBA_fnc_waitAndExecute; + [LINKFUNC(endMissionNoPlayers), [], 150 - CBA_missionTime] call CBA_fnc_waitAndExecute; } else { // End instantly or after delay if (XGVAR(endMission) == 1) then { @@ -39,7 +37,7 @@ if !(_object in GVAR(headlessClients)) exitWith { } else { TRACE_2("Delayed 60s end",GVAR(endMission),CBA_missionTime); GVAR(endMissionCheckDelayed) = true; - [FUNC(endMissionNoPlayers), [], 60] call CBA_fnc_waitAndExecute; + [LINKFUNC(endMissionNoPlayers), [], 60] call CBA_fnc_waitAndExecute; }; }; }; diff --git a/addons/headless/functions/fnc_handleSpawn.sqf b/addons/headless/functions/fnc_handleSpawn.sqf index 50277e38456..56b74f407db 100644 --- a/addons/headless/functions/fnc_handleSpawn.sqf +++ b/addons/headless/functions/fnc_handleSpawn.sqf @@ -4,27 +4,22 @@ * Handles AI spawn and requests a rebalance if applicable. * * Arguments: - * 0: Object + * 0: Unit * * Return Value: * None * * Example: - * [object] call ace_headless_fnc_handleSpawn + * [cursorObject] call ace_headless_fnc_handleSpawn * * Public: No */ -params ["_object"]; -TRACE_1("Spawn",_object); +params ["_unit"]; +TRACE_1("Spawn",_unit); -// Exit if HC transferring disabled or object not a unit (including unit inside vehicle) or is player -if (!(_object in allUnits) || {isPlayer _object}) exitWith {}; - -// Exit and blacklist if of blacklist type -if ({_object isKindOf _x} count GVAR(blacklistType) > 0) exitWith { - _object setVariable [QXGVAR(blacklist), true]; -}; +// Exit if unit is player or UAV crew +if (isPlayer _unit || {unitIsUAV _unit}) exitWith {}; // Rebalance [false] call FUNC(rebalance); diff --git a/addons/headless/functions/fnc_rebalance.sqf b/addons/headless/functions/fnc_rebalance.sqf index 84be441ebe8..5ec32f39bd8 100644 --- a/addons/headless/functions/fnc_rebalance.sqf +++ b/addons/headless/functions/fnc_rebalance.sqf @@ -23,7 +23,7 @@ TRACE_3("Rebalance",GVAR(inRebalance),GVAR(headlessClients),_force); if (GVAR(inRebalance) || {GVAR(headlessClients) isEqualTo []}) exitWith {}; // Transfer after rebalance delay -[FUNC(transferGroups), [_force], XGVAR(Delay)] call CBA_fnc_waitAndExecute; +[LINKFUNC(transferGroups), _force, XGVAR(delay)] call CBA_fnc_waitAndExecute; // Currently in rebalance flag GVAR(inRebalance) = true; diff --git a/addons/headless/functions/fnc_transferGroups.sqf b/addons/headless/functions/fnc_transferGroups.sqf index 37580c4fff9..60d3c093d11 100644 --- a/addons/headless/functions/fnc_transferGroups.sqf +++ b/addons/headless/functions/fnc_transferGroups.sqf @@ -79,8 +79,8 @@ private _numTransferredHC3 = 0; _transfer = false; }; - // No transfer if player in this group - if (isPlayer _x) exitWith { + // No transfer if player or UAV in this group + if (isPlayer _x || {unitIsUAV _x}) exitWith { _transfer = false; }; @@ -89,14 +89,16 @@ private _numTransferredHC3 = 0; _transfer = false; }; - // No transfer if vehicle unit is in or crew in that vehicle is blacklisted - if (vehicle _x != _x && {(vehicle _x) getVariable [QXGVAR(blacklist), false]}) exitWith { + private _vehicle = objectParent _x; + + // No transfer if the vehicle the unit is in or if the crew in that vehicle is blacklisted + if ((_vehicle getVariable [QXGVAR(blacklist), false]) || {unitIsUAV _vehicle}) exitWith { _transfer = false; }; // Save gear if unit about to be transferred with current loadout (naked unit work-around) if (XGVAR(transferLoadout) == 1) then { - _x setVariable [QGVAR(loadout), [_x] call CBA_fnc_getLoadout, true]; + _x setVariable [QGVAR(loadout), _x call CBA_fnc_getLoadout, true]; }; } forEach (units _x); }; diff --git a/addons/headless/initSettings.inc.sqf b/addons/headless/initSettings.inc.sqf index cb5fe6e53d7..d00cb6eb307 100644 --- a/addons/headless/initSettings.inc.sqf +++ b/addons/headless/initSettings.inc.sqf @@ -4,7 +4,7 @@ [ELSTRING(common,Enabled), LSTRING(EnabledDesc)], format ["ACE %1", LLSTRING(Module)], false, - true, + 1, {[QGVAR(enabled), _this] call EFUNC(common,cbaSettings_settingChanged)}, true ] call CBA_fnc_addSetting; @@ -15,9 +15,8 @@ [LSTRING(Delay), LSTRING(DelayDesc)], format ["ACE %1", LLSTRING(Module)], [0, 60, 15, -1], - true, - {[QGVAR(delay), _this] call EFUNC(common,cbaSettings_settingChanged)}, - true + 1, + {[QGVAR(delay), _this] call EFUNC(common,cbaSettings_settingChanged)} ] call CBA_fnc_addSetting; [ @@ -26,7 +25,7 @@ [LSTRING(EndMission), LSTRING(EndMissionDesc)], format ["ACE %1", LLSTRING(Module)], [[0, 1, 2], [ELSTRING(Common,Disabled), LSTRING(Instant), LSTRING(Delayed)], 0], - true, + 1, {[QGVAR(delay), _this] call EFUNC(common,cbaSettings_settingChanged)}, true ] call CBA_fnc_addSetting; @@ -37,9 +36,8 @@ [LSTRING(Log), LSTRING(LogDesc)], format ["ACE %1", LLSTRING(Module)], false, - true, - {[QGVAR(enabled), _this] call EFUNC(common,cbaSettings_settingChanged)}, - true + 1, + {[QGVAR(enabled), _this] call EFUNC(common,cbaSettings_settingChanged)} ] call CBA_fnc_addSetting; [ @@ -48,7 +46,7 @@ [LSTRING(TransferLoadout), LSTRING(TransferLoadoutDesc)], format ["ACE %1", LLSTRING(Module)], [[0, 1, 2], [ELSTRING(Common,Disabled), LSTRING(TransferLoadoutCurrent), LSTRING(TransferLoadoutConfig)], 0], - true, + 1, {}, true // needs mission restart ] call CBA_fnc_addSetting; diff --git a/addons/headless/script_component.hpp b/addons/headless/script_component.hpp index c73e2260dee..73761a7bb16 100644 --- a/addons/headless/script_component.hpp +++ b/addons/headless/script_component.hpp @@ -17,4 +17,3 @@ #include "\z\ace\addons\main\script_macros.hpp" #define DELAY_DEFAULT 15 -#define BLACKLIST_UAV "UAV", "UAV_AI_base_F", "B_UAV_AI", "O_UAV_AI", "I_UAV_AI"