Dayz Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Loading...
Searching...
No Matches
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 private float m_Time;
16 private float m_NextEvent;
17 private float m_ExhaustionTimer;
18
19 private bool m_Exhaustion;
20
29
30 override string GetDebugText()
31 {
32 return ("Activate threshold: "+AGENT_THRESHOLD_ACTIVATE + "| " +"Deativate threshold: "+AGENT_THRESHOLD_DEACTIVATE);
33 }
34
35 override protected bool ActivateCondition(PlayerBase player)
36 {
37 return player.GetSingleAgentCount(eAgents.SALMONELLA) >= AGENT_THRESHOLD_ACTIVATE;
38 }
39
40 override protected bool DeactivateCondition(PlayerBase player)
41 {
42 return player.GetSingleAgentCount(eAgents.SALMONELLA) <= AGENT_THRESHOLD_DEACTIVATE;
43 }
44
45 override protected void OnActivate(PlayerBase player)
46 {
47 player.IncreaseDiseaseCount();
48
49 SymptomBase symptom = player.GetSymptomManager().QueueUpPrimarySymptom( SymptomIDs.SYMPTOM_VOMIT );
50 if (symptom)
51 {
54 symptom.SetDuration(5.0);
55 }
56 }
57
58 override protected void OnDeactivate(PlayerBase player)
59 {
60 player.GetStaminaHandler().DeactivateRecoveryModifier(EStaminaMultiplierTypes.VOMIT_EXHAUSTION);
61 player.GetStaminaHandler().DeactivateDepletionModifier(EStaminaMultiplierTypes.VOMIT_EXHAUSTION);
62 m_Exhaustion = false;
64 player.DecreaseDiseaseCount();
65 }
66
67 override protected void OnTick(PlayerBase player, float deltaT)
68 {
69 float stomach_volume = player.m_PlayerStomach.GetStomachVolume();
70 if (stomach_volume >= STOMACH_MIN_VOLUME)
71 {
72 int roll = Math.RandomInt(0, 100);
73 int chanceOfVomit = CHANCE_OF_VOMIT + (CHANCE_OF_VOMIT_AGENT * player.GetSingleAgentCountNormalized(eAgents.SALMONELLA));
74 if (roll < chanceOfVomit)
75 {
76 SymptomBase symptom = player.GetSymptomManager().QueueUpPrimarySymptom(SymptomIDs.SYMPTOM_VOMIT);
77
78 if (symptom)
79 {
82 symptom.SetDuration(5);
83 player.m_AgentPool.ReduceAgent(eAgents.SALMONELLA, 30.0);
84
85 if (m_Player.GetStatWater().Get() > WATER_DRAIN_FROM_VOMIT)
86 m_Player.GetStatWater().Add(-1 * WATER_DRAIN_FROM_VOMIT);
87 if (m_Player.GetStatEnergy().Get() > ENERGY_DRAIN_FROM_VOMIT)
88 m_Player.GetStatEnergy().Add(-1 * ENERGY_DRAIN_FROM_VOMIT);
89
90 player.GetStaminaHandler().ActivateRecoveryModifier(EStaminaMultiplierTypes.VOMIT_EXHAUSTION);
91 player.GetStaminaHandler().ActivateDepletionModifier(EStaminaMultiplierTypes.VOMIT_EXHAUSTION);
92
93 m_Exhaustion = true;
95 }
96 }
97 }
98
99 m_Time += deltaT;
100
101 if (m_Time >= m_NextEvent)
102 {
103 m_Time = 0;
105 player.GetSymptomManager().QueueUpPrimarySymptom(SymptomIDs.SYMPTOM_PAIN_LIGHT);
106 }
107
108 if (m_Exhaustion)
109 {
110 m_ExhaustionTimer += deltaT;
111 if (m_ExhaustionTimer >= 45)
112 {
113 player.GetStaminaHandler().DeactivateRecoveryModifier(EStaminaMultiplierTypes.DISEASE_PNEUMONIA);
114 player.GetStaminaHandler().DeactivateDepletionModifier(EStaminaMultiplierTypes.DISEASE_PNEUMONIA);
115
116 m_Exhaustion = false;
117 }
118 }
119
120
121 }
122}
map m_Player
static ref Param1< float > PARAM1_FLOAT
Definition enmath.c:7
float m_NextEvent
Definition salmonella.c:16
static const int CHANCE_OF_VOMIT_AGENT
Definition salmonella.c:7
static const float STOMACH_MIN_VOLUME
Definition salmonella.c:10
static const int AGENT_THRESHOLD_ACTIVATE
Definition salmonella.c:3
bool ActivateCondition(PlayerBase player)
Definition salmonella.c:35
override string GetDebugText()
Definition salmonella.c:30
static const int WATER_DRAIN_FROM_VOMIT
Definition salmonella.c:8
static const float EVENT_INTERVAL_MIN
Definition salmonella.c:12
static const int CHANCE_OF_VOMIT
Definition salmonella.c:6
override void Init()
Definition salmonella.c:21
bool DeactivateCondition(PlayerBase player)
Definition salmonella.c:40
static const int AGENT_THRESHOLD_DEACTIVATE
Definition salmonella.c:4
void OnTick(PlayerBase player, float deltaT)
Definition salmonella.c:67
void OnActivate(PlayerBase player)
Definition salmonella.c:45
void OnDeactivate(PlayerBase player)
Definition salmonella.c:58
float m_ExhaustionTimer
Definition salmonella.c:17
static const int ENERGY_DRAIN_FROM_VOMIT
Definition salmonella.c:9
static const float EVENT_INTERVAL_MAX
Definition salmonella.c:13
void SetDuration(float duration)
Definition statebase.c:80
void SetParam(Param p)
Definition statebase.c:105
eAgents
Definition eagents.c:3
int m_ID
ID of effect, given by SEffectManager when registered (automatically done when playing through it).
Definition effect.c:51
eModifiers
Definition emodifiers.c:2
static proto int RandomInt(int min, int max)
Returns a random int number between and min [inclusive] and max [exclusive].
static float RandomFloatInclusive(float min, float max)
Returns a random float number between and min [inclusive] and max [inclusive].
Definition enmath.c:106
bool m_TrackActivatedTime
overall time this modifier was active
bool m_AnalyticsStatsEnabled
float m_TickIntervalActive
float m_TickIntervalInactive
const int DEFAULT_TICK_TIME_INACTIVE
enum eModifierSyncIDs DEFAULT_TICK_TIME_ACTIVE
EStaminaMultiplierTypes