Page MenuHomeFeedback Tracker

Killed-event handler can run twice for the same entity
Feedback, NormalPublic

Description

If setDamage 1 command is used inside a HandleDamage event handler, the Killed event may be raised twice.

Details

Severity
None
Resolution
Open
Reproducibility
Always
Operating System
Windows 7 x64
Operating System Version
A3 v1.96.146114 x64
Category
Scripting
Steps To Reproduce
  1. Add this to the editor init box of some AI:
this addEventHandler ["HandleDamage", {
    if (param [7] isEqualTo "hitface") then {
        param [0] setDamage 1;
    } else {0};
}];

this addEventHandler ["Killed", {
    systemChat str ["Killed", _this];
}];
  1. Preview the mission and shoot them in the head.

It will print in chat:

["Killed",[B Alpha 1-2:1,B Alpha 1-2:1,<NULL-object>,true]]
["Killed",[B Alpha 1-2:1,B Alpha 1-1:1 (OGefr. commy2),B Alpha 1-1:1 (OGefr. commy2),true]]

Event Timeline

dedmen added a subscriber: dedmen.Feb 28 2020, 8:49 PM
dedmen claimed this task.Mar 24 2020, 3:31 PM
dedmen changed the task status from New to Acknowledged.
dedmen removed dedmen as the assignee of this task.Oct 13 2020, 9:47 PM
dedmen changed the task status from Acknowledged to New.

You are lucky it only fires twice. Just check how many times the HandleDamage EH fires on a single bullet.

Revision: 147668

BIS_fnc_KK removed BIS_fnc_KK as the assignee of this task.May 30 2021, 1:10 PM
BIS_fnc_KK changed the task status from New to Feedback.
BIS_fnc_KK added a subscriber: BIS_fnc_KK.