DayZ 1.24
Loading...
Searching...
No Matches
AreaDamageManager.c File Reference

Go to the source code of this file.

Classes

class  AreaDamageComponentTypes
 

Functions

void AreaDamageManager (EntityAI parent)
 
void ~AreaDamageManager ()
 
void SetDamageComponentType (int type)
 
void Spawn ()
 spawn damage trigger
 
void Destroy ()
 destroy damage trigger
 
AreaDamageEvents Implementation

Implementation for handling AreaDamageEvents Pass them on to the AreaDamageComponent Calling of the events that are the same in TriggerEvents will come from AreaDamageTriggerBase

override void OnTriggerCreated ()
 
override void OnTriggerDestroyed ()
 Called when a trigger is destroyed.
 
override void OnEnterBeginEvent (TriggerInsider insider)
 Called when an object enters the trigger.
 
override void OnEnterServerEvent (TriggerInsider insider)
 
override void OnEnterClientEvent (TriggerInsider insider)
 
override void OnEnterEndEvent (TriggerInsider insider)
 
override void OnStayStartBeginEvent (int nrOfInsiders)
 Called at the beginning of an update loop.
 
override void OnStayStartServerEvent (int nrOfInsiders)
 
override void OnStayStartClientEvent (int nrOfInsiders)
 
override void OnStayStartEndEvent (int nrOfInsiders)
 
override void OnStayBeginEvent (TriggerInsider insider, float deltaTime)
 Called in the update loop.
 
override void OnStayServerEvent (TriggerInsider insider, float deltaTime)
 
override void OnStayClientEvent (TriggerInsider insider, float deltaTime)
 
override void OnStayEndEvent (TriggerInsider insider, float deltaTime)
 
override void OnStayFinishBeginEvent ()
 Called at the end of an update loop.
 
override void OnStayFinishServerEvent ()
 
override void OnStayFinishClientEvent ()
 
override void OnStayFinishEndEvent ()
 
override void OnLeaveBeginEvent (TriggerInsider insider)
 Called when an object leaves the trigger.
 
override void OnLeaveServerEvent (TriggerInsider insider)
 
override void OnLeaveClientEvent (TriggerInsider insider)
 
override void OnLeaveEndEvent (TriggerInsider insider)
 
override bool OnEvaluateDamage (TriggerInsider insider, float damageCoef)
 Tell the AreaDamageComponent to calculate and apply the damage to the Object.
 
override void PreDamageActions ()
 Usually called from AreaDamageComponent.
 
override void PostDamageActions ()
 Usually called from AreaDamageComponent.
 
bool OnEvaluateDamageEx (TriggerInsider insider, float deltaTime)
 
float CalculateDamageScale (TriggerInsider insider, float deltaTime)
 Helper for calculating damageCoeff when using OnEvaluateDamageEx.
 
void SetExtents (vector mins, vector maxs)
 
void GetExtents (out vector mins, out vector maxs)
 
void GetWorldExtents (out vector mins, out vector maxs)
 
void SetAmmoName (string ammo_name)
 
string GetAmmoName ()
 
void SetDamageType (int pDamageType)
 
int GetDamageType ()
 
void SetParentObject (EntityAI obj)
 
EntityAI GetParentObject ()
 
void SetAreaPosition (vector position)
 
vector GetPosition ()
 Get the world position of the Effect.
 
void SetAreaOrientation (vector orientation)
 
vector GetOrientation ()
 
void SetDamageableTypes (array< typename > damageableTypes)
 
array< typenameGetDamageableTypes ()
 
void AddDamageableType (typename damageableType)
 
void RemoveAddDamageableType (typename damageableType)
 
void SetLoopInterval (float time)
 
void SetDeferDuration (float time)
 
void SetHitZones (array< string > hitzones)
 
void SetRaycastSources (array< string > raycast_sources)
 
void SetRaycastSourcesVector (array< vector > raycast_sources)
 
