Adding better logging for playerDied

Also made some basic code changes for player_death
This commit is contained in:
A Man
2019-11-08 20:32:07 +01:00
parent ba6b1ed57d
commit ae3a4fa2c8
2 changed files with 41 additions and 34 deletions

View File

@@ -1,8 +1,8 @@
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;
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","_sourceID"];
// Get reference to player object before respawn into new unit (respawnDelay=0 in description.ext) // Get reference to player object before respawn into new unit (respawnDelay=0 in description.ext)
if (typeName (_this select 0) == "ARRAY") then { if (typeName (_this select 0) == "ARRAY") then {
_body = (_this select 0) select 0; _body = (_this select 0) select 0;
@@ -18,6 +18,7 @@ if (typeName (_this select 0) == "ARRAY") then {
_deathPos = getPosATL _body; _deathPos = getPosATL _body;
_playerID = getPlayerUID player; _playerID = getPlayerUID player;
_sourceID = "0";
//Switch view to camera so player does not see debug plains at respawn_west //Switch view to camera so player does not see debug plains at respawn_west
_camera = "camera" camCreate _deathPos; _camera = "camera" camCreate _deathPos;
@@ -43,16 +44,16 @@ if (dayz_onBack != "") then {
}; };
//Get killer information immediately. Weapon, distance or vehicle can change in seconds. //Get killer information immediately. Weapon, distance or vehicle can change in seconds.
_infected = if (r_player_infected && DZE_PlayerZed) then {1} else {0}; _infected = [0, 1] select (r_player_infected && {DZE_PlayerZed});
_sourceName = "unknown"; _sourceName = "unknown";
_sourceWeapon = ""; _sourceWeapon = "";
_distance = 0; _distance = 0;
_method = switch true do { _method = call {
case (_this select 1 != "find"): {_this select 1}; //Manually passed method if (_this select 1 != "find") exitwith {_this select 1}; //Manually passed method
case (dayz_lastDamageSource != "none" && diag_tickTime - dayz_lastDamageTime < 30): {dayz_lastDamageSource}; //Major event takes priority for cause of death (zombie, melee, shot, fell, etc.) if (dayz_lastDamageSource != "none" && {diag_tickTime - dayz_lastDamageTime < 30}) exitwith {dayz_lastDamageSource}; //Major event takes priority for cause of death (zombie, melee, shot, fell, etc.)
case (dayz_lastMedicalSource != "none" && diag_tickTime - dayz_lastMedicalTime < 10): {dayz_lastMedicalSource}; //Starve, Dehyd, Sick if (dayz_lastMedicalSource != "none" && {diag_tickTime - dayz_lastMedicalTime < 10}) exitwith {dayz_lastMedicalSource}; //Starve, Dehyd, Sick
default {"bled"}; //No other damage sources in last 30 seconds "bled"; //No other damage sources in last 30 seconds
}; };
_ammo = if (count _this > 2) then {_this select 2} else {""}; _ammo = if (count _this > 2) then {_this select 2} else {""};
@@ -71,7 +72,12 @@ if (!isNull _source) then {
}; };
if (alive _source) then { if (alive _source) then {
_sourceName = if (isPlayer _source) then {name _source} else {"AI"}; if (isPlayer _source) then {
_sourceName = name _source;
_sourceID = getPlayerUID _source;
} else {
_sourceName = "AI";
};
} else { } else {
if (_source == _body) then {_sourceName = dayz_playerName;}; if (_source == _body) then {_sourceName = dayz_playerName;};
}; };
@@ -79,12 +85,12 @@ if (!isNull _source) then {
//Send Death Notice //Send Death Notice
diag_log format["Player_Death: Body:%1 BodyName:%2 Infected:%3 SourceName:%4 SourceWeapon:%5 Distance:%6 Method:%7",_body,dayz_playerName,_infected,_sourceName,_sourceWeapon,_distance,_method]; diag_log format["Player_Death: Body:%1 BodyName:%2 Infected:%3 SourceName:%4 SourceWeapon:%5 Distance:%6 Method:%7",_body,dayz_playerName,_infected,_sourceName,_sourceWeapon,_distance,_method];
PVDZ_plr_Death = [dayz_characterID,0,_body,_playerID,toArray dayz_playerName,_infected,toArray _sourceName,_sourceWeapon,_distance,_method]; //Send name as array to avoid publicVariable value restrictions PVDZ_plr_Death = [dayz_characterID,0,_body,_playerID,toArray dayz_playerName,_infected,toArray _sourceName,_sourceWeapon,_distance,_method,_sourceID]; //Send name as array to avoid publicVariable value restrictions
publicVariableServer "PVDZ_plr_Death"; publicVariableServer "PVDZ_plr_Death";
_body setVariable ["deathType", if (_method == "suicide") then {"shot"} else {_method}, true]; _body setVariable ["deathType", if (_method == "suicide") then {"shot"} else {_method}, true];
if (!local _source && isPlayer _source && !(_body isKindOf "PZombie_VB")) then { //If corpse is a player zombie do not give killer a human or bandit kill if (!local _source && {isPlayer _source} && {!(_body isKindOf "PZombie_VB")}) then { //If corpse is a player zombie do not give killer a human or bandit kill
//Values like humanity which were setVariabled onto player before death remain on corpse. //Values like humanity which were setVariabled onto player before death remain on corpse.
_isBandit = (_body getVariable["humanity",0]) <= -2000; _isBandit = (_body getVariable["humanity",0]) <= -2000;
//_isBandit = (typeOf _body in ["Bandit1_DZ","BanditW1_DZ"]); //_isBandit = (typeOf _body in ["Bandit1_DZ","BanditW1_DZ"]);

View File

@@ -1,6 +1,6 @@
#include "\z\addons\dayz_server\compile\server_toggle_debug.hpp" #include "\z\addons\dayz_server\compile\server_toggle_debug.hpp"
private ["_characterID","_minutes","_newObject","_playerID","_playerName","_key","_pos","_infected","_sourceName","_sourceWeapon","_distance","_message","_method","_suicide","_bodyName","_type"]; private ["_characterID","_minutes","_newObject","_playerID","_playerName","_key","_pos","_infected","_sourceName","_sourceWeapon","_distance","_message","_method","_suicide","_bodyName","_type","_sourceID"];
//[unit, weapon, muzzle, mode, ammo, magazine, projectile] //[unit, weapon, muzzle, mode, ammo, magazine, projectile]
_characterID = _this select 0; _characterID = _this select 0;
@@ -13,6 +13,7 @@ _sourceName = toString (_this select 6);
_sourceWeapon = _this select 7; _sourceWeapon = _this select 7;
_distance = _this select 8; _distance = _this select 8;
_method = _this select 9; _method = _this select 9;
_sourceID = _this select 10;
//Mark player as dead so we bypass the ghost system //Mark player as dead so we bypass the ghost system
dayz_died set [count dayz_died, _playerID]; dayz_died set [count dayz_died, _playerID];
@@ -32,7 +33,7 @@ if (_characterID != "0") then {
_key call server_hiveWrite; _key call server_hiveWrite;
}; };
diag_log format ["Player UID#%3 CID#%4 %1 as %5 died at %2", diag_log format ["Player %1(%3) died as %5 at %2 CharID: %4",
_newObject call fa_plr2str, _pos call fa_coor2str, _newObject call fa_plr2str, _pos call fa_coor2str,
_playerID, _characterID, _playerID, _characterID,
typeOf _newObject typeOf _newObject
@@ -41,7 +42,7 @@ diag_log format ["Player UID#%3 CID#%4 %1 as %5 died at %2",
// DEATH MESSAGES // DEATH MESSAGES
_suicide = ((_sourceName == _playerName) or (_method == "suicide")); _suicide = ((_sourceName == _playerName) or (_method == "suicide"));
if (_method in ["explosion","melee","shot","shothead","shotheavy","suicide"] && !(_method == "explosion" && (_suicide or _sourceName == "unknown"))) then { if (_method in ["explosion","melee","shot","shothead","shotheavy","suicide"] && {!(_method == "explosion" && {_suicide || {_sourceName == "unknown"}})}) then {
if (_suicide) then { if (_suicide) then {
_message = ["suicide",_playerName]; _message = ["suicide",_playerName];
} else { } else {
@@ -56,8 +57,8 @@ if (_method in ["explosion","melee","shot","shothead","shotheavy","suicide"] &&
_message = ["died",_playerName,_method]; _message = ["died",_playerName,_method];
}; };
if (_playerName != "unknown" or _sourceName != "unknown") then { if (_playerName != "unknown" || {_sourceName != "unknown"}) then {
if (toLower DZE_DeathMsgChat != "none" or DZE_DeathMsgRolling or DZE_DeathMsgDynamicText) then { if (toLower DZE_DeathMsgChat != "none" || {DZE_DeathMsgRolling} || {DZE_DeathMsgDynamicText}) then {
PVDZE_deathMessage = _message; PVDZE_deathMessage = _message;
//Don't use regular PV here since JIP clients don't need it //Don't use regular PV here since JIP clients don't need it
owner _newObject publicVariableClient "PVDZE_deathMessage"; //Send to dead player (not in playableUnits) owner _newObject publicVariableClient "PVDZE_deathMessage"; //Send to dead player (not in playableUnits)
@@ -71,14 +72,14 @@ if (_playerName != "unknown" or _sourceName != "unknown") then {
_type = _message select 0; _type = _message select 0;
_bodyName = _message select 1; _bodyName = _message select 1;
if (_type == "killed" && _sourceName == "AI") then { if (_type == "killed" && {_sourceName == "AI"}) then {
_message set [2, (localize "STR_PLAYER_AI")]; _message set [2, (localize "STR_PLAYER_AI")];
}; };
_message = switch _type do { _message = call {
case "died": {format [localize "str_player_death_died", _bodyName, localize format["str_death_%1",_message select 2]]}; if (_type == "died") exitwith {format ["%1(%3) died from %2", _bodyName, localize format["str_death_%1",_message select 2],_playerID]};
case "killed": {format [localize "str_player_death_killed", _bodyName, _message select 2, _message select 3, _message select 4]}; if (_type == "killed") exitwith {format ["%1(%5) was killed by %2(%6) with %3 from %4m", _bodyName, _message select 2, _message select 3, _message select 4,_playerID,_sourceID]};
case "suicide": {format [localize "str_player_death_suicide", _bodyName]}; if (_type == "suicide") exitwith {format ["%1(%2) committed suicide", _bodyName,_playerID]};
}; };
diag_log format["DeathMessage: %1",_message]; diag_log format["DeathMessage: %1",_message];
}; };