Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
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_ProcessTimeAccuHot;
7 
8  PlayerBase m_Player;
9  float m_EventTimeFreeze = -1;
10  float m_EventTimeHot = -1;
11  protected ref HumanMovementState m_MovementState = new HumanMovementState();
12 
13  const float TIME_INTERVAL_HC_MINUS_LOW_MIN = 5; const float TIME_INTERVAL_HC_MINUS_LOW_MAX = 12;
14  const float TIME_INTERVAL_HC_MINUS_HIGH_MIN = 15; const float TIME_INTERVAL_HC_MINUS_HIGH_MAX = 25;
15 
16  const float TIME_INTERVAL_HC_PLUS_LOW_MIN = 5; const float TIME_INTERVAL_HC_PLUS_LOW_MAX = 12;
17  const float TIME_INTERVAL_HC_PLUS_HIGH_MIN = 15; const float TIME_INTERVAL_HC_PLUS_HIGH_MAX = 25;
18 
20  {
21  m_Player = player;
22  }
23 
24  void Update(float delta_time, HumanMovementState hms)
25  {
26  m_TimeSinceLastTick += delta_time;
27 
29  {
30  Process(m_TimeSinceLastTick);
32  }
33  }
34 
35  float GetEventTime(float hc_value ,float threshold_low, float threshold_high, float low_min, float high_min, float low_max, float high_max)
36  {
37  float inv_value = Math.InverseLerp(threshold_low, threshold_high, hc_value);
38  float value_min = Math.Lerp(low_min, high_min,inv_value);
39  float value_max = Math.Lerp(low_max,high_max,inv_value);
40 
41  return Math.RandomFloatInclusive(value_min,value_max);
42  }
43 
44 
45  void Process(float delta_time)
46  {
47  if( GetGame().IsServer() )
48  {
49 
50  float hc = m_Player.GetStatHeatComfort().Get();
51  float inv_value;
52  float value_min;
53  float value_max;
54  float offset_time;
55 
56  if ( hc <= PlayerConstants.THRESHOLD_HEAT_COMFORT_MINUS_WARNING )
57  {
58  m_ProcessTimeAccuFreeze++;
59 
60  if(m_EventTimeFreeze < 0)//if not set
61  {
62  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);
63  }
64 
65  if( m_ProcessTimeAccuFreeze > m_EventTimeFreeze )
66  {
67  m_ProcessTimeAccuFreeze = 0;
68  m_EventTimeFreeze = -1;
69  m_Player.GetSymptomManager().QueueUpPrimarySymptom(SymptomIDs.SYMPTOM_FREEZE);
70  /*
71  Print("-----======== freezing ========-------");
72  Print(inv_value);
73  Print(value_min);
74  Print(value_max);
75  Print(offset_time);
76  Print("-----======== freezing ========-------");
77  */
78  }
79  }
80  else if ( hc >= PlayerConstants.THRESHOLD_HEAT_COMFORT_PLUS_WARNING )
81  {
82  m_ProcessTimeAccuHot++;
83 
84  if(m_EventTimeHot < 0)//if not set
85  {
86  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);
87  }
88 
89  if( m_ProcessTimeAccuHot > m_EventTimeHot )
90  {
91  m_ProcessTimeAccuHot = 0;
92  m_EventTimeHot = -1;
93  m_Player.GetSymptomManager().QueueUpPrimarySymptom(SymptomIDs.SYMPTOM_HOT);
94 
95  //Print("-----======== freezing ========-------");
96  //Print(inv_value);
97  //Print(value_min);
98  //Print(value_max);
99  //Print(offset_time);
100  //Print("-----======== freezing ========-------");
101 
102  }
103  }
104  }
105  }
106 }
GetGame
proto native CGame GetGame()
m_TimeSinceLastTick
float m_TimeSinceLastTick
Definition: injuryhandler.c:47
HumanMovementState
Definition: human.c:1125
HeatComfortAnimHandler
Definition: heatcomfortanimhandler.c:1
PlayerBase
Definition: playerbaseclient.c:1
PlayerConstants
Definition: playerconstants.c:1
m_Player
DayZPlayer m_Player
Definition: hand_events.c:42
TICK_INTERVAL
const float TICK_INTERVAL
Definition: staminasoundhandler.c:1
Math
Definition: enmath.c:6