DayZ 1.24
Loading...
Searching...
No Matches
AreaDamageBase Class Reference
Inheritance diagram for AreaDamageBase:
[legend]
Collaboration diagram for AreaDamageBase:
[legend]

Protected Member Functions

void AreaDamageBase (EntityAI parent)
 
void OnEnter (Object object)
 events
 
void OnEnterClient (Object object)
 
void OnEnterServer (Object object)
 
void OnLeave (Object object)
 
void OnLeaveClient (Object object)
 
void OnLeaveServer (Object object)
 
void EvaluateDamage_Loop (Object object)
 
void EvaluateDamage_Defer (Object object)
 
void EvaluateDamage_DeferLoop (Object object)
 
void EvaluateDamage (Object object)
 
void EvaluateDamage_Common (Object object, string hitzone)
 
string GetRandomHitZone (array< string > hitzones)
 
string GetRaycastedHitZone (Object victim, array< string > raycast_sources_str)
 

Protected Attributes

AreaDamageBase m_AreaDamage
 
float m_PlayerDamage
 
float m_OthersDamage
 
string m_AmmoName
 
int m_DamageType
 
float m_LoopInterval
 
float m_DeferDuration
 
ref array< stringm_HitZones
 
ref array< stringm_RaycastSources
 
ref Timer m_LoopTimer
 
ref Timer m_DeferTimer
 

Private Member Functions

void AreaDamageOneTime (EntityAI parent)
 
void ~AreaDamageOneTime ()
 
override void SetHitZones (array< string > hitzones)
 
override void OnEnterServer (Object object)
 
void AreaDamageOneTimeDeferred (EntityAI parent)
 
void ~AreaDamageOneTimeDeferred ()
 
override void SetDeferDuration (float time)
 
override void SetHitZones (array< string > hitzones)
 
override void OnEnterServer (Object object)
 
void AreaDamageOneTimeRaycasted (EntityAI parent)
 
void ~AreaDamageOneTimeRaycasted ()
 
override void SetRaycastSources (array< string > raycast_sources)
 
override void OnEnterServer (Object object)
 
void AreaDamageOneTimeRaycastedDeferred (EntityAI parent)
 
void ~AreaDamageOneTimeRaycastedDeferred ()
 
override void SetDeferDuration (float time)
 
override void SetRaycastSources (array< string > raycast_sources)
 
override void OnEnterServer (Object object)
 
void AreaDamageRegular (EntityAI parent)
 
void ~AreaDamageRegular ()
 
override void SetLoopInterval (float time)
 
override void SetHitZones (array< string > hitzones)
 
override void OnEnterServer (Object object)
 
void AreaDamageRegularRaycasted (EntityAI parent)
 
void ~AreaDamageRegularRaycasted ()
 
override void SetLoopInterval (float time)
 
override void SetRaycastSources (array< string > raycast_sources)
 
override void OnEnterServer (Object object)
 
void AreaDamageRegularRaycastedDeferred (EntityAI parent)
 
void ~AreaDamageRegularRaycastedDeferred ()
 
override void SetLoopInterval (float time)
 
override void SetDeferDuration (float time)
 
override void SetRaycastSources (array< string > raycast_sources)
 
override void OnEnterServer (Object object)
 

Detailed Description

Definition at line 3 of file AreaDamage.c.

Constructor & Destructor Documentation

◆ AreaDamageBase()

void AreaDamageBase::AreaDamageBase ( EntityAI parent)
inlineprotected

Definition at line 23 of file AreaDamage.c.

24 {
25 m_AreaDamage = this;
26
27 m_PlayerDamage = 0.0;
28 m_OthersDamage = 0.0;
29
30 m_AmmoName = "MeleeDamage";
32
33 m_LoopInterval = 1.0;
34 m_DeferDuration = 1.0;
35
40
43
44 m_TriggerBaseClass = "AreaDamageTrigger";
45 }
string m_TriggerBaseClass
AreaDamageBase m_AreaDamage
Definition AreaDamage.c:5
ref Timer m_DeferTimer
Definition AreaDamage.c:21
float m_PlayerDamage
Definition AreaDamage.c:7
float m_OthersDamage
Definition AreaDamage.c:8
string m_AmmoName
Definition AreaDamage.c:10
float m_LoopInterval
Definition AreaDamage.c:13
ref Timer m_LoopTimer
Definition AreaDamage.c:20
float m_DeferDuration
Definition AreaDamage.c:14
ref array< string > m_RaycastSources
Definition AreaDamage.c:17
ref array< string > m_HitZones
Definition AreaDamage.c:16
const int CALL_CATEGORY_SYSTEM
Definition tools.c:8

