Advertisement
Guest User

Untitled

a guest
Jan 18th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.50 KB | None | 0 0
  1. // Converts projectile type into a human-readable base ammo type.
  2. STMF_DeathReport_GetMagazineType =
  3. {
  4. params ["_projectile"];
  5.  
  6. private _type = switch(true) do
  7. {
  8.  
  9. // Bullet
  10. case (_projectile isKindOf "BulletBase"): { "a bullet" };
  11.  
  12. // Rocket
  13. case (_projectile isKindOf "RocketBase"): { "a rocket" };
  14.  
  15. // Missile
  16. case (_projectile isKindOf "MissileBase"): { "a missile" };
  17.  
  18. // Mine
  19. case ((_projectile isKindOf "MineBase") || (_projectile isKindOf "BoundingMineCore")): { "a mine" };
  20.  
  21. // GP
  22. case (_projectile isKindOf "G_40mm_HE"): { "a rifle-propelled grenade" };
  23.  
  24. // Grenade
  25. case (_projectile isKindOf "Grenade"): { "a grenade" };
  26.  
  27. // Bomb
  28. case ((_projectile isKindOf "BombCore") || (_projectile isKindOf "TimeBombCore") || (_projectile isKindOf "DirectionalBombBase")): { "a bomb" };
  29.  
  30. // Vehicle
  31. case (_projectile isEqualTo ""): { "a vehicle" };
  32.  
  33. // Unknown
  34. default {"UNKNOWN"};
  35. };
  36.  
  37. _type
  38. };
  39.  
  40.  
  41. // Log each damage report for later usage, as the "Killed" event handler doesn't track the projectile that caused damage.
  42. STMF_DeathReport_DamageEHCode =
  43. {
  44. private["_unit","_projectile"];
  45.  
  46. params ["_unit", "", "", "", "_projectile"];
  47.  
  48. if(alive _unit) then
  49. {
  50. // Store projectile used, locally
  51. _unit setVariable ["STMF_DeathReport_LastDamage", _projectile, false];
  52. };
  53. };
  54.  
  55.  
  56. // Make a death report in system chat when the player is killed, using the previously collected data from the damage handler.
  57. STMF_DeathReport_KilledEHCode =
  58. {
  59. if (STMF_R3_Active && STMF_SafeStart) exitWith {};
  60.  
  61. params ["_unit", "_killer"];
  62.  
  63. // Fetch last damage report and convert to human-readable format
  64. private _projectile = _unit getVariable ["STMF_DeathReport_LastDamage", "NONE"];
  65. private _type = [_projectile] call STMF_DeathReport_GetMagazineType;
  66.  
  67. // If death was a road kill, add the vehicle type in brackets, rather than the ammo type
  68. if(_type == "a vehicle") then {_projectile = typeOf (vehicle _killer)};
  69.  
  70. // Prepare message before we start the delay
  71. private _message = switch(true) do
  72. {
  73. // If it's self-harm, it's probably physics or suicide.
  74. case (_unit == _killer): { "You were either killed by a physics collision or yourself." };
  75.  
  76. // If the killer doesn't exist or is on sideUnknown, it's probably an explosion. Or a ghost.
  77. case ((isNull _killer) || (side(group(_killer)) == sideUnknown)): { "You were killed by an exploding object." };
  78.  
  79. // If everything is normal, relay all kill details to the player.
  80. default
  81. {
  82. private _name = _killer getVariable ["STMF_Name", name(_killer)];
  83. format [
  84. "You were killed by %1 from %2 metres away with %3 (%4), on team %5. You are on team %6."
  85. , _name, (round (_unit distance _killer))
  86. , _type, _projectile, side(group(_killer)), STMF_PlayerSide
  87. ];
  88. };
  89. };
  90.  
  91. private _serverMessage = "";
  92. // Re-create message in third-person format, for server logging
  93. if (isPlayer(_unit)) then
  94. {
  95. // Output original message to player, delayed until in spectator
  96. [15, [_message, {systemChat _this}]] call STMF_CallInSeconds;
  97.  
  98. _serverMessage = [_message, "You were", format ["%1 was", STMF_PlayerName]] call CBA_fnc_replace;
  99. _serverMessage = [_serverMessage, "You are", format ["%1 is", STMF_PlayerName]] call CBA_fnc_replace;
  100. _serverMessage = [_serverMessage, "yourself", "himself"] call CBA_fnc_replace;
  101. }
  102. else
  103. {
  104. _serverMessage = [_message, "You were", "AI was"] call CBA_fnc_replace;
  105. _serverMessage = [_serverMessage, "You are on team any", ""] call CBA_fnc_replace;
  106. };
  107.  
  108. // Add prefix to server message
  109. _serverMessage = "STMF Death Report: " + _serverMessage;
  110.  
  111. // Add suffix if potential FF
  112. if((side(group(_unit)) == side(group(_killer))) && (_unit != _killer)) then
  113. {
  114. _serverMessage = _serverMessage + " FF?";
  115. };
  116.  
  117. // Output new message to server RPT
  118. ["deathrep", [_unit, _killer, _projectile, _serverMessage]] call CBA_fnc_serverEvent;
  119. };
  120.  
  121. // See xeh.h for entry point
  122. STMF_DeathReport_Init =
  123. {
  124. params ["_unit"];
  125. _unit addEventHandler ["HandleDamage", {_this call STMF_DeathReport_DamageEHCode}];
  126. };
  127.  
  128. if (isServer) then
  129. {
  130. ["deathrep", {diag_log [time, _this]; if (isPlayer (_this select 0)) then {[_this select 3] spawn STMF_AdminLog_AddEvent};}] call CBA_fnc_addEventHandler;
  131. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement