static void Postfix(PlayerControl __instance, GameData.PlayerInfo CAKODNGLPDF) { System.Console.WriteLine("Report Body!"); var matches = killedPlayers.Where(x => x.PlayerId == CAKODNGLPDF.PlayerId).ToArray(); DeadPlayer killer = null; if (matches.Length > 0) { killer = matches[0]; } if (killer == null) { return; } var isMedicAlive = __instance.isPlayerRole("Medic"); var areReportsEnabled = Main.Config.showReport; if (!isMedicAlive || !areReportsEnabled) { return; } var isUserMedic = PlayerControl.LocalPlayer.isPlayerRole("Medic"); if (!isUserMedic) { return; } var br = new BodyReport { Killer = PlayerTools.getPlayerById(killer.KillerId), Reporter = __instance, KillAge = (float)(DateTime.UtcNow - killer.KillTime).TotalMilliseconds, DeathReason = killer.DeathReason }; var reportMsg = BodyReport.ParseBodyReport(br); if (string.IsNullOrWhiteSpace(reportMsg)) { return; } if (AmongUsClient.Instance.AmClient && DestroyableSingleton <HudManager> .Instance) { // Send the message through chat only visible to the medic DestroyableSingleton <HudManager> .Instance.Chat.AddChat(PlayerControl.LocalPlayer, reportMsg); } if (reportMsg.IndexOf("who", StringComparison.OrdinalIgnoreCase) >= 0) { // Really did not understand this DestroyableSingleton <Telemetry> .Instance.SendWho(); } }
public static string ParseBodyReport(BodyReport br) { var VisualTime = Math.Round(br.KillAge / 1000).ToString(CultureInfo.InvariantCulture); var Medic = MedicRole.INSTANCE; if (br.KillAge > Medic.KillerColorDuration * 1000) { return(LanguageManager.Get("er.medic.report.old") .Replace("%t", VisualTime)); } else if (br.DeathReason == (DeathReason)3) { return(LanguageManager.Get("er.medic.report.officer") .Replace("%t", VisualTime)); } else if (br.DeathReason == (DeathReason)4) { return(LanguageManager.Get("er.medic.report.zombie") .Replace("%t", VisualTime)); } else if (br.KillAge < Medic.KillerNameDuration * 1000) { return(LanguageManager.Get("er.medic.report.name") .Replace("%t", VisualTime) .Replace("%n", br.Killer.name)); } else { var Darker = LanguageManager.Get("er.darker"); var Lighter = LanguageManager.Get("er.lighter"); var Colors = new Dictionary <byte, string> { { 0, Darker }, { 1, Darker }, { 2, Darker }, { 3, Lighter }, { 4, Lighter }, { 5, Lighter }, { 6, Darker }, { 7, Lighter }, { 8, Darker }, { 9, Darker }, { 10, Lighter }, { 11, Lighter }, }; var ColorType = Colors[br.Killer.Data.ColorId]; return(LanguageManager.Get("er.medic.report.color") .Replace("%t", VisualTime) .Replace("%c", ColorType)); } }
static void Postfix(PlayerControl __instance, GameData.PlayerInfo CAKODNGLPDF) { System.Console.WriteLine("Report Body!"); DeadPlayer[] matches = killedPlayers.Where(x => x.PlayerId == CAKODNGLPDF.PlayerId).ToArray(); DeadPlayer killer = null; if (matches.Length > 0) { killer = matches[0]; } if (killer != null) { // If there is a Medic alive and Medic reported and reports are enabled if (__instance.isPlayerRole("Medic") && Main.Config.showReport) { // If the user is the medic if (PlayerControl.LocalPlayer.isPlayerRole("Medic")) { // Create Body Report BodyReport br = new BodyReport(); br.Killer = PlayerTools.getPlayerById(killer.KillerId); br.Reporter = __instance; br.KillAge = (float)(DateTime.UtcNow - killer.KillTime).TotalMilliseconds; br.DeathReason = killer.DeathReason; // Generate message var reportMsg = BodyReport.ParseBodyReport(br); // If message is not empty if (!string.IsNullOrWhiteSpace(reportMsg)) { if (AmongUsClient.Instance.AmClient && DestroyableSingleton <HudManager> .Instance) { // Send the message through chat only visible to the medic DestroyableSingleton <HudManager> .Instance.Chat.AddChat(PlayerControl.LocalPlayer, reportMsg); } if (reportMsg.IndexOf("who", StringComparison.OrdinalIgnoreCase) >= 0) { // Really did not understand this DestroyableSingleton <Telemetry> .Instance.SendWho(); } } } } } }
static void Postfix(PlayerControl __instance, GameData.PlayerInfo __0) { System.Console.WriteLine("Report Body!"); byte reporterId = __instance.PlayerId; DeadPlayer killer = killedPlayers.Where(x => x.PlayerId == __0.PlayerId).FirstOrDefault(); if (killer != null) { // If there is a Medic alive and Medic reported and reports are enabled if (PlayerControl.LocalPlayer.isPlayerRole(Role.Medic) && Main.Config.showReport) { // If the user is the medic if (PlayerControl.LocalPlayer.isPlayerRole(Role.Medic)) { // Create Body Report BodyReport br = new BodyReport(); br.Killer = PlayerTools.getPlayerById(killer.KillerId); br.Reporter = br.Killer = PlayerTools.getPlayerById(killer.KillerId); br.KillAge = (float)(DateTime.UtcNow - killer.KillTime).TotalMilliseconds; br.DeathReason = killer.DeathReason; // Generate message var reportMsg = BodyReport.ParseBodyReport(br); // If message is not empty if (!string.IsNullOrWhiteSpace(reportMsg)) { if (AmongUsClient.Instance.AmClient && DestroyableSingleton <HudManager> .Instance) { // Send the message through chat only visible to the medic DestroyableSingleton <HudManager> .Instance.Chat.AddChat(PlayerControl.LocalPlayer, reportMsg); } } } } } }