diff --git a/dayz_server/compile/fnc_plyrHit.sqf b/dayz_server/compile/fnc_plyrHit.sqf index a2e0d0231..078672b7b 100644 --- a/dayz_server/compile/fnc_plyrHit.sqf +++ b/dayz_server/compile/fnc_plyrHit.sqf @@ -6,15 +6,21 @@ if (!isPlayer _victim || !isPlayer _attacker) exitWith {}; if ((name _victim) == (name _attacker)) exitWith {}; _weapon = weaponState _attacker; -if (_weapon select 0 == "Throw") then { +if (_weapon select 0 == "Throw") then +{ _weapon = _weapon select 3; -} else { +} +else +{ _weapon = _weapon select 0; }; _distance = _victim distance _attacker; +diag_log format["PHIT: %1 was hit by %2 with %3 from %4m", _victim, _attacker, _weapon, _distance]; + _victim setVariable["AttackedBy", _attacker, true]; _victim setVariable["AttackedByName", (name _attacker), true]; +//_victim setVariable["AttackedByWeapon", (currentWeapon _attacker), true]; _victim setVariable["AttackedByWeapon", _weapon, true]; _victim setVariable["AttackedFromDistance", _distance, true]; \ No newline at end of file diff --git a/dayz_server/compile/server_playerDied.sqf b/dayz_server/compile/server_playerDied.sqf index 8d786e3e0..ef6609aad 100644 --- a/dayz_server/compile/server_playerDied.sqf +++ b/dayz_server/compile/server_playerDied.sqf @@ -1,4 +1,4 @@ -private ["_characterID","_minutes","_newObject","_playerID","_key"]; +private["_characterID","_minutes","_newObject","_playerID","_playerName","_infected","_victim","_victimName","_killer","_killerName","_weapon","_distance","_message","_loc_message","_key","_eh","_body","_method","_name"]; //[unit, weapon, muzzle, mode, ammo, magazine, projectile] _characterID = _this select 0; _minutes = _this select 1; @@ -15,31 +15,45 @@ _victimName = _victim getVariable["bodyName", "nil"]; _killer = _victim getVariable["AttackedBy", "nil"]; _killerName = _victim getVariable["AttackedByName", "nil"]; -if (_killerName == "nil" || _victimName == _killerName) then { - _message = format["%1 Commited Suicide Or Was Killed By A Zombie",_victimName]; - _loc_message = format["KILLMSG: %1 Commited Suicide Or Was Killed By A Zombie", _victimName]; -} else { +// when a zombie kills a player _killer, _killerName and _weapon will be "nil" +// we can use this to determine a zombie kill and send a customized message for that. right now no killmsg means it was a zombie. +if (_killerName != "nil") then +{ _weapon = _victim getVariable["AttackedByWeapon", "nil"]; _distance = _victim getVariable["AttackedFromDistance", "nil"]; - _message = format["%1 Was Killed By %2 With A %3",_victimName, _killerName, _weapon]; - _loc_message = format["KILLMSG: %1 Was Killed By %2 With A %3 From %4m", _victimName, _killerName, _weapon, _distance]; + + if (_victimName == _killerName) then + { + _message = format["%1 killed himself",_victimName]; + _loc_message = format["PKILL: %1 killed himself", _victimName]; + } + else + { + _message = format["%1 was killed by %2 with weapon %3",_victimName, _killerName, _weapon]; + _loc_message = format["PKILL: %1 was killed by %2 with weapon %3 from %4m", _victimName, _killerName, _weapon, _distance]; + }; + + diag_log _loc_message; + [nil, nil, rspawn, [_killer, _message], { (_this select 0) globalChat (_this select 1) }] call RE; + //[nil, nil, rHINT, _message] call RE; + + // Cleanup + _victim setVariable["AttackedBy", "nil", true]; + _victim setVariable["AttackedByName", "nil", true]; + _victim setVariable["AttackedByWeapon", "nil", true]; + _victim setVariable["AttackedFromDistance", "nil", true]; }; -diag_log _loc_message; -//SHOW THE MESSAGE INGAME [GLOBAL CHAT] -[nil, nil, rspawn, [_victim, _message], { (_this select 0) globalChat (_this select 1) }] call RE; - -//SHOW THE MESSAGE INGAME [TITLE TEXT] -//[nil,nil,rTITLETEXT,_message,"PLAIN DOWN"] call RE; - -_victim setVariable["AttackedBy", "nil", true]; -_victim setVariable["AttackedByName", "nil", true]; -_victim setVariable["AttackedByWeapon", "nil", true]; -_victim setVariable["AttackedFromDistance", "nil", true]; - dayz_disco = dayz_disco - [_playerID]; _newObject setVariable["processedDeath",time]; +/* +diag_log ("DW_DEBUG: (isnil _characterID): " + str(isnil "_characterID")); +if (isnil "_characterID") then { +diag_log ("DW_DEBUG: _newObject: " + str(_newObject)); + }; +*/ + if (typeName _minutes == "STRING") then { _minutes = parseNumber _minutes; @@ -54,3 +68,17 @@ else { deleteVehicle _newObject; }; + +diag_log ("PDEATH: Player Died " + _playerID); +/* +_eh = [_newObject] spawn { + _body = _this select 0; + _method = _body getVariable["deathType","unknown"]; + _name = _body getVariable["bodyName","unknown"]; + waitUntil{!isPlayer _body;sleep 1}; + _body setVariable["deathType",_method,true]; + _body setVariable["bodyName",_name,true]; + diag_log ("PDEATH: Player Left Body " + _name); +}; +*/ +//dead_bodyCleanup set [count dead_bodyCleanup,_newObject]; diff --git a/dayz_server/compile/server_playerSetup.sqf b/dayz_server/compile/server_playerSetup.sqf index bf501b452..4e9796136 100644 --- a/dayz_server/compile/server_playerSetup.sqf +++ b/dayz_server/compile/server_playerSetup.sqf @@ -1,4 +1,4 @@ -private["_characterID","_playerObj","_playerID","_dummy","_worldspace","_state","_doLoop","_key","_primary","_medical","_stats","_humanity","_lastinstance","_randomSpot","_position","_debug","_distance","_hit","_fractures","_score","_findSpot","_mkr","_counter","_isNear","_isZero","_pos","_isIsland","_w","_clientID","_friendlies"]; +private["_characterID","_playerObj","_playerID","_dummy","_worldspace","_state","_doLoop","_key","_primary","_medical","_stats","_humanity","_lastinstance","_friendlies","_randomSpot","_position","_debug","_distance","_hit","_fractures","_score","_findSpot","_mkr","_counter","_isNear","_isZero","_pos","_isIsland","_w","_clientID"]; //Wait for HIVE to be free //diag_log ("SETUP: attempted with " + str(_this)); @@ -11,6 +11,7 @@ if (isNull _playerObj) exitWith { }; //Add MPHit event handler +diag_log("Adding MPHit EH for " + str(_playerObj)); _playerObj addMPEventHandler ["MPHit", {_this spawn fnc_plyrHit;}]; if (_playerID == "") then {