References CALL_CATEGORY_SYSTEM, m_AmmoName, m_AreaDamage, m_DamageType, m_DeferDuration, m_DeferTimer, m_HitZones, m_LoopInterval, m_LoopTimer, m_OthersDamage, m_PlayerDamage, m_RaycastSources, and m_TriggerBaseClass.

◆ ~AreaDamageOneTime()

void AreaDamageBase::~AreaDamageOneTime ( )
inlineprivate

Definition at line 9 of file AreaDamageOneTime.c.

9{}

◆ ~AreaDamageOneTimeDeferred()

void AreaDamageBase::~AreaDamageOneTimeDeferred ( )
inlineprivate

Definition at line 9 of file AreaDamageOneTimeDeferred.c.

9{}

◆ ~AreaDamageOneTimeRaycasted()

void AreaDamageBase::~AreaDamageOneTimeRaycasted ( )
inlineprivate

Definition at line 9 of file AreaDamageOneTimeRaycasted.c.

9{}

◆ ~AreaDamageOneTimeRaycastedDeferred()

void AreaDamageBase::~AreaDamageOneTimeRaycastedDeferred ( )
inlineprivate

Definition at line 9 of file AreaDamageOneTimeRaycastedDeferred.c.

9{}

◆ ~AreaDamageRegular()

void AreaDamageBase::~AreaDamageRegular ( )
inlineprivate

Definition at line 9 of file AreaDamageRegular.c.

9{}

◆ ~AreaDamageRegularRaycasted()

void AreaDamageBase::~AreaDamageRegularRaycasted ( )
inlineprivate

Definition at line 9 of file AreaDamageRegularRaycasted.c.

9{}

◆ ~AreaDamageRegularRaycastedDeferred()

void AreaDamageBase::~AreaDamageRegularRaycastedDeferred ( )
inlineprivate

Definition at line 9 of file AreaDamageRegularRaycastedDeferred.c.

9{}

Member Function Documentation

◆ AreaDamageOneTime()

void AreaDamageBase::AreaDamageOneTime ( EntityAI parent)
inlineprivate

Definition at line 4 of file AreaDamageOneTime.c.

5 {
6
7 }

◆ AreaDamageOneTimeDeferred()

void AreaDamageBase::AreaDamageOneTimeDeferred ( EntityAI parent)
inlineprivate

Definition at line 4 of file AreaDamageOneTimeDeferred.c.

5 {
6
7 }

◆ AreaDamageOneTimeRaycasted()

void AreaDamageBase::AreaDamageOneTimeRaycasted ( EntityAI parent)
inlineprivate

Definition at line 4 of file AreaDamageOneTimeRaycasted.c.

5 {
6
7 }

◆ AreaDamageOneTimeRaycastedDeferred()

void AreaDamageBase::AreaDamageOneTimeRaycastedDeferred ( EntityAI parent)
inlineprivate

Definition at line 4 of file AreaDamageOneTimeRaycastedDeferred.c.

5 {
6
7 }

◆ AreaDamageRegular()

void AreaDamageBase::AreaDamageRegular ( EntityAI parent)
inlineprivate

Definition at line 4 of file AreaDamageRegular.c.

5 {
6
7 }

◆ AreaDamageRegularRaycasted()

void AreaDamageBase::AreaDamageRegularRaycasted ( EntityAI parent)
inlineprivate

Definition at line 4 of file AreaDamageRegularRaycasted.c.

5 {
6
7 }

◆ AreaDamageRegularRaycastedDeferred()

void AreaDamageBase::AreaDamageRegularRaycastedDeferred ( EntityAI parent)
inlineprivate

Definition at line 4 of file AreaDamageRegularRaycastedDeferred.c.

5 {
6
7 }

◆ EvaluateDamage()

