summaryrefslogtreecommitdiffstats
path: root/Common/Functions/Common_GetTeamArtillery.sqf
blob: 3bc97d70bcc76047122dcd6f1ce3ddd06d6d3fbf (plain)
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
Private["_artillery","_artyTypes","_artyWeapons","_count","_ignoreAmmo","_index","_position","_search","_side","_team","_units","_vehicle","_weapon","_x","_y"];

_team = _this select 0;
_ignoreAmmo = _this select 1;
_index = _this select 2;
_side = _this select 3;

if (_index < 0) exitWith {[]};

_units = units _team;
_artyTypes = (Format ["WFBE_%1_ARTILLERY_NAMES",_side] Call GetNamespace) select _index;
_artyWeapons = Format ["WFBE_%1_ARTILLERY_WEAPONS",_side] Call GetNamespace;

_artillery = [];

{
	_vehicle = vehicle _x;

	if (typeOf(_vehicle) in _artyTypes) then {
		if (!(isNull(gunner _vehicle)) && !(_vehicle in _artillery) && !(isPlayer(gunner _vehicle))) then {
			if !(isPlayer(gunner _vehicle)) then {
				_weapon = _artyWeapons select _index;

				if (_ignoreAmmo || (_vehicle ammo _weapon > 0)) then {
					_artillery = _artillery + [_vehicle];
				};
			};
		};
	};
} forEach _units;

_artillery