Clicking the Respawn Button to do damage to the player does not fire the EH, despite damage being applied.
Description
Details
- Legacy ID
- 56106383
- Severity
- None
- Resolution
- Open
- Reproducibility
- Always
- Operating System
- Windows 10 x64
- Category
- Menu UI
Put the following in the init.sqf of a mission containing a playable soldier and with Respawn available. Then play that mission and hit the respawn button. Note that no message pops up, indicating that the EH never fired from the Respawn Button.
player setVariable ["selections", []]; player setVariable ["gethit", []]; player addEventHandler [ "HandleDamage", { _unit = _this select 0; _selections = player getVariable ["selections", []]; _gethit = player getVariable ["gethit", []]; _selection = _this select 1; _projectile = _this select 4; if !(_selection in _selections) then { _selections set [count _selections, _selection]; _gethit set [count _gethit, 0]; }; _i = _selections find _selection; _olddmg = _gethit select _i; _curdmg = _this select 2; if ((_projectile == "") || _curdmg == 1) then { _curdmg; player sideChat "Respawn button used!"; } else { player sideChat "NOT Respawn button!"; _newdmg = _olddmg + (_curdmg - _olddmg); _gethit set [_i, _newdmg]; _newdmg; }; } ];
I understand that the respawn button simply executed a setDamage 1 command, but without the EH firing this cannot be manipulated. For instance, what if I don't want the unit to die when I hit the Respawn button?
Event Timeline
Still a reproducible issue.
Game version: 1.80.143869
Workaround would probably be in the onKilled or onRespawn parts.
Per the wiki at https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#Killed, it is possible that since A3 v1.65 if the instigator isNull, then respawn button was clicked. At least, this is how the BIS revive system detects for it in BIS_fnc_reviveEhKilled. However the unit is already dead at this point, so this does not help the issue.
Instead of somehow detecting use of respawn button during HandleDamage EH, I use the following workaround to disable the button at the source:
[] spawn { while {true} do { //Wait for game menu to open waitUntil {!isNull (findDisplay 49)}; //Add EH to close game menu when respawn button is clicked and announce that it is disabled _respawnButtonEH = ((findDisplay 49) displayCtrl 1010) ctrlAddEventHandler ["MouseButtonDown",{(findDisplay 49) closeDisplay 0; titleText ["The Respawn Button is disabled by the host!","PLAIN",1]; titleFadeOut 5;}]; //Wait for game menu to be closed (and EH deleted) waitUntil {isNull (findDisplay 49)}; }; };