Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
areadamagecomponentraycasted.c
Go to the documentation of this file.
1
2
class
AreaDamageComponentRaycasted
:
AreaDamageComponent
3
{
4
// Defined in local space of the trigger
5
ref
array<vector>
m_RaycastSources
;
6
vector
m_RaycastEndOffset
;
7
8
ref
array<ref RaycastRVResult>
m_RaycastCache
;
9
int
m_RaycastCachedIndex
;
10
11
void
AreaDamageComponentRaycasted
(
AreaDamageManager
parent)
12
{
13
m_RaycastSources
=
new
array<vector>
;
14
m_RaycastEndOffset
=
"0 0.5 0"
;
15
16
m_RaycastCache
=
new
array<ref RaycastRVResult>
;
17
m_RaycastCachedIndex
= -1;
18
}
19
20
override
void
OnTriggerCreated
()
21
{
22
super.OnTriggerCreated();
23
24
ClearCache
();
25
}
26
27
void
SetRaycastSources
(
array<string>
raycast_sources )
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
{
35
m_RaycastSources
.Insert(raycast_sources[v].ToVector());
36
}
37
}
38
39
void
SetRaycastSourcesVector
(
array<vector>
raycast_sources )
40
{
41
m_RaycastSources
= raycast_sources;
42
}
43
44
void
SetRaycastLength
(
float
length)
45
{
46
m_RaycastEndOffset
=
Vector
(0, length, 0);
47
}
48
49
override
void
OnStayFinishServerEvent
()
50
{
51
super.OnStayFinishServerEvent();
52
53
ClearCache
();
54
}
55
56
override
protected
AreaDamageComponentData
GetAreaDamageComponentData
(
Object
object
)
57
{
58
AreaDamageComponentData
data =
new
AreaDamageComponentData
;
59
data.
Hitzone
=
GetRaycastedHitZone
(
object
);
60
61
return
data;
62
}
63
64
protected
void
ClearCache
()
65
{
66
m_RaycastCache
.Clear();
67
m_RaycastCachedIndex
= -1;
68
}
69
70
protected
string
GetRaycastedHitZone
(
Object
victim)
71
{
72
int
nrOfCachedResults =
m_RaycastSources
.Count();
73
for
(
int
c = 0; c < nrOfCachedResults; ++c )
74
{
75
RaycastRVResult
cachedRes =
m_RaycastCache
[c];
76
if
( cachedRes.
obj
== victim )
77
return
victim.GetDamageZoneNameByComponentIndex(cachedRes.
component
);
78
}
79
80
int
nrOfSources =
m_RaycastSources
.Count();
81
array<ref RaycastRVResult>
victims =
new
array<ref RaycastRVResult>
;
82
83
string
hitzone =
""
;
84
85
AreaDamageTriggerBase
trigger =
m_Parent
.GetTrigger();
86
87
RaycastRVParams
params =
new
RaycastRVParams
(
vector
.
Zero
,
vector
.
Zero
, trigger, 0.0 );
88
params.
type
= ObjIntersectIFire;
89
params.
flags
=
CollisionFlags
.ONLYDYNAMIC;
90
91
for
(
int
i =
m_RaycastCachedIndex
+ 1; i < nrOfSources; ++i )
92
{
93
m_RaycastCachedIndex
= i;
94
95
params.
begPos
= trigger.ModelToWorld(
m_RaycastSources
[i] );
96
params.
endPos
= params.
begPos
+
m_RaycastEndOffset
;
97
98
if
(
DayZPhysics
.
RaycastRVProxy
(params, victims) )
99
{
100
for
(
int
j = 0; j < victims.Count(); ++j )
101
{
102
RaycastRVResult
res = victims[j];
103
104
if
(res.
obj
== victim)
105
hitzone = victim.GetDamageZoneNameByComponentIndex(res.
component
);
106
107
if
(res.
obj
.IsAnyInherited(m_DamageableTypes))
108
m_RaycastCache
.Insert(res);
109
}
110
111
if
( !( hitzone ==
""
) )
112
return
hitzone;
113
114
victims.Clear();
115
}
116
}
117
118
return
GetFallbackHitZone
(victim);
119
}
120
121
protected
string
GetFallbackHitZone
(
Object
victim)
122
{
123
Error
(
string
.Format(
"[WARNING] :: [%1] :: [AreaDamageComponentRaycasted] :: No proper HitZone found for damaging %2, using fallback."
,
124
m_Parent
,
Object
.GetDebugName(victim)));
125
126
// Fallbacks, currently are implemented assuming that foot/leg damagezones would be desired to damage
127
if
( victim.IsInherited(
DayZPlayer
) || victim.IsInherited(
DayZInfected
) )
128
{
129
// Damage random leg since we don't know what part of player's body was caught in the trap.
130
if
(
Math
.
RandomIntInclusive
(0, 1) == 1 )
131
return
"RightFoot"
;
132
return
"LeftFoot"
;
133
}
134
else
135
{
136
array<string>
damageZones =
new
array<string>
;
137
victim.GetDamageZones(damageZones);
138
139
int
nrOfDmgZones = damageZones.Count();
140
141
if
(nrOfDmgZones > 0)
142
{
143
for
(
int
z = 0; z < nrOfDmgZones; ++z)
144
{
145
if
( damageZones[z].Contains(
"Foot"
) || damageZones[z].Contains(
"Leg"
) )
146
return
damageZones[z];
147
}
148
149
return
damageZones.GetRandomElement();
150
}
151
else
152
return
""
;
153
}
154
}
155
}
AreaDamageComponent
ref array< typename > m_DamageableTypes void AreaDamageComponent(AreaDamageManager parent)
Definition
areadamagecomponent.c:16
AreaDamageManager
void AreaDamageManager(EntityAI parent)
Definition
areadamagemanager.c:22
m_Parent
Entity m_Parent
Definition
cachedequipmentstoragebase.c:15
AreaDamageComponentData
Definition
areadamagecomponent.c:2
AreaDamageComponentData::Hitzone
string Hitzone
Definition
areadamagecomponent.c:3
AreaDamageComponentRaycasted::m_RaycastSources
ref array< vector > m_RaycastSources
Definition
areadamagecomponentraycasted.c:5
AreaDamageComponentRaycasted::m_RaycastCache
ref array< ref RaycastRVResult > m_RaycastCache
Definition
areadamagecomponentraycasted.c:8
AreaDamageComponentRaycasted::OnStayFinishServerEvent
override void OnStayFinishServerEvent()
Definition
areadamagecomponentraycasted.c:49
AreaDamageComponentRaycasted::AreaDamageComponentRaycasted
void AreaDamageComponentRaycasted(AreaDamageManager parent)
Definition
areadamagecomponentraycasted.c:11
AreaDamageComponentRaycasted::GetAreaDamageComponentData
AreaDamageComponentData GetAreaDamageComponentData(Object object)
Definition
areadamagecomponentraycasted.c:56
AreaDamageComponentRaycasted::GetFallbackHitZone
string GetFallbackHitZone(Object victim)
Definition
areadamagecomponentraycasted.c:121
AreaDamageComponentRaycasted::m_RaycastCachedIndex
int m_RaycastCachedIndex
Definition
areadamagecomponentraycasted.c:9
AreaDamageComponentRaycasted::OnTriggerCreated
override void OnTriggerCreated()
Definition
areadamagecomponentraycasted.c:20
AreaDamageComponentRaycasted::GetRaycastedHitZone
string GetRaycastedHitZone(Object victim)
Definition
areadamagecomponentraycasted.c:70
AreaDamageComponentRaycasted::m_RaycastEndOffset
vector m_RaycastEndOffset
Definition
areadamagecomponentraycasted.c:6
AreaDamageComponentRaycasted::SetRaycastSources
void SetRaycastSources(array< string > raycast_sources)
Definition
areadamagecomponentraycasted.c:27
AreaDamageComponentRaycasted::ClearCache
void ClearCache()
Definition
areadamagecomponentraycasted.c:64
AreaDamageComponentRaycasted::SetRaycastLength
void SetRaycastLength(float length)
Definition
areadamagecomponentraycasted.c:44
AreaDamageComponentRaycasted::SetRaycastSourcesVector
void SetRaycastSourcesVector(array< vector > raycast_sources)
Definition
areadamagecomponentraycasted.c:39
AreaDamageTriggerBase
Definition
areadamagetriggerdirect.c:2
DayZInfected
Definition
zombiebase.c:2
DayZPhysics
Definition
dayzphysics.c:124
DayZPhysics::RaycastRVProxy
static proto bool RaycastRVProxy(notnull RaycastRVParams in, out notnull array< ref RaycastRVResult > results, array< Object > excluded=null)
DayZPlayer
Definition
dayzplayerimplement.c:87
Math
Definition
enmath.c:7
Object
Definition
objecttyped.c:2
RaycastRVParams
Input parameters for RaycastRVProxy function.
Definition
dayzphysics.c:50
RaycastRVParams::flags
CollisionFlags flags
Sets the raycast behaviour in terms of result.
Definition
dayzphysics.c:63
RaycastRVParams::begPos
vector begPos
begin position of raycast (e.g.
Definition
dayzphysics.c:51
RaycastRVParams::endPos
vector endPos
end position of raycast (e.g.
Definition
dayzphysics.c:52
RaycastRVParams::type
int type
type of intersection, possible values ObjIntersectFire(0), ObjIntersectView(1), ObjIntersectGeom(2),...
Definition
dayzphysics.c:73
RaycastRVResult
Contains result data of RaycastRVProxy function.
Definition
dayzphysics.c:99
RaycastRVResult::obj
Object obj
object,that we collide with (NULL if none), If hierLevel > 0 object is the proxy object
Definition
dayzphysics.c:100
RaycastRVResult::component
int component
index of component in corresponding geometry level
Definition
dayzphysics.c:107
array
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Definition
isboxcollidinggeometryproxyclasses.c:28
vector
Definition
enconvert.c:119
vector::Zero
static const vector Zero
Definition
enconvert.c:123
Error
void Error(string err)
Messagebox with error message.
Definition
endebug.c:90
CollisionFlags
CollisionFlags
Definition
endebug.c:141
Vector
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
Math::RandomIntInclusive
static int RandomIntInclusive(int min, int max)
Returns a random int number between and min [inclusive] and max [inclusive].
Definition
enmath.c:54
Games
Dayz
scripts
4_world
classes
areadamage
areadamagenew
damagecomponents
areadamagecomponentraycasted.c
Generated by
1.17.0