Prevent double death issue

Prevents conflicts with using setDamage or setHit to kill a player as
described in:

https://epochmod.com/forum/topic/43990-when-player-dies-kill-message-appears-twice-and-spawn-in-worldspace/#comment-293696

Vanilla commit:

a7b650daa1
This commit is contained in:
ebayShopper
2017-06-11 17:57:49 -04:00
parent 75ba14a68d
commit 88f7687bec

View File

@@ -1,4 +1,4 @@
private ["_ammo","_body","_distance","_infected","_playerID","_sourceName","_sourceWeapon","_sourceVehicleType","_isBandit","_punishment","_humanityHit","_myKills","_kills","_killsV","_display","_myGroup","_camera","_deathPos","_animState","_animStateArray","_animCheck","_source","_method","_realSource"]; private ["_ammo","_body","_distance","_infected","_killed","_playerID","_sourceName","_sourceWeapon","_sourceVehicleType","_isBandit","_punishment","_humanityHit","_myKills","_kills","_killsV","_display","_myGroup","_camera","_deathPos","_animState","_animStateArray","_animCheck","_source","_method","_realSource"];
if (deathHandled) exitWith {}; if (deathHandled) exitWith {};
deathHandled = true; deathHandled = true;
@@ -8,10 +8,12 @@ if (typeName (_this select 0) == "ARRAY") then {
_body = (_this select 0) select 0; _body = (_this select 0) select 0;
_source = (_this select 0) select 1; _source = (_this select 0) select 1;
diag_log format["Player_Death called from 'killed' event handler %1",_this]; diag_log format["Player_Death called from 'killed' event handler %1",_this];
_killed = true;
} else { } else {
_body = player; _body = player;
_source = _this select 0; _source = _this select 0;
diag_log format["Player_Death called from script %1",_this]; diag_log format["Player_Death called from script %1",_this];
_killed = false;
}; };
_deathPos = getPos _body; _deathPos = getPos _body;
@@ -26,8 +28,10 @@ _camera camSetTarget _deathPos;
_camera camSetPos [_deathPos select 0, (_deathPos select 1) + 2, 5]; _camera camSetPos [_deathPos select 0, (_deathPos select 1) + 2, 5];
_camera camCommit 0; _camera camCommit 0;
//SetDamage immediately so Arma registers the player as dead and respawns them into new unit if (!_killed) then {
player setDamage 1; //Kill the player if they are not already dead so they respawn into new unit
_body setHit ["body",1];
};
if (dayz_onBack != "") then { if (dayz_onBack != "") then {
_body addWeapon dayz_onBack; _body addWeapon dayz_onBack;