Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
poisoning.c
Go to the documentation of this file.
2 {
3  static const int AGENT_THRESHOLD_ACTIVATE = 150;
4  static const int AGENT_THRESHOLD_DEACTIVATE = 0;
5 
6  static const int VOMIT_OCCURRENCES_PER_HOUR_MIN = 60;
7  static const int VOMIT_OCCURRENCES_PER_HOUR_MAX = 120;
8 
9  static const int WATER_DRAIN_FROM_VOMIT = 70;
10  static const int ENERGY_DRAIN_FROM_VOMIT = 55;
11 
12  override void Init()
13  {
14  m_TrackActivatedTime = true;
15  m_IsPersistent = true;
16  m_ID = eModifiers.MDF_POISONING;
19  }
20 
21  override string GetDebugText()
22  {
23  return ("Activate threshold: "+AGENT_THRESHOLD_ACTIVATE + "| " +"Deativate threshold: "+AGENT_THRESHOLD_DEACTIVATE);
24  }
25 
26  override bool ActivateCondition(PlayerBase player)
27  {
28  if(player.GetSingleAgentCount(eAgents.FOOD_POISON) >= AGENT_THRESHOLD_ACTIVATE)
29  {
30  return true;
31  }
32  else
33  {
34  return false;
35  }
36  }
37 
38  override bool DeactivateCondition(PlayerBase player)
39  {
40  if(player.GetSingleAgentCount(eAgents.FOOD_POISON) <= AGENT_THRESHOLD_DEACTIVATE)
41  {
42  return true;
43  }
44  else
45  {
46  return false;
47  }
48  }
49 
50  override void OnActivate(PlayerBase player)
51  {
52  player.IncreaseDiseaseCount();
53  }
54 
55  override void OnReconnect(PlayerBase player)
56  {
57  this.OnActivate(player);
58  }
59 
60  override void OnDeactivate(PlayerBase player)
61  {
62  player.DecreaseDiseaseCount();
63  }
64 
65  override void OnTick(PlayerBase player, float deltaT)
66  {
67  int agent_max = PluginTransmissionAgents.GetAgentMaxCount(eAgents.FOOD_POISON);
68  int agent_count = player.m_AgentPool.GetSingleAgentCount(eAgents.FOOD_POISON);
69  float stomach_volume = player.m_PlayerStomach.GetStomachVolume();
70 
71  float norm_value = Math.InverseLerp(0, agent_max, agent_count );
72  float eased_value = Easing.EaseInCirc(norm_value);
73  float chance = Math.Lerp(VOMIT_OCCURRENCES_PER_HOUR_MIN, VOMIT_OCCURRENCES_PER_HOUR_MAX, eased_value );
74  chance = (chance / 3600) * deltaT;
75 
76  if( Math.RandomFloat01() < chance )
77  {
78  SymptomBase symptom = player.GetSymptomManager().QueueUpPrimarySymptom(SymptomIDs.SYMPTOM_VOMIT);
79 
80  if( symptom )
81  {
82  symptom.SetDuration(5);
83 
84  if (m_Player.GetStatWater().Get() > (WATER_DRAIN_FROM_VOMIT))
85  m_Player.GetStatWater().Add(-1 * WATER_DRAIN_FROM_VOMIT);
86  if (m_Player.GetStatEnergy().Get() > (ENERGY_DRAIN_FROM_VOMIT))
87  m_Player.GetStatEnergy().Add(-1 * ENERGY_DRAIN_FROM_VOMIT);
88  }
89  }
90  }
91 };
m_TickIntervalActive
float m_TickIntervalActive
Definition: modifierbase.c:19
m_TrackActivatedTime
bool m_TrackActivatedTime
Definition: modifierbase.c:15
SymptomBase
Definition: statebase.c:1
Easing
Input value between 0 and 1, returns value adjusted by easing, no automatic clamping of input(do your...
Definition: easing.c:2
DEFAULT_TICK_TIME_ACTIVE
const int DEFAULT_TICK_TIME_ACTIVE
Definition: modifiersmanager.c:31
PlayerBase
Definition: playerbaseclient.c:1
eAgents
eAgents
Definition: eagents.c:2
PoisoningMdfr
Definition: poisoning.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
m_IsPersistent
bool m_IsPersistent
Definition: modifierbase.c:16
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