AreaDamageTriggerBase GetTrigger ()
 
bool CreateDamageTriggerEx ()
 
void CreateDamageTrigger ()
 
bool DestroyDamageTriggerEx ()
 
void DestroyDamageTrigger ()
 

Variables

class AreaDamageComponentTypes m_ParentObject
 
AreaDamageTriggerBase m_AreaDamageTrigger
 
ref AreaDamageComponent m_DamageComponent
 
vector m_ExtentMin
 
vector m_ExtentMax
 
vector m_AreaPosition
 
vector m_AreaOrientation
 
string m_TriggerBaseClass
 

Function Documentation

◆ AddDamageableType()

void AddDamageableType ( typename damageableType )
protected

Definition at line 314 of file AreaDamageManager.c.

315 {
316 if (m_DamageComponent.m_DamageableTypes.Find(damageableType) != -1)
317 m_DamageComponent.m_DamageableTypes.Insert(damageableType);
318 }
ref AreaDamageComponent m_DamageComponent

References m_DamageComponent.

◆ AreaDamageManager()

void AreaDamageManager ( EntityAI parent)
protected

Definition at line 22 of file AreaDamageManager.c.

23 {
24 m_ParentObject = parent;
25
27
30 m_AreaPosition = parent.GetPosition();
31 m_AreaOrientation = parent.GetOrientation();
32
33 m_TriggerBaseClass = "AreaDamageTriggerBase";
34 }
ref array< typename > m_DamageableTypes void AreaDamageComponent(AreaDamageManager parent)
vector m_AreaPosition
vector m_ExtentMin
vector m_ExtentMax
string m_TriggerBaseClass
vector m_AreaOrientation
class AreaDamageComponentTypes m_ParentObject
static const vector Zero
Definition EnConvert.c:110

References AreaDamageComponent(), m_AreaOrientation, m_AreaPosition, m_DamageComponent, m_ExtentMax, m_ExtentMin, m_ParentObject, m_TriggerBaseClass, and vector::Zero.

◆ CalculateDamageScale()

float CalculateDamageScale ( TriggerInsider insider,
float deltaTime )
protected

Helper for calculating damageCoeff when using OnEvaluateDamageEx.

Definition at line 224 of file AreaDamageManager.c.

225 {
226 return deltaTime;
227 }

Referenced by OnEvaluateDamageEx().

◆ CreateDamageTrigger()

void CreateDamageTrigger ( )
protected

Definition at line 391 of file AreaDamageManager.c.

392 {
394 }
bool CreateDamageTriggerEx()

References CreateDamageTriggerEx().

◆ CreateDamageTriggerEx()

bool CreateDamageTriggerEx ( )
protected

create damage trigger with basic set of params

Definition at line 371 of file AreaDamageManager.c.

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 }
AreaDamageTriggerBase m_AreaDamageTrigger
const int ECE_LOCAL
const int ECE_CREATEPHYSICS
override void SetAreaDamageManager(AreaDamageManager adType)
override void SetExtents(vector mins, vector maxs)
Super root of all classes in Enforce script.
Definition EnScript.c:11
proto native CGame GetGame()
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.

References Class::CastTo(), ECE_CREATEPHYSICS, ECE_LOCAL, GetGame(), m_AreaDamageTrigger, m_AreaOrientation, m_AreaPosition, m_ExtentMax, m_ExtentMin, m_TriggerBaseClass, AreaDamageTriggerBase::SetAreaDamageManager(), and AreaDamageTriggerBase::SetExtents().

Referenced by CreateDamageTrigger(), and Spawn().

◆ DestroyDamageTrigger()

void DestroyDamageTrigger ( )
protected

Definition at line 412 of file AreaDamageManager.c.

413 {
415 }
bool DestroyDamageTriggerEx()

References DestroyDamageTriggerEx().

◆ DestroyDamageTriggerEx()

bool DestroyDamageTriggerEx ( )
protected

destroys damage trigger

