Exemple #1
0
            public static void HackButtonPress(Glitch __gInstance, KillButtonManager __instance)
            {
                if (__gInstance.HackTarget != null)
                {
                    if (__gInstance.HackTarget.isShielded())
                    {
                        var medic  = __gInstance.HackTarget.getMedic().Player.PlayerId;
                        var writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId,
                                                                                (byte)CustomRPC.AttemptSound, SendOption.Reliable, -1);
                        writer.Write(medic);
                        writer.Write(__gInstance.HackTarget.PlayerId);
                        AmongUsClient.Instance.FinishRpcImmediately(writer);
                        if (CustomGameOptions.ShieldBreaks)
                        {
                            __gInstance.LastHack = DateTime.UtcNow;
                        }

                        StopKill.BreakShield(medic, __gInstance.HackTarget.PlayerId,
                                             CustomGameOptions.ShieldBreaks);

                        return;
                    }

                    __gInstance.LastHack = DateTime.UtcNow;
                    //System.Console.WriteLine("Hacking " + __gInstance.HackTarget.Data.PlayerName + "...");
                    __gInstance.RpcSetHacked(__gInstance.HackTarget);
                }
            }
Exemple #2
0
            public static void KillButtonUpdate(Glitch __gInstance, HudManager __instance)
            {
                if (!__gInstance.Player.Data.IsImpostor && Input.GetKeyDown(KeyCode.Q))
                {
                    __instance.KillButton.PerformKill();
                }

                __instance.KillButton.gameObject.SetActive(__instance.UseButton.isActiveAndEnabled &&
                                                           !__gInstance.Player.Data.IsDead);
                __instance.KillButton.SetCoolDown(
                    CustomGameOptions.GlitchKillCooldown -
                    (float)(DateTime.UtcNow - __gInstance.LastKill).TotalSeconds,
                    CustomGameOptions.GlitchKillCooldown);

                __instance.KillButton.SetTarget(null);
                __gInstance.KillTarget = null;

                if (__instance.KillButton.isActiveAndEnabled)
                {
                    __instance.KillButton.SetTarget(__gInstance.ClosestPlayer);
                    __gInstance.KillTarget = __gInstance.ClosestPlayer;
                }

                if (__gInstance.KillTarget != null)
                {
                    __gInstance.KillTarget.myRend.material.SetColor("_OutlineColor", __gInstance.Color);
                }
            }
Exemple #3
0
            public static void KillButtonPress(Glitch __gInstance, KillButtonManager __instance)
            {
                if (__gInstance.KillTarget != null)
                {
                    if (__gInstance.KillTarget.isShielded())
                    {
                        var medic  = __gInstance.HackTarget.getMedic().Player.PlayerId;
                        var writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId,
                                                                                (byte)CustomRPC.AttemptSound, SendOption.Reliable, -1);
                        writer.Write(medic);
                        writer.Write(__gInstance.KillTarget.PlayerId);
                        AmongUsClient.Instance.FinishRpcImmediately(writer);
                        if (CustomGameOptions.ShieldBreaks)
                        {
                            __gInstance.LastKill = DateTime.UtcNow;
                        }

                        StopKill.BreakShield(medic, __gInstance.KillTarget.PlayerId,
                                             CustomGameOptions.ShieldBreaks);

                        return;
                    }

                    __gInstance.LastKill = DateTime.UtcNow;
                    __gInstance.Player.SetKillTimer(CustomGameOptions.GlitchKillCooldown);
                    Utils.RpcMurderPlayer(__gInstance.Player, __gInstance.KillTarget);
                }
            }
