From 7107514b05944b33ab8b149e5972d2d01c03521e Mon Sep 17 00:00:00 2001 From: SilentSpike Date: Sat, 25 Jul 2015 11:32:42 +0100 Subject: [PATCH] New function to precisely control spectatable sides --- addons/spectator/XEH_preInit.sqf | 2 ++ .../functions/fnc_updateSpectatableSides.sqf | 33 +++++++++++++++++++ .../spectator/functions/fnc_updateUnits.sqf | 2 +- 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 addons/spectator/functions/fnc_updateSpectatableSides.sqf diff --git a/addons/spectator/XEH_preInit.sqf b/addons/spectator/XEH_preInit.sqf index f259f6bbeb..cf6304f99a 100644 --- a/addons/spectator/XEH_preInit.sqf +++ b/addons/spectator/XEH_preInit.sqf @@ -18,11 +18,13 @@ PREP(setSpectator); PREP(transitionCamera); PREP(toggleInterface); PREP(updateCameraModes); +PREP(updateSpectatableSides); PREP(updateUnits); PREP(updateVisionModes); // Permanent variables GVAR(availableModes) = [0,1,2]; +GVAR(availableSides) = [west,east,resistance,civilian]; GVAR(availableVisions) = [-2,-1,0,1]; GVAR(camMode) = 0; diff --git a/addons/spectator/functions/fnc_updateSpectatableSides.sqf b/addons/spectator/functions/fnc_updateSpectatableSides.sqf new file mode 100644 index 0000000000..e4f359b4d1 --- /dev/null +++ b/addons/spectator/functions/fnc_updateSpectatableSides.sqf @@ -0,0 +1,33 @@ +/* + * Author: SilentSpike + * Adds or removes sides from the selection available to spectate by the local player. + * Note that the side filter setting is applied to the available sides dynamically. + * + * Default selection is [west,east,resistance,civilian] + * + * Arguments: + * 0: Sides to add + * 1: Sides to remove + * + * Return Value: + * Spectatable sides + * + * Example: + * [[west], [east,civilian]] call ace_spectator_fnc_updateSpectatableSides + * + * Public: Yes + */ + +#include "script_component.hpp" + +params [["_addSides",[],[[]]], ["_removeSides",[],[[]]]]; + +// Add and remove sides +_addSides append (GVAR(availableSides) - _removeSides); + +// Only need array of unique sides +_addSides arrayIntersect _addSides; + +GVAR(availableSides) = _addSides; + +_addSides diff --git a/addons/spectator/functions/fnc_updateUnits.sqf b/addons/spectator/functions/fnc_updateUnits.sqf index 66c91c37a0..0393fa0e36 100644 --- a/addons/spectator/functions/fnc_updateUnits.sqf +++ b/addons/spectator/functions/fnc_updateUnits.sqf @@ -45,7 +45,7 @@ _cond = [{_this == (side group player)},{(_this getFriend (side group player)) > if (_x call _cond) then { _sides pushBack _x; }; -} forEach [west,east,resistance,civilian]; +} forEach GVAR(availableSides); // Filter units and append to list _filteredUnits = [];