Esempio n. 1
0
        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" },
                { 1, "darker" },
                { 2, "darker" },
                { 3, "lighter" },
                { 4, "lighter" },
                { 5, "lighter" },
                { 6, "darker" },
                { 7, "lighter" },
                { 8, "darker" },
                { 9, "darker" },
                { 10, "lighter" },
                { 11, "lighter" },
                { 12, "darker" },
                { 13, "darker" },
                { 14, "lighter" },
                { 15, "darker" },
                { 16, "lighter" },
                { 17, "lighter" },
                { 18, "lighter" },
                { 19, "lighter" },
            };
            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)");
        }
Esempio n. 2
0
        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);
            }
        }