DayZ 1.24
Loading...
Searching...
No Matches
ContaminatedTrigger.c
Go to the documentation of this file.
1// In this file you will find both Static and Dynamic contaminated area triggers
2class ContaminatedTrigger extends EffectTrigger
3{
4 const float DAMAGE_TICK_RATE = 10;//deal damage every n-th second
5
6 // ----------------------------------------------
7 // TRIGGER EVENTS
8 // ----------------------------------------------
9
10 override void OnEnterServerEvent(TriggerInsider insider)
11 {
12 super.OnEnterServerEvent(insider);
13 //Print("Entered A " + GetType());
14 if (insider)
15 {
17
18 if (creature)
19 creature.IncreaseEffectTriggerCount();
20 }
21
22 }
23
24 override void OnLeaveServerEvent(TriggerInsider insider)
25 {
26 super.OnLeaveServerEvent(insider);
27 //Print("Left A " + GetType());
28 if (insider)
29 {
31
32 if (creature)
33 creature.DecreaseEffectTriggerCount();
34
35 }
36 }
37
38 override void OnEnterClientEvent(TriggerInsider insider)
39 {
40 super.OnEnterClientEvent(insider);
41 }
42
43 override void OnLeaveClientEvent(TriggerInsider insider)
44 {
45 super.OnLeaveClientEvent(insider);
46 }
47
48
50 {
51 m_TimeAccuStay += m_DeltaTime;
52 if (m_TimeAccuStay > DAMAGE_TICK_RATE)
53 {
54 m_DealDamageFlag = true;
55 //this is where we would normally reset the m_TimeAccuStay, but we need the value as deltaT when dealing damage to the insiders, so we reset it only after the insider update in OnStayFinishServerEvent
56 }
57
58 }
59
61 {
62 if (m_DealDamageFlag) //the flag was previously set to true, the insiders have been updated at this point, reset the flag and the timer as well
63 {
64 m_TimeAccuStay = 0;
65 m_DealDamageFlag = false;
66 }
67 }
68
69 override void OnStayServerEvent(TriggerInsider insider, float deltaTime)
70 {
71 if (m_DealDamageFlag)
72 {
74 if (creature && creature.m_EffectTriggerCount != 0)
75 creature.DecreaseHealth("", "", GameConstants.AI_CONTAMINATION_DMG_PER_SEC * m_TimeAccuStay / creature.m_EffectTriggerCount);// we devide by m_EffectTriggerCount for multiple trigger presence(overlapping triggers)
76 }
77 }
78
79 override string GetAmbientSoundsetName()
80 {
81 return "ContaminatedArea_SoundSet";
82 }
83
84
85}
86
87class ContaminatedTrigger_Dynamic : ContaminatedTrigger
88{
89 protected int m_AreaState; // Used to get the state from linked area and update effects
90
92 {
93 RegisterNetSyncVariableInt("m_AreaState");
94
95 // Register in the trigger effect manager
97 m_Manager.RegisterTriggerType(this);
98 }
99
101 {
103 SetSynchDirty();
104 }
105
106
107 override protected void OnStayClientEvent(TriggerInsider insider, float deltaTime)
108 {
109 //no super, overriding parent behaviour
110 if (insider.GetObject().IsMan())
111 {
113
114 // We will only handle the controlled player, as effects are only relevant to this player instance
115 if (playerInsider.IsControlledPlayer())
116 {
117 // We check if we are not in the standard LIVE state
119 if (nonDefaultState)
120 {
121 // if not we check the specific state and update local effect values
123 if (m_AreaState == eAreaDecayStage.DECAY_START)
125 else
127
128 playerInsider.RequestTriggerEffect(this, m_PPERequester, m_AroundPartId, m_TinyPartId, GetAmbientSoundsetName(), nonDefaultState, localPartBirthRate);
129 }
130 else
131 playerInsider.RequestTriggerEffect(this, m_PPERequester, m_AroundPartId, m_TinyPartId, GetAmbientSoundsetName());
132 }
133 }
134 }
135
136
138 {
139 super.OnVariablesSynchronized();
140
141 // Is the controlled player inside when trigger is synchronized
142 for (int i = 0; i < GetInsiders().Count(); i++)
143 {
144 PlayerBase playerInsider = PlayerBase.Cast(m_insiders.Get(i).GetObject());
145 if (playerInsider)
146 {
147 if (playerInsider.IsControlledPlayer())
148 {
149 // Update Local particle effects
151 if (nonDefaultState)
152 {
154 if (m_AreaState == eAreaDecayStage.DECAY_START)
156 else
158
159 //Update the local effects
160 playerInsider.RequestTriggerEffect(this, m_PPERequester, m_AroundPartId, m_TinyPartId, GetAmbientSoundsetName(), nonDefaultState, localPartBirthRate, true);
161 }
162 return;
163 }
164 }
165 }
166 }
167}
168
169
170class ContaminatedTrigger_Local : ContaminatedTrigger
171{
172 override string GetAmbientSoundsetName()
173 {
174 return "";
175 }
176
177}
override void OnVariablesSynchronized()
override void OnStayClientEvent(TriggerInsider insider, float deltaTime)
PPERequester_PainBlur m_PPERequester
void ContaminatedTrigger_Dynamic()
class ContaminatedTrigger extends EffectTrigger m_AreaState
void SetAreaState(int state)
ModifiersManager m_Manager
override string GetAmbientSoundsetName()
do not process rotations !
Definition DayZAnimal.c:573
override string GetAmbientSoundsetName()
override void OnStayFinishServerEvent()
override void OnStayServerEvent(TriggerInsider insider, float deltaTime)
override void OnLeaveServerEvent(TriggerInsider insider)
override void OnEnterClientEvent(TriggerInsider insider)
override void OnStayStartServerEvent(int nrOfInsiders)
override void OnLeaveClientEvent(TriggerInsider insider)
override void OnEnterServerEvent(TriggerInsider insider)
static TriggerEffectManager GetInstance()
The object which is in a trigger and its metadata.
Definition Trigger.c:3
Object GetObject()
Definition Trigger.c:28
const float AI_CONTAMINATION_DMG_PER_SEC
Definition constants.c:916