Exposed projectile event handlers for both blacklist use and other shenanigans.

This commit is contained in:
lambdatiger 2024-05-19 00:15:05 -05:00
parent b9aa3cb65b
commit eaff498f3f
2 changed files with 9 additions and 10 deletions

View File

@ -19,3 +19,5 @@ params ["_projectile"];
TRACE_1("addBlackList",_projectile);
_projectile setVariable [QGVAR(blacklisted), true, true];
_projectile removeEventHandler ["HitPart", _projectile getVariable [QGVAR(hitPartEH), -1]];
_projectile removeEventHandler ["Explode", _projectile getVariable [QGVAR(explodeEH), -1]];

View File

@ -21,20 +21,17 @@ if (!isServer) exitWith {};
params ["_projectile"];
private _ammo = typeOf _projectile;
if (_ammo isEqualTo "" || {isNull _projectile}) exitWith {
TRACE_2("bad ammo or projectile",_ammo,_projectile);
if (_ammo isEqualTo "" || {isNull _projectile}
|| {_projectile getVariable [QGVAR(blacklisted), false]}) exitWith {
TRACE_2("bad ammo or projectile, or blackList",_ammo,_projectile);
};
if (_projectile getVariable [QGVAR(blacklisted), false]) exitWith {};
if (GVAR(enabled) && {_ammo call FUNC(shouldFrag)}) then {
_projectile addEventHandler [
private _explodeEH = _projectile addEventHandler [
"Explode",
{
params ["_projectile", "_posASL", "_velocity"];
if (_projectile getVariable [QGVAR(blacklisted), false]) exitWith {};
private _shotParents = _projectile getVariable [QGVAR(shotParent), getShotParents _projectile];
private _ammo = typeOf _projectile;
// wait for frag damage to kill units before spawning fragments
@ -47,16 +44,15 @@ if (GVAR(enabled) && {_ammo call FUNC(shouldFrag)}) then {
};
}
];
_projectile setVariable [QGVAR(explodeEH), _explodeEH];
};
if (GVAR(spallEnabled) && {_ammo call FUNC(shouldSpall)}) then {
_projectile addEventHandler [
private _hitPartEH = _projectile addEventHandler [
"HitPart",
{
params ["_projectile", "_hitObject", "", "_posASL", "_velocity", "_surfNorm", "", "", "_surfType"];
if (_projectile getVariable [QGVAR(blacklisted), false]) exitWith {};
// 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;
@ -72,6 +68,7 @@ if (GVAR(spallEnabled) && {_ammo call FUNC(shouldSpall)}) then {
] call CBA_fnc_execNextFrame;
}
];
_projectile setVariable [QGVAR(hitPartEH), _hitPartEH];
};
#ifdef DEBUG_MODE_DRAW
if (GVAR(debugOptions) && {_ammo call FUNC(shouldFrag) || {_ammo call FUNC(shouldSpall)}}) then {