Definition at line 400 of file AreaDamageManager.c.

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 }

References GetGame(), and m_AreaDamageTrigger.

Referenced by Destroy(), and DestroyDamageTrigger().

◆ GetAmmoName()

string GetAmmoName ( )
protected

Definition at line 258 of file AreaDamageManager.c.

259 {
260 return m_DamageComponent.m_AmmoName;
261 }

References m_DamageComponent.

◆ GetDamageableTypes()

array< typename > GetDamageableTypes ( )
protected

Definition at line 309 of file AreaDamageManager.c.

310 {
311 return m_DamageComponent.m_DamageableTypes;
312 }

References m_DamageComponent.

◆ GetDamageType()

int GetDamageType ( )
protected

Definition at line 267 of file AreaDamageManager.c.

268 {
269 return m_DamageComponent.m_DamageType;
270 }

References m_DamageComponent.

◆ GetExtents()

void GetExtents ( out vector mins,
out vector maxs )
protected

Definition at line 241 of file AreaDamageManager.c.

242 {
245 }

References m_ExtentMax, and m_ExtentMin.

Referenced by GetWorldExtents().

◆ GetOrientation()

◆ GetParentObject()

EntityAI GetParentObject ( )
protected

Definition at line 276 of file AreaDamageManager.c.

277 {
278 return m_ParentObject;
279 }

References m_ParentObject.

◆ GetPosition()

vector GetPosition ( )
protected

Get the world position of the Effect.

Warning
Only gets the cached variable, for immediate effect use GetCurrent variant
Returns
vector The world position of the Effect

Definition at line 288 of file AreaDamageManager.c.

289 {
290 return m_AreaPosition;
291 }

References m_AreaPosition.

◆ GetTrigger()

AreaDamageTriggerBase GetTrigger ( )
protected

Definition at line 362 of file AreaDamageManager.c.

363 {
364 return m_AreaDamageTrigger;
365 }

References m_AreaDamageTrigger.

◆ GetWorldExtents()

void GetWorldExtents ( out vector mins,
out vector maxs )
protected

Definition at line 246 of file AreaDamageManager.c.

247 {
249
252 }
void GetExtents(out vector mins, out vector maxs)

References GetExtents(), and m_AreaPosition.

◆ OnEnterBeginEvent()

override void OnEnterBeginEvent ( TriggerInsider insider)
protected

Called when an object enters the trigger.

Definition at line 103 of file AreaDamageManager.c.

104 {
105 m_DamageComponent.OnEnterBeginEvent(insider);
106 }

References m_DamageComponent.

◆ OnEnterClientEvent()

override void OnEnterClientEvent ( TriggerInsider insider)
protected

Definition at line 111 of file AreaDamageManager.c.

112 {
113 m_DamageComponent.OnEnterClientEvent(insider);
114 }

References m_DamageComponent.

◆ OnEnterEndEvent()

override void OnEnterEndEvent ( TriggerInsider insider)
protected

Definition at line 115 of file AreaDamageManager.c.

116 {
117 m_DamageComponent.OnEnterEndEvent(insider);
118 }

References m_DamageComponent.

◆ OnEnterServerEvent()

void OnEnterServerEvent ( TriggerInsider insider)
protected

Definition at line 107 of file AreaDamageManager.c.

108 {
109 m_DamageComponent.OnEnterServerEvent(insider);
110 }

References m_DamageComponent.

◆ OnEvaluateDamage()

override bool OnEvaluateDamage ( TriggerInsider insider,
float damageCoef )
protected

Tell the AreaDamageComponent to calculate and apply the damage to the Object.

Definition at line 193 of file AreaDamageManager.c.

194 {
195 return m_DamageComponent.OnEvaluateDamage(insider, damageCoef);
196 }

References m_DamageComponent.

Referenced by OnEvaluateDamageEx().

◆ OnEvaluateDamageEx()

