Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Safemode - add public setWeaponSafety function #7092

Merged
merged 14 commits into from
Oct 8, 2019
Merged
1 change: 1 addition & 0 deletions addons/safemode/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ PREP(lockSafety);
PREP(playChangeFiremodeSound);
PREP(setSafeModeVisual);
PREP(unlockSafety);
PREP(setWeaponSafety);
36 changes: 36 additions & 0 deletions addons/safemode/functions/fnc_setWeaponSafety.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include "script_component.hpp"
/*
* Author: Brostrom.A
* Safe or unsafe the given weapon based on weapon state; locked or unlocked.
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Weapon <STRING>
* 2: State <BOOL>
*
* Return Value:
* None
*
* Example:
* [ACE_player, currentWeapon ACE_player, true] call ace_safemode_fnc_setWeaponSafety
*
* Public: Yes
*/

params [
["_unit", objNull, [objNull]],
["_weapon", "", [""]],
["_state", true, [true]]
];

AndreasBrostrom marked this conversation as resolved.
Show resolved Hide resolved
if (_weapon == "") exitWith {};

private _safedWeapons = _unit getVariable [QGVAR(safedWeapons), []];

_weapon = configName (configFile >> "CfgWeapons" >> _weapon);

private _muzzle = currentMuzzle _unit;

if !(_state isEqualTo (_weapon in _safedWeapons)) then {
[_unit, _weapon, _muzzle] call FUNC(lockSafety);
};