From 9b13bd0e5e8a016055907c8f3480a3ea0f298eef Mon Sep 17 00:00:00 2001 From: ebaydayz Date: Tue, 27 Sep 2016 15:08:30 -0400 Subject: [PATCH] Update new death messages --- CHANGE LOG 1.0.6.txt | 2 +- SQF/dayz_code/compile/player_death.sqf | 33 +++++++------ SQF/dayz_code/init/compiles.sqf | 36 ++++++++++++++ SQF/dayz_code/init/publicEH.sqf | 29 +++++++++-- SQF/dayz_code/init/variables.sqf | 9 ++++ SQF/dayz_code/stringtable.xml | 24 +--------- SQF/dayz_server/compile/server_playerDied.sqf | 48 +++++++++++-------- 7 files changed, 115 insertions(+), 66 deletions(-) diff --git a/CHANGE LOG 1.0.6.txt b/CHANGE LOG 1.0.6.txt index ae75107ed..2dfe29a31 100644 --- a/CHANGE LOG 1.0.6.txt +++ b/CHANGE LOG 1.0.6.txt @@ -98,7 +98,7 @@ [FIXED] User input is disabled and then gear dialog is closed during safe lock/unlock/pack to block various duping methods. #1341 @RimBlock @ebaydayz [FIXED] Duplicate objectUIDs occasionally causing vehicles to swap classes or be deleted across restarts @ebaydayz @icomrade #1504 [FIXED] DZE_BuildingLimit now counts buildables only instead of all object types. Thanks jOoPs @ebaydayz -[FIXED] Reworked death messages. Fixed messages not always showing, undefined errors and wrong distance bug. Added bled out, killed by zombie, etc. MPHit event handler (fnc_plyrHit) is no longer needed. @ebaydayz +[FIXED] Rewrote death messages to a PVEH instead of the unreliable MPHit. Added localization, more causes of death and optional dynamicText killfeed. @ebaydayz [FIXED] Player no longer hears radiation sound when changing clothes. @ebaydayz [FIXED] Ponds and lakes are now detected correctly in player_goFishing. #1678 @ebaydayz [FIXED] Players are now ejected and killed when their vehicle is destroyed (Fix applies to all types of vehicles). @icomrade diff --git a/SQF/dayz_code/compile/player_death.sqf b/SQF/dayz_code/compile/player_death.sqf index 292893e32..638ab9e86 100644 --- a/SQF/dayz_code/compile/player_death.sqf +++ b/SQF/dayz_code/compile/player_death.sqf @@ -1,4 +1,4 @@ -private ["_pos","_display","_body","_playerID","_array","_source","_method","_isBandit","_punishment","_humanityHit","_myKills","_humanity","_kills","_killsV","_myGroup","_model"]; +private ["_pos","_display","_body","_playerID","_array","_source","_method","_isBandit","_punishment","_humanityHit","_myKills","_humanity","_kills","_killsV","_myGroup","_model","_infected","_distance","_sourceVehicle","_sourceWeapon","_sourceName"]; disableSerialization; if (deathHandled) exitWith {}; deathHandled = true; @@ -28,29 +28,28 @@ if (dayz_onBack != "") then { */ }; _infected = if (r_player_infected && DZE_PlayerZed) then {1} else {0}; -_killerMethod = "unknown"; -_killerName = "unknown"; -_killerWeapon = "unknown weapon"; -_killerDist = 0; +_method = "unknown"; +_sourceName = "unknown"; +_sourceWeapon = ""; +_distance = 0; if (count _this > 0) then { - _killerObj = _this select 0; - _killerMethod = _this select 1; - if (typeName _killerMethod == "OBJECT") exitWith {_killerMethod = "Respawned"}; + _source = _this select 0; + _method = _this select 1; - if (!isNull _killerObj) then { - if (!isNull _body) then {_killerDist = _body distance _killerObj;}; - _killerVehicle = vehicle _killerObj; - _killerWeapon = if (_killerVehicle != _killerObj) then {typeOf _killerVehicle} else {currentWeapon _killerObj}; - if (alive _killerObj) then { - _killerName = if (isPlayer _killerObj) then {name _killerObj} else {localize "STR_EPOCH_AI"}; + if (!isNull _source) then { + if (!isNull _body) then {_distance = round (_body distance _source);}; + _sourceVehicle = vehicle _source; + _sourceWeapon = if (_sourceVehicle != _source) then {typeOf _sourceVehicle} else {currentWeapon _source}; + if (_sourceWeapon == "Throw") then {_sourceWeapon = (weaponState _source) select 3;}; + if (alive _source) then { + _sourceName = if (isPlayer _source) then {name _source} else {localize "STR_EPOCH_AI"}; }; }; - if (count _this > 2) then {_killerMethod = "zombie";}; }; //Send Death Notice -diag_log format["Debug death message vars: CharacterID:%1 BodyObject:%3 UID:%4 PlayerName:%5 Infected:%6 KillerName:%7 KillerWeapon:%8 KillerDistance:%9 KillerMethod:%10",dayz_characterID,0,_body,_playerID,_bodyName,_infected,_killerName,_killerWeapon,_killerDist,_killerMethod]; -PVDZ_plr_Death = [dayz_characterID,0,_body,_playerID,toArray _bodyName,_infected,toArray _killerName,toArray _killerWeapon,_killerDist,toArray _killerMethod]; //Send name as array to avoid publicVariable value restrictions +diag_log format["Player_Death: Body:%1 BodyName:%2 Infected:%3 SourceName:%4 SourceWeapon:%5 Distance:%6 Method:%7",_body,_bodyName,_infected,_sourceName,_sourceWeapon,_distance,_method]; +PVDZ_plr_Death = [dayz_characterID,0,_body,_playerID,toArray _bodyName,_infected,toArray _sourceName,toArray _sourceWeapon,_distance,toArray _method]; //Send name as array to avoid publicVariable value restrictions publicVariableServer "PVDZ_plr_Death"; _id = [player,20,true,getPosATL player] call player_alertZombies; diff --git a/SQF/dayz_code/init/compiles.sqf b/SQF/dayz_code/init/compiles.sqf index 40dab85ad..4bc8822d6 100644 --- a/SQF/dayz_code/init/compiles.sqf +++ b/SQF/dayz_code/init/compiles.sqf @@ -577,6 +577,42 @@ if (!isDedicated) then { _message call _displayText; }; + dayz_killFeed = { + private ["_distance","_icon","_message","_playerName","_sourceName"]; + _playerName = _this select 1; + _sourceName = _this select 2; + _distance = _this select 4; + _icon = _this select 5; + if (_icon == "") exitWith {}; + + if (diag_ticktime - death_1_time < 10) then { + if (time - death_2_time < 10) then { + if (time - death_3_time < 10) then { + death_4 = death_3; + death_4_time = death_3_time; + } else { + death_4 = ""; + }; + death_3 = death_2; + death_3_time = death_2_time; + } else { + death_3 = ""; + death_4 = ""; + }; + death_2 = death_1; + death_2_time = death_1_time; + } else { + death_2 = ""; + death_3 = ""; + death_4 = ""; + }; + + death_1 = format["%1 %3 (%4m)",_sourceName,_icon,_playerName,_distance];; + death_1_time = diag_ticktime; + _message = format ["%1
%2
%3
%4",death_1,death_2,death_3,death_4]; + [_message,safeZoneX,safeZoneY,10,0,0,8000] call BIS_fnc_dynamicText; + }; + dayz_originalPlayer = player; // database trader menu diff --git a/SQF/dayz_code/init/publicEH.sqf b/SQF/dayz_code/init/publicEH.sqf index 6167fb268..71f5f0ea4 100644 --- a/SQF/dayz_code/init/publicEH.sqf +++ b/SQF/dayz_code/init/publicEH.sqf @@ -324,16 +324,35 @@ if (!isDedicated) then { // EPOCH ADDITION "PVDZE_deathMessage" addPublicVariableEventHandler { - // do not allow PVDZE_deathMessage in publicvariable.txt, it is only sent from the server machine + private "_weapon"; _message = _this select 1; + _message = switch (_message select 0) do { + case "died": {format [localize "str_player_death_died",_message select 1,localize format["str_death_%1",_message select 2]]}; + case "killed": { + _weapon = _message select 3; + switch true do { + case (isClass (configFile >> "CfgWeapons" >> _weapon)): { + _message set [3, getText (configFile >> "CfgWeapons" >> _weapon >> "displayName")]; + _message set [5, getText (configFile >> "CfgWeapons" >> _weapon >> "picture")]; + }; + case (isClass (configFile >> "CfgVehicles" >> _weapon)): { + _message set [3, getText (configFile >> "CfgVehicles" >> _weapon >> "displayName")]; + _message set [5, getText (configFile >> "CfgVehicles" >> _weapon >> "picture")]; + }; + default {_message set [5,""]}; + }; + if (DZE_DeathMsgDynamicText) then {_message call dayz_killFeed}; + format [localize "str_player_death_killed",_message select 1,_message select 2,_message select 3,_message select 4] + }; + case "suicide": {format [localize "str_player_death_suicide",_message select 1]}; + }; switch (toLower DZE_DeathMsgChat) do { - // Use FunctionsManager logic unit (BIS_functions_mainscope) to send chat messages so no side or quotation marks are shown - case "global": {BIS_functions_mainscope globalChat _message;}; - case "side": {BIS_functions_mainscope sideChat _message;}; + case "global": {objNull globalChat _message;}; + case "side": {objNull sideChat _message;}; case "system": {systemChat _message;}; }; if (DZE_DeathMsgCutText) then {_message call dayz_rollingMessages;}; - if (DZE_DeathMsgDynamicText) then {/* add later */}; + diag_log format["DeathMessage: %1",_message]; }; // flies and swarm sound sync diff --git a/SQF/dayz_code/init/variables.sqf b/SQF/dayz_code/init/variables.sqf index 2bb6f3d47..4f4d39b59 100644 --- a/SQF/dayz_code/init/variables.sqf +++ b/SQF/dayz_code/init/variables.sqf @@ -22,6 +22,15 @@ Message_3 = ""; Message_1_time = 0; Message_2_time = 0; Message_3_time = 0; +//Kill Feed +death_1 = ""; +death_2 = ""; +death_3 = ""; +death_4 = ""; +death_1_time = 0; +death_2_time = 0; +death_3_time = 0; +death_4_time = 0; //OpenTarget timer OpenTarget_Time = 0; diff --git a/SQF/dayz_code/stringtable.xml b/SQF/dayz_code/stringtable.xml index 39cf262ea..2ef9f3e03 100644 --- a/SQF/dayz_code/stringtable.xml +++ b/SQF/dayz_code/stringtable.xml @@ -13800,48 +13800,26 @@ radiation Strahlung излучение - radiación - záření being crushed zerquetscht раздавлен - ser aplastado - être écrasé - rozdrcení - - - %1 was killed by a zombie - %1 wurde von einem Zombie getötet. - %1 был убит зомби - %1 murió a manos de un zombi - %1 a été tué par un zombie - %1 byl zabit zombie %1 committed suicide %1 Selbstmord %1 покончил с собой - %1 se suicidó - %1 suicidé - %1 spáchal sebevraždu - + %1 died from %2 %1 starb durch %2 %1 умер от %2 - %1 murió de %2 - %1 %2 de mort - %1 zemřelo %2 %1 was killed by %2 with a %3 from %4m %1 wurde von %2 mit einer %3 von %4m getötet %1 был убит игроком %2 с %3 с расстояния %4м - %1 murió a manos de %2 con un %3 de %4m - %1 a été tué par %2 avec un %3 de %4m - %1 byl zabit %2 na %3 z %4m Pitch Desert Dome Tent diff --git a/SQF/dayz_server/compile/server_playerDied.sqf b/SQF/dayz_server/compile/server_playerDied.sqf index 49ae42f8d..1966fb5d9 100644 --- a/SQF/dayz_server/compile/server_playerDied.sqf +++ b/SQF/dayz_server/compile/server_playerDied.sqf @@ -1,6 +1,6 @@ #include "\z\addons\dayz_server\compile\server_toggle_debug.hpp" -private ["_characterID","_minutes","_newObject","_playerID","_key","_pos","_infected","_killerName","_killerWeapon","_distance","_message","_killerMethod"]; +private ["_characterID","_minutes","_newObject","_playerID","_key","_pos","_infected","_sourceName","_sourceWeapon","_distance","_message","_method"]; //[unit, weapon, muzzle, mode, ammo, magazine, projectile] _characterID = _this select 0; @@ -9,10 +9,10 @@ _newObject = _this select 2; _playerID = _this select 3; _playerName = toString (_this select 4); //Sent as array to avoid publicVariable value restrictions _infected = _this select 5; -_killerName = toString (_this select 6); -_killerWeapon = toString (_this select 7); +_sourceName = toString (_this select 6); +_sourceWeapon = toString (_this select 7); _distance = _this select 8; -_killerMethod = toString (_this select 9); +_method = toString (_this select 9); //Mark player as dead so we bypass the ghost system dayz_died set [count dayz_died, _playerID]; @@ -43,30 +43,38 @@ diag_log format ["Player UID#%3 CID#%4 %1 as %5 died at %2", // EPOCH DEATH MESSAGES -if (_killerWeapon == "Throw") then {_killerWeapon = "Grenade";}; -if (_killerMethod in ["starve","dehyd","sick","bled","crushed","rad","zombie"]) then { - if (_killerMethod == "zombie") then { - _message = format[localize "str_player_death_zombie",_playerName]; +if (_method in ["explosion","melee","runover","shot","shothead","shotheavy"]) then { + if (_sourceName == _playerName) then { + _message = ["suicide",_playerName]; } else { - _methodStr = localize format["str_death_%1",_killerMethod]; - _message = format[localize "str_player_death_message",_playerName,_methodStr]; + if (_sourceWeapon == "") then {_sourceWeapon = "unknown weapon";}; + _message = ["killed",_playerName,_sourceName,_sourceWeapon,_distance]; + // Store death messages to allow viewing at message board in trader citys. + PlayerDeaths set [count PlayerDeaths,[_playerName,_sourceName,_sourceWeapon,_distance,ServerCurrentTime]]; }; } else { - if (_killerName == _playerName) then { - _message = format[localize "str_player_death_suicide",_playerName]; - } else { - _message = format[localize "str_player_death_killed",_playerName,_killerName,_killerWeapon,_distance]; - }; + // No source name, distance or weapon needed: "%1 died from %2" str_death_%1 (see stringtable) + // Possible methods: ["bled","combatlog","crushed","dehyd","eject","fall","starve","sick","rad","unknown","zombie"] + _message = ["died",_playerName,_method]; }; -if ((_killerWeapon != "unknown weapon") or {_killerMethod != "unknown"} or {_killerName != "unknown"}) then { - diag_log _message; +if (_playerName != "unknown" or _sourceName != "unknown") then { if (toLower DZE_DeathMsgChat != "none" or DZE_DeathMsgCutText or DZE_DeathMsgDynamicText) then { PVDZE_deathMessage = _message; - publicVariable "PVDZE_deathMessage"; + //Don't use regular PV here since JIP clients don't need it + { + if (isPlayer _x) then { + owner _x publicVariableClient "PVDZE_deathMessage"; + }; + } count playableUnits; }; - // Store death messages to allow viewing at message board in trader citys. - PlayerDeaths set [count PlayerDeaths,[_playerName,_killerName,_killerWeapon,_distance,ServerCurrentTime]]; + + _message = switch (_message select 0) do { + case "died": {format [localize "str_player_death_died", _message select 1, localize format["str_death_%1",_message select 2]]}; + case "killed": {format [localize "str_player_death_killed", _message select 1, _message select 2, _message select 3, _message select 4]}; + case "suicide": {format [localize "str_player_death_suicide", _message select 1]}; + }; + diag_log format["DeathMessage: %1",_message]; };