Jump to content

[Release] Fixed Kill/Death Messages


Guest

Recommended Posts

So, we all know how shit the death messages on DayZ are; whether it's people crying "PVP!" when killed by a zombie, or scratching their head at "RandomNoob killed himself" when shot by an AI on a mission, it never quite works right.

 

With that in mind, I decided to fix them.

 

fnc_plyrHit.sqf

private ["_victim", "_attacker","_weapon","_distance","_damage","_pvp"];
_victim = _this select 0;
_attacker = _this select 1;
_damage = _this select 2;
_pvp = true;

if (!isPlayer _victim) exitWith {};

if (side _attacker == EAST) then { _pvp = false; };

if ((owner _victim) == (owner _attacker)) then {
	_attacker = _victim;
	_pvp = false;
};

_weapon = weaponState _attacker;
if (!isNil "_weapon") then {
	if (_weapon select 0 == "Throw") then {
		_weapon = _weapon select 3;
	} else {
		_weapon = _weapon select 0;
	};
} else {
	_weapon = "Unknown";
};

_vehicle = typeOf (vehicle _attacker); 
if ((getText (configFile >> "CfgVehicles" >> _vehicle >> "vehicleClass")) in ["CarW","Car","CarD","Armored","Ship","Support","Air","ArmouredW","ArmouredD","SupportWoodland_ACR"]) then {
	_weapon = getText (configFile >> "CfgVehicles" >> _vehicle >> "displayName");
};

_distance = _victim distance _attacker;

if (_pvp) then { diag_log format["PVP Attack: %1 was hit by %2 with %3 from %4m with %5 dmg", _victim, _attacker, _weapon, _distance, _damage]; };

_victim setVariable["AttackedBy", _attacker, true];
_victim setVariable["AttackedByName", (name _attacker), true];
_victim setVariable["AttackedByWeapon", _weapon, true];
_victim setVariable["AttackedFromDistance", _distance, true];
_victim setVariable["LastHit", time, true];

server_playerDied.sqf

private ["_characterID","_minutes","_newObject","_playerID","_infected","_victim","_victimName","_killer","_killerName","_weapon","_distance","_message","_loc_message","_key","_death_record"];
//[unit, weapon, muzzle, mode, ammo, magazine, projectile]
_characterID = 	_this select 0;
_minutes =		_this select 1;
_newObject = 	_this select 2;
_playerID = 	_this select 3;
_infected =		_this select 4;
if (((count _this) >= 6) && {(typeName (_this select 5)) == "STRING"} && {(_this select 5) != ""}) then {
	_victimName =	_this select 5;
} else {
	_victimName =  if (alive _newObject) then {name _newObject;} else {"";};
};
_victim = _newObject;
_newObject setVariable ["bodyName", _victimName, true];

_killer = _victim getVariable["AttackedBy", "nil"];
_killerName = _victim getVariable["AttackedByName", "nil"];
_lastHit = _victim getVariable["LastHit",0];

// when a zombie kills a player _killer, _killerName && _weapon will be "nil"
// we can use this to determine a zombie kill && send a customized message for that. right now no killmsg means it was a zombie.