Exemple #4
0
            public static void HackButtonUpdate(Glitch __gInstance, HudManager __instance)
            {
                if (__gInstance.HackButton == null)
                {
                    __gInstance.HackButton = KillButtonManager.Instantiate(__instance.KillButton);
                    __gInstance.HackButton.gameObject.SetActive(true);
                    __gInstance.HackButton.renderer.enabled = true;
                }

                __gInstance.HackButton.renderer.sprite = HackSprite;


                __gInstance.HackButton.gameObject.SetActive(__instance.UseButton.isActiveAndEnabled &&
                                                            !__gInstance.Player.Data.IsDead);
                __gInstance.HackButton.transform.position = new Vector3(__gInstance.MimicButton.transform.position.x,
                                                                        __instance.ReportButton.transform.position.y, __instance.ReportButton.transform.position.z);
                __gInstance.HackButton.SetCoolDown(
                    CustomGameOptions.HackCooldown - (float)(DateTime.UtcNow - __gInstance.LastHack).TotalSeconds,
                    CustomGameOptions.HackCooldown);

                __gInstance.HackButton.SetTarget(null);
                __gInstance.HackTarget = null;

                if (__gInstance.DistClosest < GameOptionsData.KillDistances[CustomGameOptions.GlitchHackDistance])
                {
                    __gInstance.HackButton.SetTarget(__gInstance.ClosestPlayer);
                    __gInstance.HackTarget = __gInstance.ClosestPlayer;
                }

                if (__gInstance.HackTarget != null)
                {
                    __gInstance.HackTarget.myRend.material.SetColor("_OutlineColor", __gInstance.Color);
                }
            }
Exemple #5
0
            public static void MimicButtonUpdate(Glitch __gInstance, HudManager __instance)
            {
                if (__gInstance.MimicButton == null)
                {
                    __gInstance.MimicButton = KillButtonManager.Instantiate(__instance.KillButton);
                    __gInstance.MimicButton.gameObject.SetActive(true);
                    __gInstance.MimicButton.renderer.enabled = true;
                }

                __gInstance.MimicButton.renderer.sprite = MimicSprite;


                __gInstance.MimicButton.gameObject.SetActive(__instance.UseButton.isActiveAndEnabled &&
                                                             !__gInstance.Player.Data.IsDead);
                __gInstance.MimicButton.transform.position = new Vector3(
                    Camera.main.ScreenToWorldPoint(new Vector3(0, 0)).x + 0.75f,
                    __instance.UseButton.transform.position.y, __instance.UseButton.transform.position.z);
                __gInstance.MimicButton.SetCoolDown(
                    CustomGameOptions.MimicCooldown - (float)(DateTime.UtcNow - __gInstance.LastMimic).TotalSeconds,
                    CustomGameOptions.MimicCooldown);

                if (!__gInstance.MimicButton.isCoolingDown && !__gInstance.IsUsingMimic)
                {
                    __gInstance.MimicButton.isCoolingDown = false;
                    __gInstance.MimicButton.renderer.material.SetFloat("_Desat", 0f);
                    __gInstance.MimicButton.renderer.color = Palette.EnabledColor;
                }
                else
                {
                    __gInstance.MimicButton.isCoolingDown = true;
                    __gInstance.MimicButton.renderer.material.SetFloat("_Desat", 1f);
                    __gInstance.MimicButton.renderer.color = Palette.DisabledClear;
                }
            }
Exemple #6
0
            public static void MimicButtonPress(Glitch __gInstance, KillButtonManager __instance)
            {
                if (__gInstance.MimicList == null)
                {
                    __gInstance.MimicList = ChatController.Instantiate(HudManager.Instance.Chat);

                    __gInstance.MimicList.transform.SetParent(Camera.main.transform);
                    __gInstance.MimicList.SetVisible(true);
                    __gInstance.MimicList.Toggle();

                    __gInstance.MimicList.TextBubble.enabled = false;
                    __gInstance.MimicList.TextBubble.gameObject.SetActive(false);

                    __gInstance.MimicList.TextArea.enabled = false;
                    __gInstance.MimicList.TextArea.gameObject.SetActive(false);

                    __gInstance.MimicList.BanButton.enabled = false;
                    __gInstance.MimicList.BanButton.gameObject.SetActive(false);

                    __gInstance.MimicList.CharCount.enabled = false;
                    __gInstance.MimicList.CharCount.gameObject.SetActive(false);

                    __gInstance.MimicList.gameObject.transform.GetChild(0).gameObject.GetComponent <SpriteRenderer>().enabled = false;
                    __gInstance.MimicList.gameObject.transform.GetChild(0).gameObject.SetActive(false);

                    __gInstance.MimicList.BackgroundImage.enabled = false;

                    foreach (SpriteRenderer rend in __gInstance.MimicList.Content.GetComponentsInChildren <SpriteRenderer>())
                    {
                        if (rend.name == "SendButton" || rend.name == "QuickChatButton")
                        {
                            rend.enabled = false;
                            rend.gameObject.SetActive(false);
                        }
                    }

                    foreach (var bubble in __gInstance.MimicList.chatBubPool.activeChildren)
                    {
                        bubble.enabled = false;
                        bubble.gameObject.SetActive(false);
                    }
                    __gInstance.MimicList.chatBubPool.activeChildren.Clear();

                    foreach (PlayerControl player in PlayerControl.AllPlayerControls.ToArray().Where(x => x != PlayerControl.LocalPlayer))
                    {
                        bool oldDead = player.Data.IsDead;
                        player.Data.IsDead = false;
                        //System.Console.WriteLine(player.PlayerId);
                        __gInstance.MimicList.AddChat(player, "Click here");
                        player.Data.IsDead = oldDead;
                    }
                }
                else
                {
                    __gInstance.MimicList.Toggle();
                    __gInstance.MimicList.SetVisible(false);
                    __gInstance.MimicList = null;
                }
            }
