DayZ 1.24
Loading...
Searching...
No Matches
StaminaHandler.c File Reference

Go to the source code of this file.

Classes

class  StaminaConsumers
 
class  StaminaModifierExponential
 
class  StaminaHandler
 

Enumerations

enum  EStaminaMultiplierTypes
 

Functions

void StaminaConsumer (float threshold, float threshold2, bool state)
 
bool GetState ()
 returns one of STATE_...
 
void SetState (bool state)
 
float GetActivationThreshold ()
 
void SetActivationThreshold (float threshold)
 
float GetDrainThreshold ()
 
void SetDrainThreshold (float threshold)
 
void StaminaConsumers ()
 
void RegisterConsumer (EStaminaConsumers consumer, float threshold, float depletion_threshold=-1)
 
bool HasEnoughStaminaFor (EStaminaConsumers consumer, float curStamina, bool isDepleted, float cap)
 
bool HasEnoughStaminaToStart (EStaminaConsumers consumer, float curStamina, bool isDepleted, float cap)
 
void StaminaModifier (int type, float min, float max, float cooldown, float startTime=0, float duration=0)
 
int GetType ()
 
float GetMinValue ()
 
void SetMinValue (float val)
 
float GetMaxValue ()
 
void SetMaxValue (float val)
 
float GetCooldown ()
 
void SetCooldown (float val)
 
float GetStartTime ()
 
void SetStartTime (float val)
 
float GetStartTimeAdjustment ()
 
float GetDuration ()
 
float GetDurationAdjusted ()
 
bool IsInUse ()
 
void SetInUse (bool val)
 
float GetRunTime ()
 
void AddRunTime (float val)
 
void SetRunTimeTick (float val)
 
void ResetRunTime ()
 
void StaminaModifiers ()
 
void RegisterFixed (EStaminaModifiers modifier, float value, float cooldown=GameConstants.STAMINA_REGEN_COOLDOWN_DEPLETION)
 register single value modifier - depletes stamina for that value
 
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;
 
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, lerps to endValue over duration
 
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, lerps from 0 to exponent over duration
 
void RegisterExponentialEx (EStaminaModifiers modifier, SMDataExponential data)
 register exponential modifier, extended parameters
 
StaminaModifier GetModifierData (EStaminaModifiers modifier)
 

Variables

 MASK = 1
 
 FATIGUE
 
 EPINEPHRINE
 
 DROWNING
 
 m_ActivationThreshold
 
bool m_State
 
ref map< EStaminaConsumers, ref StaminaConsumerm_StaminaConsumers
 
 m_InUse = false
 
int m_Type
 
float m_MinValue
 
float m_MaxValue
 
float m_Multiplier
 
float m_Cooldown
 
float m_StartTime
 
float m_StartTimeAdjustment
 
float m_Duration
 
float m_ProgressTime
 
float m_Tick
 
StaminaModifierExponential FIXED = 0
 
const int RANDOMIZED = 1
 
const int LINEAR = 2
 
const int EXPONENTIAL = 3
 
ref map< EStaminaModifiers, ref StaminaModifierm_StaminaModifiers
 

Enumeration Type Documentation

◆ EStaminaMultiplierTypes

Definition at line 1 of file StaminaHandler.c.

2{
3 MASK = 1,
7}
DROWNING
FATIGUE
EPINEPHRINE
MASK

Function Documentation

◆ AddRunTime()

void AddRunTime ( float val)
protected

Definition at line 173 of file StaminaHandler.c.

173{ m_ProgressTime += val; }
float m_ProgressTime

References m_ProgressTime.

◆ GetActivationThreshold()

float GetActivationThreshold ( )
protected

Definition at line 32 of file StaminaHandler.c.

32{ return m_ActivationThreshold; }
m_ActivationThreshold

References m_ActivationThreshold.

◆ GetCooldown()

float GetCooldown ( )
protected

Definition at line 158 of file StaminaHandler.c.

158{ return m_Cooldown; }
float m_Cooldown

References m_Cooldown.

◆ GetDrainThreshold()

float GetDrainThreshold ( )
protected

Definition at line 35 of file StaminaHandler.c.

35{ return m_DrainThreshold; }

◆ GetDuration()

float GetDuration ( )
protected

