2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2015-08-08 00:26:09 +00:00
|
|
|
/*
|
2024-08-02 11:59:18 +00:00
|
|
|
* Author: commy2, johnb43
|
|
|
|
* Takes the weapon safety lock off.
|
2015-08-08 00:26:09 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Unit <OBJECT>
|
|
|
|
* 1: Weapon <STRING>
|
|
|
|
* 2: Muzzle <STRING>
|
2024-08-02 11:59:18 +00:00
|
|
|
* 3: Show hint <BOOL> (default: true)
|
2015-08-08 00:26:09 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [ACE_player, currentWeapon ACE_player, currentMuzzle ACE_player] call ace_safemode_fnc_unlockSafety
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2024-08-02 11:59:18 +00:00
|
|
|
params ["_unit", "_weapon", "_muzzle", ["_hint", true]];
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2024-08-02 11:59:18 +00:00
|
|
|
private _safedWeaponMuzzles = (_unit getVariable QGVAR(safedWeapons)) get _weapon;
|
|
|
|
private _firemode = _safedWeaponMuzzles deleteAt _muzzle;
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2024-08-02 11:59:18 +00:00
|
|
|
// Remove action if all weapons have removed their safeties
|
|
|
|
if (_safedWeaponMuzzles isEqualTo createHashMap) then {
|
|
|
|
(_unit getVariable QGVAR(safedWeapons)) deleteAt _weapon;
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2024-08-02 11:59:18 +00:00
|
|
|
private _ehID = _unit getVariable QGVAR(actionID);
|
2019-03-12 16:26:20 +00:00
|
|
|
|
2024-08-02 11:59:18 +00:00
|
|
|
if (!isNil "_ehID" && {(_unit getVariable QGVAR(safedWeapons)) isEqualTo createHashMap}) then {
|
|
|
|
[_unit, "DefaultAction", _ehID] call EFUNC(common,removeActionEventHandler);
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2024-08-02 11:59:18 +00:00
|
|
|
_unit setVariable [QGVAR(actionID), nil];
|
|
|
|
};
|
2019-03-12 16:26:20 +00:00
|
|
|
};
|
|
|
|
|
2024-08-02 11:59:18 +00:00
|
|
|
// 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];
|
2015-05-15 13:41:41 +00:00
|
|
|
|
2024-08-02 11:59:18 +00:00
|
|
|
// Play fire mode selector sound
|
2015-05-15 13:41:41 +00:00
|
|
|
[_unit, _weapon, _muzzle] call FUNC(playChangeFiremodeSound);
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|
|
|
|
|
2024-08-02 11:59:18 +00:00
|
|
|
// Player HUD
|
|
|
|
true call FUNC(setSafeModeVisual);
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2024-08-02 11:59:18 +00:00
|
|
|
// Show info box unless disabled
|
2022-12-03 19:57:16 +00:00
|
|
|
if (_hint) then {
|
2024-08-02 11:59:18 +00:00
|
|
|
[LLSTRING(TookOffSafety), getText (configFile >> "CfgWeapons" >> _weapon >> "picture")] call EFUNC(common,displayTextPicture);
|
2022-12-03 19:57:16 +00:00
|
|
|
};
|