bool OnEvaluateDamageEx ( TriggerInsider insider,
float deltaTime )
protected

Some event extensions

Alternative OnEvaluateDamage, using CalculateDamageScale

Definition at line 218 of file AreaDamageManager.c.

219 {
220 return OnEvaluateDamage(insider, CalculateDamageScale(insider, deltaTime));
221 }
override bool OnEvaluateDamage(TriggerInsider insider, float damageCoef)
Tell the AreaDamageComponent to calculate and apply the damage to the Object.
float CalculateDamageScale(TriggerInsider insider, float deltaTime)
Helper for calculating damageCoeff when using OnEvaluateDamageEx.

References CalculateDamageScale(), and OnEvaluateDamage().

Referenced by AreaDamageLooped::OnEnterServerEvent(), AreaDamageOnce::OnEnterServerEvent(), AreaDamageLooped::OnStayServerEvent(), and OnStayServerEvent().

◆ OnLeaveBeginEvent()

override void OnLeaveBeginEvent ( TriggerInsider insider)
protected

Called when an object leaves the trigger.

Definition at line 175 of file AreaDamageManager.c.

176 {
177 m_DamageComponent.OnLeaveBeginEvent(insider);
178 }

References m_DamageComponent.

◆ OnLeaveClientEvent()

override void OnLeaveClientEvent ( TriggerInsider insider)
protected

Definition at line 183 of file AreaDamageManager.c.

184 {
185 m_DamageComponent.OnLeaveClientEvent(insider);
186 }

References m_DamageComponent.

◆ OnLeaveEndEvent()

override void OnLeaveEndEvent ( TriggerInsider insider)
protected

Definition at line 187 of file AreaDamageManager.c.

188 {
189 m_DamageComponent.OnLeaveEndEvent(insider);
190 }

References m_DamageComponent.

◆ OnLeaveServerEvent()

override void OnLeaveServerEvent ( TriggerInsider insider)
protected

Definition at line 179 of file AreaDamageManager.c.

180 {
181 m_DamageComponent.OnLeaveServerEvent(insider);
182 }

References m_DamageComponent.

◆ OnStayBeginEvent()

override void OnStayBeginEvent ( TriggerInsider insider,
float deltaTime )
protected

Called in the update loop.

Definition at line 139 of file AreaDamageManager.c.

140 {
141 m_DamageComponent.OnStayBeginEvent(insider, deltaTime);
142 }

References m_DamageComponent.

◆ OnStayClientEvent()

override void OnStayClientEvent ( TriggerInsider insider,
float deltaTime )
protected

Definition at line 147 of file AreaDamageManager.c.

148 {
149 m_DamageComponent.OnStayClientEvent(insider, deltaTime);
150 }

References m_DamageComponent.

◆ OnStayEndEvent()

override void OnStayEndEvent ( TriggerInsider insider,
float deltaTime )
protected

Definition at line 151 of file AreaDamageManager.c.

152 {
153 m_DamageComponent.OnStayEndEvent(insider, deltaTime);
154 }

References m_DamageComponent.

◆ OnStayFinishBeginEvent()

override void OnStayFinishBeginEvent ( )
protected

Called at the end of an update loop.

Definition at line 157 of file AreaDamageManager.c.

158 {
159 m_DamageComponent.OnStayFinishBeginEvent();
160 }

References m_DamageComponent.

◆ OnStayFinishClientEvent()

override void OnStayFinishClientEvent ( )
protected

Definition at line 165 of file AreaDamageManager.c.

166 {
167 m_DamageComponent.OnStayFinishClientEvent();
168 }

References m_DamageComponent.

◆ OnStayFinishEndEvent()

override void OnStayFinishEndEvent ( )
protected

Definition at line 169 of file AreaDamageManager.c.

170 {
171 m_DamageComponent.OnStayFinishEndEvent();
172 }

References m_DamageComponent.

◆ OnStayFinishServerEvent()

override void OnStayFinishServerEvent ( )
protected

