diff --git a/addons/spectator/functions/fnc_handleInterface.sqf b/addons/spectator/functions/fnc_handleInterface.sqf index 80d87cf40a..d06c19bd38 100644 --- a/addons/spectator/functions/fnc_handleInterface.sqf +++ b/addons/spectator/functions/fnc_handleInterface.sqf @@ -80,7 +80,7 @@ switch (toLower _mode) do { clearRadio; // Return to player view - _unit switchCamera "internal"; + player switchCamera "internal"; // Enable BI damage effects BIS_fnc_feedback_allowPP = true; diff --git a/addons/spectator/functions/fnc_respawnTemplate.sqf b/addons/spectator/functions/fnc_respawnTemplate.sqf index b03c6dfb06..b808c43eab 100644 --- a/addons/spectator/functions/fnc_respawnTemplate.sqf +++ b/addons/spectator/functions/fnc_respawnTemplate.sqf @@ -21,6 +21,11 @@ params [["_unit",objNull,[objNull]], ["_killer",objNull,[objNull]], ["_respawn",0,[0]], ["_respawnDelay",0,[0]]]; private ["_vision","_pos"]; +// End mission when all are dead with respawn type "None" +if ((_respawn == 0) && {{alive _x} count allPlayers <= 0}) exitWith { + [["endDeath",false],"BIS_fnc_endMission"] call EFUNC(common,execRemoteFnc); +}; + if (isNull _killer) then {_killer = _unit}; _vision = [-2,-1] select (sunOrMoon < 1); _pos = (getPosATL _unit) vectorAdd [0,0,5]; @@ -29,11 +34,11 @@ if (alive _unit) then { if (_respawn == 1) then { [_unit,QGVAR(isSeagull)] call EFUNC(common,hideUnit); [2,_killer,_vision,_pos,getDir _unit] call FUNC(setCameraAttributes); - [_unit] call FUNC(setSpectator); + [true] call FUNC(setSpectator); } else { - [_unit,false] call FUNC(setSpectator); + [false] call FUNC(setSpectator); }; } else { [2,_killer,_vision,_pos,getDir _unit] call FUNC(setCameraAttributes); - [_unit] call FUNC(setSpectator); + [true] call FUNC(setSpectator); }; diff --git a/addons/spectator/functions/fnc_setSpectator.sqf b/addons/spectator/functions/fnc_setSpectator.sqf index 2d5ada415c..4f41e073d7 100644 --- a/addons/spectator/functions/fnc_setSpectator.sqf +++ b/addons/spectator/functions/fnc_setSpectator.sqf @@ -1,48 +1,42 @@ /* * Author: SilentSpike - * Sets target player to the given spectator state (virtually) + * Sets local client to the given spectator state (virtually) * To physically handle a spectator see ace_spectator_fnc_stageSpectator * - * Player will be able to communicate in ACRE/TFAR as appropriate + * Client will be able to communicate in ACRE/TFAR as appropriate * The spectator interface will be opened/closed * * Arguments: - * 0: Unit to put into spectator state - * 1: Spectator state + * 0: Spectator state of local client * * Return Value: * None * * Example: - * [player, true] call ace_spectator_fnc_setSpectator + * [true] call ace_spectator_fnc_setSpectator * * Public: Yes */ #include "script_component.hpp" -params ["_unit", ["_set",true,[true]]]; +params [["_set",true,[true]]]; -// Only run for player units -if !(isPlayer _unit) exitWith {}; - -if !(local _unit) exitwith { - [[_unit, _set], QFUNC(setSpectator), _unit] call EFUNC(common,execRemoteFnc); -}; +// Only clients can be spectators +if !(hasInterface) exitWith {}; // Handle common addon audio if (["ace_hearing"] call EFUNC(common,isModLoaded)) then {EGVAR(hearing,disableVolumeUpdate) = _set}; 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 {[player, _set] call TFAR_fnc_forceSpectator}; if (_set) then { ["open"] call FUNC(handleInterface); } else { - ["close",_unit] call FUNC(handleInterface); + ["close"] call FUNC(handleInterface); }; // Mark spectator state for reference -_unit setVariable [QGVAR(isSet), _set, true]; GVAR(isSet) = _set; -["spectatorSet",[_set,_unit]] call EFUNC(common,localEvent); +["spectatorSet",[_set]] call EFUNC(common,localEvent); diff --git a/addons/spectator/functions/fnc_stageSpectator.sqf b/addons/spectator/functions/fnc_stageSpectator.sqf index 3e17235e3e..7f0d862719 100644 --- a/addons/spectator/functions/fnc_stageSpectator.sqf +++ b/addons/spectator/functions/fnc_stageSpectator.sqf @@ -7,7 +7,7 @@ * Upon unstage, units will be moved to the position they were in upon staging * * Arguments: - * 0: Unit to put into spectator stage + * 0: Unit to put into spectator stage * 1: Spectator stage * * Return Value: @@ -21,19 +21,16 @@ #include "script_component.hpp" -params ["_unit", ["_set",true,[true]]]; +params [["_unit",player,[objNull]], ["_set",true,[true]]]; // No change, no service (but allow spectators to be reset) if !(_set || (GETVAR(_unit,GVAR(isStaged),false))) exitWith {}; -// Only run for player units -if !(isPlayer _unit) exitWith {}; - if !(local _unit) exitwith { [[_unit, _set], QFUNC(stageSpectator), _unit] call EFUNC(common,execRemoteFnc); }; -// Prevent player falling into water +// Prevent unit falling into water _unit enableSimulation !_set; // Move to/from group as appropriate