2021-10-14 15:46:43 +00:00
|
|
|
#include "script_component.hpp"
|
|
|
|
|
|
|
|
["ace_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 {
|
2021-10-22 13:17:58 +00:00
|
|
|
["AllVehicles", "initPost", FUNC(handleSpawn), nil, nil, true] call CBA_fnc_addClassEventHandler;
|
2021-10-14 15:46:43 +00:00
|
|
|
};
|
|
|
|
// Add disconnect EH
|
|
|
|
addMissionEventHandler ["HandleDisconnect", {call FUNC(handleDisconnect)}];
|
|
|
|
} else {
|
|
|
|
// Register HC (this part happens on HC only)
|
|
|
|
[QXGVAR(headlessClientJoined), [player]] call CBA_fnc_globalEvent; // Global event for API purposes
|
|
|
|
};
|
|
|
|
|
|
|
|
// Transfer loadouts (naked unit work-around)
|
|
|
|
if (XGVAR(transferLoadout) > 0) then {
|
|
|
|
["CAManBase", "Local", {
|
|
|
|
params ["_unit", "_local"];
|
|
|
|
|
|
|
|
// Check if naked unit bug happened
|
|
|
|
if (_local && {uniform _unit == ""}) then {
|
2022-08-25 16:56:54 +00:00
|
|
|
scopeName QGVAR(applyLoadout);
|
2021-10-14 15:46:43 +00:00
|
|
|
INFO_1("Unit [%1] became local with broken loadout - attempting to fix",_unit);
|
|
|
|
if (XGVAR(transferLoadout) == 1) then {
|
|
|
|
// Transferred loadout, if unavailable reset to config default (still better than naked)
|
2022-08-25 16:56:54 +00:00
|
|
|
private _loadout = _unit getVariable [QGVAR(loadout), []];
|
|
|
|
if (_loadout isNotEqualTo []) then {
|
|
|
|
[_unit, _loadout] call CBA_fnc_setLoadout;
|
|
|
|
breakOut QGVAR(applyLoadout);
|
|
|
|
};
|
2021-10-14 15:46:43 +00:00
|
|
|
};
|
2022-08-25 16:56:54 +00:00
|
|
|
// Config default loadout
|
|
|
|
_unit setUnitLoadout (typeOf _unit);
|
2021-10-14 15:46:43 +00:00
|
|
|
};
|
|
|
|
}] call CBA_fnc_addClassEventHandler;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}] call CBA_fnc_addEventHandler;
|