mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
8f46ffd8d5
count -> forEach Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com>
39 lines
940 B
Plaintext
39 lines
940 B
Plaintext
#include "..\script_component.hpp"
|
|
/*
|
|
* Author: commy2
|
|
* Returns gunner using specified weapon type in vehicle. Only works if all turrets have different weapons.
|
|
*
|
|
* Arguments:
|
|
* 0: Vehicle <OBJECT>
|
|
* 1: Weapon <STRING>
|
|
*
|
|
* Return Value:
|
|
* Gunner <OBJECT>
|
|
*
|
|
* Example:
|
|
* [car, "gun"] call ace_common_fnc_getGunner
|
|
*
|
|
* Public: Yes
|
|
*/
|
|
|
|
params [["_vehicle", objNull, [objNull]], ["_weapon", "", [""]]];
|
|
|
|
// on foot
|
|
if (gunner _vehicle == _vehicle && {_weapon in weapons _vehicle || {toLowerANSI _weapon in ["throw", "put"]}}) exitWith {gunner _vehicle};
|
|
|
|
// inside vehicle
|
|
private _gunner = objNull;
|
|
|
|
{
|
|
if (_weapon in (_vehicle weaponsTurret _x)) exitWith {
|
|
_gunner = _vehicle turretUnit _x;
|
|
};
|
|
} forEach allTurrets [_vehicle, true];
|
|
|
|
// ensure that at least the pilot is returned if there is no gunner
|
|
if (isManualFire _vehicle && {isNull _gunner}) then {
|
|
_gunner = effectiveCommander _vehicle;
|
|
};
|
|
|
|
_gunner
|