Advertisement
Jamchiv01

Script

Mar 29th, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 14.57 KB | None | 0 0
  1. /**
  2.  * ExileServer_object_player_event_onMpKilled
  3.  *
  4.  * Exile Mod
  5.  * www.exilemod.com
  6.  * © 2015 Exile Mod Team
  7.  *
  8.  * This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.
  9.  * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
  10.  */
  11.  
  12. private["_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"];
  13. if (!isServer || hasInterface) exitWith {};
  14. _victim = _this select 0;
  15. _killer = _this select 1;
  16. if( isNull _victim ) exitWith {};
  17. _victim setVariable ["ExileDiedAt", time];
  18. if !(isPlayer _victim) exitWith {};
  19. _victimPosition = getPos _victim;
  20. 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;
  21. format["deletePlayer:%1", _victim getVariable ["ExileDatabaseId", -1]] call ExileServer_system_database_query_fireAndForget;
  22. _victim setVariable ["ExileIsDead", true];
  23. _victim setVariable ["ExileName", name _victim, true];
  24. _victim call ExileServer_object_flies_spawn;
  25. _addDeathStat = true;
  26. _addKillStat = true;
  27. _normalkill = true;
  28. _killerRespectPoints = [];
  29. _fragAttributes = [];
  30. if (_victim isEqualTo _killer) then
  31. {
  32.     ["systemChatRequest", [format["%1 commited suicide!", (name _victim)]]] call ExileServer_object_player_event_killFeed;
  33. }
  34. else
  35. {
  36.     if (vehicle _victim isEqualTo _killer) then
  37.     {
  38.         ["systemChatRequest", [format["%1 crashed to death!", (name _victim)]]] call ExileServer_object_player_event_killfeed;
  39.     }
  40.     else
  41.     {
  42.         if (isNull _killer) then
  43.         {
  44.             ["systemChatRequest", [format["%1 died for an unknown reason!", (name _victim)]]] call ExileServer_object_player_event_killfeed;
  45.         }
  46.         else
  47.         {
  48.             _player = objNull;
  49.             if (isPlayer _killer) then
  50.             {
  51.                 if ((typeOf _killer) isEqualTo "Exile_Unit_Player") then
  52.                 {
  53.                     _player = _killer;
  54.                 }
  55.                 else
  56.                 {
  57.                     _uid = getPlayerUID _killer;
  58.                     {
  59.                         if ((getPlayerUID _x) isEqualTo _uid) exitWith
  60.                         {
  61.                             _player = _x;
  62.                         };
  63.                     }
  64.                     forEach allPlayers;
  65.                 };
  66.             }
  67.             else
  68.             {
  69.                 if (isUAVConnected _killer) then
  70.                 {
  71.                     _player = (UAVControl _killer) select 0;
  72.                 };
  73.             };
  74.  
  75.  
  76.             if !(isNull _player) then
  77.             {
  78.         if (_victim getVariable ["ExileIsBambi", false]) then
  79.                 {
  80.                     _addKillStat = false;
  81.                     _addDeathStat = false;
  82.                     _fragAttributes pushBack "Bambi Slayer";
  83.                     _killerRespectPoints pushBack ["BAMBI SLAYER", (getNumber (configFile >> "CfgSettings" >> "Respect" >> "Frags" >> "bambi"))];
  84.                 }
  85.                 else
  86.                 {
  87.           _respectPercentLoss = 0.988; //0.95 Looses 5% of ammount!
  88.           _PopTabsPercentLoss = 0.97; //0.95 Looses 5% of ammount!
  89.           _respectTaxLoss = 0.01; //Taxes 1% of ammount
  90.           _PopTabsTaxLoss = 0.02; //Taxes 2% of ammount
  91.  
  92.           _killer = _player;
  93.  
  94.           _KillerPopTabs = _killer getVariable ["ExileMoney", 0];
  95.           _KillerRespect = _killer getVariable ["ExileScore", 0];
  96.  
  97.           _VictimPopTabs = _victim getVariable ["ExileMoney", 0];
  98.           _VictimRespect = _victim getVariable ["ExileScore", 0];
  99.  
  100.           _newVictimPopTabs = round (_VictimPopTabs * _PopTabsPercentLoss); //FINAL READY TO SET BALANCE
  101.           _newVictimRespect = round(_VictimRespect * _respectPercentLoss); //FINAL READY TO SET BALANCE
  102.  
  103.           _LootPopTabs = round(_VictimPopTabs * (1-(_PopTabsPercentLoss + _PopTabsTaxLoss)));
  104.           _LootRespect = round(_VictimRespect * (1-(_respectPercentLoss + _respectTaxLoss)));
  105.  
  106.           _NewKillerPopTabs = round (_KillerPopTabs + _LootPopTabs); //FINAL READY TO SET BALANCE
  107.           _NewKillerRespect = round (_KillerRespect + _LootRespect); //FINAL READY TO SET BALANCE
  108.  
  109.           _victim setVariable ["ExileMoney", _newVictimPopTabs];
  110.           _victim setVariable ["ExileScore", _newVictimRespect];
  111.           format["setAccountMoney:%1:%2", _newVictimPopTabs, getPlayerUID _victim] call ExileServer_system_database_query_fireAndForget;
  112.           format["setAccountScore:%1:%2", _newVictimRespect, getPlayerUID _victim] call ExileServer_system_database_query_fireAndForget;
  113.  
  114.           _killer setVariable ["ExileMoney", _NewKillerPopTabs];
  115.           _killer setVariable ["ExileScore", _NewKillerRespect];
  116.           format["setAccountMoney:%1:%2", _NewKillerPopTabs, getPlayerUID _killer] call ExileServer_system_database_query_fireAndForget;
  117.           format["setAccountScore:%1:%2", _NewKillerRespect, getPlayerUID _killer] call ExileServer_system_database_query_fireAndForget;
  118.  
  119.           ["systemChatRequest", [format["%1 Lost %2 PopTabs and %3 Respect to %4", (name _victim), _LootPopTabs, _LootRespect, (name _killer)]]] call ExileServer_object_player_event_killfeed;
  120.  
  121.                     _grpvictim = _victim getVariable ["ExileGroup",(group _victim)];
  122.                     _grpkiller = _killer getVariable ["ExileGroup",(group _killer)];
  123.                     if((_grpvictim isEqualTo _grpkiller)&&!(ExileGraveyardGroup isEqualTo _grpkiller))then
  124.                     {
  125.                         _log = format["%2 was team-killed by %1!", (name _killer), (name _victim)];
  126.                         ["systemChatRequest", [_log]] call ExileServer_object_player_event_killfeed;
  127.                         _fragAttributes pushBack "Teamkill";
  128.                         _killerRespectPoints pushBack ["TEAMKILL", (getNumber (configFile >> "CfgSettings" >> "Respect" >> "Frags" >> "friendlyFire"))];
  129.                         _normalkill = false;
  130.                     }
  131.                     else
  132.                     {
  133.                         _lastVictims = _killer getVariable ["ExileLastVictims", ["0", "1", "2"]];
  134.                         _victimUID = _victim getVariable ["ExileOwnerUID", getPlayerUID _victim];
  135.                         if (_victimUID in _lastVictims) then
  136.                         {
  137.                             _log = format["%1 keeps killing %2!", (name _killer), (name _victim)];
  138.                             ["systemChatRequest", [_log]] call ExileServer_object_player_event_killfeed;
  139.                             _fragAttributes pushBack "Domination";
  140.                             _killerRespectPoints pushBack ["DOMINATION BONUS", (getNumber (configFile >> "CfgSettings" >> "Respect" >> "Frags" >> "domination"))];
  141.                         }
  142.                         else
  143.                         {
  144.                             _lastVictims deleteAt 0;
  145.                             _lastVictims pushBack _victimUID;
  146.                             _killer setVariable ["ExileLastVictims", _lastVictims];
  147.                             if ((vehicle _killer) isEqualTo _killer) then
  148.                             {
  149.                                 if ((currentWeapon _killer) isEqualTo "Exile_Melee_Axe") then
  150.                                 {
  151.                                     _fragAttributes pushBack "Humiliation";
  152.                                     _killerRespectPoints pushBack ["HUMILIATION", (getNumber (configFile >> "CfgSettings" >> "Respect" >> "Frags" >> "humiliation"))];
  153.                                 }
  154.                                 else
  155.                                 {
  156.                                     _killerRespectPoints pushBack ["ENEMY FRAGGED", (getNumber (configFile >> "CfgSettings" >> "Respect" >> "Frags" >> "standard"))];
  157.                                 };
  158.                             }
  159.                             else
  160.                             {
  161.                                 _vehicleRole = assignedVehicleRole _killer;
  162.                                 switch (toLower (_vehicleRole select 0)) do
  163.                                 {
  164.                                     case "driver":
  165.                                     {
  166.                                         _vehicle = vehicle _killer;
  167.                                         switch (true) do
  168.                                         {
  169.                                             case (_vehicle isKindOf "ParachuteBase"):
  170.                                             {
  171.                                                 _fragAttributes pushBack "Chute > Chopper";
  172.                                                 _killerRespectPoints pushBack ["CHUTE > CHOPPER", (getNumber (configFile >> "CfgSettings" >> "Respect" >> "Frags" >> "chuteGreaterChopper"))];
  173.                                             };
  174.                                             case (_vehicle isKindOf "Air"):
  175.                                             {
  176.                                                 _fragAttributes pushBack "Big Bird";
  177.                                                 _killerRespectPoints pushBack ["BIG BIRD", (getNumber (configFile >> "CfgSettings" >> "Respect" >> "Frags" >> "bigBird"))];
  178.                                             };
  179.                                             default
  180.                                             {
  181.                                                 _fragAttributes pushBack "Road Kill";
  182.                                                 _killerRespectPoints pushBack ["ROAD KILL", (getNumber (configFile >> "CfgSettings" >> "Respect" >> "Frags" >> "roadKill"))];
  183.                                             };
  184.                                         };
  185.                                     };
  186.                                     case "turret":
  187.                                     {
  188.                                         if ((currentWeapon _killer) isKindOf "StaticWeapon") then
  189.                                         {
  190.                                             _fragAttributes pushBack "Let it Rain";
  191.                                             _killerRespectPoints pushBack ["LET IT RAIN", (getNumber (configFile >> "CfgSettings" >> "Respect" >> "Frags" >> "letItRain"))];
  192.                                         }
  193.                                         else
  194.                                         {
  195.                                             _fragAttributes pushBack "Mad Passenger";
  196.                                             _killerRespectPoints pushBack ["MAD PASSENGER", (getNumber (configFile >> "CfgSettings" >> "Respect" >> "Frags" >> "passenger"))];
  197.                                         };
  198.                                     };
  199.                                     default
  200.                                     {
  201.                                         _fragAttributes pushBack "Mad Passenger";
  202.                                         _killerRespectPoints pushBack ["MAD PASSENGER", (getNumber (configFile >> "CfgSettings" >> "Respect" >> "Frags" >> "passenger"))];
  203.                                     };
  204.                                 };
  205.                             };
  206.                         };
  207.                     };
  208.                 };
  209.                 if (_addKillStat) then
  210.                 {
  211.                     if(_normalkill)then
  212.                     {
  213.                         _lastKillAt = _killer getVariable ["ExileLastKillAt", 0];
  214.                         _killStack = _killer getVariable ["ExileKillStack", 0];
  215.                         _killStack = _killStack + 1;
  216.                         if (isNil "ExileServerHadFirstBlood") then
  217.                         {
  218.                             ExileServerHadFirstBlood = true;
  219.                             _fragAttributes pushBack "First Blood";
  220.                             _killerRespectPoints pushBack ["FIRST BLOOD", getNumber (configFile >> "CfgSettings" >> "Respect" >> "Bonus" >> "firstBlood")];
  221.                         }
  222.                         else
  223.                         {
  224.                             if (time - _lastKillAt < (getNumber (configFile >> "CfgSettings" >> "Respect" >> "Bonus" >> "killStreakTimeout"))) then
  225.                             {
  226.                                 _fragAttributes pushBack (format ["%1x Kill Streak", _killStack]);
  227.                                 _killerRespectPoints pushBack [(format ["%1x KILL STREAK", _killStack]), _killStack * (getNumber (configFile >> "CfgSettings" >> "Respect" >> "Bonus" >> "killStreak"))];
  228.                             }
  229.                             else
  230.                             {
  231.                                 _killStack = 1;
  232.                             };
  233.                         };
  234.                         _killer setVariable ["ExileKillStack", _killStack];
  235.                         _killer setVariable ["ExileLastKillAt", time];
  236.                     };
  237.                     _distance = floor(_victim distance _killer);
  238.                     _fragAttributes pushBack (format ["%1m Distance", _distance]);
  239.                     _distanceBonus = (floor ((_distance min 3000) / 100)) * getNumber (configFile >> "CfgSettings" >> "Respect" >> "Bonus" >> "per100mDistance");
  240.                     if (_distanceBonus > 0) then
  241.                     {
  242.                         _killerRespectPoints pushBack [(format ["%1m RANGE BONUS", _distance]), _distanceBonus];
  243.                     };
  244.                     _flagNextToKiller = _killer call ExileClient_util_world_getTerritoryAtPosition;
  245.                     if !(isNull _flagNextToKiller) then
  246.                     {
  247.                         if ((getPlayerUID _killer) in (_flagNextToKiller getVariable ["ExileTerritoryBuildRights", []])) then
  248.                         {
  249.                             _homieBonus = getNumber (configFile >> "CfgSettings" >> "Respect" >> "Bonus" >> "homie");
  250.                             if (_homieBonus > 0) then
  251.                             {
  252.                                 _fragAttributes pushBack "Homie";
  253.                                 _killerRespectPoints pushBack ["HOMIE BONUS", _homieBonus];
  254.                             };
  255.                         };
  256.                     };
  257.                     _flagNextToVictim = _victim call ExileClient_util_world_getTerritoryAtPosition;
  258.                     if !(isNull _flagNextToVictim) then
  259.                     {
  260.                         if ((getPlayerUID _victim) in (_flagNextToVictim getVariable ["ExileTerritoryBuildRights", []])) then
  261.                         {
  262.                             _raidBonus = getNumber (configFile >> "CfgSettings" >> "Respect" >> "Bonus" >> "raid");
  263.                             if (_raidBonus > 0) then
  264.                             {
  265.                                 _fragAttributes pushBack "Raid";
  266.                                 _killerRespectPoints pushBack ["RAID BONUS", _raidBonus];
  267.                             };
  268.                         };
  269.                     };
  270.                 };
  271.                 _overallRespectChange = 0;
  272.                 {
  273.                     _overallRespectChange = _overallRespectChange + (_x select 1);
  274.                 }
  275.                 forEach _killerRespectPoints;
  276.                 _newKillerScore = _killer getVariable ["ExileScore", 0];
  277.                 _newKillerScore = _newKillerScore + _overallRespectChange;
  278.                 _killer setVariable ["ExileScore", _newKillerScore];
  279.                 format["setAccountScore:%1:%2", _newKillerScore,getPlayerUID _killer] call ExileServer_system_database_query_fireAndForget;
  280.                 if(_normalkill)then
  281.                 {
  282.                     _killMessage = format ["%1 was killed by %2", (name _victim), (name _killer)];
  283.                     if !(count _fragAttributes isEqualTo 0) then
  284.                     {
  285.                         _killMessage = _killMessage + " (" + (_fragAttributes joinString ", ") + ")";
  286.                     };
  287.                     ["systemChatRequest", [_killMessage]] call ExileServer_object_player_event_killfeed;
  288.                     if (_addKillStat isEqualTo true) then
  289.                     {
  290.                         _newKillerFrags = _killer getVariable ["ExileKills", 0];
  291.                         _newKillerFrags = _newKillerFrags + 1;
  292.                         _killer setVariable ["ExileKills", _newKillerFrags];
  293.                         format["addAccountKill:%1", getPlayerUID _killer] call ExileServer_system_database_query_fireAndForget;
  294.                     };
  295.                 };
  296.                 [_killer, "showFragRequest", [_killerRespectPoints]] call ExileServer_system_network_send_to;
  297.                 _killer call ExileServer_object_player_sendStatsUpdate;
  298.             }
  299.             else
  300.             {
  301.                 ["systemChatRequest", [format["%1 was killed by an NPC! (%2m Distance)", (name _victim), floor(_victim distance _killer)]]] call ExileServer_object_player_event_killfeed;
  302.  
  303.         _respectPercentLoss = 0.97; //0.92 Looses 8% of ammount!
  304.         _PopTabsPercentLoss = 0.95; //0.95 Looses 5% of ammount!
  305.  
  306.         _VictimPopTabs = _victim getVariable ["ExileMoney", 0];
  307.         _VictimRespect = _victim getVariable ["ExileScore", 0];
  308.  
  309.         _LootPopTabs = round(_VictimPopTabs * (1-(_PopTabsPercentLoss)));
  310.         _LootRespect = round(_VictimRespect * (1-(_respectPercentLoss)));
  311.  
  312.         _newVictimPopTabs = round (_VictimPopTabs * _PopTabsPercentLoss); //FINAL READY TO SET BALANCE
  313.         _newVictimRespect = round(_VictimRespect * _respectPercentLoss); //FINAL READY TO SET BALANCE
  314.  
  315.         _victim setVariable ["ExileMoney", _newVictimPopTabs];
  316.         _victim setVariable ["ExileScore", _newVictimRespect];
  317.         format["setAccountMoney:%1:%2", _newVictimPopTabs, getPlayerUID _victim] call ExileServer_system_database_query_fireAndForget;
  318.         format["setAccountScore:%1:%2", _newVictimRespect, getPlayerUID _victim] call ExileServer_system_database_query_fireAndForget;
  319.  
  320.         ["systemChatRequest", [format["%1 Lost %2 PopTabs and %3 Respect to %4", (name _victim), _LootPopTabs, _LootRespect, "An NPC LOL"]]] call ExileServer_object_player_event_killfeed;
  321.  
  322.             };
  323.         };
  324.     };
  325. };
  326. if (_addDeathStat isEqualTo true) then
  327. {
  328.     _newVictimDeaths = _victim getVariable ["ExileDeaths", 0];
  329.     _newVictimDeaths = _newVictimDeaths + 1;
  330.     _victim setVariable ["ExileDeaths", _newVictimDeaths];
  331.     format["addAccountDeath:%1", getPlayerUID _victim] call ExileServer_system_database_query_fireAndForget;
  332.     _victim call ExileServer_object_player_sendStatsUpdate;
  333. };
  334. [_victim] joinSilent ExileGraveyardGroup;
  335. true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement