ACE3/addons/spectator/functions/fnc_updateCamera.sqf
2015-07-18 16:59:05 +01:00

50 lines
1.3 KiB
Plaintext

#include "script_component.hpp"
params [["_newMode",GVAR(camMode)],["_newUnit",GVAR(camUnit)]];
// Reset gun cam if mode is changing
if (_newMode != GVAR(camMode)) then {
GVAR(gunCam) = false;
GVAR(camMode) = _newMode;
};
// When no units available to spectate, exit to freecam
if (GVAR(unitList) isEqualTo []) then {
GVAR(camMode) = 0;
GVAR(camUnit) = objNull;
};
if (GVAR(camMode) == 0) then { // Free
// Preserve camUnit value for consistency when manually changing view
GVAR(camera) cameraEffect ["internal", "back"];
// HUD stuff
showCinemaBorder false;
cameraEffectEnableHUD false;
// Handle camera movement
[FUNC(handleCamera), 0] call CBA_fnc_addPerFrameHandler;
} else {
// When null unit is given choose random
if (isNull _newUnit) then {
_newUnit = GVAR(unitList) select floor(random(count GVAR(unitList)));
};
if (GVAR(camMode) == 1) then { // Internal
// Handle gun cam
if (GVAR(gunCam)) then {
_newUnit switchCamera "gunner";
} else {
_newUnit switchCamera "internal";
};
} else { // External
_newUnit switchCamera "external";
};
GVAR(camUnit) = _newUnit;
// Terminate camera view
GVAR(camera) cameraEffect ["terminate", "back"];
cameraEffectEnableHUD true;
};