Prior to 1.84, my HandleDamage handler could use exitWith to return desired damage values. That isn't the case anymore.
Description
Details
- Severity
- None
- Resolution
- Open
- Reproducibility
- Always
- Operating System
- Windows 7
- Category
- Scripting
Experiment control:
- Spawn soldier (e.g. using Zeus)
- Add HandleDamage handler to the soldier
_unit removeAllEventHandlers "handledamage"; _unit addEventHandler ["handledamage", { params ["_wounded", "_selection", "_damage", "_source", "_projectile", "_partIndex", "_instigator"]; 0 }];
- Attempt to damage the soldier (e.g. remote control, drop grenade). He will take no damage, as expected.
Demonstrate problem:
- Spawn soldier (e.g. using Zeus)
- 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 }];
- 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
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.