diff --git a/addons/grenades/functions/fnc_flashbangExplosionEH.sqf b/addons/grenades/functions/fnc_flashbangExplosionEH.sqf index 07b74b7bcc..29bb46db8a 100644 --- a/addons/grenades/functions/fnc_flashbangExplosionEH.sqf +++ b/addons/grenades/functions/fnc_flashbangExplosionEH.sqf @@ -47,28 +47,42 @@ private _affected = (ASLtoAGL _grenadePosASL) nearEntities ["CAManBase", 20]; _affected = _affected - [ACE_player]; { if (local _x && {alive _x}) then { - private _strength = 1 - (((eyePos _x) vectorDistance _grenadePosASL) min 20) / 20; + private _unit = _x; + private _strength = 1 - (((eyePos _unit) vectorDistance _grenadePosASL) min 20) / 20; - TRACE_3("FlashBangEffect Start",_x,((getPosASL _x) vectorDistance _grenadePosASL),_strength); + TRACE_3("FlashBangEffect Start",_unit,((getPosASL _unit) vectorDistance _grenadePosASL),_strength); - [_x, true] call EFUNC(common,disableAI); - - _x setSkill (skill _x / 50); + [_unit, true] call EFUNC(common,disableAI); // Make AI try to look away - private _dirToFlash = _x getDir _grenadePosASL; - _x setDir (_dirToFlash + linearConversion [0.2, 1, _strength, 40, 135] * selectRandom [-1, 1]); + private _dirToFlash = _unit getDir _grenadePosASL; + _unit setDir (_dirToFlash + linearConversion [0.2, 1, _strength, 40, 135] * selectRandom [-1, 1]); - [{ - params ["_unit"]; + private _flashReactionDebounce = _unit getVariable [QGVAR(flashReactionDebounce), 0]; + _unit setVariable [QGVAR(flashReactionDebounce), _flashReactionDebounce max (CBA_missionTime + (7 * _strength))]; + if (_flashReactionDebounce < CBA_missionTime) then { + // Not used interally but could be useful for other mods + _unit setVariable [QGVAR(flashStrength), _strength, true]; + { + _unit setSkill [_x, (_unit skill _x) / 50]; + } forEach SUBSKILLS; + [{ + params ["_unit"]; + CBA_missiontime >= _unit getVariable [QGVAR(flashReactionDebounce), 0] + },{ + params ["_unit"]; - //Make sure we don't enable AI for unconscious units - if !(_unit getVariable ["ace_isUnconscious", false]) then { - [_unit, false] call EFUNC(common,disableAI); - }; + _unit setVariable [QGVAR(flashStrength), 0, true]; - _unit setSkill (skill _unit * 50); - }, [_x], 7 * _strength] call CBA_fnc_waitAndExecute; + // Make sure we don't enable AI for unconscious units + if !(_unit getVariable ["ace_isUnconscious", false]) then { + [_unit, false] call EFUNC(common,disableAI); + }; + { + _unit setSkill [_x, (_unit skill _x) * 50]; + } forEach SUBSKILLS; + }, [_unit]] call CBA_fnc_waitUntilAndExecute; + }; }; } count _affected; diff --git a/addons/main/script_macros.hpp b/addons/main/script_macros.hpp index 58ae338aae..cc02c06b94 100644 --- a/addons/main/script_macros.hpp +++ b/addons/main/script_macros.hpp @@ -147,4 +147,6 @@ #define ZEUS_ACTION_CONDITION ([_target, {QUOTE(QUOTE(ADDON)) in curatorAddons _this}, missionNamespace, QUOTE(QGVAR(zeusCheck)), 1E11, 'ace_interactMenuClosed'] call EFUNC(common,cachedCall)) +#define SUBSKILLS ["aimingAccuracy", "aimingShake", "aimingSpeed", "spotDistance", "spotTime", "courage", "reloadSpeed", "commanding", "general"] + #include "script_debug.hpp"