ACE3 icon indicating copy to clipboard operation
ACE3 copied to clipboard

Killed eventhandler is ran/triggered twice because of ACE3

Open MrSanchez opened this issue 11 years ago • 12 comments

ACE3 Version: 3.1.1 stable PWS version (indicate if stable or dev, if dev indicate the commit the version is based on)

Mods:

  • @cba_a3
  • @ace3

Placed ACE3 Modules: None

Description: Add a 'killed' eventhandler to a playable AI in a MP lan lobby while solo in that lobby, kill the AI and witness how the eventhandler is triggered twice.

I made a BIS thread about it before I knew that ACE3 was the problem; http://forums.bistudio.com/showthread.php?193486-Killed-Eventhandler-ran-twice

Steps to reproduce: I made a repro mission: https://dl.dropboxusercontent.com/u/23922015/ai_eventhandler_bug.VR.rar

Where did the issue occur? Multiplayer yet solo, LAN lobby, only player == server

RPT log file: http://pastebin.com/skfgguNw

MrSanchez avatar Jul 15 '15 23:07 MrSanchez

This seems to be caused by the medical module (can't reproduce with the "HandleDamage" EH commented out)

Adding this to bottom on handleDam_basic diag_log text format ["_damage %1 from %2, %3", _damage, _this, (alive _unit)]; gives some weird results:

19:53:47 _damage 0.0260697 from [a2,"head",0.0260697,<NULL-object>,"B_65x39_Caseless"], true
19:53:47 _damage 0.572074 from [a2,"",0.572074,B Alpha 1-1:1 (Pabst Mirror),"B_65x39_Caseless"], true
19:53:47 _damage 0.572074 from [a2,"",0.572074,B Alpha 1-1:1 (Pabst Mirror),"B_65x39_Caseless"], true
19:53:47 _damage 0.0260697 from [a2,"head",0.0260697,B Alpha 1-1:1 (Pabst Mirror),"B_65x39_Caseless"], true
19:53:47 _damage 2.31542 from [a2,"body",2.31542,B Alpha 1-1:1 (Pabst Mirror),"B_65x39_Caseless"], true
19:53:47 _damage 0 from [a2,"hand_l",0.0446218,B Alpha 1-1:1 (Pabst Mirror),"B_65x39_Caseless"], false
19:53:47 _damage 0 from [a2,"hand_r",0.0198612,B Alpha 1-1:1 (Pabst Mirror),"B_65x39_Caseless"], false
19:53:47 _damage 0 from [a2,"leg_l",0.00240231,B Alpha 1-1:1 (Pabst Mirror),"B_65x39_Caseless"], false
19:53:47 _damage 0 from [a2,"leg_r",0.00211351,B Alpha 1-1:1 (Pabst Mirror),"B_65x39_Caseless"], false

Added a bunch of debug statements, and found that in one test this is the line that "kills" the unit: _unit setHitPointDamage ["HitLegs", 0]; Which makes no sense to me.

TBH, scripted damage is weird, but I'm inclined to put the blame on BIS as a unit shouldn't be able to die twice.

If you need a workaround with ACE, you could try something like this:

    _x addeventhandler ["Killed", {
        if ((time - ((_this select 0) getVariable ["LastKilledTime", -1])) > 1) then {
            (_this select 0) setVariable ["LastKilledTime", time];
            _this execVM "aikilled.sqf";
        } else {
            systemChat "double";
        };
    }];

which should prevent 2 calls to aikilled.sqf

PabstMirror avatar Jul 17 '15 01:07 PabstMirror

Yes this is probably BI's fault. There is some wierd shit going on with handleDamage. I will see if I can figure out exactly what is going on when I have some time.

thojkooi avatar Jul 17 '15 06:07 thojkooi

I've scripted myself a workaround, very similar to the one you posted after I submitted this report.

I don't know the behaviour if the AI is replaced by players, as locality comes into play...If you haven't tested that already I might find some time to do so soon. For me it's not the end of the world if it's an AI-only problem, as I used the AIs purely for testing my eventhandlers. So knowing if it's an AI-only problem is important to me.

Kind regards, Sanchez

MrSanchez avatar Jul 17 '15 09:07 MrSanchez

This issue seems to have reared its head again in the latest release (3.3.1.2), with double kills for each player kill. I've taken the whole set of mods back to just ace and cba to check it, and reverted back to previous version of ace and it didn't repeat it. Seems to confirm its something version specific.

W4R-PYR4T3 avatar Sep 19 '15 23:09 W4R-PYR4T3

[ACE] (medical) INFO: lethalDamage - calling setDead head
[ACE] (medical) INFO: setDead returned true head
[ACE] (medical) INFO: killedEH - [B Alpha 1-2:1 (Pabst Mirror (2)),B Alpha 1-2:1 (Pabst Mirror (2))]
[ACE] (medical) INFO: killedEH - [B Alpha 1-2:1 (Pabst Mirror (2)),B Alpha 1-1:1 (Pabst Mirror) REMOTE]

I think it's from setDead when we do [_unit, 1] call FUNC(setStructuralDamage);

So unit takes a bullet to head, inside the handleDamage we do setDamage 1, and also return a damage of 1 to the EH for a critical hitpoint which kills them a 2nd time.

Edit, that's why the first time the killer is self, because it's scripted. 2nd time is from handle damage which shows the remote shooter.

PabstMirror avatar Sep 20 '15 00:09 PabstMirror

Oh wow, it's been two months already.....Yeah if this can be fixed by removing the setDamage or returning less-than-1 damage that'd be grand.

MrSanchez avatar Sep 20 '15 00:09 MrSanchez

Nice find Pabst.

commy2 avatar Sep 20 '15 08:09 commy2

I know a solution for this. I will wait for @commy2 s rewrite of the handleDamage system and implement in there, if it is still required.

thojkooi avatar Sep 20 '15 10:09 thojkooi

Fixed by #2876

thojkooi avatar Nov 28 '15 19:11 thojkooi

This bug has come back after the latest ACE3 update -- having the same issue with my mod Guilt and Remembrance. No changes since before latest update, but now the "killed" EH is being triggered twice.

My workaround, in the eventhandler function:

if (_killed getVariable ["ace_bug_alreadykilled",0] == 1) exitWith {};
_killed setVariable ["ace_bug_alreadykilled",1];

musurca avatar Jan 11 '20 20:01 musurca

Unfortunately this bug is back and is a known issue that we may not be able to fix

There is a global CBA event that will only fire once ["ace_killed", [_unit, _causeOfDeath, _killer, _instigator]] from https://github.com/acemod/ACE3/blob/master/addons/medical_status/functions/fnc_handleKilled.sqf#L41

your exitWith/setVar solution is similar to what it uses

PabstMirror avatar Jan 11 '20 21:01 PabstMirror

My workaround, in the eventhandler function:

Keep in mind that variables may be copied from the corpse to the new body for respawning playable units. This can be circumvented by resetting the value in a Respawn event handler.

Also, don't expect this bug to be fixed any time soon, as the root cause is not a problem in ACE, and can not be circumvented without either causing greater issues or changing the game itself.

commy2 avatar Jan 11 '20 22:01 commy2