public static void Postfix(PlayerControl __instance, PlayerControl PAIBDFDMIGK, bool __state)
        {
            // Collect dead player info
            DeadPlayer deadPlayer = new DeadPlayer(PAIBDFDMIGK, DateTime.UtcNow, DeathReason.Kill, __instance);

            GameHistory.deadPlayers.Add(deadPlayer);

            // Reset killer to crewmate if __state
            if (__state)
            {
                __instance.Data.IsImpostor = false;
            }

            // Lover suicide trigger on murder
            if ((Lovers.lover1 != null && PAIBDFDMIGK == Lovers.lover1) || (Lovers.lover2 != null && PAIBDFDMIGK == Lovers.lover2))
            {
                PlayerControl otherLover = PAIBDFDMIGK == Lovers.lover1 ? Lovers.lover2 : Lovers.lover1;
                if (PlayerControl.LocalPlayer == PAIBDFDMIGK && otherLover != null && !otherLover.Data.IsDead && Lovers.bothDie)   // Only the dead lover sends the rpc
                {
                    MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.LoverSuicide, Hazel.SendOption.None, -1);
                    writer.Write(otherLover.PlayerId);
                    AmongUsClient.Instance.FinishRpcImmediately(writer);
                    RPCProcedure.loverSuicide(otherLover.PlayerId);
                }
            }

            // Child died
            if (Child.child != null && PAIBDFDMIGK == Child.child)
            {
                MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ChildDied, Hazel.SendOption.None, -1);
                AmongUsClient.Instance.FinishRpcImmediately(writer);
                RPCProcedure.childDied();
            }
        }
Example #2
0
        static void Postfix(VitalsMinigame __instance)
        {
            // Spy show time since death
            bool showSpyInfo = Spy.spy != null && Spy.spy == PlayerControl.LocalPlayer && Spy.spyTimer > 0;

            for (int k = 0; k < __instance.vitals.Length; k++)
            {
                VitalsPanel         vitalsPanel = __instance.vitals[k];
                GameData.PlayerInfo playerInfo  = GameData.Instance.AllPlayers[k];

                if (vitalsPanel.IsDead)
                {
                    DeadPlayer deadPlayer = deadPlayers?.Where(x => x.player?.PlayerId == playerInfo?.PlayerId)?.FirstOrDefault();
                    if (deadPlayer != null && deadPlayer.timeOfDeath != null)
                    {
                        float timeSinceDeath = ((float)(DateTime.UtcNow - deadPlayer.timeOfDeath).TotalMilliseconds);

                        if (showSpyInfo)
                        {
                            vitalsPanel.Text.Text = Math.Round(timeSinceDeath / 1000) + "s";
                        }
                        else
                        {
                            vitalsPanel.Text.Text = DestroyableSingleton <TranslationController> .Instance.GetString(Palette.ShortColorNames[(int)playerInfo.ColorId], new UnhollowerBaseLib.Il2CppReferenceArray <Il2CppSystem.Object>(0));
                        }
                    }
                }
            }
        }
        static void Postfix(PlayerControl __instance, GameData.PlayerInfo PAIBDFDMIGK)
        {
            // Medic report
            if (Medic.medic != null && Medic.medic == PlayerControl.LocalPlayer && __instance.PlayerId == Medic.medic.PlayerId)
            {
                DeadPlayer deadPlayer = deadPlayers?.Where(x => x.player?.PlayerId == PAIBDFDMIGK?.PlayerId)?.FirstOrDefault();

                if (deadPlayer != null && deadPlayer.killerIfExisting != null)
                {
                    float  timeSinceDeath = ((float)(DateTime.UtcNow - deadPlayer.timeOfDeath).TotalMilliseconds);
                    string msg            = "";

                    if (timeSinceDeath < Medic.reportNameDuration * 1000)
                    {
                        msg = $"Body Report: The killer appears to be {deadPlayer.killerIfExisting.name}! (Killed {Math.Round(timeSinceDeath / 1000)}s ago)";
                    }
                    else if (timeSinceDeath < Medic.reportColorDuration * 1000)
                    {
                        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 typeOfColor = colors[deadPlayer.killerIfExisting.Data.ColorId] ?? "unknown";
                        msg = $"Body Report: The killer appears to be a {typeOfColor} color. (Killed {Math.Round(timeSinceDeath / 1000)}s ago)";
                    }
                    else
                    {
                        msg = $"Body Report: The corpse is too old to gain information from. (Killed {Math.Round(timeSinceDeath / 1000)}s ago)";
                    }

                    if (!string.IsNullOrWhiteSpace(msg))
                    {
                        if (AmongUsClient.Instance.AmClient && DestroyableSingleton <HudManager> .Instance)
                        {
                            DestroyableSingleton <HudManager> .Instance.Chat.AddChat(PlayerControl.LocalPlayer, msg);
                        }
                        if (msg.IndexOf("who", StringComparison.OrdinalIgnoreCase) >= 0)
                        {
                            DestroyableSingleton <Assets.CoreScripts.Telemetry> .Instance.SendWho();
                        }
                    }
                }
            }
        }
 public static void bendTimeUpdate()
 {
     if (TimeMaster.isRewinding)
     {
         if (localPlayerPositions.Count > 0)
         {
             // Set position
             var next = localPlayerPositions[0];
             if (!PlayerControl.LocalPlayer.inVent)
             {
                 PlayerControl.LocalPlayer.transform.position = next.Item1;
             }
             localPlayerPositions.RemoveAt(0);
             if (localPlayerPositions.Count > 0)
             {
                 localPlayerPositions.RemoveAt(0);                                 // Skip every second position to rewinde in half the time
             }
             // Try reviving LOCAL player
             if (TimeMaster.reviveDuringRewind && PlayerControl.LocalPlayer.Data.IsDead)
             {
                 DeadPlayer deadPlayer = deadPlayers.Where(x => x.player == PlayerControl.LocalPlayer).FirstOrDefault();
                 if (deadPlayer != null && next.Item2 < deadPlayer.timeOfDeath)
                 {
                     MessageWriter write = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.TimeMasterRevive, SendOption.None, -1);
                     write.Write(PlayerControl.LocalPlayer.PlayerId);
                     AmongUsClient.Instance.FinishRpcImmediately(write);
                     RPCProcedure.timeMasterRevive(PlayerControl.LocalPlayer.PlayerId);
                 }
             }
         }
         else
         {
             TimeMaster.isRewinding                 = false;
             PlayerControl.LocalPlayer.moveable     = true;
             HudManager.Instance.FullScreen.enabled = false;
         }
     }
     else
     {
         while (localPlayerPositions.Count >= Mathf.Round(TimeMaster.rewindTime / Time.fixedDeltaTime))
         {
             localPlayerPositions.RemoveAt(localPlayerPositions.Count - 1);
         }
         localPlayerPositions.Insert(0, new Tuple <Vector3, DateTime>(PlayerControl.LocalPlayer.transform.position, DateTime.UtcNow));
     }
 }
