Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
dayzaihitcomponents.c
Go to the documentation of this file.
1
3{
4 string m_Name;
5 int m_Weight;
6};
7
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};
holds hit components and its weights for attack from AI (used on each type - DayZPlayerType,...
Definition enmath.c:7
Result for an object found in CGame.IsBoxCollidingGeometryProxy.