Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
flies.c
Go to the documentation of this file.
2 {
3  const float DISTANCE_SENSITIVITY_SQR = Math.SqrFloat(0.05/*actual distance in meters*/);
4  const int TICK_FREQUENCY = 15;
5  const int IDLE_COUNT_THRESHOLD = 40;
6  vector m_PrevPosition;
7  int m_IdleCount;
8 
9 
10  override void Init()
11  {
12  m_TrackActivatedTime = false;
13  m_ID = eModifiers.MDF_FLIES;
15  m_TickIntervalActive = TICK_FREQUENCY;
18  }
19 
20  override bool ActivateCondition(PlayerBase player)
21  {
22  return false;
23  }
24 
25  override bool DeactivateCondition(PlayerBase player)
26  {
27  return false;
28  }
29 
30  override void OnTick(PlayerBase player, float deltaT)
31  {
32  float dist_sqr = vector.DistanceSq(player.GetPosition(), m_PrevPosition);
33  if( dist_sqr < DISTANCE_SENSITIVITY_SQR)//has the player stayed still since last check
34  {
35  m_IdleCount++;
36  }
37  else
38  {
39  if(m_IdleCount >= IDLE_COUNT_THRESHOLD)//disable the effect
40  {
41  player.m_CorpseState = -PlayerConstants.CORPSE_STATE_DECAYED;
42  player.SetSynchDirty();
43  }
44 
45  m_IdleCount = 0;//player moved, reset the count
46  }
47  m_PrevPosition = player.GetPosition();
48 
49  if( m_IdleCount == IDLE_COUNT_THRESHOLD)//should we play the effect ?
50  {
51  player.m_CorpseState = PlayerConstants.CORPSE_STATE_DECAYED;
52  player.SetSynchDirty();
53  }
54 
55 
56  }
57 
58  override void OnReconnect(PlayerBase player)
59  {
60  OnActivate(player);
61  }
62 
63  override void OnActivate(PlayerBase player)
64  {
65  m_IdleCount = 0;
66  player.m_CorpseState = -PlayerConstants.CORPSE_STATE_DECAYED;
67  player.SetSynchDirty();
68  }
69 
70  override void OnDeactivate(PlayerBase player)
71  {
72 
73  }
74 
75 
76 
77 };
m_TickIntervalActive
float m_TickIntervalActive
Definition: modifierbase.c:19
m_TrackActivatedTime
bool m_TrackActivatedTime
Definition: modifierbase.c:15
DisableDeactivateCheck
void DisableDeactivateCheck()
Definition: modifierbase.c:83
FliesMdfr
Definition: flies.c:1
PlayerBase
Definition: playerbaseclient.c:1
PlayerConstants
Definition: playerconstants.c:1
vector
Definition: enconvert.c:105
m_TickIntervalInactive
float m_TickIntervalInactive
Definition: modifierbase.c:18
eModifiers
eModifiers
Definition: emodifiers.c:1
ModifierBase
Definition: breathvapourmdfr.c:3
DisableActivateCheck
void DisableActivateCheck()
Definition: modifierbase.c:78
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