Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
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 
9 {
10  protected EntityAI m_ParentObject;
12 
14 
15  protected vector m_ExtentMin;
16  protected vector m_ExtentMax;
19 
20  protected string m_TriggerBaseClass;
21 
23  {
24  m_ParentObject = parent;
25 
27 
28  m_ExtentMin = vector.Zero;
29  m_ExtentMax = vector.Zero;
30  m_AreaPosition = parent.GetPosition();
31  m_AreaOrientation = parent.GetOrientation();
32 
33  m_TriggerBaseClass = "AreaDamageTriggerBase";
34  }
35 
37  {
38  Destroy();
39  }
40 
41  void SetDamageComponentType(int type)
42  {
43  switch (type)
44  {
45  case AreaDamageComponentTypes.BASE:
46  {
48  break;
49  }
50  case AreaDamageComponentTypes.HITZONE:
51  {
53  break;
54  }
55  case AreaDamageComponentTypes.RAYCASTED:
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  {
72  if ( CreateDamageTriggerEx() )
74  }
75 
77  void Destroy()
78  {
79  if ( DestroyDamageTriggerEx() )
81  }
82 
84 
89  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 
121  override void OnStayStartBeginEvent(int nrOfInsiders)
122  {
123  m_DamageComponent.OnStayStartBeginEvent(nrOfInsiders);
124  }
125  override void OnStayStartServerEvent(int nrOfInsiders)
126  {
127  m_DamageComponent.OnStayStartServerEvent(nrOfInsiders);
128  }
129  override void OnStayStartClientEvent(int nrOfInsiders)
130  {
131  m_DamageComponent.OnStayStartClientEvent(nrOfInsiders);
132  }
133  override void OnStayStartEndEvent(int nrOfInsiders)
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 
157  override void OnStayFinishBeginEvent()
158  {
159  m_DamageComponent.OnStayFinishBeginEvent();
160  }
161  override void OnStayFinishServerEvent()
162  {
163  m_DamageComponent.OnStayFinishServerEvent();
164  }
165  override void OnStayFinishClientEvent()
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 
218  bool OnEvaluateDamageEx(TriggerInsider insider, float deltaTime)
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 
233  void SetExtents( vector mins, vector maxs )
234  {
235  m_ExtentMin = mins;
236  m_ExtentMax = maxs;
237 
238  if ( m_AreaDamageTrigger )
239  {
241  }
242  }
243  void GetExtents( out vector mins, out vector maxs )
244  {
245  mins = m_ExtentMin;
246  maxs = m_ExtentMax;
247  }
248  void GetWorldExtents( out vector mins, out vector maxs )
249  {
250  GetExtents(mins, maxs);
251 
252  mins + m_AreaPosition;
253  maxs + m_AreaPosition;
254  }
255 
256  void SetAmmoName( string ammo_name )
257  {
258  m_DamageComponent.m_AmmoName = ammo_name;
259  }
260  string GetAmmoName()
261  {
262  return m_DamageComponent.m_AmmoName;
263  }
264 
265  void SetDamageType( int pDamageType )
266  {
267  m_DamageComponent.m_DamageType = pDamageType;
268  }
270  {
271  return m_DamageComponent.m_DamageType;
272  }
273 
275  {
276  m_ParentObject = obj;
277  }
279  {
280  return m_ParentObject;
281  }
282 
283  void SetAreaPosition( vector position )
284  {
285  m_AreaPosition = position;
286 
287  if ( m_AreaDamageTrigger )
288  {
289  m_AreaDamageTrigger.SetPosition(m_AreaPosition);
290  }
291  }
293  {
294  return m_AreaPosition;
295  }
296 
297  void SetAreaOrientation( vector orientation )
298  {
299  m_AreaOrientation = orientation;
300 
301  if ( m_AreaDamageTrigger )
302  {
303  m_AreaDamageTrigger.SetOrientation(m_AreaOrientation);
304  }
305  }
307  {
308  return m_AreaOrientation;
309  }
310 
311  void SetDamageableTypes(array<typename> damageableTypes)
312  {
313  m_DamageComponent.m_DamageableTypes = damageableTypes;
314  }
316  {
317  return m_DamageComponent.m_DamageableTypes;
318  }
319 
320  void AddDamageableType(typename damageableType)
321  {
322  if (m_DamageComponent.m_DamageableTypes.Find(damageableType) != -1)
323  m_DamageComponent.m_DamageableTypes.Insert(damageableType);
324  }
325 
326  void RemoveAddDamageableType(typename damageableType)
327  {
328  m_DamageComponent.m_DamageableTypes.RemoveItem(damageableType);
329  }
330 
331  void SetLoopInterval( float time )
332  {
333  Error("SetLoopInterval not implemented - usable in Regular(looped) area damage objects only");
334  }
335 
336  void SetDeferDuration( float time )
337  {
338  Error("SetDeferDuration not implemented - usable in Deferred area damage objects only");
339  }
340 
341  void SetHitZones( array<string> hitzones )
342  {
344  if ( CastTo( adc, m_DamageComponent ) )
345  adc.SetHitZones( hitzones );
346  else
347  Error("SetHitZones not implemented - override for non raycasted versions of area damage objects only");
348  }
349 
350  void SetRaycastSources( array<string> raycast_sources )
351  {
353  if ( CastTo( adc, m_DamageComponent ) )
354  adc.SetRaycastSources( raycast_sources );
355  else
356  Error("SetRaycastSources not implemented - override for raycasted versions of area damage objects only");
357  }
358 
359  void SetRaycastSourcesVector( array<vector> raycast_sources )
360  {
362  if ( CastTo( adc, m_DamageComponent ) )
363  adc.SetRaycastSourcesVector( raycast_sources );
364  else
365  Error("SetRaycastSources not implemented - override for raycasted versions of area damage objects only");
366  }
367 
369  {
370  return m_AreaDamageTrigger;
371  }
373 
374 
377  protected bool CreateDamageTriggerEx()
378  {
379  int flags;
380 
381  if ( GetGame().IsMultiplayer() && GetGame().IsServer() )
382  flags = ECE_CREATEPHYSICS;
383  else
384  flags = ECE_LOCAL;
385 
386  if (Class.CastTo(m_AreaDamageTrigger, GetGame().CreateObjectEx( m_TriggerBaseClass, m_AreaPosition, flags )))
387  {
388  m_AreaDamageTrigger.SetOrientation( m_AreaOrientation );
390  m_AreaDamageTrigger.SetAreaDamageManager(this);
391  return true;
392  }
393 
394  return false;
395  }
396 
397  protected void CreateDamageTrigger()
398  {
400  }
402 
403 
406  protected bool DestroyDamageTriggerEx()
407  {
408  if ( GetGame() && m_AreaDamageTrigger ) // It's necesarry to check if the game exists. Otherwise a crash occurs while quitting.
409  {
410  GetGame().ObjectDelete( m_AreaDamageTrigger );
411  m_AreaDamageTrigger = null;
412  return true;
413  }
414 
415  return false;
416  }
417 
418  protected void DestroyDamageTrigger()
419  {
421  }
423 }
PostDamageActions
override void PostDamageActions()
Usually called from AreaDamageComponent.
Definition: areadamagemanager.c:206
GetAmmoName
string GetAmmoName()
Definition: areadamagemanager.c:260
GetGame
proto native CGame GetGame()
OnStayClientEvent
override void OnStayClientEvent(TriggerInsider insider, float deltaTime)
Definition: areadamagemanager.c:147
OnEnterClientEvent
override void OnEnterClientEvent(TriggerInsider insider)
Definition: areadamagemanager.c:111
AreaDamageComponentRandomHitzone
Newer implementation equivalent of "AreaDamageRegular", hitzone selection only.
Definition: areadamagecomponentrandomhitzone.c:2
SetLoopInterval
void SetLoopInterval(float time)
Definition: areadamagemanager.c:331
CreateDamageTriggerEx
protected bool CreateDamageTriggerEx()
Definition: areadamagemanager.c:377
GetExtents
void GetExtents(out vector mins, out vector maxs)
Definition: areadamagemanager.c:243
m_ExtentMin
protected vector m_ExtentMin
Definition: areadamagemanager.c:15
Error
void Error(string err)
Messagebox with error message.
Definition: endebug.c:90
OnTriggerDestroyed
override void OnTriggerDestroyed()
Called when a trigger is destroyed.
Definition: areadamagemanager.c:97
OnEnterServerEvent
override void OnEnterServerEvent(TriggerInsider insider)
Definition: areadamagemanager.c:107
GetTrigger
AreaDamageTriggerBase GetTrigger()
Definition: areadamagemanager.c:368
AreaDamageComponentRaycasted
Newer implementation equivalent of "AreaDamageRegularRaycasted", hitzone selection only.
Definition: areadamagecomponentraycasted.c:2
TriggerInsider
The object which is in a trigger and its metadata.
Definition: trigger.c:2
RemoveAddDamageableType
void RemoveAddDamageableType(typename damageableType)
Definition: areadamagemanager.c:326
OnLeaveBeginEvent
override void OnLeaveBeginEvent(TriggerInsider insider)
Called when an object leaves the trigger.
Definition: areadamagemanager.c:175
SetExtents
void SetExtents(vector mins, vector maxs)
Definition: areadamagemanager.c:233
SetDamageComponentType
void SetDamageComponentType(int type)
Definition: areadamagemanager.c:41
SetAmmoName
void SetAmmoName(string ammo_name)
Definition: areadamagemanager.c:256
AreaDamageTriggerBase
Definition: areadamagetriggerdirect.c:1
OnStayStartEndEvent
override void OnStayStartEndEvent(int nrOfInsiders)
Definition: areadamagemanager.c:133
OnEnterBeginEvent
override void OnEnterBeginEvent(TriggerInsider insider)
Called when an object enters the trigger.
Definition: areadamagemanager.c:103
OnEvaluateDamageEx
bool OnEvaluateDamageEx(TriggerInsider insider, float deltaTime)
Definition: areadamagemanager.c:218
OnLeaveEndEvent
override void OnLeaveEndEvent(TriggerInsider insider)
Definition: areadamagemanager.c:187
SetRaycastSources
void SetRaycastSources(array< string > raycast_sources)
Definition: areadamagemanager.c:350
GetDamageType
int GetDamageType()
Definition: areadamagemanager.c:269
~AreaDamageManager
void ~AreaDamageManager()
Definition: areadamagemanager.c:36
m_AreaPosition
protected vector m_AreaPosition
Definition: areadamagemanager.c:17
DestroyDamageTriggerEx
protected bool DestroyDamageTriggerEx()
Definition: areadamagemanager.c:406
OnStayEndEvent
override void OnStayEndEvent(TriggerInsider insider, float deltaTime)
Definition: areadamagemanager.c:151
OnStayStartServerEvent
override void OnStayStartServerEvent(int nrOfInsiders)
Definition: areadamagemanager.c:125
AreaDamageEvents
Events used across AreaDamage API, calling of these needs to be handled by parent.
Definition: areadamageevents.c:2
OnStayFinishServerEvent
override void OnStayFinishServerEvent()
Definition: areadamagemanager.c:161
SetParentObject
void SetParentObject(EntityAI obj)
Definition: areadamagemanager.c:274
DestroyDamageTrigger
protected void DestroyDamageTrigger()
Definition: areadamagemanager.c:418
GetDamageableTypes
array< typename > GetDamageableTypes()
Definition: areadamagemanager.c:315
Spawn
void Spawn()
spawn damage trigger
Definition: areadamagemanager.c:70
vector
Definition: enconvert.c:105
OnTriggerCreated
override void OnTriggerCreated()
Definition: areadamagemanager.c:91
Destroy
void Destroy()
destroy damage trigger
Definition: areadamagemanager.c:77
OnStayFinishBeginEvent
override void OnStayFinishBeginEvent()
Called at the end of an update loop.
Definition: areadamagemanager.c:157
m_AreaDamageTrigger
protected AreaDamageTriggerBase m_AreaDamageTrigger
Definition: areadamagemanager.c:11
m_ParentObject
class AreaDamageComponentTypes m_ParentObject
PreDamageActions
override void PreDamageActions()
Usually called from AreaDamageComponent.
Definition: areadamagemanager.c:199
GetParentObject
EntityAI GetParentObject()
Definition: areadamagemanager.c:278
SetDamageType
void SetDamageType(int pDamageType)
Definition: areadamagemanager.c:265
SetAreaOrientation
void SetAreaOrientation(vector orientation)
Definition: areadamagemanager.c:297
OnEvaluateDamage
override bool OnEvaluateDamage(TriggerInsider insider, float damageCoef)
Tell the AreaDamageComponent to calculate and apply the damage to the Object.
Definition: areadamagemanager.c:193
AreaDamageComponent
ref array< typename > m_DamageableTypes void AreaDamageComponent(AreaDamageManager parent)
Definition: areadamagecomponent.c:16
m_TriggerBaseClass
protected string m_TriggerBaseClass
Definition: areadamagemanager.c:20
GetPosition
vector GetPosition()
Get the world position of the Effect.
Definition: areadamagemanager.c:292
m_ExtentMax
protected vector m_ExtentMax
Definition: areadamagemanager.c:16
array< typename >
AddDamageableType
void AddDamageableType(typename damageableType)
Definition: areadamagemanager.c:320
OnStayFinishClientEvent
override void OnStayFinishClientEvent()
Definition: areadamagemanager.c:165
m_AreaOrientation
protected vector m_AreaOrientation
Definition: areadamagemanager.c:18
OnStayStartClientEvent
override void OnStayStartClientEvent(int nrOfInsiders)
Definition: areadamagemanager.c:129
OnEnterEndEvent
override void OnEnterEndEvent(TriggerInsider insider)
Definition: areadamagemanager.c:115
OnLeaveClientEvent
override void OnLeaveClientEvent(TriggerInsider insider)
Definition: areadamagemanager.c:183
AreaDamageComponentTypes
Definition: areadamagemanager.c:1
SetHitZones
void SetHitZones(array< string > hitzones)
Definition: areadamagemanager.c:341
AreaDamageManager
void AreaDamageManager(EntityAI parent)
Definition: areadamagemanager.c:22
OnLeaveServerEvent
override void OnLeaveServerEvent(TriggerInsider insider)
Definition: areadamagemanager.c:179
ECE_CREATEPHYSICS
const int ECE_CREATEPHYSICS
Definition: centraleconomy.c:16
ECE_LOCAL
const int ECE_LOCAL
Definition: centraleconomy.c:24
CreateDamageTrigger
protected void CreateDamageTrigger()
Definition: areadamagemanager.c:397
SetDeferDuration
void SetDeferDuration(float time)
Definition: areadamagemanager.c:336
SetDamageableTypes
void SetDamageableTypes(array< typename > damageableTypes)
Definition: areadamagemanager.c:311
OnStayFinishEndEvent
override void OnStayFinishEndEvent()
Definition: areadamagemanager.c:169
SetAreaPosition
void SetAreaPosition(vector position)
Definition: areadamagemanager.c:283
OnStayStartBeginEvent
override void OnStayStartBeginEvent(int nrOfInsiders)
Called at the beginning of an update loop.
Definition: areadamagemanager.c:121
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10
CalculateDamageScale
protected float CalculateDamageScale(TriggerInsider insider, float deltaTime)
Helper for calculating damageCoeff when using OnEvaluateDamageEx.
Definition: areadamagemanager.c:224
OnStayBeginEvent
override void OnStayBeginEvent(TriggerInsider insider, float deltaTime)
Called in the update loop.
Definition: areadamagemanager.c:139
EntityAI
Definition: building.c:5
GetWorldExtents
void GetWorldExtents(out vector mins, out vector maxs)
Definition: areadamagemanager.c:248
OnStayServerEvent
override void OnStayServerEvent(TriggerInsider insider, float deltaTime)
Definition: areadamagemanager.c:143
m_DamageComponent
protected ref AreaDamageComponent m_DamageComponent
Definition: areadamagemanager.c:13
SetRaycastSourcesVector
void SetRaycastSourcesVector(array< vector > raycast_sources)
Definition: areadamagemanager.c:359
GetOrientation
vector GetOrientation()
Definition: areadamagemanager.c:306