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 {""};
@@ -60,7 +61,7 @@ if (!isNull _source) then {
if (!isNull _body) then { if (!isNull _body) then {
_distance = round (_deathPos distance _source); _distance = round (_deathPos distance _source);
}; };
_sourceVehicleType = typeOf (vehicle _source); _sourceVehicleType = typeOf (vehicle _source);
_sourceWeapon = currentWeapon _source; _sourceWeapon = currentWeapon _source;
_sourceWeapon = switch true do { _sourceWeapon = switch true do {
@@ -69,9 +70,14 @@ if (!isNull _source) then {
case (_sourceWeapon == "Throw"): {(weaponState _source) select 3}; case (_sourceWeapon == "Throw"): {(weaponState _source) select 3};
default {_sourceWeapon}; default {_sourceWeapon};
}; };
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,16 +85,16 @@ 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"]);
//if you are a bandit or start first - player will not recieve humanity drop //if you are a bandit or start first - player will not recieve humanity drop
_punishment = (_isBandit or {_body getVariable ["OpenTarget",false]}); _punishment = (_isBandit or {_body getVariable ["OpenTarget",false]});
_humanityHit = 0; _humanityHit = 0;
@@ -110,7 +116,7 @@ if (!local _source && isPlayer _source && !(_body isKindOf "PZombie_VB")) then {
_killsV = _realSource getVariable ["banditKills",0]; _killsV = _realSource getVariable ["banditKills",0];
_realSource setVariable ["banditKills",(_killsV + 1),true]; _realSource setVariable ["banditKills",(_killsV + 1),true];
}; };
//Setup for study bodys. //Setup for study bodys.
_body setVariable ["KillingBlow",[_realSource,_punishment],true]; _body setVariable ["KillingBlow",[_realSource,_punishment],true];
}; };
@@ -177,16 +183,16 @@ if ((_body == (vehicle _body)) && {_animState != "deadstate" && {_animCheck != "
publicVariableServer "PVDZ_plr_SwitchMove"; publicVariableServer "PVDZ_plr_SwitchMove";
}; };
[_body,_camera,_deathPos] spawn { [_body,_camera,_deathPos] spawn {
_body = _this select 0; _body = _this select 0;
_camera = _this select 1; _camera = _this select 1;
_deathPos = _this select 2; _deathPos = _this select 2;
waitUntil {camCommitted _camera}; waitUntil {camCommitted _camera};
_camera camSetPos [_deathPos select 0, (_deathPos select 1) + 2, (_deathPos select 2) + 15]; _camera camSetPos [_deathPos select 0, (_deathPos select 1) + 2, (_deathPos select 2) + 15];
_camera camCommit 4; _camera camCommit 4;
uiSleep 5; uiSleep 5;
1 cutRsc [if (DZE_DeathScreen) then {"DeathScreen_DZE"} else {"DeathScreen_DZ"},"BLACK OUT",3]; 1 cutRsc [if (DZE_DeathScreen) then {"DeathScreen_DZE"} else {"DeathScreen_DZ"},"BLACK OUT",3];
playMusic "dayz_track_death_1"; playMusic "dayz_track_death_1";
uiSleep 2; uiSleep 2;
@@ -198,9 +204,9 @@ if ((_body == (vehicle _body)) && {_animState != "deadstate" && {_animCheck != "
PVDZ_Server_Simulation = [_body, false]; PVDZ_Server_Simulation = [_body, false];
publicVariableServer "PVDZ_Server_Simulation"; publicVariableServer "PVDZ_Server_Simulation";
_camera cameraEffect ["Terminate","BACK"]; _camera cameraEffect ["Terminate","BACK"];
camDestroy _camera; camDestroy _camera;
endMission "END1"; endMission "END1";
}; };

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)
@@ -67,22 +68,22 @@ if (_playerName != "unknown" or _sourceName != "unknown") then {
}; };
} count playableUnits; } count playableUnits;
}; };
_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];
}; };
_newObject setDamage 1; _newObject setDamage 1;
_newObject setOwner 0; _newObject setOwner 0;
//dead_bodyCleanup set [count dead_bodyCleanup,_newObject]; //dead_bodyCleanup set [count dead_bodyCleanup,_newObject];