DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
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 {
9 m_ID = eModifiers.MDF_DROWNING;
12 m_SyncID = eModifierSyncIDs.MODIFIER_SYNC_DROWNING;
13 }
14
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);
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};
protected int m_ID
ID of effect, given by SEffectManager when registered (automatically done when playing through it)
Definition Effect.c:49
DayZPlayer m_Player
Definition Hand_Events.c:42
bool m_TrackActivatedTime
eModifierSyncIDs m_SyncID
float m_TickIntervalActive
float m_TickIntervalInactive
eModifierSyncIDs
const int DEFAULT_TICK_TIME_INACTIVE
EStaminaMultiplierTypes
override ScriptCallQueue GetCallQueue(int call_category)
Definition DayZGame.c:1153
static float GetShockDepletionSpeed()
static float GetHealthDepletionSpeed()
void RequestSoundEventEx(EPlayerSoundEventID id, bool from_server_and_client=false, int param=0)
override bool DeactivateCondition(PlayerBase player)
Definition Drowning.c:25
override void OnReconnect(PlayerBase player)
Definition Drowning.c:40
override void OnActivate(PlayerBase player)
Definition Drowning.c:45
bool CheckIsDrowning(PlayerBase player)
Definition Drowning.c:15
override void OnTick(PlayerBase player, float deltaT)
Definition Drowning.c:30
override void Init()
Definition Drowning.c:6
override bool ActivateCondition(PlayerBase player)
Definition Drowning.c:20
override void OnDeactivate(PlayerBase player)
Definition Drowning.c:69
void PlayDrowningSound(int index)
Definition Drowning.c:54
const int TICK_FREQUENCY
Definition Drowning.c:3
static const float STAMINA_RECOVERY_MULTIPLIER
Definition Drowning.c:4
proto void CallLater(func fn, int delay=0, bool repeat=false, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
adds call into the queue with given parameters and arguments (arguments are held in memory until the ...
eModifiers
Definition eModifiers.c:2
proto native CGame GetGame()
const int CALL_CATEGORY_SYSTEM
Definition tools.c:8
class HumanMovementState OnActivate()
HumanCommandScript fully scriptable command.
Definition human.c:1169