void AreaDamageBase::EvaluateDamage ( Object object)
inlineprotected

Definition at line 91 of file AreaDamage.c.

92 {
93 string hitzone;
94
95 if (m_RaycastSources.Count())
96 {
99 }
100 else
101 {
104 }
105 }
string GetRaycastedHitZone(Object victim, array< string > raycast_sources_str)
Definition AreaDamage.c:150
void EvaluateDamage_Common(Object object, string hitzone)
Definition AreaDamage.c:107
string GetRandomHitZone(array< string > hitzones)
Definition AreaDamage.c:142

References EvaluateDamage_Common(), GetRandomHitZone(), GetRaycastedHitZone(), m_HitZones, and m_RaycastSources.

Referenced by OnEnterServer().

◆ EvaluateDamage_Common()

void AreaDamageBase::EvaluateDamage_Common ( Object object,
string hitzone )
inlineprotected

Definition at line 107 of file AreaDamage.c.

108 {
109 if (object && object.IsAlive())
110 {
111 if (object.IsAnyInherited(m_DamageableTypes))
112 {
113 //If we are hitting an infected or animal, we increase the damage dealt as they do not bleed
114 //Change is multiplier
115 /*DayZInfected dayzInfected = DayZInfected.Cast(object);
116 DayZAnimal dayzAnimal = DayZAnimal.Cast(object);
117 EntityAI eai = EntityAI.Cast(object);
118 if ( dayzInfected || dayzAnimal )
119 {
120 //Agents should not take damage from fireplace, but just in case, keep multiplier relatively low
121 if ( hitzone )
122 {
123 eai.ProcessDirectDamage(m_DamageType, EntityAI.Cast(m_ParentObject), hitzone, m_AmmoName, "0.5 0.5 0.5", 8);
124 }
125 else
126 eai.ProcessDirectDamage(m_DamageType, EntityAI.Cast(m_ParentObject), "", m_AmmoName, "0.5 0.5 0.5", 8);
127 }
128 else*/
129 {
130 object.ProcessDirectDamage(m_DamageType, m_ParentObject, hitzone, m_AmmoName, "0.5 0.5 0.5", 1);
131 }
133 }
134 }
135 }
override void PostDamageActions()
Usually called from AreaDamageComponent.
Object m_ParentObject
Cached parent.
Definition Effect.c:39

References m_AmmoName, m_DamageType, m_ParentObject, and PostDamageActions().

Referenced by EvaluateDamage().

◆ EvaluateDamage_Defer()

void AreaDamageBase::EvaluateDamage_Defer ( Object object)
inlineprotected

Definition at line 81 of file AreaDamage.c.

82 {
83 m_DeferTimer.Run(m_DeferDuration, this, "EvaluateDamage", new Param1<Object>(object), false);
84 }

References m_DeferDuration, and m_DeferTimer.

Referenced by OnEnterServer().

◆ EvaluateDamage_DeferLoop()

void AreaDamageBase::EvaluateDamage_DeferLoop ( Object object)
inlineprotected

Definition at line 86 of file AreaDamage.c.

87 {
88 m_DeferTimer.Run(m_DeferDuration, this, "EvaluateDamage_Loop", new Param1<Object>(object), false);
89 }

References m_DeferDuration, and m_DeferTimer.

Referenced by OnEnterServer().

◆ EvaluateDamage_Loop()

void AreaDamageBase::EvaluateDamage_Loop ( Object object)
inlineprotected

Definition at line 76 of file AreaDamage.c.

77 {
78 m_LoopTimer.Run(m_LoopInterval, this, "EvaluateDamage", new Param1<Object>(object), true);
79 }

References m_LoopInterval, and m_LoopTimer.

Referenced by OnEnterServer().

◆ GetRandomHitZone()

string AreaDamageBase::GetRandomHitZone ( array< string > hitzones)
inlineprotected

common

Definition at line 142 of file AreaDamage.c.

143 {
144 Math.Randomize(-1);
145 int idx = Math.RandomInt(0, 100) % hitzones.Count();
146
147 return hitzones[idx];
148 }
Definition EnMath.c:7
static proto int Randomize(int seed)
Sets the seed for the random number generator.
static proto int RandomInt(int min, int max)
Returns a random int number between and min [inclusive] and max [exclusive].

