DayZ 1.26
DayZ Explorer by KGB
Загрузка...
Поиск...
Не найдено
Класс StaminaHandler

Защищенные члены

void StaminaHandler (PlayerBase player)
 
void Init ()
 
void ActivateDepletionModifier (EStaminaMultiplierTypes type)
 
void DeactivateDepletionModifier (EStaminaMultiplierTypes type)
 
void RecalculateDepletionMultiplier ()
 
void ActivateRecoveryModifier (EStaminaMultiplierTypes type)
 
void DeactivateRecoveryModifier (EStaminaMultiplierTypes type)
 
void RecalculateRecoveryMultiplier ()
 
void Update (float deltaT, int pCurrentCommandID)
 
void OnRPC (float stamina, float stamina_cap, bool cooldown)
 deprecated use, StaminaHandler uses SyncJunctures now
 
void OnSyncJuncture (int pJunctureID, ParamsReadContext pCtx)
 called from PlayerBase - syncs stamina values on server with client AND sets the value to match on server and client both (m_StaminaSynced guarantees identical values)
 
void StaminaProcessor_Move (HumanMovementState pHumanMovementState)
 
void StaminaProcessor_Ladder (HumanMovementState pHumanMovementState)
 
void StaminaProcessor_Swimming (HumanMovementState pHumanMovementState)
 
void SyncStamina (float stamina, float stamina_cap, bool cooldown)
 stamina sync - server part
 
void SyncAdditionalStaminaInfo (Param par)
 Method to sync more info for stamina manager. Template parameter means it is very extendable for further use.
 
void ReadAdditionalStaminaInfo (ParamsReadContext pCtx)
 Order of read parameters must match the order of writing above.
 
void RegisterStaminaConsumers ()
 
void RegisterStaminaModifiers ()
 
float CalcStaminaGainBonus ()
 Calulates stamina regain bonus coef based on current stamina cap and level.
 
void ApplyExhaustion ()
 
void CheckStaminaState ()
 check if the stamina is completely depleted
 
void SetCooldown (float time, int modifier=-1)
 set cooldown timer between each consume of stamina

 
void ResetCooldown (int modifier=-1)
 
Timer GetCooldownTimer (int modifier)
 
bool HasEnoughStaminaFor (EStaminaConsumers consumer)
 
bool HasEnoughStaminaToStart (EStaminaConsumers consumer)
 
void SetStamina (float stamina_value)
 
float GetStamina ()
 
float GetStaminaNormalized ()
 
float GetSyncedStamina ()
 
float GetSyncedStaminaNormalized ()
 
float GetStaminaCap ()
 
float GetStaminaMax ()
 
void SetDepletionMultiplier (float val)
 
void SetRecoveryMultiplier (float val)
 
float GetDepletionMultiplier ()
 
float GetRecoveryMultiplier ()
 
void DepleteStamina (EStaminaModifiers modifier, float dT=-1)
 

Защищенные данные

float m_PlayerLoad
 
float m_StaminaDelta
 
float m_Stamina
 
float m_StaminaSynced
 
float m_StaminaCap
 
float m_StaminaDepletion
 
float m_StaminaDepletionMultiplier
 
float m_StaminaRecoveryMultiplier
 
float m_Time
 
ref Param3< float, float, boolm_StaminaParams
 
ref HumanMovementState m_State
 
SHumanCommandMoveSettings m_HumanMoveSettings
 
PlayerBase m_Player
 
bool m_Debug
 
bool m_StaminaDepleted
 DEPRECATED.
 
ref map< int, ref Timerm_TimerMap
 
ref map< EStaminaMultiplierTypes, floatm_RegisteredDepletionModifiers
 
ref set< EStaminaMultiplierTypesm_ActiveDepletionModifiers
 
ref map< EStaminaMultiplierTypes, floatm_RegisteredRecoveryModifiers
 
ref set< EStaminaMultiplierTypesm_ActiveRecoveryModifiers
 
bool m_IsInCooldown
 
ref StaminaConsumers m_StaminaConsumers
 
ref StaminaModifiers m_StaminaModifiers
 

Подробное описание

Конструктор(ы)

◆ StaminaHandler()

void StaminaHandler ( PlayerBase player)
inlineprotected
298 {
299 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
300 m_StaminaParams = new Param3<float,float,bool>(0, 0, false);
301
309 m_Time = 0;
310 m_StaminaDepleted = false;
311 m_IsInCooldown = false;
312 m_HumanMoveSettings = m_Player.GetDayZPlayerType().CommandMoveSettingsW();
313
316
318
319 //----------------- depletion --------------------
322
323 //----------------- recovery --------------------
326
327 Init();
328 }
Definition CfgGameplayHandler.c:2
static float GetStaminaMax()
Definition CfgGameplayHandler.c:207
Definition human.c:1139
Definition EntityAI.c:95
bool m_StaminaDepleted
DEPRECATED.
Definition StaminaHandler.c:279
float m_Stamina
Definition StaminaHandler.c:266
SHumanCommandMoveSettings m_HumanMoveSettings
Definition StaminaHandler.c:275
ref map< EStaminaMultiplierTypes, float > m_RegisteredDepletionModifiers
Definition StaminaHandler.c:282
void Init()
Definition StaminaHandler.c:331
ref HumanMovementState m_State
Definition StaminaHandler.c:274
float m_Time
Definition StaminaHandler.c:272
float m_StaminaDepletion
Definition StaminaHandler.c:269
PlayerBase m_Player
Definition StaminaHandler.c:276
void RegisterStaminaModifiers()
Definition StaminaHandler.c:748
float m_StaminaRecoveryMultiplier
Definition StaminaHandler.c:271
ref map< EStaminaMultiplierTypes, float > m_RegisteredRecoveryModifiers
Definition StaminaHandler.c:285
float m_StaminaCap
Definition StaminaHandler.c:268
ref set< EStaminaMultiplierTypes > m_ActiveDepletionModifiers
Definition StaminaHandler.c:283
float m_StaminaDepletionMultiplier
Definition StaminaHandler.c:270
ref Param3< float, float, bool > m_StaminaParams
Definition StaminaHandler.c:273
bool m_IsInCooldown
Definition StaminaHandler.c:288
ref map< int, ref Timer > m_TimerMap
Definition StaminaHandler.c:281
void RegisterStaminaConsumers()
Definition StaminaHandler.c:707
ref set< EStaminaMultiplierTypes > m_ActiveRecoveryModifiers
Definition StaminaHandler.c:286
proto native CGame GetGame()

