Page MenuHomeFeedback Tracker

HandleDamage event handler doesn't respect exitWith
New, NormalPublic

Description

Prior to 1.84, my HandleDamage handler could use exitWith to return desired damage values. That isn't the case anymore.

Details

Severity
None
Resolution
Open
Reproducibility
Always
Operating System
Windows 7
Category
Scripting
Steps To Reproduce

Experiment control:

  1. Spawn soldier (e.g. using Zeus)
  2. Add HandleDamage handler to the soldier
_unit removeAllEventHandlers "handledamage";
_unit addEventHandler ["handledamage",
{
   params ["_wounded", "_selection", "_damage", "_source", "_projectile", "_partIndex", "_instigator"];
   0
}];
  1. Attempt to damage the soldier (e.g. remote control, drop grenade). He will take no damage, as expected.

Demonstrate problem:

  1. Spawn soldier (e.g. using Zeus)
  2. Add HandleDamage handler to the soldier
_unit removeAllEventHandlers "handledamage";
_unit addEventHandler ["handledamage",
{
   params ["_wounded", "_selection", "_damage", "_source", "_projectile", "_partIndex", "_instigator"];
   if (true) exitWith { systemchat "exitWith"; 0 };
   _damage
}];
  1. Attempt to damage the soldier (e.g. remote control, drop grenade). He will take damage, and the exitWith messages will be generated in system chat.

Event Timeline

JB47394 created this task.Sep 3 2018, 6:56 PM
reekoj added a subscriber: reekoj.Sep 4 2018, 4:44 PM

try like this

_unit removeAllEventHandlers "handledamage";
_unit addEventHandler ["handledamage",
{
   params ["_wounded", "_selection", "_damage", "_source", "_projectile", "_partIndex", "_instigator"];
   call {if (true) exitWith {systemchat "exitWith"; 0}};
}];

Source : last KK's comment on https://community.bistudio.com/wiki/exitWith

Thanks for the pointer. It's an absurd exception, flying in the face of KK's prior comment, but after two years of constant development with this mess I've come to expect so little from SQF that such an exception seems to comfort me in some strange way.

Note that I've refactored the code to always flow through to the end of the handler so that anyone looking at the handler doesn't have an aneurysm when they see the exitWith usage.

One last mention is that SOMETHING changed to break my damage handling. I had things such that a vehicle explosion would incapacitate everyone and throw them clear of the wreck. Whatever changed in the last update triggered an immediate respawn. I suspect it has to do with the reporting of explosion damage to the damage handler.