Definition at line 166 of file StaminaHandler.c.

166{ return m_Duration; }
float m_Duration

References m_Duration.

◆ GetDurationAdjusted()

float GetDurationAdjusted ( )
protected

Definition at line 167 of file StaminaHandler.c.

167{ return m_Duration / m_Tick; }
float m_Tick

References m_Duration, and m_Tick.

◆ GetMaxValue()

float GetMaxValue ( )
protected

Definition at line 155 of file StaminaHandler.c.

155{ return m_MaxValue; }
float m_MaxValue

References m_MaxValue.

◆ GetMinValue()

float GetMinValue ( )
protected

Definition at line 152 of file StaminaHandler.c.

152{ return m_MinValue; }
float m_MinValue

References m_MinValue.

◆ GetModifierData()

StaminaModifier GetModifierData ( EStaminaModifiers modifier)
protected

Definition at line 251 of file StaminaHandler.c.

252 {
253 return m_StaminaModifiers.Get(modifier);
254 }
ref map< EStaminaModifiers, ref StaminaModifier > m_StaminaModifiers

References m_StaminaModifiers.

◆ GetRunTime()

float GetRunTime ( )
protected

Definition at line 172 of file StaminaHandler.c.

172{ return m_ProgressTime; }

References m_ProgressTime.

◆ GetStartTime()

float GetStartTime ( )
protected

Definition at line 161 of file StaminaHandler.c.

161{ return m_StartTime; } //Actual game time (progressive modifiers only)
float m_StartTime

References m_StartTime.

◆ GetStartTimeAdjustment()

float GetStartTimeAdjustment ( )
protected

Definition at line 164 of file StaminaHandler.c.

164{return m_StartTimeAdjustment;} //adjustment to current time (progressive modifiers only)
float m_StartTimeAdjustment

References m_StartTimeAdjustment.

◆ GetState()

bool GetState ( )
protected

returns one of STATE_...

returns the state of climb (enum value of ClimbStates);

Definition at line 29 of file StaminaHandler.c.

29{ return m_State; }
bool m_State

◆ GetType()

int GetType ( )
protected

Definition at line 150 of file StaminaHandler.c.

150{ return m_Type; }
int m_Type

References m_Type.

◆ HasEnoughStaminaFor()

bool Stamina::HasEnoughStaminaFor ( EStaminaConsumers consumer,
float curStamina,
bool isDepleted,
float cap )
protected

Definition at line 61 of file StaminaHandler.c.

62 {
64 {
66
67 if (consumer != EStaminaConsumers.SPRINT)
68 {
69 if ((isDepleted || (curStamina < sc.GetDrainThreshold()/* && curStamina < cap*/)))
70 {
71 sc.SetState(false);
72 return false;
73 }
74 }
75 else
76 {
77 if (!isDepleted)
78 {
79 if (sc.GetState())
80 {
81 sc.SetState(true);
82 return true;
83 }
84 }
85 else
86 {
87 sc.SetState(false);
88 return false;
89 }
90 }
91
92 if (curStamina > sc.GetDrainThreshold() || curStamina == cap) //Sometimes player can't go up to drain threshold
93 {
94 sc.SetState(true);
95 return true;
96 }
97 }
98
99 return false;
100 }
EStaminaConsumers
void StaminaConsumer(float threshold, float threshold2, bool state)
ref map< EStaminaConsumers, ref StaminaConsumer > m_StaminaConsumers

◆ HasEnoughStaminaToStart()

bool Stamina::HasEnoughStaminaToStart ( EStaminaConsumers consumer,
float curStamina,
bool isDepleted,
float cap )
protected

Definition at line 102 of file StaminaHandler.c.

103 {
105 {
107
108 if ((isDepleted || (curStamina < sc.GetActivationThreshold() && curStamina < cap)))
109 {
110 sc.SetState(false);
111 return false;
112 }
113 else
114 {
115 sc.SetState(true);
116 return true;
117 }
118 }
119
120 return false;
121 }

◆ IsInUse()

bool IsInUse ( )
protected

Definition at line 169 of file StaminaHandler.c.

169{ return m_InUse; }
m_InUse

References m_InUse.

◆ RegisterConsumer()

void Stamina::RegisterConsumer ( EStaminaConsumers consumer,
float threshold,
float depletion_threshold = -1 )
protected

