Skip to content

Commit

Permalink
Grenades - Make flashbang reaction more authentic (#6034)
Browse files Browse the repository at this point in the history
  • Loading branch information
BaerMitUmlaut authored Feb 22, 2020
1 parent af777a4 commit 3bc727f
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions addons/grenades/functions/fnc_flashbangExplosionEH.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,17 @@ private _affected = (ASLtoAGL _grenadePosASL) nearEntities ["CAManBase", 20];
_affected = _affected - [ACE_player];
{
if (local _x && {alive _x}) then {
private _strength = 1 - (((getPosASL _x) vectorDistance _grenadePosASL) min 20) / 20;
private _strength = 1 - (((eyePos _x) vectorDistance _grenadePosASL) min 20) / 20;

TRACE_3("FlashBangEffect Start",_x,((getPosASL _x) vectorDistance _grenadePosASL),_strength);

[_x, true] call EFUNC(common,disableAI);

_x setSkill (skill _x / 50);

if (_strength > 0.2) then {
_x setVectorDir ((getPosASL _x) vectorDiff _grenadePosASL);
};
// Make AI try to look away
private _dirToFlash = _x getDir _grenadePosASL;
_x setDir (_dirToFlash + linearConversion [0.2, 1, _strength, 40, 135] * selectRandom [-1, 1]);

[{
params ["_unit"];
Expand Down Expand Up @@ -140,8 +140,11 @@ if (hasInterface && {!isNull ACE_player} && {alive ACE_player}) then {
}, [], 17 * _strength] call CBA_fnc_waitAndExecute;
};

if (_strength > 0.2) then {
ACE_player setVectorDir (_eyePos vectorDiff _grenadePosASL);
};
// Make player flinch
if (_strength <= 0.2) exitWith {};
private _minFlinch = linearConversion [0.2, 1, _strength, 0, 60, true];
private _maxFlinch = linearConversion [0.2, 1, _strength, 0, 95, true];
private _flinch = (_minFlinch + random (_maxFlinch - _minFlinch)) * selectRandom [-1, 1];
ACE_player setDir (getDir ACE_player + _flinch);
};
true

0 comments on commit 3bc727f

Please sign in to comment.