DayZ 1.24
Loading...
Searching...
No Matches
AreaDamageManager.c
Go to the documentation of this file.
2{
3 const int BASE = 0;
4 const int HITZONE = 1;
5 const int RAYCASTED = 2;
6}
7
8class AreaDamageManager : AreaDamageEvents
9{
12
13 protected ref AreaDamageComponent m_DamageComponent;
14
19
20 protected string m_TriggerBaseClass;
21
23 {
24 m_ParentObject = parent;
25
27
30 m_AreaPosition = parent.GetPosition();
31 m_AreaOrientation = parent.GetOrientation();
32
33 m_TriggerBaseClass = "AreaDamageTriggerBase";
34 }
35
37 {
38 Destroy();
39 }
40
42 {
43 switch (type)
44 {
46 {
48 break;
49 }
51 {
53 break;
54 }
56 {
58 break;
59 }
60
61 default:
62 {
63 Error(string.Format("[ERROR] :: [AreaDamageManager] :: Unknown DamageComponentType: %1", type));
64 break;
65 }
66 }
67 }
68
70 void Spawn()
71 {
74 }
75
77 void Destroy()
78 {
81 }
82
84
91 override void OnTriggerCreated()
92 {
93 m_DamageComponent.OnTriggerCreated();
94 }
95
97 override void OnTriggerDestroyed()
98 {
99 m_DamageComponent.OnTriggerDestroyed();
100 }
101
103 override void OnEnterBeginEvent(TriggerInsider insider)
104 {
105 m_DamageComponent.OnEnterBeginEvent(insider);
106 }
107 override void OnEnterServerEvent(TriggerInsider insider)
108 {
109 m_DamageComponent.OnEnterServerEvent(insider);
110 }
111 override void OnEnterClientEvent(TriggerInsider insider)
112 {
113 m_DamageComponent.OnEnterClientEvent(insider);
114 }
115 override void OnEnterEndEvent(TriggerInsider insider)
116 {
117 m_DamageComponent.OnEnterEndEvent(insider);
118 }
119
122 {
123 m_DamageComponent.OnStayStartBeginEvent(nrOfInsiders);
124 }
126 {
127 m_DamageComponent.OnStayStartServerEvent(nrOfInsiders);
128 }
130 {
131 m_DamageComponent.OnStayStartClientEvent(nrOfInsiders);
132 }
134 {
135 m_DamageComponent.OnStayStartEndEvent(nrOfInsiders);
136 }
137
139 override void OnStayBeginEvent(TriggerInsider insider, float deltaTime)
140 {
141 m_DamageComponent.OnStayBeginEvent(insider, deltaTime);
142 }
143 override void OnStayServerEvent(TriggerInsider insider, float deltaTime)
144 {
145 m_DamageComponent.OnStayServerEvent(insider, deltaTime);
146 }
147 override void OnStayClientEvent(TriggerInsider insider, float deltaTime)
148 {
149 m_DamageComponent.OnStayClientEvent(insider, deltaTime);
150 }
151 override void OnStayEndEvent(TriggerInsider insider, float deltaTime)
152 {
153 m_DamageComponent.OnStayEndEvent(insider, deltaTime);
154 }
155
158 {
159 m_DamageComponent.OnStayFinishBeginEvent();
160 }
162 {
163 m_DamageComponent.OnStayFinishServerEvent();
164 }
166 {
167 m_DamageComponent.OnStayFinishClientEvent();
168 }
169 override void OnStayFinishEndEvent()
170 {
171 m_DamageComponent.OnStayFinishEndEvent();
172 }
173
175 override void OnLeaveBeginEvent(TriggerInsider insider)
176 {
177 m_DamageComponent.OnLeaveBeginEvent(insider);
178 }
179 override void OnLeaveServerEvent(TriggerInsider insider)
180 {
181 m_DamageComponent.OnLeaveServerEvent(insider);
182 }
183 override void OnLeaveClientEvent(TriggerInsider insider)
184 {
185 m_DamageComponent.OnLeaveClientEvent(insider);
186 }
187 override void OnLeaveEndEvent(TriggerInsider insider)
188 {
189 m_DamageComponent.OnLeaveEndEvent(insider);
190 }
191
193 override bool OnEvaluateDamage(TriggerInsider insider, float damageCoef)
194 {
195 return m_DamageComponent.OnEvaluateDamage(insider, damageCoef);
196 }
197
199 override void PreDamageActions()
200 {
201 if (m_ParentObject)
202 m_ParentObject.PreAreaDamageActions();
203 }
204
206 override void PostDamageActions()
207 {
208 if (m_ParentObject)
209 m_ParentObject.PostAreaDamageActions();
210 }
213
214
219 {
220 return OnEvaluateDamage(insider, CalculateDamageScale(insider, deltaTime));
221 }
222
224 protected float CalculateDamageScale(TriggerInsider insider, float deltaTime)
225 {
226 return deltaTime;
227 }
229
230
253
255 {
256 m_DamageComponent.m_AmmoName = ammo_name;
257 }
258 string GetAmmoName()
259 {
260 return m_DamageComponent.m_AmmoName;
261 }
262
264 {
265 m_DamageComponent.m_DamageType = pDamageType;
266 }
268 {
269 return m_DamageComponent.m_DamageType;
270 }
271
273 {
274 m_ParentObject = obj;
275 }
277 {
278 return m_ParentObject;
279 }
280
289 {
290 return m_AreaPosition;
291 }
292
301 {
302 return m_AreaOrientation;
303 }
304
310 {
311 return m_DamageComponent.m_DamageableTypes;
312 }
313
315 {
316 if (m_DamageComponent.m_DamageableTypes.Find(damageableType) != -1)
317 m_DamageComponent.m_DamageableTypes.Insert(damageableType);
318 }
319
321 {
322 m_DamageComponent.m_DamageableTypes.RemoveItem(damageableType);
323 }
324
326 {
327 Error("SetLoopInterval not implemented - usable in Regular(looped) area damage objects only");
328 }
329
331 {
332 Error("SetDeferDuration not implemented - usable in Deferred area damage objects only");
333 }
334
336 {
338 if (CastTo(adc, m_DamageComponent))
339 adc.SetHitZones(hitzones);
340 else
341 Error("SetHitZones not implemented - override for non raycasted versions of area damage objects only");
342 }
343
345 {
347 if (CastTo(adc, m_DamageComponent))
348 adc.SetRaycastSources(raycast_sources);
349 else
350 Error("SetRaycastSources not implemented - override for raycasted versions of area damage objects only");
351 }
352
354 {
356 if (CastTo(adc, m_DamageComponent))
357 adc.SetRaycastSourcesVector(raycast_sources);
358 else
359 Error("SetRaycastSources not implemented - override for raycasted versions of area damage objects only");
360 }
361
367
368
371 protected bool CreateDamageTriggerEx()
372 {
373 int flags;
374
375 if (GetGame().IsMultiplayer() && GetGame().IsServer())
376 flags = ECE_CREATEPHYSICS;
377 else
378 flags = ECE_LOCAL;
379
381 {
385 return true;
386 }
387
388 return false;
389 }
390
391 protected void CreateDamageTrigger()
392 {
394 }
396
397
400 protected bool DestroyDamageTriggerEx()
401 {
402 if (GetGame() && m_AreaDamageTrigger) // It's necesarry to check if the game exists. Otherwise a crash occurs while quitting.
403 {
404 GetGame().ObjectDelete(m_AreaDamageTrigger);
406 return true;
407 }
408
409 return false;
410 }
411
412 protected void DestroyDamageTrigger()
413 {
415 }
417}
ref array< typename > m_DamageableTypes void AreaDamageComponent(AreaDamageManager parent)
vector m_AreaPosition
bool DestroyDamageTriggerEx()
void AddDamageableType(typename damageableType)
void SetAreaOrientation(vector orientation)
override void OnStayStartBeginEvent(int nrOfInsiders)
Called at the beginning of an update loop.
void GetExtents(out vector mins, out vector maxs)
void SetDamageType(int pDamageType)
vector m_ExtentMin
vector m_ExtentMax
void SetDamageComponentType(int type)
AreaDamageTriggerBase GetTrigger()
void CreateDamageTrigger()
void SetExtents(vector mins, vector maxs)
array< typename > GetDamageableTypes()
override void OnStayServerEvent(TriggerInsider insider, float deltaTime)
void SetLoopInterval(float time)
override void OnStayClientEvent(TriggerInsider insider, float deltaTime)
vector GetOrientation()
override bool OnEvaluateDamage(TriggerInsider insider, float damageCoef)
Tell the AreaDamageComponent to calculate and apply the damage to the Object.
void SetDeferDuration(float time)
void GetWorldExtents(out vector mins, out vector maxs)
override void OnLeaveEndEvent(TriggerInsider insider)
void ~AreaDamageManager()
override void OnLeaveBeginEvent(TriggerInsider insider)
Called when an object leaves the trigger.
string m_TriggerBaseClass
override void OnStayStartServerEvent(int nrOfInsiders)
override void OnStayFinishServerEvent()
override void OnEnterEndEvent(TriggerInsider insider)
override void OnStayStartEndEvent(int nrOfInsiders)
void SetParentObject(EntityAI obj)
override void PostDamageActions()
Usually called from AreaDamageComponent.
override void OnStayFinishEndEvent()
void DestroyDamageTrigger()
float CalculateDamageScale(TriggerInsider insider, float deltaTime)
Helper for calculating damageCoeff when using OnEvaluateDamageEx.
void Spawn()
spawn damage trigger
override void OnLeaveClientEvent(TriggerInsider insider)
void RemoveAddDamageableType(typename damageableType)
bool CreateDamageTriggerEx()
void SetDamageableTypes(array< typename > damageableTypes)
void SetAreaPosition(vector position)
void SetHitZones(array< string > hitzones)
void SetAmmoName(string ammo_name)
override void OnStayFinishClientEvent()
bool OnEvaluateDamageEx(TriggerInsider insider, float deltaTime)
override void OnStayStartClientEvent(int nrOfInsiders)
ref AreaDamageComponent m_DamageComponent
vector m_AreaOrientation
override void OnStayEndEvent(TriggerInsider insider, float deltaTime)
override void OnTriggerCreated()
string GetAmmoName()
int GetDamageType()
void AreaDamageManager(EntityAI parent)
override void PreDamageActions()
Usually called from AreaDamageComponent.
override void OnStayFinishBeginEvent()
Called at the end of an update loop.
AreaDamageTriggerBase m_AreaDamageTrigger
override void OnStayBeginEvent(TriggerInsider insider, float deltaTime)
Called in the update loop.
override void OnLeaveServerEvent(TriggerInsider insider)
void SetRaycastSources(array< string > raycast_sources)
override void OnTriggerDestroyed()
Called when a trigger is destroyed.
override void OnEnterBeginEvent(TriggerInsider insider)
Called when an object enters the trigger.
void SetRaycastSourcesVector(array< vector > raycast_sources)
override void OnEnterServerEvent(TriggerInsider insider)
EntityAI GetParentObject()
override void OnEnterClientEvent(TriggerInsider insider)
const int ECE_LOCAL
const int ECE_CREATEPHYSICS
Object m_ParentObject
Cached parent.
Definition Effect.c:39
class JsonUndergroundAreaTriggerData GetPosition
Newer implementation equivalent of "AreaDamageRegular", hitzone selection only.
Newer implementation equivalent of "AreaDamageRegularRaycasted", hitzone selection only.
Events used across AreaDamage API, calling of these needs to be handled by parent.
override void SetAreaDamageManager(AreaDamageManager adType)
override void SetExtents(vector mins, vector maxs)
Super root of all classes in Enforce script.
Definition EnScript.c:11
The object which is in a trigger and its metadata.
Definition Trigger.c:3
static const vector Zero
Definition EnConvert.c:110
proto native CGame GetGame()
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90
proto native void Destroy()
Cleans up the Effect, including unregistering if needed.
Definition Effect.c:207
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.