2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2015-01-17 17:26:51 +00:00
|
|
|
/*
|
|
|
|
* Author: commy2
|
|
|
|
* The player will select the specified weapon or will change to the next firing mode if the weapon was already selected.
|
|
|
|
*
|
2015-08-08 12:40:23 +00:00
|
|
|
* Arguments:
|
2015-08-04 01:08:21 +00:00
|
|
|
* 0: Unit <OBJECT>
|
|
|
|
* 1: Weapon <STRING>
|
2015-01-17 17:26:51 +00:00
|
|
|
*
|
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, currentWeapon player] call ace_weaponselect_fnc_selectWeaponMode
|
|
|
|
*
|
|
|
|
* Public: No
|
2015-01-17 17:26:51 +00:00
|
|
|
*/
|
|
|
|
|
2015-08-04 01:08:21 +00:00
|
|
|
params ["_unit", "_weapon"];
|
2015-01-17 17:26:51 +00:00
|
|
|
|
2024-07-20 06:13:42 +00:00
|
|
|
if (_weapon == "" || {!(_unit hasWeapon _weapon)}) exitWith {};
|
|
|
|
|
|
|
|
private _currentWeaponMode = (_unit weaponState _weapon) select 2;
|
|
|
|
private _muzzle = (_weapon call EFUNC(common,getWeaponMuzzles)) select 0;
|
2015-01-17 17:26:51 +00:00
|
|
|
|
|
|
|
if (currentWeapon _unit != _weapon) exitWith {
|
2024-07-20 06:13:42 +00:00
|
|
|
_unit selectWeapon [_weapon, _muzzle, _currentWeaponMode];
|
2015-01-17 17:26:51 +00:00
|
|
|
};
|
|
|
|
|
2024-07-20 06:13:42 +00:00
|
|
|
// Unlock safety
|
2024-08-02 11:59:18 +00:00
|
|
|
if ((["ace_safemode"] call EFUNC(common,isModLoaded)) && {[_unit, _weapon] call EFUNC(safemode,getWeaponSafety)}) exitWith {
|
|
|
|
[_unit, _weapon, false] call EFUNC(safemode,setWeaponSafety);
|
2015-01-17 17:26:51 +00:00
|
|
|
};
|
|
|
|
|
2024-07-20 06:13:42 +00:00
|
|
|
private _modes = _weapon call EFUNC(common,getWeaponModes);
|
2015-01-17 17:26:51 +00:00
|
|
|
|
2024-07-20 06:13:42 +00:00
|
|
|
_unit selectWeapon [_weapon, _muzzle, _modes select (((_modes find _currentWeaponMode) + 1) % (count _modes))];
|
2015-01-17 17:26:51 +00:00
|
|
|
|
2024-07-20 06:13:42 +00:00
|
|
|
// Play fire mode selector sound
|
2015-01-17 17:26:51 +00:00
|
|
|
[_unit, _weapon] call FUNC(playChangeFiremodeSound);
|