Exemple #7
0
            public static IEnumerator Mimic(Glitch __instance, PlayerControl mimicPlayer)
            {
                var writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId,
                                                                        (byte)CustomRPC.SetMimic, SendOption.Reliable, -1);

                writer.Write(PlayerControl.LocalPlayer.PlayerId);
                writer.Write(mimicPlayer.PlayerId);
                AmongUsClient.Instance.FinishRpcImmediately(writer);

                Utils.Morph(__instance.Player, mimicPlayer, true);

                var mimicActivation = DateTime.UtcNow;
                var mimicText       = new GameObject("_Player").AddComponent <ImportantTextTask>();

                mimicText.transform.SetParent(PlayerControl.LocalPlayer.transform, false);
                mimicText.Text =
                    $"{__instance.ColorString}Mimicking {mimicPlayer.Data.PlayerName} ({CustomGameOptions.MimicDuration}s)</color>";
                PlayerControl.LocalPlayer.myTasks.Insert(0, mimicText);

                while (true)
                {
                    __instance.IsUsingMimic = true;
                    __instance.MimicTarget  = mimicPlayer;
                    var totalMimickTime = (DateTime.UtcNow - mimicActivation).TotalMilliseconds / 1000;
                    mimicText.Text =
                        $"{__instance.ColorString}Mimicking {mimicPlayer.Data.PlayerName} ({CustomGameOptions.MimicDuration - Math.Round(totalMimickTime)}s)</color>";
                    if (totalMimickTime > CustomGameOptions.MimicDuration ||
                        PlayerControl.LocalPlayer.Data.IsDead ||
                        AmongUsClient.Instance.GameState == InnerNetClient.GameStates.Ended)
                    {
                        PlayerControl.LocalPlayer.myTasks.Remove(mimicText);
                        //System.Console.WriteLine("Unsetting mimic");
                        __instance.LastMimic    = DateTime.UtcNow;
                        __instance.IsUsingMimic = false;
                        __instance.MimicTarget  = null;
                        Utils.Unmorph(__instance.Player);

                        var writer2 = AmongUsClient.Instance.StartRpcImmediately(
                            PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.RpcResetAnim, SendOption.Reliable,
                            -1);
                        writer2.Write(PlayerControl.LocalPlayer.PlayerId);
                        writer2.Write(mimicPlayer.PlayerId);
                        AmongUsClient.Instance.FinishRpcImmediately(writer2);
                        yield break;
                    }

                    Utils.Morph(__instance.Player, mimicPlayer);
                    __instance.MimicButton.SetCoolDown(CustomGameOptions.MimicDuration - (float)totalMimickTime,
                                                       CustomGameOptions.MimicDuration);

                    yield return(null);
                }
            }
Exemple #8
0
            public static void HackButtonPress(Glitch __gInstance, KillButtonManager __instance)
            {
                if (__gInstance.HackTarget != null)
                {
                    if (__gInstance.HackTarget.isShielded())
                    {
                        Utils.BreakShield(__gInstance.HackTarget);
                        if (CustomGameOptions.ShieldBreaks)
                        {
                            __gInstance.LastHack = DateTime.UtcNow;
                        }

                        return;
                    }

                    __gInstance.LastHack = DateTime.UtcNow;
                    //System.Console.WriteLine("Hacking " + __gInstance.HackTarget.Data.PlayerName + "...");
                    __gInstance.RpcSetHacked(__gInstance.HackTarget);
                }
            }