init of StaminaConsumer - threshold, state

Definition at line 48 of file StaminaHandler.c.

◆ RegisterExponential()

void RegisterExponential ( EStaminaModifiers modifier,
float startValue,
float exponent,
float startTime,
float duration,
float cooldown = GameConstants.STAMINA_REGEN_COOLDOWN_DEPLETION )
protected

register exponential modifier - depletes stamina for startValue, and, after a startTime, lerps from 0 to exponent over duration

Definition at line 237 of file StaminaHandler.c.

238 {
241 }
void StaminaModifier(int type, float min, float max, float cooldown, float startTime=0, float duration=0)
const int EXPONENTIAL

References EXPONENTIAL, m_StaminaModifiers, and StaminaModifier().

◆ RegisterExponentialEx()

void RegisterExponentialEx ( EStaminaModifiers modifier,
SMDataExponential data )
protected

register exponential modifier, extended parameters

Definition at line 244 of file StaminaHandler.c.

245 {
246 StaminaModifierExponential smex = new StaminaModifierExponential(EXPONENTIAL, data.m_BaseValue, data.m_Exponent, data.m_Cooldown, data.m_StartTimeAdjustment, data.m_Duration);
247 smex.SetData(data);
249 }

References EXPONENTIAL, and m_StaminaModifiers.

◆ RegisterFixed()

void RegisterFixed ( EStaminaModifiers modifier,
float value,
float cooldown = GameConstants.STAMINA_REGEN_COOLDOWN_DEPLETION )
protected

register single value modifier - depletes stamina for that value

init of StaminaModifier - type and min, max values (min is not relevant for that type)

Definition at line 208 of file StaminaHandler.c.

209 {
210 if (!m_StaminaModifiers.Contains(modifier))
211 {
213 StaminaModifier sm = new StaminaModifier(FIXED, -1, value, cooldown);
215 }
216 }
StaminaModifierExponential FIXED

References FIXED, m_StaminaModifiers, and StaminaModifier().

◆ RegisterLinear()

void RegisterLinear ( EStaminaModifiers modifier,
float startValue,
float endValue,
float startTime,
float duration,
float cooldown = GameConstants.STAMINA_REGEN_COOLDOWN_DEPLETION )
protected

register lerped modifier - depletes stamina for startValue, and, after a startTime, lerps to endValue over duration

Definition at line 230 of file StaminaHandler.c.

231 {
234 }
const int LINEAR

References LINEAR, m_StaminaModifiers, and StaminaModifier().

◆ RegisterRandomized()

void RegisterRandomized ( EStaminaModifiers modifier,
float minValue,
float maxValue,
float cooldown = GameConstants.STAMINA_REGEN_COOLDOWN_DEPLETION )
protected

register randomized modifier - stamina will be depleted by value between min and max value;

init of StaminaModifier - type, min, max values

Definition at line 219 of file StaminaHandler.c.

220 {
221 if (!m_StaminaModifiers.Contains(modifier))
222 {
224 StaminaModifier sm = new StaminaModifier(RANDOMIZED, minValue, maxValue, cooldown);
226 }
227 }
const int RANDOMIZED

References m_StaminaModifiers, RANDOMIZED, and StaminaModifier().

◆ ResetRunTime()

void ResetRunTime ( )
protected

Definition at line 175 of file StaminaHandler.c.

175{ m_ProgressTime = 0 }

References m_ProgressTime.

◆ SetActivationThreshold()

void SetActivationThreshold ( float threshold)
protected

Definition at line 33 of file StaminaHandler.c.

References m_ActivationThreshold.

◆ SetCooldown()

void SetCooldown ( float val)
protected

Definition at line 159 of file StaminaHandler.c.

159{ m_Cooldown = val; }

References m_Cooldown.

Referenced by HandleFightLogic().

◆ SetDrainThreshold()

void SetDrainThreshold ( float threshold)
protected

Definition at line 36 of file StaminaHandler.c.

◆ SetInUse()

void SetInUse ( bool val)
protected

Definition at line 170 of file StaminaHandler.c.

170{ m_InUse = val; }

References m_InUse.

◆ SetMaxValue()

void SetMaxValue ( float val)
protected

Definition at line 156 of file StaminaHandler.c.