References Math::RandomInt(), and Math::Randomize().

Referenced by EvaluateDamage().

◆ GetRaycastedHitZone()

string AreaDamageBase::GetRaycastedHitZone ( Object victim,
array< string > raycast_sources_str )
inlineprotected

Definition at line 150 of file AreaDamage.c.

151 {
152
153 // Vertical raycast start positions: Center, North East, North West, South East, South West
154 //vector raycast_sources[5] = {"0.0 0.1 0.0", "0.2 0.1 0.2", "-.2 0.1 0.2", "0.2 0.1 -.2", "-.2 0.1 -.2"};
155
156 string hitzone;
160 bool isSteppedOn = false;
161
164
165 // convert Array of string to array of Vectors
166 for (int v = 0; v < raycast_sources_str.Count(); ++v)
167 raycast_sources.Insert(raycast_sources_str[v].ToVector());
168
169 for (int i = 0; i < raycast_sources.Count(); ++i)
170 {
173
174 //#ifdef DEVELOPER
175 //Debug.DrawArrow( raycast_start_pos, raycast_end_pos );
176 //#endif
178
179 for (int j = 0; j < victims.Count(); ++j)
180 {
182
183 if (contact_obj.IsAnyInherited(m_DamageableTypes))
184 {
185 isSteppedOn = true;
186 break;
187 }
188 }
189
190 if (isSteppedOn)
191 {
192 EntityAI eai = EntityAI.Cast(victim);
193 if (eai)
194 {
195 hitzone = eai.GetDamageZoneNameByComponentIndex(contactComponent);
196 break;
197 }
198 }
199 }
200
201 if (isSteppedOn)
202 return hitzone;
203 else
204 {
205 // Damage random leg since we don't know what part of player's body was caught in the trap.
206 string dmg_zone_rnd = "LeftFoot";
207 if (Math.RandomIntInclusive(0, 1) == 1)
208 dmg_zone_rnd = "RightFoot";
209 return dmg_zone_rnd;
210 }
211 }
AreaDamageTriggerBase m_AreaDamageTrigger
static proto bool RaycastRV(vector begPos, vector endPos, out vector contactPos, out vector contactDir, out int contactComponent, set< Object > results=NULL, Object with=NULL, Object ignore=NULL, bool sorted=false, bool ground_only=false, int iType=ObjIntersectView, float radius=0.0, CollisionFlags flags=CollisionFlags.NEARESTCONTACT)
Raycasts world by given parameters.
static int RandomIntInclusive(int min, int max)
Returns a random int number between and min [inclusive] and max [inclusive].
Definition EnMath.c:54

References m_AreaDamageTrigger, Math::RandomIntInclusive(), and DayZPhysics::RaycastRV().

Referenced by EvaluateDamage().

◆ OnEnter()

void AreaDamageBase::OnEnter ( Object object)
inlineprotected

events

Definition at line 48 of file AreaDamage.c.

49 {
50 if (GetGame().IsServer())
51 OnEnterServer(object);
52 else
53 OnEnterClient(object);
54 }
void OnEnterClient(Object object)
Definition AreaDamage.c:55
void OnEnterServer(Object object)
Definition AreaDamage.c:56
proto native CGame GetGame()

References GetGame(), OnEnterClient(), and OnEnterServer().

◆ OnEnterClient()

void AreaDamageBase::OnEnterClient ( Object object)
inlineprotected

Definition at line 55 of file AreaDamage.c.

55{}

Referenced by OnEnter().

◆ OnEnterServer() [1/8]

void AreaDamageBase::OnEnterServer ( Object object)
inlineprotected

Definition at line 56 of file AreaDamage.c.

56{}

Referenced by OnEnter().

◆ OnEnterServer() [2/8]

override void AreaDamageBase::OnEnterServer ( Object object)
inlineprivate

Definition at line 16 of file AreaDamageOneTime.c.

17 {
18 super.OnEnterServer(object);
19
20 EvaluateDamage(object);
21 }
void EvaluateDamage(Object object)
Definition AreaDamage.c:91

References EvaluateDamage().

◆ OnEnterServer() [3/8]

override void AreaDamageBase::OnEnterServer ( Object object)
inlineprivate

