Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
brokenlegs.c
Go to the documentation of this file.
2 {
3  private const float HEALTHY_LEG = 100; //Health at which legs are no longer considered broken
4  private int currentState = -1; //Current broken leg state used upon reconnect
5  private const float TIME_TO_UPDATE = 0.5;
6  private float elapsedTime = TIME_TO_UPDATE + 1;
7 
8  #ifdef DEVELOPER
9  ref static Timer timer;
10  #endif
11 
12  override void Init()
13  {
14  m_TrackActivatedTime = false;
15  m_ID = eModifiers.MDF_BROKEN_LEGS;
18  m_ActivationType = EActivationType.TRIGGER_EVENT_ON_ACTIVATION;
19  m_IsPersistent = true;
20  }
21 
22  override void OnActivate(PlayerBase player)
23  {
24  //Print("------------> OnActivate - BrokenLegsMdfr");
25  player.SetBrokenLegs(-eBrokenLegs.BROKEN_LEGS);//note the negative sign
26  player.GetNotifiersManager().ActivateByType(eNotifiers.NTF_FRACTURE);
27  }
28 
29  override void OnReconnect(PlayerBase player)
30  {
31  //Print("------------> OnReconnect - BrokenLegsMdfr");
32  player.SetBrokenLegs(player.GetBrokenLegs());
33  player.GetNotifiersManager().ActivateByType(eNotifiers.NTF_FRACTURE);
34  }
35 
36 
37  override void OnDeactivate(PlayerBase player)
38  {
39  player.UpdateBrokenLegs(eBrokenLegs.NO_BROKEN_LEGS);
40  if ( player.IsWearingSplint() )
41  {
42  MiscGameplayFunctions.RemoveSplint(player); //Remove splint when leg is healed
43  }
44 
45  player.SetBrokenLegs(eBrokenLegs.NO_BROKEN_LEGS);
46  player.GetNotifiersManager().DeactivateByType(eNotifiers.NTF_FRACTURE);
47  }
48 
49  override bool DeactivateCondition(PlayerBase player)
50  {
51  if ( player.GetHealth("RightLeg", "Health") >= HEALTHY_LEG && player.GetHealth("LeftLeg", "Health") >= HEALTHY_LEG )
52  {
53 
54  return true;
55  }
56  else
57  {
58  return false;
59  }
60  }
61 
62  override void OnTick(PlayerBase player, float deltaT)
63  {
64  player.UpdateBrokenLegs(/*legacy param - value not used*/0);
65  }
66 
67 
68  #ifdef DEVELOPER
69  static void DelayedRequest(PlayerBase player, bool state)
70  {
71  timer = new Timer( CALL_CATEGORY_SYSTEM );
72  if(state)
73  timer.Run( 10 , player.GetModifiersManager().GetModifier(eModifiers.MDF_BROKEN_LEGS), "Delayed", new Param1<bool>(state));
74  else
75  BrokenLegsMdfr.Cast(player.GetModifiersManager().GetModifier(eModifiers.MDF_BROKEN_LEGS)).Delayed(false);
76  }
77 
78  void Delayed(bool state)
79  {
80  m_Player.GetModifiersManager().ActivateModifier(eModifiers.MDF_BROKEN_LEGS);
81  }
82  #endif
83 };
CALL_CATEGORY_SYSTEM
const int CALL_CATEGORY_SYSTEM
Definition: tools.c:8
BrokenLegsMdfr
Definition: brokenlegs.c:1
m_ActivationType
EActivationType m_ActivationType
Definition: modifierbase.c:28
m_TickIntervalActive
float m_TickIntervalActive
Definition: modifierbase.c:19
m_TrackActivatedTime
bool m_TrackActivatedTime
Definition: modifierbase.c:15
EActivationType
EActivationType
Definition: modifiersmanager.c:24
eBrokenLegs
eBrokenLegs
Definition: ebrokenlegs.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
m_IsPersistent
bool m_IsPersistent
Definition: modifierbase.c:16
eNotifiers
eNotifiers
Definition: notifiersmanager.c:1
Timer
Definition: dayzplayerimplement.c:62
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