mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
6a25e9365a
* Refactor safemode * Further improvements and fixes * Update XEH_postInit.sqf * Don't allow binoculars to be set to safe * Add API for getting weapon safety status * Update fnc_jamWeapon.sqf * Added doc * Update fnc_playChangeFiremodeSound.sqf * Update addons/overheating/functions/fnc_jamWeapon.sqf Co-authored-by: PabstMirror <pabstmirror@gmail.com> * Update addons/weaponselect/functions/fnc_selectWeaponMode.sqf Co-authored-by: PabstMirror <pabstmirror@gmail.com> --------- Co-authored-by: PabstMirror <pabstmirror@gmail.com>
41 lines
1.2 KiB
Plaintext
41 lines
1.2 KiB
Plaintext
#include "..\script_component.hpp"
|
|
/*
|
|
* Author: commy2
|
|
* The player will select the specified weapon or will change to the next firing mode if the weapon was already selected.
|
|
*
|
|
* Arguments:
|
|
* 0: Unit <OBJECT>
|
|
* 1: Weapon <STRING>
|
|
*
|
|
* Return Value:
|
|
* None
|
|
*
|
|
* Example:
|
|
* [player, currentWeapon player] call ace_weaponselect_fnc_selectWeaponMode
|
|
*
|
|
* Public: No
|
|
*/
|
|
|
|
params ["_unit", "_weapon"];
|
|
|
|
if (_weapon == "" || {!(_unit hasWeapon _weapon)}) exitWith {};
|
|
|
|
private _currentWeaponMode = (_unit weaponState _weapon) select 2;
|
|
private _muzzle = (_weapon call EFUNC(common,getWeaponMuzzles)) select 0;
|
|
|
|
if (currentWeapon _unit != _weapon) exitWith {
|
|
_unit selectWeapon [_weapon, _muzzle, _currentWeaponMode];
|
|
};
|
|
|
|
// Unlock safety
|
|
if ((["ace_safemode"] call EFUNC(common,isModLoaded)) && {[_unit, _weapon] call EFUNC(safemode,getWeaponSafety)}) exitWith {
|
|
[_unit, _weapon, false] call EFUNC(safemode,setWeaponSafety);
|
|
};
|
|
|
|
private _modes = _weapon call EFUNC(common,getWeaponModes);
|
|
|
|
_unit selectWeapon [_weapon, _muzzle, _modes select (((_modes find _currentWeaponMode) + 1) % (count _modes))];
|
|
|
|
// Play fire mode selector sound
|
|
[_unit, _weapon] call FUNC(playChangeFiremodeSound);
|