DayZ 1.24
Loading...
Searching...
No Matches
AreaDamageComponentRaycasted Class Reference

Newer implementation equivalent of "AreaDamageRegularRaycasted", hitzone selection only. More...

Inheritance diagram for AreaDamageComponentRaycasted:
[legend]
Collaboration diagram for AreaDamageComponentRaycasted:
[legend]

Protected Member Functions

AreaDamageComponentData GetAreaDamageComponentData (Object object)
 
void ClearCache ()
 
string GetRaycastedHitZone (Object victim)
 
string GetFallbackHitZone (Object victim)
 

Private Member Functions

void AreaDamageComponentRaycasted (AreaDamageManager parent)
 
override void OnTriggerCreated ()
 
void SetRaycastSources (array< string > raycast_sources)
 
void SetRaycastSourcesVector (array< vector > raycast_sources)
 
void SetRaycastLength (float length)
 
override void OnStayFinishServerEvent ()
 

Private Attributes

ref array< vectorm_RaycastSources
 
vector m_RaycastEndOffset
 
ref array< ref RaycastRVResultm_RaycastCache
 
int m_RaycastCachedIndex
 

Detailed Description

Newer implementation equivalent of "AreaDamageRegularRaycasted", hitzone selection only.

Definition at line 2 of file AreaDamageComponentRaycasted.c.

Constructor & Destructor Documentation

◆ AreaDamageComponentRaycasted()

void AreaDamageComponentRaycasted::AreaDamageComponentRaycasted ( AreaDamageManager parent)
inlineprivate

Member Function Documentation

◆ ClearCache()

void AreaDamageComponentRaycasted::ClearCache ( )
inlineprotected

Definition at line 62 of file AreaDamageComponentRaycasted.c.

63 {
64 m_RaycastCache.Clear();
66 }

References m_RaycastCache, and m_RaycastCachedIndex.

Referenced by OnStayFinishServerEvent(), and OnTriggerCreated().

◆ GetAreaDamageComponentData()

AreaDamageComponentData AreaDamageComponentRaycasted::GetAreaDamageComponentData ( Object object)
inlineprotected

◆ GetFallbackHitZone()

string AreaDamageComponentRaycasted::GetFallbackHitZone ( Object victim)
inlineprotected

Definition at line 119 of file AreaDamageComponentRaycasted.c.

120 {
121 Error(string.Format("[WARNING] :: [%1] :: [AreaDamageComponentRaycasted] :: No proper HitZone found for damaging %2, using fallback.",
122 m_Parent, Object.GetDebugName(victim)));
123
124 // Fallbacks, currently are implemented assuming that foot/leg damagezones would be desired to damage
125 if (victim.IsInherited(DayZPlayer) || victim.IsInherited(DayZInfected))
126 {
127 // Damage random leg since we don't know what part of player's body was caught in the trap.
128 if (Math.RandomIntInclusive(0, 1) == 1)
129 return "RightFoot";
130 return "LeftFoot";
131 }
132 else
133 {
135 victim.GetDamageZones(damageZones);
136
137 int nrOfDmgZones = damageZones.Count();
138
139 if (nrOfDmgZones > 0)
140 {
141 for (int z = 0; z < nrOfDmgZones; ++z)
142 {
143 if (damageZones[z].Contains("Foot") || damageZones[z].Contains("Leg"))
144 return damageZones[z];
145 }
146
147 return damageZones.GetRandomElement();
148 }
149 else
150 return "";
151 }
152 }
Widget m_Parent
Definition SizeToChild.c:86
Definition EnMath.c:7
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90
static int RandomIntInclusive(int min, int max)
Returns a random int number between and min [inclusive] and max [inclusive].
Definition EnMath.c:54

References Error(), m_Parent, and Math::RandomIntInclusive().

Referenced by GetRaycastedHitZone().

◆ GetRaycastedHitZone()

string AreaDamageComponentRaycasted::GetRaycastedHitZone ( Object victim)
inlineprotected

