Advertisement
LostCoast

Untitled

Dec 23rd, 2018
400
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 8.85 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", "_instigator", "_countDeath", "_countKill", "_killSummary", "_killingPlayer", "_killType", "_oldVictimRespect", "_newVictimRespect", "_oldKillerRespect", "_newKillerRespect", "_unknownReasons", "_systemChat", "_modifyVictimRespect", "_respectLoss", "_perks", "_minRespectTransfer", "_respectTransfer", "_perkNames", "_killerStatsNeedUpdate", "_newKillerFrags", "_victimStatsNeedUpdate", "_newVictimDeaths", "_victimPosition"];
  13. _victim = _this select 0;
  14. _killer = _this select 1;
  15. _instigator = _this select 2;
  16. if (!isServer || hasInterface || isNull _victim) exitWith {};
  17. _victim setVariable ["ExileDiedAt", time];
  18. if !(isPlayer _victim) exitWith {};
  19. _victim setVariable ["ExileIsDead", true];
  20. _victim setVariable ["ExileName", name _victim, true];
  21. _countDeath = false;
  22. _countKill = false;
  23. _killSummary = [];
  24. _killingPlayer = _killer call ExileServer_util_getFragKiller;
  25. _killType = [_victim, _killer, _killingPlayer, _instigator] call ExileServer_util_getFragType;
  26. _oldVictimRespect = _victim getVariable ["ExileScore", 0];
  27. _newVictimRespect = _oldVictimRespect;
  28. _oldKillerRespect = 0;
  29. if !(isNull _killingPlayer) then
  30. {
  31.     _oldKillerRespect = _killingPlayer getVariable ["ExileScore", 0];
  32. };
  33. _newKillerRespect = _oldKillerRespect;
  34. switch (_killType) do
  35. {
  36.     default
  37.     {
  38.         _unknownReasons =
  39.         [
  40.             "%1 died because... Arma.",
  41.             "%1 died because the universe hates him.",
  42.             "%1 died a mysterious death.",
  43.             "%1 died and nobody knows why.",
  44.             "%1 died because that's why.",
  45.             "%1 died because %1 was very unlucky.",
  46.             "%1 died due to Arma bugs and is probably very salty right now.",
  47.             "%1 died an awkward death.",
  48.             "%1 died. Yes, %1 is dead. Like really dead-dead."
  49.         ];
  50.         _countDeath = true;
  51.         _systemChat = format [selectRandom _unknownReasons, name _victim];
  52.         _newVictimRespect = _oldVictimRespect - round ((abs _oldVictimRespect) / 100 * (getNumber (configFile >> "CfgSettings" >> "Respect" >> "Percentages" >> "unlucky")));
  53.     };
  54.     case 1:
  55.     {
  56.         _countDeath = true;
  57.         _modifyVictimRespect = true;
  58.         _systemChat = format ["%1 commited suicide!", name _victim];
  59.         _newVictimRespect = _oldVictimRespect - round ((abs _oldVictimRespect) / 100 * (getNumber (configFile >> "CfgSettings" >> "Respect" >> "Percentages" >> "suicide")));
  60.     };
  61.     case 2:
  62.     {
  63.         _countDeath = true;
  64.         _countKill = false;
  65.         _systemChat = format ["%1 died while playing Russian Roulette!", name _victim];
  66.         _newVictimRespect = _oldVictimRespect;
  67.         _victim call ExileServer_system_russianRoulette_event_onPlayerDied;
  68.     };
  69.     case 3:
  70.     {
  71.         _countDeath = true;
  72.         _countKill = false;
  73.         _systemChat = format ["%1 crashed to death!", name _victim];
  74.         _newVictimRespect = _oldVictimRespect - round ((abs _oldVictimRespect) / 100 * (getNumber (configFile >> "CfgSettings" >> "Respect" >> "Percentages" >> "crash")));
  75.     };
  76.     case 4:
  77.     {
  78.         _countDeath = true;
  79.         _countKill = false;
  80.         _systemChat = format ["%1 was killed by an NPC!", name _victim];
  81.         _newVictimRespect = _oldVictimRespect - round ((abs _oldVictimRespect) / 100 * (getNumber (configFile >> "CfgSettings" >> "Respect" >> "Percentages" >> "npc")));
  82.     };
  83.     case 5:
  84.     {
  85.         _countDeath = false;
  86.         _countKill = false;
  87.         _systemChat = format ["%1 was team-killed by %2!", name _victim, name _killingPlayer];
  88.         _respectLoss = round ((abs _oldKillerRespect) / 100 * (getNumber (configFile >> "CfgSettings" >> "Respect" >> "Percentages" >> "friendyFire")));
  89.         _newKillerRespect = _oldKillerRespect - _respectLoss;
  90.         _killSummary pushBack ["FRIENDLY FIRE", -1 * _respectLoss];
  91.     };
  92.     case 6:
  93.     {
  94.         _countDeath = false;
  95.         _countKill = false;
  96.         _systemChat = format ["%1 was killed by %2! (BAMBI SLAYER)", name _victim, name _killingPlayer];
  97.         _respectLoss = round ((abs _oldKillerRespect) / 100 * (getNumber (configFile >> "CfgSettings" >> "Respect" >> "Percentages" >> "bambiKill")));
  98.         _newKillerRespect = _oldKillerRespect - _respectLoss;
  99.         _killSummary pushBack ["BAMBI SLAYER", -1 * _respectLoss];
  100.     };
  101.     case 7:
  102.     {
  103.         _countDeath = true;
  104.         _countKill = true;
  105.         _perks = [_victim, _killer, _killingPlayer] call ExileServer_util_getFragPerks;
  106.         _minRespectTransfer = getNumber (configFile >> "CfgSettings" >> "Respect" >> "minRespectTransfer");
  107.         _respectTransfer = round ((abs _oldVictimRespect) / 100 * (getNumber (configFile >> "CfgSettings" >> "Respect" >> "Percentages" >> "frag")));
  108.         if (_respectTransfer < _minRespectTransfer) then
  109.         {
  110.             _respectTransfer = _minRespectTransfer;
  111.         };
  112.         _newVictimRespect = _oldVictimRespect - _respectTransfer;
  113.         _newKillerRespect = _oldKillerRespect + _respectTransfer;
  114.         _killSummary pushBack ["ENEMY FRAGGED", _respectTransfer];
  115.         if (_perks isEqualTo []) then
  116.         {
  117.             _systemChat = format ["%1 was killed by %2!", name _victim, name _killingPlayer];
  118.         }
  119.         else
  120.         {
  121.             _perkNames = [];
  122.             {
  123.                 _perkNames pushBack (_x select 0);
  124.                 _killSummary pushBack _x;
  125.                 _newKillerRespect = _newKillerRespect + (_x select 1);
  126.             }
  127.             forEach _perks;
  128.             _systemChat = format ["%1 was killed by %2! (%3)", name _victim, name _killingPlayer, _perkNames joinString ", "];
  129.         };
  130.     };
  131. };
  132. if !(isNull _killingPlayer) then
  133. {
  134.     if !(_killSummary isEqualTo []) then
  135.     {  
  136.         [_killingPlayer, "showFragRequest", [_killSummary]] call ExileServer_system_network_send_to;
  137.     };
  138. };
  139. if !(isNull _killingPlayer) then
  140. {
  141.     _killerStatsNeedUpdate = false;
  142.     if (_countKill) then
  143.     {
  144.         _newKillerFrags = _killingPlayer getVariable ["ExileKills", 0];
  145.         _newKillerFrags = _newKillerFrags + 1;
  146.         _killerStatsNeedUpdate = true;
  147.         _killingPlayer setVariable ["ExileKills", _newKillerFrags];
  148.         format["addAccountKill:%1", getPlayerUID _killingPlayer] call ExileServer_system_database_query_fireAndForget;
  149.     };
  150.     if !(_newKillerRespect isEqualTo _oldKillerRespect) then
  151.     {
  152.         _killingPlayer setVariable ["ExileScore", _newKillerRespect];
  153.         _killerStatsNeedUpdate = true;
  154.         format["setAccountScore:%1:%2", _newKillerRespect, getPlayerUID _killingPlayer] call ExileServer_system_database_query_fireAndForget;
  155.     };
  156.     if (_killerStatsNeedUpdate) then
  157.     {
  158.         _killingPlayer call ExileServer_object_player_sendStatsUpdate;
  159.     };
  160. };
  161. _victimStatsNeedUpdate = false;
  162. if (_countDeath) then
  163. {
  164.     _newVictimDeaths = _victim getVariable ["ExileDeaths", 0];
  165.     _newVictimDeaths = _newVictimDeaths + 1;
  166.     _victim setVariable ["ExileDeaths", _newVictimDeaths];
  167.     _victimStatsNeedUpdate = true;
  168.     format["addAccountDeath:%1", getPlayerUID _victim] call ExileServer_system_database_query_fireAndForget;
  169. };
  170. if !(_newVictimRespect isEqualTo _oldVictimRespect) then
  171. {
  172.     _victim setVariable ["ExileScore", _newVictimRespect];
  173.     _victimStatsNeedUpdate = true;
  174.     format["setAccountScore:%1:%2", _newVictimRespect, getPlayerUID _victim] call ExileServer_system_database_query_fireAndForget;
  175. };
  176. if (_victimStatsNeedUpdate) then
  177. {
  178.     _victim call ExileServer_object_player_sendStatsUpdate;
  179. };
  180. if ((vehicle _victim) isEqualTo _victim) then
  181. {
  182.     if !(underwater _victim) then
  183.     {
  184.         if !(_victim call ExileClient_util_world_isInTraderZone) then
  185.         {
  186.             _victim call ExileServer_object_flies_spawn;
  187.         };
  188.     };
  189. };
  190. if !(_systemChat isEqualTo "") then
  191. {
  192.     if ((getNumber (configFile >> "CfgSettings" >> "KillFeed" >> "showKillFeed")) isEqualTo 1) then
  193.     {
  194.         ["systemChatRequest", [_systemChat]] call ExileServer_system_network_send_broadcast;
  195.     };
  196. };
  197. if !(_systemChat isEqualTo "") then
  198. {
  199.     if ((getNumber (configFile >> "CfgSettings" >> "Logging" >> "deathLogging")) isEqualTo 1) then
  200.     {
  201.         "extDB2" callExtension format["1:DEATH:%1", _systemChat];
  202.     };
  203. };
  204. if (getNumber(configFile >> "CfgSettings" >> "Escape" >> "enableEscape") isEqualTo 1) then
  205. {
  206.     [_killer, _victim, _killType] spawn ExileServer_system_escape_deathCheck;
  207. }
  208. else
  209. {
  210.     _victimPosition = getPos _victim;
  211.     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;
  212.     format["deletePlayer:%1", _victim getVariable ["ExileDatabaseId", -1]] call ExileServer_system_database_query_fireAndForget;
  213. };
  214.  
  215. _uidKiller = 1;
  216. if(isPlayer _killer)then{
  217. _uidKiller = getPlayerUID _killer;
  218. };
  219.  
  220. _uidVictim = 1;
  221. if(isPlayer _victim)then{
  222. _uidVictim = getPlayerUID _victim;
  223. };
  224.  
  225. if!((isNull _killer) && (isNull _victim))then{
  226.    format["createKillsInfo:%1:%2:%3:%4:%5:%6:%7:%8:%9", _uidKiller, _uidVictim, name _killer, name _victim, currentWeapon _killer, _victim distance _killer, _victimPosition select 0, _victimPosition select 1, _victimPosition select 2] call ExileServer_system_database_query_fireAndForget;
  227. };
  228. true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement