Exemple #1
0
            static bool Prefix(ref KillButtonManager __instance)
            {
                if (IsSheriff(PlayerControl.LocalPlayer.PlayerId) && __instance.isActiveAndEnabled &&
                    __instance.CurrentTarget && !__instance.isCoolingDown &&
                    !PlayerControl.LocalPlayer.Data.IsImpostor && PlayerControl.LocalPlayer.CanMove)
                {
                    if (__instance.CurrentTarget.Data.IsImpostor) // target is an impostor
                    {
                        PlayerControl_FixedUpdate.RpcSheriffKill(PlayerControl.LocalPlayer,
                                                                 __instance.CurrentTarget.PlayerId);
                    }
                    else
                    {
                        if (CustomGameOptionsData.customGameOptions.doKillSheriffsTarget.value)
                        {
                            // TODO: uhm
                            PlayerControl_FixedUpdate.RpcSheriffKill(__instance.CurrentTarget,
                                                                     __instance.CurrentTarget.PlayerId);
                        }

                        PlayerControl_FixedUpdate.RpcSheriffKill(PlayerControl.LocalPlayer,
                                                                 PlayerControl.LocalPlayer.PlayerId);
                    }

                    __instance.SetTarget(null);
                    return(false);
                }

                return(true);
            }
Exemple #2
0
        public void CheckShieldButton(HudManager instance)
        {
            if (instance.UseButton == null || !instance.UseButton.isActiveAndEnabled || player.Data.IsDead)
            {
                return;
            }

            KillButtonManager killButton = instance.KillButton;

            killButton.gameObject.SetActive(true);
            killButton.renderer.enabled = true;
            killButton.isActive         = true;
            killButton.renderer.sprite  = specialButton;
            killButton.SetTarget(!shieldUsed ? PlayerTools.FindClosestTarget(player) : null);
        }
Exemple #3
0
        public static void SetTarget(
            ref PlayerControl closestPlayer,
            KillButtonManager button,
            float maxDistance            = float.NaN,
            List <PlayerControl> targets = null
            )
        {
            if (!button.isActiveAndEnabled)
            {
                return;
            }

            button.SetTarget(
                SetClosestPlayer(ref closestPlayer, maxDistance, targets)
                );
        }
 public static bool Prefix(KillButtonManager __instance)
 {
     if (__instance.isActiveAndEnabled && __instance.CurrentTarget && !__instance.isCoolingDown && !PlayerControl.LocalPlayer.PPMOEEPBHJO.IAGJEKLJCCI && PlayerControl.LocalPlayer.POECPOEKKNO) // Among Us default checks
     {
         if (Helpers.handleMurderAttempt(__instance.CurrentTarget))                                                                                                                             // Custom checks
         {
             if (Child.child != null && PlayerControl.LocalPlayer == Child.child)                                                                                                               // Not checked by official servers
             {
                 MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.UncheckedMurderPlayer, Hazel.SendOption.Reliable, -1);
                 writer.Write(PlayerControl.LocalPlayer.PlayerId);
                 writer.Write(__instance.CurrentTarget.PlayerId);
                 AmongUsClient.Instance.FinishRpcImmediately(writer);
                 RPCProcedure.uncheckedMurderPlayer(PlayerControl.LocalPlayer.PlayerId, __instance.CurrentTarget.PlayerId);
             }
             else     // Checked by official servers
             {
                 PlayerControl.LocalPlayer.RpcMurderPlayer(__instance.CurrentTarget);
             }
             __instance.SetTarget(null);
         }
     }
     return(false);
 }
