2023-02-14 04:01:51 +00:00
|
|
|
#include "script_component.hpp"
|
|
|
|
/*
|
|
|
|
* Author: PabstMirror
|
|
|
|
* Get the firemode index of the weapon for use with "SwitchWeapon"
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Unit <OBJECT>
|
2023-05-01 15:33:07 +00:00
|
|
|
* 1: Muzzle <STRING> (default: current weapon muzzle)
|
|
|
|
* 2: Firemode <STRING> (default: current weapon fire mode)
|
2023-02-14 04:01:51 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* Weapon/Mode index <NUMBER>
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [player] call ace_common_fnc_getFiremodeIndex
|
|
|
|
*
|
|
|
|
* Public: Yes
|
|
|
|
*/
|
|
|
|
|
|
|
|
params ["_unit"];
|
2023-05-01 15:33:07 +00:00
|
|
|
(weaponState _unit) params ["", "_currentMuzzle", "_currentFiremode"];
|
2023-02-14 04:01:51 +00:00
|
|
|
params ["", ["_muzzle", _currentMuzzle], ["_firemode", _currentFireMode]];
|
|
|
|
|
2023-05-01 15:33:07 +00:00
|
|
|
private _weapons = _unit weaponsInfo [_muzzle, false];
|
|
|
|
private _index = -1;
|
2023-02-14 04:01:51 +00:00
|
|
|
{
|
|
|
|
_x params ["_xIndex", "", "", "", "_xFiremode"];
|
2023-05-01 15:33:07 +00:00
|
|
|
if (_xFiremode == _firemode) exitWith { _index = _xIndex; };
|
2023-02-14 04:01:51 +00:00
|
|
|
} forEach _weapons;
|
|
|
|
|
|
|
|
_index
|