Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
FreeLookCinematicTrackModifier.c
Go to the documentation of this file.
2{
3 float lastX;
4 float lastY;
5 float deltaX;
6 float deltaY;
7 float inactiveX;
8 float inactiveY;
9 float deltaCumulX;
10 float deltaCumulY;
11 bool firstFrame = true;
12
13 bool invertMouse = false;
14 int signMouse = 1;
15
16 [Attribute(defvalue:"45", desc:"MaxAngleX")]
17 int maxAngleX;
18
19 [Attribute(defvalue:"30", desc:"MaxAngleX")]
20 int maxAngleY;
21
22 [Attribute(defvalue:"true")]
23 bool returnCameraAfterInactivity;
24
25 override vector OnApplyModifierVector(float time, vector originalValue)
26 {
27
28 InputManager inputManager = GetGame().GetInputManager();
29 inputManager.ActivateContext("CharacterFreelookMouseContext");
30 inputManager.ActivateContext("CharacterFreelookGamepadContext");
31
32 // Get Mouse Movement
33 float positionX = inputManager.GetActionValue("MouseX");
34 float positionY = inputManager.GetActionValue("MouseY");
35
36 BaseContainer inputDeviceSettings = GetGame().GetEngineUserSettings().GetModule("InputDeviceUserSettings");
37
38 if (inputDeviceSettings)
39 inputDeviceSettings.Get("MouseInvert", invertMouse);
40
41 if (invertMouse)
42 signMouse = -1;
43 else
44 signMouse = 1;
45
46 if (firstFrame)
47 {
48 firstFrame = false;
49 lastX = positionX;
50 lastY = positionY;
51 return originalValue;
52 }
53
54 deltaX = (positionX - lastX) / 15 - inputManager.GetActionValue("FreelookGamepadLeft") + inputManager.GetActionValue("FreelookGamepadRight");
55 deltaY = (-signMouse * positionY + signMouse * lastY) / 15 + inputManager.GetActionValue("FreelookGamepadUp") - inputManager.GetActionValue("FreelookGamepadDown");;
56
57 lastX = positionX;
58 lastY = positionY;
59
60 if (deltaX == 0 && returnCameraAfterInactivity) //no x input move
61 {
62 inactiveX += 0.001;
63
64 if (inactiveX > 0.06) //for more than second
65 deltaCumulX = deltaCumulX / (1 + inactiveX - 0.06); //slowly get back to original camera
66 }
67 else //if there is input - full impact on camera
68 {
69 inactiveX = 0;
70 deltaCumulX += deltaX;
71 }
72
73 if (deltaY == 0 && returnCameraAfterInactivity) //no y input move
74 {
75 inactiveY += 0.001;
76
77 if (inactiveY > 0.06) //for more than second
78 deltaCumulY = deltaCumulY / (1 + inactiveY - 0.06); //slowly get back to original camera
79 }
80 else //if there is input - full impact on camera
81 {
82 inactiveY = 0;
83 deltaCumulY += deltaY;
84 }
85
86 //Print(deltaCumulY);
87 deltaCumulX = Math.Clamp(deltaCumulX, -maxAngleX, maxAngleX);
88 deltaCumulY = Math.Clamp(deltaCumulY, -maxAngleY, maxAngleY);
89
90 vector newValue;
91 newValue[0] = originalValue[0] + deltaCumulY;
92 newValue[1] = originalValue[1] + deltaCumulX;
93 newValue[2] = originalValue[2];
94
95 return newValue;
96 }
97};
ArmaReforgerScripted GetGame()
Definition game.c:1398
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Input management system for user interactions.
Definition Math.c:13
SCR_FieldOfViewSettings Attribute