speedweasel

[Closed] Improved Kill Feed (for v0.9.6)

25 posts in this topic

****EDIT 3 July 2016****   *****As of Exile version 0.9.8 this script no longer works.  Please do not use.*****

I've tweaked ExileServer_object_player_event_onMpKilled to handle and report the following in the kill feed:

- Running over another player in a vehicle

- Getting killed by a Ryan Zombie

- The nearest town to the killing

- The weapon the killer used

- The optic the killer used (or "Iron sights" if no optic)

Spoiler

/**
 * ExileServer_object_player_event_onMpKilled
 *
 * Exile Mod
 * exile.majormittens.co.uk
 * © 2015 Exile Mod Team
 *
 * This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. 
 * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
 */
 
private["_killerVehicle","_weaponScopeDisplayName","_weaponScope","_weaponDisplayName","_zombieKill","_zombie","_bystanders","_weapon","_victimNear","_locationNames","_victim","_killer","_victimPosition","_addDeathStat","_addKillStat","_normalkill","_killerRespectPoints","_fragAttributes","_player","_grpvictim","_grpkiller","_log","_lastVictims","_victimUID","_vehicleRole","_vehicle","_lastKillAt","_killStack","_distance","_distanceBonus","_flagNextToKiller","_homieBonus","_flagNextToVictim","_raidBonus","_overallRespectChange","_newKillerScore","_killMessage","_newKillerFrags","_newVictimDeaths"];
if (!isServer || hasInterface) exitWith {};
_victim = _this select 0;
_killer = _this select 1;

diag_log format ["%1 killed %2", _killer, _victim];

if( isNull _victim ) exitWith {};
_victim setVariable ["ExileDiedAt", time];
if !(isPlayer _victim) exitWith {};
_victimPosition = getPos _victim;

_distance = floor(_victim distance _killer);

_locationNames = nearestLocations [getPos _victim, ["NameVillage","NameCity","NameCityCapital"], 4000];   
_victimNear = text (_locationNames select 0);

format["insertPlayerHistory:%1:%2:%3:%4:%5", getPlayerUID _victim, name _victim, _victimPosition select 0, _victimPosition select 1, _victimPosition select 2] call ExileServer_system_database_query_fireAndForget;
format["deletePlayer:%1", _victim getVariable ["ExileDatabaseId", -1]] call ExileServer_system_database_query_fireAndForget;
_victim setVariable ["ExileIsDead", true];
_victim setVariable ["ExileName", name _victim, true]; 
_victim call ExileServer_object_flies_spawn;
_addDeathStat = true;
_addKillStat = true;
_normalkill = true;
_killerRespectPoints = [];
_fragAttributes = [];
_zombieKill = false;

