public static string ParseBodyReport(BodyReport br) { //System.Console.WriteLine(br.KillAge); if (br.KillAge > CustomGameOptions.MedicReportColorDuration * 1000) { return ($"Body Report: The corpse is too old to gain information from. (Killed {Math.Round(br.KillAge / 1000)}s ago)"); } if (br.Killer.PlayerId == br.Body.PlayerId) { return ($"Body Report: The kill appears to have been a suicide! (Killed {Math.Round(br.KillAge / 1000)}s ago)"); } if (br.KillAge < CustomGameOptions.MedicReportNameDuration * 1000) { return ($"Body Report: The killer appears to be {br.Killer.Data.PlayerName}! (Killed {Math.Round(br.KillAge / 1000)}s ago)"); } var colors = new Dictionary <int, string> { { 0, "darker" }, // red { 1, "darker" }, // blue { 2, "darker" }, // green { 3, "lighter" }, // pink { 4, "lighter" }, // orange { 5, "lighter" }, // yellow { 6, "darker" }, // black { 7, "lighter" }, // white { 8, "darker" }, // purple { 9, "darker" }, // brown { 10, "lighter" }, // cyan { 11, "lighter" }, // lime { 12, "darker" }, // maroon { 13, "lighter" }, // rose { 14, "lighter" }, // banana { 15, "lighter" }, // gray { 16, "darker" }, // tan { 17, "lighter" }, // coral { 18, "darker" }, // watermelon { 19, "darker" }, // chocolate { 20, "lighter" }, // sky blue { 21, "darker" }, // beige { 22, "lighter" }, // hot pink { 23, "lighter" }, // turquoise { 24, "lighter" }, // lilac { 25, "lighter" }, // rainbow { 26, "lighter" }, // azure }; var typeOfColor = colors[br.Killer.Data.ColorId]; return ($"Body Report: The killer appears to be a {typeOfColor} color. (Killed {Math.Round(br.KillAge / 1000)}s ago)"); }
private static void Postfix(PlayerControl __instance, [HarmonyArgument(0)] GameData.PlayerInfo info) { //System.Console.WriteLine("Report Body!"); if (info == null) { return; } var matches = Murder.KilledPlayers.Where(x => x.PlayerId == info.PlayerId).ToArray(); DeadPlayer killer = null; if (matches.Length > 0) { //System.Console.WriteLine("RBOOF"); killer = matches[0]; } if (killer == null) { //System.Console.WriteLine("RBTWOOF"); return; } var isMedicAlive = __instance.Is(RoleEnum.Medic); var areReportsEnabled = CustomGameOptions.ShowReports; if (!isMedicAlive || !areReportsEnabled) { return; } var isUserMedic = PlayerControl.LocalPlayer.Is(RoleEnum.Medic); if (!isUserMedic) { return; } //System.Console.WriteLine("RBTHREEF"); var br = new BodyReport { Killer = Utils.PlayerById(killer.KillerId), Reporter = __instance, Body = Utils.PlayerById(killer.PlayerId), KillAge = (float)(DateTime.UtcNow - killer.KillTime).TotalMilliseconds }; //System.Console.WriteLine("FIVEF"); var reportMsg = BodyReport.ParseBodyReport(br); //System.Console.WriteLine("SIXTHF"); if (string.IsNullOrWhiteSpace(reportMsg)) { return; } //System.Console.WriteLine("SEFENFTH"); if (DestroyableSingleton <HudManager> .Instance) { // Send the message through chat only visible to the medic DestroyableSingleton <HudManager> .Instance.Chat.AddChat(PlayerControl.LocalPlayer, reportMsg); } }