2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2015-08-04 01:08:21 +00:00
|
|
|
/*
|
|
|
|
* Author: commy2
|
|
|
|
* Select weapon for unit in vehicle.
|
|
|
|
*
|
2015-08-08 12:40:23 +00:00
|
|
|
* Arguments:
|
2015-08-04 01:08:21 +00:00
|
|
|
* 0: Unit <OBJECT>
|
|
|
|
* 1: Vehicle <OBJECT>
|
|
|
|
* 2: Weapon index <NUMBER>
|
|
|
|
*
|
2015-08-08 12:40:23 +00:00
|
|
|
* Return Value:
|
2015-08-04 01:08:21 +00:00
|
|
|
* None
|
2015-08-08 12:40:23 +00:00
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [player, vehicle player, 1] call ace_weaponselect_fnc_selectWeaponVehicle
|
|
|
|
*
|
|
|
|
* Public: No
|
2015-08-04 01:08:21 +00:00
|
|
|
*/
|
2015-01-17 17:26:51 +00:00
|
|
|
|
2015-08-04 01:08:21 +00:00
|
|
|
params ["_unit", "_vehicle", "_index"];
|
2015-01-17 17:26:51 +00:00
|
|
|
|
2016-01-06 21:42:02 +00:00
|
|
|
private _turret = _unit call EFUNC(common,getTurretIndex);
|
2015-01-17 17:26:51 +00:00
|
|
|
|
|
|
|
if (_turret isEqualTo [] && {_unit == driver _vehicle}) then {
|
2016-01-06 21:42:02 +00:00
|
|
|
private _weapons = weapons _vehicle;
|
2015-01-17 17:26:51 +00:00
|
|
|
|
|
|
|
if (_index > count _weapons - 1) exitWith {};
|
|
|
|
|
2016-01-06 21:42:02 +00:00
|
|
|
private _weapon = _weapons select _index;
|
2015-01-17 17:26:51 +00:00
|
|
|
|
|
|
|
_index = 0;
|
2016-01-06 21:42:02 +00:00
|
|
|
|
2015-01-17 17:26:51 +00:00
|
|
|
while {
|
2017-05-12 18:12:39 +00:00
|
|
|
_index < 299 && {currentWeapon _vehicle != _weapon}
|
2015-01-17 17:26:51 +00:00
|
|
|
} do {
|
|
|
|
_unit action ["SwitchWeapon", _vehicle, _unit, _index];
|
|
|
|
_index = _index + 1;
|
|
|
|
};
|
|
|
|
} else {
|
2016-01-06 21:42:02 +00:00
|
|
|
private _weapons = _vehicle weaponsTurret _turret;
|
2015-01-17 17:26:51 +00:00
|
|
|
|
|
|
|
if (_index > count _weapons - 1) exitWith {};
|
|
|
|
|
2016-01-06 21:42:02 +00:00
|
|
|
private _weapon = _weapons select _index;
|
2015-01-17 17:26:51 +00:00
|
|
|
|
|
|
|
_index = 0;
|
2016-01-06 21:42:02 +00:00
|
|
|
|
2015-01-17 17:26:51 +00:00
|
|
|
while {
|
2017-05-12 18:12:39 +00:00
|
|
|
_index < 299 && {_vehicle currentWeaponTurret _turret != _weapon}
|
2015-01-17 17:26:51 +00:00
|
|
|
} do {
|
|
|
|
_unit action ["SwitchWeapon", _vehicle, _unit, _index];
|
|
|
|
_index = _index + 1;
|
|
|
|
};
|
|
|
|
};
|