Dayz Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Loading...
Searching...
No Matches
heatcomfortanimhandler.c
Go to the documentation of this file.
2{
3 const float TICK_INTERVAL = 2;
4
9
11
12 float m_EventTimeFreezeRattle = -1; // -1 = symptom effect needs to be triggered for first time
13 float m_EventTimeFreeze = -1;
14 float m_EventTimeHot = -1;
15
17
18 const float TIME_INTERVAL_HC_MINUS_LOW_MIN = 12; // Freezing and rattle symptoms interval minimum, lerped according to heat confort
20
21 const float TIME_INTERVAL_HC_MINUS_LOW_MAX = 20; // Interval maximum, lerped according to heat confort
23
24 const float TIME_INTERVAL_HC_PLUS_LOW_MIN = 12; // Ditto for heat symptoms
26
29
31 {
32 m_Player = player;
33 }
34
35 void Update(float delta_time, HumanMovementState hms)
36 {
37 m_TimeSinceLastTick += delta_time;
38
40 {
41 if (g_Game.IsServer())
43
45 }
46 }
47
48 void Process(float delta_time)
49 {
50 float hc = m_Player.GetStatHeatComfort().Get();
51
53 {
54 m_ProcessTimeAccuHot += delta_time;
55
57 ProcessHot(hc);
58 }
60 {
61 // White zone, reset the timers
62
63 if (m_EventTimeHot > -1 && hc <= 0)
64 m_EventTimeHot = -1;
65
66 if (m_EventTimeFreeze > -1 && hc >= 0)
68
71
72 }
73 else if (hc <= PlayerConstants.THRESHOLD_HEAT_COMFORT_MINUS_WARNING) // Light blue zone
74 {
75 if (hc <= PlayerConstants.THRESHOLD_HEAT_COMFORT_MINUS_CRITICAL) // Deep blue blinking zone, rattling is layerd on top of freezing
76 {
78
81 }
82
83 m_ProcessTimeAccuFreeze += delta_time;
84
86 ProcessFreeze(hc);
87 }
88
89 // Debug.Log("HeatComfort: " + hc);
90 }
91
92 private void ProcessHot(float hcValue)
93 {
94 m_Player.GetSymptomManager().QueueUpPrimarySymptom(SymptomIDs.SYMPTOM_HOT);
97
98 // Debug.Log("HeatComfort: " + hcValue + ", HOT in: " + m_EventTimeHot + "s");
99 }
100
101 private void ProcessFreeze(float hcValue)
102 {
103 m_Player.GetSymptomManager().QueueUpPrimarySymptom(SymptomIDs.SYMPTOM_FREEZE);
106
107 // Debug.Log("HeatComfort: " + hcValue + ", FREEZE in: " + m_EventTimeFreeze + "s");
108 }
109
110 private void ProcessFreezeRattle(float hcValue)
111 {
112 m_Player.GetSymptomManager().QueueUpPrimarySymptom(SymptomIDs.SYMPTOM_FREEZE_RATTLE);
115
116 // Debug.Log("HeatComfort: " + hcValue + ", RATTLE in: " + m_EventTimeFreezeRattle + "s");
117 }
118
119 private float GetEventTime(float hcValue, float threshold_low, float thresholdHigh, float lowMin, float highMin, float lowMax, float highMax)
120 {
121 float inv_value = Math.Clamp(Math.InverseLerp(threshold_low, thresholdHigh, hcValue), 0, 1);
122 float valueMin = Math.Lerp(lowMin, highMin, inv_value);
123 float value_max = Math.Lerp(lowMax, highMax, inv_value);
124
125 return Math.RandomFloatInclusive(valueMin, value_max);
126 }
127}
float GetEventTime(float hcValue, float threshold_low, float thresholdHigh, float lowMin, float highMin, float lowMax, float highMax)
void ProcessFreeze(float hcValue)
void ProcessHot(float hcValue)
ref HumanMovementState m_MovementState
void Update(float delta_time, HumanMovementState hms)
void Process(float delta_time)
void ProcessFreezeRattle(float hcValue)
void HeatComfortAnimHandler(PlayerBase player)
Definition enmath.c:7
static const float THRESHOLD_HEAT_COMFORT_MINUS_WARNING
static const float THRESHOLD_HEAT_COMFORT_PLUS_WARNING
static const float THRESHOLD_HEAT_COMFORT_PLUS_EMPTY
static const float THRESHOLD_HEAT_COMFORT_MINUS_CRITICAL
static const float THRESHOLD_HEAT_COMFORT_MINUS_EMPTY
DayZGame g_Game
Definition dayzgame.c:3942
void Process()
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 bool IsInRange(float v, float min, float max)
Returns if value is between min and max (inclusive).
static float RandomFloatInclusive(float min, float max)
Returns a random float number between and min [inclusive] and max [inclusive].
Definition enmath.c:106
static proto float Lerp(float a, float b, float time)
Linearly interpolates between 'a' and 'b' given 'time'.