Перекрестные ссылки GetGame(), CfgGameplayHandler::GetStaminaMax(), Init(), m_ActiveDepletionModifiers, m_ActiveRecoveryModifiers, m_HumanMoveSettings, m_IsInCooldown, m_Player, m_RegisteredDepletionModifiers, m_RegisteredRecoveryModifiers, m_Stamina, m_StaminaCap, m_StaminaDepleted, m_StaminaDepletion, m_StaminaDepletionMultiplier, m_StaminaParams, m_StaminaRecoveryMultiplier, m_State, m_Time, m_TimerMap, RegisterStaminaConsumers() и RegisterStaminaModifiers().

Методы

◆ ActivateDepletionModifier()

void ActivateDepletionModifier ( EStaminaMultiplierTypes type)
inlineprotected
350 {
351 if (m_RegisteredDepletionModifiers.Contains(type))
352 {
353 m_ActiveDepletionModifiers.Insert(type);
355 }
356 else
357 {
358 Error("attempting to activate unregistered depletion modifier");
359 }
360 }
void RecalculateDepletionMultiplier()
Definition StaminaHandler.c:372
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90

Перекрестные ссылки Error(), m_ActiveDepletionModifiers, m_RegisteredDepletionModifiers и RecalculateDepletionMultiplier().

◆ ActivateRecoveryModifier()

void ActivateRecoveryModifier ( EStaminaMultiplierTypes type)
inlineprotected
386 {
387 if (m_RegisteredRecoveryModifiers.Contains(type))
388 {
389 m_ActiveRecoveryModifiers.Insert(type);
391 }
392 else
393 {
394 Error("attempting to activate unregistered recovery modifier");
395 }
396 }
void RecalculateRecoveryMultiplier()
Definition StaminaHandler.c:409

Перекрестные ссылки Error(), m_ActiveRecoveryModifiers, m_RegisteredRecoveryModifiers и RecalculateRecoveryMultiplier().

◆ ApplyExhaustion()

void ApplyExhaustion ( )
inlineprotected

sets exhaustion look of player based on stamina level

808 {
810 HumanCommandAdditives ad = m_Player.GetCommandModifier_Additives();
811
812 float exhaustion_value = 1;
813 if (m_StaminaCap != 0)
814 {
815 exhaustion_value = 1 - ((m_Stamina / (m_StaminaCap * 0.01)) * 0.01);
816 }
817
819 if (ad)
820 {
821 // do not apply exhaustion on local client if player is in ADS/Optics (camera shakes)
822 if (m_Player.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT && (m_Player.IsInOptics() || m_Player.IsInIronsights()))
823 {
824 ad.SetExhaustion(0, true);
825 }
826 else
827 {
828 ad.SetExhaustion(exhaustion_value, true);
829 }
830 }
831 }
Definition EnMath.c:7
DayZPlayerInstanceType
defined in C++
Definition dayzplayer.c:1068
static proto float Min(float x, float y)
Returns smaller of two given values.
class HumanCommandWeapons HumanCommandAdditives()
Definition human.c:1112

Перекрестные ссылки HumanCommandAdditives(), m_Player, m_Stamina, m_StaminaCap и Math::Min().

Используется в Update().

◆ CalcStaminaGainBonus()

float CalcStaminaGainBonus ( )
inlineprotected

Calulates stamina regain bonus coef based on current stamina cap and level.

797 {
798 if (m_StaminaDepletion > 0)
799 return 0;
800
801 if (m_Stamina > 25)
802 return Math.Min((m_Stamina/10),GameConstants.STAMINA_GAIN_BONUS_CAP); // exp version
803 else
804 return GameConstants.STAMINA_GAIN_BONUS_CAP; // linear version
805 }
Definition constants.c:638
const float STAMINA_GAIN_BONUS_CAP
Definition constants.c:670

Перекрестные ссылки m_Stamina, m_StaminaDepletion, Math::Min() и GameConstants::STAMINA_GAIN_BONUS_CAP.

Используется в StaminaProcessor_Ladder(), StaminaProcessor_Move() и StaminaProcessor_Swimming().

◆ CheckStaminaState()

void CheckStaminaState ( )
inlineprotected

check if the stamina is completely depleted

in case of complete depletion - start a cooldown timer before the regeneration cycle start

835 {
836 if (m_Stamina <= 0)
837 {
838 m_StaminaDepleted = true;
840 if (!m_IsInCooldown)
841 {
842 // set this only once
844 }
845 }
846 else
847 {
848 m_StaminaDepleted = false;
849 }
850 }
void SetCooldown(float time, int modifier=-1)
set cooldown timer between each consume of stamina
Definition StaminaHandler.c:853
const float STAMINA_REGEN_COOLDOWN_EXHAUSTION
Definition constants.c:685

Перекрестные ссылки m_IsInCooldown, m_Stamina, m_StaminaDepleted, SetCooldown() и GameConstants::STAMINA_REGEN_COOLDOWN_EXHAUSTION.

Используется в Update().