156{ m_MaxValue = val; }

References m_MaxValue.

◆ SetMinValue()

void SetMinValue ( float val)
protected

Definition at line 153 of file StaminaHandler.c.

153{ m_MinValue = val; }

References m_MinValue.

◆ SetRunTimeTick()

void SetRunTimeTick ( float val)
protected

Definition at line 174 of file StaminaHandler.c.

174{ m_Tick = val; }

References m_Tick.

◆ SetStartTime()

void SetStartTime ( float val)
protected

Definition at line 162 of file StaminaHandler.c.

162{ m_StartTime = val; }

References m_StartTime.

◆ SetState()

◆ StaminaConsumer()

void StaminaConsumer ( float threshold,
float threshold2,
bool state )
protected

Definition at line 22 of file StaminaHandler.c.

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 }

References m_ActivationThreshold, and m_State.

Referenced by StaminaConsumers::HasEnoughStaminaFor(), StaminaConsumers::HasEnoughStaminaToStart(), and StaminaConsumers::RegisterConsumer().

◆ StaminaConsumers()

void Stamina::StaminaConsumers ( )
protected

◆ StaminaModifier()

void StaminaModifier ( int type,
float min,
float max,
float cooldown,
float startTime = 0,
float duration = 0 )
protected

◆ StaminaModifiers()

void StaminaModifiers ( )
protected

Variable Documentation

◆ DROWNING

@ DROWNING

Definition at line 6 of file StaminaHandler.c.

◆ EPINEPHRINE

EPINEPHRINE

Definition at line 5 of file StaminaHandler.c.

◆ EXPONENTIAL

const int EXPONENTIAL = 3
protected

Definition at line 198 of file StaminaHandler.c.

Referenced by RegisterExponential(), and RegisterExponentialEx().

◆ FATIGUE

FATIGUE

Definition at line 4 of file StaminaHandler.c.

◆ FIXED

StaminaModifierExponential FIXED = 0
protected

Referenced by RegisterFixed().

◆ LINEAR

const int LINEAR = 2
protected

Definition at line 197 of file StaminaHandler.c.

Referenced by RegisterLinear().

◆ m_ActivationThreshold

m_ActivationThreshold

◆ m_Cooldown

float m_Cooldown
protected

Definition at line 137 of file StaminaHandler.c.

Referenced by GetCooldown(), Init(), SetCooldown(), and StaminaModifier().

◆ m_Duration

float m_Duration
protected

Definition at line 137 of file StaminaHandler.c.

◆ m_InUse

m_InUse = false
protected

Referenced by IsInUse(), and SetInUse().

◆ m_MaxValue

◆ m_MinValue

◆ m_Multiplier

float m_Multiplier
protected

Definition at line 137 of file StaminaHandler.c.

Referenced by Init().

◆ m_ProgressTime

float m_ProgressTime
protected

Definition at line 137 of file StaminaHandler.c.

Referenced by AddRunTime(), GetRunTime(), and ResetRunTime().

◆ m_StaminaConsumers

ref map<EStaminaConsumers, ref StaminaConsumer> m_StaminaConsumers
protected

Definition at line 41 of file StaminaHandler.c.

◆ m_StaminaModifiers

◆ m_StartTime

float m_StartTime
protected

Definition at line 137 of file StaminaHandler.c.

Referenced by GetStartTime(), and SetStartTime().

◆ m_StartTimeAdjustment

float m_StartTimeAdjustment
protected

Definition at line 137 of file StaminaHandler.c.

Referenced by GetStartTimeAdjustment(), Init(), and StaminaModifier().

◆ m_State

bool m_State
protected

Definition at line 20 of file StaminaHandler.c.

