Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
shock.c
Go to the documentation of this file.
2 {
3  private const float UNCONSCIOUS_LIMIT = 50;
4  private const float SHOCK_INCREMENT_PER_SEC = 1;
5 
6  override void Init()
7  {
8  m_ID = eModifiers.MDF_SHOCK;
10  m_TickIntervalActive = 0.35;
11  //DisableActivateCheck();
13  }
14 
15  override bool ActivateCondition(PlayerBase player)
16  {
17  return true;
18  }
19 
20  override bool DeactivateCondition(PlayerBase player)
21  {
22  return false;
23  }
24 
25  override void OnActivate(PlayerBase player)
26  {
27  }
28 
29  override void OnDeactivate(PlayerBase player)
30  {
31  }
32 
33  float GetRefillSpeed(PlayerBase player)
34  {
35  if ( player.m_IsDrowning )
36  {
37  return 0;
38  }
39  if ( player.IsUnconscious() )
40  {
41  return CfgGameplayHandler.GetShockRefillSpeedUnconscious() * player.m_UnconRefillModifier;
42  }
43  if (player.GetBrokenLegs() != eBrokenLegs.BROKEN_LEGS || (player.m_MovementState.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_PRONE || player.m_MovementState.m_iStanceIdx == DayZPlayerConstants.STANCEIDX_RAISEDPRONE))
44  {
45  return CfgGameplayHandler.GetShockRefillSpeedConscious();
46  }
47  if ( player.GetBrokenLegs() == eBrokenLegs.BROKEN_LEGS && (player.IsSwimming() || player.IsClimbingLadder()) )
48  {
49  return CfgGameplayHandler.GetShockRefillSpeedUnconscious();
50  }
51  return 0; //Block shock regen when standing with broken legs
52  }
53 
54  override void OnTick(PlayerBase player, float deltaT)
55  {
56  //Print("m_UnconRefillModifier" + player.m_UnconRefillModifier);
57  if ( GetGame().GetTime() > player.m_LastShockHitTime + PlayerConstants.SHOCK_REFILL_COOLDOWN_AFTER_HIT && player.GetPulseType() == EPulseType.REGULAR)
58  {
59  if (!player.IsUnconscious())
60  player.m_UnconRefillModifier = 1;//reset this UnconRefillModifier some time after the player has been hit(we want the UnconRefillModifier to only apply to uncon induced by a projectile)
61 
62  if (player.GetHealth01("","Shock") == 1)//no need to continue if the shock is full
63  return;
64 
65  if ( !CfgGameplayHandler.GetAllowRefillSpeedModifier() )
66  player.m_UnconRefillModifier = 1;
67 
68  player.AddHealth("","Shock", deltaT * GetRefillSpeed(player) );
69  }
70  }
71 
72  override void OnReconnect(PlayerBase player)
73  {
74 
75  }
76 };
GetGame
proto native CGame GetGame()
m_TickIntervalActive
float m_TickIntervalActive
Definition: modifierbase.c:19
eBrokenLegs
eBrokenLegs
Definition: ebrokenlegs.c:1
DisableDeactivateCheck
void DisableDeactivateCheck()
Definition: modifierbase.c:83
PlayerBase
Definition: playerbaseclient.c:1
ShockMdfr
Definition: shock.c:1
PlayerConstants
Definition: playerconstants.c:1
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition: dayzplayer.c:601
EPulseType
EPulseType
Definition: epulsetype.c:1
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
GetTime
float GetTime()
Definition: notificationsystem.c:35
m_ID
protected int m_ID
ID of effect, given by SEffectManager when registered (automatically done when playing through it)
Definition: effect.c:49