ACE3/addons/spectator/functions/fnc_updateCamera.sqf

71 lines
1.7 KiB
Plaintext
Raw Normal View History

2015-07-18 17:46:46 +00:00
/*
* Author: SilentSpike
* Updates the spectator camera view mode and unit
*
* Arguments:
* 0: Camera mode <NUMBER>
* - 0: Free
* - 1: Internal
* - 2: External
* 1: Camera unit <OBJECT>
*
* Return Value:
* None <NIL>
*
* Example:
* [0,objNull] call ace_spectator_fnc_updateCamera
*
* Public: No
*/
2015-07-15 13:33:11 +00:00
#include "script_component.hpp"
2015-07-17 17:54:19 +00:00
params [["_newMode",GVAR(camMode)],["_newUnit",GVAR(camUnit)]];
2015-07-16 18:43:16 +00:00
// Reset gun cam if mode is changing
if (_newMode != GVAR(camMode)) then {
GVAR(gunCam) = false;
GVAR(camMode) = _newMode;
};
2015-07-16 22:58:58 +00:00
// When no units available to spectate, exit to freecam
if (GVAR(unitList) isEqualTo []) then {
GVAR(camMode) = 0;
2015-07-18 15:50:11 +00:00
GVAR(camUnit) = objNull;
2015-07-16 22:58:58 +00:00
};
2015-07-15 13:33:11 +00:00
2015-07-16 22:58:58 +00:00
if (GVAR(camMode) == 0) then { // Free
2015-07-18 15:50:11 +00:00
// Preserve camUnit value for consistency when manually changing view
2015-07-15 13:33:11 +00:00
GVAR(camera) cameraEffect ["internal", "back"];
2015-07-16 16:48:32 +00:00
// HUD stuff
showCinemaBorder false;
cameraEffectEnableHUD false;
2015-07-18 15:59:05 +00:00
// Handle camera movement
2015-07-18 16:06:13 +00:00
if (isNil QGVAR(camHandler)) then { GVAR(camHandler) = [FUNC(handleCamera), 0] call CBA_fnc_addPerFrameHandler; };
2015-07-15 13:33:11 +00:00
} else {
2015-07-18 15:50:11 +00:00
// When null unit is given choose random
if (isNull _newUnit) then {
2015-07-17 17:54:19 +00:00
_newUnit = GVAR(unitList) select floor(random(count GVAR(unitList)));
2015-07-15 13:33:11 +00:00
};
2015-07-16 22:58:58 +00:00
if (GVAR(camMode) == 1) then { // Internal
2015-07-15 13:33:11 +00:00
// Handle gun cam
if (GVAR(gunCam)) then {
2015-07-17 17:54:19 +00:00
_newUnit switchCamera "gunner";
2015-07-15 13:33:11 +00:00
} else {
2015-07-17 17:54:19 +00:00
_newUnit switchCamera "internal";
2015-07-15 13:33:11 +00:00
};
} else { // External
2015-07-17 17:54:19 +00:00
_newUnit switchCamera "external";
2015-07-15 13:33:11 +00:00
};
2015-07-16 16:48:32 +00:00
2015-07-17 17:54:19 +00:00
GVAR(camUnit) = _newUnit;
2015-07-16 16:48:32 +00:00
// Terminate camera view
GVAR(camera) cameraEffect ["terminate", "back"];
2015-07-18 16:06:13 +00:00
GVAR(camHandler) = nil;
2015-07-16 16:48:32 +00:00
cameraEffectEnableHUD true;
2015-07-15 13:33:11 +00:00
};