Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
shockdamage.c
Go to the documentation of this file.
2 {
3  const int UNCONSIOUSS_COOLDOWN_TIME = 60;//in s
4  override void Init()
5  {
6  m_TrackActivatedTime = false;
7  m_ID = eModifiers.MDF_SHOCK_DAMAGE;
10  }
11 
12  override void OnActivate(PlayerBase player)
13  {
14 
15  }
16 
17  override void OnReconnect(PlayerBase player)
18  {
19 
20  }
21 
22  override bool ActivateCondition(PlayerBase player)
23  {
24  if( !player.IsUnconscious() && player.GetHealth("","Blood") <= PlayerConstants.SHOCK_DAMAGE_BLOOD_THRESHOLD_HIGH && GetGame().GetTime() > (player.m_UnconsciousEndTime + UNCONSIOUSS_COOLDOWN_TIME) )
25  {
26  return true;
27  }
28  else
29  {
30  return false;
31  }
32  }
33 
34  override bool DeactivateCondition(PlayerBase player)
35  {
36  return !ActivateCondition(player);
37  }
38  // ------------------------------------------------------------------------------
39 
40  override void OnTick(PlayerBase player, float deltaT)
41  {
42  float blood = player.GetHealth("","Blood");
43  float value = Math.InverseLerp( PlayerConstants.SHOCK_DAMAGE_BLOOD_THRESHOLD_HIGH, PlayerConstants.SHOCK_DAMAGE_BLOOD_THRESHOLD_LOW, blood );
44  value = Math.Clamp(value,0,1);
45  float dmg = Math.Lerp( PlayerConstants.SHOCK_DAMAGE_HIGH, PlayerConstants.SHOCK_DAMAGE_LOW, value);
46  float damage = -dmg * deltaT;
47  player.AddHealth("","Shock", damage);
48  //PrintString(damage.ToString());
49  }
50 };
GetGame
proto native CGame GetGame()
ShockDamageMdfr
Definition: shockdamage.c:1
m_TickIntervalActive
float m_TickIntervalActive
Definition: modifierbase.c:19
m_TrackActivatedTime
bool m_TrackActivatedTime
Definition: modifierbase.c:15
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
GetTime
float GetTime()
Definition: notificationsystem.c:35
Math
Definition: enmath.c:6
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