if (_victim isEqualTo _killer) then
{
    _bystanders = _victimPosition nearEntities ['Man',3];
    {_zombie = getText(configFile >> 'CfgVehicles' >> typeOf _x >> 'author') isEqualTo 'Ryan';
    if(_zombie)then
    {
        _zombieKill = true;
    };
    } forEach _bystanders;
    if (_zombieKill) then
    {
        ["systemChatRequest", [format["%1 was eaten by a zombie!", (name _victim)]]] call ExileServer_object_player_event_killFeed;            
    }
    else
    {
        ["systemChatRequest", [format["%1 committed suicide!", (name _victim)]]] call ExileServer_object_player_event_killFeed;
    };
}
else 
{
    if (vehicle _victim isEqualTo _killer) then
    {
        ["systemChatRequest", [format["%1 crashed!", (name _victim)]]] call ExileServer_object_player_event_killfeed;
    }
    else 
    {
        if (isNull _killer) then
        {
            ["systemChatRequest", [format["%1 died for an unknown reason.", (name _victim)]]] call ExileServer_object_player_event_killfeed;
        }
        else 
        {
            _player = objNull;
            if (isPlayer _killer) then 
            {
                if ((typeOf _killer) isEqualTo "Exile_Unit_Player") then
                {
                    _player = _killer;    
                }
                else 
                {
                    _uid = getPlayerUID _killer;
                    {
                        if ((getPlayerUID _x) isEqualTo _uid) exitWith 
                        {
                            _player = _x;
                        };
                    }
                    forEach allPlayers;
                };
            }
            else 
            {
                if (isUAVConnected _killer) then 
                {
                    _player = (UAVControl _killer) select 0;
                };
            };
            if !(isNull _player) then
            {
                _killer = _player;
                if (_victim getVariable ["ExileIsBambi", false]) then
                {
                    _addKillStat = false;
                    _addDeathStat = false;
                    _fragAttributes pushBack "Bambi Slayer";
                    _killerRespectPoints pushBack ["BAMBI SLAYER", (getNumber (configFile >> "CfgSettings" >> "Respect" >> "Frags" >> "bambi"))];
                }
                else 
                {
                    _grpvictim = _victim getVariable ["ExileGroup",(group _victim)];
                    _grpkiller = _killer getVariable ["ExileGroup",(group _killer)];
                    if((_grpvictim isEqualTo _grpkiller)&&!(ExileGraveyardGroup isEqualTo _grpkiller))then
                    {
                        _log = format["%2 was team-killed by %1!", (name _killer), (name _victim)];
                        ["systemChatRequest", [_log]] call ExileServer_object_player_event_killfeed;
                        _fragAttributes pushBack "Teamkill";
                        _killerRespectPoints pushBack ["TEAMKILL", (getNumber (configFile >> "CfgSettings" >> "Respect" >> "Frags" >> "friendlyFire"))];
                        _normalkill = false;
                    }
                    else
                    {
                        _lastVictims = _killer getVariable ["ExileLastVictims", ["0", "1", "2"]];
                        _victimUID = _victim getVariable ["ExileOwnerUID", getPlayerUID _victim];
                        if (_victimUID in _lastVictims) then
                        {
                            _log = format["%1 keeps killing %2!", (name _killer), (name _victim)];
                            ["systemChatRequest", [_log]] call ExileServer_object_player_event_killfeed;
                            _fragAttributes pushBack "Domination";
                            _killerRespectPoints pushBack ["DOMINATION BONUS", (getNumber (configFile >> "CfgSettings" >> "Respect" >> "Frags" >> "domination"))];
                        }
                        else
                        {
                            _lastVictims deleteAt 0;
                            _lastVictims pushBack _victimUID;
                            _killer setVariable ["ExileLastVictims", _lastVictims];
                            if ((vehicle _killer) isEqualTo _killer) then 
                            {
                                if ((currentWeapon _killer) isEqualTo "Exile_Melee_Axe") then
                                {
                                    _fragAttributes pushBack "Humiliation";
                                    _killerRespectPoints pushBack ["HUMILIATION", (getNumber (configFile >> "CfgSettings" >> "Respect" >> "Frags" >> "humiliation"))];
                                }
                                else 
                                {
                                    _killerRespectPoints pushBack ["ENEMY FRAGGED", (getNumber (configFile >> "CfgSettings" >> "Respect" >> "Frags" >> "standard"))];
                                };
                            }
                            else 
                            {
                                _vehicleRole = assignedVehicleRole _killer;
                                switch (toLower (_vehicleRole select 0)) do 
                                {
                                    case "driver":
                                    {
                                        _vehicle = vehicle _killer;
                                        switch (true) do 
                                        {
                                            case (_vehicle isKindOf "ParachuteBase"):
                                            {
                                                _fragAttributes pushBack "Chute > Chopper";
                                                _killerRespectPoints pushBack ["CHUTE > CHOPPER", (getNumber (configFile >> "CfgSettings" >> "Respect" >> "Frags" >> "chuteGreaterChopper"))];
                                            };
                                            case (_vehicle isKindOf "Air"):
                                            {
                                                _fragAttributes pushBack "Big Bird";
                                                _killerRespectPoints pushBack ["BIG BIRD", (getNumber (configFile >> "CfgSettings" >> "Respect" >> "Frags" >> "bigBird"))];
                                            };
                                            default 
                                            {
                                                _fragAttributes pushBack "Road Kill";
                                                _killerRespectPoints pushBack ["ROAD KILL", (getNumber (configFile >> "CfgSettings" >> "Respect" >> "Frags" >> "roadKill"))];
                                            };
                                        };
                                    };
                                    case "turret":
                                    {
                                        if ((currentWeapon _killer) isKindOf "StaticWeapon") then 
                                        {
                                            _fragAttributes pushBack "Let it Rain";
                                            _killerRespectPoints pushBack ["LET IT RAIN", (getNumber (configFile >> "CfgSettings" >> "Respect" >> "Frags" >> "letItRain"))];
                                        }
                                        else 
                                        {
                                            _fragAttributes pushBack "Mad Passenger";
                                            _killerRespectPoints pushBack ["MAD PASSENGER", (getNumber (configFile >> "CfgSettings" >> "Respect" >> "Frags" >> "passenger"))];
                                        };
                                    };
                                    default
                                    {
                                        _fragAttributes pushBack "Mad Passenger";
                                        _killerRespectPoints pushBack ["MAD PASSENGER", (getNumber (configFile >> "CfgSettings" >> "Respect" >> "Frags" >> "passenger"))];
                                    };
                                };
                            };                        
                        };
                    };
                };
                if (_addKillStat) then
                {
                    if(_normalkill)then
                    {
                        _lastKillAt = _killer getVariable ["ExileLastKillAt", 0];
                        _killStack = _killer getVariable ["ExileKillStack", 0];
                        _killStack = _killStack + 1;
                        if (isNil "ExileServerHadFirstBlood") then
                        {
                            ExileServerHadFirstBlood = true;
                            _fragAttributes pushBack "First Blood";
                            _killerRespectPoints pushBack ["FIRST BLOOD", getNumber (configFile >> "CfgSettings" >> "Respect" >> "Bonus" >> "firstBlood")];
                        }
                        else 
                        {
                            if (time - _lastKillAt < (getNumber (configFile >> "CfgSettings" >> "Respect" >> "Bonus" >> "killStreakTimeout"))) then
                            {
                                _fragAttributes pushBack (format ["%1x Kill Streak", _killStack]);
                                _killerRespectPoints pushBack [(format ["%1x KILL STREAK", _killStack]), _killStack * (getNumber (configFile >> "CfgSettings" >> "Respect" >> "Bonus" >> "killStreak"))];
                            }
                            else 
                            {
                                _killStack = 1; 
                            };
                        };
                        _killer setVariable ["ExileKillStack", _killStack];
                        _killer setVariable ["ExileLastKillAt", time];
                    };
//                    _distance = floor(_victim distance _killer);
                    _fragAttributes pushBack (format ["%1m Range", _distance]);
                    _distanceBonus = (floor ((_distance min 3000) / 100)) * getNumber (configFile >> "CfgSettings" >> "Respect" >> "Bonus" >> "per100mDistance");
                    if (_distanceBonus > 0) then
                    {
                        _killerRespectPoints pushBack [(format ["%1m RANGE BONUS", _distance]), _distanceBonus];
                    };
                    _flagNextToKiller = _killer call ExileClient_util_world_getTerritoryAtPosition;
                    if !(isNull _flagNextToKiller) then 
                    {
                        if ((getPlayerUID _killer) in (_flagNextToKiller getVariable ["ExileTerritoryBuildRights", []])) then
                        {
                            _homieBonus = getNumber (configFile >> "CfgSettings" >> "Respect" >> "Bonus" >> "homie");
                            if (_homieBonus > 0) then
                            {
                                _fragAttributes pushBack "Homie";
                                _killerRespectPoints pushBack ["HOMIE BONUS", _homieBonus];
                            };
                        };
                    };
                    _flagNextToVictim = _victim call ExileClient_util_world_getTerritoryAtPosition;
                    if !(isNull _flagNextToVictim) then 
                    {
                        if ((getPlayerUID _victim) in (_flagNextToVictim getVariable ["ExileTerritoryBuildRights", []])) then
                        {
                            _raidBonus = getNumber (configFile >> "CfgSettings" >> "Respect" >> "Bonus" >> "raid");
                            if (_raidBonus > 0) then
                            {
                                _fragAttributes pushBack "Raid";
                                _killerRespectPoints pushBack ["RAID BONUS", _raidBonus];
                            };
                        };
                    };
                };
                _overallRespectChange = 0;
                {
                    _overallRespectChange = _overallRespectChange + (_x select 1);
                }
                forEach _killerRespectPoints;
                _newKillerScore = _killer getVariable ["ExileScore", 0];
                _newKillerScore = _newKillerScore + _overallRespectChange;
                _killer setVariable ["ExileScore", _newKillerScore];
                format["setAccountScore:%1:%2", _newKillerScore,getPlayerUID _killer] call ExileServer_system_database_query_fireAndForget;
                if(_normalkill)then
                {
                    if (((vehicle _killer) != _killer) && (driver (vehicle _killer) == _killer)) then  // Killer is in a vehicle AND they are the driver
                    {
                        _killMessage = format ["%1 was run over by %2 near %3", (name _victim), (name _killer), (text _victimNear)];
                    }
                    else
                    {
                        _weapon = currentWeapon _killer;
                        _weaponDisplayName = getText (configfile >> "CfgWeapons" >> _weapon >> "displayName");
                        _weaponScope = ""; 
                        _weaponScope = _killer weaponAccessories currentMuzzle _killer select 2;
                        if (_weaponScope == "") then
                        {
                            _weaponScopeDisplayName = "Iron sights";
                        }
                        else
                        {
                            _weaponScopeDisplayName = getText (configfile >> "CfgWeapons" >> _weaponScope >> "displayName");
                        };
                        _killMessage = format ["%1 was killed by %2 with a %3 (%4) near %5", (name _victim), (name _killer), (text _weaponDisplayName), (text _weaponScopeDisplayName), (text _victimNear)];
                    };
                    if !(count _fragAttributes isEqualTo 0) then
                    {
                        _killMessage = _killMessage + " (" + (_fragAttributes joinString ", ") + ")";
                    };
                    ["systemChatRequest", [_killMessage]] call ExileServer_object_player_event_killfeed;
                    if (_addKillStat isEqualTo true) then
                    {
                        _newKillerFrags = _killer getVariable ["ExileKills", 0];
                        _newKillerFrags = _newKillerFrags + 1;
                        _killer setVariable ["ExileKills", _newKillerFrags];
                        format["addAccountKill:%1", getPlayerUID _killer] call ExileServer_system_database_query_fireAndForget;
                    };
                    
                };
                [_killer, "showFragRequest", [_killerRespectPoints]] call ExileServer_system_network_send_to;
                _killer call ExileServer_object_player_sendStatsUpdate;
            }
            else 
            {
                ["systemChatRequest", [format["%1 was killed by AI (%2m Range)", (name _victim), floor(_victim distance _killer)]]] call ExileServer_object_player_event_killfeed;
            };
        };
    };
};
if (_addDeathStat isEqualTo true) then
{
    _newVictimDeaths = _victim getVariable ["ExileDeaths", 0];
    _newVictimDeaths = _newVictimDeaths + 1;
    _victim setVariable ["ExileDeaths", _newVictimDeaths];
    format["addAccountDeath:%1", getPlayerUID _victim] call ExileServer_system_database_query_fireAndForget;
    _victim call ExileServer_object_player_sendStatsUpdate;
};
[_victim] joinSilent ExileGraveyardGroup;
true

 

