21 protected float m_DrainThreshold
27 m_DrainThreshold = threshold2;
52 if (depletion_threshold == -1)
54 depletion_threshold = threshold;
72 if (isDepleted || (curStamina < sc.GetDrainThreshold()))
95 if (curStamina > sc.GetDrainThreshold() || curStamina == cap)
110 if ((isDepleted || (curStamina < sc.GetActivationThreshold() && curStamina < cap)))
141 void StaminaModifier(
int type,
float min,
float max,
float cooldown,
float startTime = 0,
float duration = 0)
310 #ifdef DIAG_DEVELOPER
311 protected bool m_StaminaDisabled;
312 protected float m_DebugTimer = 0;
313 protected int m_LastPoolInUse = 0;
321 m_State =
new HumanMovementState();
390 Error(
"attempting to activate unregistered depletion modifier");
426 Error(
"attempting to activate unregistered recovery modifier");
474 void Update(
float deltaT,
int pCurrentCommandID)
476 #ifdef DIAG_DEVELOPER
477 if (m_StaminaDisabled)
488 cooldownParams.param1 -= deltaT;
489 if (cooldownParams.param1 <= 0)
491 expiredCooldowns.Insert(modifier);
496 foreach (
int expiredModifier : expiredCooldowns)
507 bool isAiOrSingleplayer =
m_Player.IsAuthorityOwner();
508 bool isServerOrSingleplayer =
m_Player.IsAuthority();
511 if (isServerOrSingleplayer)
523 PlayerBaseMove move = PlayerBaseMove.Cast(
m_Player.GetNextMove());
531 if (isAiOrSingleplayer)
556 switch (
m_State.m_CommandTypeId)
605 if (isServerOrSingleplayer)
647 if (!pCtx.Read(stamina) || !pCtx.Read(staminaCap) || !pCtx.Read(cooldown))
679 switch (pHumanMovementState.m_iMovement)
742 switch (pHumanMovementState.m_iMovement)
767 switch (pHumanMovementState.m_iMovement)
797 protected void SyncStamina(
float stamina,
float stamina_cap,
bool cooldown)
799 m_Player.GetStatStamina().Set(stamina);
802 pCtx.Write(stamina_cap);
803 pCtx.Write(cooldown);
813 pCtx.Write(p.param1);
814 pCtx.Write(p.param2);
821 float depletionMultiplier;
822 float recoveryMultiplier;
823 if (!pCtx.Read(depletionMultiplier) || !pCtx.Read(recoveryMultiplier))
957 HumanCommandAdditives ad =
m_Player.GetCommandModifier_Additives();
959 float exhaustion_value = 1;
965 exhaustion_value =
Math.Min(1, exhaustion_value);
971 ad.SetExhaustion(0,
true);
975 ad.SetExhaustion(exhaustion_value,
true);
1010 cooldown.param1 = time;
1018 sm.SetStartTime(-1);
1112 #ifdef DIAG_DEVELOPER
1113 if (m_StaminaDisabled)
1117 float current_time =
m_Player.GetSimulationTimeStamp();
1118 float valueProgress;
1122 switch (sm.GetType())
1134 val =
Math.RandomFloat(sm.GetMinValue(), sm.GetMaxValue());
1142 sm.SetStartTime(current_time + sm.GetStartTimeAdjustment()/dT);
1143 sm.SetRunTimeTick(dT);
1146 valueProgress =
Math.Clamp((current_time - sm.GetStartTime())/sm.GetDurationAdjusted(), 0, 1 );
1147 val =
Math.Lerp(sm.GetMinValue(), sm.GetMaxValue(), valueProgress);
1154 if (!
Class.CastTo(smex,sm))
1156 ErrorEx(
"StaminaModifierExponential not found for modifier type: " + sm.GetType());
1160 if (!smex.IsInUse())
1163 smex.SetRunTimeTick(dT);
1164 smex.SetInUse(
true);
1211 if (move.m_bStaminaSynced)
1225 #ifdef DIAG_DEVELOPER
1226 void SetStaminaDisabled(
bool value)
1228 m_StaminaDisabled = value;
1243 [
Obsolete(
"Deprecated use, StaminaHandler uses SyncJunctures now!")]
1244 void OnRPC(
float stamina,
float stamina_cap,
bool cooldown);
eBleedingSourceType m_Type
eBleedingSourceType GetType()
Super root of all classes in Enforce script.
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
void RegisterConsumer(EStaminaConsumers consumer, float threshold, float depletion_threshold=-1)
ref map< EStaminaConsumers, ref StaminaConsumer > m_StaminaConsumers
bool HasEnoughStaminaToStart(EStaminaConsumers consumer, float curStamina, bool isDepleted, float cap)
bool HasEnoughStaminaFor(EStaminaConsumers consumer, float curStamina, bool isDepleted, float cap)
float m_StaminaDepletionMultiplier
void StaminaProcessor_Ladder(HumanMovementState pHumanMovementState)
void RegisterStaminaModifiers()
ref HumanMovementState m_State
void StaminaProcessor_Swimming(HumanMovementState pHumanMovementState)
float GetDepletionMultiplier()
void ReplayMove(PlayerBaseMove move)
void RecalculateRecoveryMultiplier()
void DepleteStamina(EStaminaModifiers modifier, float dT=-1)
float m_StaminaDepletionMultiplierNext
void DepleteStaminaEx(EStaminaModifiers modifier, float dT=-1, float coef=1.0)
void SetDepletionMultiplier(float val)
void SetRecoveryMultiplier(float val)
void RecalculateStaminaCap()
float m_StaminaRecoveryMultiplier
ref set< EStaminaMultiplierTypes > m_ActiveDepletionModifiers
float GetSyncedStaminaCap()
void SyncAdditionalStaminaInfo(Param par)
Method to sync more info for stamina manager. Template parameter means it is very extendable for furt...
ref StaminaModifiers m_StaminaModifiers
void OnSyncJuncture(int pJunctureID, ParamsReadContext pCtx)
called from PlayerBase - syncs stamina values on server with client AND sets the value to match on se...
void CheckStaminaState()
check if the stamina is completely depleted
void DeactivateRecoveryModifier(EStaminaMultiplierTypes type)
void RegisterStaminaConsumers()
float m_StaminaRecoveryMultiplierNext
bool HasEnoughStaminaFor(EStaminaConsumers consumer)
void StaminaHandler(PlayerBase player)
const float STAMINA_GAIN_MODIFIER
ref map< int, ref StaminaCooldownParams > m_CooldownMap
float GetRecoveryMultiplier()
bool m_IsStaminaGainBonusCached
void OnRPC(float stamina, float stamina_cap, bool cooldown)
float CalcStaminaGainBonus()
Calulates stamina regain bonus coef based on current stamina cap and level and caches it during one U...
bool m_MovementStateChanged
ref set< EStaminaMultiplierTypes > m_ActiveRecoveryModifiers
const float STAMINA_GAIN_THRESHOLD
ref Param3< float, float, bool > m_StaminaParams
void RecalculateDepletionMultiplier()
bool HasMovementStateChanged()
void StaminaProcessor_Move(HumanMovementState pHumanMovementState)
float GetStaminaNormalized()
float GetSyncedStaminaNormalized()
void SyncStaminaEx()
stamina sync - server part
void ProcessStaminaChanges(float deltaT, bool isServerOrSingleplayer)
void DeactivateDepletionModifier(EStaminaMultiplierTypes type)
void ObtainMove(PlayerBaseMove move)
float m_CachedStaminaGainBonus
bool HasEnoughStaminaToStart(EStaminaConsumers consumer)
void ProcessMovementState()
void SetCooldown(float time, int modifier=-1)
set cooldown timer between each consume of stamina
void SetStamina(float stamina_value)
void ReadAdditionalStaminaInfo(ParamsReadContext pCtx)
Order of read parameters must match the order of writing above.
void ObtainState(PlayerBaseOwnerState state)
void RewindState(PlayerBaseOwnerState state, PlayerBaseMove move)
ref StaminaConsumers m_StaminaConsumers
void ActivateDepletionModifier(EStaminaMultiplierTypes type)
SHumanCommandMoveSettings m_HumanMoveSettings
void ResetCooldown(int modifier=-1)
void SyncStamina(float stamina, float stamina_cap, bool cooldown)
stamina sync - server part
ref map< EStaminaMultiplierTypes, float > m_RegisteredRecoveryModifiers
void ActivateRecoveryModifier(EStaminaMultiplierTypes type)
ref map< EStaminaMultiplierTypes, float > m_RegisteredDepletionModifiers
void Update(float deltaT, int pCurrentCommandID)
override float GetStartTimeAdjustment()
override float GetCooldown()
override float GetDuration()
void SetData(SMDataExponential data)
override float GetDurationAdjusted()
ref SMDataExponential m_SMDataEx
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
DayZPlayerInstanceType
defined in C++
DayZPlayerConstants
defined in C++
Serializer ParamsReadContext
void Error(string err)
Messagebox with error message.
void Obsolete(string msg="")
class SHumanGlobalSettings SHumanCommandMoveSettings()
enum EObjectTemperatureState m_State
class PlayerStatBase m_MinValue
void StaminaConsumer(float threshold, float threshold2, bool state)
void SetMaxValue(float val)
void StaminaModifier(int type, float min, float max, float cooldown, float startTime=0, float duration=0)
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,...
void SetActivationThreshold(float threshold)
void SetStartTime(float val)
StaminaModifierExponential FIXED
void SetDrainThreshold(float threshold)
float m_StartTimeAdjustment
void SetState(bool state)
ref map< EStaminaModifiers, ref StaminaModifier > m_StaminaModifiers
void RegisterExponentialEx(EStaminaModifiers modifier, SMDataExponential data)
register exponential modifier, extended parameters
float GetStartTimeAdjustment()
float GetDrainThreshold()
float GetActivationThreshold()
Param1< float > StaminaCooldownParams
void SetRunTimeTick(float val)
void SetMinValue(float val)
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
void SetCooldown(float val)
bool GetState()
returns one of STATE_...
StaminaModifier GetModifierData(EStaminaModifiers modifier)
float GetDurationAdjusted()
void AddRunTime(float val)
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;