-
Notifications
You must be signed in to change notification settings - Fork 739
/
fnc_cam_setCameraMode.sqf
88 lines (71 loc) · 2.38 KB
/
fnc_cam_setCameraMode.sqf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#include "..\script_component.hpp"
/*
* Author: Nelson Duarte, AACO, kymckay
* Function used to select the camera mode
*
* Intended to run even if new mode == old mode, as it handles focus
*
* Arguments:
* 0: New camera mode <NUMBER>
*
* Return Value:
* None
*
* Example:
* [1] call ace_spectator_fnc_cam_setCameraMode
*
* Public: No
*/
params ["_newMode"];
private _oldMode = GVAR(camMode);
private _modes = GVAR(availableModes);
private _focus = GVAR(camFocus);
// If new mode isn't available then keep current (unless current also isn't)
if !(_newMode in _modes) then {
_newMode = _modes select ((_modes find _oldMode) max 0);
};
// Can't switch camera from free mode with no focus selected
if (!isNull _focus || _newMode == MODE_FREE) then {
private _camera = GVAR(camera);
private _showHUD = [true,true,true,true,true,true,true,true];
if (_newMode == MODE_FPS) then {
_camera cameraEffect ["Terminate", "BACK"];
_focus switchCamera "INTERNAL";
// Reset vision mode
[VISION_NORM] call FUNC(cam_setVisionMode);
[] call FUNC(cam_resetTarget);
// Disable camera input
_camera camCommand "manual off";
// Hide all unit/group information in first person view
_showHUD = [true,false,false,false,false,false,false,true];
};
if (_newMode == MODE_FOLLOW) then {
_camera cameraEffect ["Internal", "BACK"];
_focus switchCamera "EXTERNAL";
[] call FUNC(cam_resetTarget);
// Disable camera input
_camera camCommand "manual off";
};
if (_newMode == MODE_FREE) then {
_camera cameraEffect ["Internal", "BACK"];
switchCamera GVAR(camAgentFree); // Fix draw3D while in free camera for case where player is perma-dead
_camera setDir getDirVisual _camera;
if (!isNull _focus) then {
if (_oldMode == MODE_FPS) then {
[_focus] call FUNC(cam_prepareTarget);
};
[_focus] call FUNC(cam_setTarget);
};
// Enable camera input
_camera camCommand "manual on";
};
// Update the HUD
cameraEffectEnableHUD true;
showHUD _showHUD;
GVAR(camMode) = _newMode;
// Only update display if it exists, this function is independent of it
if !(isNull SPEC_DISPLAY) then {
[] call FUNC(ui_updateCamButtons);
[] call FUNC(ui_updateHelp);
};
};