Edited by speedweasel
  • Like 6

Share this post


Link to post
Share on other sites
Advertisement

Ah dude, you legend. I've been meaning to merge all of your work on this but you've gone and done it. :D Thank you!!

EDIT: Is this meant to be Muzzle when it's looking at Scopes or is it a typo?

_weaponScope = _killer weaponAccessories currentMuzzle _killer select 2;

 

Edited by kuplion
  • Like 1

Share this post


Link to post
Share on other sites

currentMuzzle returns the weapon name and 'select 2' pulls the optic from the array returned by weaponAccessories.

I tried currentWeapon for the same purpose but had trouble with it. Cant remember what it was now.

Either way, it's tested and working:)

  • Like 2

Share this post


Link to post
Share on other sites
30 minutes ago, kuplion said:

Haha, that's ok then. :) My apologies, it threw me when it said Muzzle so I figured I'd check. :)

I think I ended up with currentMuzzle after having issues with currentWeapon when the killer was occupying a static gun or a turret in an armed vehicle.  The code would return their rifle rather than the mounted weapon.  In the end I re-ordered the logic, shuffled some if-then-elses to better handle that problem.

  • Like 1

Share this post


Link to post
Share on other sites
8 hours ago, sCorporation said:

How we can install it?

Save my script in the OP to a file called ExileServer_object_player_event_onMpKilled.sqf and put it in a folder called "fixes" inside your mission folder (Exile.Altis or whatever map you are running)

