Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
heatcomfortanimhandler.c
Go to the documentation of this file.
2{
3 const float TICK_INTERVAL = 2;
4 float m_TimeSinceLastTick;
5 float m_ProcessTimeAccuFreeze;
6 float m_ProcessTimeAccuFreezeRattle;
7 float m_ProcessTimeAccuHot;
8
9 PlayerBase m_Player;
10 float m_EventTimeFreeze = -1;
11 float m_EventTimeFreezeRattle = -1;
12 float m_EventTimeHot = -1;
13 protected ref HumanMovementState m_MovementState = new HumanMovementState();
14
17
20
22 {
23 m_Player = player;
24 }
25
26 void Update(float delta_time, HumanMovementState hms)
27 {
28 m_TimeSinceLastTick += delta_time;
29
31 {
34 }
35 }
36
37 float GetEventTime(float hc_value, float threshold_low, float threshold_high, float low_min, float high_min, float low_max, float high_max)
38 {
39 float inv_value = Math.InverseLerp(threshold_low, threshold_high, hc_value);
40 float value_min = Math.Lerp(low_min, high_min, inv_value);
41 float value_max = Math.Lerp(low_max, high_max, inv_value);
42
43 return Math.RandomFloatInclusive(value_min, value_max);
44 }
45
46
47 void Process(float delta_time)
48 {
49 if( GetGame().IsServer() )
50 {
51 float hc = m_Player.GetStatHeatComfort().Get();
52
53 if ( hc <= PlayerConstants.THRESHOLD_HEAT_COMFORT_MINUS_CRITICAL ) // Deep blue zone, rattling sounds are layerd on top of freezing sounds
54 {
55 m_ProcessTimeAccuFreezeRattle++;
56
57 if (m_EventTimeFreezeRattle < 0)
59
60 if( m_ProcessTimeAccuFreezeRattle > m_EventTimeFreezeRattle )
61 {
62 m_ProcessTimeAccuFreezeRattle = 0;
63 m_EventTimeFreezeRattle = -1;
64 m_Player.GetSymptomManager().QueueUpPrimarySymptom(SymptomIDs.SYMPTOM_FREEZE_RATTLE);
65 }
66 }
67
68 if ( hc <= PlayerConstants.THRESHOLD_HEAT_COMFORT_MINUS_WARNING ) // Light blue zone
69 {
70 m_ProcessTimeAccuFreeze++;
71
72 if(m_EventTimeFreeze < 0) //if not set
73 {
74 m_EventTimeFreeze = GetEventTime(hc, PlayerConstants.THRESHOLD_HEAT_COMFORT_MINUS_EMPTY, PlayerConstants.THRESHOLD_HEAT_COMFORT_MINUS_WARNING, TIME_INTERVAL_HC_MINUS_LOW_MIN, TIME_INTERVAL_HC_MINUS_HIGH_MIN, TIME_INTERVAL_HC_MINUS_LOW_MAX, TIME_INTERVAL_HC_MINUS_HIGH_MAX);
75 }
76
77 if( m_ProcessTimeAccuFreeze > m_EventTimeFreeze )
78 {
79 m_ProcessTimeAccuFreeze = 0;
80 m_EventTimeFreeze = -1;
81 m_Player.GetSymptomManager().QueueUpPrimarySymptom(SymptomIDs.SYMPTOM_FREEZE);
82 }
83 }
84 else if ( hc >= PlayerConstants.THRESHOLD_HEAT_COMFORT_PLUS_WARNING ) // Yellow zone
85 {
86 m_ProcessTimeAccuHot++;
87
88 if(m_EventTimeHot < 0) //if not set
89 {
90 m_EventTimeHot = GetEventTime(hc, PlayerConstants.THRESHOLD_HEAT_COMFORT_PLUS_EMPTY,PlayerConstants.THRESHOLD_HEAT_COMFORT_PLUS_WARNING, TIME_INTERVAL_HC_PLUS_LOW_MIN, TIME_INTERVAL_HC_PLUS_LOW_MIN, TIME_INTERVAL_HC_PLUS_LOW_MAX, TIME_INTERVAL_HC_PLUS_HIGH_MAX);
91 }
92
93 if( m_ProcessTimeAccuHot > m_EventTimeHot )
94 {
95 m_ProcessTimeAccuHot = 0;
96 m_EventTimeHot = -1;
97 m_Player.GetSymptomManager().QueueUpPrimarySymptom(SymptomIDs.SYMPTOM_HOT);
98 }
99 }
100 }
101 }
102}
void Update(float delta_time, HumanMovementState hms)
ref HumanMovementState m_MovementState
void Process(float delta_time)
float GetEventTime(float hc_value, float threshold_low, float threshold_high, float low_min, float high_min, float low_max, float high_max)
void HeatComfortAnimHandler(PlayerBase player)
Definition enmath.c:7
void Process()
proto native CGame GetGame()
DayZPlayer m_Player
Definition hand_events.c:42
float m_TimeSinceLastTick
const float TICK_INTERVAL