Exemple #9
0
            public static void KillButtonPress(Glitch __gInstance, KillButtonManager __instance)
            {
                if (__gInstance.KillTarget != null)
                {
                    if (__gInstance.KillTarget.isShielded())
                    {
                        Utils.BreakShield(__gInstance.KillTarget);
                        if (CustomGameOptions.ShieldBreaks)
                        {
                            __gInstance.LastKill = DateTime.UtcNow;
                        }

                        return;
                    }

                    __gInstance.LastKill = DateTime.UtcNow;
                    __gInstance.Player.SetKillTimer(PlayerControl.GameOptions.KillCooldown);
                    Utils.RpcMurderPlayer(__gInstance.Player, __gInstance.KillTarget);
                }
            }
Exemple #10
0
            public static void HackButtonPress(Glitch __gInstance, KillButtonManager __instance)
            {
                if (__gInstance.HackTarget != null)
                {
                    if (__gInstance.HackTarget.isShielded())
                    {
                        if (CustomGameOptions.PlayerMurderIndicator)
                        {
                            var writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId,
                                                                                    (byte)CustomRPC.AttemptSound, Hazel.SendOption.None, -1);
                            writer.Write(__gInstance.HackTarget.PlayerId);
                            AmongUsClient.Instance.FinishRpcImmediately(writer);
                            MedicMod.StopKill.BreakShield(__gInstance.HackTarget.PlayerId, false);
                        }

                        return;
                    }
                    __gInstance.LastHack = DateTime.UtcNow;
                    //System.Console.WriteLine("Hacking " + __gInstance.HackTarget.Data.PlayerName + "...");
                    __gInstance.RpcSetHacked(__gInstance.HackTarget);
                }
            }
Exemple #11
0
            public static void KillButtonPress(Glitch __gInstance, KillButtonManager __instance)
            {
                if (__gInstance.KillTarget != null)
                {
                    if (__gInstance.KillTarget.isShielded())
                    {
                        if (CustomGameOptions.PlayerMurderIndicator)
                        {
                            var writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId,
                                                                                    (byte)CustomRPC.AttemptSound, Hazel.SendOption.None, -1);
                            writer.Write(__gInstance.KillTarget.PlayerId);
                            AmongUsClient.Instance.FinishRpcImmediately(writer);
                            MedicMod.StopKill.BreakShield(__gInstance.KillTarget.PlayerId, false);
                        }

                        return;
                    }
                    __gInstance.LastKill = DateTime.UtcNow;
                    __gInstance.Player.SetKillTimer(CustomGameOptions.GlitchKillCooldown);
                    Utils.RpcMurderPlayer(__gInstance.Player, __gInstance.KillTarget);
                }
            }