Definition at line 21 of file AreaDamageOneTimeDeferred.c.

22 {
23 super.OnEnterServer(object);;
24
26 }
void EvaluateDamage_Defer(Object object)
Definition AreaDamage.c:81

References EvaluateDamage_Defer().

◆ OnEnterServer() [4/8]

override void AreaDamageBase::OnEnterServer ( Object object)
inlineprivate

Definition at line 16 of file AreaDamageOneTimeRaycasted.c.

17 {
18 super.OnEnterServer(object);
19
20 EvaluateDamage(object);
21 }

References EvaluateDamage().

◆ OnEnterServer() [5/8]

override void AreaDamageBase::OnEnterServer ( Object object)
inlineprivate

Definition at line 21 of file AreaDamageOneTimeRaycastedDeferred.c.

22 {
23 super.OnEnterServer(object);
24
26 }

References EvaluateDamage_Defer().

◆ OnEnterServer() [6/8]

override void AreaDamageBase::OnEnterServer ( Object object)
inlineprivate

Definition at line 21 of file AreaDamageRegular.c.

22 {
23 super.OnEnterServer(object);
24
25 EvaluateDamage_Loop(object);
26 }
void EvaluateDamage_Loop(Object object)
Definition AreaDamage.c:76

◆ OnEnterServer() [7/8]

override void AreaDamageBase::OnEnterServer ( Object object)
inlineprivate

Definition at line 21 of file AreaDamageRegularRaycasted.c.

22 {
23 super.OnEnterServer(object);
24
25 EvaluateDamage_Loop(object);
26 }

References EvaluateDamage_Loop().

◆ OnEnterServer() [8/8]

override void AreaDamageBase::OnEnterServer ( Object object)
inlineprivate

Definition at line 26 of file AreaDamageRegularRaycastedDeferred.c.

27 {
28 super.OnEnterServer(object);
29
31 }
void EvaluateDamage_DeferLoop(Object object)
Definition AreaDamage.c:86

References EvaluateDamage_DeferLoop().

◆ OnLeave()

void AreaDamageBase::OnLeave ( Object object)
inlineprotected

Definition at line 58 of file AreaDamage.c.

59 {
60 if (GetGame().IsServer())
61 OnLeaveServer(object);
62 else
63 OnLeaveClient(object);
64 }
void OnLeaveServer(Object object)
Definition AreaDamage.c:67
void OnLeaveClient(Object object)
Definition AreaDamage.c:66

References GetGame(), OnLeaveClient(), and OnLeaveServer().

◆ OnLeaveClient()

void AreaDamageBase::OnLeaveClient ( Object object)
inlineprotected

Definition at line 66 of file AreaDamage.c.

66{}

Referenced by OnLeave().

◆ OnLeaveServer()

void AreaDamageBase::OnLeaveServer ( Object object)
inlineprotected

stop all running timers

Definition at line 67 of file AreaDamage.c.

68 {
70 if (m_DeferTimer && m_DeferTimer.IsRunning())
71 m_DeferTimer.Stop();
72 if (m_LoopTimer && m_LoopTimer.IsRunning())
73 m_LoopTimer.Stop();
74 }

References m_DeferTimer, and m_LoopTimer.

Referenced by OnLeave().

◆ SetDeferDuration() [1/3]

override void AreaDamageBase::SetDeferDuration ( float time)
inlineprivate

Definition at line 11 of file AreaDamageOneTimeDeferred.c.

12 {
14 }

References m_DeferDuration.

◆ SetDeferDuration() [2/3]

override void AreaDamageBase::SetDeferDuration ( float time)
inlineprivate

Definition at line 11 of file AreaDamageOneTimeRaycastedDeferred.c.

12 {
14 }

References m_DeferDuration.

◆ SetDeferDuration() [3/3]

override void AreaDamageBase::SetDeferDuration ( float time)
inlineprivate

Definition at line 16 of file AreaDamageRegularRaycastedDeferred.c.

17 {
19 }

References m_DeferDuration.

◆ SetHitZones() [1/3]

override void AreaDamageBase::SetHitZones ( array< string > hitzones)
inlineprivate

Definition at line 11 of file AreaDamageOneTime.c.

12 {
14 }

