Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
hunger.c
Go to the documentation of this file.
2 {
3  protected float m_EnergyDelta;
4  protected float m_LastEnergyLevel;
5  ref HumanMovementState m_MovementState = new HumanMovementState();
6 
7  override void Init()
8  {
9  m_TrackActivatedTime = false;
10  m_ID = eModifiers.MDF_HUNGER;
14  }
15 
16  override bool ActivateCondition(PlayerBase player)
17  {
18  return true;
19  }
20 
21  override bool DeactivateCondition(PlayerBase player)
22  {
23  return false;
24  }
25 
26  override void OnReconnect(PlayerBase player)
27  {
28 
29  }
30 
31  override void OnTick(PlayerBase player, float deltaT)
32  {
33  player.GetMovementState(m_MovementState);
34  float energy = player.GetStatEnergy().Get();
35  float metabolic_speed = MiscGameplayFunctions.GetEnergyMetabolicSpeed(m_MovementState.m_iMovement);
36 
37  float modifier = energy/PlayerConstants.SL_ENERGY_MAX + PlayerConstants.CONSUMPTION_MULTIPLIER_BASE;
38  metabolic_speed *= modifier; //non linear shaping for consumption curve (comment out to have it linear)
39 
40  player.GetStatEnergy().Add( -metabolic_speed * deltaT );
41  if ( energy <= PlayerConstants.LOW_ENERGY_THRESHOLD )
42  {
43  player.SetMixedSoundState( eMixedSoundStates.HUNGRY );
44  if ((player.GetStomach().GetDigestingType() & PlayerStomach.DIGESTING_ENERGY) == 0)
45  player.AddHealth("GlobalHealth", "Health", -PlayerConstants.LOW_ENERGY_DAMAGE_PER_SEC * deltaT );
46  }
47  else
48  {
49  player.UnsetMixedSoundState( eMixedSoundStates.HUNGRY );
50  }
51  }
52 };
eMixedSoundStates
eMixedSoundStates
bits
Definition: emixedsoundstates.c:2
m_TickIntervalActive
float m_TickIntervalActive
Definition: modifierbase.c:19
PlayerStomach
void PlayerStomach(PlayerBase player)
Definition: playerstomach.c:127
m_TrackActivatedTime
bool m_TrackActivatedTime
Definition: modifierbase.c:15
HumanMovementState
Definition: human.c:1125
m_MovementState
ref HumanMovementState m_MovementState
movement state
Definition: dayzplayercamera3rdperson.c:155
DisableDeactivateCheck
void DisableDeactivateCheck()
Definition: modifierbase.c:83
PlayerBase
Definition: playerbaseclient.c:1
PlayerConstants
Definition: playerconstants.c:1
m_TickIntervalInactive
float m_TickIntervalInactive
Definition: modifierbase.c:18
eModifiers
eModifiers
Definition: emodifiers.c:1
ModifierBase
Definition: breathvapourmdfr.c:3
HungerMdfr
Definition: hunger.c:1
m_ID
protected int m_ID
ID of effect, given by SEffectManager when registered (automatically done when playing through it)
Definition: effect.c:49
DEFAULT_TICK_TIME_INACTIVE
const int DEFAULT_TICK_TIME_INACTIVE
Definition: modifiersmanager.c:33