use common addExplosionEventHandler

move from firedEH to use common's explode event
This commit is contained in:
PabstMirror 2024-08-22 13:54:42 -05:00
parent 06b3aa25eb
commit 0642d3724d
3 changed files with 33 additions and 36 deletions

View File

@ -3,6 +3,39 @@
[ [
"CBA_settingsInitialized", "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_firedPlayer", LINKFUNC(fired)] call CBA_fnc_addEventHandler;
["ace_firedNonPlayer", LINKFUNC(fired)] call CBA_fnc_addEventHandler; ["ace_firedNonPlayer", LINKFUNC(fired)] call CBA_fnc_addEventHandler;
["ace_firedPlayerVehicle", LINKFUNC(fired)] call CBA_fnc_addEventHandler; ["ace_firedPlayerVehicle", LINKFUNC(fired)] call CBA_fnc_addEventHandler;

View File

@ -19,11 +19,3 @@ params ["_projectile"];
TRACE_2("addBlackList",_projectile,typeOf projectile); TRACE_2("addBlackList",_projectile,typeOf projectile);
_projectile setVariable [QGVAR(blacklisted), true]; _projectile setVariable [QGVAR(blacklisted), true];
_projectile removeEventHandler [
"HitPart",
_projectile getVariable [QGVAR(hitPartEventHandler), -1]
];
_projectile removeEventHandler [
"Explode",
_projectile getVariable [QGVAR(explodeEventHandler), -1]
];

View File

@ -53,34 +53,6 @@ if (GVAR(spallEnabled) && {_ammo call FUNC(shouldSpall)}) then {
_projectile setVariable [QGVAR(hitPartEventHandler), _hitPartEventHandler]; _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 #ifdef DEBUG_MODE_DRAW
if (GVAR(debugOptions) && {_ammo call FUNC(shouldFrag) || {_ammo call FUNC(shouldSpall)}}) then { if (GVAR(debugOptions) && {_ammo call FUNC(shouldFrag) || {_ammo call FUNC(shouldSpall)}}) then {
[_projectile, "red", true] call FUNC(dev_trackObj); [_projectile, "red", true] call FUNC(dev_trackObj);