Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent double execution of Killed event on the same body #1291

Merged
merged 2 commits into from
Feb 7, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions addons/xeh/fnc_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,25 @@ GVAR(EventsLowercase) = [];
_header = format ["scriptName 'XEH:%1';", _x];
#endif
// generate event functions
if (_x isEqualTo "Init") then {
FUNC(Init) = compileFinal (_header + "(_this select 0) call CBA_fnc_initEvents; (_this select 0) call CBA_fnc_init");
} else {
if (_x isEqualTo "HitPart") then {
switch _x do {
case "Init": {
FUNC(Init) = compileFinal (_header + "(_this select 0) call CBA_fnc_initEvents; (_this select 0) call CBA_fnc_init");
};
// This prevents double execution of the Killed event on the same unit.
case "Killed": {
FUNC(Killed) = compileFinal (_header + format ['\
params ["_unit"];\
if (_unit getVariable [QGVAR(killedBody), objNull] != _unit) then {\
_unit setVariable [QGVAR(killedBody), _unit];\
private "_unit";\
{call _x} forEach ((_this select 0) getVariable QGVAR(%1));\
};',
_x]);
};
case "HitPart": {
FUNC(HitPart) = compileFinal (_header + format ['{call _x} forEach ((_this select 0 select 0) getVariable QGVAR(%1))', _x]);
} else {
};
default {
missionNamespace setVariable [
format [QFUNC(%1), _x],
compileFinal (_header + format ['{call _x} forEach ((_this select 0) getVariable QGVAR(%1))', _x])
Expand Down