Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
heavymetal.c
Go to the documentation of this file.
2{
3 static const float WATER_LOSS_HEAVYMETAL_MIN = 0.3;
4 static const float WATER_LOSS_HEAVYMETAL_MAX = 0.8;
5
6 static const float HEALTH_LOSS_HEAVYMETAL_MIN = 0.03;
7 static const float HEALTH_LOSS_HEAVYMETAL_MAX = 0.05;
8
9 static const int SYMPTOMFALLOFF_THRESHOLD1 = 200;
10 static const int SYMPTOMFALLOFF_THRESHOLD2 = 300;
11 static const int SYMPTOMFALLOFF_THRESHOLD3 = 400;
12
13 protected float m_NextEvent;
14 protected float m_Time;
15
16 protected float m_DeafnessTime;
17 protected bool m_IsDeaf;
18
28
29 override protected void OnActivate(PlayerBase player)
30 {
31 player.IncreaseDiseaseCount();
32 }
33
34 override protected void OnDeactivate(PlayerBase player)
35 {
36 player.DecreaseDiseaseCount();
37 }
38}
39
40class HeavyMetalPhase1Mdfr : HeavyMetalMdfr
41{
42 static const int AGENT_THRESHOLD_ACTIVATE = 1;
43 static const int AGENT_THRESHOLD_DEACTIVATE = 200;
44
45 static const int SHIVER_EVENT_INTERVAL_MIN = 20;
46 static const int SHIVER_EVENT_INTERVAL_MAX = 40;
47
48 override string GetDebugText()
49 {
50 return ("Activate threshold: "+AGENT_THRESHOLD_ACTIVATE + "| " +"Deativate threshold: "+AGENT_THRESHOLD_DEACTIVATE);
51 }
52
53 override protected bool ActivateCondition(PlayerBase player)
54 {
55 return (player.GetSingleAgentCount(eAgents.HEAVYMETAL) >= AGENT_THRESHOLD_ACTIVATE && player.GetSingleAgentCount(eAgents.HEAVYMETAL) < AGENT_THRESHOLD_DEACTIVATE);
56 }
57
58 override protected bool DeactivateCondition(PlayerBase player)
59 {
60 return (player.GetSingleAgentCount(eAgents.HEAVYMETAL) < AGENT_THRESHOLD_ACTIVATE || player.GetSingleAgentCount(eAgents.HEAVYMETAL) > AGENT_THRESHOLD_DEACTIVATE);
61 }
62
63 override protected void OnTick(PlayerBase player, float deltaT)
64 {
65 if (player.GetSingleAgentCount(eAgents.HEAVYMETAL) <= SYMPTOMFALLOFF_THRESHOLD3)
66 {
67 float waterLoss = (deltaT * (WATER_LOSS_HEAVYMETAL_MAX * Math.Max(WATER_LOSS_HEAVYMETAL_MIN, player.GetSingleAgentCountNormalized(eAgents.HEAVYMETAL))));
68 player.GetStatWater().Add(-waterLoss);
69 }
70
71 m_Time += deltaT;
72
73 if (player.GetSingleAgentCount(eAgents.HEAVYMETAL) <= SYMPTOMFALLOFF_THRESHOLD2)
74 {
75 player.m_AgentPool.AddAgent(eAgents.HEAVYMETAL, -0.5);
76 }
77
78 if (player.GetSingleAgentCount(eAgents.HEAVYMETAL) <= SYMPTOMFALLOFF_THRESHOLD3)
79 {
80 if ( m_Time >= m_NextEvent )
81 {
82 player.GetSymptomManager().QueueUpPrimarySymptom(SymptomIDs.SYMPTOM_HAND_SHIVER);
83 m_Time = 0;
84
85 m_NextEvent = Math.RandomFloatInclusive(SHIVER_EVENT_INTERVAL_MIN, SHIVER_EVENT_INTERVAL_MAX);
86 }
87 }
88 }
89}
90
92{
93 static const int AGENT_THRESHOLD_ACTIVATE = 200;
94 static const int AGENT_THRESHOLD_DEACTIVATE = 400;
95
96 static const int PAIN_EVENT_INTERVAL_MIN = 20;
97 static const int PAIN_EVENT_INTERVAL_MAX = 40;
98
99 static const int DEAFNESS_INTERVAL = 3;
100
101 override void Init()
102 {
103 super.Init();
104
105 m_ID = eModifiers.MDF_HEAVYMETAL2;
106 }
107
108 override string GetDebugText()
109 {
110 return ("Activate threshold: "+AGENT_THRESHOLD_ACTIVATE + "| " +"Deativate threshold: "+AGENT_THRESHOLD_DEACTIVATE);
111 }
112
113 override protected bool ActivateCondition(PlayerBase player)
114 {
115 return (player.GetSingleAgentCount(eAgents.HEAVYMETAL) >= AGENT_THRESHOLD_ACTIVATE && player.GetSingleAgentCount(eAgents.HEAVYMETAL) < AGENT_THRESHOLD_DEACTIVATE);
116 }
117
118 override protected bool DeactivateCondition(PlayerBase player)
119 {
120 return (player.GetSingleAgentCount(eAgents.HEAVYMETAL) < AGENT_THRESHOLD_ACTIVATE || player.GetSingleAgentCount(eAgents.HEAVYMETAL) > AGENT_THRESHOLD_DEACTIVATE);
121 }
122
123 override protected void OnTick(PlayerBase player, float deltaT)
124 {
125 m_Time += deltaT;
126
127 if (m_IsDeaf)
128 {
129 m_DeafnessTime += deltaT;
130 }
131
132 if (m_Time >= m_NextEvent)
133 {
134 if (player.GetSingleAgentCount(eAgents.HEAVYMETAL) >= SYMPTOMFALLOFF_THRESHOLD1)
135 {
136 player.GetSymptomManager().QueueUpPrimarySymptom(SymptomIDs.SYMPTOM_PAIN_LIGHT);
137 m_Time = 0;
138
139 m_NextEvent = Math.RandomFloatInclusive(PAIN_EVENT_INTERVAL_MIN, PAIN_EVENT_INTERVAL_MAX);
140 }
141 }
142
143 float chanceOfDeafness = player.GetSingleAgentCountNormalized(eAgents.HEAVYMETAL);
144 if (Math.RandomFloat01() < chanceOfDeafness / Math.RandomInt(5, 10))
145 {
146 player.GetSymptomManager().QueueUpSecondarySymptom(SymptomIDs.SYMPTOM_DEAFNESS_COMPLETE);
147 m_Time = 0;
148 m_DeafnessTime = 0;
149 m_IsDeaf = true;
150
151 m_NextEvent = Math.RandomFloatInclusive(PAIN_EVENT_INTERVAL_MIN, PAIN_EVENT_INTERVAL_MAX);
152 }
153
154 if (m_IsDeaf && m_DeafnessTime > DEAFNESS_INTERVAL + player.GetSingleAgentCountNormalized(eAgents.HEAVYMETAL)*0.6)
155 {
156 player.GetSymptomManager().RemoveSecondarySymptom(SymptomIDs.SYMPTOM_DEAFNESS_COMPLETE);
157 m_IsDeaf = false;
158 }
159
160 if (player.GetSingleAgentCount(eAgents.HEAVYMETAL) <= SYMPTOMFALLOFF_THRESHOLD3 && eAgents.HEAVYMETAL >= SYMPTOMFALLOFF_THRESHOLD1)
161 {
162 float waterLoss = (deltaT * (WATER_LOSS_HEAVYMETAL_MAX * Math.Max(WATER_LOSS_HEAVYMETAL_MIN, player.GetSingleAgentCountNormalized(eAgents.HEAVYMETAL))));
163 player.GetStatWater().Add(-waterLoss);
164 }
165
166 if (player.GetSingleAgentCount(eAgents.HEAVYMETAL) <= SYMPTOMFALLOFF_THRESHOLD3)
167 {
168 player.m_AgentPool.AddAgent(eAgents.HEAVYMETAL, -0.5);
169 }
170 }
171}
172
173class HeavyMetalPhase3Mdfr : HeavyMetalMdfr
174{
175 static const int AGENT_THRESHOLD_ACTIVATE = 400;
176 static const int AGENT_THRESHOLD_DEACTIVATE = 600;
177
178 static const int VOMIT_EVENT_INTERVAL_MIN = 180;
179 static const int VOMIT_EVENT_INTERVAL_MAX = 360;
180
181 override void Init()
182 {
183 super.Init();
184
185 m_ID = eModifiers.MDF_HEAVYMETAL3;
186 }
187
188 override string GetDebugText()
189 {
190 return ("Activate threshold: "+AGENT_THRESHOLD_ACTIVATE + "| " +"Deativate threshold: "+AGENT_THRESHOLD_DEACTIVATE);
191 }
192
193 override protected bool ActivateCondition(PlayerBase player)
194 {
195 return (player.GetSingleAgentCount(eAgents.HEAVYMETAL) >= AGENT_THRESHOLD_ACTIVATE && player.GetSingleAgentCount(eAgents.HEAVYMETAL) < AGENT_THRESHOLD_DEACTIVATE);
196 }
197
198 override protected bool DeactivateCondition(PlayerBase player)
199 {
200 return player.GetSingleAgentCount(eAgents.HEAVYMETAL) < AGENT_THRESHOLD_ACTIVATE;
201 }
202
203 override protected void OnActivate(PlayerBase player)
204 {
205 super.OnActivate(player);
206
207 player.GetSymptomManager().QueueUpSecondarySymptom(SymptomIDs.SYMPTOM_DEAFNESS_COMPLETE);
208 player.GetSymptomManager().QueueUpSecondarySymptom(SymptomIDs.SYMPTOM_HMP_SEVERE);
209 }
210
211 override protected void OnDeactivate(PlayerBase player)
212 {
213 super.OnDeactivate(player);
214
215 player.GetSymptomManager().RemoveSecondarySymptom(SymptomIDs.SYMPTOM_DEAFNESS_COMPLETE);
216 player.GetSymptomManager().RemoveSecondarySymptom(SymptomIDs.SYMPTOM_HMP_SEVERE);
217 }
218
219 override protected void OnTick(PlayerBase player, float deltaT)
220 {
221 float healthLoss = (deltaT * (HEALTH_LOSS_HEAVYMETAL_MAX * Math.Max(HEALTH_LOSS_HEAVYMETAL_MIN, player.GetSingleAgentCountNormalized(eAgents.HEAVYMETAL))));
222 player.AddHealth(-healthLoss);
223
224 m_Time += deltaT;
225
226 if (m_Time >= m_NextEvent)
227 {
228 SymptomBase symptom = player.GetSymptomManager().QueueUpPrimarySymptom(SymptomIDs.SYMPTOM_VOMIT);
229 if (symptom)
230 {
231 CachedObjectsParams.PARAM1_FLOAT.param1 = 30.0; //percentage of stomach
232 symptom.SetParam(CachedObjectsParams.PARAM1_FLOAT);
233 }
234
235 m_Time = 0;
236 m_NextEvent = Math.RandomFloatInclusive( VOMIT_EVENT_INTERVAL_MIN, VOMIT_EVENT_INTERVAL_MAX );
237 }
238 }
239}
void OnActivate(PlayerBase player)
Definition heavymetal.c:29
void OnDeactivate(PlayerBase player)
Definition heavymetal.c:34
override void Init()
Definition heavymetal.c:19
float m_NextEvent
Definition heavymetal.c:13
float m_DeafnessTime
Definition heavymetal.c:16
void OnTick(PlayerBase player, float deltaT)
Definition heavymetal.c:123
bool DeactivateCondition(PlayerBase player)
Definition heavymetal.c:118
bool ActivateCondition(PlayerBase player)
Definition heavymetal.c:113
Definition enmath.c:7
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
float m_Time
Definition environment.c:59
HeavyMetalMdfr AGENT_THRESHOLD_ACTIVATE
bool m_TrackActivatedTime
overall time this modifier was active
bool ActivateCondition(PlayerBase player)
string GetDebugText()
bool DeactivateCondition(PlayerBase player)
bool m_AnalyticsStatsEnabled
float m_TickIntervalActive
float m_TickIntervalInactive
const int DEFAULT_TICK_TIME_INACTIVE
enum eModifierSyncIDs DEFAULT_TICK_TIME_ACTIVE
void OnActivate()
float m_NextEvent