Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Converts projectile type into a human-readable base ammo type.
- STMF_DeathReport_GetMagazineType =
- {
- params ["_projectile"];
- private _type = switch(true) do
- {
- // Bullet
- case (_projectile isKindOf "BulletBase"): { "a bullet" };
- // Rocket
- case (_projectile isKindOf "RocketBase"): { "a rocket" };
- // Missile
- case (_projectile isKindOf "MissileBase"): { "a missile" };
- // Mine
- case ((_projectile isKindOf "MineBase") || (_projectile isKindOf "BoundingMineCore")): { "a mine" };
- // GP
- case (_projectile isKindOf "G_40mm_HE"): { "a rifle-propelled grenade" };
- // Grenade
- case (_projectile isKindOf "Grenade"): { "a grenade" };
- // Bomb
- case ((_projectile isKindOf "BombCore") || (_projectile isKindOf "TimeBombCore") || (_projectile isKindOf "DirectionalBombBase")): { "a bomb" };
- // Vehicle
- case (_projectile isEqualTo ""): { "a vehicle" };
- // Unknown
- default {"UNKNOWN"};
- };
- _type
- };
- // Log each damage report for later usage, as the "Killed" event handler doesn't track the projectile that caused damage.
- STMF_DeathReport_DamageEHCode =
- {
- private["_unit","_projectile"];
- params ["_unit", "", "", "", "_projectile"];
- if(alive _unit) then
- {
- // Store projectile used, locally
- _unit setVariable ["STMF_DeathReport_LastDamage", _projectile, false];
- };
- };
- // Make a death report in system chat when the player is killed, using the previously collected data from the damage handler.
- STMF_DeathReport_KilledEHCode =
- {
- if (STMF_R3_Active && STMF_SafeStart) exitWith {};
- params ["_unit", "_killer"];
- // Fetch last damage report and convert to human-readable format
- private _projectile = _unit getVariable ["STMF_DeathReport_LastDamage", "NONE"];
- private _type = [_projectile] call STMF_DeathReport_GetMagazineType;
- // If death was a road kill, add the vehicle type in brackets, rather than the ammo type
- if(_type == "a vehicle") then {_projectile = typeOf (vehicle _killer)};
- // Prepare message before we start the delay
- private _message = switch(true) do
- {
- // If it's self-harm, it's probably physics or suicide.
- case (_unit == _killer): { "You were either killed by a physics collision or yourself." };
- // If the killer doesn't exist or is on sideUnknown, it's probably an explosion. Or a ghost.
- case ((isNull _killer) || (side(group(_killer)) == sideUnknown)): { "You were killed by an exploding object." };
- // If everything is normal, relay all kill details to the player.
- default
- {
- private _name = _killer getVariable ["STMF_Name", name(_killer)];
- format [
- "You were killed by %1 from %2 metres away with %3 (%4), on team %5. You are on team %6."
- , _name, (round (_unit distance _killer))
- , _type, _projectile, side(group(_killer)), STMF_PlayerSide
- ];
- };
- };
- private _serverMessage = "";
- // Re-create message in third-person format, for server logging
- if (isPlayer(_unit)) then
- {
- // Output original message to player, delayed until in spectator
- [15, [_message, {systemChat _this}]] call STMF_CallInSeconds;
- _serverMessage = [_message, "You were", format ["%1 was", STMF_PlayerName]] call CBA_fnc_replace;
- _serverMessage = [_serverMessage, "You are", format ["%1 is", STMF_PlayerName]] call CBA_fnc_replace;
- _serverMessage = [_serverMessage, "yourself", "himself"] call CBA_fnc_replace;
- }
- else
- {
- _serverMessage = [_message, "You were", "AI was"] call CBA_fnc_replace;
- _serverMessage = [_serverMessage, "You are on team any", ""] call CBA_fnc_replace;
- };
- // Add prefix to server message
- _serverMessage = "STMF Death Report: " + _serverMessage;
- // Add suffix if potential FF
- if((side(group(_unit)) == side(group(_killer))) && (_unit != _killer)) then
- {
- _serverMessage = _serverMessage + " FF?";
- };
- // Output new message to server RPT
- ["deathrep", [_unit, _killer, _projectile, _serverMessage]] call CBA_fnc_serverEvent;
- };
- // See xeh.h for entry point
- STMF_DeathReport_Init =
- {
- params ["_unit"];
- _unit addEventHandler ["HandleDamage", {_this call STMF_DeathReport_DamageEHCode}];
- };
- if (isServer) then
- {
- ["deathrep", {diag_log [time, _this]; if (isPlayer (_this select 0)) then {[_this select 3] spawn STMF_AdminLog_AddEvent};}] call CBA_fnc_addEventHandler;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement