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

Static Private Member Functions

static void RegisterHitComponent (array< ref DayZAIHitComponent > pHitComponents, string pName, float pWeight)
 Register Hit Component for AI targeting.
 
static bool SelectMostProbableHitComponent (array< ref DayZAIHitComponent > pHitComponents, out string pHitComponent)
 
static int SumOfWeights (array< ref DayZAIHitComponent > pHitComponents)
 Calculates the sum of all entries in DayZAIHitComponent array.
 

Detailed Description

Definition at line 8 of file DayZAIHitComponents.c.

Member Function Documentation

◆ RegisterHitComponent()

DayZAIHitComponentHelpers::RegisterHitComponent ( array< ref DayZAIHitComponent > pHitComponents,
string pName,
float pWeight )
inlinestaticprivate

Register Hit Component for AI targeting.

Register Hit Component for AI targeting to array defined on entity's Type (DayZPlayerType, DayZInfectedType, etc.) Uses component name from damage system (zone) and its weight.

Parameters
[in]pHitComponentsarray that keeps registered compoenents
[in]pNamecomponent name (zone in Damage System)
[in]pWeightweight of the component (probability)

Definition at line 21 of file DayZAIHitComponents.c.

22 {
24
25 newComponent.m_Name = pName;
26 newComponent.m_Weight = pWeight;
27
29 }
holds hit components and its weights for attack from AI (used on each type - DayZPlayerType,...

Referenced by RegisterHitComponentsForAI(), DayZCreatureAI::RegisterHitComponentsForAI(), and AnimalBase::RegisterHitComponentsForAI().

◆ SelectMostProbableHitComponent()

static bool DayZAIHitComponentHelpers::SelectMostProbableHitComponent ( array< ref DayZAIHitComponent > pHitComponents,
out string pHitComponent )
inlinestaticprivate

Definition at line 40 of file DayZAIHitComponents.c.

41 {
43 float rnd = Math.RandomInt(0, weights);
44
45 for (int i = 0; i < pHitComponents.Count(); ++i)
46 {
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 }
static int SumOfWeights(array< ref DayZAIHitComponent > pHitComponents)
Calculates the sum of all entries in DayZAIHitComponent array.
Definition EnMath.c:7
static proto int RandomInt(int min, int max)
Returns a random int number between and min [inclusive] and max [exclusive].

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

Referenced by GetHitComponentForAI(), and DayZCreatureAI::GetHitComponentForAI().

◆ SumOfWeights()

DayZAIHitComponentHelpers::SumOfWeights ( array< ref DayZAIHitComponent > pHitComponents)
inlinestaticprivate

Calculates the sum of all entries in DayZAIHitComponent array.

Parameters
[in]pHitComponentsarray that keeps registered compoenents
Returns
Sum of weights of all entries in array

Definition at line 68 of file DayZAIHitComponents.c.

69 {
70 int sum = 0;
71
72 for (int i = 0; i < pHitComponents.Count(); ++i)
73 {
75 sum += hitComp.m_Weight;
76 }
77
78 return sum;
79 }

Referenced by SelectMostProbableHitComponent().


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