Exemple #5
0
        private static void UpdateKillButton(HudManager __instance)
        {
            KillButton = __instance.KillButton;
            if (PlayerControl.AllPlayerControls.Count <= 1)
            {
                return;
            }
            if (PlayerControl.LocalPlayer == null)
            {
                return;
            }
            if (PlayerControl.LocalPlayer.Data == null)
            {
                return;
            }
            var flag7 = PlayerControl.AllPlayerControls.Count > 1 & Utils.Sheriff != null;

            if (!flag7)
            {
                return;
            }
            var flag8 = PlayerControl.LocalPlayer.isSheriff();

            if (flag8)
            {
                var isDead = PlayerControl.LocalPlayer.Data.IsDead;
                if (isDead)
                {
                    KillButton.gameObject.SetActive(false);
                    KillButton.isActive = false;
                }
                else
                {
                    KillButton.gameObject.SetActive(true);
                    KillButton.isActive = true;
                    KillButton.SetCoolDown(Methods.SheriffKillTimer(), PlayerControl.GameOptions.KillCooldown + 15f);
                    Methods.ClosestPlayer = Methods.getClosestPlayer(PlayerControl.LocalPlayer);
                    var distBetweenPlayers = Methods.getDistBetweenPlayers(PlayerControl.LocalPlayer, Methods.ClosestPlayer);
                    var flag9 = distBetweenPlayers < GameOptionsData.KillDistances[PlayerControl.GameOptions.KillDistance];
                    if (flag9)
                    {
                        KillButton.SetTarget(Methods.ClosestPlayer);
                    }
                }
            }
            else
            {
                var isImpostor = PlayerControl.LocalPlayer.Data.IsImpostor;
                if (!isImpostor)
                {
                    return;
                }
                var isDead2 = PlayerControl.LocalPlayer.Data.IsDead;
                if (isDead2)
                {
                    KillButton.gameObject.SetActive(false);
                    KillButton.isActive = false;
                }
                else
                {
                    __instance.KillButton.gameObject.SetActive(true);
                    __instance.KillButton.isActive = true;
                }
            }
        }
        public static bool Prefix(KillButtonManager __instance)
        {
            var flag = PlayerControl.LocalPlayer.Is(RoleEnum.Arsonist);

            if (!flag)
            {
                return(true);
            }
            if (PlayerControl.LocalPlayer.Data.IsDead)
            {
                return(false);
            }
            if (!PlayerControl.LocalPlayer.CanMove)
            {
                return(false);
            }
            var role = Role.GetRole <Arsonist>(PlayerControl.LocalPlayer);

            if (role.IgniteUsed)
            {
                return(false);
            }
            if (__instance == role.IgniteButton)
            {
                if (!__instance.isActiveAndEnabled)
                {
                    return(false);
                }
                if (!role.CheckEveryoneDoused())
                {
                    return(false);
                }
                var writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId,
                                                                        (byte)CustomRPC.Ignite, SendOption.Reliable, -1);
                writer.Write(PlayerControl.LocalPlayer.PlayerId);
                AmongUsClient.Instance.FinishRpcImmediately(writer);
                Ignite(role);
                return(false);
            }

            if (__instance != DestroyableSingleton <HudManager> .Instance.KillButton)
            {
                return(true);
            }
            if (!__instance.isActiveAndEnabled)
            {
                return(false);
            }
            if (role.ClosestPlayer == null)
            {
                return(false);
            }
            if (role.DouseTimer() != 0)
            {
                return(false);
            }
            if (role.DousedPlayers.Contains(role.ClosestPlayer.PlayerId))
            {
                return(false);
            }
            var distBetweenPlayers = Utils.getDistBetweenPlayers(PlayerControl.LocalPlayer, role.ClosestPlayer);
            var flag3 = distBetweenPlayers <
                        GameOptionsData.KillDistances[PlayerControl.GameOptions.KillDistance];

            if (!flag3)
            {
                return(false);
            }
            var writer2 = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId,
                                                                     (byte)CustomRPC.Douse, SendOption.Reliable, -1);

            writer2.Write(PlayerControl.LocalPlayer.PlayerId);
            writer2.Write(role.ClosestPlayer.PlayerId);
            AmongUsClient.Instance.FinishRpcImmediately(writer2);
            role.DousedPlayers.Add(role.ClosestPlayer.PlayerId);
            role.LastDoused = DateTime.UtcNow;

            __instance.SetTarget(null);
            return(false);
        }
Exemple #7
0
        private static void UpdateKillButton(HudManager __instance)
        {
            KillButton = __instance.KillButton;
            if (PlayerControl.AllPlayerControls.Count <= 1)
            {
                return;
            }
            if (PlayerControl.LocalPlayer == null)
            {
                return;
            }
            if (PlayerControl.LocalPlayer.Data == null)
            {
                return;
            }
            var flag7 = PlayerControl.AllPlayerControls.Count > 1;

            if (!flag7)
            {
                return;
            }
            var flag8 = PlayerControl.LocalPlayer.Is(RoleEnum.Sheriff);

            if (flag8)
            {
                var role   = Roles.Role.GetRole <Roles.Sheriff>(PlayerControl.LocalPlayer);
                var isDead = PlayerControl.LocalPlayer.Data.IsDead;
                if (isDead)
                {
                    KillButton.gameObject.SetActive(false);
                    KillButton.isActive = false;
                }
                else
                {
                    KillButton.gameObject.SetActive(!MeetingHud.Instance);
                    KillButton.isActive = !MeetingHud.Instance;
                    KillButton.SetCoolDown(role.SheriffKillTimer(), PlayerControl.GameOptions.KillCooldown + 15f);
                    role.ClosestPlayer = Utils.getClosestPlayer(PlayerControl.LocalPlayer);
                    var distBetweenPlayers = Utils.getDistBetweenPlayers(PlayerControl.LocalPlayer, role.ClosestPlayer);
                    var flag9 = distBetweenPlayers < GameOptionsData.KillDistances[PlayerControl.GameOptions.KillDistance];
                    if (flag9 && KillButton.enabled)
                    {
                        KillButton.SetTarget(role.ClosestPlayer);
                    }
                }
            }
            else
            {
                var isImpostor = PlayerControl.LocalPlayer.Data.IsImpostor;
                if (!isImpostor)
                {
                    return;
                }
                var isDead2 = PlayerControl.LocalPlayer.Data.IsDead;
                if (isDead2)
                {
                    KillButton.gameObject.SetActive(false);
                    KillButton.isActive = false;
                }
                else
                {
                    __instance.KillButton.gameObject.SetActive(!MeetingHud.Instance);
                    __instance.KillButton.isActive = !MeetingHud.Instance;
                }
            }
        }