2015-07-16 10:15:33 +00:00
|
|
|
/*
|
|
|
|
* Author: SilentSpike
|
2015-07-17 15:02:38 +00:00
|
|
|
* Adds units to spectator whitelist/blacklist and refreshes the filter units
|
2015-07-16 10:15:33 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
2015-07-17 17:40:49 +00:00
|
|
|
* 0: Units to add to the whitelist <ARRAY>
|
2015-07-17 15:02:38 +00:00
|
|
|
* 1: Use blacklist <BOOL> <OPTIONAL>
|
2015-07-16 10:15:33 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None <NIL>
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [allUnits,true] call ace_spectator_fnc_updateUnits
|
|
|
|
*
|
|
|
|
* Public: Yes
|
|
|
|
*/
|
|
|
|
|
2015-07-15 13:58:38 +00:00
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-07-17 15:02:38 +00:00
|
|
|
params [["_newUnits",[],[[]]],["_blacklist",false,[false]]];
|
2015-07-15 13:58:38 +00:00
|
|
|
|
2015-07-17 17:40:49 +00:00
|
|
|
// Function only matter on player clients
|
|
|
|
if !(hasInterface) exitWith {};
|
|
|
|
|
2015-07-17 15:02:38 +00:00
|
|
|
if !(_newUnits isEqualTo []) then {
|
|
|
|
if (_blacklist) then {
|
2015-07-16 10:15:33 +00:00
|
|
|
GVAR(unitWhitelist) = GVAR(unitWhitelist) - _newUnits;
|
|
|
|
GVAR(unitBlacklist) append _newUnits;
|
2015-07-17 15:02:38 +00:00
|
|
|
} else {
|
|
|
|
GVAR(unitBlacklist) = GVAR(unitBlacklist) - _newUnits;
|
|
|
|
GVAR(unitWhitelist) append _newUnits;
|
2015-07-15 13:58:38 +00:00
|
|
|
};
|
2015-07-16 10:15:33 +00:00
|
|
|
};
|
2015-07-15 13:58:38 +00:00
|
|
|
|
2015-07-17 17:40:49 +00:00
|
|
|
// Reset the filter list (removes any units that no longer apply)
|
|
|
|
GVAR(unitList) = [];
|
|
|
|
|
|
|
|
// Unit filter
|
2015-07-17 15:02:38 +00:00
|
|
|
_newUnits = [[],allPlayers,allUnits] select GVAR(filterUnits);
|
2015-07-15 13:58:38 +00:00
|
|
|
|
2015-07-17 17:40:49 +00:00
|
|
|
// Side filter
|
|
|
|
private ["_playerSide","_sides"];
|
|
|
|
_playerSide = side group player;
|
|
|
|
|
|
|
|
if (GVAR(filterSides) == 0) then {
|
|
|
|
_sides = [_playerSide];
|
|
|
|
} else {
|
2015-07-17 23:40:20 +00:00
|
|
|
_sides = [west,east,resistance,civilian];
|
|
|
|
if (GVAR(filterSides) == 1) then {
|
|
|
|
{
|
|
|
|
if ((_x getFriend _playerSide) < 0.6) then {
|
|
|
|
_sides = _sides - [_x];
|
|
|
|
};
|
|
|
|
} forEach _sides;
|
|
|
|
};
|
2015-07-17 17:40:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Filter units and append to list
|
2015-07-17 15:02:38 +00:00
|
|
|
{
|
|
|
|
if (
|
|
|
|
(alive _x) &&
|
|
|
|
{(_x isKindOf "CAManBase")} &&
|
2015-07-17 17:40:49 +00:00
|
|
|
{(side _x) in _sides} && // Side filter
|
2015-07-18 16:13:27 +00:00
|
|
|
{simulationEnabled _x} &&
|
2015-07-17 15:02:38 +00:00
|
|
|
{!(_x getVariable [QGVAR(isSpectator), false])} // Who watches the watchmen?
|
|
|
|
) then {
|
|
|
|
GVAR(unitList) pushBack _x;
|
|
|
|
};
|
|
|
|
} forEach (_newUnits - GVAR(unitBlacklist));
|
2015-07-17 01:30:00 +00:00
|
|
|
|
2015-07-17 15:02:38 +00:00
|
|
|
// Apply whitelist
|
|
|
|
GVAR(unitList) append GVAR(unitWhitelist);
|
|
|
|
GVAR(unitList) = GVAR(unitList) arrayIntersect GVAR(unitList);
|