Definition at line 161 of file AreaDamageManager.c.

162 {
163 m_DamageComponent.OnStayFinishServerEvent();
164 }

References m_DamageComponent.

◆ OnStayServerEvent()

override void OnStayServerEvent ( TriggerInsider insider,
float deltaTime )
protected

Definition at line 143 of file AreaDamageManager.c.

144 {
145 m_DamageComponent.OnStayServerEvent(insider, deltaTime);
146 }

References m_DamageComponent.

◆ OnStayStartBeginEvent()

override void OnStayStartBeginEvent ( int nrOfInsiders)
protected

Called at the beginning of an update loop.

Definition at line 121 of file AreaDamageManager.c.

122 {
123 m_DamageComponent.OnStayStartBeginEvent(nrOfInsiders);
124 }

References m_DamageComponent.

◆ OnStayStartClientEvent()

override void OnStayStartClientEvent ( int nrOfInsiders)
protected

Definition at line 129 of file AreaDamageManager.c.

130 {
131 m_DamageComponent.OnStayStartClientEvent(nrOfInsiders);
132 }

References m_DamageComponent.

◆ OnStayStartEndEvent()

override void OnStayStartEndEvent ( int nrOfInsiders)
protected

Definition at line 133 of file AreaDamageManager.c.

134 {
135 m_DamageComponent.OnStayStartEndEvent(nrOfInsiders);
136 }

References m_DamageComponent.

◆ OnStayStartServerEvent()

override void OnStayStartServerEvent ( int nrOfInsiders)
protected

Definition at line 125 of file AreaDamageManager.c.

126 {
127 m_DamageComponent.OnStayStartServerEvent(nrOfInsiders);
128 }

References m_DamageComponent.

◆ OnTriggerCreated()

override void OnTriggerCreated ( )
protected

Called when a trigger is created

Definition at line 91 of file AreaDamageManager.c.

92 {
93 m_DamageComponent.OnTriggerCreated();
94 }

References m_DamageComponent.

Referenced by Spawn().

◆ OnTriggerDestroyed()

override void OnTriggerDestroyed ( )
protected

Called when a trigger is destroyed.

Definition at line 97 of file AreaDamageManager.c.

98 {
99 m_DamageComponent.OnTriggerDestroyed();
100 }

References m_DamageComponent.

Referenced by Destroy().

◆ PostDamageActions()

override void PostDamageActions ( )
protected

Usually called from AreaDamageComponent.

Definition at line 206 of file AreaDamageManager.c.

207 {
208 if (m_ParentObject)
209 m_ParentObject.PostAreaDamageActions();
210 }

References m_ParentObject.

Referenced by AreaDamageBase::EvaluateDamage_Common(), and EvaluateDamageInternal().

◆ PreDamageActions()

override void PreDamageActions ( )
protected

Usually called from AreaDamageComponent.

Definition at line 199 of file AreaDamageManager.c.

200 {
201 if (m_ParentObject)
202 m_ParentObject.PreAreaDamageActions();
203 }

References m_ParentObject.

Referenced by EvaluateDamageInternal().

◆ RemoveAddDamageableType()

void RemoveAddDamageableType ( typename damageableType )
protected

Definition at line 320 of file AreaDamageManager.c.

321 {
322 m_DamageComponent.m_DamageableTypes.RemoveItem(damageableType);
323 }

References m_DamageComponent.

◆ SetAmmoName()

void SetAmmoName ( string ammo_name)
protected

Definition at line 254 of file AreaDamageManager.c.

255 {
256 m_DamageComponent.m_AmmoName = ammo_name;
257 }

References m_DamageComponent.

◆ SetAreaOrientation()

void SetAreaOrientation ( vector orientation)
protected

Definition at line 293 of file AreaDamageManager.c.

294 {
296
299 }

References m_AreaDamageTrigger, and m_AreaOrientation.

◆ SetAreaPosition()

void SetAreaPosition ( vector position)
protected

