mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
e2ac18a05d
* advanced_ballistics * advanced_fatigue * advanced_throwing * ai * aircraft * arsenal * atragmx * attach * backpacks * ballistics * captives * cargo * chemlights * common * concertina_wire * cookoff * dagr * disarming * disposable * dogtags * dragging * explosives * fastroping * fcs * finger * frag * gestures * gforces * goggles * grenades * gunbag * hearing * hitreactions * huntir * interact_menu * interaction * inventory * kestrel4500 * laser * laserpointer * logistics_uavbattery * logistics_wirecutter * magazinerepack * map * map_gestures * maptools * markers * medical * medical_ai * medical_blood * medical_menu * microdagr * minedetector * missileguidance * missionmodules * mk6mortar * modules * movement * nametags * nightvision * nlaw * optics * optionsmenu * overheating * overpressure * parachute * pylons * quickmount * rangecard * rearm * recoil * refuel * reload * reloadlaunchers * repair * respawn * safemode * sandbag * scopes * slideshow * spectator * spottingscope * switchunits * tacticalladder * tagging * trenches * tripod * ui * vector * vehiclelock * vehicles * viewdistance * weaponselect * weather * winddeflection * yardage450 * zeus * arsenal defines.hpp * optionals * DEBUG_MODE_FULL 1 * DEBUG_MODE_FULL 2 * Manual fixes * Add SQF Validator check for #include after block comment * explosives fnc_openTimerUI * fix uniqueItems
72 lines
2.1 KiB
Plaintext
72 lines
2.1 KiB
Plaintext
#include "script_component.hpp"
|
|
/*
|
|
* Author: commy2
|
|
* Put weapon on safety, or take it off safety if safety is already put on.
|
|
*
|
|
* Arguments:
|
|
* 0: Unit <OBJECT>
|
|
* 1: Weapon <STRING>
|
|
* 2: Muzzle <STRING>
|
|
*
|
|
* Return Value:
|
|
* None
|
|
*
|
|
* Example:
|
|
* [ACE_player, currentWeapon ACE_player, currentMuzzle ACE_player] call ace_safemode_fnc_lockSafety
|
|
*
|
|
* Public: No
|
|
*/
|
|
|
|
// don't immediately switch back
|
|
if (inputAction "nextWeapon" > 0) exitWith {};
|
|
|
|
params ["_unit", "_weapon", "_muzzle"];
|
|
|
|
private _safedWeapons = _unit getVariable [QGVAR(safedWeapons), []];
|
|
|
|
if (_weapon in _safedWeapons) exitWith {
|
|
_this call FUNC(unlockSafety);
|
|
};
|
|
|
|
_safedWeapons pushBack _weapon;
|
|
|
|
_unit setVariable [QGVAR(safedWeapons), _safedWeapons];
|
|
|
|
if (_unit getVariable [QGVAR(actionID), -1] == -1) then {
|
|
_unit setVariable [QGVAR(actionID), [
|
|
_unit, "DefaultAction", {
|
|
if (
|
|
[_this select 1] call CBA_fnc_canUseWeapon
|
|
&& {
|
|
if (currentMuzzle (_this select 1) in ((_this select 1) getVariable [QGVAR(safedWeapons), []])) then {
|
|
if (inputAction "nextWeapon" > 0) exitWith {
|
|
[_this select 1, currentWeapon (_this select 1), currentMuzzle (_this select 1)] call FUNC(unlockSafety);
|
|
false
|
|
};
|
|
true
|
|
} else {false}
|
|
}
|
|
) then {
|
|
// player hud
|
|
[false] call FUNC(setSafeModeVisual);
|
|
true
|
|
} else {
|
|
// player hud
|
|
[true] call FUNC(setSafeModeVisual);
|
|
false
|
|
};
|
|
}, {}
|
|
] call EFUNC(common,addActionEventHandler)];
|
|
};
|
|
|
|
if (_muzzle isEqualType "") then {
|
|
_unit selectWeapon _muzzle;
|
|
};
|
|
|
|
// play fire mode selector sound
|
|
[_unit, _weapon, _muzzle] call FUNC(playChangeFiremodeSound);
|
|
|
|
// show info box
|
|
private _picture = getText (configFile >> "CfgWeapons" >> _weapon >> "picture");
|
|
[localize LSTRING(PutOnSafety), _picture] call EFUNC(common,displayTextPicture);
|