2015-02-04 02:20:55 +00:00
|
|
|
/*
|
|
|
|
* Author: commy2
|
|
|
|
*
|
2015-02-11 13:51:21 +00:00
|
|
|
* Get the gunner of a vehicle who uses the given weapon type. Requires every turret to have a different weapon.
|
2015-02-04 02:20:55 +00:00
|
|
|
*
|
|
|
|
* Argument:
|
|
|
|
* 0: The vehicle (Object)
|
|
|
|
* 1: weapon of the vehicle (String)
|
|
|
|
*
|
|
|
|
* Return value:
|
|
|
|
* The turret gunner with this weapon (Object)
|
|
|
|
*/
|
|
|
|
|
|
|
|
private ["_vehicle", "_weapon"];
|
|
|
|
|
|
|
|
_vehicle = _this select 0;
|
|
|
|
_weapon = _this select 1;
|
|
|
|
|
2015-04-10 04:36:09 +00:00
|
|
|
// on foot
|
2015-04-10 04:47:31 +00:00
|
|
|
if (gunner _vehicle == _vehicle && {_weapon in weapons _vehicle || {toLower _weapon in ["throw", "put"]}}) exitWith {gunner _vehicle};
|
2015-04-02 11:52:22 +00:00
|
|
|
|
2015-04-10 04:36:09 +00:00
|
|
|
// inside vehicle
|
2015-02-04 02:20:55 +00:00
|
|
|
private "_gunner";
|
|
|
|
_gunner = objNull;
|
|
|
|
|
|
|
|
{
|
2015-02-19 18:14:52 +00:00
|
|
|
if (_weapon in (_vehicle weaponsTurret _x)) exitWith {
|
|
|
|
_gunner = _vehicle turretUnit _x;
|
|
|
|
};
|
2015-04-02 11:52:22 +00:00
|
|
|
} forEach allTurrets [_vehicle, true];
|
2015-02-04 02:20:55 +00:00
|
|
|
|
2015-04-10 04:36:09 +00:00
|
|
|
// ensure that at least the pilot is returned if there is no gunner
|
|
|
|
if (isManualFire _vehicle && {isNull _gunner}) then {
|
2015-05-14 18:06:06 +00:00
|
|
|
_gunner = driver _vehicle;
|
2015-04-10 04:36:09 +00:00
|
|
|
};
|
|
|
|
|
2015-05-14 18:06:06 +00:00
|
|
|
_gunner
|