ACE3/addons/weaponselect/functions/fnc_selectWeaponVehicle.sqf

55 lines
1.2 KiB
Plaintext
Raw Normal View History

#include "..\script_component.hpp"
/*
* Author: commy2
* Select weapon for unit in vehicle.
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Vehicle <OBJECT>
* 2: Weapon index <NUMBER>
*
* Return Value:
* None
*
* Example:
* [player, vehicle player, 1] call ace_weaponselect_fnc_selectWeaponVehicle
*
* Public: No
*/
2015-01-17 17:26:51 +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 {
_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 {
_index < 299 && {_vehicle currentWeaponTurret _turret != _weapon}
2015-01-17 17:26:51 +00:00
} do {
_unit action ["SwitchWeapon", _vehicle, _unit, _index];
_index = _index + 1;
};
};