diff --git a/addons/frag/XEH_postInit.sqf b/addons/frag/XEH_postInit.sqf index 47affc9971..2861792f6a 100644 --- a/addons/frag/XEH_postInit.sqf +++ b/addons/frag/XEH_postInit.sqf @@ -3,6 +3,39 @@ [ "CBA_settingsInitialized", { + + [{ + params ["_projectile", "_posASL"]; + + if (_projectile getVariable [QGVAR(blacklisted), false]) exitWith {}; + + if (GVAR(reflectionsEnabled)) then { + [_posASL, _ammo] call FUNC(doReflections); + }; + + private _ammo = typeOf _projectile; + if !(_ammo call FUNC(shouldFrag)) exitWith {}; + private _shotParents = getShotParents _projectile; + + // only let a unit make a frag event once per second + private _instigator = _shotParents#1; + if (CBA_missionTime < (_instigator getVariable [QGVAR(nextFragEvent), -1])) exitWith {}; + _instigator setVariable [QGVAR(nextFragEvent), CBA_missionTime + ACE_FRAG_FRAG_UNIT_HOLDOFF]; + + // Wait a frame to make sure it doesn't target the dead + [ + { [QGVAR(frag_eh), _this] call CBA_fnc_serverEvent; }, + [_posASL, _ammo, [objNull, _instigator]] + ] call CBA_fnc_execNextFrame; + + }] call EFUNC(common,addExplosionEventHandler); + + + +#ifndef DEBUG_MODE_DRAW + if (GVAR(spallEnabled)) exitWith {}; +#endif + ["ace_firedPlayer", LINKFUNC(fired)] call CBA_fnc_addEventHandler; ["ace_firedNonPlayer", LINKFUNC(fired)] call CBA_fnc_addEventHandler; ["ace_firedPlayerVehicle", LINKFUNC(fired)] call CBA_fnc_addEventHandler; diff --git a/addons/frag/functions/fnc_addBlacklist.sqf b/addons/frag/functions/fnc_addBlacklist.sqf index cb7c28e77c..ad8c30946f 100644 --- a/addons/frag/functions/fnc_addBlacklist.sqf +++ b/addons/frag/functions/fnc_addBlacklist.sqf @@ -19,11 +19,3 @@ params ["_projectile"]; TRACE_2("addBlackList",_projectile,typeOf projectile); _projectile setVariable [QGVAR(blacklisted), true]; -_projectile removeEventHandler [ - "HitPart", - _projectile getVariable [QGVAR(hitPartEventHandler), -1] -]; -_projectile removeEventHandler [ - "Explode", - _projectile getVariable [QGVAR(explodeEventHandler), -1] -]; diff --git a/addons/frag/functions/fnc_fired.sqf b/addons/frag/functions/fnc_fired.sqf index 10a9da223e..d6fd1c8df7 100644 --- a/addons/frag/functions/fnc_fired.sqf +++ b/addons/frag/functions/fnc_fired.sqf @@ -53,34 +53,6 @@ if (GVAR(spallEnabled) && {_ammo call FUNC(shouldSpall)}) then { _projectile setVariable [QGVAR(hitPartEventHandler), _hitPartEventHandler]; }; -if (GVAR(reflectionsEnabled) || (GVAR(enabled) && {_ammo call FUNC(shouldFrag)})) then { - private _explodeEventHandler = _projectile addEventHandler [ - "Explode", - { - params ["_projectile", "_posASL"]; - - if (GVAR(reflectionsEnabled)) then { - [_posASL, _ammo] call FUNC(doReflections); - }; - - private _shotParents = getShotParents _projectile; - private _ammo = typeOf _projectile; - - // only let a unit make a frag event once per second - private _instigator = _shotParents#1; - if (CBA_missionTime < (_instigator getVariable [QGVAR(nextFragEvent), -1])) exitWith {}; - _instigator setVariable [QGVAR(nextFragEvent), CBA_missionTime + ACE_FRAG_FRAG_UNIT_HOLDOFF]; - - // Wait a frame to make sure it doesn't target the dead - [ - { [QGVAR(frag_eh), _this] call CBA_fnc_serverEvent; }, - [_posASL, _ammo, [objNull, _instigator]] - ] call CBA_fnc_execNextFrame; - } - ]; - _projectile setVariable [QGVAR(explodeEventHandler), _explodeEventHandler]; -}; - #ifdef DEBUG_MODE_DRAW if (GVAR(debugOptions) && {_ammo call FUNC(shouldFrag) || {_ammo call FUNC(shouldSpall)}}) then { [_projectile, "red", true] call FUNC(dev_trackObj);