◆ DeactivateDepletionModifier()

void DeactivateDepletionModifier ( EStaminaMultiplierTypes type)
inlineprotected
363 {
364 int index = m_ActiveDepletionModifiers.Find(type);
365 if (index != -1)
366 {
369 }
370 }

Перекрестные ссылки m_ActiveDepletionModifiers и RecalculateDepletionMultiplier().

◆ DeactivateRecoveryModifier()

void DeactivateRecoveryModifier ( EStaminaMultiplierTypes type)
inlineprotected
400 {
401 int index = m_ActiveRecoveryModifiers.Find(type);
402 if (index != -1)
403 {
406 }
407 }

Перекрестные ссылки m_ActiveRecoveryModifiers и RecalculateRecoveryMultiplier().

◆ DepleteStamina()

void DepleteStamina ( EStaminaModifiers modifier,
float dT = -1 )
inlineprotected

run cooldown right after depletion

971 {
972 #ifdef DIAG_DEVELOPER
974 return;
975 #endif
976 float val = 0.0;
977 float current_time = m_Player.GetSimulationTimeStamp();
978 float valueProgress;
979 StaminaModifier sm = m_StaminaModifiers.GetModifierData(modifier);
980
981 // select by modifier type and drain stamina
982 switch (sm.GetType())
983 {
984 case m_StaminaModifiers.FIXED:
985 if (dT == -1)
986 {
987 dT = 1;
988 }
989 m_StaminaDepletion = m_StaminaDepletion + sm.GetMaxValue() * dT;
990
991 break;
992
993 case m_StaminaModifiers.RANDOMIZED:
994 val = Math.RandomFloat(sm.GetMinValue(), sm.GetMaxValue());
996
997 break;
998
999 case m_StaminaModifiers.LINEAR:
1000 if (!sm.IsInUse())
1001 {
1002 sm.SetStartTime(current_time + sm.GetStartTimeAdjustment()/dT);
1003 sm.SetRunTimeTick(dT);
1004 sm.SetInUse(true);
1005 }
1006 valueProgress = Math.Clamp((current_time - sm.GetStartTime())/sm.GetDurationAdjusted(), 0, 1 );
1007 val = Math.Lerp(sm.GetMinValue(), sm.GetMaxValue(), valueProgress);
1009
1010 break;
1011
1012 case m_StaminaModifiers.EXPONENTIAL:
1014 if (!Class.CastTo(smex,sm))
1015 {
1016 ErrorEx("StaminaModifierExponential not found for modifier type: " + sm.GetType());
1017 break;
1018 }
1019
1020 if (!smex.IsInUse())
1021 {
1022 smex.SetStartTime(current_time + smex.GetStartTimeAdjustment()/dT);
1023 smex.SetRunTimeTick(dT);
1024 smex.SetInUse(true);
1025 }
1026 valueProgress = Math.Clamp((current_time - smex.GetStartTime())/smex.GetDurationAdjusted(), 0, 1 );
1027 float exp;
1028 if (Math.AbsFloat(smex.GetBaseValue()) < 1)
1029 {
1030 exp = 1 - Math.Lerp(0, smex.GetExponent(), valueProgress);
1031 val = Math.Pow(smex.GetBaseValue(),exp);
1032 }
1033 else
1034 {
1035 exp = Math.Lerp(Math.Min(0, smex.GetExponent()), Math.Max(0, smex.GetExponent()), valueProgress);
1036 val = Math.Pow(smex.GetBaseValue(),exp) + smex.GetBaseValue() - 1;
1037 }
1038
1040 m_StaminaDepletion *= smex.GetMultiplier();
1041
1042 break;
1043 }
1044
1046 SetCooldown(sm.GetCooldown(),modifier);
1048
1050 }
Super root of all classes in Enforce script.
Definition EnScript.c:11
ref StaminaModifiers m_StaminaModifiers
Definition StaminaHandler.c:291
Definition StaminaHandler.c:183
enum ShapeType ErrorEx
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
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 Lerp(float a, float b, float time)
Linearly interpolates between 'a' and 'b' given 'time'.
static proto float AbsFloat(float f)
Returns absolute value.

Перекрестные ссылки Math::AbsFloat(), Class::CastTo(), Math::Clamp(), ErrorEx, CfgGameplayHandler::GetStaminaMax(), Math::Lerp(), m_Player, m_StaminaDepletion, m_StaminaDepletionMultiplier, m_StaminaModifiers, Math::Max(), Math::Min(), Math::Pow(), Math::RandomFloat() и SetCooldown().

◆ GetCooldownTimer()

Timer GetCooldownTimer ( int modifier)
inlineprotected
892 {
893
894 }

◆ GetDepletionMultiplier()

float GetDepletionMultiplier ( )
inlineprotected
961 {
963 }

Перекрестные ссылки m_StaminaDepletionMultiplier.

◆ GetRecoveryMultiplier()

float GetRecoveryMultiplier ( )
inlineprotected
966 {
968 }

Перекрестные ссылки m_StaminaRecoveryMultiplier.

◆ GetStamina()

float GetStamina ( )
inlineprotected
914 {
915 return m_Stamina;
916 }

Перекрестные ссылки m_Stamina.

◆ GetStaminaCap()

float GetStaminaCap ( )
inlineprotected
934 {
935 return m_StaminaCap;
936 }

Перекрестные ссылки m_StaminaCap.

◆ GetStaminaMax()

float GetStaminaMax ( )
inlineprotected
939 {
941 }

Перекрестные ссылки CfgGameplayHandler::GetStaminaMax().

Используется в GetStaminaNormalized() и GetSyncedStaminaNormalized().

◆ GetStaminaNormalized()