Referenced by HFSMBase< Class FSMStateBase, Class FSMEventBase, Class FSMActionBase, Class FSMGuardBase >::Abort(), HFSMBase< Class FSMStateBase, Class FSMEventBase, Class FSMActionBase, Class FSMGuardBase >::FindAbortDestinationState(), HFSMBase< Class FSMStateBase, Class FSMEventBase, Class FSMActionBase, Class FSMGuardBase >::FindFirstCompletionTransition(), HFSMBase< Class FSMStateBase, Class FSMEventBase, Class FSMActionBase, Class FSMGuardBase >::FindFirstUnguardedTransition(), HFSMBase< Class FSMStateBase, Class FSMEventBase, Class FSMActionBase, Class FSMGuardBase >::GetCurrentState(), AlarmClock_ColorBase::GetDebugText(), KitchenTimer::GetDebugText(), GetState(), ItemBase::GetState(), Inventory_Base::HescoBox(), HFSMBase< WeaponStateBase, WeaponEventBase, WeaponActionBase, WeaponGuardBase >::Internal_ValidateAndRepair(), IsAlarmOn(), IsRinging(), HFSMBase< Class FSMStateBase, Class FSMEventBase, Class FSMActionBase, Class FSMGuardBase >::IsRunning(), HFSMBase< WeaponStateBase, WeaponEventBase, WeaponActionBase, WeaponGuardBase >::LoadAndSetCurrentFSMState(), HFSMBase< WeaponStateBase, WeaponEventBase, WeaponActionBase, WeaponGuardBase >::LoadCurrentFSMState(), HFSMBase< WeaponStateBase, WeaponEventBase, WeaponActionBase, WeaponGuardBase >::OnFailThresholdBreached(), FireworksLauncher::OnIndexChangedClient(), HFSMBase< WeaponStateBase, WeaponEventBase, WeaponActionBase, WeaponGuardBase >::OnStoreLoad(), FireworksLauncher::OnStoreLoad(), ItemBase::OnStoreLoad(), AlarmClock_ColorBase::OnStoreSave(), FireworksLauncher::OnStoreSave(), KitchenTimer::OnStoreSave(), Inventory_Base::OnStoreSave(), ItemBase::OnStoreSave(), OnStoreSave(), OnVariablesSynchronized(), ItemBase::OnVariablesSynchronized(), ItemBase::Pack(), ItemBase::Pitch(), HFSMBase< Class FSMStateBase, Class FSMEventBase, Class FSMActionBase, Class FSMGuardBase >::ProcessAbortEvent(), HFSMBase< WeaponStateBase, WeaponEventBase, WeaponActionBase, WeaponGuardBase >::ProcessAbortEvent(), HFSMBase< Class FSMStateBase, Class FSMEventBase, Class FSMActionBase, Class FSMGuardBase >::ProcessAbortTransition(), HFSMBase< WeaponStateBase, WeaponEventBase, WeaponActionBase, WeaponGuardBase >::ProcessAbortTransition(), HFSMBase< Class FSMStateBase, Class FSMEventBase, Class FSMActionBase, Class FSMGuardBase >::ProcessEvent(), HFSMBase< WeaponStateBase, WeaponEventBase, WeaponActionBase, WeaponGuardBase >::ProcessEvent(), HFSMBase< Class FSMStateBase, Class FSMEventBase, Class FSMActionBase, Class FSMGuardBase >::ProcessLocalTransition(), HFSMBase< WeaponStateBase, WeaponEventBase, WeaponActionBase, WeaponGuardBase >::ProcessLocalTransition(), HFSMBase< WeaponStateBase, WeaponEventBase, WeaponActionBase, WeaponGuardBase >::RandomizeFSMStateEx(), ItemBase::RefreshPhysics(), SetState(), SetState(), SetState(), Inventory_Base::SetState(), SetState(), StaminaConsumer(), HFSMBase< Class FSMStateBase, Class FSMEventBase, Class FSMActionBase, Class FSMGuardBase >::Start(), HFSMBase< Class FSMStateBase, Class FSMEventBase, Class FSMActionBase, Class FSMGuardBase >::Terminate(), ItemBase::ToggleAnimation(), HFSMBase< Class FSMStateBase, Class FSMEventBase, Class FSMActionBase, Class FSMGuardBase >::Update(), and HFSMBase< WeaponStateBase, WeaponEventBase, WeaponActionBase, WeaponGuardBase >::ValidateAndRepairHelper().

◆ m_Tick

◆ m_Type

int m_Type
protected

Definition at line 136 of file StaminaHandler.c.

◆ MASK

MASK = 1

Definition at line 3 of file StaminaHandler.c.

◆ RANDOMIZED

const int RANDOMIZED = 1
protected

Definition at line 196 of file StaminaHandler.c.

Referenced by RegisterRandomized().