if ((time - _lastHit) < 30) then {
	if ((typeName _killer) != "STRING") then {
		_weapon = _victim getVariable["AttackedByWeapon", "nil"];
		_distance = _victim getVariable["AttackedFromDistance", "nil"];

		if ((owner _victim) == (owner _killer)) then {
			_message = format["%1 killed themselves!",_victimName];
			_loc_message = format["PDEATH: %1 killed themselves!", _victimName];
		} else {
			if (side _killer == EAST) then {
				_message = format["%1 was killed by %2 (AI) with weapon %3 from %4m",_victimName, _killerName, _weapon, _distance];
				_loc_message = format["AI Kill: %1 was killed by %2 (AI) with weapon %3 from %4m", _victimName, _killerName, _weapon, _distance];
			} else {
				_message = format["%1 was killed by %2 with weapon %3 from %4m",_victimName, _killerName, _weapon, _distance];
				_loc_message = format["PVP Event: %1 was killed by %2 with weapon %3 from %4m", _victimName, _killerName, _weapon, _distance];
			};
		};

		// build array to store death messages to allow viewing at message board in trader citys.
		_death_record = [
			_victimName,
			_killerName,
			_weapon,
			_distance,
			ServerCurrentTime
		];
		PlayerDeaths set [count PlayerDeaths,_death_record];

		if(DZE_DeathMsgGlobal) then { [nil, nil, rspawn, [_killer, _message], { (_this select 0) globalChat (_this select 1) }] call RE; };
		if(DZE_DeathMsgSide) then { [nil, nil, rspawn, [_killer, _message], { (_this select 0) sideChat (_this select 1) }] call RE; };
		if(DZE_DeathMsgTitleText) then { [nil,nil,"per",rTITLETEXT,_message,"PLAIN DOWN"] call RE; };
	};
} else {
	_message = format["%1 died of natural causes!",_victimName];
	_loc_message = format["Accidental Death: %1 died of natural causes!", _victimName];

	if(DZE_DeathMsgGlobal) then { [nil, nil, rspawn, [_victim, _message], { (_this select 0) globalChat (_this select 1) }] call RE; };
	if(DZE_DeathMsgSide) then { [nil, nil, rspawn, [_victim, _message], { (_this select 0) sideChat (_this select 1) }] call RE; };
	if(DZE_DeathMsgTitleText) then { [nil,nil,"per",rTITLETEXT,_message,"PLAIN DOWN"] call RE; };
};

// Cleanup
_victim setVariable["AttackedBy", "nil", true];
_victim setVariable["AttackedByName", "nil", true];
_victim setVariable["AttackedByWeapon", "nil", true];
_victim setVariable["AttackedFromDistance", "nil", true];
_victim setVariable["LastHit", "nil", true];

diag_log _loc_message;

_newObject setVariable["processedDeath",diag_tickTime];

if (typeName _minutes == "STRING") then
{
	_minutes = parseNumber _minutes;
};

if (_characterID != "0") then
{
	_key = format["CHILD:202:%1:%2:%3:",_characterID,_minutes,_infected];
	#ifdef DZE_SERVER_DEBUG_HIVE
	diag_log ("HIVE: WRITE: "+ str(_key));
	#endif
	_key call server_hiveWrite;
}
else
{
	deleteVehicle _newObject;
};

Enjoy!

 

R4duLIz.jpg

Link to comment
Share on other sites

  • Replies 52
  • Created
  • Last Reply

Top Posters In This Topic

For instances where the death message isn't accurate, it's USUALLY as a result of a single shot kill from an enemy (player, AI, etc). If you check the RPT logs, it'll have the PHIT displayed after the PKILL. Gonna try adding in a sleep into server_playerDied and see if that fixes things.

Link to comment
Share on other sites

Is this to fix the dead board in traders too ? (sorry - dont understand code language)

 

Nope. But the fix for that can be found on the official github. Since it is a client file and the current release (1051) has the bugged code you need to get it to your mission folder and change the compile path in your compiles.sqf.

Link to comment
Share on other sites

I replaced the two files and nothing has changed, no death messages.

 

Only guessing now – but if you get no kill message at all. You might want to look in your init.sqf to make sure you have:

 

DZE_DeathMsgGlobal = true;

DZE_DeathMsgSide = true;

DZE_DeathMsgTitleText = true;

 

‘X was killed by Y with weapon Z’ is the ‘advanced’ kill message – and I think the 3 lines need to be in the init.sqf for it to work.

Link to comment
Share on other sites

Nope. But the fix for that can be found on the official github. Since it is a client file and the current release (1051) has the bugged code you need to get it to your mission folder and change the compile path in your compiles.sqf.

 

Hi can someone please tell me what I am doing wrong here – I want to use the above fix for the dead boards

 

In my Init.sqf I have

call compile preprocessFileLineNumbers "custom\compiles.sqf";

In that compiles.sqf – I added this, to what was already there

player_murderMenu = compile preprocessFileLineNumbers "custom\player_murderMenu.sqf";

In my custom folder I have placed the player_murderMenu.sqf

 

