Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
heatcomfortmdfr.c
Go to the documentation of this file.
2 {
3  override void Init()
4  {
5  m_TrackActivatedTime = false;
6  m_ID = eModifiers.MDF_TEMPERATURE;
10  }
11 
12  override bool ActivateCondition(PlayerBase player)
13  {
14  return true;
15  }
16 
17  override bool DeactivateCondition(PlayerBase player)
18  {
19  return false;
20  }
21 
22  override void OnReconnect(PlayerBase player)
23  {
24 
25  }
26 
27  override string GetDebugText()
28  {
29  return m_Player.GetStatHeatComfort().Get().ToString();
30  }
31 
32  override string GetDebugTextSimple()
33  {
34  return m_Player.GetStatHeatComfort().Get().ToString();
35  }
36 
37 
38  override void OnTick(PlayerBase player, float deltaT)
39  {
40  float heat_comfort = player.GetStatHeatComfort().Get();
41  float health_loss;
42  float value_normalized;
43 
44  if( heat_comfort > PlayerConstants.WATER_LOSS_THRESHOLD_HC_PLUS_LOW )
45  {
46  value_normalized = Math.Lerp(PlayerConstants.WATER_LOSS_THRESHOLD_HC_PLUS_LOW, PlayerConstants.WATER_LOSS_THRESHOLD_HC_PLUS_HIGH, heat_comfort);
47  value_normalized = Math.Clamp(value_normalized, 0, 1);
48  float water_loss = deltaT * Math.Lerp(PlayerConstants.WATER_LOSS_HC_PLUS_LOW, PlayerConstants.WATER_LOSS_HC_PLUS_HIGH, value_normalized);
49  player.GetStatWater().Add(-water_loss);
50 
51  if( heat_comfort > PlayerConstants.WATER_LOSS_THRESHOLD_HC_PLUS_HIGH )
52  {
53  value_normalized = Math.Lerp(PlayerConstants.WATER_LOSS_THRESHOLD_HC_PLUS_HIGH, 1.0, heat_comfort);
54  value_normalized = Math.Clamp(value_normalized, 0, 1);
55  health_loss = deltaT * Math.Lerp(PlayerConstants.HEALTH_LOSS_HC_PLUS_LOW, PlayerConstants.HEALTH_LOSS_HC_PLUS_HIGH, value_normalized);
56  }
57  }
58  if( heat_comfort < PlayerConstants.ENERGY_LOSS_THRESHOLD_HC_MINUS_LOW )
59  {
60  value_normalized = Math.InverseLerp(PlayerConstants.ENERGY_LOSS_THRESHOLD_HC_MINUS_LOW, PlayerConstants.ENERGY_LOSS_THRESHOLD_HC_MINUS_HIGH, heat_comfort);
61  value_normalized = Math.Clamp(value_normalized, 0, 1);
62  float energy_loss = deltaT * Math.Lerp(PlayerConstants.ENERGY_LOSS_HC_MINUS_LOW, PlayerConstants.ENERGY_LOSS_HC_MINUS_HIGH, value_normalized);
63  player.GetStatEnergy().Add(-energy_loss);
64 
65  if( heat_comfort < PlayerConstants.ENERGY_LOSS_THRESHOLD_HC_MINUS_HIGH )
66  {
67  value_normalized = Math.InverseLerp(PlayerConstants.ENERGY_LOSS_THRESHOLD_HC_MINUS_HIGH, -1.0, heat_comfort);
68  value_normalized = Math.Clamp(value_normalized, 0, 1);
69  health_loss = deltaT * Math.Lerp(PlayerConstants.HEALTH_LOSS_HC_MINUS_LOW, PlayerConstants.HEALTH_LOSS_HC_MINUS_HIGH, value_normalized);
70  }
71  }
72 
73  if( health_loss != 0 )
74  {
75  player.AddHealth("","",-health_loss);
76  }
77  }
78 };
79 
m_TickIntervalActive
float m_TickIntervalActive
Definition: modifierbase.c:19
m_TrackActivatedTime
bool m_TrackActivatedTime
Definition: modifierbase.c:15
DisableDeactivateCheck
void DisableDeactivateCheck()
Definition: modifierbase.c:83
DEFAULT_TICK_TIME_ACTIVE
const int DEFAULT_TICK_TIME_ACTIVE
Definition: modifiersmanager.c:31
PlayerBase
Definition: playerbaseclient.c:1
PlayerConstants
Definition: playerconstants.c:1
m_Player
DayZPlayer m_Player
Definition: hand_events.c:42
m_TickIntervalInactive
float m_TickIntervalInactive
Definition: modifierbase.c:18
eModifiers
eModifiers
Definition: emodifiers.c:1
ModifierBase
Definition: breathvapourmdfr.c:3
HeatComfortMdfr
Definition: heatcomfortmdfr.c:1
Math
Definition: enmath.c:6
m_ID
protected int m_ID
ID of effect, given by SEffectManager when registered (automatically done when playing through it)
Definition: effect.c:49
DEFAULT_TICK_TIME_INACTIVE
const int DEFAULT_TICK_TIME_INACTIVE
Definition: modifiersmanager.c:33