DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
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 {
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};
eBrokenLegs
Definition EBrokenLegs.c:2
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
float m_TickIntervalActive
float m_TickIntervalInactive
EActivationType m_ActivationType
bool m_IsPersistent
EActivationType
const int DEFAULT_TICK_TIME_INACTIVE
eNotifiers
override bool DeactivateCondition(PlayerBase player)
Definition BrokenLegs.c:49
override void OnReconnect(PlayerBase player)
Definition BrokenLegs.c:29
override void OnActivate(PlayerBase player)
Definition BrokenLegs.c:22
private const float TIME_TO_UPDATE
Definition BrokenLegs.c:5
private const float HEALTHY_LEG
Definition BrokenLegs.c:3
override void OnTick(PlayerBase player, float deltaT)
Definition BrokenLegs.c:62
override void Init()
Definition BrokenLegs.c:12
override void OnDeactivate(PlayerBase player)
Definition BrokenLegs.c:37
private int currentState
Definition BrokenLegs.c:4
private float elapsedTime
Definition BrokenLegs.c:6
eModifiers
Definition eModifiers.c:2
const int CALL_CATEGORY_SYSTEM
Definition tools.c:8