I still only get the first kill on the dead board - so I must be doing something wrong  :(

Link to comment
Share on other sites

Hi can someone please tell me what I am doing wrong here – I want to use the above fix for the dead boards

 

In my Init.sqf I have

call compile preprocessFileLineNumbers "custom\compiles.sqf";

In that compiles.sqf – I added this, to what was already there

player_murderMenu = compile preprocessFileLineNumbers "custom\player_murderMenu.sqf";

In my custom folder I have placed the player_murderMenu.sqf

 

I still only get the first kill on the dead board - so I must be doing something wrong  :(

 

Looks good, to be sure - try this one. Works for us, but not sure if i made any other changes to make it work.

 

EpochDeathBoardDialogList = 21000;
EpochDeathBoardDialogSText = 21001;
EpochDeathBoardDeaths = [];

EpochDeathBoardLoad = {
    createdialog "EpochDeathBoardDialog";
    {
        lbAdd [EpochDeathBoardDialogList, (_x select 0)];
    } forEach PVDZE_plr_DeathBResult;
};

EpochDeathBoardClick = {
    disableSerialization;
    private ["_i", "_record", "_output", "_record_stxt", "_name", "_image", "_h", "_m", "_format","_quotes"];
    _quotes = [
        "Death is God's way of telling you not to be such a wise guy.",
        "What happens if you get scared half to death, twice?",
        "Don't upset me.. I'm running out of places to hide the bodies.",
        "Don't run, you'll just die tired.",
        "Give me immortality or give me death.",
        "I can't live with death; he's always leaving the toilet seat up.",
        "Why won't you die?!?!",
        "Guns don't kill people; death kills people. It's a proven medical fact."
    ];
    _i = _this select 0;
    if (_i < 0) exitWith {};
    _output = _this select 1;
    _record = PVDZE_plr_DeathBResult select _i;
    _record_stxt = call compile format["epoch_death_board_record_%1;",_i];
    if(isNil "_record_stxt") then {
        _record_stxt = format["<t size='1.6' align='left'>%1</t><br /><br />", (_record select 0)];

        _format = {
            private ["_codeCount", "_str"];
            _str = format["%1", _this];
            _codeCount = (count (toArray _str));
            if (_codeCount == 1) then {
                _str = format["0%1", _str];
            };
            _str;
        };
        _h = ((_record select 4) select 0)+timezoneswitch;
        _m = (_record select 4) select 1;
        
        _record_stxt = format["%1<t size='1' align='left'>Died at %2:%3</t><br /><br />", _record_stxt, (_h call _format), (_m call _format)];
        
        if ((_record select 1) != 'unknown') then {
            _record_stxt = format["%1<t size='1' align='left'>Was killed by %2</t><br /><br />", _record_stxt, (_record select 1)];
        };
        
        if ((_record select 2) != 'unknown') then {
            _name = getText(configFile >> "cfgWeapons" >> (_record select 2) >> "displayName");
            _image = getText(configFile >> "cfgWeapons" >> (_record select 2) >> "picture");
            _record_stxt = format["%1<t size='1' align='left'>With a %2<br /><img size='3' image='%3' /></t><br /><br />", _record_stxt, _name, _image];
        };
        
        if (format["%1", (_record select 3)] != 'unknown') then {
            _record_stxt = format["%1<t size='1' align='left'>At a distance of %2m</t><br /><br />", _record_stxt, (_record select 3)];
        };
        _record_stxt = format["%1<t font='Bitstream'>%2</t>", _record_stxt, (_quotes call BIS_fnc_selectRandom)];
        call compile format["epoch_death_board_record_%1 = ""%2"";" ,_i , _record_stxt];
    };
    _output ctrlSetStructuredText parseText _record_stxt;
};
Link to comment
Share on other sites

Nope. But the fix for that can be found on the official github. Since it is a client file and the current release (1051) has the bugged code you need to get it to your mission folder and change the compile path in your compiles.sqf.

 

Bugga still not working  :( I have a feeling that my error is in how I call the player_murderMenu.sqf in the compiles.sqf

Is this right ?


if (!isDedicated) then {
	player_build = compile preprocessFileLineNumbers "custom\snap_pro\player_build.sqf";
	snap_build = compile preprocessFileLineNumbers "custom\snap_pro\snap_build.sqf";
	dayz_spaceInterrupt = compile preprocessFileLineNumbers "custom\snap_pro\dayz_spaceInterrupt.sqf";
	player_murderMenu = compile preprocessFileLineNumbers "custom\player_murderMenu.sqf";
};
Link to comment
Share on other sites

Here you go

 

 

//Load in compiled functions
call compile preprocessFileLineNumbers "\z\addons\dayz_code\init\variables.sqf"; //Initilize the Variables (IMPORTANT: Must happen very early)
progressLoadingScreen 0.1;
call compile preprocessFileLineNumbers "\z\addons\dayz_code\init\publicEH.sqf"; //Initilize the publicVariable event handlers
progressLoadingScreen 0.2;
call compile preprocessFileLineNumbers "\z\addons\dayz_code\medical\setup_functions_med.sqf"; //Functions used by CLIENT for medical
progressLoadingScreen 0.4;
call compile preprocessFileLineNumbers "\z\addons\dayz_code\init\compiles.sqf"; //Compile regular functions
call compile preprocessFileLineNumbers "custom\compiles.sqf";                            //Compile custom compiles
progressLoadingScreen 0.5;
call compile preprocessFileLineNumbers "server_traders.sqf"; //Compile trader configs
progressLoadingScreen 1.0;
fnc_usec_selfActions = compile preprocessFileLineNumbers "clothes\fn_selfActions.sqf";
 

Link to comment
Share on other sites

Try this

if (!isDedicated) then {
	player_build = compile preprocessFileLineNumbers "custom\snap_pro\player_build.sqf";
	snap_build = compile preprocessFileLineNumbers "custom\snap_pro\snap_build.sqf";
	dayz_spaceInterrupt = compile preprocessFileLineNumbers "custom\snap_pro\dayz_spaceInterrupt.sqf";
	call compile preprocessFileLineNumbers "custom\player_murderMenu.sqf";
};
Link to comment
Share on other sites

I have one of my admins testing... she is using a m107 and it's triggering...

 

} else {
_message = format["%1 died of natural causes!",_victimName];
_loc_message = format["Accidental Death: %1 died of natural causes!", _victimName];
 
I haven't looked at the code enough myself... she's testing a non-one-shot gun now to see what happens.
 
Happening with every weapon she tries D:
 
Edit:  I see RPT error:
 
 
18:47:41 Error in expression < of natural causes!", _victimName];
 
if(DZE_DeathMsgGlobal) then { [nil, nil, rs>
18:47:41   Error position: <DZE_DeathMsgGlobal) then { [nil, nil, rs>
18:47:41   Error Undefined variable in expression: dze_deathmsgglobal
18:47:41 File z\addons\dayz_server\compile\server_playerDied.sqf, line 59
18:47:41 "Accidental Death: Big Papi died of natural causes!"

 

 

I just have DZE_DeathMsgGlobal = true; defined in variables.  Maybe I need to add the other as false lol.

Link to comment
Share on other sites

I have one of my admins testing... she is using a m107 and it's triggering...

 

} else {
_message = format["%1 died of natural causes!",_victimName];
_loc_message = format["Accidental Death: %1 died of natural causes!", _victimName];
 
I haven't looked at the code enough myself... she's testing a non-one-shot gun now to see what happens.
 
Happening with every weapon she tries D:
 
Edit:  I see RPT error:
 
 
18:47:41 Error in expression < of natural causes!", _victimName];
 
if(DZE_DeathMsgGlobal) then { [nil, nil, rs>
18:47:41   Error position: <DZE_DeathMsgGlobal) then { [nil, nil, rs>
18:47:41   Error Undefined variable in expression: dze_deathmsgglobal
18:47:41 File z\addons\dayz_server\compile\server_playerDied.sqf, line 59
18:47:41 "Accidental Death: Big Papi died of natural causes!"

 

 

I just have DZE_DeathMsgGlobal = true; defined in variables.  Maybe I need to add the other as false lol.

 

Define it in init.sqf instead, right at the top.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

  • Discord

×
×
  • Create New...