Example #5
0
 public static void timeMasterRevive(byte playerId)
 {
     foreach (PlayerControl player in PlayerControl.AllPlayerControls)
     {
         if (player.PlayerId == playerId)
         {
             player.Revive();
             var        body            = UnityEngine.Object.FindObjectsOfType <DeadBody>().FirstOrDefault(b => b.ParentId == playerId);
             DeadPlayer deadPlayerEntry = deadPlayers.Where(x => x.player.PlayerId == playerId).FirstOrDefault();
             if (body != null)
             {
                 UnityEngine.Object.Destroy(body.gameObject);
             }
             if (deadPlayerEntry != null)
             {
                 deadPlayers.Remove(deadPlayerEntry);
             }
         }
     }
 }
        public static void Postfix(PlayerControl __instance)
        {
            // Collect dead player info
            DeadPlayer deadPlayer = new DeadPlayer(__instance, DateTime.UtcNow, DeathReason.Exile, null);

            GameHistory.deadPlayers.Add(deadPlayer);

            // Lover suicide trigger on exile
            if ((Lovers.lover1 != null && __instance == Lovers.lover1) || (Lovers.lover2 != null && __instance == Lovers.lover2))
            {
                PlayerControl otherLover = __instance == Lovers.lover1 ? Lovers.lover2 : Lovers.lover1;
                if (PlayerControl.LocalPlayer == __instance && otherLover != null && !otherLover.Data.IsDead && Lovers.bothDie)   // Only the dead lover sends the rpc
                {
                    MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.LoverSuicide, Hazel.SendOption.None, -1);
                    writer.Write(otherLover.PlayerId);
                    AmongUsClient.Instance.FinishRpcImmediately(writer);
                    RPCProcedure.loverSuicide(otherLover.PlayerId);
                }
            }
        }
        static void Postfix(VitalsMinigame __instance)
        {
            // Spy show time since death
            if (Spy.spy == null || Spy.spy != PlayerControl.LocalPlayer)
            {
                return;
            }
            for (int k = 0; k < __instance.vitals.Length; k++)
            {
                VitalsPanel         vitalsPanel = __instance.vitals[k];
                GameData.PlayerInfo playerInfo  = GameData.Instance.AllPlayers[k];

                if (vitalsPanel.IsDead)
                {
                    DeadPlayer deadPlayer = deadPlayers?.Where(x => x.player?.PlayerId == playerInfo?.PlayerId)?.FirstOrDefault();
                    if (deadPlayer != null && deadPlayer.timeOfDeath != null)
                    {
                        float timeSinceDeath = ((float)(DateTime.UtcNow - deadPlayer.timeOfDeath).TotalMilliseconds);
                        vitalsPanel.Text.Text = Math.Round(timeSinceDeath / 1000) + "s";
                    }
                }
            }
        }