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>
55 lines
1.6 KiB
Plaintext
55 lines
1.6 KiB
Plaintext
#include "..\script_component.hpp"
|
|
/*
|
|
* Author: commy2, johnb43
|
|
* Takes the weapon safety lock off.
|
|
*
|
|
* Arguments:
|
|
* 0: Unit <OBJECT>
|
|
* 1: Weapon <STRING>
|
|
* 2: Muzzle <STRING>
|
|
* 3: Show hint <BOOL> (default: true)
|
|
*
|
|
* Return Value:
|
|
* None
|
|
*
|
|
* Example:
|
|
* [ACE_player, currentWeapon ACE_player, currentMuzzle ACE_player] call ace_safemode_fnc_unlockSafety
|
|
*
|
|
* Public: No
|
|
*/
|
|
|
|
params ["_unit", "_weapon", "_muzzle", ["_hint", true]];
|
|
|
|
private _safedWeaponMuzzles = (_unit getVariable QGVAR(safedWeapons)) get _weapon;
|
|
private _firemode = _safedWeaponMuzzles deleteAt _muzzle;
|
|
|
|
// Remove action if all weapons have removed their safeties
|
|
if (_safedWeaponMuzzles isEqualTo createHashMap) then {
|
|
(_unit getVariable QGVAR(safedWeapons)) deleteAt _weapon;
|
|
|
|
private _ehID = _unit getVariable QGVAR(actionID);
|
|
|
|
if (!isNil "_ehID" && {(_unit getVariable QGVAR(safedWeapons)) isEqualTo createHashMap}) then {
|
|
[_unit, "DefaultAction", _ehID] call EFUNC(common,removeActionEventHandler);
|
|
|
|
_unit setVariable [QGVAR(actionID), nil];
|
|
};
|
|
};
|
|
|
|
// Let engine handle switching to next firemode/muzzle
|
|
if (inputAction "nextWeapon" == 0 && {inputAction "prevWeapon" == 0}) then {
|
|
// This syntax of selectWeapon doesn't mess with gun lights and lasers
|
|
_unit selectWeapon [_weapon, _muzzle, _firemode];
|
|
|
|
// Play fire mode selector sound
|
|
[_unit, _weapon, _muzzle] call FUNC(playChangeFiremodeSound);
|
|
};
|
|
|
|
// Player HUD
|
|
true call FUNC(setSafeModeVisual);
|
|
|
|
// Show info box unless disabled
|
|
if (_hint) then {
|
|
[LLSTRING(TookOffSafety), getText (configFile >> "CfgWeapons" >> _weapon >> "picture")] call EFUNC(common,displayTextPicture);
|
|
};
|