<commit_before>// ******************************************************************************************
// * This project is licensed under the GNU Affero GPL v3. Copyright © 2014 A3Wasteland.com *
// ******************************************************************************************
//	@file Version: 1.0
//	@file Name: serverPlayerDied.sqf
//	@file Author: [404] Pulse, AgentRev
//	@file Created: 20/11/2012 05:19

if (!isServer) exitWith {};

private ["_unit", "_killer", "_presumedKiller", "_backpack"];

_unit = _this select 0;
_unit setVariable ["processedDeath", diag_tickTime];

// Remove player save on death
if (isPlayer _unit && {["A3W_playerSaving"] call isConfigOn}) then
{
	(getPlayerUID _unit) call fn_deletePlayerSave;
};

_killer = if (count _this > 1) then { _this select 1 } else { objNull };
_presumedKiller = if (count _this > 2) then { _this select 2 } else { objNull };

if !(_killer isKindOf "Man") then { _killer = effectiveCommander _killer };

// Score handling
if (isPlayer _killer) then
{
	_playerSide = side group _unit;
	_killerSide = side group _killer;
	_indyIndyKill = (_playerSide == _killerSide) && !(_playerSide in [BLUFOR,OPFOR]) && (group _unit != group _killer);

	_scoreColumn = if (isPlayer _unit) then { "playerKills" } else { "aiKills" };
	_scoreValue = if (_killerSide getFriend _playerSide < 0.6 || _indyIndyKill || (!isPlayer _unit && _playerSide == CIVILIAN)) then { 1 } else { -1 };

	[_killer, _scoreColumn, _scoreValue] call fn_addScore;

	if (isPlayer _presumedKiller && _presumedKiller != _unit) then
	{
		[_presumedKiller, "playerKills", 0] call fn_addScore; // sync Steam score
	};
};

if (isPlayer _unit) then
{
	[_unit, "deathCount", 1] call fn_addScore;
};

_backpack = unitBackpack _unit;

if (!isNull _backpack) then
{
	_backpack setVariable ["processedDeath", diag_tickTime];
};

// Eject corpse from vehicle once stopped
if (!isPlayer _unit && vehicle _unit != _unit) then
{
	_unit spawn
	{
		private "_veh";

		waitUntil
		{
			sleep 0.1;
			_veh = vehicle _this;
			(isTouchingGround _veh || (getPos _veh) select 2 < 5) && {vectorMagnitude velocity _veh < 5}
		};

		if (_veh != _this) then
		{
			_this setPos getPosATL _this; // ejects dead bodies<commit_msg>Eject corpses from vehicles<commit_after>// ******************************************************************************************
// * This project is licensed under the GNU Affero GPL v3. Copyright © 2014 A3Wasteland.com *
// ******************************************************************************************
//	@file Version: 1.0
//	@file Name: serverPlayerDied.sqf
//	@file Author: [404] Pulse, AgentRev
//	@file Created: 20/11/2012 05:19

if (!isServer) exitWith {};

private ["_unit", "_killer", "_presumedKiller", "_backpack"];

_unit = _this select 0;
_unit setVariable ["processedDeath", diag_tickTime];

// Remove player save on death
if (isPlayer _unit && {["A3W_playerSaving"] call isConfigOn}) then
{
	(getPlayerUID _unit) call fn_deletePlayerSave;
};

_killer = if (count _this > 1) then { _this select 1 } else { objNull };
_presumedKiller = if (count _this > 2) then { _this select 2 } else { objNull };

if !(_killer isKindOf "Man") then { _killer = effectiveCommander _killer };

// Score handling
if (isPlayer _killer) then
{
	_playerSide = side group _unit;
	_killerSide = side group _killer;
	_indyIndyKill = (_playerSide == _killerSide) && !(_playerSide in [BLUFOR,OPFOR]) && (group _unit != group _killer);

	_scoreColumn = if (isPlayer _unit) then { "playerKills" } else { "aiKills" };
	_scoreValue = if (_killerSide getFriend _playerSide < 0.6 || _indyIndyKill || (!isPlayer _unit && _playerSide == CIVILIAN)) then { 1 } else { -1 };

	[_killer, _scoreColumn, _scoreValue] call fn_addScore;

	if (isPlayer _presumedKiller && _presumedKiller != _unit) then
	{
		[_presumedKiller, "playerKills", 0] call fn_addScore; // sync Steam score
	};
};

if (isPlayer _unit) then
{
	[_unit, "deathCount", 1] call fn_addScore;
};

_backpack = unitBackpack _unit;

if (!isNull _backpack) then
{
	_backpack setVariable ["processedDeath", diag_tickTime];
};

// Eject corpse from vehicle once stopped
if (vehicle _unit != _unit) then
{
	_unit spawn
	{
		private "_veh";

		waitUntil
		{
			sleep 0.5;
			_veh = vehicle _this;
			isNull _this || ((isTouchingGround _veh || (getPos _veh) select 2 < 5) && {vectorMagnitude velocity _veh < 5})
		};

		if (_veh != _this) then
		{
			_this setPos ((getPosATL _this) vectorAdd ([[1 + random 1.5, 0, 0], -([_this, _veh] call BIS_fnc_dirTo)] call BIS_fnc_rotateVector2D)); // ejects dead bodies
{'fraction_non_alphanumeric': 0.19891186071817193, 'fraction_numerical': 0.018715995647442873, 'mean_word_length': 4.723536737235367, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7471093', 'n_tokens_mistral': 1662, 'n_tokens_neox': 1513, 'n_words': 460}