Search Exile.Altis\config.cpp for "CfgExileCustomCode" and then insert the line below into that class:

ExileServer_object_player_event_onMpKilled = "fixes\ExileServer_object_player_event_onMpKilled.sqf";

You can overwrite the standard ExileServer_object_player_event_onMpKilled.sqf with my new one.

My CfgExileCustomCode class is shown below as an example.  I am running three custom sqf files:

class CfgExileCustomCode 
{
	/*
		You can overwrite every single file of our code without touching it.
		To do that, add the function name you want to overwrite plus the 
		path to your custom file here. If you wonder how this works, have a
		look at our bootstrap/fn_preInit.sqf function.

		Simply add the following scheme here:

		<Function Name of Exile> = "<New File Name>";

		Example:

		ExileClient_util_fusRoDah = "myaddon\myfunction.sqf";
	*/
	
	// Reduce size of map icons (speedweasel)
	ExileClient_gui_map_event_onDraw = "fixes\ExileClient_gui_map_event_onDraw.sqf";
	
	// Remove survival info that gives away base locations (speedweasel)
	ExileClient_gui_hud_showSurvivalInfo = "fixes\ExileClient_gui_hud_showSurvivalInfo.sqf";

	// Improved killfeed (speedweasel)
	ExileServer_object_player_event_onMpKilled = "fixes\ExileServer_object_player_event_onMpKilled.sqf";
	
};

Share this post


Link to post
Share on other sites

@speedweasel Interested to know what this is...

 

	// Remove survival info that gives away base locations (speedweasel)
	ExileClient_gui_hud_showSurvivalInfo = "fixes\ExileClient_gui_hud_showSurvivalInfo.sqf";

Share this post


Link to post
Share on other sites
38 minutes ago, Spackler said:

@speedweasel Interested to know what this is...

 


	// Remove survival info that gives away base locations (speedweasel)
	ExileClient_gui_hud_showSurvivalInfo = "fixes\ExileClient_gui_hud_showSurvivalInfo.sqf";

Haha, I was wondering the same thing. I'd hazard a guess that it removes the Territory/Area names showing up as the player moves across the map?

Edited by kuplion
  • Like 1

Share this post


Link to post
Share on other sites
Advertisement

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

  • Recently Browsing   0 members

    No registered users viewing this page.