diff --git a/addons/frag/functions/fnc_addBlacklist.sqf b/addons/frag/functions/fnc_addBlacklist.sqf index aecdbf832d..3bbd93cdfc 100644 --- a/addons/frag/functions/fnc_addBlacklist.sqf +++ b/addons/frag/functions/fnc_addBlacklist.sqf @@ -19,3 +19,11 @@ params ["_projectile"]; TRACE_2("addBlackList",_projectile,typeOf projectile); _projectile setVariable [QGVAR(blacklisted)]; +_projectile removeEventHandler [ + "HitPart", + _projectile getVariable [QGVAR(hitPartEventHandler), -1] +]; +_projectile removeEventHandler [ + "Explode", + _projectile getVariable [QGVAR(explodeEventHandler), -1] +]; \ No newline at end of file diff --git a/addons/frag/functions/fnc_fired.sqf b/addons/frag/functions/fnc_fired.sqf index 5d9864d9c9..8077e95b62 100644 --- a/addons/frag/functions/fnc_fired.sqf +++ b/addons/frag/functions/fnc_fired.sqf @@ -24,15 +24,11 @@ if (_ammo isEqualTo "" || {isNull _projectile} || }; if (GVAR(spallEnabled) && {_ammo call FUNC(shouldSpall)}) then { - _projectile addEventHandler [ + private _hitPartEventHandler = _projectile addEventHandler [ "HitPart", { params ["_projectile", "_hitObject", "", "_posASL", "_velocity", "_surfNorm", "", "", "_surfType"]; - if (_projectile getVariable [QGVAR(blacklisted), false]) exitWith { - TRACE_2("projectile blackisted",typeOf _projectile,_projectile); - }; - // starting v2.18 it may be faster to use the instigator parameter, the same as the second entry shotParents, to recreate _shotParent // The "explode" EH does not get the same parameter private _shotParent = getShotParents _projectile; @@ -53,10 +49,11 @@ if (GVAR(spallEnabled) && {_ammo call FUNC(shouldSpall)}) then { ] call CBA_fnc_execNextFrame; } ]; + _projectile setVariable [QGVAR(hitPartEventHandler), _hitPartEventHandler]; }; if (GVAR(reflectionsEnabled) || GVAR(enabled) && _ammo call FUNC(shouldFrag)) then { - _projectile addEventHandler [ + private _explodeEventHandler = _projectile addEventHandler [ "Explode", { params ["_projectile", "_posASL", "_velocity"]; @@ -64,9 +61,6 @@ if (GVAR(reflectionsEnabled) || GVAR(enabled) && _ammo call FUNC(shouldFrag)) th if (GVAR(reflectionsEnabled)) then { [_posASL, _ammo] call FUNC(doReflections); }; - if (_projectile getVariable [QGVAR(blacklisted), false]) exitWith { - TRACE_2("projectile blackisted",typeOf _projectile,_projectile); - }; private _shotParents = getShotParents _projectile; private _ammo = typeOf _projectile; @@ -83,6 +77,7 @@ if (GVAR(reflectionsEnabled) || GVAR(enabled) && _ammo call FUNC(shouldFrag)) th ] call CBA_fnc_execNextFrame; } ]; + _projectile setVariable [QGVAR(explodeEventHandler), _explodeEventHandler]; }; #ifdef DEBUG_MODE_DRAW