Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
dayzaihitcomponents.c
Go to the documentation of this file.
1
2
class
DayZAIHitComponent
3
{
4
string
m_Name
;
5
int
m_Weight
;
6
};
7
8
class
DayZAIHitComponentHelpers
9
{
21
static
void
RegisterHitComponent
(
array<ref DayZAIHitComponent>
pHitComponents,
string
pName,
float
pWeight)
22
{
23
DayZAIHitComponent
newComponent =
new
DayZAIHitComponent
();
24
25
newComponent.
m_Name
= pName;
26
newComponent.
m_Weight
= pWeight;
27
28
pHitComponents.Insert(newComponent);
29
}
30
40
static
bool
SelectMostProbableHitComponent
(
array<ref DayZAIHitComponent>
pHitComponents, out
string
pHitComponent)
41
{
42
int
weights =
SumOfWeights
(pHitComponents);
43
float
rnd =
Math
.
RandomInt
(0, weights);
44
45
for
(
int
i = 0; i < pHitComponents.Count(); ++i )
46
{
47
DayZAIHitComponent
hitComp = pHitComponents.Get(i);
48
rnd -= hitComp.
m_Weight
;
49
50
if
(rnd <= 0)
51
{
52
pHitComponent = hitComp.
m_Name
;
53
return
true
;
54
}
55
}
56
57
return
false
;
58
}
59
68
static
int
SumOfWeights
(
array<ref DayZAIHitComponent>
pHitComponents)
69
{
70
int
sum = 0;
71
72
for
(
int
i = 0; i < pHitComponents.Count(); ++i )
73
{
74
DayZAIHitComponent
hitComp = pHitComponents.Get(i);
75
sum += hitComp.
m_Weight
;
76
}
77
78
return
sum;
79
}
80
};
DayZAIHitComponentHelpers
Definition
dayzaihitcomponents.c:9
DayZAIHitComponentHelpers::SumOfWeights
static int SumOfWeights(array< ref DayZAIHitComponent > pHitComponents)
Definition
dayzaihitcomponents.c:68
DayZAIHitComponentHelpers::SelectMostProbableHitComponent
static bool SelectMostProbableHitComponent(array< ref DayZAIHitComponent > pHitComponents, out string pHitComponent)
Definition
dayzaihitcomponents.c:40
DayZAIHitComponentHelpers::RegisterHitComponent
static void RegisterHitComponent(array< ref DayZAIHitComponent > pHitComponents, string pName, float pWeight)
Definition
dayzaihitcomponents.c:21
DayZAIHitComponent
holds hit components and its weights for attack from AI (used on each type - DayZPlayerType,...
Definition
dayzaihitcomponents.c:3
DayZAIHitComponent::m_Name
string m_Name
Definition
dayzaihitcomponents.c:4
DayZAIHitComponent::m_Weight
int m_Weight
"Head", "Torso", etc.
Definition
dayzaihitcomponents.c:5
Math
Definition
enmath.c:7
array
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Definition
isboxcollidinggeometryproxyclasses.c:28
Math::RandomInt
static proto int RandomInt(int min, int max)
Returns a random int number between and min [inclusive] and max [exclusive].
Games
Dayz
scripts
3_game
entities
dayzaihitcomponents.c
Generated by
1.17.0