forked from acemod/ACE3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfnc_countTreatmentItems.sqf
More file actions
72 lines (65 loc) · 2 KB
/
fnc_countTreatmentItems.sqf
File metadata and controls
72 lines (65 loc) · 2 KB
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
#include "..\script_component.hpp"
/*
* Author: AmsteadRayle
* Counts how many of the given items are present between the medic and patient.
* If medic or patient are in a vehicle then vehicle's inventory will also be checked.
*
* Arguments:
* 0: Items <ARRAY>
*
* Return Value:
* Counts (can be nil) <ARRAY>
*
* Example:
* [items] call ace_medical_gui_fnc_countTreatmentItems
*
* Public: No
*/
params ["_items"];
private _medicCount = 0;
private _patientCount = nil;
private _vehicleCount = nil;
// Medic
{
_medicCount = _medicCount + ([ACE_player, _x] call EFUNC(common,getCountOfItem));
} forEach _items;
// Patient
if (ACE_player != GVAR(target)) then {
_patientCount = 0;
{
_patientCount = _patientCount + ([GVAR(target), _x] call EFUNC(common,getCountOfItem));
} forEach _items;
};
// Vehicle
private _medicVehicle = objectParent ACE_player;
private _patientVehicle = objectParent GVAR(target);
private _vehicle = [_patientVehicle, _medicVehicle] select (!isNull _medicVehicle);
if (!isNull _vehicle) then {
_vehicleCount = 0;
private _magazineItems = [];
private _itemItems = [];
{
if (isClass (configFile >> "CfgMagazines" >> _x)) then {
_magazineItems pushBack _x;
} else {
_itemItems pushBack _x;
};
} forEach _items;
if (_magazineItems isNotEqualTo []) then {
(getMagazineCargo _vehicle) params ["_itemTypes", "_itemCounts"];
{
private _item = _x;
private _index = _itemTypes find _item;
_vehicleCount = _vehicleCount + (_itemCounts param [_index, 0]);
} forEach _magazineItems;
};
if (_itemItems isNotEqualTo []) then {
(getItemCargo _vehicle) params ["_itemTypes", "_itemCounts"];
{
private _item = _x;
private _index = _itemTypes find _item;
_vehicleCount = _vehicleCount + (_itemCounts param [_index, 0]);
} forEach _itemItems;
};
};
[_medicCount, _patientCount, _vehicleCount]