float GetStaminaNormalized ( )
inlineprotected
919 {
920 return m_Stamina / GetStaminaMax();
921 }
float GetStaminaMax()
Definition StaminaHandler.c:938

Перекрестные ссылки GetStaminaMax() и m_Stamina.

◆ GetSyncedStamina()

float GetSyncedStamina ( )
inlineprotected
924 {
925 return m_StaminaSynced;
926 }
float m_StaminaSynced
Definition StaminaHandler.c:267

Перекрестные ссылки m_StaminaSynced.

Используется в GetSyncedStaminaNormalized().

◆ GetSyncedStaminaNormalized()

float GetSyncedStaminaNormalized ( )
inlineprotected
929 {
930 return GetSyncedStamina() / GetStaminaMax();
931 }
float GetSyncedStamina()
Definition StaminaHandler.c:923

Перекрестные ссылки GetStaminaMax() и GetSyncedStamina().

◆ HasEnoughStaminaFor()

bool HasEnoughStaminaFor ( EStaminaConsumers consumer)
inlineprotected
898 {
900 }
ref StaminaConsumers m_StaminaConsumers
Definition StaminaHandler.c:290

Перекрестные ссылки m_Stamina, m_StaminaCap, m_StaminaConsumers и m_StaminaDepleted.

◆ HasEnoughStaminaToStart()

bool HasEnoughStaminaToStart ( EStaminaConsumers consumer)
inlineprotected
903 {
904 return m_StaminaConsumers.HasEnoughStaminaToStart(consumer, m_Stamina, m_StaminaDepleted, m_StaminaCap);
905 }

Перекрестные ссылки m_Stamina, m_StaminaCap, m_StaminaConsumers и m_StaminaDepleted.

◆ Init()

void Init ( )
inlineprotected
332 {
333 //----------------- depletion --------------------
339
340 //----------------- recovery --------------------
346
347 }
EStaminaMultiplierTypes
Definition StaminaHandler.c:2
Definition Drowning.c:2
static const float STAMINA_RECOVERY_MULTIPLIER
Definition Drowning.c:3
Definition EpinephrineMdfr.c:2
const float STAMINA_DEPLETION_MULTIPLIER
Definition EpinephrineMdfr.c:4
Definition Fatigue.c:2
static const float STAMINA_DEPLETION_MULTIPLIER
Definition Fatigue.c:9
static const float STAMINA_RECOVERY_MULTIPLIER
Definition Fatigue.c:8
Definition Mask.c:2
const float STAMINA_DEPLETION_MODIFIER
Definition Mask.c:7
const float STAMINA_RECOVERY_MODIFIER
Definition Mask.c:6
Definition Pneumonia.c:2
const float STAMINA_DEPLETION_MULTIPLIER
Definition Pneumonia.c:6
const float STAMINA_RECOVERY_MULTIPLIER
Definition Pneumonia.c:7
Definition VomitState.c:2
static const float STAMINA_DEPLETION_MULTIPLIER
Definition VomitState.c:3
static const float STAMINA_RECOVERY_MULTIPLIER
Definition VomitState.c:4

Перекрестные ссылки m_RegisteredDepletionModifiers, m_RegisteredRecoveryModifiers, MaskMdfr::STAMINA_DEPLETION_MODIFIER, FatigueMdfr::STAMINA_DEPLETION_MULTIPLIER, PneumoniaMdfr::STAMINA_DEPLETION_MULTIPLIER, EpinephrineMdfr::STAMINA_DEPLETION_MULTIPLIER, VomitSymptom::STAMINA_DEPLETION_MULTIPLIER, MaskMdfr::STAMINA_RECOVERY_MODIFIER, FatigueMdfr::STAMINA_RECOVERY_MULTIPLIER, PneumoniaMdfr::STAMINA_RECOVERY_MULTIPLIER, DrowningMdfr::STAMINA_RECOVERY_MULTIPLIER и VomitSymptom::STAMINA_RECOVERY_MULTIPLIER.

Используется в StaminaHandler().

◆ OnRPC()

void OnRPC ( float stamina,
float stamina_cap,
bool cooldown )
inlineprotected

deprecated use, StaminaHandler uses SyncJunctures now

516 {
517 }

◆ OnSyncJuncture()

void OnSyncJuncture ( int pJunctureID,
ParamsReadContext pCtx )
inlineprotected

called from PlayerBase - syncs stamina values on server with client AND sets the value to match on server and client both (m_StaminaSynced guarantees identical values)

