Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
salmonella.c
Go to the documentation of this file.
2 {
3  static const int AGENT_THRESHOLD_ACTIVATE = 60;
4  static const int AGENT_THRESHOLD_DEACTIVATE = 20;
5 
6  static const int CHANCE_OF_VOMIT = 10; // base vomit chance
7  static const int CHANCE_OF_VOMIT_AGENT = 20; // adjusted by the agent count
8  static const int WATER_DRAIN_FROM_VOMIT = 450;
9  static const int ENERGY_DRAIN_FROM_VOMIT = 310;
10  static const float STOMACH_MIN_VOLUME = 200; // min volume of stomach for vomit symptom
11 
12  static const float EVENT_INTERVAL_MIN = 12;
13  static const float EVENT_INTERVAL_MAX = 18;
14 
15 
16 
17  float m_Time;
18  float m_NextEvent;
19 
20  override void Init()
21  {
22  m_TrackActivatedTime = false;
23  m_ID = eModifiers.MDF_SALMONELLA;
26  }
27 
28  override string GetDebugText()
29  {
30  return ("Activate threshold: "+AGENT_THRESHOLD_ACTIVATE + "| " +"Deativate threshold: "+AGENT_THRESHOLD_DEACTIVATE);
31  }
32 
33  override protected bool ActivateCondition(PlayerBase player)
34  {
35  if(player.GetSingleAgentCount(eAgents.SALMONELLA) >= AGENT_THRESHOLD_ACTIVATE)
36  {
37  return true;
38  }
39  else
40  {
41  return false;
42  }
43  }
44 
45  override protected void OnActivate(PlayerBase player)
46  {
47  //if( player.m_NotifiersManager ) player.m_NotifiersManager.ActivateByType(eNotifiers.NTF_SICK);
48  player.IncreaseDiseaseCount();
49  }
50 
51  override protected void OnDeactivate(PlayerBase player)
52  {
53  player.DecreaseDiseaseCount();
54  }
55 
56  override protected bool DeactivateCondition(PlayerBase player)
57  {
58  if( player.GetSingleAgentCount( eAgents.SALMONELLA ) <= AGENT_THRESHOLD_DEACTIVATE )
59  {
60  return true;
61  }
62  else
63  {
64  return false;
65  }
66  }
67 
68  override protected void OnTick(PlayerBase player, float deltaT)
69  {
70  float stomach_volume = player.m_PlayerStomach.GetStomachVolume();
71  if( stomach_volume >= STOMACH_MIN_VOLUME )
72  {
73  int roll = Math.RandomInt( 0, 100 );
74  int chance_of_vomit = CHANCE_OF_VOMIT + ( CHANCE_OF_VOMIT_AGENT * player.GetSingleAgentCountNormalized( eAgents.SALMONELLA ) );
75  if( roll < chance_of_vomit )
76  {
77  SymptomBase symptom = player.GetSymptomManager().QueueUpPrimarySymptom( SymptomIDs.SYMPTOM_VOMIT );
78 
79  if( symptom )
80  {
81  symptom.SetDuration( 5 );
82 
83  // figure something more clever
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 
92  m_Time += deltaT;
93 
94  if ( m_Time >= m_NextEvent )
95  {
96  m_Time = 0;
97  m_NextEvent = Math.RandomFloatInclusive( EVENT_INTERVAL_MIN, EVENT_INTERVAL_MAX );
98  player.GetSymptomManager().QueueUpPrimarySymptom(SymptomIDs.SYMPTOM_PAIN_LIGHT);
99  }
100 
101 
102  }
103 };
m_Time
protected float m_Time
Definition: carscript.c:146
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
SalmonellaMdfr
Definition: salmonella.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