Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
drowning.c
Go to the documentation of this file.
2 {
3  const int TICK_FREQUENCY = 1;
4  static const float STAMINA_RECOVERY_MULTIPLIER = 0;
5 
6  override void Init()
7  {
8  m_TrackActivatedTime = false;
9  m_ID = eModifiers.MDF_DROWNING;
11  m_TickIntervalActive = TICK_FREQUENCY;
12  m_SyncID = eModifierSyncIDs.MODIFIER_SYNC_DROWNING;
13  }
14 
15  bool CheckIsDrowning(PlayerBase player)
16  {
17  return player.GetDrowningWaterLevelCheck();
18  }
19 
20  override bool ActivateCondition(PlayerBase player)
21  {
22  return CheckIsDrowning(player);
23  }
24 
25  override bool DeactivateCondition(PlayerBase player)
26  {
27  return !CheckIsDrowning(player);
28  }
29 
30  override void OnTick(PlayerBase player, float deltaT)
31  {
32  if (player.GetStaminaHandler().GetStamina() <= 0)
33  {
34  player.AddHealth("","",deltaT * -CfgGameplayHandler.GetHealthDepletionSpeed());
35  player.AddHealth("","Shock",deltaT * -CfgGameplayHandler.GetShockDepletionSpeed());
36  player.RequestSoundEventEx(EPlayerSoundEventID.DROWNING_PAIN, false, EPlayerSoundEventParam.HIGHEST_PRIORITY);
37  }
38  }
39 
40  override void OnReconnect(PlayerBase player)
41  {
42  OnActivate(player);
43  }
44 
45  override void OnActivate(PlayerBase player)
46  {
47  player.SetDrowning(true);
48  player.GetStaminaHandler().ActivateRecoveryModifier(EStaminaMultiplierTypes.DROWNING);
49  player.RequestSoundEventEx(EPlayerSoundEventID.DROWNING_BREATH, false, EPlayerSoundEventParam.HIGHEST_PRIORITY);
50  GetGame().GetCallQueue( CALL_CATEGORY_SYSTEM ).CallLater( PlayDrowningSound, 3000 ,false, 1);
51  }
52 
53 
54  void PlayDrowningSound(int index)
55  {
56  if (m_Player.m_IsDrowning)//check if we are still drowning after the delay
57  {
58  if (index == 0)
59  {
60  m_Player.RequestSoundEventEx(EPlayerSoundEventID.EXHAUSTED_BREATH, false, EPlayerSoundEventParam.HIGHEST_PRIORITY);
61  }
62  else if (index == 1)
63  {
64  m_Player.RequestSoundEventEx(EPlayerSoundEventID.DROWNING_BREATH, false, EPlayerSoundEventParam.HIGHEST_PRIORITY);
65  }
66  }
67  }
68 
69  override void OnDeactivate(PlayerBase player)
70  {
71  player.SetDrowning(false);
72  player.GetStaminaHandler().DeactivateRecoveryModifier(EStaminaMultiplierTypes.DROWNING);
73  }
74 };
GetGame
proto native CGame GetGame()
CALL_CATEGORY_SYSTEM
const int CALL_CATEGORY_SYSTEM
Definition: tools.c:8
m_SyncID
eModifierSyncIDs m_SyncID
Definition: modifierbase.c:29
m_TickIntervalActive
float m_TickIntervalActive
Definition: modifierbase.c:19
m_TrackActivatedTime
bool m_TrackActivatedTime
Definition: modifierbase.c:15
EStaminaMultiplierTypes
EStaminaMultiplierTypes
Definition: staminahandler.c:1
DrowningMdfr
Definition: drowning.c:1
PlayerBase
Definition: playerbaseclient.c:1
m_Player
DayZPlayer m_Player
Definition: hand_events.c:42
m_TickIntervalInactive
float m_TickIntervalInactive
Definition: modifierbase.c:18
eModifiers
eModifiers
Definition: emodifiers.c:1
ModifierBase
Definition: breathvapourmdfr.c:3
CfgGameplayHandler
Definition: cfggameplayhandler.c:1
eModifierSyncIDs
eModifierSyncIDs
Definition: modifiersmanager.c:2
EPlayerSoundEventID
EPlayerSoundEventID
Definition: playersoundeventhandler.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