-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ammo_Notes.txt
180 lines (127 loc) · 5.6 KB
/
Ammo_Notes.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
//===== This successfully sends the name of each pylon to SystemChat
{
_var = configname(configfile >> "CfgVehicles" >> "USAF_MQ9" >> "Components" >> "TransportPylonsComponent" >> "pylons" >> configname _x);
systemChat format["%1", _var];
}forEach configProperties[configfile >> "CfgVehicles" >> "USAF_MQ9" >> "Components" >> "TransportPylonsComponent" >> "pylons"];
//===== This successfully sends the name of each pylon and the ammo count to SystemChat
{
_var = configname(configfile >> "CfgVehicles" >> "USAF_MQ9" >> "Components" >> "TransportPylonsComponent" >> "pylons" >> configname _x);
systemChat format["%1: %2", _var, uav ammoOnPylon _var];
}forEach configProperties[configfile >> "CfgVehicles" >> "USAF_MQ9" >> "Components" >> "TransportPylonsComponent" >> "pylons"];
//===== This successfully sends the name of each pylon and the ammo count and ammo name to SystemChat, plus saves stuff to arrays
myMagazines = getPylonMagazines (uav);
myIndex = 0;
ammoNameArray = [];
ammoCountArray = [];
{
_var = configname(configfile >> "CfgVehicles" >> typeOf UAV >> "Components" >> "TransportPylonsComponent" >> "pylons" >> configname _x);
_ammo = uav ammoOnPylon _var;
_ammoName = getText(configfile >> "CfgMagazines" >> myMagazines select myIndex >> "displayNameShort");
systemChat format["%1: %2 %3", _var, _ammo, _ammoName];
myIndex = myIndex + 1;
ammoNameArray pushback _ammoName;
ammoCountArray pushback _ammo;
}forEach configProperties[configfile >> "CfgVehicles" >> typeOf UAV >> "Components" >> "TransportPylonsComponent" >> "pylons"];
systemChat format["names: %1", ammoNameArray];
systemChat format["count %1", ammoCountArray];
//===== This successfully sends the name of each pylon and the ammo count and ammo name to SystemChat, plus saves stuff to arrays
myMagazines = getPylonMagazines (uav);
ammoNameArray = [];
ammoCountArray = [];
{
_var = configname(configfile >> "CfgVehicles" >> typeOf uav >> "Components" >> "TransportPylonsComponent" >> "pylons" >> configname _x);
_ammo = uav ammoOnPylon _var;
_ammoName = getText(configfile >> "CfgMagazines" >> myMagazines select _forEachIndex>> "displayNameShort");
//systemChat format["%1: %2 %3", _var, _ammo, _ammoName];
ammoNameArray pushback _ammoName;
ammoCountArray pushback _ammo;
}forEach configProperties[configfile >> "CfgVehicles" >> typeOf UAV >> "Components" >> "TransportPylonsComponent" >> "pylons"];
//systemChat format["names: %1", ammoNameArray];
//systemChat format["count %1", ammoCountArray];
finalNameArray = [];
finalAmmoArray = [];
{
tmpName = _x; //OK
//systemChat format["tmpName: %1", tmpName];
if (tmpName in finalNameArray) then
{
//Iterate per entry in final array, if name matches, sum the ammo counts
{
if (tmpName == _x) then
{
_a = finalAmmoArray select _forEachIndex;
_b = ammoCountArray select _forEachIndex; //SUSPECT
systemChat format["a: %1 b: %2 index:%3", _a, _b, _forEachIndex];
//_tmpTotal = ((finalAmmoArray select _forEachIndex) + (ammoCountArray select _forEachIndex));
_tmpTotal = _a + _b;
finalAmmoArray set [_forEachIndex, _tmpTotal];
//systemChat format["final %1 being added to Count %2 _tmpTotal: %3 index:%4", (finalAmmoArray select _forEachIndex),(ammoCountArray select _forEachIndex), _tmpTotal, _forEachIndex];
}
} forEach finalNameArray;
}
else
{
//Add new entry because it's not in the finall array
finalNameArray pushback (ammoNameArray select _forEachIndex);
finalAmmoArray pushback (ammoCountArray select _forEachIndex);
systemChat format["pushback %1 %2 ",(ammoNameArray select _forEachIndex), (ammoCountArray select _forEachIndex)];
};
} foreach FinalNameArray;
_output=[finalNameArray, finalAmmoArray];
systemChat format["final names: %1 - final count %2", finalNameArray, finalAmmoArray];
//systemChat format["final count %1", finalAmmoArray];
//systemChat format["final array %1", _output];
_output;
//##########################################################################
myMagazines = getPylonMagazines (uav);
ammoNameArray = [];
ammoCountArray = [];
//===== BUILD ARRAYS CONTAINING AMMO NAME & COUNT PER PYLON
{
_var = configname(configfile >> "CfgVehicles" >> typeOf uav >> "Components" >> "TransportPylonsComponent" >> "pylons" >> configname _x);
_ammo = uav ammoOnPylon _var;
_ammoName = getText(configfile >> "CfgMagazines" >> myMagazines select _forEachIndex>> "displayNameShort");
ammoNameArray pushback _ammoName;
ammoCountArray pushback _ammo;
}forEach configProperties[configfile >> "CfgVehicles" >> typeOf UAV >> "Components" >> "TransportPylonsComponent" >> "pylons"];
finalNameArray = [];
finalAmmoArray = [];
//===== SUM THE AMMO COUNTS PER TYPE
{
tmpName = _x;
rootIndex = _forEachIndex;
if(!(_x in finalNameArray)) then
{
finalNameArray pushback tmpName;
finalAmmoArray pushback (ammoCountArray select _forEachIndex);
}
else
{
{
if(tmpName == _X) then
{
finalAmmoArray set[_forEachIndex, (finalAmmoArray select _forEachIndex) + (ammoCountArray select rootIndex)];
};
}forEach finalNameArray;
};
}
forEach ammoNameArray;
//======== PREPARE FORMATTED STRING WITH PLYLON AMMO INFO
_text = "";
_tmpIndex = 0;
{
_text = _text + str(finalAmmoArray select _tmpIndex) + "x " + (finalNameArray select _tmpIndex);
if(count finalNameArray > _tmpIndex+1) then
{
_text = _text + ", ";
};
_tmpIndex = _tmpIndex+1;
} forEach finalNameArray;
_totalAmmo = 0;
{
_totalAmmo = _totalAmmo + _x;
}forEach finalAmmoArray;
//===== IF THERE ARE NO ROUNDS OF ANY TYPE, REPORT WINCHESTER
if(_totalAmmo ==0) then {_text = "Winchester"};
_output = [finalAmmoArray, finalNameArray, _text];
_output;