Exemple #12
0
            public static IEnumerator Hack(Glitch __instance, PlayerControl hackPlayer)
            {
                GameObject[]      lockImg = { null, null, null, null };
                ImportantTextTask hackText;

                if (tickDictionary.ContainsKey(hackPlayer.PlayerId))
                {
                    tickDictionary[hackPlayer.PlayerId] = DateTime.UtcNow;
                    yield break;
                }

                hackText = new GameObject("_Player").AddComponent <ImportantTextTask>();
                hackText.transform.SetParent(PlayerControl.LocalPlayer.transform, false);
                hackText.Text =
                    $"{__instance.ColorString}Hacked {hackPlayer.Data.PlayerName} ({CustomGameOptions.HackDuration}s)</color>";
                hackText.Index = hackPlayer.PlayerId;
                tickDictionary.Add(hackPlayer.PlayerId, DateTime.UtcNow);
                PlayerControl.LocalPlayer.myTasks.Insert(0, hackText);

                while (true)
                {
                    if (PlayerControl.LocalPlayer == hackPlayer)
                    {
                        if (HudManager.Instance.KillButton != null)
                        {
                            if (lockImg[0] == null)
                            {
                                lockImg[0] = new GameObject();
                                var lockImgR = lockImg[0].AddComponent <SpriteRenderer>();
                                lockImgR.sprite = LockSprite;
                            }

                            lockImg[0].layer = 5;
                            lockImg[0].transform.position =
                                new Vector3(HudManager.Instance.KillButton.transform.position.x,
                                            HudManager.Instance.KillButton.transform.position.y, -50f);
                            HudManager.Instance.KillButton.enabled        = false;
                            HudManager.Instance.KillButton.renderer.color = Palette.DisabledClear;
                            HudManager.Instance.KillButton.renderer.material.SetFloat("_Desat", 1f);
                        }

                        if (HudManager.Instance.UseButton != null)
                        {
                            if (lockImg[1] == null)
                            {
                                lockImg[1] = new GameObject();
                                var lockImgR = lockImg[1].AddComponent <SpriteRenderer>();
                                lockImgR.sprite = LockSprite;
                            }

                            lockImg[1].transform.position =
                                new Vector3(HudManager.Instance.UseButton.transform.position.x,
                                            HudManager.Instance.UseButton.transform.position.y, -50f);
                            lockImg[1].layer = 5;
                            HudManager.Instance.UseButton.enabled = false;
                            HudManager.Instance.UseButton.currentButtonShown.graphic.color = Palette.DisabledClear;
                            HudManager.Instance.UseButton.currentButtonShown.graphic.material.SetFloat("_Desat", 1f);
                        }

                        if (HudManager.Instance.ReportButton != null)
                        {
                            if (lockImg[2] == null)
                            {
                                lockImg[2] = new GameObject();
                                var lockImgR = lockImg[2].AddComponent <SpriteRenderer>();
                                lockImgR.sprite = LockSprite;
                            }

                            lockImg[2].transform.position =
                                new Vector3(HudManager.Instance.ReportButton.transform.position.x,
                                            HudManager.Instance.ReportButton.transform.position.y, -50f);
                            lockImg[2].layer = 5;
                            HudManager.Instance.ReportButton.enabled = false;
                            HudManager.Instance.ReportButton.SetActive(false);
                        }

                        var role = GetRole(PlayerControl.LocalPlayer);
                        if (role != null)
                        {
                            if (role.ExtraButtons.Count > 0)
                            {
                                if (lockImg[3] == null)
                                {
                                    lockImg[3] = new GameObject();
                                    var lockImgR = lockImg[3].AddComponent <SpriteRenderer>();
                                    lockImgR.sprite = LockSprite;
                                }

                                lockImg[3].transform.position = new Vector3(
                                    role.ExtraButtons[0].transform.position.x,
                                    role.ExtraButtons[0].transform.position.y, -50f);
                                lockImg[3].layer                    = 5;
                                role.ExtraButtons[0].enabled        = false;
                                role.ExtraButtons[0].renderer.color = Palette.DisabledClear;
                                role.ExtraButtons[0].renderer.material.SetFloat("_Desat", 1f);
                            }
                        }

                        if (Minigame.Instance)
                        {
                            Minigame.Instance.Close();
                            Minigame.Instance.Close();
                        }

                        if (MapBehaviour.Instance)
                        {
                            MapBehaviour.Instance.Close();
                            MapBehaviour.Instance.Close();
                        }
                    }

                    var totalHacktime = (DateTime.UtcNow - tickDictionary[hackPlayer.PlayerId]).TotalMilliseconds /
                                        1000;
                    hackText.Text =
                        $"{__instance.ColorString}Hacked {hackPlayer.Data.PlayerName} ({CustomGameOptions.HackDuration - Math.Round(totalHacktime)}s)</color>";
                    if (MeetingHud.Instance || totalHacktime > CustomGameOptions.HackDuration || hackPlayer == null ||
                        hackPlayer.Data.IsDead)
                    {
                        foreach (var obj in lockImg)
                        {
                            if (obj != null)
                            {
                                obj.SetActive(false);
                            }
                        }

                        if (PlayerControl.LocalPlayer == hackPlayer)
                        {
                            HudManager.Instance.UseButton.enabled    = true;
                            HudManager.Instance.ReportButton.enabled = true;
                            HudManager.Instance.KillButton.enabled   = true;
                            HudManager.Instance.UseButton.currentButtonShown.graphic.color = Palette.EnabledColor;
                            HudManager.Instance.UseButton.currentButtonShown.graphic.material.SetFloat("_Desat", 0f);
                            var role = GetRole(PlayerControl.LocalPlayer);
                            if (role != null)
                            {
                                if (role.ExtraButtons.Count > 0)
                                {
                                    role.ExtraButtons[0].enabled        = true;
                                    role.ExtraButtons[0].renderer.color = Palette.EnabledColor;
                                    role.ExtraButtons[0].renderer.material.SetFloat("_Desat", 0f);
                                }
                            }
                        }

                        tickDictionary.Remove(hackPlayer.PlayerId);
                        PlayerControl.LocalPlayer.myTasks.Remove(hackText);
                        yield break;
                    }

                    yield return(null);
                }
            }