diff --git a/addons/spectator/functions/fnc_handleInterface.sqf b/addons/spectator/functions/fnc_handleInterface.sqf index 61e642b96d..c959fcce3c 100644 --- a/addons/spectator/functions/fnc_handleInterface.sqf +++ b/addons/spectator/functions/fnc_handleInterface.sqf @@ -234,10 +234,7 @@ switch (toLower _mode) do { //[_show] call FUNC(handleMap); }; case 57: { // Spacebar - GVAR(camMode) = [1,2,0] select GVAR(camMode); - GVAR(gunCam) = false; - - call FUNC(updateView); + [[1,2,0] select GVAR(camMode)] call FUNC(updateView); }; }; @@ -279,19 +276,25 @@ switch (toLower _mode) do { // Tree events case "ontreedblclick": { // Update camera view when listbox unit is double clicked on - private ["_sel","_netID"]; + private ["_sel","_netID","_newUnit","_newMode"]; _sel = _args select 1; // Ensure a unit was selected if (count _sel == 2) then { _netID = (_args select 0) tvData _sel; - GVAR(camUnit) = objectFromNetId _netID; + _newUnit = objectFromNetId _netID; // Only update camera mode when in free cam if (GVAR(camMode) == 0) then { - GVAR(camMode) = 1; + _newMode = = 1; + } else { + // When unit is reselected, toggle camera mode + if (_newUnit == GVAR(camUnit)) then { + _newMode = [0,2,1] select GVAR(camMode); + }; }; - call FUNC(updateView); + GVAR(camUnit) = _newUnit; + [_newMode] call FUNC(updateView); }; }; }; diff --git a/addons/spectator/functions/fnc_updateView.sqf b/addons/spectator/functions/fnc_updateView.sqf index 64f2544645..db85bdf6ae 100644 --- a/addons/spectator/functions/fnc_updateView.sqf +++ b/addons/spectator/functions/fnc_updateView.sqf @@ -1,8 +1,16 @@ #include "script_component.hpp" +params [["_newMode",GVAR(camMode)]]; + +// Reset gun cam if mode is changing +if (_newMode != GVAR(camMode)) then { + GVAR(gunCam) = false; + GVAR(camMode) = _newMode; +}; + GVAR(camera) camSetFOV GVAR(camFOV); -if (GVAR(camMode) == 0) then { // Free +if (_newMode == 0) then { // Free GVAR(camera) cameraEffect ["internal", "back"]; // HUD stuff @@ -11,8 +19,7 @@ if (GVAR(camMode) == 0) then { // Free } else { // When no units available to spectate, exit to freecam if (unitList isEqualTo []) exitWith { - GVAR(camMode) = 0; - call FUNC(updateView); + [0] call FUNC(updateView); }; // First ensure valid unit is selected @@ -20,7 +27,7 @@ if (GVAR(camMode) == 0) then { // Free GVAR(camUnit) = GVAR(unitList) select floor(random(count GVAR(unitList))); }; - if (GVAR(camMode) == 1) then { // Internal + if (_newMode == 1) then { // Internal // Handle gun cam if (GVAR(gunCam)) then { GVAR(camUnit) switchCamera "gunner";