521 {
522 switch ( pJunctureID )
523 {
525 float stamina;
526 float stamina_cap;
527 bool cooldown;
528
529 if (!pCtx.Read(stamina) || !pCtx.Read(stamina_cap) || !pCtx.Read(cooldown))
530 {
531 return;
532 }
533
534 m_Stamina = stamina; //?
536
537 if (m_Player.GetInstanceType() != DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
538 {
539 return;
540 }
541
542 if ( stamina_cap != m_StaminaCap )
543 {
545 }
546
548 m_Player.SetStamina(m_Stamina, m_StaminaCap);
549 break;
550
553 break;
554 }
555 }
Definition DayZPlayerSyncJunctures.c:5
static const int SJ_STAMINA
Definition DayZPlayerSyncJunctures.c:29
static const int SJ_STAMINA_MISC
Definition DayZPlayerSyncJunctures.c:30
void ReadAdditionalStaminaInfo(ParamsReadContext pCtx)
Order of read parameters must match the order of writing above.
Definition StaminaHandler.c:694

Перекрестные ссылки m_IsInCooldown, m_Player, m_Stamina, m_StaminaCap, m_StaminaSynced, ReadAdditionalStaminaInfo(), DayZPlayerSyncJunctures::SJ_STAMINA и DayZPlayerSyncJunctures::SJ_STAMINA_MISC.

Используется в ManBase::OnSyncJuncture().

◆ ReadAdditionalStaminaInfo()

void ReadAdditionalStaminaInfo ( ParamsReadContext pCtx)
inlineprotected

Order of read parameters must match the order of writing above.

Перекрестные ссылки m_StaminaDepletionMultiplier и m_StaminaRecoveryMultiplier.

Используется в OnSyncJuncture().

◆ RecalculateDepletionMultiplier()

void RecalculateDepletionMultiplier ( )
inlineprotected
373 {
374 float value = 1;
375
377 {
379 }
380
383 }
void SetDepletionMultiplier(float val)
Definition StaminaHandler.c:944

Перекрестные ссылки m_ActiveDepletionModifiers, m_RegisteredDepletionModifiers, m_StaminaDepletionMultiplier и SetDepletionMultiplier().

Используется в ActivateDepletionModifier() и DeactivateDepletionModifier().

◆ RecalculateRecoveryMultiplier()

void RecalculateRecoveryMultiplier ( )
inlineprotected
410 {
411 float value = 1;
412
414 {
416 }
417
419 {
421 }
422 }
void SetRecoveryMultiplier(float val)
Definition StaminaHandler.c:952

Перекрестные ссылки m_ActiveRecoveryModifiers, m_RegisteredRecoveryModifiers, m_StaminaRecoveryMultiplier и SetRecoveryMultiplier().

Используется в ActivateRecoveryModifier() и DeactivateRecoveryModifier().

◆ RegisterStaminaConsumers()

void RegisterStaminaConsumers ( )
inlineprotected
708 {
710
711 m_StaminaConsumers.RegisterConsumer(
712 EStaminaConsumers.HOLD_BREATH,
715 );
716 m_StaminaConsumers.RegisterConsumer(
717 EStaminaConsumers.SPRINT,
719 );
720 m_StaminaConsumers.RegisterConsumer(
723 );
724 m_StaminaConsumers.RegisterConsumer(
725 EStaminaConsumers.VAULT,
727 );
728 m_StaminaConsumers.RegisterConsumer(
729 EStaminaConsumers.CLIMB,
731 );
732 m_StaminaConsumers.RegisterConsumer(
733 EStaminaConsumers.MELEE_HEAVY,
735 );
736 m_StaminaConsumers.RegisterConsumer(
737 EStaminaConsumers.MELEE_EVADE,
739 );
740 m_StaminaConsumers.RegisterConsumer(
743 );
744 m_StaminaConsumers.RegisterConsumer(EStaminaConsumers.DROWN, 0);
745 m_StaminaConsumers.RegisterConsumer(EStaminaConsumers.PUSH, 0);
746 }
EStaminaConsumers
Definition EStaminaConsumers.c:2
void StaminaConsumers()
Definition StaminaHandler.c:45
static float GetStaminaMinCap()
Definition CfgGameplayHandler.c:217
const float STAMINA_JUMP_THRESHOLD
Definition constants.c:676
const float STAMINA_VAULT_THRESHOLD
Definition constants.c:677
const float STAMINA_CLIMB_THRESHOLD
Definition constants.c:678
const float STAMINA_MELEE_EVADE_THRESHOLD
Definition constants.c:683
const float STAMINA_MELEE_HEAVY_THRESHOLD
Definition constants.c:682
const float STAMINA_ROLL_THRESHOLD
Definition constants.c:679
const float STAMINA_HOLD_BREATH_THRESHOLD_DRAIN
Definition constants.c:675
const float STAMINA_HOLD_BREATH_THRESHOLD_ACTIVATE
Definition constants.c:674

Перекрестные ссылки CfgGameplayHandler::GetStaminaMinCap(), m_StaminaConsumers, GameConstants::STAMINA_CLIMB_THRESHOLD, GameConstants::STAMINA_HOLD_BREATH_THRESHOLD_ACTIVATE, GameConstants::STAMINA_HOLD_BREATH_THRESHOLD_DRAIN, GameConstants::STAMINA_JUMP_THRESHOLD, GameConstants::STAMINA_MELEE_EVADE_THRESHOLD, GameConstants::STAMINA_MELEE_HEAVY_THRESHOLD, GameConstants::STAMINA_ROLL_THRESHOLD, GameConstants::STAMINA_VAULT_THRESHOLD и StaminaConsumers().

Используется в StaminaHandler().

◆ RegisterStaminaModifiers()

void RegisterStaminaModifiers ( )
inlineprotected
749 {
751
753 m_StaminaModifiers.RegisterExponentialEx(
754 EStaminaModifiers.HOLD_BREATH,
755 data,
756 );
757 m_StaminaModifiers.RegisterExponentialEx(
758 EStaminaModifiers.PUSH_CAR,
759 data,
760 );
761 m_StaminaModifiers.RegisterFixed(EStaminaModifiers.DROWN, 10);
762 m_StaminaModifiers.RegisterFixed(
765 );
766 m_StaminaModifiers.RegisterFixed(
767 EStaminaModifiers.VAULT,
769 );
770 m_StaminaModifiers.RegisterFixed(
771 EStaminaModifiers.CLIMB,
773 );
774 m_StaminaModifiers.RegisterFixed(
775 EStaminaModifiers.MELEE_LIGHT,
777 );
778 m_StaminaModifiers.RegisterFixed(
779 EStaminaModifiers.MELEE_HEAVY,
781 );
782 m_StaminaModifiers.RegisterFixed(
783 EStaminaModifiers.OVERALL_DRAIN,
785 5.0,
786 );
787 m_StaminaModifiers.RegisterRandomized(
788 EStaminaModifiers.MELEE_EVADE,
791 );
793 }
EStaminaModifiers
Definition EStaminaModifiers.c:2
void StaminaModifiers()
Definition StaminaHandler.c:206
static float GetObstacleTraversalStaminaModifier()
Definition CfgGameplayHandler.c:227
static float GetMeleeStaminaModifier()
Definition CfgGameplayHandler.c:222
Definition StaminaModifierData.c:42
const float STAMINA_DRAIN_CLIMB
Definition constants.c:655
const float STAMINA_DRAIN_MELEE_LIGHT
Definition constants.c:656
const float STAMINA_DRAIN_VAULT
Definition constants.c:654
const float STAMINA_DRAIN_MELEE_HEAVY
Definition constants.c:657
const float STAMINA_DRAIN_JUMP
Definition constants.c:653
const float STAMINA_DRAIN_MELEE_EVADE
Definition constants.c:658
const float STAMINA_DRAIN_ROLL
Definition constants.c:659

Перекрестные ссылки CfgGameplayHandler::GetMeleeStaminaModifier(), CfgGameplayHandler::GetObstacleTraversalStaminaModifier(), CfgGameplayHandler::GetStaminaMax(), m_StaminaModifiers, GameConstants::STAMINA_DRAIN_CLIMB, GameConstants::STAMINA_DRAIN_JUMP, GameConstants::STAMINA_DRAIN_MELEE_EVADE, GameConstants::STAMINA_DRAIN_MELEE_HEAVY, GameConstants::STAMINA_DRAIN_MELEE_LIGHT, GameConstants::STAMINA_DRAIN_ROLL, GameConstants::STAMINA_DRAIN_VAULT и StaminaModifiers().

Используется в StaminaHandler().

◆ ResetCooldown()

void ResetCooldown ( int modifier = -1)
inlineprotected
878 {
879 StaminaModifier sm = m_StaminaModifiers.GetModifierData(modifier);
880 if (sm)
881 {
882 //Print(modifier);
883 //Error("Error: No StaminaModifier found! | StaminaHandler | ResetCooldown");
884 sm.SetStartTime(-1);
885 sm.ResetRunTime();
886 sm.SetInUse(false);
887 }
888 m_IsInCooldown = false;
889 }

Перекрестные ссылки m_IsInCooldown и m_StaminaModifiers.

Используется в SetCooldown().

◆ SetCooldown()

void SetCooldown ( float time,
int modifier = -1 )
inlineprotected

set cooldown timer between each consume of stamina

854 {
855 if ( m_StaminaDepleted || m_Stamina <= 0.0 )
856 {
858 return;
859 }
860
861 m_IsInCooldown = true;
862
863 Timer timer;
864 if (m_TimerMap.Find(modifier, timer) && timer.IsRunning())
865 {
866 timer.Stop();
867 }
868 else
869 {
870 timer = new ref Timer;
872 }
873 timer.Run(time, this, "ResetCooldown", new Param1<int>( modifier ));
874 //Print(m_TimerMap.Count());
875 }
void ResetCooldown(int modifier=-1)
Definition StaminaHandler.c:877
Definition DayZPlayerImplement.c:63

Перекрестные ссылки m_IsInCooldown, m_Stamina, m_StaminaDepleted, m_TimerMap и ResetCooldown().

Используется в CheckStaminaState(), DepleteStamina(), StaminaProcessor_Ladder(), StaminaProcessor_Move() и StaminaProcessor_Swimming().

◆ SetDepletionMultiplier()

void SetDepletionMultiplier ( float val)
inlineprotected
945 {
950 }
void SyncAdditionalStaminaInfo(Param par)
Method to sync more info for stamina manager. Template parameter means it is very extendable for furt...
Definition StaminaHandler.c:683

Перекрестные ссылки m_StaminaDepletionMultiplier, m_StaminaRecoveryMultiplier и SyncAdditionalStaminaInfo().

Используется в RecalculateDepletionMultiplier().

◆ SetRecoveryMultiplier()

◆ SetStamina()

void SetStamina ( float stamina_value)
inlineprotected
908 {
911 }
void SyncStamina(float stamina, float stamina_cap, bool cooldown)
stamina sync - server part
Definition StaminaHandler.c:672

Перекрестные ссылки Math::Clamp(), CfgGameplayHandler::GetStaminaMax(), m_IsInCooldown, m_Stamina, m_StaminaCap и SyncStamina().

Используется в ManBase::EEHitBy(), ManBase::ResetPlayer() и Update().

◆ StaminaProcessor_Ladder()

void StaminaProcessor_Ladder ( HumanMovementState pHumanMovementState)
inlineprotected
621 {
622 switch (pHumanMovementState.m_iMovement)
623 {
624 case 2: //climb up (fast)
627 break;
628
629 case 1: //climb up (slow)
630 if (!m_IsInCooldown)
631 {
633 }
634 break;
635
636 default:
637 if (!m_IsInCooldown)
638 {
640 }
641 break;
642 }
643 }
static float GetSprintLadderStaminaModifier()
Definition CfgGameplayHandler.c:197
float CalcStaminaGainBonus()
Calulates stamina regain bonus coef based on current stamina cap and level.
Definition StaminaHandler.c:796
float m_StaminaDelta
Definition StaminaHandler.c:265
const int STAMINA_GAIN_IDLE_PER_SEC
Definition constants.c:666
const float STAMINA_REGEN_COOLDOWN_DEPLETION
Definition constants.c:684
const int STAMINA_DRAIN_LADDER_FAST_PER_SEC
Definition constants.c:649
const int STAMINA_GAIN_LADDER_PER_SEC
Definition constants.c:668

Перекрестные ссылки CalcStaminaGainBonus(), CfgGameplayHandler::GetSprintLadderStaminaModifier(), m_IsInCooldown, m_StaminaDelta, SetCooldown(), GameConstants::STAMINA_DRAIN_LADDER_FAST_PER_SEC, GameConstants::STAMINA_GAIN_IDLE_PER_SEC, GameConstants::STAMINA_GAIN_LADDER_PER_SEC и GameConstants::STAMINA_REGEN_COOLDOWN_DEPLETION.

Используется в Update().

◆ StaminaProcessor_Move()

void StaminaProcessor_Move ( HumanMovementState pHumanMovementState)
inlineprotected
558 {
559 switch (pHumanMovementState.m_iMovement)
560 {
561 case DayZPlayerConstants.MOVEMENTIDX_SPRINT: //sprint
562 if (pHumanMovementState.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_ERECT)
563 {
566 break;
567 }
568 else if ( pHumanMovementState.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_CROUCH)
569 {
572 break;
573 }
574
576 break;
577
578 case DayZPlayerConstants.MOVEMENTIDX_RUN: //jog
579 if (m_Player.GetCurrentWaterLevel() >= m_HumanMoveSettings.m_fWaterLevelSpeedRectrictionHigh)
580 {
582 break;
583 }
584
585 if (!m_IsInCooldown)
586 {
588 }
589 break;
590
591 case DayZPlayerConstants.MOVEMENTIDX_WALK: //walk
592 if (!m_IsInCooldown)
593 {
595 }
596 break;
597
598 case DayZPlayerConstants.MOVEMENTIDX_IDLE: //idle
599 if (m_Player.IsRolling())
600 {
602 break;
603 }
604
605 if (!m_IsInCooldown)
606 {
608 }
609 break;
610
611 default:
612 if (!m_IsInCooldown)
613 {
615 }
616 break;
617 }
618 }
static float GetSprintStaminaModifierCro()
Definition CfgGameplayHandler.c:188
static float GetSprintStaminaModifierErc()
Definition CfgGameplayHandler.c:183
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:602
const int STAMINA_GAIN_ROLL_PER_SEC
Definition constants.c:669
const int STAMINA_GAIN_JOG_PER_SEC
Definition constants.c:664
const int STAMINA_DRAIN_STANDING_SPRINT_PER_SEC
Definition constants.c:645
const int STAMINA_DRAIN_CROUCHED_SPRINT_PER_SEC
Definition constants.c:646
const int STAMINA_GAIN_WALK_PER_SEC
Definition constants.c:665

Перекрестные ссылки CalcStaminaGainBonus(), CfgGameplayHandler::GetSprintStaminaModifierCro(), CfgGameplayHandler::GetSprintStaminaModifierErc(), m_HumanMoveSettings, m_IsInCooldown, m_Player, m_StaminaDelta, SetCooldown(), GameConstants::STAMINA_DRAIN_CROUCHED_SPRINT_PER_SEC, GameConstants::STAMINA_DRAIN_STANDING_SPRINT_PER_SEC, GameConstants::STAMINA_GAIN_IDLE_PER_SEC, GameConstants::STAMINA_GAIN_JOG_PER_SEC, GameConstants::STAMINA_GAIN_ROLL_PER_SEC, GameConstants::STAMINA_GAIN_WALK_PER_SEC и GameConstants::STAMINA_REGEN_COOLDOWN_DEPLETION.

Используется в Update().

◆ StaminaProcessor_Swimming()

void StaminaProcessor_Swimming ( HumanMovementState pHumanMovementState)
inlineprotected
646 {
647 switch (pHumanMovementState.m_iMovement)
648 {
649 case 3: //swim fast
652 break;
653
654
655 case 2: //swim slow
656 if (!m_IsInCooldown)
657 {
659 }
660 break;
661
662 default:
663 if (!m_IsInCooldown)
664 {
666 }
667 break;
668 }
669 }
static float GetSprintSwimmingStaminaModifier()
Definition CfgGameplayHandler.c:193
const int STAMINA_GAIN_SWIM_PER_SEC
Definition constants.c:667
const int STAMINA_DRAIN_SWIM_FAST_PER_SEC
Definition constants.c:648

Перекрестные ссылки CalcStaminaGainBonus(), CfgGameplayHandler::GetSprintSwimmingStaminaModifier(), m_IsInCooldown, m_StaminaDelta, SetCooldown(), GameConstants::STAMINA_DRAIN_SWIM_FAST_PER_SEC, GameConstants::STAMINA_GAIN_IDLE_PER_SEC, GameConstants::STAMINA_GAIN_SWIM_PER_SEC и GameConstants::STAMINA_REGEN_COOLDOWN_DEPLETION.

Используется в Update().

◆ SyncAdditionalStaminaInfo()

void SyncAdditionalStaminaInfo ( Param par)
inlineprotected

Method to sync more info for stamina manager. Template parameter means it is very extendable for further use.

684 {
686
688 pCtx.Write(p.param1);
689 pCtx.Write(p.param2);
691 }
Definition gameplay.c:151

Перекрестные ссылки m_Player и DayZPlayerSyncJunctures::SJ_STAMINA_MISC.

Используется в SetDepletionMultiplier() и SetRecoveryMultiplier().

◆ SyncStamina()

void SyncStamina ( float stamina,
float stamina_cap,
bool cooldown )
inlineprotected

stamina sync - server part

673 {
674 m_Player.GetStatStamina().Set(m_Stamina);
676 pCtx.Write(m_Stamina);
677 pCtx.Write(m_StaminaCap);
678 pCtx.Write(m_IsInCooldown);
680 }

Перекрестные ссылки m_IsInCooldown, m_Player, m_Stamina, m_StaminaCap и DayZPlayerSyncJunctures::SJ_STAMINA.

Используется в SetStamina().

◆ Update()

void Update ( float deltaT,
int pCurrentCommandID )
inlineprotected

gets the actual players load

StaminaCap calculation starts when PlayerLoad exceeds STAMINA_WEIGHT_LIMIT_THRESHOLD

processed on event

processed on event

processed on event

425 {
426 #ifdef DIAG_DEVELOPER
428 return;
429 #endif
430 if (m_Player)
431 {
432 // Calculates actual max stamina based on player's load
433 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
434 {
436 m_PlayerLoad = m_Player.GetWeightEx();
437
440 {
442 }
443 else
444 {
446 }
447 }
448
449 // Calculates stamina gain/loss based on movement and load
450 m_Player.GetMovementState(m_State);
451
452 switch (m_State.m_CommandTypeId)
453 {
454 case DayZPlayerConstants.COMMANDID_MOVE:
456 break;
457 case DayZPlayerConstants.COMMANDID_LADDER:
459 break;
460 case DayZPlayerConstants.COMMANDID_SWIM:
462 break;
463 case DayZPlayerConstants.COMMANDID_FALL:
464 case DayZPlayerConstants.COMMANDID_MELEE2:
465 case DayZPlayerConstants.COMMANDID_CLIMB:
466 break;
467 default:
468 if (!m_IsInCooldown)
469 {
471 }
472 break;
473 }
474
475 //Sets current stamina & stores + syncs data with client
476 float temp = m_StaminaDelta * deltaT;
477 if (temp < 0)
478 {
480 }
481 else
482 {
484 }
485
488
489 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
490 {
491 m_Player.GetStatStamina().Set(m_Stamina);
492 m_Time += deltaT;
493
495 {
496 m_Time = 0;
498 }
499 }
500
501 #ifndef SERVER
503 #endif
504
507
508 m_StaminaDelta = 0;
509 m_StaminaDepletion = 0; // resets depletion modifier
510
511 }
512 }
static float GetStaminaKgToStaminaPercentPenalty()
Definition CfgGameplayHandler.c:212
static float GetStaminaWeightLimitThreshold()
Definition CfgGameplayHandler.c:202
float m_PlayerLoad
Definition StaminaHandler.c:264
void ApplyExhaustion()
Definition StaminaHandler.c:807
void SetStamina(float stamina_value)
Definition StaminaHandler.c:907
void StaminaProcessor_Ladder(HumanMovementState pHumanMovementState)
Definition StaminaHandler.c:620
void CheckStaminaState()
check if the stamina is completely depleted
Definition StaminaHandler.c:834
void StaminaProcessor_Swimming(HumanMovementState pHumanMovementState)
Definition StaminaHandler.c:645
void StaminaProcessor_Move(HumanMovementState pHumanMovementState)
Definition StaminaHandler.c:557
const float STAMINA_KG_TO_GRAMS
in grams (weight where the player is not penalized by stamina)
Definition constants.c:687
const float STAMINA_SYNC_RATE
Definition constants.c:688

Перекрестные ссылки ApplyExhaustion(), CheckStaminaState(), GetGame(), CfgGameplayHandler::GetStaminaKgToStaminaPercentPenalty(), CfgGameplayHandler::GetStaminaMax(), CfgGameplayHandler::GetStaminaMinCap(), CfgGameplayHandler::GetStaminaWeightLimitThreshold(), m_IsInCooldown, m_Player, m_PlayerLoad, m_Stamina, m_StaminaCap, m_StaminaDelta, m_StaminaDepletion, m_StaminaDepletionMultiplier, m_StaminaRecoveryMultiplier, m_StaminaSynced, m_State, m_Time, Math::Max(), Math::Min(), SetStamina(), GameConstants::STAMINA_GAIN_IDLE_PER_SEC, GameConstants::STAMINA_KG_TO_GRAMS, GameConstants::STAMINA_SYNC_RATE, StaminaProcessor_Ladder(), StaminaProcessor_Move() и StaminaProcessor_Swimming().

Используется в ManBase::CommandHandler().

Поля

◆ m_ActiveDepletionModifiers

◆ m_ActiveRecoveryModifiers

◆ m_Debug

bool m_Debug
protected

◆ m_HumanMoveSettings

SHumanCommandMoveSettings m_HumanMoveSettings
protected

Используется в StaminaHandler() и StaminaProcessor_Move().

◆ m_IsInCooldown

◆ m_Player

◆ m_PlayerLoad

float m_PlayerLoad
protected

Используется в Update().

◆ m_RegisteredDepletionModifiers

ref map<EStaminaMultiplierTypes, float> m_RegisteredDepletionModifiers
protected

◆ m_RegisteredRecoveryModifiers

ref map<EStaminaMultiplierTypes, float> m_RegisteredRecoveryModifiers
protected

◆ m_Stamina

◆ m_StaminaCap

◆ m_StaminaConsumers

ref StaminaConsumers m_StaminaConsumers
protected

◆ m_StaminaDelta

float m_StaminaDelta
protected

◆ m_StaminaDepleted

bool m_StaminaDepleted
protected

◆ m_StaminaDepletion

float m_StaminaDepletion
protected

◆ m_StaminaDepletionMultiplier

◆ m_StaminaModifiers

ref StaminaModifiers m_StaminaModifiers
protected

◆ m_StaminaParams

ref Param3<float,float,bool> m_StaminaParams
protected

Используется в StaminaHandler().

◆ m_StaminaRecoveryMultiplier

◆ m_StaminaSynced

float m_StaminaSynced
protected

Используется в GetSyncedStamina(), OnSyncJuncture() и Update().

◆ m_State

ref HumanMovementState m_State
protected

Используется в StaminaHandler() и Update().

◆ m_Time

float m_Time
protected

Используется в StaminaHandler() и Update().

◆ m_TimerMap

ref map<int,ref Timer> m_TimerMap
protected

Используется в SetCooldown() и StaminaHandler().


Объявления и описания членов класса находятся в файле: