made addBlackList remove projectile EHs

This commit is contained in:
lambdatiger 2024-07-18 18:55:19 -05:00
parent 20b1ab7e64
commit a20274a2c2
2 changed files with 12 additions and 9 deletions

View File

@ -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]
];

View File

@ -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