DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
StaminaHandler.c
Go to the documentation of this file.
2{
3 MASK = 1,
7}
8
9
17{
18 protected float m_ActivationThreshold;
19 protected float m_DrainThreshold
20 protected bool m_State;
21
22 void StaminaConsumer(float threshold, float threshold2, bool state)
23 {
24 m_ActivationThreshold = threshold; //can be activated if above this threshold
25 m_DrainThreshold = threshold2; //can continually drain until it reaches this threshold
26 m_State = state;
27 }
28
29 bool GetState() { return m_State; }
30 void SetState(bool state) { m_State = state; }
31
33 void SetActivationThreshold(float threshold) { m_ActivationThreshold = threshold; }
34
35 float GetDrainThreshold() { return m_DrainThreshold; }
36 void SetDrainThreshold(float threshold) { m_DrainThreshold = threshold; }
37}
38
40{
42
44 {
46 }
47
48 void RegisterConsumer(EStaminaConsumers consumer, float threshold, float depletion_threshold = -1)
49 {
50 if (depletion_threshold == -1)
51 {
52 depletion_threshold = threshold;
53 }
54
55 if ( !m_StaminaConsumers.Contains(consumer) )
56 {
58 StaminaConsumer sc = new StaminaConsumer(threshold, depletion_threshold, true);
59 m_StaminaConsumers.Set(consumer, sc);
60 }
61 }
62
63 bool HasEnoughStaminaFor(EStaminaConsumers consumer, float curStamina, bool isDepleted, float cap)
64 {
65 if ( m_StaminaConsumers && m_StaminaConsumers.Contains(consumer) )
66 {
67 StaminaConsumer sc = m_StaminaConsumers.Get(consumer);
68
69 if ( consumer != EStaminaConsumers.SPRINT )
70 {
71 if ( (isDepleted || (curStamina < sc.GetDrainThreshold()/* && curStamina < cap*/)) )
72 {
73 sc.SetState(false);
74 return false;
75 }
76 }
77 else
78 {
79 if ( !isDepleted )
80 {
81 if ( sc.GetState() )
82 {
83 sc.SetState(true);
84 return true;
85 }
86 }
87 else
88 {
89 sc.SetState(false);
90 return false;
91 }
92 }
93
94 if ( curStamina > sc.GetDrainThreshold() || curStamina == cap ) //Sometimes player can't go up to drain threshold
95 {
96 sc.SetState(true);
97 return true;
98 }
99 }
100
101 return false;
102 }
103
104 bool HasEnoughStaminaToStart(EStaminaConsumers consumer, float curStamina, bool isDepleted, float cap)
105 {
106 if ( m_StaminaConsumers && m_StaminaConsumers.Contains(consumer) )
107 {
108 StaminaConsumer sc = m_StaminaConsumers.Get(consumer);
109
110 if ( (isDepleted || (curStamina < sc.GetActivationThreshold() && curStamina < cap)) )
111 {
112 sc.SetState(false);
113 return false;
114 }
115 else
116 {
117 sc.SetState(true);
118 return true;
119 }
120 }
121
122 return false;
123 }
124}
125
126
135class StaminaModifier
136{
137 bool m_InUse = false;
140
141 void StaminaModifier(int type, float min, float max, float cooldown, float startTime = 0, float duration = 0)
142 {
143 m_Type = type;
144 m_MinValue = min;
145 m_MaxValue = max;
146 m_Cooldown = cooldown;
147 m_StartTime = startTime;
148 m_Duration = duration;
149 m_Tick = 1;
150 }
151
152 int GetType() { return m_Type; }
153
154 float GetMinValue() { return m_MinValue; }
155 void SetMinValue(float val) { m_MinValue = val; }
156
157 float GetMaxValue() { return m_MaxValue; }
158 void SetMaxValue(float val) { m_MaxValue = val; }
159
160 float GetCooldown() { return m_Cooldown; }
161 void SetCooldown(float val) { m_Cooldown = val; }
162
163 float GetStartTime() { return m_StartTime; }
164 void SetStartTime(float val) { m_StartTime = val; }
165
166 float GetDuration() { return m_Duration; }
168
169 bool IsInUse() { return m_InUse; }
170 void SetInUse(bool val) { m_InUse = val; }
171
172 float GetRunTime() { return m_ProgressTime; }
173 void AddRunTime(float val) { m_ProgressTime += val; }
174 void SetRunTimeTick(float val) { m_Tick = val; }
176}
177
179{
180 const int FIXED = 0;
181 const int RANDOMIZED = 1;
182 const int LINEAR = 2; //Useful ONLY for regular, over-time stamina drain
183 const int EXPONENTIAL = 3; //Useful ONLY for regular, over-time stamina drain
184
186
188 {
190 }
191
194 {
195 if ( !m_StaminaModifiers.Contains(modifier) )
196 {
198 StaminaModifier sm = new StaminaModifier(FIXED, -1, value, cooldown);
199 m_StaminaModifiers.Set(modifier, sm);
200 }
201 }
202
204 void RegisterRandomized(EStaminaModifiers modifier, float minValue, float maxValue, float cooldown = GameConstants.STAMINA_REGEN_COOLDOWN_DEPLETION)
205 {
206 if ( !m_StaminaModifiers.Contains(modifier) )
207 {
209 StaminaModifier sm = new StaminaModifier(RANDOMIZED, minValue, maxValue, cooldown);
210 m_StaminaModifiers.Set(modifier, sm);
211 }
212 }
213
215 void RegisterLinear(EStaminaModifiers modifier, float startValue, float endValue, float startTime, float duration, float cooldown = GameConstants.STAMINA_REGEN_COOLDOWN_DEPLETION)
216 {
217 StaminaModifier sm = new StaminaModifier(LINEAR, startValue, endValue, cooldown, startTime, duration);
218 m_StaminaModifiers.Set(modifier, sm);
219 }
220
222 void RegisterExponential(EStaminaModifiers modifier, float startValue, float exponent, float startTime, float duration, float cooldown = GameConstants.STAMINA_REGEN_COOLDOWN_DEPLETION)
223 {
224 StaminaModifier sm = new StaminaModifier(EXPONENTIAL, startValue, exponent, cooldown, startTime, duration);
225 m_StaminaModifiers.Set(modifier, sm);
226 }
227
229 {
230 return m_StaminaModifiers.Get(modifier);
231 }
232}
233
234
235class StaminaHandler
236{
237 protected float m_PlayerLoad;
238 protected float m_StaminaDelta;
239 protected float m_Stamina;
240 protected float m_StaminaSynced; //guaranteed to be identical on server and client
241 protected float m_StaminaCap;
242 protected float m_StaminaDepletion;
243 protected float m_StaminaDepletionMultiplier; //controls depletion rate
244 protected float m_StaminaRecoveryMultiplier; //controls recovery rate
245 protected float m_Time;
246 protected ref Param3<float,float,bool> m_StaminaParams;
247 protected ref HumanMovementState m_State;
250
251 protected bool m_Debug;
252 protected bool m_StaminaDepleted;
253
256 ref set<EStaminaMultiplierTypes> m_ActiveDepletionModifiers;
257
259 ref set<EStaminaMultiplierTypes> m_ActiveRecoveryModifiers;
260
261 protected bool m_IsInCooldown;
262
265
266 #ifdef DIAG_DEVELOPER
267 protected bool m_StaminaEnabled = true;
268 #endif
269
271 {
272 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
273 {
274 m_StaminaParams = new Param3<float,float,bool>(0,0, false);
275 }
277 m_Player = player;
283 m_Time = 0;
284 m_StaminaDepleted = false;
285 m_IsInCooldown = false;
286 m_HumanMoveSettings = m_Player.GetDayZPlayerType().CommandMoveSettingsW();
287
290
292
293 //----------------- depletion --------------------
295 m_ActiveDepletionModifiers = new set<EStaminaMultiplierTypes>;
296
297 //----------------- recovery --------------------
299 m_ActiveRecoveryModifiers = new set<EStaminaMultiplierTypes>;
300
301 Init();
302 }
303
304
305 void Init()
306 {
307 //----------------- depletion --------------------
311
312 //----------------- recovery --------------------
316
317 }
318
320 {
321 if (m_RegisteredDepletionModifiers.Contains(type))
322 {
323 m_ActiveDepletionModifiers.Insert(type);
325 }
326 else
327 {
328 Error("attempting to activate unregistered depletion modifier");
329 }
330 }
331
333 {
334 int index = m_ActiveDepletionModifiers.Find(type);
335 if (index != -1)
336 {
337 m_ActiveDepletionModifiers.Remove(index);
339 }
340 }
341
343 {
344 float value = 1;
345
346 foreach (int multiplier: m_ActiveDepletionModifiers)
347 {
348 value *= m_RegisteredDepletionModifiers.Get(multiplier);
349 }
350
351 if (value != m_StaminaDepletionMultiplier)
353 }
354
356 {
357 if (m_RegisteredRecoveryModifiers.Contains(type))
358 {
359 m_ActiveRecoveryModifiers.Insert(type);
361 }
362 else
363 {
364 Error("attempting to activate unregistered recovery modifier");
365 }
366 }
367
368
370 {
371 int index = m_ActiveRecoveryModifiers.Find(type);
372 if (index != -1)
373 {
374 m_ActiveRecoveryModifiers.Remove(index);
376 }
377 }
378
380 {
381 float value = 1;
382
383 foreach (int multiplier: m_ActiveRecoveryModifiers)
384 {
385 value *= m_RegisteredRecoveryModifiers.Get(multiplier);
386 }
387
388 if (value != m_StaminaRecoveryMultiplier)
389 {
391 }
392 }
393
394 void Update(float deltaT, int pCurrentCommandID)
395 {
396 #ifdef DIAG_DEVELOPER
397 if (!m_StaminaEnabled || DiagMenu.GetBool(DiagMenuIDs.CHEATS_DISABLE_STAMINA))
398 {
399 return;
400 }
401 #endif
402 if (m_Player)
403 {
404 // Calculates actual max stamina based on player's load
405 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
406 {
408 m_PlayerLoad = m_Player.GetWeightEx();
409
412 {
414 }
415 else
416 {
418 }
419 }
420
421 // Calculates stamina gain/loss based on movement and load
422 m_Player.GetMovementState(m_State);
423
424 switch (pCurrentCommandID)
425 {
426 case DayZPlayerConstants.COMMANDID_MOVE:
428 break;
429 case DayZPlayerConstants.COMMANDID_LADDER:
431 break;
432 case DayZPlayerConstants.COMMANDID_SWIM:
434 break;
435 case DayZPlayerConstants.COMMANDID_FALL:
436 case DayZPlayerConstants.COMMANDID_MELEE2:
437 case DayZPlayerConstants.COMMANDID_CLIMB:
438 break;
439 default:
440 if (!m_IsInCooldown)
441 {
443 }
444 break;
445 }
446
447 //Sets current stamina & stores + syncs data with client
448 float temp = m_StaminaDelta * deltaT;
449 if (temp < 0)
450 {
452 }
453 else
454 {
456 }
457
460
461 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
462 {
463 m_Player.GetStatStamina().Set(m_Stamina);
464 m_Time += deltaT;
465
467 {
468 m_Time = 0;
470 }
471 }
472
473 #ifndef SERVER
475 #endif
476
479
480 m_StaminaDelta = 0;
481 m_StaminaDepletion = 0; // resets depletion modifier
482
483 }
484 }
485
487 void OnRPC(float stamina, float stamina_cap, bool cooldown)
488 {
489 }
490
492 void OnSyncJuncture(int pJunctureID, ParamsReadContext pCtx)
493 {
494 switch ( pJunctureID )
495 {
497 float stamina;
498 float stamina_cap;
499 bool cooldown;
500
501 if (!pCtx.Read(stamina) || !pCtx.Read(stamina_cap) || !pCtx.Read(cooldown))
502 {
503 return;
504 }
505
506 m_Stamina = stamina; //?
507 m_StaminaSynced = stamina;
508
509 if (m_Player.GetInstanceType() != DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
510 {
511 return;
512 }
513
514 if ( stamina_cap != m_StaminaCap )
515 {
516 m_StaminaCap = stamina_cap;
517 }
518
519 m_IsInCooldown = cooldown;
520 m_Player.SetStamina(m_Stamina, m_StaminaCap);
521 break;
522
525 break;
526 }
527 }
528
529 protected void StaminaProcessor_Move(HumanMovementState pHumanMovementState)
530 {
531 switch (pHumanMovementState.m_iMovement)
532 {
533 case DayZPlayerConstants.MOVEMENTIDX_SPRINT: //sprint
534 if (pHumanMovementState.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_ERECT)
535 {
538 break;
539 }
540 else if ( pHumanMovementState.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_CROUCH)
541 {
544 break;
545 }
546
548 break;
549
550 case DayZPlayerConstants.MOVEMENTIDX_RUN: //jog
551 if (m_Player.GetCurrentWaterLevel() >= m_HumanMoveSettings.m_fWaterLevelSpeedRectrictionHigh)
552 {
554 break;
555 }
556
557 if (!m_IsInCooldown)
558 {
560 }
561 break;
562
563 case DayZPlayerConstants.MOVEMENTIDX_WALK: //walk
564 if (!m_IsInCooldown)
565 {
567 }
568 break;
569
570 case DayZPlayerConstants.MOVEMENTIDX_IDLE: //idle
571 if (m_Player.IsRolling())
572 {
574 break;
575 }
576
577 if (!m_IsInCooldown)
578 {
580 }
581 break;
582
583 default:
584 if (!m_IsInCooldown)
585 {
587 }
588 break;
589 }
590 }
591
592 protected void StaminaProcessor_Ladder(HumanMovementState pHumanMovementState)
593 {
594 switch (pHumanMovementState.m_iMovement)
595 {
596 case 2: //climb up (fast)
599 break;
600
601 case 1: //climb up (slow)
602 if (!m_IsInCooldown)
603 {
605 }
606 break;
607
608 default:
609 if (!m_IsInCooldown)
610 {
612 }
613 break;
614 }
615 }
616
617 protected void StaminaProcessor_Swimming(HumanMovementState pHumanMovementState)
618 {
619 switch (pHumanMovementState.m_iMovement)
620 {
621 case 3: //swim fast
624 break;
625
626
627 case 2: //swim slow
628 if (!m_IsInCooldown)
629 {
631 }
632 break;
633
634 default:
635 if (!m_IsInCooldown)
636 {
638 }
639 break;
640 }
641 }
642
644 protected void SyncStamina(float stamina, float stamina_cap, bool cooldown)
645 {
646 m_Player.GetStatStamina().Set(m_Stamina);
648 pCtx.Write(m_Stamina);
649 pCtx.Write(m_StaminaCap);
650 pCtx.Write(m_IsInCooldown);
651 m_Player.SendSyncJuncture(DayZPlayerSyncJunctures.SJ_STAMINA,pCtx);
652 }
653
656 {
658
660 pCtx.Write(p.param1);
661 pCtx.Write(p.param2);
662 m_Player.SendSyncJuncture(DayZPlayerSyncJunctures.SJ_STAMINA_MISC,pCtx);
663 }
664
667 {
668 float depletionMultiplier;
669 float recoveryMultiplier;
670 if (!pCtx.Read(depletionMultiplier) || !pCtx.Read(recoveryMultiplier))
671 {
672 return;
673 }
674
675 m_StaminaDepletionMultiplier = depletionMultiplier;
676 m_StaminaRecoveryMultiplier = recoveryMultiplier;
677 }
678
680 {
691 m_StaminaConsumers.RegisterConsumer(EStaminaConsumers.DROWN,0);
692 }
693
695 {
708 }
709
711 protected float CalcStaminaGainBonus()
712 {
713 if (m_StaminaDepletion > 0)
714 return 0;
715
716 if (m_Stamina > 25)
717 return Math.Min((m_Stamina/10),GameConstants.STAMINA_GAIN_BONUS_CAP); // exp version
718 else
719 return GameConstants.STAMINA_GAIN_BONUS_CAP; // linear version
720 }
721
722 protected void ApplyExhaustion()
723 {
725 HumanCommandAdditives ad = m_Player.GetCommandModifier_Additives();
726
727 float exhaustion_value = 1;
728 if (m_StaminaCap != 0)
729 {
730 exhaustion_value = 1 - ((m_Stamina / (m_StaminaCap * 0.01)) * 0.01);
731 }
732
733 exhaustion_value = Math.Min(1, exhaustion_value);
734 if (ad)
735 {
736 // do not apply exhaustion on local client if player is in ADS/Optics (camera shakes)
737 if (m_Player.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT && (m_Player.IsInOptics() || m_Player.IsInIronsights()))
738 {
739 ad.SetExhaustion(0, true);
740 }
741 else
742 {
743 ad.SetExhaustion(exhaustion_value, true);
744 }
745 }
746 }
747
749 protected void CheckStaminaState()
750 {
751 if (m_Stamina <= 0)
752 {
753 m_StaminaDepleted = true;
755 if (!m_IsInCooldown)
756 {
757 // set this only once
759 }
760 }
761 else
762 {
763 m_StaminaDepleted = false;
764 }
765 }
766
768 protected void SetCooldown(float time, int modifier = -1)
769 {
770 if ( m_StaminaDepleted || m_Stamina <= 0.0 )
771 {
772 ResetCooldown(modifier);
773 return;
774 }
775
776 m_IsInCooldown = true;
777
778 Timer timer;
779 if (m_TimerMap.Find(modifier, timer) && timer.IsRunning())
780 {
781 timer.Stop();
782 }
783 else
784 {
785 timer = new ref Timer;
786 m_TimerMap.Set(modifier,timer);
787 }
788 timer.Run(time, this, "ResetCooldown", new Param1<int>( modifier ));
789 //Print(m_TimerMap.Count());
790 }
791
792 protected void ResetCooldown(int modifier = -1)
793 {
795 if (sm)
796 {
797 //Print(modifier);
798 //Error("Error: No StaminaModifier found! | StaminaHandler | ResetCooldown");
799 sm.SetStartTime(-1);
800 sm.ResetRunTime();
801 sm.SetInUse(false);
802 }
803 m_IsInCooldown = false;
804 }
805
807 {
808
809 }
810
811 // ---------------------------------------------------
813 {
814 return m_StaminaConsumers.HasEnoughStaminaFor(consumer, m_Stamina, m_StaminaDepleted, m_StaminaCap);
815 }
816
818 {
819 return m_StaminaConsumers.HasEnoughStaminaToStart(consumer, m_Stamina, m_StaminaDepleted, m_StaminaCap);
820 }
821
822 void SetStamina(float stamina_value)
823 {
824 m_Stamina = Math.Clamp(stamina_value, 0, CfgGameplayHandler.GetStaminaMax());
826 }
827
829 {
830 return m_Stamina;
831 }
832
834 {
835 return m_Stamina / GetStaminaMax();
836 }
837
839 {
840 return m_StaminaSynced;
841 }
842
844 {
845 return GetSyncedStamina() / GetStaminaMax();
846 }
847
849 {
850 return m_StaminaCap;
851 }
852
854 {
856 }
857
858 //obsolete, use ActivateDepletionModifier/DeactivateDepletionModifier instead
860 {
865 }
866 //obsolete, use ActivateRecoveryModifier/DeactivateRecoveryModifier instead
867 void SetRecoveryMultiplier(float val)
868 {
873 }
874
876 {
878 }
879
881 {
883 }
884
885 void DepleteStamina(EStaminaModifiers modifier, float dT = -1)
886 {
887 #ifdef DIAG_DEVELOPER
888 if (!m_StaminaEnabled || DiagMenu.GetBool(DiagMenuIDs.CHEATS_DISABLE_STAMINA))
889 {
890 return;
891 }
892 #endif
893 float val = 0.0;
894 float current_time = m_Player.GetSimulationTimeStamp();
895 float time;
897
898 // select by modifier type and drain stamina
899 switch (sm.GetType())
900 {
902 if (dT == -1)
903 {
904 dT = 1;
905 }
906 m_StaminaDepletion = m_StaminaDepletion + sm.GetMaxValue() * dT;
907 break;
908
910 val = Math.RandomFloat(sm.GetMinValue(), sm.GetMaxValue());
912 break;
913
915 if (!sm.IsInUse())
916 {
917 sm.SetStartTime(current_time + ( (PlayerSwayConstants.SWAY_TIME_IN + PlayerSwayConstants.SWAY_TIME_STABLE) / dT ) );
918 sm.SetRunTimeTick(dT);
919 sm.SetInUse(true);
920 }
921 time = Math.Clamp( ((current_time - sm.GetStartTime()) / sm.GetDurationAdjusted()), 0, 1 );
922 val = Math.Lerp(sm.GetMinValue(), sm.GetMaxValue(), time);
924
925 break;
926
928 if (!sm.IsInUse())
929 {
930 sm.SetStartTime(current_time + ( (PlayerSwayConstants.SWAY_TIME_IN + PlayerSwayConstants.SWAY_TIME_STABLE) / dT ) );
931 sm.SetRunTimeTick(dT);
932 sm.SetInUse(true);
933 }
934 time = Math.Clamp( ((current_time - sm.GetStartTime()) / sm.GetDurationAdjusted()), 0, 1 );
935 float exp;
936 if (sm.GetMinValue() < 1)
937 {
938 exp = 1 - Math.Lerp(0, sm.GetMaxValue(), time);
939 }
940 else
941 {
942 exp = Math.Lerp(0, sm.GetMaxValue(), time);
943 }
944 val = Math.Pow(sm.GetMinValue(),exp);
946
947 break;
948 }
949
951 SetCooldown(sm.GetCooldown(),modifier);
953
955 }
956
957 #ifdef DIAG_DEVELOPER
958 void SetStaminaEnabled(bool value)
959 {
960 m_StaminaEnabled = value;
961 }
962 #endif
963};
eBleedingSourceType m_Type
eBleedingSourceType GetType()
float m_Duration
override Widget Init()
Definition DayZGame.c:122
DiagMenuIDs
Definition EDiagMenuIDs.c:2
EStaminaConsumers
EStaminaModifiers
void OnSyncJuncture(int pJunctureID, ParamsReadContext pCtx)
DayZPlayer m_Player
Definition Hand_Events.c:42
void StaminaConsumer(float threshold, float threshold2, bool state)
ref map< EStaminaMultiplierTypes, float > m_RegisteredDepletionModifiers
bool HasEnoughStaminaToStart(EStaminaConsumers consumer, float curStamina, bool isDepleted, float cap)
protected SHumanCommandMoveSettings m_HumanMoveSettings
m_ActivationThreshold
protected float m_Stamina
protected float CalcStaminaGainBonus()
Calulates stamina regain bonus coef based on current stamina cap and level.
void SetDepletionMultiplier(float val)
void SetRecoveryMultiplier(float val)
EStaminaMultiplierTypes
DROWNING
protected bool m_StaminaDepleted
DEPRECATED.
float GetMinValue()
float m_MaxValue
void SetMaxValue(float val)
float m_ProgressTime
void StaminaModifier(int type, float min, float max, float cooldown, float startTime=0, float duration=0)
protected float m_StaminaDepletionMultiplier
protected void RegisterStaminaConsumers()
void StaminaHandler(PlayerBase player)
protected float m_Time
void SetActivationThreshold(float threshold)
void ResetRunTime()
FATIGUE
float m_Tick
void SetStartTime(float val)
float GetRecoveryMultiplier()
void SetInUse(bool val)
void RecalculateDepletionMultiplier()
protected void StaminaProcessor_Ladder(HumanMovementState pHumanMovementState)
m_InUse
void SetDrainThreshold(float threshold)
protected void RegisterStaminaModifiers()
float GetSyncedStaminaNormalized()
void SetState(bool state)
float GetMaxValue()
void ActivateDepletionModifier(EStaminaMultiplierTypes type)
float GetStaminaNormalized()
protected bool m_IsInCooldown
bool IsInUse()
protected void SyncStamina(float stamina, float stamina_cap, bool cooldown)
stamina sync - server part
float m_StartTime
float GetSyncedStamina()
void SetStamina(float stamina_value)
void DepleteStamina(EStaminaModifiers modifier, float dT=-1)
float GetDrainThreshold()
float m_MinValue
protected void StaminaProcessor_Swimming(HumanMovementState pHumanMovementState)
float GetActivationThreshold()
protected float m_StaminaSynced
protected ref map< int, ref Timer > m_TimerMap
protected void ApplyExhaustion()
protected void ReadAdditionalStaminaInfo(ParamsReadContext pCtx)
Order of read parameters must match the order of writing above.
protected void SyncAdditionalStaminaInfo(Param par)
Method to sync more info for stamina manager. Template parameter means it is very extendable for furt...
void OnRPC(float stamina, float stamina_cap, bool cooldown)
deprecated use, StaminaHandler uses SyncJunctures now
void SetRunTimeTick(float val)
ref map< EStaminaMultiplierTypes, float > m_RegisteredRecoveryModifiers
protected float m_StaminaDepletion
float GetStaminaCap()
class StaminaModifiers m_PlayerLoad
protected ref StaminaModifiers m_StaminaModifiers
ref set< EStaminaMultiplierTypes > m_ActiveDepletionModifiers
void SetMinValue(float val)
protected void ResetCooldown(int modifier=-1)
protected void CheckStaminaState()
check if the stamina is completely depleted
protected float m_StaminaRecoveryMultiplier
float GetRunTime()
protected float m_StaminaDelta
protected void StaminaProcessor_Move(HumanMovementState pHumanMovementState)
Timer GetCooldownTimer(int modifier)
protected ref map< EStaminaConsumers, ref StaminaConsumer > m_StaminaConsumers
void ActivateRecoveryModifier(EStaminaMultiplierTypes type)
EPINEPHRINE
float GetStartTime()
void SetCooldown(float val)
float GetStaminaMax()
protected ref Param3< float, float, bool > m_StaminaParams
protected float m_StaminaCap
MASK
void DeactivateRecoveryModifier(EStaminaMultiplierTypes type)
void DeactivateDepletionModifier(EStaminaMultiplierTypes type)
bool HasEnoughStaminaFor(EStaminaConsumers consumer, float curStamina, bool isDepleted, float cap)
float GetCooldown()
float GetDurationAdjusted()
float GetDepletionMultiplier()
float m_Cooldown
float GetStamina()
void AddRunTime(float val)
ref set< EStaminaMultiplierTypes > m_ActiveRecoveryModifiers
void RecalculateRecoveryMultiplier()
protected bool m_Debug
protected float m_DrainThreshold protected bool m_State
static float GetObstacleTraversalStaminaModifier()
static float GetStaminaMinCap()
static float GetStaminaKgToStaminaPercentPenalty()
static float GetSprintSwimmingStaminaModifier()
static float GetHoldBreathStaminaModifier()
static float GetSprintLadderStaminaModifier()
static float GetSprintStaminaModifierCro()
static float GetSprintStaminaModifierErc()
static float GetStaminaWeightLimitThreshold()
static float GetMeleeStaminaModifier()
static float GetStaminaMax()
override float GetCurrentWaterLevel()
static const float STAMINA_RECOVERY_MULTIPLIER
Definition Drowning.c:4
const float STAMINA_DEPLETION_MULTIPLIER
static const float STAMINA_DEPLETION_MULTIPLIER
Definition Fatigue.c:9
static const float STAMINA_RECOVERY_MULTIPLIER
Definition Fatigue.c:8
int m_iStanceIdx
current command's id
Definition human.c:1117
int m_iMovement
current stance (DayZPlayerConstants.STANCEIDX_ERECT, ...), only if the command has a stance
Definition human.c:1118
Definition Mask.c:2
const float STAMINA_DEPLETION_MODIFIER
Definition Mask.c:7
const float STAMINA_RECOVERY_MODIFIER
Definition Mask.c:6
Definition EnMath.c:7
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition param.c:12
Serialization general interface. Serializer API works with:
Definition Serializer.c:56
proto bool Write(void value_out)
proto bool Read(void value_in)
bool HasEnoughStaminaToStart(EStaminaConsumers consumer, float curStamina, bool isDepleted, float cap)
void RegisterConsumer(EStaminaConsumers consumer, float threshold, float depletion_threshold=-1)
bool HasEnoughStaminaFor(EStaminaConsumers consumer, float curStamina, bool isDepleted, float cap)
protected ref map< EStaminaConsumers, ref StaminaConsumer > m_StaminaConsumers
void RegisterLinear(EStaminaModifiers modifier, float startValue, float endValue, float startTime, float duration, float cooldown=GameConstants.STAMINA_REGEN_COOLDOWN_DEPLETION)
register lerped modifier - depletes stamina for startValue, and, after a startTime,...
protected ref map< EStaminaModifiers, ref StaminaModifier > m_StaminaModifiers
void RegisterExponential(EStaminaModifiers modifier, float startValue, float exponent, float startTime, float duration, float cooldown=GameConstants.STAMINA_REGEN_COOLDOWN_DEPLETION)
register exponential modifier - depletes stamina for startValue, and, after a startTime,...
void RegisterFixed(EStaminaModifiers modifier, float value, float cooldown=GameConstants.STAMINA_REGEN_COOLDOWN_DEPLETION)
register single value modifier - depletes stamina for that value
StaminaModifier GetModifierData(EStaminaModifiers modifier)
void RegisterRandomized(EStaminaModifiers modifier, float minValue, float maxValue, float cooldown=GameConstants.STAMINA_REGEN_COOLDOWN_DEPLETION)
register randomized modifier - stamina will be depleted by value between min and max value;
override void Stop()
DayZPlayerInstanceType
defined in C++
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:602
proto native CGame GetGame()
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90
static proto bool GetBool(int id, bool reverse=false)
Get value as bool from the given script id.
static proto float Max(float x, float y)
Returns bigger of two given values.
static proto float Pow(float v, float power)
Return power of v ^ power.
static proto float Clamp(float value, float min, float max)
Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'.
static proto float RandomFloat(float min, float max)
Returns a random float number between and min[inclusive] and max[exclusive].
static proto float Min(float x, float y)
Returns smaller of two given values.
static proto float Lerp(float a, float b, float time)
Linearly interpolates between 'a' and 'b' given 'time'.
const float STAMINA_JUMP_THRESHOLD
Definition constants.c:635
const int STAMINA_GAIN_SWIM_PER_SEC
Definition constants.c:626
const float STAMINA_DRAIN_HOLD_BREATH_START
Definition constants.c:610
const float STAMINA_DRAIN_CLIMB
Definition constants.c:614
const float STAMINA_VAULT_THRESHOLD
Definition constants.c:636
const float STAMINA_REGEN_COOLDOWN_EXHAUSTION
Definition constants.c:644
const float STAMINA_CLIMB_THRESHOLD
Definition constants.c:637
const float STAMINA_KG_TO_GRAMS
in grams (weight where the player is not penalized by stamina)
Definition constants.c:646
const float STAMINA_DRAIN_MELEE_LIGHT
Definition constants.c:615
const float STAMINA_DRAIN_VAULT
Definition constants.c:613
const float STAMINA_SYNC_RATE
Definition constants.c:647
const int STAMINA_GAIN_IDLE_PER_SEC
Definition constants.c:625
const int STAMINA_GAIN_ROLL_PER_SEC
Definition constants.c:628
const float STAMINA_MELEE_EVADE_THRESHOLD
Definition constants.c:642
const int STAMINA_GAIN_JOG_PER_SEC
Definition constants.c:623
const float STAMINA_DRAIN_MELEE_HEAVY
Definition constants.c:616
const float STAMINA_DRAIN_HOLD_BREATH_DURATION
Definition constants.c:620
const float STAMINA_DRAIN_JUMP
Definition constants.c:612
const float STAMINA_MELEE_HEAVY_THRESHOLD
Definition constants.c:641
const float STAMINA_DRAIN_MELEE_EVADE
Definition constants.c:617
const int STAMINA_DRAIN_SWIM_FAST_PER_SEC
Definition constants.c:607
const float STAMINA_GAIN_BONUS_CAP
Definition constants.c:629
const int STAMINA_DRAIN_STANDING_SPRINT_PER_SEC
Definition constants.c:604
const float STAMINA_ROLL_THRESHOLD
Definition constants.c:638
const float STAMINA_DRAIN_HOLD_BREATH_EXPONENT
Definition constants.c:621
const float STAMINA_REGEN_COOLDOWN_DEPLETION
Definition constants.c:643
const float STAMINA_HOLD_BREATH_THRESHOLD_DRAIN
Definition constants.c:634
const int STAMINA_DRAIN_LADDER_FAST_PER_SEC
Definition constants.c:608
const float STAMINA_DRAIN_ROLL
Definition constants.c:618
const int STAMINA_DRAIN_CROUCHED_SPRINT_PER_SEC
Definition constants.c:605
const int STAMINA_GAIN_LADDER_PER_SEC
Definition constants.c:627
const int STAMINA_GAIN_WALK_PER_SEC
Definition constants.c:624
const float STAMINA_HOLD_BREATH_THRESHOLD_ACTIVATE
Definition constants.c:633
float GetDuration()
Definition tools.c:310
proto native volatile void Update()
proto native int GetState()
returns one of STATE_...
class HumanCommandWeapons HumanCommandAdditives()
Definition human.c:1088
class SHumanGlobalSettings SHumanCommandMoveSettings()