Definition at line 68 of file AreaDamageComponentRaycasted.c.

69 {
71 for (int c = 0; c < nrOfCachedResults; ++c)
72 {
74 if (cachedRes.obj == victim)
75 return victim.GetDamageZoneNameByComponentIndex(cachedRes.component);
76 }
77
78 int nrOfSources = m_RaycastSources.Count();
80
81 string hitzone = "";
82
84
87 params.flags = CollisionFlags.ONLYDYNAMIC;
88
89 for (int i = m_RaycastCachedIndex + 1; i < nrOfSources; ++i)
90 {
92
93 params.begPos = trigger.ModelToWorld(m_RaycastSources[i]);
94 params.endPos = params.begPos + m_RaycastEndOffset;
95
97 {
98 for (int j = 0; j < victims.Count(); ++j)
99 {
101
102 if (res.obj == victim)
103 hitzone = victim.GetDamageZoneNameByComponentIndex(res.component);
104
105 if (res.obj.IsAnyInherited(m_DamageableTypes))
106 m_RaycastCache.Insert(res);
107 }
108
109 if (!(hitzone == ""))
110 return hitzone;
111
112 victims.Clear();
113 }
114 }
115
117 }
static proto bool RaycastRVProxy(notnull RaycastRVParams in, out notnull array< ref RaycastRVResult > results, array< Object > excluded=null)
static const vector Zero
Definition EnConvert.c:110
CollisionFlags
Definition EnDebug.c:141

References GetFallbackHitZone(), m_Parent, m_RaycastCache, m_RaycastCachedIndex, m_RaycastEndOffset, m_RaycastSources, DayZPhysics::RaycastRVProxy(), and vector::Zero.

Referenced by GetAreaDamageComponentData().

◆ OnStayFinishServerEvent()

override void AreaDamageComponentRaycasted::OnStayFinishServerEvent ( )
inlineprivate

Definition at line 47 of file AreaDamageComponentRaycasted.c.

48 {
49 super.OnStayFinishServerEvent();
50
51 ClearCache();
52 }

References ClearCache().

◆ OnTriggerCreated()

override void AreaDamageComponentRaycasted::OnTriggerCreated ( )
inlineprivate

Definition at line 20 of file AreaDamageComponentRaycasted.c.

21 {
22 super.OnTriggerCreated();
23
24 ClearCache();
25 }

References ClearCache().

◆ SetRaycastLength()

void AreaDamageComponentRaycasted::SetRaycastLength ( float length)
inlineprivate

Definition at line 42 of file AreaDamageComponentRaycasted.c.

43 {
45 }
proto native vector Vector(float x, float y, float z)
Vector constructor from components.

References m_RaycastEndOffset, and Vector().

◆ SetRaycastSources()

void AreaDamageComponentRaycasted::SetRaycastSources ( array< string > raycast_sources)
inlineprivate

Definition at line 27 of file AreaDamageComponentRaycasted.c.

28 {
29 m_RaycastSources.Clear();
30
31 // convert Array of string to array of Vectors
32 int nrOfSources = raycast_sources.Count();
33 for (int v = 0; v < nrOfSources; ++v)
34 m_RaycastSources.Insert(raycast_sources[v].ToVector());
35 }

References m_RaycastSources.

◆ SetRaycastSourcesVector()

void AreaDamageComponentRaycasted::SetRaycastSourcesVector ( array< vector > raycast_sources)
inlineprivate

Definition at line 37 of file AreaDamageComponentRaycasted.c.

References m_RaycastSources.

Member Data Documentation

◆ m_RaycastCache

ref array<ref RaycastRVResult> AreaDamageComponentRaycasted::m_RaycastCache
private

◆ m_RaycastCachedIndex

int AreaDamageComponentRaycasted::m_RaycastCachedIndex
private

◆ m_RaycastEndOffset

vector AreaDamageComponentRaycasted::m_RaycastEndOffset
private

◆ m_RaycastSources

ref array<vector> AreaDamageComponentRaycasted::m_RaycastSources
private

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