diff --git a/addons/switchunits/CfgEventHandlers.hpp b/addons/switchunits/CfgEventHandlers.hpp index 47dcd984d1..38f9883743 100644 --- a/addons/switchunits/CfgEventHandlers.hpp +++ b/addons/switchunits/CfgEventHandlers.hpp @@ -5,7 +5,7 @@ class Extended_PreInit_EventHandlers { }; class Extended_PostInit_EventHandlers { - class ADDON { - postInit = QUOTE(call COMPILE_FILE(XEH_postInit) ); - }; + class ADDON { + clientInit = QUOTE( call COMPILE_FILE(XEH_clientInit) ); + }; }; diff --git a/addons/switchunits/XEH_clientInit.sqf b/addons/switchunits/XEH_clientInit.sqf new file mode 100644 index 0000000000..3075d67941 --- /dev/null +++ b/addons/switchunits/XEH_clientInit.sqf @@ -0,0 +1,39 @@ +/* + * Author: bux578 + * Initializes the SwitchUnits pbo. + * + * Arguments: + * None + * + * Return Value: + * None + * + * Example: + * None + * + * Public: No + */ + +#include "script_component.hpp" + +DFUNC(pfhClientInit) = { + + if (GVAR(EnableSwitchUnits)) exitWith { + + private ["_sides"]; + _sides = []; + + if(GVAR(SwitchToWest)) then {_sides pushBack west;}; + if(GVAR(SwitchToEast)) then {_sides pushBack east;}; + if(GVAR(SwitchToIndependent)) then {_sides pushBack independent;}; + if(GVAR(SwitchToCivilian)) then {_sides pushBack civilian;}; + + if (player getVariable ["ACE_CanSwitchUnits", false]) then { + [player, _sides] call FUNC(initPlayer); + }; + + [(_this select 1)] call cba_fnc_removePerFrameHandler; + }; +}; + +[FUNC(pfhClientInit), 0.5, []] call cba_fnc_addPerFrameHandler; diff --git a/addons/switchunits/XEH_postInit.sqf b/addons/switchunits/XEH_postInit.sqf deleted file mode 100644 index 3ce84ef838..0000000000 --- a/addons/switchunits/XEH_postInit.sqf +++ /dev/null @@ -1,27 +0,0 @@ -/* - Author(s): - bux578 -*/ - -#include "script_component.hpp" - -//0 spawn { - -private ["_sides"]; - -//waitUntil {sleep 0.5; AGM_SwitchUnits_EnableSwitchUnits}; - -//_side = [west, east, independent, civilian] select AGM_SwitchUnits_SwitchUnitsAllowedForSide; - -_sides = []; - -if(GVAR(SwitchToWest)) then {_sides pushBack west}; -if(GVAR(SwitchToEast)) then {_sides pushBack east}; -if(GVAR(SwitchToIndependent)) then {_sides pushBack independent}; -if(GVAR(SwitchToCivilian)) then {_sides pushBack civilian}; - -if (player getVariable ["ACE_CanSwitchUnits", false]) then { -[player, _sides] call FUNC(initPlayer); -}; - -//}; diff --git a/addons/switchunits/functions/fnc_addMapFunction.sqf b/addons/switchunits/functions/fnc_addMapFunction.sqf index 1c4e158d80..62a7c42a22 100644 --- a/addons/switchunits/functions/fnc_addMapFunction.sqf +++ b/addons/switchunits/functions/fnc_addMapFunction.sqf @@ -1,19 +1,19 @@ /* - Name: ACE_SwitchUnits_fnc_addMapFunction - - Author(s): - bux578 - - Description: - Adds a mapClick Eventhandler - - Parameters: - 0: OBJECT - unit - 1: ARRAY - sides - - Returns: - VOID -*/ + * Author: bux578 + * Adds a mapClick Eventhandler + * + * Arguments: + * 0: unit + * 1: sides > + * + * Return Value: + * None + * + * Example: + * [_unit, _sides] call FUNC(addMapFunction) + * + * Public: No + */ #include "script_component.hpp" diff --git a/addons/switchunits/functions/fnc_handleMapClick.sqf b/addons/switchunits/functions/fnc_handleMapClick.sqf index bce28963da..3033071984 100644 --- a/addons/switchunits/functions/fnc_handleMapClick.sqf +++ b/addons/switchunits/functions/fnc_handleMapClick.sqf @@ -1,45 +1,41 @@ /* - Name: ACE_SwitchUnits_fnc_handleMapClick - - Author(s): - bux578 - - Description: - Finds the clicked unit - - Parameters: - 0: OBJECT - MapClickEventHandlerArgs - 0: OBJECT - unit // useless - 1: ARRAY - sides - - Returns: - VOID -*/ + * Author: bux578 + * Switches to a unit close to a clicked map position + * + * Arguments: + * 0: unit + * 1: sides > + * + * Return Value: + * None + * + * Example: + * [_unit, _sides] call FUNC(handleMapClick) + * + * Public: No + */ #include "script_component.hpp" private ["_sides", "_pos", "_sideNearest"]; -// that's wrong -//_currentPlayerUnit = (_this select 0) select 0; - _sides = (_this select 0) select 1; _pos = _this select 1; _sideNearest = []; { - if ([_x] call FUNC(isValidAi) && (side group _x in _sides)) then { - _sideNearest pushBack _x; - }; + if ([_x] call FUNC(isValidAi) && (side group _x in _sides)) then { + _sideNearest pushBack _x; + }; } forEach (nearestObjects [_pos, ["Man"], 20]); if (count _sideNearest > 0) then { - private ["_switchUnit"]; - - _switchUnit = _sideNearest select 0; - [ACE_player, _switchUnit] call FUNC(switchUnit); - - openMap false; + private ["_switchUnit"]; + + _switchUnit = _sideNearest select 0; + [ACE_player, _switchUnit] call FUNC(switchUnit); + + openMap false; }; diff --git a/addons/switchunits/functions/fnc_initPlayer.sqf b/addons/switchunits/functions/fnc_initPlayer.sqf index 81e4fc259f..9c71f8cefc 100644 --- a/addons/switchunits/functions/fnc_initPlayer.sqf +++ b/addons/switchunits/functions/fnc_initPlayer.sqf @@ -1,19 +1,19 @@ /* - Name: ACE_SwitchUnits_fnc_initPlayer - - Author(s): - bux578 - - Description: - Initializes the player - - Parameters: - 0: OBJECT - player - 1: ARRAY - Array containing selected sides - - Returns: - VOID -*/ + * Author: bux578 + * Initializes the player + * + * Arguments: + * 0: player + * 1: sides > + * + * Return Value: + * None + * + * Example: + * [_player, _sides] call FUNC(initPlayer) + * + * Public: No + */ #include "script_component.hpp" @@ -24,27 +24,28 @@ _sides = _this select 1; if (vehicle _playerUnit == _playerUnit) then { - [_sides] call FUNC(markAiOnMap); + [_sides] call FUNC(markAiOnMap); - _playerUnit setVariable [QGVAR(IsPlayerUnit), true]; - _playerUnit allowDamage false; + _playerUnit setVariable [QGVAR(IsPlayerUnit), true]; + _playerUnit allowDamage false; - GVAR(OriginalUnit) = _playerUnit; - GVAR(OriginalName) = [_playerUnit] call EFUNC(common,getName); - GVAR(OriginalGroup) = group _playerUnit; + GVAR(OriginalUnit) = _playerUnit; + //GVAR(OriginalName) = [_playerUnit] call EFUNC(common,getName); + GVAR(OriginalName) = name _playerUnit; + GVAR(OriginalGroup) = group _playerUnit; - // remove all starting gear of a player - removeAllWeapons _playerUnit; - removeGoggles _playerUnit; - removeHeadgear _playerUnit; - removeVest _playerUnit; - removeAllAssignedItems _playerUnit; - clearAllItemsFromBackpack _playerUnit; - removeBackpack _playerUnit; - _playerUnit linkItem "ItemMap"; - removeUniform _playerUnit; + // remove all starting gear of a player + removeAllWeapons _playerUnit; + removeGoggles _playerUnit; + removeHeadgear _playerUnit; + removeVest _playerUnit; + removeAllAssignedItems _playerUnit; + clearAllItemsFromBackpack _playerUnit; + removeBackpack _playerUnit; + _playerUnit linkItem "ItemMap"; + removeUniform _playerUnit; - [_playerUnit, "ACE_SwitchUnits", true] call EFUNC(common,setForceWalkStatus); + [_playerUnit, "ACE_SwitchUnits", true] call EFUNC(common,setForceWalkStatus); - [_playerUnit, _sides] call FUNC(addMapFunction); + [_playerUnit, _sides] call FUNC(addMapFunction); }; diff --git a/addons/switchunits/functions/fnc_isValidAi.sqf b/addons/switchunits/functions/fnc_isValidAi.sqf index 5beb59d430..61c2401da9 100644 --- a/addons/switchunits/functions/fnc_isValidAi.sqf +++ b/addons/switchunits/functions/fnc_isValidAi.sqf @@ -1,22 +1,22 @@ /* - Name: ACE_SwitchUnits_fnc_isValidAi - - Author(s): - bux578 - - Description: - Checks if AI is a valid target for switching - - Parameters: - 0: OBJECT - unit - - Returns: - VOID -*/ + * Author: bux578 + * Checks if AI is a valid target for switching. + * + * Arguments: + * 0: unit + * + * Return Value: + * Boolean + * + * Example: + * [_unit] call FUNC(isValidAi) + * + * Public: Yes + */ #include "script_component.hpp" -private ["_unit"]; +private "_unit"; _unit = _this select 0; diff --git a/addons/switchunits/functions/fnc_markAiOnMap.sqf b/addons/switchunits/functions/fnc_markAiOnMap.sqf index e54673c1a5..ed94c31b0b 100644 --- a/addons/switchunits/functions/fnc_markAiOnMap.sqf +++ b/addons/switchunits/functions/fnc_markAiOnMap.sqf @@ -1,69 +1,71 @@ /* - Name: ACE_SwitchUnits_fnc_markAiOnMap - - Author(s): - bux578 - - Description: - Creates markers for AI units for given sides - Marks players in a different color - - Parameters: - 0: OBJECT - side - - Returns: - VOID -*/ + * Author: bux578 + * Creates markers for AI units for given sides. + * Marks players in a different colour. + * + * Arguments: + * 0: side + * + * Return Value: + * None + * + * Example: + * [[west, east]] call FUNC(markAiOnMap) + * + * Public: No + */ #include "script_component.hpp" -private ["_sidesToShow"]; +private "_sidesToShow"; _sidesToShow = _this select 0; -_sidesToShow spawn { +GVAR(AllMarkerNames) = []; - private ["_sides", "_allMarkerNames"]; - _sides = _this; - _allMarkerNames = []; +DFUNC(pfhMarkAiOnMap) = { + private ["_args", "_sides"]; + _args = _this select 0; + _sides = _args select 0; - while { true } do { - sleep 1.5; + + // delete markers + { + deleteMarkerLocal _x; + } forEach GVAR(AllMarkerNames); - // delete markers + if (alive ACE_player && {GVAR(OriginalUnit) getVariable ["ACE_CanSwitchUnits", false]}) then { + + // create markers { - deleteMarkerLocal _x; - } forEach _allMarkerNames; + if (([_x] call FUNC(isValidAi) && (side group _x in _sides)) || (_x getVariable [QGVAR(IsPlayerControlled), false])) then { + private ["_markerName", "_marker", "_markerColor"]; + + hint format ["marker. %1", time]; - if (alive ACE_player && {GVAR(OriginalUnit) getVariable ["ACE_CanSwitchUnits", false]}) then { + //_markerName = format ["%1", [_x] call EFUNC(common,getName)]; + _markerName = str _x; - // create markers - { - if (([_x] call FUNC(isValidAi) && (side group _x in _sides)) || (_x getVariable [QGVAR(IsPlayerControlled), false])) then { - private ["_markerName", "_marker", "_markerColor"]; + _marker = createMarkerLocal [_markerName, position _x]; + _markerName setMarkerTypeLocal "mil_triangle"; + _markerName setMarkerShapeLocal "ICON"; + _markerName setMarkerSizeLocal [0.5,0.7]; + _markerName setMarkerDirLocal getDir _x; - //_markerName = format ["%1", [_x] call EFUNC(common,getName)]; - _markerName = str _x; + // commy's one liner magic + _markerColor = format ["Color%1", side group _x]; - _marker = createMarkerLocal [_markerName, position _x]; - _markerName setMarkerTypeLocal "mil_triangle"; - _markerName setMarkerShapeLocal "ICON"; - _markerName setMarkerSizeLocal [0.5,0.7]; - _markerName setMarkerDirLocal getDir _x; - - // commy's one liner magic - _markerColor = format ["Color%1", side group _x]; - - if ((_x getVariable [QGVAR(IsPlayerControlled), false])) then { - _markerName setMarkerColorLocal "ColorOrange"; - _markerName setMarkerTextLocal (_x getVariable [QGVAR(PlayerControlledName), ""]); - } else { - _markerName setMarkerColorLocal _markerColor; - _markerName setMarkerTextLocal (getText (configFile >> "CfgVehicles" >> typeOf _x >> "displayName")); - }; - - _allMarkerNames pushBack _markerName; + if ((_x getVariable [QGVAR(IsPlayerControlled), false])) then { + _markerName setMarkerColorLocal "ColorOrange"; + _markerName setMarkerTextLocal (_x getVariable [QGVAR(PlayerControlledName), ""]); + } else { + _markerName setMarkerColorLocal _markerColor; + _markerName setMarkerTextLocal (getText (configFile >> "CfgVehicles" >> typeOf _x >> "displayName")); }; - } forEach allUnits; - }; + + GVAR(AllMarkerNames) pushBack _markerName; + }; + } forEach allUnits; }; }; + +[FUNC(pfhMarkAiOnMap), 1.5, [_sidesToShow]] call CBA_fnc_addPerFrameHandler; diff --git a/addons/switchunits/functions/fnc_module.sqf b/addons/switchunits/functions/fnc_module.sqf index 9a50e5c435..e622a65338 100644 --- a/addons/switchunits/functions/fnc_module.sqf +++ b/addons/switchunits/functions/fnc_module.sqf @@ -1,20 +1,20 @@ /* - Name: ACE_SwitchUnits_fnc_module - - Author(s): - bux578 - - Description: - Initializes the SwitchUnits module - - Parameters: - 0: OBJECT - module logic - 1: ARRAY - list of affected units - 2: BOOLEAN - isActivated - - Returns: - BOOLEAN (Good practice to include one) -*/ + * Author: bux578 + * Initializes the SwitchUnits module + * + * Arguments: + * 0: module logic + * 1: list of affected units > + * 2: isActivated + * + * Return Value: + * None + * + * Example: + * None + * + * Public: No + */ #include "script_component.hpp" @@ -27,8 +27,6 @@ if !(_activated) exitWith {}; GVAR(Module) = true; -[QGVAR(EnableSwitchUnits), true] call EFUNC(common,setParameter); - [_logic, QGVAR(SwitchToWest), "SwitchToWest"] call EFUNC(common,readSettingFromModule); [_logic, QGVAR(SwitchToEast), "SwitchToEast"] call EFUNC(common,readSettingFromModule); [_logic, QGVAR(SwitchToIndependent), "SwitchToIndependent"] call EFUNC(common,readSettingFromModule); @@ -37,4 +35,6 @@ GVAR(Module) = true; [_logic, QGVAR(EnableSafeZone), "EnableSafeZone"] call EFUNC(common,readSettingFromModule); [_logic, QGVAR(SafeZoneRadius), "SafeZoneRadius"] call EFUNC(common,readSettingFromModule); +[QGVAR(EnableSwitchUnits), true, false, true] call EFUNC(common,setSetting); + diag_log text "[ACE]: SwitchUnits Module Initialized."; diff --git a/addons/switchunits/functions/fnc_nearestPlayers.sqf b/addons/switchunits/functions/fnc_nearestPlayers.sqf index 217e1b90e4..b79c54054f 100644 --- a/addons/switchunits/functions/fnc_nearestPlayers.sqf +++ b/addons/switchunits/functions/fnc_nearestPlayers.sqf @@ -1,19 +1,19 @@ /* - Name: ACE_SwitchUnits_fnc_nearestPlayers - - Author(s): - bux578 - - Description: - Returns an array of alive players in a given radius around a given location - - Parameters: - 0: POSTION - Center position - 1: NUMBER - Radius - - Returns: - ARRAY - Player units -*/ + * Author: bux578 + * Returns an array of alive players in a given radius around a given location + * + * Arguments: + * 0: Center position + * 1: Radius + * + * Return Value: + * Player units > + * + * Example: + * [_pos, 100] call FUNC(nearestPlayers) + * + * Public: Yes + */ #include "script_component.hpp" diff --git a/addons/switchunits/functions/fnc_switchBack.sqf b/addons/switchunits/functions/fnc_switchBack.sqf index 6bdc2c8bac..d54713bbe4 100644 --- a/addons/switchunits/functions/fnc_switchBack.sqf +++ b/addons/switchunits/functions/fnc_switchBack.sqf @@ -1,31 +1,41 @@ /* - Name: ACE_SwitchUnits_fnc_switchBack - - Author(s): - bux578 - - Description: - Switches back to the original player unit - This method needs to be "spawn"ed - - Parameters: - 0: OBJECT - original player unit - 1: OBJECT - respawned unit - - Returns: - VOID -*/ + * Author: bux578 + * Switches back to the original player unit + * + * Arguments: + * 0: Original player unit + * 1: Respawned unit + * + * Return Value: + * None + * + * Example: + * [_origPlayer, _respPlayer] call FUNC(switchBack) + * + * Public: Yes + */ #include "script_component.hpp" -private ["_originalPlayerUnit", "_currentUnit"]; -_originalPlayerUnit = _this select 0; -_currentUnit = _this select 1; +private ["_origPlayerUnit"]; -[_originalPlayerUnit] joinSilent GVAR(OriginalGroup); +_origPlayerUnit = _this select 0; +[_origPlayerUnit] joinSilent GVAR(OriginalGroup); -waitUntil {local _originalPlayerUnit}; +DFUNC(pfhSwitchBack) = { + + private ["_args", "_originalPlayerUnit", "_currentUnit"]; + + _args = _this select 0; + + _originalPlayerUnit = _args select 0; + _currentUnit = _args select 1; -selectPlayer _originalPlayerUnit; + if (local _originalPlayerUnit) exitWith { + selectPlayer _originalPlayerUnit; + deleteVehicle _currentUnit; + [(_this select 1)] call cba_fnc_removePerFrameHandler; + }; +}; -deleteVehicle _currentUnit; +[FUNC(pfhSwitchBack), 0.2, _this] call CBA_fnc_addPerFrameHandler; diff --git a/addons/switchunits/functions/fnc_switchUnit.sqf b/addons/switchunits/functions/fnc_switchUnit.sqf index efe3cef901..abd053ffae 100644 --- a/addons/switchunits/functions/fnc_switchUnit.sqf +++ b/addons/switchunits/functions/fnc_switchUnit.sqf @@ -1,81 +1,98 @@ /* - Name: ACE_SwitchUnits_fnc_switchUnit - - Author(s): - bux578 - - Description: - Selects the new given player unit - - Parameters: - 0: OBJECT - the unit to switch to - - Returns: - VOID -*/ + * Author: bux578 + * Switches to the new given player unit + * + * Arguments: + * 0: current unit + * 1: the unit to switch to + * + * Return Value: + * None + * + * Example: + * [_unit] call FUNC(switchUnit) + * + * Public: Yes + */ + #include "script_component.hpp" -private ["_newUnit"]; +private ["_unit", "_allNearestPlayers", "_oldUnit", "_leave"]; -_newUnit = _this select 1; +_unit = _this select 1; // don't switch to original player units -if (!([_newUnit] call FUNC(isValidAi))) exitWith {}; +if (!([_unit] call FUNC(isValidAi))) exitWith {}; + +// exit var +_leave = false; + +if (GVAR(EnableSafeZone)) then { -_newUnit spawn { - private ["_unit", "_allNearestPlayers", "_oldUnit", "_respawnEhId", "_oldOwner", "_leave"]; - - _unit = _this; - - _leave = false; - - if (GVAR(EnableSafeZone)) then { - _allNearestPlayers = [position _unit, GVAR(SafeZoneRadius)] call FUNC(nearestPlayers); _nearestEnemyPlayers = [_allNearestPlayers, {((side GVAR(OriginalGroup)) getFriend (side _this) < 0.6) && !(_this getVariable [QGVAR(IsPlayerControlled), false])}] call EFUNC(common,filter); if (count _nearestEnemyPlayers > 0) exitWith { - _leave = true; + _leave = true; }; - }; - - // exitWith doesn't exit past the "if(EnableSafeZone)" block - if (_leave) exitWith { - [localize "STR_ACE_SwitchUnits_TooCloseToEnemy"] call EFUNC(common,displayTextStructured); - }; - - // should switch locality - // This doesn't work anymore, because one's now able to switch to units from a different side - //[_unit] joinSilent group player; - [[_unit, player], QUOTE({(_this select 0) setVariable [ARR_3(QUOTE(QGVAR(OriginalOwner)), owner (_this select 0), true)]; (_this select 0) setOwner owner (_this select 1)}), 1] call EFUNC(common,execRemoteFnc); - - _oldUnit = player; - waitUntil {sleep 0.2; local _unit}; - - _oldUnit setVariable [QGVAR(IsPlayerControlled), false, true]; - _oldUnit setVariable [QGVAR(PlayerControlledName), "", true]; - - _respawnEhId = _unit getVariable [QGVAR(RespawnEhId), -1]; - if (_respawnEhId != -1) then { - _oldUnit removeEventHandler ["Respawn", _respawnEhId]; - }; - - selectPlayer _unit; - - _unit setVariable [QGVAR(IsPlayerControlled), true, true]; - _unit setVariable [QGVAR(PlayerControlledName), GVAR(OriginalName), true]; - - _respawnEhId = _unit addEventHandler ["Respawn", { - [GVAR(OriginalUnit), _this select 0] spawn FUNC(switchBack); - }]; - _unit setVariable [QGVAR(RespawnEhId), _respawnEhId, true]; - - // set owner back to original owner - _oldOwner = _oldUnit getVariable[QGVAR(OriginalOwner), -1]; - if (_oldOwner > -1) then { - [[_oldUnit, _oldOwner], QUOTE({(_this select 0) setOwner (_this select 1)}), 1] call EFUNC(common,execRemoteFnc); - }; - - [localize "STR_ACE_SwitchUnits_SwitchedUnit"] call EFUNC(common,displayTextStructured); + }; + +// exitWith doesn't exit past the "if(EnableSafeZone)" block +if (_leave) exitWith { + [localize "STR_ACE_SwitchUnits_TooCloseToEnemy"] call EFUNC(common,displayTextStructured); +}; + +// should switch locality +// This doesn't work anymore, because one's now able to switch to units from a different side +//[_unit] joinSilent group player; +[[_unit, player], QUOTE({(_this select 0) setVariable [ARR_3(QUOTE(QGVAR(OriginalOwner)), owner (_this select 0), true)]; (_this select 0) setOwner owner (_this select 1)}), 1] call EFUNC(common,execRemoteFnc); + +_oldUnit = player; + + +DFUNC(pfhSwitchUnit) = { + + private ["_args", "_unit", "_oldUnit", "_respawnEhId", "_oldOwner"]; + _args = _this select 0; + + _unit = _args select 0; + _oldUnit = _args select 1; + + + + if (local _unit) exitWith { + + _oldUnit setVariable [QGVAR(IsPlayerControlled), false, true]; + _oldUnit setVariable [QGVAR(PlayerControlledName), "", true]; + + _respawnEhId = _unit getVariable [QGVAR(RespawnEhId), -1]; + if (_respawnEhId != -1) then { + _oldUnit removeEventHandler ["Respawn", _respawnEhId]; + }; + + selectPlayer _unit; + + _unit setVariable [QGVAR(IsPlayerControlled), true, true]; + _unit setVariable [QGVAR(PlayerControlledName), GVAR(OriginalName), true]; + + _respawnEhId = _unit addEventHandler ["Respawn", { + [GVAR(OriginalUnit), _this select 0] call FUNC(switchBack); + }]; + _unit setVariable [QGVAR(RespawnEhId), _respawnEhId, true]; + + // set owner back to original owner + _oldOwner = _oldUnit getVariable[QGVAR(OriginalOwner), -1]; + if (_oldOwner > -1) then { + [[_oldUnit, _oldOwner], QUOTE({(_this select 0) setOwner (_this select 1)}), 1] call EFUNC(common,execRemoteFnc); + }; + + [localize "STR_ACE_SwitchUnits_SwitchedUnit"] call EFUNC(common,displayTextStructured); + + [(_this select 1)] call cba_fnc_removePerFrameHandler; + + }; +}; + +[FUNC(pfhSwitchUnit), 0.2, [_unit, _oldUnit]] call cba_fnc_addPerFrameHandler;