Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
cholera.c
Go to the documentation of this file.
2 {
3  static const int AGENT_THRESHOLD_ACTIVATE = 250;
4  static const int AGENT_THRESHOLD_DEACTIVATE = 50;
5 
6  static const int CHANCE_OF_VOMIT = 10;
7  static const int CHANCE_OF_VOMIT_AGENT = 30;
8  static const int WATER_DRAIN_FROM_VOMIT = 450;
9  static const int ENERGY_DRAIN_FROM_VOMIT = 310;
10  static const float WATER_LOSS_CHOLERA = 0.5;
11  static const float WATER_LOSS_CHOLERA_MIN = 0.1; // min multiplier of WATER_LOSS_CHOLERA
12  static const float STOMACH_MIN_VOLUME = 200; // for vomit symptom
13 
14  override void Init()
15  {
16  m_TrackActivatedTime = false;
17  m_ID = eModifiers.MDF_CHOLERA;
20  }
21 
22  override string GetDebugText()
23  {
24  return ("Activate threshold: "+AGENT_THRESHOLD_ACTIVATE + "| " +"Deativate threshold: "+AGENT_THRESHOLD_DEACTIVATE);
25  }
26 
27  override protected bool ActivateCondition(PlayerBase player)
28  {
29  if(player.GetSingleAgentCount(eAgents.CHOLERA) >= AGENT_THRESHOLD_ACTIVATE)
30  {
31  return true;
32  }
33  else
34  {
35  return false;
36  }
37  }
38 
39  override protected void OnActivate(PlayerBase player)
40  {
41  player.IncreaseDiseaseCount();
42  }
43 
44  override protected void OnDeactivate(PlayerBase player)
45  {
46  player.DecreaseDiseaseCount();
47  }
48 
49  override protected bool DeactivateCondition(PlayerBase player)
50  {
51  if(player.GetSingleAgentCount(eAgents.CHOLERA) <= AGENT_THRESHOLD_DEACTIVATE)
52  {
53  return true;
54  }
55  else
56  {
57  return false;
58  }
59  }
60 
61  override protected void OnTick(PlayerBase player, float deltaT)
62  {
63  float water_loss = ( deltaT * ( WATER_LOSS_CHOLERA * Math.Max( WATER_LOSS_CHOLERA_MIN, player.GetSingleAgentCountNormalized( eAgents.CHOLERA ) ) ) );
64  //Print( ( WATER_LOSS_CHOLERA * Math.Max( WATER_LOSS_CHOLERA_MIN, player.GetSingleAgentCountNormalized( eAgents.CHOLERA ) ) ) );
65  player.GetStatWater().Add( -water_loss );
66 
67  float stomach_volume = player.m_PlayerStomach.GetStomachVolume();
68  if( stomach_volume >= STOMACH_MIN_VOLUME )
69  {
70  int roll = Math.RandomInt( 0, 100 );
71  if( roll < ( CHANCE_OF_VOMIT + ( CHANCE_OF_VOMIT_AGENT * player.GetSingleAgentCountNormalized( eAgents.CHOLERA ) ) ) )
72  {
73  SymptomBase symptom = player.GetSymptomManager().QueueUpPrimarySymptom( SymptomIDs.SYMPTOM_VOMIT );
74  if( symptom )
75  {
76  symptom.SetDuration( Math.RandomIntInclusive( 4,8 ) );
77 
78  if (m_Player.GetStatWater().Get() > (WATER_DRAIN_FROM_VOMIT))
79  m_Player.GetStatWater().Add(-1 * WATER_DRAIN_FROM_VOMIT);
80  if (m_Player.GetStatEnergy().Get() > (ENERGY_DRAIN_FROM_VOMIT))
81  m_Player.GetStatEnergy().Add(-1 * ENERGY_DRAIN_FROM_VOMIT);
82  }
83  }
84  }
85  }
86 };
m_TickIntervalActive
float m_TickIntervalActive
Definition: modifierbase.c:19
m_TrackActivatedTime
bool m_TrackActivatedTime
Definition: modifierbase.c:15
SymptomBase
Definition: statebase.c:1
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
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
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
CholeraMdfr
Definition: cholera.c:1
DEFAULT_TICK_TIME_INACTIVE
const int DEFAULT_TICK_TIME_INACTIVE
Definition: modifiersmanager.c:33