2015-07-18 17:46:46 +00:00
|
|
|
/*
|
|
|
|
* Author: SilentSpike
|
2015-07-21 12:31:00 +00:00
|
|
|
* Transitions the spectator camera vision/view/unit
|
2015-07-18 17:46:46 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Camera mode <NUMBER>
|
|
|
|
* - 0: Free
|
|
|
|
* - 1: Internal
|
|
|
|
* - 2: External
|
|
|
|
* 1: Camera unit <OBJECT>
|
2015-07-21 10:59:20 +00:00
|
|
|
* 2: Vision mode <NUMBER>
|
|
|
|
* - -2: Normal
|
|
|
|
* - -1: NV
|
|
|
|
* - 0: White hot
|
|
|
|
* - 1: Black hot
|
2015-07-18 17:46:46 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None <NIL>
|
|
|
|
*
|
|
|
|
* Example:
|
2015-07-20 21:45:11 +00:00
|
|
|
* [0,objNull] call ace_spectator_fnc_transitionCamera
|
2015-07-18 17:46:46 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
2015-07-15 13:33:11 +00:00
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-07-21 10:59:20 +00:00
|
|
|
params [["_newMode",GVAR(camMode)], ["_newUnit",GVAR(camUnit)], ["_newVision",GVAR(camVision)]];
|
2015-07-16 18:43:16 +00:00
|
|
|
|
2015-07-21 20:51:32 +00:00
|
|
|
// If new mode isn't available then keep current (unless current also isn't)
|
2015-07-21 14:53:20 +00:00
|
|
|
if !(_newMode in GVAR(availableModes)) then {
|
2015-07-21 20:51:32 +00:00
|
|
|
_newMode = GVAR(availableModes) select ((GVAR(availableModes) find GVAR(camMode)) max 0);
|
2015-07-21 14:53:20 +00:00
|
|
|
};
|
|
|
|
|
2015-07-16 22:58:58 +00:00
|
|
|
// When no units available to spectate, exit to freecam
|
2015-08-05 12:19:47 +00:00
|
|
|
if ((GVAR(unitList) isEqualTo []) && (alive _newUnit || isNull _newUnit)) then {
|
2015-07-19 15:35:30 +00:00
|
|
|
_newMode = 0;
|
|
|
|
_newUnit = objNull;
|
2015-07-16 22:58:58 +00:00
|
|
|
};
|
2015-07-15 13:33:11 +00:00
|
|
|
|
2015-07-19 15:35:30 +00:00
|
|
|
// Reset gun cam if not internal
|
|
|
|
if (_newMode != 1) then {
|
2015-07-21 10:59:20 +00:00
|
|
|
GVAR(camGun) = false;
|
2015-07-19 15:35:30 +00:00
|
|
|
};
|
|
|
|
|
2015-09-09 22:21:49 +00:00
|
|
|
private ["_camera"];
|
2015-07-19 15:35:30 +00:00
|
|
|
if (_newMode == 0) then { // Free
|
2015-09-09 22:21:49 +00:00
|
|
|
_camera = GVAR(freeCamera);
|
|
|
|
|
2015-07-18 15:50:11 +00:00
|
|
|
// Preserve camUnit value for consistency when manually changing view
|
2015-09-09 22:21:49 +00:00
|
|
|
_camera cameraEffect ["internal", "back"];
|
2015-07-16 16:48:32 +00:00
|
|
|
|
2015-07-24 18:02:27 +00:00
|
|
|
// Apply the camera zoom
|
2015-09-09 22:21:49 +00:00
|
|
|
_camera camSetFov -(linearConversion [0.01,2,GVAR(camZoom),-2,-0.01,true]);
|
|
|
|
_camera camCommit 0;
|
2015-07-24 18:02:27 +00:00
|
|
|
|
2015-08-08 14:49:07 +00:00
|
|
|
// Agent is switched to in free cam to hide death table and prevent AI chat while allowing icons to draw (also prevents systemChat and unit HUD)
|
2015-08-06 10:34:24 +00:00
|
|
|
// (Why is so much stuff tied into the current camera unit BI?!)
|
2015-08-04 21:11:34 +00:00
|
|
|
if (isNull GVAR(camAgent)) then {
|
|
|
|
GVAR(camAgent) = createAgent ["VirtualMan_F",markerPos QGVAR(respawn),[],0,""];
|
|
|
|
};
|
|
|
|
|
|
|
|
GVAR(camAgent) switchCamera "internal";
|
2015-07-15 13:33:11 +00:00
|
|
|
} else {
|
2015-09-09 22:21:49 +00:00
|
|
|
_camera = GVAR(unitCamera);
|
|
|
|
|
2015-07-18 15:50:11 +00:00
|
|
|
// When null unit is given choose random
|
|
|
|
if (isNull _newUnit) then {
|
2015-11-29 15:33:25 +00:00
|
|
|
_newUnit = selectRandom GVAR(unitList);
|
2015-07-15 13:33:11 +00:00
|
|
|
};
|
|
|
|
|
2015-09-09 22:21:49 +00:00
|
|
|
// Switch camera view to internal unit view (external uses the camera)
|
|
|
|
if (GVAR(camGun)) then {
|
|
|
|
_newUnit switchCamera "gunner";
|
|
|
|
} else {
|
|
|
|
_newUnit switchCamera "internal";
|
|
|
|
};
|
|
|
|
|
|
|
|
// Handle camera differently for internal/external view
|
|
|
|
if (_newMode == 1) then {
|
|
|
|
// Terminate camera view
|
|
|
|
_camera cameraEffect ["terminate", "back"];
|
|
|
|
GVAR(camHandler) = nil;
|
|
|
|
} else {
|
|
|
|
// Switch to the camera
|
|
|
|
_camera cameraEffect ["internal", "back"];
|
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-15 13:33:11 +00:00
|
|
|
};
|
2015-07-19 15:35:30 +00:00
|
|
|
|
2015-10-04 18:26:53 +00:00
|
|
|
if (_newMode in [0,2]) then {
|
|
|
|
// Set up camera UI
|
|
|
|
showCinemaBorder false;
|
|
|
|
cameraEffectEnableHUD true;
|
|
|
|
|
|
|
|
// Handle camera movement
|
|
|
|
if (isNil QGVAR(camHandler)) then { GVAR(camHandler) = [FUNC(handleCamera), 0] call CBA_fnc_addPerFrameHandler; };
|
|
|
|
|
|
|
|
// If new vision isn't available then keep current (unless current also isn't)
|
|
|
|
if !(_newVision in GVAR(availableVisions)) then {
|
|
|
|
_newVision = GVAR(availableVisions) select ((GVAR(availableVisions) find GVAR(camVision)) max 0);
|
|
|
|
};
|
|
|
|
|
|
|
|
// Vision mode applies to free and external cam
|
|
|
|
if (_newVision < 0) then {
|
|
|
|
false setCamUseTi 0;
|
|
|
|
camUseNVG (_newVision >= -1);
|
|
|
|
} else {
|
|
|
|
true setCamUseTi _newVision;
|
|
|
|
};
|
|
|
|
GVAR(camVision) = _newVision;
|
|
|
|
};
|
|
|
|
|
2015-07-19 15:35:30 +00:00
|
|
|
GVAR(camMode) = _newMode;
|