Definition at line 281 of file AreaDamageManager.c.

282 {
284
287 }

References m_AreaDamageTrigger, and m_AreaPosition.

◆ SetDamageableTypes()

void SetDamageableTypes ( array< typename > damageableTypes)
protected

Definition at line 305 of file AreaDamageManager.c.

306 {
307 m_DamageComponent.m_DamageableTypes = damageableTypes;
308 }

References m_DamageComponent.

◆ SetDamageComponentType()

void SetDamageComponentType ( int type)
protected

Definition at line 41 of file AreaDamageManager.c.

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 }
Newer implementation equivalent of "AreaDamageRegular", hitzone selection only.
Newer implementation equivalent of "AreaDamageRegularRaycasted", hitzone selection only.
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90

References AreaDamageComponent(), AreaDamageComponentTypes::BASE, Error(), AreaDamageComponentTypes::HITZONE, m_DamageComponent, and AreaDamageComponentTypes::RAYCASTED.

◆ SetDamageType()

void SetDamageType ( int pDamageType)
protected

Definition at line 263 of file AreaDamageManager.c.

264 {
265 m_DamageComponent.m_DamageType = pDamageType;
266 }

References m_DamageComponent.

◆ SetDeferDuration()

void SetDeferDuration ( float time)
protected

Definition at line 330 of file AreaDamageManager.c.

331 {
332 Error("SetDeferDuration not implemented - usable in Deferred area damage objects only");
333 }

References Error().

◆ SetExtents()

void SetExtents ( vector mins,
vector maxs )
protected

script configuration

Definition at line 233 of file AreaDamageManager.c.

References m_AreaDamageTrigger, m_ExtentMax, m_ExtentMin, and AreaDamageTriggerBase::SetExtents().

Referenced by Init().

◆ SetHitZones()

void SetHitZones ( array< string > hitzones)
protected

Definition at line 335 of file AreaDamageManager.c.

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 }

References Error(), and m_DamageComponent.

◆ SetLoopInterval()

void SetLoopInterval ( float time)
protected

Definition at line 325 of file AreaDamageManager.c.

326 {
327 Error("SetLoopInterval not implemented - usable in Regular(looped) area damage objects only");
328 }

References Error().

◆ SetParentObject()

void SetParentObject ( EntityAI obj)
protected

Definition at line 272 of file AreaDamageManager.c.

273 {
274 m_ParentObject = obj;
275 }

References m_ParentObject.

◆ SetRaycastSources()

void SetRaycastSources ( array< string > raycast_sources)
protected

Definition at line 344 of file AreaDamageManager.c.

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 }

References Error(), and m_DamageComponent.

◆ SetRaycastSourcesVector()

void SetRaycastSourcesVector ( array< vector > raycast_sources)
protected

Definition at line 353 of file AreaDamageManager.c.

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 }

References Error(), and m_DamageComponent.

◆ Spawn()

void Spawn ( )
protected

spawn damage trigger

Definition at line 70 of file AreaDamageManager.c.

71 {
74 }
override void OnTriggerCreated()

References CreateDamageTriggerEx(), and OnTriggerCreated().

Referenced by ActionConstructor::ConstructActions(), EmoteConstructor::ConstructEmotes(), and ImpactMaterials::EvaluateImpactEffect().

◆ ~AreaDamageManager()

void ~AreaDamageManager ( )
protected

Definition at line 36 of file AreaDamageManager.c.

37 {
38 Destroy();
39 }
void Destroy()
destroy damage trigger

References Destroy().

Variable Documentation

◆ m_AreaDamageTrigger

◆ m_AreaOrientation

vector m_AreaOrientation
protected

◆ m_AreaPosition

vector m_AreaPosition
protected

◆ m_DamageComponent

◆ m_ExtentMax

◆ m_ExtentMin

◆ m_ParentObject

◆ m_TriggerBaseClass

string m_TriggerBaseClass
protected