2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2015-02-04 02:20:55 +00:00
|
|
|
/*
|
|
|
|
* Author: commy2
|
2015-09-20 21:18:51 +00:00
|
|
|
* Returns gunner using specified weapon type in vehicle. Only works if all turrets have different weapons.
|
2015-02-04 02:20:55 +00:00
|
|
|
*
|
2015-09-20 21:18:51 +00:00
|
|
|
* Arguments:
|
|
|
|
* 0: Vehicle <OBJECT>
|
|
|
|
* 1: Weapon <STRING>
|
2015-02-04 02:20:55 +00:00
|
|
|
*
|
2015-09-20 21:18:51 +00:00
|
|
|
* Return Value:
|
|
|
|
* Gunner <OBJECT>
|
2015-02-04 02:20:55 +00:00
|
|
|
*
|
2017-06-08 13:31:51 +00:00
|
|
|
* Example:
|
|
|
|
* [car, "gun"] call ace_common_fnc_getGunner
|
|
|
|
*
|
2015-09-20 21:18:51 +00:00
|
|
|
* Public: Yes
|
2015-02-04 02:20:55 +00:00
|
|
|
*/
|
|
|
|
|
2015-12-12 15:48:54 +00:00
|
|
|
params [["_vehicle", objNull, [objNull]], ["_weapon", "", [""]]];
|
2015-02-04 02:20:55 +00:00
|
|
|
|
2015-04-10 04:36:09 +00:00
|
|
|
// on foot
|
2024-03-07 21:08:13 +00:00
|
|
|
if (gunner _vehicle == _vehicle && {_weapon in weapons _vehicle || {toLowerANSI _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-12-12 15:48:54 +00:00
|
|
|
private _gunner = objNull;
|
2015-02-04 02:20:55 +00:00
|
|
|
|
|
|
|
{
|
2015-02-19 18:14:52 +00:00
|
|
|
if (_weapon in (_vehicle weaponsTurret _x)) exitWith {
|
|
|
|
_gunner = _vehicle turretUnit _x;
|
|
|
|
};
|
2024-04-04 11:15:26 +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 {
|
2016-02-13 18:04:43 +00:00
|
|
|
_gunner = effectiveCommander _vehicle;
|
2015-04-10 04:36:09 +00:00
|
|
|
};
|
|
|
|
|
2015-09-20 21:18:51 +00:00
|
|
|
_gunner
|