Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_SpeedBoostUpManualCameraComponent.c
Go to the documentation of this file.
1 // Script File
2 [BaseContainerProps(), SCR_BaseManualCameraComponentTitle()]
4 {
5  [Attribute("1")]
6  private bool m_bSpeedBoostUpEnabled;
7 
8  [Attribute("1")]
9  private bool m_bHoldBoostUpEnabled;
10 
11  [Attribute("1")]
12  private bool m_bDisableOnSprint;
13 
14  [Attribute("25")]
15  private float m_iHeightMax;
16 
17  [Attribute("2")]
18  private float m_HeightMultiplier;
19 
20  [Attribute("3")]
21  private float m_fHoldSpeedMultiplier;
22 
23  [Attribute("2")]
24  private float m_fHoldBoostMax;
25 
26  private float m_HoldMultiplier = 0;
27 
28  private bool m_bDebugEnabled;
29 
30  //------------------------------------------------------------------------------------------------
31  override void EOnCameraFrame(SCR_ManualCameraParam param)
32  {
33  m_bDebugEnabled = DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_MANUAL_CAMERA_SPEED_BOOST_UP);
34 
35  if (!m_bDebugEnabled && param.velocityOriginal[1] <= 0)
36  return;
37 
38  DrawDebug1(param);
39 
40  if (!param.isManualInputEnabled)
41  return;
42 
43  vector pos = CoordFromCamera(param.transform[3]);
44  float surfaceY = param.world.GetSurfaceY(pos[0], pos[2]);
45  if (pos[1] > 0)
46  surfaceY = Math.Max(surfaceY, 0); //--- When above ground, use ASL, not ATL height
47  float height = pos[1] - surfaceY;
48 
49  float multiplierVertical = 0;
50 
51  InputManager inputManager = GetGame().GetInputManager();
52 
53  if (m_bHoldBoostUpEnabled && height < m_iHeightMax && inputManager.GetActionValue("ManualCameraMoveVertical") > 0)
54  m_HoldMultiplier = Math.Min( m_HoldMultiplier + (param.timeSlice * m_fHoldSpeedMultiplier), m_fHoldBoostMax);
55  else
56  m_HoldMultiplier = 0;
57 
58  if (height < m_iHeightMax && param.velocityOriginal[1] > 0)
59  multiplierVertical = (1 - (height / m_iHeightMax)) * m_HeightMultiplier;
60 
61  if (m_bHoldBoostUpEnabled)
62  multiplierVertical *= m_HoldMultiplier;
63 
64  DrawDebug2(height);
65 
66  if (!m_bSpeedBoostUpEnabled || (m_bDisableOnSprint && inputManager.GetActionValue("ManualCameraSpeedBoost") > 0))
67  {
68  DrawDebug3(param);
69  return;
70  }
71 
72  param.multiplier[1] = param.multiplier[1] * (1 + multiplierVertical);
73 
74  DrawDebug4(param, multiplierVertical);
75  }
76 
77  //------------------------------------------------------------------------------------------------
78  override bool EOnCameraInit()
79  {
80  DiagMenu.RegisterBool(SCR_DebugMenuID.DEBUGUI_MANUAL_CAMERA_SPEED_BOOST_UP, "", "Speed boost up debug", "Manual Camera", false);
81  return true;
82  }
83 
84  //------------------------------------------------------------------------------------------------
85  private void DrawDebug1(SCR_ManualCameraParam param)
86  {
87  if (m_bDebugEnabled)
88  {
89  DbgUI.Begin("Camera speed boost up debug", 0, 0);
90 
91  DbgUI.Check("Enable ground up boost", m_bSpeedBoostUpEnabled);
92  DbgUI.Check("Enable hold delay+boost", m_bHoldBoostUpEnabled);
93  DbgUI.Check("Disable boost up on sprint", m_bDisableOnSprint);
94 
95  DbgUI.SliderFloat("HeigthMax", m_iHeightMax, 10, 100);
96  DbgUI.SameLine();
97  DbgUI.Text(m_iHeightMax.ToString());
98 
99  DbgUI.SliderFloat("HeigtMultiplier", m_HeightMultiplier, 0, 10);
100  DbgUI.SameLine();
101  DbgUI.Text(m_HeightMultiplier.ToString());
102 
103  if (m_bHoldBoostUpEnabled)
104  {
105  DbgUI.SliderFloat("HoldBoostMax", m_fHoldBoostMax, 1, 10);
106  DbgUI.SameLine();
107  DbgUI.Text(m_fHoldBoostMax.ToString());
108 
109  DbgUI.SliderFloat("HoldSpeedupMultiplier", m_fHoldSpeedMultiplier, 1, 10);
110  DbgUI.SameLine();
111  DbgUI.Text(m_fHoldSpeedMultiplier.ToString());
112  }
113 
114  DbgUI.Text("VelY: " + param.velocityOriginal[1]);
115  DbgUI.PlotLive("VelY", 200, 100, param.velocityOriginal[1], 100, 100);
116  }
117  }
118 
119  //------------------------------------------------------------------------------------------------
120  private void DrawDebug2(float height)
121  {
122  if (m_bDebugEnabled)
123  {
124  DbgUI.Text("Height: " + height);
125  DbgUI.PlotLive("Height", 200, 100, height, 100, 100);
126  }
127  }
128 
129  //------------------------------------------------------------------------------------------------
130  private void DrawDebug3(SCR_ManualCameraParam param)
131  {
132  if (m_bDebugEnabled)
133  {
134  DbgUI.Text("Param.MultiplierHorizontal: " + param.multiplier[0]);
135  DbgUI.Text("Param.MultiplierVertical: " + param.multiplier[1]);
136  DbgUI.PlotLive("Param.MultiplierHorizontal", 200, 100, param.multiplier[0], 100, 100);
137  DbgUI.SameLine();
138  DbgUI.PlotLive("Param.MultiplierVertical", 200, 100, param.multiplier[1], 100, 100);
139 
140  DbgUI.End();
141  }
142  }
143 
144  //------------------------------------------------------------------------------------------------
145  private void DrawDebug4(SCR_ManualCameraParam param, float multiplierVertical)
146  {
147  if (m_bDebugEnabled)
148  {
149  DbgUI.Text("Param.MultiplierHorizontal: " + param.multiplier[0]);
150  DbgUI.Text("Param.MultiplierVertical: " + param.multiplier[1]);
151  DbgUI.PlotLive("Param.MultiplierHorizontal", 200, 100, param.multiplier[0], 100, 100);
152  DbgUI.SameLine();
153  DbgUI.PlotLive("Param.MultiplierVertical", 200, 100, param.multiplier[1], 100, 100);
154 
155  DbgUI.Text("NultiplierVertical: " + (1 + multiplierVertical));
156  DbgUI.PlotLive("NultiplierVertical", 200, 100, (1 + multiplierVertical), 100, 100);
157 
158  if (m_bHoldBoostUpEnabled)
159  {
160  DbgUI.Text("HoldMultplier: " + (1 + m_HoldMultiplier));
161  DbgUI.PlotLive("HoldMultplier", 200, 100, (1 + m_HoldMultiplier), 100, 100);
162  }
163 
164  DbgUI.End();
165  }
166  }
167 }
CoordFromCamera
protected vector CoordFromCamera(vector pos)
Definition: SCR_BaseManualCameraComponent.c:80
SCR_BaseManualCameraComponent
Parent class from which all SCR_ManualCamera components inherit.
Definition: SCR_BaseManualCameraComponent.c:5
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_SpeedBoostUpManualCameraComponent
Definition: SCR_SpeedBoostUpManualCameraComponent.c:3
SCR_ManualCameraParam
Parameter for carrying information between individual camera components.
Definition: SCR_ManualCameraParam.c:5
SCR_DebugMenuID
SCR_DebugMenuID
This enum contains all IDs for DiagMenu entries added in script.
Definition: DebugMenuID.c:3
BaseContainerProps
SCR_AIGoalReaction_Follow BaseContainerProps
Handles insects that are supposed to be spawned around selected prefabs defined in prefab names array...
Definition: SCR_AIGoalReaction.c:468