Differentiate between staged and set spectators

Existing variable "ace_spectator_isSpectator" split into counterparts "ace_spectator_isSet" and "ace_spectator_isStaged" in order to better manage spectator events
This commit is contained in:
SilentSpike 2015-08-02 12:47:26 +01:00
parent 38e08d513a
commit 63c034e348
4 changed files with 21 additions and 12 deletions

View File

@ -2,7 +2,7 @@
//#include "initKeybinds.sqf"; //#include "initKeybinds.sqf";
// Add interaction menu exception // Add interaction menu exception
["isNotSpectating", {!((_this select 0) getVariable [QGVAR(isSpectator), false])}] call EFUNC(common,addCanInteractWithCondition); ["isNotSpectating", {!(GETVAR((_this select 0),GVAR(isStaged),false))}] call EFUNC(common,addCanInteractWithCondition);
["SettingsInitialized", { ["SettingsInitialized", {
GVAR(availableModes) = [[0,1,2], [1,2], [0], [1], [2]] select GVAR(restrictModes); GVAR(availableModes) = [[0,1,2], [1,2], [0], [1], [2]] select GVAR(restrictModes);

View File

@ -23,6 +23,9 @@
params ["_unit", ["_set",true,[true]]]; params ["_unit", ["_set",true,[true]]];
// No change, no service (but allow spectators to be reset)
if !(_set || (GETVAR(_unit,GVAR(isSet),false))) exitWith {};
// Only run for player units // Only run for player units
if !(isPlayer _unit) exitWith {}; if !(isPlayer _unit) exitWith {};
@ -41,4 +44,10 @@ if (["ace_hearing"] call EFUNC(common,isModLoaded)) then {EGVAR(hearing,disableV
if (["acre_sys_radio"] call EFUNC(common,isModLoaded)) then {[_set] call acre_api_fnc_setSpectator}; if (["acre_sys_radio"] call EFUNC(common,isModLoaded)) then {[_set] call acre_api_fnc_setSpectator};
if (["task_force_radio"] call EFUNC(common,isModLoaded)) then {[_unit, _set] call TFAR_fnc_forceSpectator}; if (["task_force_radio"] call EFUNC(common,isModLoaded)) then {[_unit, _set] call TFAR_fnc_forceSpectator};
["spectatorSet",[_set]] call EFUNC(common,localEvent); // No theoretical change if an existing spectator was reset
if !(_set isEqualTo (GETVAR(_unit,GVAR(isSet),false))) then {
// Mark spectator state for reference
_unit setVariable [QGVAR(isSet), _set, true];
["spectatorSet",[_set]] call EFUNC(common,localEvent);
};

View File

@ -23,8 +23,8 @@
params ["_unit", ["_set",true,[true]]]; params ["_unit", ["_set",true,[true]]];
// No change, no service (but allow spectators who respawn to be reset) // No change, no service (but allow spectators to be reset)
if !(_set || (GETVAR(_unit,GVAR(isSpectator),false))) exitWith {}; if !(_set || (GETVAR(_unit,GVAR(isStaged),false))) exitWith {};
// Only run for player units // Only run for player units
if !(isPlayer _unit) exitWith {}; if !(isPlayer _unit) exitWith {};
@ -37,7 +37,7 @@ if !(local _unit) exitwith {
_unit enableSimulation !_set; _unit enableSimulation !_set;
// Move to/from group as appropriate // Move to/from group as appropriate
[_unit, _set, QGVAR(isSpectator), side group _unit] call EFUNC(common,switchToGroupSide); [_unit, _set, QGVAR(isStaged), side group _unit] call EFUNC(common,switchToGroupSide);
if (_set) then { if (_set) then {
// Move and hide the player ASAP to avoid being seen // Move and hide the player ASAP to avoid being seen
@ -45,12 +45,12 @@ if (_set) then {
_unit setPos (getMarkerPos QGVAR(respawn)); _unit setPos (getMarkerPos QGVAR(respawn));
// Ghosts can't talk // Ghosts can't talk
[_unit, QGVAR(isSpectator)] call EFUNC(common,hideUnit); [_unit, QGVAR(isStaged)] call EFUNC(common,hideUnit);
[_unit, QGVAR(isSpectator)] call EFUNC(common,muteUnit); [_unit, QGVAR(isStaged)] call EFUNC(common,muteUnit);
} else { } else {
// Physical beings can talk // Physical beings can talk
[_unit, QGVAR(isSpectator)] call EFUNC(common,unhideUnit); [_unit, QGVAR(isStaged)] call EFUNC(common,unhideUnit);
[_unit, QGVAR(isSpectator)] call EFUNC(common,unmuteUnit); [_unit, QGVAR(isStaged)] call EFUNC(common,unmuteUnit);
_unit setPosATL GVAR(oldPos); _unit setPosATL GVAR(oldPos);
}; };
@ -60,9 +60,9 @@ _unit allowDamage !_set;
_unit setVariable [QEGVAR(medical,allowDamage), !_set]; _unit setVariable [QEGVAR(medical,allowDamage), !_set];
// No theoretical change if an existing spectator was reset // No theoretical change if an existing spectator was reset
if !(_set isEqualTo (GETVAR(_unit,GVAR(isSpectator),false))) then { if !(_set isEqualTo (GETVAR(_unit,GVAR(isStaged),false))) then {
// Mark spectator state for reference // Mark spectator state for reference
_unit setVariable [QGVAR(isSpectator), _set, true]; _unit setVariable [QGVAR(isStaged), _set, true];
["spectatorStaged",[_set]] call EFUNC(common,localEvent); ["spectatorStaged",[_set]] call EFUNC(common,localEvent);
}; };

View File

@ -55,7 +55,7 @@ _filteredUnits = [];
{(_x isKindOf "CAManBase")} && {(_x isKindOf "CAManBase")} &&
{(side group _x) in _sides} && // Side filter {(side group _x) in _sides} && // Side filter
{simulationEnabled _x} && {simulationEnabled _x} &&
{!(_x getVariable [QGVAR(isSpectator), false])} // Who watches the watchmen? {!(_x getVariable [QGVAR(isStaged), false])} // Who watches the watchmen?
) then { ) then {
_filteredUnits pushBack _x; _filteredUnits pushBack _x;
}; };