Dayz Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Loading...
Searching...
No Matches
boathud.c
Go to the documentation of this file.
1// Boat HUD UI
3{
4 protected const float ENGINE_BLINK_DURATION = 3;
5
6 protected ImageWidget m_SpeedPointer;
7 protected ImageWidget m_EngineLight;
8 protected ImageWidget m_FuelLight;
9
10 protected bool m_HasEngine;
11 protected int m_EngagedGear;
12 protected int m_EngineHealthLevel;
13 protected float m_FuelLevel;
14 protected float m_TimeSinceEngineHit;
15 protected float m_TimeSinceEngineBlink;
17
18 protected ref WidgetFadeTimer m_FadeTimer = new WidgetFadeTimer();
19
20 override void Init(Widget vehicleHudPanels)
21 {
22 super.Init(vehicleHudPanels);
23
24 m_VehiclePanel = g_Game.GetWorkspace().CreateWidgets("gui/layouts/day_z_hud_boats.layout", vehicleHudPanels);
25
26 m_SpeedPointer = ImageWidget.Cast( m_VehiclePanel.FindAnyWidget("SpeedPointer") );
27 m_EngineLight = ImageWidget.Cast( m_VehiclePanel.FindAnyWidget("EngineLight"));
28 m_FuelLight = ImageWidget.Cast( m_VehiclePanel.FindAnyWidget("FuelLight"));
29
30 m_VehicleCurrentGearValue = TextWidget.Cast( m_VehiclePanel.FindAnyWidget("Current") );
31 m_VehicleNextGearValue = TextWidget.Cast( m_VehiclePanel.FindAnyWidget("Next") );
32 m_VehiclePrevGearValue = TextWidget.Cast( m_VehiclePanel.FindAnyWidget("Prev") );
33 }
34
35 override void ShowVehicleInfo(PlayerBase player)
36 {
37 HumanCommandVehicle hcv = player.GetCommand_Vehicle();
38 if (!hcv)
39 return;
40
42
43 m_VehiclePanel.Show(true);
44
46 m_FuelLevel = -1;
47
48 if (m_CurrentVehicle.HasEngine())
49 m_HasEngine = true;
50
51 float gearNeutral = m_CurrentVehicle.GetNeutralGear();
52 m_VehicleGearTable.Set(gearNeutral - 2, "");
53 m_VehicleGearTable.Set(gearNeutral - 1, "R");
54 m_VehicleGearTable.Set(gearNeutral, "N");
55 m_VehicleGearTable.Set(gearNeutral + 1, "F");
56 m_VehicleGearTable.Set(gearNeutral + 2, "");
57
58 m_EngagedGear = -10; // force initial update
59 }
60
61 override void HideVehicleInfo()
62 {
63 m_CurrentVehicle = null;
64 m_VehicleGearTable.Clear();
65 }
66
67 override void RefreshVehicleHud(float timeslice)
68 {
69 int engineHealthLevel = m_CurrentVehicle.GetHealthLevel("Engine");
70 float fuelFraction = m_CurrentVehicle.GetFluidFraction(BoatFluid.FUEL);
71
72 if (m_EngineHealthLevel != engineHealthLevel)
73 UpdateEngineIcon(engineHealthLevel);
74
75 if (m_FuelLevel != fuelFraction)
76 UpdateFuelIcon(fuelFraction);
77
78 if (m_CurrentVehicle.HasEngineZoneReceivedHit())
80
82 UpdateEngineBlink(timeslice);
83
85 UpdateGear();
86 }
87
88 protected void UpdateEngineIcon(int level)
89 {
90 m_EngineHealthLevel = level;
91
93 {
94 m_EngineLight.SetColor(COLOR_WHITE);
95 m_EngineLight.SetAlpha(0);
96 }
98 {
100 m_EngineLight.SetAlpha(1);
101 }
102 }
103
104 protected void UpdateFuelIcon(float level)
105 {
106 m_FuelLevel = level;
107
108 if (m_FuelLevel > 0.45)
109 {
110 m_FuelLight.SetAlpha(0);
111 return;
112 }
113 else if (m_FuelLevel > 0.15)
115 else if (m_FuelLevel > 0)
117 else
119
120 m_FuelLight.SetAlpha(1);
121 }
122
123 protected void UpdateSpeedPointer()
124 {
125 if (m_HasEngine)
126 {
127 float min, max, current;
128 min = 0;
129 max = m_CurrentVehicle.EngineGetRPMMax();
130 current = Math.Clamp(m_CurrentVehicle.EngineGetRPM(), min, max);
131
132 float percentVal = Math.InverseLerp(min, max, current);
133 m_SpeedPointer.SetRotation(0, 0, Math.Lerp(225, 495, Math.AbsFloat(percentVal)), true);
134 }
135 }
136
137 protected void UpdateGear()
138 {
139 if (!m_HasEngine)
140 return;
141
142 int gear = m_CurrentVehicle.GetGear();
143 if (m_EngagedGear == gear)
144 return;
145
147
151 }
152
153 protected void UpdateEngineBlink(float timeSlice)
154 {
155 m_TimeSinceEngineHit -= timeSlice;
156 if (m_TimeSinceEngineHit <= 0)
157 {
158 m_FadeTimer.Stop();
159 m_EngineLight.SetAlpha(1);
160 return;
161 }
162
163 m_TimeSinceEngineBlink -= timeSlice;
164 if (m_TimeSinceEngineBlink <= 0)
165 {
167 if (m_EngineLight.GetAlpha() == 0)
168 m_FadeTimer.FadeIn(m_EngineLight, 0.1);
169 else
170 m_FadeTimer.FadeOut(m_EngineLight, 0.1);
171 }
172 }
173
174 protected float GetSpeedometer()
175 {
176 vector transform[4];
177 m_CurrentVehicle.GetTransform(transform);
178
179 return GetVelocity(m_CurrentVehicle).InvMultiply3(transform)[2];
180 }
181}
BoatFluid
Type of vehicle's fluid. (native, do not change or extend).
Definition boat.c:14
bool m_HasEngine
Definition boathud.c:10
ref WidgetFadeTimer m_FadeTimer
Definition boathud.c:18
int m_EngineHealthLevel
Definition boathud.c:12
void UpdateSpeedPointer()
Definition boathud.c:123
override void ShowVehicleInfo(PlayerBase player)
Definition boathud.c:35
void UpdateEngineBlink(float timeSlice)
Definition boathud.c:153
void UpdateGear()
Definition boathud.c:137
float m_FuelLevel
Definition boathud.c:13
ImageWidget m_FuelLight
Definition boathud.c:8
ImageWidget m_EngineLight
Definition boathud.c:7
override void RefreshVehicleHud(float timeslice)
Definition boathud.c:67
float m_TimeSinceEngineBlink
Definition boathud.c:15
override void Init(Widget vehicleHudPanels)
Definition boathud.c:20
float GetSpeedometer()
Definition boathud.c:174
void UpdateFuelIcon(float level)
Definition boathud.c:104
void UpdateEngineIcon(int level)
Definition boathud.c:88
override void HideVehicleInfo()
Definition boathud.c:61
ImageWidget m_SpeedPointer
Definition boathud.c:6
const float ENGINE_BLINK_DURATION
Definition boathud.c:4
BoatScript m_CurrentVehicle
Definition boathud.c:16
float m_TimeSinceEngineHit
Definition boathud.c:14
int m_EngagedGear
Definition boathud.c:11
Base script class for boats.
Definition boatscript.c:42
Definition colors.c:4
const int COLOR_BADLY_DAMAGED
Definition colors.c:21
const int COLOR_DAMAGED
Definition colors.c:22
const int COLOR_RUINED
Definition colors.c:20
proto native Transport GetTransport()
static int GetItemHealthColor(int pHealthLevel)
Definition enmath.c:7
TextWidget m_VehiclePrevGearValue
void VehicleHudBase()
TextWidget m_VehicleCurrentGearValue
ref map< int, string > m_VehicleGearTable
TextWidget m_VehicleNextGearValue
Widget m_VehiclePanel
proto vector InvMultiply3(vector mat[3])
Invert-transforms vector.
DayZGame g_Game
Definition dayzgame.c:3942
const int COLOR_WHITE
Definition constants.c:63
const int STATE_WORN
Definition constants.c:854
static proto float Clamp(float value, float min, float max)
Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'.
static proto float InverseLerp(float a, float b, float value)
Calculates the linear value that produces the interpolant value within the range [a,...
static proto float Lerp(float a, float b, float time)
Linearly interpolates between 'a' and 'b' given 'time'.
static proto float AbsFloat(float f)
Returns absolute value.
proto native vector GetVelocity(notnull IEntity ent)
Returns linear velocity.
< h scale="0.8">< image set="dayz_gui" name="icon_pin"/> Welcome to the DayZ Stress Test Branch</h >< h scale="0.6"> This branch serves for time limited development tests that are open to the community Our goal in each of these tests is to gather performance and stability data from servers under heavy load</h ></br >< h scale="0.8">< image set="dayz_gui" name="icon_pin"/> Stress test Schedule</h >< h scale="0.6"> We ll only run the Stress Tests when our development team needs data and or specific feedback Stress Tests will be announced on our Twitter and and will usually run for a couple of hours</h ></br >< h scale="0.8">< image set="dayz_gui" name="icon_pin"/> Current Stress Test</h >< h scale="0.6"> In the first bunch of Stress we ll mostly focus on watching server performance under heavy PvP gameplay load For detailed information about an ongoing Stress please visit dayz com dev hub</h ></br >< h scale="0.8">< image set="dayz_gui" name="icon_pin"/> Important Note</h >< h scale="0.6"> Stress Tests do not represent a typical DayZ gameplay experience Spawn starting gear
Definition news_feed.txt:26