◆ SetHitZones() [2/3]

override void AreaDamageBase::SetHitZones ( array< string > hitzones)
inlineprivate

Definition at line 16 of file AreaDamageOneTimeDeferred.c.

17 {
19 }

◆ SetHitZones() [3/3]

override void AreaDamageBase::SetHitZones ( array< string > hitzones)
inlineprivate

Definition at line 16 of file AreaDamageRegular.c.

17 {
19 }

◆ SetLoopInterval() [1/3]

override void AreaDamageBase::SetLoopInterval ( float time)
inlineprivate

Definition at line 11 of file AreaDamageRegular.c.

12 {
14 }

◆ SetLoopInterval() [2/3]

override void AreaDamageBase::SetLoopInterval ( float time)
inlineprivate

Definition at line 11 of file AreaDamageRegularRaycasted.c.

12 {
14 }

◆ SetLoopInterval() [3/3]

override void AreaDamageBase::SetLoopInterval ( float time)
inlineprivate

Definition at line 11 of file AreaDamageRegularRaycastedDeferred.c.

12 {
14 }

◆ SetRaycastSources() [1/4]

override void AreaDamageBase::SetRaycastSources ( array< string > raycast_sources)
inlineprivate

Definition at line 11 of file AreaDamageOneTimeRaycasted.c.

◆ SetRaycastSources() [2/4]

override void AreaDamageBase::SetRaycastSources ( array< string > raycast_sources)
inlineprivate

Definition at line 16 of file AreaDamageOneTimeRaycastedDeferred.c.

◆ SetRaycastSources() [3/4]

override void AreaDamageBase::SetRaycastSources ( array< string > raycast_sources)
inlineprivate

Definition at line 16 of file AreaDamageRegularRaycasted.c.

◆ SetRaycastSources() [4/4]

override void AreaDamageBase::SetRaycastSources ( array< string > raycast_sources)
inlineprivate

Definition at line 21 of file AreaDamageRegularRaycastedDeferred.c.

Member Data Documentation

◆ m_AmmoName

string AreaDamageBase::m_AmmoName
protected

Definition at line 10 of file AreaDamage.c.

Referenced by AreaDamageBase(), and EvaluateDamage_Common().

◆ m_AreaDamage

AreaDamageBase AreaDamageBase::m_AreaDamage
protected

Definition at line 5 of file AreaDamage.c.

Referenced by AreaDamageBase().

◆ m_DamageType

int AreaDamageBase::m_DamageType
protected

Definition at line 11 of file AreaDamage.c.

Referenced by AreaDamageBase(), and EvaluateDamage_Common().

◆ m_DeferDuration

float AreaDamageBase::m_DeferDuration
protected

Definition at line 14 of file AreaDamage.c.

Referenced by AreaDamageBase(), EvaluateDamage_Defer(), and EvaluateDamage_DeferLoop().

◆ m_DeferTimer

ref Timer AreaDamageBase::m_DeferTimer
protected

◆ m_HitZones

ref array<string> AreaDamageBase::m_HitZones
protected

Definition at line 16 of file AreaDamage.c.

Referenced by AreaDamageBase(), and EvaluateDamage().

◆ m_LoopInterval

float AreaDamageBase::m_LoopInterval
protected

Definition at line 13 of file AreaDamage.c.

Referenced by AreaDamageBase(), and EvaluateDamage_Loop().

◆ m_LoopTimer

ref Timer AreaDamageBase::m_LoopTimer
protected

Definition at line 20 of file AreaDamage.c.

Referenced by AreaDamageBase(), EvaluateDamage_Loop(), and OnLeaveServer().

◆ m_OthersDamage

float AreaDamageBase::m_OthersDamage
protected

Definition at line 8 of file AreaDamage.c.

Referenced by AreaDamageBase().

◆ m_PlayerDamage

float AreaDamageBase::m_PlayerDamage
protected

Definition at line 7 of file AreaDamage.c.

Referenced by AreaDamageBase().

◆ m_RaycastSources

ref array<string> AreaDamageBase::m_RaycastSources
protected

Definition at line 17 of file AreaDamage.c.

Referenced by AreaDamageBase(), and EvaluateDamage().


The documentation for this class was generated from the following files: