DayZ 1.30
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
Silicosis.c
См. документацию.
2{
3 private const int STAMINA_LIMIT_TRESHOLD = 600;
4 private const int HEALTH_THRESHOLD = 700;
5 private const int UNCON_THRESHOLD = 800;
6
8 protected static const float UNCONSCIOUSNESS_LENGTH_MIN = 5.0;
9 protected static const float UNCONSCIOUSNESS_LENGTH_MAX = 10.0;
10 protected static const float UNCONSCIOUSNESS_EVENT_INTERVAL_MIN = 60.0;
11 protected static const float UNCONSCIOUSNESS_EVENT_INTERVAL_MAX = 120.0;
12
13 private const float HEALTH_LOSS = 2.0;
14
15 private const int HEAVY_BREATH_TRESHOLD_MIN = 200;
16 private const float HEAVY_BREATH_INTERVAL_MIN = 3.0;
17 private const float HEAVY_BREATH_INTERVAL_MAX = 25.0;
18
22 protected float m_HeavyBreathTimer;
23
24 private float m_AgentsCountPrevious;
25 private bool m_StaminaLimitation;
27
28 override void Init()
29 {
31 m_ID = eModifiers.MDF_PARTICLES_BREATH;
34 }
35
36 override protected bool ActivateCondition(PlayerBase player)
37 {
38 return (player.GetSingleAgentCount(eAgents.SILICOSIS) > 0);
39 }
40
41 override bool DeactivateCondition(PlayerBase player)
42 {
43 return (player.GetSingleAgentCount(eAgents.SILICOSIS) == 0);
44 }
45
46 override void OnActivate(PlayerBase player)
47 {
49
53
55
56 m_FaintSymptom = player.GetSymptomManager().QueueUpSecondarySymptomEx(SymptomIDs.SYMPTOM_FAINT);
58 {
60
61 SymptomSyncData faintData = new SymptomSyncData();
62 params.param1 = SymptomIDs.SYMPTOM_FAINT;
63 faintData.m_FloatArray.Insert(0.0);
64 faintData.m_FloatArray.Insert(0.0);
65 faintData.m_FloatArray.Insert(0.0);
66 faintData.m_IntArray.Insert(1);
67 params.param2 = faintData;
68
69 m_FaintSymptom.SetParam(params);
70 }
71 }
72
73 override void OnDeactivate(PlayerBase player)
74 {
75 m_StaminaLimitation = false;
76 }
77
78 override void OnTick(PlayerBase player, float deltaT)
79 {
80 #ifdef DEVELOPER
81 if(!player.GetCanBeDestroyed())
82 return;
83 #endif
84
85 float agentsCount = player.GetSingleAgentCount(eAgents.SILICOSIS);
86 float agentsCountDiff = agentsCount - m_AgentsCountPrevious;
87
89 {
90 float heavyBreathIntensity = Math.Remap(HEAVY_BREATH_TRESHOLD_MIN, 1000, 0.1, 1.0, agentsCount);
91 float heavyBreathInterval = Math.Lerp(HEAVY_BREATH_INTERVAL_MAX, HEAVY_BREATH_INTERVAL_MIN, heavyBreathIntensity);
92
93 if (heavyBreathIntensity > 0.0)
94 m_HeavyBreathTimer += deltaT;
95 else
97
98 if (m_HeavyBreathTimer >= heavyBreathInterval)
99 {
100 m_HeavyBreathTimer = 0.0;
101
102 Math.Randomize(Math.RandomInt(1, 1000));
103 float rand = Math.RandomFloat01();
104 if (rand <= heavyBreathIntensity)
105 player.RequestSoundEventEx(EPlayerSoundEventID.HEAVY_BREATHING, true, EPlayerSoundEventParam.HIGHEST_PRIORITY);
106 }
107 }
108
111 {
112 if (agentsCount >= STAMINA_LIMIT_TRESHOLD && !m_StaminaLimitation)
113 {
114 player.GetStaminaHandler().ActivateRecoveryModifier(EStaminaMultiplierTypes.DISEASE_PNEUMONIA);
115 player.GetStaminaHandler().ActivateDepletionModifier(EStaminaMultiplierTypes.DISEASE_PNEUMONIA);
116 m_StaminaLimitation = true;
117 }
118 else if (agentsCount < STAMINA_LIMIT_TRESHOLD && m_StaminaLimitation)
119 {
120 player.GetStaminaHandler().DeactivateRecoveryModifier(EStaminaMultiplierTypes.DISEASE_PNEUMONIA);
121 player.GetStaminaHandler().DeactivateDepletionModifier(EStaminaMultiplierTypes.DISEASE_PNEUMONIA);
122 m_StaminaLimitation = false;
123 }
124 }
125
127 SymptomSyncData faintData = new SymptomSyncData();
128 if (!player.IsUnconscious())
129 {
130 m_FaintEffectTime += deltaT;
131
133 if (agentsCount > HEALTH_THRESHOLD && agentsCountDiff > 0)
134 {
135 float healthLoss = HEALTH_LOSS * Math.Remap(HEALTH_THRESHOLD, UNCON_THRESHOLD, 0.0, 1.0, agentsCount);
136 player.AddHealth(-healthLoss);
137 }
138
140 float vignette = Math.Remap(UNCON_THRESHOLD, 1000, 0.0, 2.0, agentsCount);
141 float fadeOut = Math.Remap(UNCON_THRESHOLD, 1000, 0.0, 5.0, agentsCount);
142 float interval = Math.Remap(1000, UNCON_THRESHOLD, 0.0, 10.0, agentsCount) + fadeOut;
143
145 {
146 params.param1 = SymptomIDs.SYMPTOM_FAINT;
147 faintData.m_FloatArray.Insert(vignette);
148 faintData.m_FloatArray.Insert(fadeOut);
149 faintData.m_FloatArray.Insert(interval);
150 faintData.m_IntArray.Insert(1);
151 params.param2 = faintData;
152
153 m_FaintSymptom.SetParam(params);
154
156 m_FaintEffectActive = true;
159 }
160 else if (m_FaintEffectTime > interval && m_CanFaintEffectFadeOut)
161 {
162 params.param1 = SymptomIDs.SYMPTOM_FAINT;
163 faintData.m_FloatArray.Insert(vignette);
164 faintData.m_FloatArray.Insert(fadeOut);
165 faintData.m_FloatArray.Insert(interval);
166 faintData.m_IntArray.Insert(0);
167 params.param2 = faintData;
168
169 m_FaintSymptom.SetParam(params);
170
174 }
175 }
176 else
177 {
179 {
180 m_FaintEffectActive = false;
181
182 params.param1 = SymptomIDs.SYMPTOM_FAINT;
183 faintData.m_FloatArray.Insert(vignette);
184 faintData.m_FloatArray.Insert(fadeOut);
185 faintData.m_FloatArray.Insert(interval);
186 faintData.m_IntArray.Insert(2);
187 params.param2 = faintData;
188
189 m_FaintSymptom.SetParam(params);
190 }
191 }
192
194 {
195 if (agentsCount > UNCON_THRESHOLD)
196 {
199 }
200
201 bool canTriggerUnconsciousness = !m_CanFaintEffectFadeOut;
202 if ((agentsCount > UNCON_THRESHOLD && canTriggerUnconsciousness) || player.IsUnconscious())
203 {
205 if (m_UnconciousnessInactiveTimer >= m_NextUnconsciousnessEvent && !player.IsUnconscious())
206 {
207 player.RequestUnconsciousness(true);
208 player.SetHealth("", "Shock", 25.0);
212 }
213 else if (m_UnconciousnessActiveTimer > unconsciousnessLength && player.IsUnconscious())
214 {
215 player.RequestUnconsciousness(false);
218 }
219 }
220 }
221
222 m_AgentsCountPrevious = agentsCount;
223 }
224}
int m_ID
Определения DustKickupEffects.c:26
eAgents
Определения EAgents.c:3
bool m_TrackActivatedTime
overall time this modifier was active
Определения ModifierBase.c:14
float m_TickIntervalActive
Определения ModifierBase.c:18
float m_TickIntervalInactive
Определения ModifierBase.c:17
const int DEFAULT_TICK_TIME_INACTIVE_LONG
Определения ModifiersManager.c:30
EPlayerSoundEventID
Определения PlayerSoundEventHandler.c:3
EStaminaMultiplierTypes
Определения StaminaHandler.c:2
Определения EnMath.c:7
Определения BreathVapourMdfr.c:4
Определения PPEConstants.c:68
Определения PlayerBaseClient.c:2
const int STAMINA_LIMIT_TRESHOLD
Определения Silicosis.c:3
bool m_FaintEffectActive
Определения Silicosis.c:19
bool m_StaminaLimitation
Определения Silicosis.c:25
float m_UnconciousnessInactiveTimer
Определения Silicosis.c:20
const float HEAVY_BREATH_INTERVAL_MIN
min #num of agents
Определения Silicosis.c:16
static const float UNCONSCIOUSNESS_EVENT_INTERVAL_MAX
Определения Silicosis.c:11
override void OnTick(PlayerBase player, float deltaT)
Определения Silicosis.c:78
static const float UNCONSCIOUSNESS_LENGTH_MAX
Определения Silicosis.c:9
ref SymptomBase m_FaintSymptom
Определения Silicosis.c:26
const float HEAVY_BREATH_INTERVAL_MAX
seconds
Определения Silicosis.c:17
float m_NextUnconsciousnessEvent
Определения Silicosis.c:21
const float HEALTH_LOSS
Определения Silicosis.c:13
const int UNCON_THRESHOLD
Определения Silicosis.c:5
float m_HeavyBreathTimer
Определения Silicosis.c:22
bool ActivateCondition(PlayerBase player)
Определения Silicosis.c:36
static const float UNCONSCIOUSNESS_LENGTH_MIN
Unconsciousness.
Определения Silicosis.c:8
override void OnActivate(PlayerBase player)
Определения Silicosis.c:46
override void OnDeactivate(PlayerBase player)
Определения Silicosis.c:73
override bool DeactivateCondition(PlayerBase player)
Определения Silicosis.c:41
const int HEAVY_BREATH_TRESHOLD_MIN
Определения Silicosis.c:15
bool m_CanFaintEffectFadeOut
Определения Silicosis.c:19
static const float UNCONSCIOUSNESS_EVENT_INTERVAL_MIN
Определения Silicosis.c:10
float m_FaintEffectTime
Определения Silicosis.c:20
float m_AgentsCountPrevious
Определения Silicosis.c:24
float m_UnconciousnessActiveTimer
Определения Silicosis.c:20
const int HEALTH_THRESHOLD
Определения Silicosis.c:4
bool m_CanFaintEffectFadeIn
seconds
Определения Silicosis.c:19
override void Init()
Определения Silicosis.c:28
Определения Silicosis.c:2
Определения StateBase.c:2
ref TFloatArray m_FloatArray
Определения StateManager.c:53
ref TIntArray m_IntArray
Определения StateManager.c:52
Определения StateManager.c:51
eModifiers
Определения eModifiers.c:2
static float RandomFloat01()
Returns a random float number between and min [inclusive] and max [inclusive].
Определения EnMath.c:126
static proto int Randomize(int seed)
Sets the seed for the random number generator.
static proto float Lerp(float a, float b, float time)
Linearly interpolates between 'a' and 'b' given 'time'.
static float RandomFloatInclusive(float min, float max)
Returns a random float number between and min [inclusive] and max [inclusive].
Определения EnMath.c:106
static proto int RandomInt(int min, int max)
Returns a random int number between and min [inclusive] and max [exclusive].
static float Remap(float inputMin, float inputMax, float outputMin, float outputMax, float inputValue, bool clampedOutput=true)
Returns given value remaped from input range into output range.
Определения EnMath.c:740