Ejemplo n.º 1
0
        public static void Postfix(HudManager __instance)
        {
            // Engineer Repair
            engineerRepairButton = new CustomButton(
                () => {
                engineerRepairButton.Timer = 0f;

                MessageWriter usedRepairWriter = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.EngineerUsedRepair, Hazel.SendOption.Reliable, -1);
                AmongUsClient.Instance.FinishRpcImmediately(usedRepairWriter);
                RPCProcedure.engineerUsedRepair();

                foreach (PlayerTask task in PlayerControl.LocalPlayer.myTasks)
                {
                    if (task.TaskType == TaskTypes.FixLights)
                    {
                        MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.EngineerFixLights, Hazel.SendOption.Reliable, -1);
                        AmongUsClient.Instance.FinishRpcImmediately(writer);
                        RPCProcedure.engineerFixLights();
                    }
                    else if (task.TaskType == TaskTypes.RestoreOxy)
                    {
                        ShipStatus.Instance.RpcRepairSystem(SystemTypes.LifeSupp, 0 | 64);
                        ShipStatus.Instance.RpcRepairSystem(SystemTypes.LifeSupp, 1 | 64);
                    }
                    else if (task.TaskType == TaskTypes.ResetReactor)
                    {
                        ShipStatus.Instance.RpcRepairSystem(SystemTypes.Reactor, 16);
                    }
                    else if (task.TaskType == TaskTypes.ResetSeismic)
                    {
                        ShipStatus.Instance.RpcRepairSystem(SystemTypes.Laboratory, 16);
                    }
                    else if (task.TaskType == TaskTypes.FixComms)
                    {
                        ShipStatus.Instance.RpcRepairSystem(SystemTypes.Comms, 16 | 0);
                        ShipStatus.Instance.RpcRepairSystem(SystemTypes.Comms, 16 | 1);
                    }
                    else if (task.TaskType == TaskTypes.StopCharles)
                    {
                        ShipStatus.Instance.RpcRepairSystem(SystemTypes.Reactor, 0 | 16);
                        ShipStatus.Instance.RpcRepairSystem(SystemTypes.Reactor, 1 | 16);
                    }
                }
            },
                () => { return(Engineer.engineer != null && Engineer.engineer == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.PPMOEEPBHJO.IAGJEKLJCCI); },
                () => {
                bool sabotageActive = false;
                foreach (PlayerTask task in PlayerControl.LocalPlayer.myTasks)
                {
                    if (task.TaskType == TaskTypes.FixLights || task.TaskType == TaskTypes.RestoreOxy || task.TaskType == TaskTypes.ResetReactor || task.TaskType == TaskTypes.ResetSeismic || task.TaskType == TaskTypes.FixComms || task.TaskType == TaskTypes.StopCharles)
                    {
                        sabotageActive = true;
                    }
                }
                return(sabotageActive && !Engineer.usedRepair && PlayerControl.LocalPlayer.POECPOEKKNO);
            },
                () => {},
                Engineer.getButtonSprite(),
                new Vector3(-1.3f, 0, 0),
                __instance
                );

            // Janitor Clean
            janitorCleanButton = new CustomButton(
                () => {
                foreach (Collider2D collider2D in Physics2D.OverlapCircleAll(PlayerControl.LocalPlayer.GetTruePosition(), PlayerControl.LocalPlayer.MaxReportDistance, Constants.ODGOCDBFMFC))
                {
                    if (collider2D.tag == "DeadBody")
                    {
                        DeadBody component = collider2D.GetComponent <DeadBody>();
                        if (component && !component.Reported)
                        {
                            Vector2 truePosition  = PlayerControl.LocalPlayer.GetTruePosition();
                            Vector2 truePosition2 = component.AMIPFAILDIF;
                            if (Vector2.Distance(truePosition2, truePosition) <= PlayerControl.LocalPlayer.MaxReportDistance && PlayerControl.LocalPlayer.POECPOEKKNO && !PhysicsHelpers.DOAHONIIFJD(truePosition, truePosition2, Constants.LEOCDMEJGPA, false))
                            {
                                GameData.LGBOMGHJELL LGBOMGHJELL = GameData.Instance.GetPlayerById(component.ParentId);

                                MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.JanitorClean, Hazel.SendOption.Reliable, -1);
                                writer.Write(LGBOMGHJELL.FNPNJHNKEBK);
                                AmongUsClient.Instance.FinishRpcImmediately(writer);
                                RPCProcedure.janitorClean(LGBOMGHJELL.FNPNJHNKEBK);
                                janitorCleanButton.Timer = janitorCleanButton.MaxTimer;

                                break;
                            }
                        }
                    }
                }
            },
                () => { return(Janitor.janitor != null && Janitor.janitor == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.PPMOEEPBHJO.IAGJEKLJCCI); },
                () => { return(__instance.ReportButton.renderer.color == Palette.BJENLBHMKAI && PlayerControl.LocalPlayer.POECPOEKKNO); },
                () => { janitorCleanButton.Timer = janitorCleanButton.MaxTimer; },
                Janitor.getButtonSprite(),
                new Vector3(-1.3f, 0, 0),
                __instance
                );

            // Sheriff Kill
            sheriffKillButton = new CustomButton(
                () => {
                if (Medic.shielded != null && Medic.shielded == Sheriff.currentTarget)
                {
                    MessageWriter attemptWriter = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ShieldedMurderAttempt, Hazel.SendOption.Reliable, -1);
                    AmongUsClient.Instance.FinishRpcImmediately(attemptWriter);
                    RPCProcedure.shieldedMurderAttempt();
                    return;
                }

                byte targetId = 0;
                if ((Sheriff.currentTarget.PPMOEEPBHJO.FDNMBJOAPFL && (Sheriff.currentTarget != Child.child || Child.isGrownUp())) ||
                    Sheriff.currentTarget == Jackal.jackal ||
                    Sheriff.currentTarget == Sidekick.sidekick ||
                    (Sheriff.spyCanDieToSheriff && Spy.spy != null && Spy.spy == Sheriff.currentTarget) ||
                    (Sheriff.jesterCanDieToSheriff && Jester.jester != null && Jester.jester == Sheriff.currentTarget))
                {
                    targetId = Sheriff.currentTarget.PlayerId;
                }
                else
                {
                    targetId = PlayerControl.LocalPlayer.PlayerId;
                }
                MessageWriter killWriter = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SheriffKill, Hazel.SendOption.Reliable, -1);
                killWriter.Write(targetId);
                AmongUsClient.Instance.FinishRpcImmediately(killWriter);
                RPCProcedure.sheriffKill(targetId);

                sheriffKillButton.Timer = sheriffKillButton.MaxTimer;
                Sheriff.currentTarget   = null;
            },
                () => { return(Sheriff.sheriff != null && Sheriff.sheriff == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.PPMOEEPBHJO.IAGJEKLJCCI); },
                () => { return(Sheriff.currentTarget && PlayerControl.LocalPlayer.POECPOEKKNO); },
                () => { sheriffKillButton.Timer = sheriffKillButton.MaxTimer; },
                __instance.KillButton.renderer.sprite,
                new Vector3(-1.3f, 0, 0),
                __instance
                );

            // Time Master Rewind Time
            timeMasterShieldButton = new CustomButton(
                () => {
                MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.TimeMasterShield, Hazel.SendOption.Reliable, -1);
                AmongUsClient.Instance.FinishRpcImmediately(writer);
                RPCProcedure.timeMasterShield();
            },
                () => { return(TimeMaster.timeMaster != null && TimeMaster.timeMaster == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.PPMOEEPBHJO.IAGJEKLJCCI); },
                () => { return(PlayerControl.LocalPlayer.POECPOEKKNO); },
                () => {
                timeMasterShieldButton.Timer          = timeMasterShieldButton.MaxTimer;
                timeMasterShieldButton.isEffectActive = false;
                timeMasterShieldButton.killButtonManager.TimerText.color = Palette.BJENLBHMKAI;
            },
                TimeMaster.getButtonSprite(),
                new Vector3(-1.3f, 0, 0),
                __instance,
                true,
                TimeMaster.shieldDuration,
                () => { timeMasterShieldButton.Timer = timeMasterShieldButton.MaxTimer; }
                );

            // Medic Shield
            medicShieldButton = new CustomButton(
                () => {
                medicShieldButton.Timer = 0f;

                MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.MedicSetShielded, Hazel.SendOption.Reliable, -1);
                writer.Write(Medic.currentTarget.PlayerId);
                AmongUsClient.Instance.FinishRpcImmediately(writer);
                RPCProcedure.medicSetShielded(Medic.currentTarget.PlayerId);
            },
                () => { return(Medic.medic != null && Medic.medic == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.PPMOEEPBHJO.IAGJEKLJCCI); },
                () => { return(!Medic.usedShield && Medic.currentTarget && PlayerControl.LocalPlayer.POECPOEKKNO); },
                () => {},
                Medic.getButtonSprite(),
                new Vector3(-1.3f, 0, 0),
                __instance
                );


            // Shifter shift
            shifterShiftButton = new CustomButton(
                () => {
                MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetFutureShifted, Hazel.SendOption.Reliable, -1);
                writer.Write(Shifter.currentTarget.PlayerId);
                AmongUsClient.Instance.FinishRpcImmediately(writer);
                RPCProcedure.setFutureShifted(Shifter.currentTarget.PlayerId);
            },
                () => { return(Shifter.shifter != null && Shifter.shifter == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.PPMOEEPBHJO.IAGJEKLJCCI); },
                () => { return(Shifter.currentTarget && Shifter.futureShift == null && PlayerControl.LocalPlayer.POECPOEKKNO); },
                () => { },
                Shifter.getButtonSprite(),
                new Vector3(-1.3f, 0, 0),
                __instance
                );

            // Morphling morph
            morphlingButton = new CustomButton(
                () => {
                if (Morphling.sampledTarget != null)
                {
                    MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.MorphlingMorph, Hazel.SendOption.Reliable, -1);
                    writer.Write(Morphling.sampledTarget.PlayerId);
                    AmongUsClient.Instance.FinishRpcImmediately(writer);
                    RPCProcedure.morphlingMorph(Morphling.sampledTarget.PlayerId);
                    Morphling.sampledTarget        = null;
                    morphlingButton.EffectDuration = 10f;
                }
                else if (Morphling.currentTarget != null)
                {
                    Morphling.sampledTarget        = Morphling.currentTarget;
                    morphlingButton.Sprite         = Morphling.getMorphSprite();
                    morphlingButton.EffectDuration = 1f;
                }
            },
                () => { return(Morphling.morphling != null && Morphling.morphling == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.PPMOEEPBHJO.IAGJEKLJCCI); },
                () => { return((Morphling.currentTarget || Morphling.sampledTarget) && PlayerControl.LocalPlayer.POECPOEKKNO); },
                () => {
                morphlingButton.Timer          = morphlingButton.MaxTimer;
                morphlingButton.Sprite         = Morphling.getSampleSprite();
                morphlingButton.isEffectActive = false;
                morphlingButton.killButtonManager.TimerText.color = Palette.BJENLBHMKAI;
                Morphling.sampledTarget = null;
            },
                Morphling.getSampleSprite(),
                new Vector3(-1.3f, 1.3f, 0f),
                __instance,
                true,
                10f,
                () => {
                if (Morphling.sampledTarget == null)
                {
                    morphlingButton.Timer  = morphlingButton.MaxTimer;
                    morphlingButton.Sprite = Morphling.getSampleSprite();
                }
            }
                );

            // Camouflager camouflage
            camouflagerButton = new CustomButton(
                () => {
                MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.CamouflagerCamouflage, Hazel.SendOption.Reliable, -1);
                AmongUsClient.Instance.FinishRpcImmediately(writer);
                RPCProcedure.camouflagerCamouflage();
            },
                () => { return(Camouflager.camouflager != null && Camouflager.camouflager == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.PPMOEEPBHJO.IAGJEKLJCCI); },
                () => { return(PlayerControl.LocalPlayer.POECPOEKKNO); },
                () => {
                camouflagerButton.Timer          = camouflagerButton.MaxTimer;
                camouflagerButton.isEffectActive = false;
                camouflagerButton.killButtonManager.TimerText.color = Palette.BJENLBHMKAI;
            },
                Camouflager.getButtonSprite(),
                new Vector3(-1.3f, 1.3f, 0f),
                __instance,
                true,
                10f,
                () => { camouflagerButton.Timer = camouflagerButton.MaxTimer; }
                );

            // Hacker button
            hackerButton = new CustomButton(
                () => {
                Hacker.hackerTimer = Hacker.duration;
            },
                () => { return(Hacker.hacker != null && Hacker.hacker == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.PPMOEEPBHJO.IAGJEKLJCCI); },
                () => { return(PlayerControl.LocalPlayer.POECPOEKKNO); },
                () => {
                hackerButton.Timer          = hackerButton.MaxTimer;
                hackerButton.isEffectActive = false;
                hackerButton.killButtonManager.TimerText.color = Palette.BJENLBHMKAI;
            },
                Hacker.getButtonSprite(),
                new Vector3(-1.3f, 0, 0),
                __instance,
                true,
                0f,
                () => {
                hackerButton.Timer = hackerButton.MaxTimer;
            }
                );

            // Tracker button
            trackerButton = new CustomButton(
                () => {
                MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.TrackerUsedTracker, Hazel.SendOption.Reliable, -1);
                writer.Write(Tracker.currentTarget.PlayerId);
                AmongUsClient.Instance.FinishRpcImmediately(writer);
                RPCProcedure.trackerUsedTracker(Tracker.currentTarget.PlayerId);
            },
                () => { return(Tracker.tracker != null && Tracker.tracker == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.PPMOEEPBHJO.IAGJEKLJCCI); },
                () => { return(PlayerControl.LocalPlayer.POECPOEKKNO && Tracker.currentTarget != null && !Tracker.usedTracker); },
                () => { },
                Tracker.getButtonSprite(),
                new Vector3(-1.3f, 0, 0),
                __instance
                );

            vampireKillButton = new CustomButton(
                () => {
                if (Helpers.handleMurderAttempt(Vampire.currentTarget))
                {
                    if (Vampire.targetNearGarlic)
                    {
                        PlayerControl.LocalPlayer.RpcMurderPlayer(Vampire.currentTarget);
                        vampireKillButton.HasEffect = false;     // Block effect on this click
                        vampireKillButton.Timer     = vampireKillButton.MaxTimer;
                    }
                    else
                    {
                        Vampire.bitten = Vampire.currentTarget;
                        // Notify players about bitten
                        MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.VampireSetBitten, Hazel.SendOption.Reliable, -1);
                        writer.Write(Vampire.bitten.PlayerId);
                        writer.Write(0);
                        AmongUsClient.Instance.FinishRpcImmediately(writer);
                        RPCProcedure.vampireSetBitten(Vampire.bitten.PlayerId, 0);

                        HudManager.CHNDKKBEIDG.StartCoroutine(Effects.DCHLMIDMBHG(Vampire.delay, new Action <float>((p) => {    // Delayed action
                            if (p == 1f)
                            {
                                if (Vampire.bitten != null && !Vampire.bitten.PPMOEEPBHJO.IAGJEKLJCCI && Helpers.handleMurderAttempt(Vampire.bitten))
                                {
                                    // Perform kill
                                    MessageWriter killWriter = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.VampireTryKill, Hazel.SendOption.Reliable, -1);
                                    AmongUsClient.Instance.FinishRpcImmediately(killWriter);
                                    RPCProcedure.vampireTryKill();
                                }
                                else
                                {
                                    // Notify players about clearing bitten
                                    MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.VampireSetBitten, Hazel.SendOption.Reliable, -1);
                                    writer.Write(byte.MaxValue);
                                    writer.Write(byte.MaxValue);
                                    AmongUsClient.Instance.FinishRpcImmediately(writer);
                                    RPCProcedure.vampireSetBitten(byte.MaxValue, byte.MaxValue);
                                }
                            }
                        })));

                        vampireKillButton.HasEffect = true;     // Trigger effect on this click
                    }
                }
                else
                {
                    vampireKillButton.HasEffect = false;     // Block effect if no action was fired
                }
            },
                () => { return(Vampire.vampire != null && Vampire.vampire == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.PPMOEEPBHJO.IAGJEKLJCCI); },
                () => {
                if (Vampire.targetNearGarlic && Vampire.canKillNearGarlics)
                {
                    vampireKillButton.killButtonManager.renderer.sprite = __instance.KillButton.renderer.sprite;
                }
                else
                {
                    vampireKillButton.killButtonManager.renderer.sprite = Vampire.getButtonSprite();
                }
                return(Vampire.currentTarget != null && PlayerControl.LocalPlayer.POECPOEKKNO && (!Vampire.targetNearGarlic || Vampire.canKillNearGarlics));
            },
                () => {
                vampireKillButton.Timer          = vampireKillButton.MaxTimer;
                vampireKillButton.isEffectActive = false;
                vampireKillButton.killButtonManager.TimerText.color = Palette.BJENLBHMKAI;
            },
                Vampire.getButtonSprite(),
                new Vector3(-1.3f, 0, 0),
                __instance,
                false,
                0f,
                () => {
                vampireKillButton.Timer = vampireKillButton.MaxTimer;
            }
                );

            garlicButton = new CustomButton(
                () => {
                Vampire.localPlacedGarlic = true;
                var pos     = PlayerControl.LocalPlayer.transform.position;
                byte[] buff = new byte[sizeof(float) * 2];
                Buffer.BlockCopy(BitConverter.GetBytes(pos.x), 0, buff, 0 * sizeof(float), sizeof(float));
                Buffer.BlockCopy(BitConverter.GetBytes(pos.y), 0, buff, 1 * sizeof(float), sizeof(float));

                MessageWriter writer = AmongUsClient.Instance.StartRpc(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.PlaceGarlic, Hazel.SendOption.Reliable);
                writer.WriteBytesAndSize(buff);
                writer.EndMessage();
                RPCProcedure.placeGarlic(buff);
            },
                () => { return(!Vampire.localPlacedGarlic && !PlayerControl.LocalPlayer.PPMOEEPBHJO.IAGJEKLJCCI && Vampire.garlicsActive); },
                () => { return(PlayerControl.LocalPlayer.POECPOEKKNO && !Vampire.localPlacedGarlic); },
                () => { },
                Vampire.getGarlicButtonSprite(),
                Vector3.zero,
                __instance,
                true
                );


            // Jackal Sidekick Button
            jackalSidekickButton = new CustomButton(
                () => {
                MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.JackalCreatesSidekick, Hazel.SendOption.Reliable, -1);
                writer.Write(Jackal.currentTarget.PlayerId);
                AmongUsClient.Instance.FinishRpcImmediately(writer);
                RPCProcedure.jackalCreatesSidekick(Jackal.currentTarget.PlayerId);
            },
                () => { return(Jackal.canCreateSidekick && Sidekick.sidekick == null && Jackal.fakeSidekick == null && Jackal.jackal != null && Jackal.jackal == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.PPMOEEPBHJO.IAGJEKLJCCI); },
                () => { return(Sidekick.sidekick == null && Jackal.fakeSidekick == null && Jackal.currentTarget != null && PlayerControl.LocalPlayer.POECPOEKKNO); },
                () => { jackalSidekickButton.Timer = jackalSidekickButton.MaxTimer; },
                Jackal.getSidekickButtonSprite(),
                new Vector3(-1.3f, 1.3f, 0f),
                __instance
                );

            // Jackal Kill
            jackalKillButton = new CustomButton(
                () => {
                if (!Helpers.handleMurderAttempt(Jackal.currentTarget))
                {
                    return;
                }
                byte targetId            = Jackal.currentTarget.PlayerId;
                MessageWriter killWriter = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.JackalKill, Hazel.SendOption.Reliable, -1);
                killWriter.Write(targetId);
                AmongUsClient.Instance.FinishRpcImmediately(killWriter);
                RPCProcedure.jackalKill(targetId);
                jackalKillButton.Timer = jackalKillButton.MaxTimer;
                Jackal.currentTarget   = null;
            },
                () => { return(Jackal.jackal != null && Jackal.jackal == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.PPMOEEPBHJO.IAGJEKLJCCI); },
                () => { return(Jackal.currentTarget && PlayerControl.LocalPlayer.POECPOEKKNO); },
                () => { jackalKillButton.Timer = jackalKillButton.MaxTimer; },
                __instance.KillButton.renderer.sprite,
                new Vector3(-1.3f, 0, 0),
                __instance
                );

            // Sidekick Kill
            sidekickKillButton = new CustomButton(
                () => {
                if (!Helpers.handleMurderAttempt(Sidekick.currentTarget))
                {
                    return;
                }
                byte targetId            = Sidekick.currentTarget.PlayerId;
                MessageWriter killWriter = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SidekickKill, Hazel.SendOption.Reliable, -1);
                killWriter.Write(targetId);
                AmongUsClient.Instance.FinishRpcImmediately(killWriter);
                RPCProcedure.sidekickKill(targetId);

                sidekickKillButton.Timer = sidekickKillButton.MaxTimer;
                Sidekick.currentTarget   = null;
            },
                () => { return(Sidekick.canKill && Sidekick.sidekick != null && Sidekick.sidekick == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.PPMOEEPBHJO.IAGJEKLJCCI); },
                () => { return(Sidekick.currentTarget && PlayerControl.LocalPlayer.POECPOEKKNO); },
                () => { sidekickKillButton.Timer = sidekickKillButton.MaxTimer; },
                __instance.KillButton.renderer.sprite,
                new Vector3(-1.3f, 0, 0),
                __instance
                );

            // Lighter light
            lighterButton = new CustomButton(
                () => {
                Lighter.lighterTimer = Lighter.duration;
            },
                () => { return(Lighter.lighter != null && Lighter.lighter == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.PPMOEEPBHJO.IAGJEKLJCCI); },
                () => { return(PlayerControl.LocalPlayer.POECPOEKKNO); },
                () => {
                lighterButton.Timer          = lighterButton.MaxTimer;
                lighterButton.isEffectActive = false;
                lighterButton.killButtonManager.TimerText.color = Palette.BJENLBHMKAI;
            },
                Lighter.getButtonSprite(),
                new Vector3(-1.3f, 0f, 0f),
                __instance,
                true,
                Lighter.duration,
                () => { lighterButton.Timer = lighterButton.MaxTimer; }
                );

            // Eraser erase button
            eraserButton = new CustomButton(
                () => {
                eraserButton.MaxTimer += 10;
                eraserButton.Timer     = eraserButton.MaxTimer;

                MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetFutureErased, Hazel.SendOption.Reliable, -1);
                writer.Write(Eraser.currentTarget.PlayerId);
                AmongUsClient.Instance.FinishRpcImmediately(writer);
                RPCProcedure.setFutureErased(Eraser.currentTarget.PlayerId);
            },
                () => { return(Eraser.eraser != null && Eraser.eraser == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.PPMOEEPBHJO.IAGJEKLJCCI); },
                () => { return(PlayerControl.LocalPlayer.POECPOEKKNO && Eraser.currentTarget != null); },
                () => { eraserButton.Timer = eraserButton.MaxTimer; },
                Eraser.getButtonSprite(),
                new Vector3(-1.3f, 1.3f, 0f),
                __instance
                );

            placeJackInTheBoxButton = new CustomButton(
                () => {
                placeJackInTheBoxButton.Timer = placeJackInTheBoxButton.MaxTimer;

                var pos     = PlayerControl.LocalPlayer.transform.position;
                byte[] buff = new byte[sizeof(float) * 2];
                Buffer.BlockCopy(BitConverter.GetBytes(pos.x), 0, buff, 0 * sizeof(float), sizeof(float));
                Buffer.BlockCopy(BitConverter.GetBytes(pos.y), 0, buff, 1 * sizeof(float), sizeof(float));

                MessageWriter writer = AmongUsClient.Instance.StartRpc(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.PlaceJackInTheBox, Hazel.SendOption.Reliable);
                writer.WriteBytesAndSize(buff);
                writer.EndMessage();
                RPCProcedure.placeJackInTheBox(buff);
            },
                () => { return(Trickster.trickster != null && Trickster.trickster == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.PPMOEEPBHJO.IAGJEKLJCCI && !JackInTheBox.hasJackInTheBoxLimitReached()); },
                () => { return(PlayerControl.LocalPlayer.POECPOEKKNO && !JackInTheBox.hasJackInTheBoxLimitReached()); },
                () => { placeJackInTheBoxButton.Timer = placeJackInTheBoxButton.MaxTimer; },
                Trickster.getPlaceBoxButtonSprite(),
                new Vector3(-1.3f, 1.3f, 0f),
                __instance
                );

            lightsOutButton = new CustomButton(
                () => {
                MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.LightsOut, Hazel.SendOption.Reliable, -1);
                AmongUsClient.Instance.FinishRpcImmediately(writer);
                RPCProcedure.lightsOut();
            },
                () => { return(Trickster.trickster != null && Trickster.trickster == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.PPMOEEPBHJO.IAGJEKLJCCI && JackInTheBox.hasJackInTheBoxLimitReached() && JackInTheBox.boxesConvertedToVents); },
                () => { return(PlayerControl.LocalPlayer.POECPOEKKNO && JackInTheBox.hasJackInTheBoxLimitReached() && JackInTheBox.boxesConvertedToVents); },
                () => {
                lightsOutButton.Timer          = lightsOutButton.MaxTimer;
                lightsOutButton.isEffectActive = false;
                lightsOutButton.killButtonManager.TimerText.color = Palette.BJENLBHMKAI;
            },
                Trickster.getLightsOutButtonSprite(),
                new Vector3(-1.3f, 1.3f, 0f),
                __instance,
                true,
                Trickster.lightsOutDuration,
                () => { lightsOutButton.Timer = lightsOutButton.MaxTimer; }
                );

            // Set the default (or settings from the previous game) timers/durations when spawning the buttons
            setCustomButtonCooldowns();
        }
Ejemplo n.º 2
0
        static void Postfix(byte ACCJCEHMKLN, MessageReader HFPCBBHJIPJ)
        {
            byte          packetId = ACCJCEHMKLN;
            MessageReader reader   = HFPCBBHJIPJ;

            switch (packetId)
            {
            // Main Controls

            case (byte)CustomRPC.ResetVaribles:
                RPCProcedure.resetVariables();
                break;

            case (byte)CustomRPC.ForceEnd:
                RPCProcedure.forceEnd();
                break;

            case (byte)CustomRPC.SetRole:
                byte roleId   = HFPCBBHJIPJ.ReadByte();
                byte playerId = HFPCBBHJIPJ.ReadByte();
                RPCProcedure.setRole(roleId, playerId);
                break;


            // Role functionality

            case (byte)CustomRPC.JesterBountyHunterWin:
                RPCProcedure.jesterBountyHunterWin(HFPCBBHJIPJ.ReadByte());
                break;

            case (byte)CustomRPC.EngineerFixLights:
                RPCProcedure.engineerFixLights();
                break;

            case (byte)CustomRPC.EngineerUsedRepair:
                RPCProcedure.engineerUsedRepair();
                break;

            case (byte)CustomRPC.JanitorClean:
                RPCProcedure.janitorClean(HFPCBBHJIPJ.ReadByte());
                break;

            case (byte)CustomRPC.SheriffKill:
                RPCProcedure.sheriffKill(HFPCBBHJIPJ.ReadByte());
                break;

            case (byte)CustomRPC.TimeMasterRewindTime:
                RPCProcedure.timeMasterRewindTime();
                break;

            case (byte)CustomRPC.MedicSetShielded:
                RPCProcedure.medicSetShielded(HFPCBBHJIPJ.ReadByte());
                break;

            case (byte)CustomRPC.ShieldedMurderAttempt:
                RPCProcedure.shieldedMurderAttempt();
                break;

            case (byte)CustomRPC.TimeMasterRevive:
                RPCProcedure.timeMasterRevive(HFPCBBHJIPJ.ReadByte());
                break;

            case (byte)CustomRPC.ShifterShift:
                RPCProcedure.shifterShift(HFPCBBHJIPJ.ReadByte());
                break;

            case (byte)CustomRPC.SwapperSwap:
                byte playerId1 = HFPCBBHJIPJ.ReadByte();
                byte playerId2 = HFPCBBHJIPJ.ReadByte();
                RPCProcedure.swapperSwap(playerId1, playerId2);
                break;

            case (byte)CustomRPC.SeerReveal:
                byte targetId          = HFPCBBHJIPJ.ReadByte();
                byte targetOrMistakeId = HFPCBBHJIPJ.ReadByte();
                RPCProcedure.seerReveal(targetId, targetOrMistakeId);
                break;

            case (byte)CustomRPC.MorphlingMorph:
                RPCProcedure.morphlingMorph(HFPCBBHJIPJ.ReadByte());
                break;

            case (byte)CustomRPC.CamouflagerCamouflage:
                RPCProcedure.camouflagerCamouflage();
                break;

            case (byte)CustomRPC.LoverSuicide:
                RPCProcedure.loverSuicide(HFPCBBHJIPJ.ReadByte());
                break;

            case (byte)CustomRPC.SetBountyHunterTarget:
                RPCProcedure.setBountyHunterTarget(HFPCBBHJIPJ.ReadByte());
                break;

            case (byte)CustomRPC.VampireBiteNotification:
                RPCProcedure.vampireBiteNotification(HFPCBBHJIPJ.ReadByte());
                break;

            case (byte)CustomRPC.VampireTryKill:
                RPCProcedure.vampireTryKill();
                break;

            case (byte)CustomRPC.PlaceGarlic:
                RPCProcedure.placeGarlic(HFPCBBHJIPJ.ReadBytesAndSize());
                break;

            case (byte)CustomRPC.TrackerUsedTracker:
                RPCProcedure.trackerUsedTracker(HFPCBBHJIPJ.ReadByte());
                break;

            case (byte)CustomRPC.JackalKill:
                RPCProcedure.jackalKill(HFPCBBHJIPJ.ReadByte());
                break;

            case (byte)CustomRPC.SidekickKill:
                RPCProcedure.sidekickKill(HFPCBBHJIPJ.ReadByte());
                break;

            case (byte)CustomRPC.JackalCreatesSidekick:
                RPCProcedure.jackalCreatesSidekick(HFPCBBHJIPJ.ReadByte());
                break;

            case (byte)CustomRPC.SidekickPromotes:
                RPCProcedure.sidekickPromotes();
                break;
            }
        }
Ejemplo n.º 3
0
        public static void Postfix(HudManager __instance)
        {
            // Engineer Repair
            engineerRepairButton = new CustomButton(
                () => {
                engineerRepairButton.Timer = 0f;

                MessageWriter usedRepairWriter = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.EngineerUsedRepair, Hazel.SendOption.Reliable, -1);
                AmongUsClient.Instance.FinishRpcImmediately(usedRepairWriter);
                RPCProcedure.engineerUsedRepair();

                foreach (PlayerTask task in PlayerControl.LocalPlayer.myTasks)
                {
                    if (task.TaskType == TaskTypes.FixLights)
                    {
                        MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.EngineerFixLights, Hazel.SendOption.Reliable, -1);
                        AmongUsClient.Instance.FinishRpcImmediately(writer);
                        RPCProcedure.engineerFixLights();
                    }
                    else if (task.TaskType == TaskTypes.RestoreOxy)
                    {
                        ShipStatus.Instance.RpcRepairSystem(SystemTypes.LifeSupp, 0 | 64);
                        ShipStatus.Instance.RpcRepairSystem(SystemTypes.LifeSupp, 1 | 64);
                    }
                    else if (task.TaskType == TaskTypes.ResetReactor)
                    {
                        ShipStatus.Instance.RpcRepairSystem(SystemTypes.Reactor, 16);
                    }
                    else if (task.TaskType == TaskTypes.ResetSeismic)
                    {
                        ShipStatus.Instance.RpcRepairSystem(SystemTypes.Laboratory, 16);
                    }
                    else if (task.TaskType == TaskTypes.FixComms)
                    {
                        ShipStatus.Instance.RpcRepairSystem(SystemTypes.Comms, 16 | 0);
                        ShipStatus.Instance.RpcRepairSystem(SystemTypes.Comms, 16 | 1);
                    }
                }
            },
                () => { return(Engineer.engineer != null && Engineer.engineer == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead); },
                () => {
                bool sabotageActive = false;
                foreach (PlayerTask task in PlayerControl.LocalPlayer.myTasks)
                {
                    if (task.TaskType == TaskTypes.FixLights || task.TaskType == TaskTypes.RestoreOxy || task.TaskType == TaskTypes.ResetReactor || task.TaskType == TaskTypes.ResetSeismic || task.TaskType == TaskTypes.FixComms)
                    {
                        sabotageActive = true;
                    }
                }
                return(sabotageActive && !Engineer.usedRepair && PlayerControl.LocalPlayer.CanMove);
            },
                () => {},
                Engineer.getButtonSprite(),
                new Vector3(-1.3f, 0, 0),
                __instance
                );

            // Janitor Clean
            janitorCleanButton = new CustomButton(
                () => {
                foreach (Collider2D collider2D in Physics2D.OverlapCircleAll(PlayerControl.LocalPlayer.GetTruePosition(), PlayerControl.LocalPlayer.MaxReportDistance, Constants.PlayersOnlyMask))
                {
                    if (collider2D.tag == "DeadBody")
                    {
                        DeadBody component = collider2D.GetComponent <DeadBody>();
                        if (component && !component.Reported)
                        {
                            Vector2 truePosition  = PlayerControl.LocalPlayer.GetTruePosition();
                            Vector2 truePosition2 = component.TruePosition;
                            if (Vector2.Distance(truePosition2, truePosition) <= PlayerControl.LocalPlayer.MaxReportDistance && PlayerControl.LocalPlayer.CanMove && !PhysicsHelpers.AnythingBetween(truePosition, truePosition2, Constants.ShipAndObjectsMask, false))
                            {
                                GameData.PlayerInfo playerInfo = GameData.Instance.GetPlayerById(component.ParentId);

                                MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.JanitorClean, Hazel.SendOption.Reliable, -1);
                                writer.Write(playerInfo.PlayerId);
                                AmongUsClient.Instance.FinishRpcImmediately(writer);
                                RPCProcedure.janitorClean(playerInfo.PlayerId);
                                janitorCleanButton.Timer = janitorCleanButton.MaxTimer;

                                break;
                            }
                        }
                    }
                }
            },
                () => { return(Janitor.janitor != null && Janitor.janitor == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead); },
                () => { return(__instance.ReportButton.renderer.color == Palette.EnabledColor && PlayerControl.LocalPlayer.CanMove); },
                () => { janitorCleanButton.Timer = janitorCleanButton.MaxTimer; },
                Janitor.getButtonSprite(),
                new Vector3(-1.3f, 0, 0),
                __instance
                );

            // Sheriff Kill
            sheriffKillButton = new CustomButton(
                () => {
                if (Medic.shielded != null && Medic.shielded == Sheriff.currentTarget)
                {
                    MessageWriter attemptWriter = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ShieldedMurderAttempt, Hazel.SendOption.Reliable, -1);
                    AmongUsClient.Instance.FinishRpcImmediately(attemptWriter);
                    RPCProcedure.shieldedMurderAttempt();
                    return;
                }

                byte targetId = 0;
                if (Sheriff.currentTarget.Data.IsImpostor ||
                    Sheriff.currentTarget == Jackal.jackal ||
                    Sheriff.currentTarget == Sidekick.sidekick ||
                    (Sheriff.jesterCanDieToSheriff && Jester.jester != null && Jester.jester == Sheriff.currentTarget))
                {
                    targetId = Sheriff.currentTarget.PlayerId;
                }
                else
                {
                    targetId = PlayerControl.LocalPlayer.PlayerId;
                }
                MessageWriter killWriter = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SheriffKill, Hazel.SendOption.Reliable, -1);
                killWriter.Write(targetId);
                AmongUsClient.Instance.FinishRpcImmediately(killWriter);
                RPCProcedure.sheriffKill(targetId);

                sheriffKillButton.Timer = sheriffKillButton.MaxTimer;
                Sheriff.currentTarget   = null;
            },
                () => { return(Sheriff.sheriff != null && Sheriff.sheriff == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead); },
                () => { return(Sheriff.currentTarget && PlayerControl.LocalPlayer.CanMove); },
                () => { sheriffKillButton.Timer = sheriffKillButton.MaxTimer; },
                __instance.KillButton.renderer.sprite,
                new Vector3(-1.3f, 0, 0),
                __instance
                );

            // Time Master Rewind Time
            timeMasterRewindTimeButton = new CustomButton(
                () => {
                MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.TimeMasterRewindTime, Hazel.SendOption.Reliable, -1);
                AmongUsClient.Instance.FinishRpcImmediately(writer);
                RPCProcedure.timeMasterRewindTime();
                timeMasterRewindTimeButton.Timer = timeMasterRewindTimeButton.MaxTimer;
            },
                () => { return(TimeMaster.timeMaster != null && TimeMaster.timeMaster == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead); },
                () => { return(PlayerControl.LocalPlayer.CanMove); },
                () => { timeMasterRewindTimeButton.Timer = timeMasterRewindTimeButton.MaxTimer; },
                TimeMaster.getButtonSprite(),
                new Vector3(-1.3f, 0, 0),
                __instance
                );

            // Medic Shield
            medicShieldButton = new CustomButton(
                () => {
                medicShieldButton.Timer = 0f;

                MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.MedicSetShielded, Hazel.SendOption.Reliable, -1);
                writer.Write(Medic.currentTarget.PlayerId);
                AmongUsClient.Instance.FinishRpcImmediately(writer);
                RPCProcedure.medicSetShielded(Medic.currentTarget.PlayerId);
            },
                () => { return(Medic.medic != null && Medic.medic == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead); },
                () => { return(!Medic.usedShield && Medic.currentTarget && PlayerControl.LocalPlayer.CanMove); },
                () => {},
                Medic.getButtonSprite(),
                new Vector3(-1.3f, 0, 0),
                __instance
                );


            // Shifter shift
            shifterShiftButton = new CustomButton(
                () => {
                shifterShiftButton.Timer = shifterShiftButton.MaxTimer;

                MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ShifterShift, Hazel.SendOption.Reliable, -1);
                writer.Write(Shifter.currentTarget.PlayerId);
                AmongUsClient.Instance.FinishRpcImmediately(writer);

                RPCProcedure.shifterShift(Shifter.currentTarget.PlayerId);
            },
                () => { return(Shifter.shifter != null && Shifter.shifter == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead); },
                () => { return(Shifter.currentTarget && PlayerControl.LocalPlayer.CanMove); },
                () => { shifterShiftButton.Timer = shifterShiftButton.MaxTimer; },
                Shifter.getButtonSprite(),
                new Vector3(-1.3f, 0, 0),
                __instance
                );

            // Seer reveal
            seerRevealButton = new CustomButton(
                () => {
                seerRevealButton.Timer = seerRevealButton.MaxTimer;

                PlayerControl targetOrMistake = Seer.currentTarget;
                if (rnd.Next(1, 101) > Seer.chanceOfSeeingRight)
                {
                    var players = PlayerControl.AllPlayerControls.ToArray().ToList();
                    players.RemoveAll(p => p != null && (p.PlayerId == Seer.seer.PlayerId || p.PlayerId == Seer.currentTarget.PlayerId));
                    int index = rnd.Next(0, players.Count);

                    if (players.Count != 0 && players[index] != null)
                    {
                        targetOrMistake = players[index];
                    }
                }

                MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SeerReveal, Hazel.SendOption.Reliable, -1);
                writer.Write(Seer.currentTarget.PlayerId);
                writer.Write(targetOrMistake.PlayerId);
                AmongUsClient.Instance.FinishRpcImmediately(writer);

                RPCProcedure.seerReveal(Seer.currentTarget.PlayerId, targetOrMistake.PlayerId);
            },
                () => { return(Seer.seer != null && Seer.seer == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead); },
                () => { return(Seer.currentTarget && PlayerControl.LocalPlayer.CanMove); },
                () => {},
                Seer.getButtonSprite(),
                new Vector3(-1.3f, 0, 0),
                __instance
                );

            // Morphling morph
            morphlingButton = new CustomButton(
                () => {
                if (Morphling.sampledTarget != null)
                {
                    MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.MorphlingMorph, Hazel.SendOption.Reliable, -1);
                    writer.Write(Morphling.sampledTarget.PlayerId);
                    AmongUsClient.Instance.FinishRpcImmediately(writer);
                    RPCProcedure.morphlingMorph(Morphling.sampledTarget.PlayerId);
                    Morphling.sampledTarget   = null;
                    morphlingButton.HasEffect = true;     // Trigger effect on this click
                }
                else if (Morphling.currentTarget != null)
                {
                    Morphling.sampledTarget   = Morphling.currentTarget;
                    morphlingButton.Sprite    = Morphling.getMorphSprite();
                    morphlingButton.HasEffect = false;     // Block effect on this click
                }
            },
                () => { return(Morphling.morphling != null && Morphling.morphling == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead); },
                () => { return((Morphling.currentTarget || Morphling.sampledTarget) && PlayerControl.LocalPlayer.CanMove); },
                () => {
                morphlingButton.Timer          = morphlingButton.MaxTimer;
                morphlingButton.Sprite         = Morphling.getSampleSprite();
                morphlingButton.isEffectActive = false;
                morphlingButton.killButtonManager.TimerText.Color = Palette.EnabledColor;
                Morphling.sampledTarget = null;
            },
                Morphling.getSampleSprite(),
                new Vector3(-1.3f, 1.3f, 0f),
                __instance,
                true,
                10f,
                () => {
                morphlingButton.Timer  = morphlingButton.MaxTimer;
                morphlingButton.Sprite = Morphling.getSampleSprite();
            }
                );

            // Camouflager camouflage
            camouflagerButton = new CustomButton(
                () => {
                MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.CamouflagerCamouflage, Hazel.SendOption.Reliable, -1);
                AmongUsClient.Instance.FinishRpcImmediately(writer);
                RPCProcedure.camouflagerCamouflage();
            },
                () => { return(Camouflager.camouflager != null && Camouflager.camouflager == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead); },
                () => { return(PlayerControl.LocalPlayer.CanMove); },
                () => {
                camouflagerButton.Timer          = camouflagerButton.MaxTimer;
                camouflagerButton.isEffectActive = false;
                camouflagerButton.killButtonManager.TimerText.Color = Palette.EnabledColor;
            },
                Camouflager.getButtonSprite(),
                new Vector3(-1.3f, 1.3f, 0f),
                __instance,
                true,
                10f,
                () => { camouflagerButton.Timer = camouflagerButton.MaxTimer; }
                );

            // Spy button
            spyButton = new CustomButton(
                () => {
                Spy.spyTimer = Spy.duration;
            },
                () => { return(Spy.spy != null && Spy.spy == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead); },
                () => { return(PlayerControl.LocalPlayer.CanMove); },
                () => {
                spyButton.Timer          = spyButton.MaxTimer;
                spyButton.isEffectActive = false;
                spyButton.killButtonManager.TimerText.Color = Palette.EnabledColor;
            },
                Spy.getButtonSprite(),
                new Vector3(-1.3f, 0, 0),
                __instance,
                true,
                0f,
                () => {
                spyButton.Timer = spyButton.MaxTimer;
            }
                );

            // Tracker button
            trackerButton = new CustomButton(
                () => {
                MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.TrackerUsedTracker, Hazel.SendOption.Reliable, -1);
                writer.Write(Tracker.currentTarget.PlayerId);
                AmongUsClient.Instance.FinishRpcImmediately(writer);
                RPCProcedure.trackerUsedTracker(Tracker.currentTarget.PlayerId);
            },
                () => { return(Tracker.tracker != null && Tracker.tracker == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead); },
                () => { return(PlayerControl.LocalPlayer.CanMove && Tracker.currentTarget != null && !Tracker.usedTracker); },
                () => { },
                Tracker.getButtonSprite(),
                new Vector3(-1.3f, 0, 0),
                __instance
                );

            vampireKillButton = new CustomButton(
                () => {
                if (Helpers.handleMurderAttempt(Vampire.currentTarget))
                {
                    if (Vampire.targetNearGarlic)
                    {
                        PlayerControl.LocalPlayer.RpcMurderPlayer(Vampire.currentTarget);
                        vampireKillButton.HasEffect = false;     // Block effect on this click
                        vampireKillButton.Timer     = vampireKillButton.MaxTimer;
                    }
                    else
                    {
                        Vampire.bitten = Vampire.currentTarget;
                        Reactor.Coroutines.Start(Vampire.killWithDelay());
                        MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.VampireBiteNotification, Hazel.SendOption.Reliable, -1);
                        writer.Write(Vampire.bitten.PlayerId);
                        AmongUsClient.Instance.FinishRpcImmediately(writer);
                        RPCProcedure.vampireBiteNotification(Vampire.bitten.PlayerId);
                        vampireKillButton.HasEffect = true;     // Trigger effect on this click
                    }
                }
                else
                {
                    vampireKillButton.HasEffect = false;     // Block effect if no action was fired
                }
            },
                () => { return(Vampire.vampire != null && Vampire.vampire == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead); },
                () => {
                if (Vampire.targetNearGarlic && Vampire.canKillNearGarlics)
                {
                    vampireKillButton.killButtonManager.renderer.sprite = __instance.KillButton.renderer.sprite;
                }
                else
                {
                    vampireKillButton.killButtonManager.renderer.sprite = Vampire.getButtonSprite();
                }
                return(Vampire.currentTarget != null && PlayerControl.LocalPlayer.CanMove && (!Vampire.targetNearGarlic || Vampire.canKillNearGarlics));
            },
                () => {
                vampireKillButton.Timer          = vampireKillButton.MaxTimer;
                vampireKillButton.isEffectActive = false;
                vampireKillButton.killButtonManager.TimerText.Color = Palette.EnabledColor;
            },
                Vampire.getButtonSprite(),
                new Vector3(-1.3f, 0, 0),
                __instance,
                false,
                0f,
                () => {
                vampireKillButton.Timer = vampireKillButton.MaxTimer;
            }
                );

            garlicButton = new CustomButton(
                () => {
                Vampire.localPlacedGarlic = true;
                var pos     = PlayerControl.LocalPlayer.transform.position;
                byte[] buff = new byte[sizeof(float) * 2];
                Buffer.BlockCopy(BitConverter.GetBytes(pos.x), 0, buff, 0 * sizeof(float), sizeof(float));
                Buffer.BlockCopy(BitConverter.GetBytes(pos.y), 0, buff, 1 * sizeof(float), sizeof(float));

                MessageWriter writer = AmongUsClient.Instance.StartRpc(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.PlaceGarlic, Hazel.SendOption.Reliable);
                writer.WriteBytesAndSize(buff);
                writer.EndMessage();
                RPCProcedure.placeGarlic(buff);
            },
                () => { return(!Vampire.localPlacedGarlic && !PlayerControl.LocalPlayer.Data.IsDead && Vampire.garlicsActive); },
                () => { return(PlayerControl.LocalPlayer.CanMove && !Vampire.localPlacedGarlic); },
                () => { },
                Vampire.getGarlicButtonSprite(),
                Vector3.zero,
                __instance,
                true
                );


            // Jackal Sidekick Button
            jackalSidekickButton = new CustomButton(
                () => {
                MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.JackalCreatesSidekick, Hazel.SendOption.Reliable, -1);
                writer.Write(Jackal.currentTarget.PlayerId);
                AmongUsClient.Instance.FinishRpcImmediately(writer);
                RPCProcedure.jackalCreatesSidekick(Jackal.currentTarget.PlayerId);
            },
                () => { return(Jackal.canCreateSidekick && Sidekick.sidekick == null && Jackal.fakeSidekick == null && Jackal.jackal != null && Jackal.jackal == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead); },
                () => { return(Sidekick.sidekick == null && Jackal.fakeSidekick == null && Jackal.currentTarget != null && PlayerControl.LocalPlayer.CanMove); },
                () => { jackalSidekickButton.Timer = jackalSidekickButton.MaxTimer; },
                Jackal.getSidekickButtonSprite(),
                new Vector3(-1.3f, 1.3f, 0f),
                __instance
                );

            // Jackal Kill
            jackalKillButton = new CustomButton(
                () => {
                if (!Helpers.handleMurderAttempt(Jackal.currentTarget))
                {
                    return;
                }
                byte targetId            = Jackal.currentTarget.PlayerId;
                MessageWriter killWriter = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.JackalKill, Hazel.SendOption.Reliable, -1);
                killWriter.Write(targetId);
                AmongUsClient.Instance.FinishRpcImmediately(killWriter);
                RPCProcedure.jackalKill(targetId);
                jackalKillButton.Timer = jackalKillButton.MaxTimer;
                Jackal.currentTarget   = null;
            },
                () => { return(Jackal.jackal != null && Jackal.jackal == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead); },
                () => { return(Jackal.currentTarget && PlayerControl.LocalPlayer.CanMove); },
                () => { jackalKillButton.Timer = jackalKillButton.MaxTimer; },
                __instance.KillButton.renderer.sprite,
                new Vector3(-1.3f, 0, 0),
                __instance
                );

            // Sidekick Kill
            sidekickKillButton = new CustomButton(
                () => {
                if (!Helpers.handleMurderAttempt(Sidekick.currentTarget))
                {
                    return;
                }
                byte targetId            = Sidekick.currentTarget.PlayerId;
                MessageWriter killWriter = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SidekickKill, Hazel.SendOption.Reliable, -1);
                killWriter.Write(targetId);
                AmongUsClient.Instance.FinishRpcImmediately(killWriter);
                RPCProcedure.sidekickKill(targetId);

                sidekickKillButton.Timer = sidekickKillButton.MaxTimer;
                Sidekick.currentTarget   = null;
            },
                () => { return(Sidekick.canKill && Sidekick.sidekick != null && Sidekick.sidekick == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead); },
                () => { return(Sidekick.currentTarget && PlayerControl.LocalPlayer.CanMove); },
                () => { sidekickKillButton.Timer = sidekickKillButton.MaxTimer; },
                __instance.KillButton.renderer.sprite,
                new Vector3(-1.3f, 0, 0),
                __instance
                );
        }
Ejemplo n.º 4
0
        static void Postfix(byte ONIABIILFGF, MessageReader JIGFBHFFNFI)
        {
            byte          packetId = ONIABIILFGF;
            MessageReader reader   = JIGFBHFFNFI;

            switch (packetId)
            {
            // Main Controls

            case (byte)CustomRPC.ResetVaribles:
                RPCProcedure.resetVariables();
                break;

            case (byte)CustomRPC.ShareOptionSelection:
                uint id        = JIGFBHFFNFI.ReadPackedUInt32();
                uint selection = JIGFBHFFNFI.ReadPackedUInt32();
                RPCProcedure.shareOptionSelection(id, selection);
                break;

            case (byte)CustomRPC.ForceEnd:
                RPCProcedure.forceEnd();
                break;

            case (byte)CustomRPC.SetRole:
                byte roleId   = JIGFBHFFNFI.ReadByte();
                byte playerId = JIGFBHFFNFI.ReadByte();
                RPCProcedure.setRole(roleId, playerId);
                break;

            case (byte)CustomRPC.SetUncheckedColor:
                byte c = JIGFBHFFNFI.ReadByte();
                byte p = JIGFBHFFNFI.ReadByte();
                RPCProcedure.setUncheckedColor(c, p);
                break;

            case (byte)CustomRPC.VersionHandshake:
                byte major          = JIGFBHFFNFI.ReadByte();
                byte minor          = JIGFBHFFNFI.ReadByte();
                byte patch          = JIGFBHFFNFI.ReadByte();
                int  versionOwnerId = JIGFBHFFNFI.ReadPackedInt32();
                RPCProcedure.versionHandshake(major, minor, patch, versionOwnerId);
                break;

            case (byte)CustomRPC.UseUncheckedVent:
                int  ventId        = JIGFBHFFNFI.ReadPackedInt32();
                byte ventingPlayer = JIGFBHFFNFI.ReadByte();
                byte isEnter       = JIGFBHFFNFI.ReadByte();
                RPCProcedure.useUncheckedVent(ventId, ventingPlayer, isEnter);
                break;

            case (byte)CustomRPC.UncheckedMurderPlayer:
                byte source = JIGFBHFFNFI.ReadByte();
                byte target = JIGFBHFFNFI.ReadByte();
                RPCProcedure.uncheckedMurderPlayer(source, target);
                break;

            // Role functionality

            case (byte)CustomRPC.EngineerFixLights:
                RPCProcedure.engineerFixLights();
                break;

            case (byte)CustomRPC.EngineerUsedRepair:
                RPCProcedure.engineerUsedRepair();
                break;

            case (byte)CustomRPC.JanitorClean:
                RPCProcedure.janitorClean(JIGFBHFFNFI.ReadByte());
                break;

            case (byte)CustomRPC.SheriffKill:
                RPCProcedure.sheriffKill(JIGFBHFFNFI.ReadByte());
                break;

            case (byte)CustomRPC.TimeMasterRewindTime:
                RPCProcedure.timeMasterRewindTime();
                break;

            case (byte)CustomRPC.TimeMasterShield:
                RPCProcedure.timeMasterShield();
                break;

            case (byte)CustomRPC.MedicSetShielded:
                RPCProcedure.medicSetShielded(JIGFBHFFNFI.ReadByte());
                break;

            case (byte)CustomRPC.ShieldedMurderAttempt:
                RPCProcedure.shieldedMurderAttempt();
                break;

            case (byte)CustomRPC.ShifterShift:
                RPCProcedure.shifterShift(JIGFBHFFNFI.ReadByte());
                break;

            case (byte)CustomRPC.SwapperSwap:
                byte playerId1 = JIGFBHFFNFI.ReadByte();
                byte playerId2 = JIGFBHFFNFI.ReadByte();
                RPCProcedure.swapperSwap(playerId1, playerId2);
                break;

            case (byte)CustomRPC.MorphlingMorph:
                RPCProcedure.morphlingMorph(JIGFBHFFNFI.ReadByte());
                break;

            case (byte)CustomRPC.CamouflagerCamouflage:
                RPCProcedure.camouflagerCamouflage();
                break;

            case (byte)CustomRPC.LoverSuicide:
                RPCProcedure.loverSuicide(JIGFBHFFNFI.ReadByte());
                break;

            case (byte)CustomRPC.VampireSetBitten:
                byte bittenId = JIGFBHFFNFI.ReadByte();
                byte reset    = JIGFBHFFNFI.ReadByte();
                RPCProcedure.vampireSetBitten(bittenId, reset);
                break;

            case (byte)CustomRPC.VampireTryKill:
                RPCProcedure.vampireTryKill();
                break;

            case (byte)CustomRPC.PlaceGarlic:
                RPCProcedure.placeGarlic(JIGFBHFFNFI.ReadBytesAndSize());
                break;

            case (byte)CustomRPC.TrackerUsedTracker:
                RPCProcedure.trackerUsedTracker(JIGFBHFFNFI.ReadByte());
                break;

            case (byte)CustomRPC.JackalKill:
                RPCProcedure.jackalKill(JIGFBHFFNFI.ReadByte());
                break;

            case (byte)CustomRPC.SidekickKill:
                RPCProcedure.sidekickKill(JIGFBHFFNFI.ReadByte());
                break;

            case (byte)CustomRPC.JackalCreatesSidekick:
                RPCProcedure.jackalCreatesSidekick(JIGFBHFFNFI.ReadByte());
                break;

            case (byte)CustomRPC.SidekickPromotes:
                RPCProcedure.sidekickPromotes();
                break;

            case (byte)CustomRPC.ErasePlayerRole:
                RPCProcedure.erasePlayerRole(JIGFBHFFNFI.ReadByte());
                break;

            case (byte)CustomRPC.SetFutureErased:
                RPCProcedure.setFutureErased(JIGFBHFFNFI.ReadByte());
                break;

            case (byte)CustomRPC.SetFutureShifted:
                RPCProcedure.setFutureShifted(JIGFBHFFNFI.ReadByte());
                break;

            case (byte)CustomRPC.PlaceJackInTheBox:
                RPCProcedure.placeJackInTheBox(JIGFBHFFNFI.ReadBytesAndSize());
                break;

            case (byte)CustomRPC.LightsOut:
                RPCProcedure.lightsOut();
                break;
            }
        }
Ejemplo n.º 5
0
        static void Postfix(byte GIICFHKILOB, MessageReader DOOILGKLBBF)
        {
            byte          packetId = GIICFHKILOB;
            MessageReader reader   = DOOILGKLBBF;

            switch (packetId)
            {
            // Main Controls

            case (byte)CustomRPC.ResetVaribles:
                RPCProcedure.resetVariables();
                break;

            case (byte)CustomRPC.ShareOptionSelection:
                uint id        = DOOILGKLBBF.ReadPackedUInt32();
                uint selection = DOOILGKLBBF.ReadPackedUInt32();
                RPCProcedure.shareOptionSelection(id, selection);
                break;

            case (byte)CustomRPC.ForceEnd:
                RPCProcedure.forceEnd();
                break;

            case (byte)CustomRPC.SetRole:
                byte roleId   = DOOILGKLBBF.ReadByte();
                byte playerId = DOOILGKLBBF.ReadByte();
                RPCProcedure.setRole(roleId, playerId);
                break;


            // Role functionality

            case (byte)CustomRPC.EngineerFixLights:
                RPCProcedure.engineerFixLights();
                break;

            case (byte)CustomRPC.EngineerUsedRepair:
                RPCProcedure.engineerUsedRepair();
                break;

            case (byte)CustomRPC.JanitorClean:
                RPCProcedure.janitorClean(DOOILGKLBBF.ReadByte());
                break;

            case (byte)CustomRPC.SheriffKill:
                RPCProcedure.sheriffKill(DOOILGKLBBF.ReadByte());
                break;

            case (byte)CustomRPC.TimeMasterRewindTime:
                RPCProcedure.timeMasterRewindTime();
                break;

            case (byte)CustomRPC.TimeMasterShield:
                RPCProcedure.timeMasterShield();
                break;

            case (byte)CustomRPC.MedicSetShielded:
                RPCProcedure.medicSetShielded(DOOILGKLBBF.ReadByte());
                break;

            case (byte)CustomRPC.ShieldedMurderAttempt:
                RPCProcedure.shieldedMurderAttempt();
                break;

            case (byte)CustomRPC.ShifterShift:
                RPCProcedure.shifterShift(DOOILGKLBBF.ReadByte());
                break;

            case (byte)CustomRPC.SwapperSwap:
                byte playerId1 = DOOILGKLBBF.ReadByte();
                byte playerId2 = DOOILGKLBBF.ReadByte();
                RPCProcedure.swapperSwap(playerId1, playerId2);
                break;

            case (byte)CustomRPC.MorphlingMorph:
                RPCProcedure.morphlingMorph(DOOILGKLBBF.ReadByte());
                break;

            case (byte)CustomRPC.CamouflagerCamouflage:
                RPCProcedure.camouflagerCamouflage();
                break;

            case (byte)CustomRPC.LoverSuicide:
                RPCProcedure.loverSuicide(DOOILGKLBBF.ReadByte());
                break;

            case (byte)CustomRPC.VampireSetBitten:
                byte bittenId = DOOILGKLBBF.ReadByte();
                byte reset    = DOOILGKLBBF.ReadByte();
                RPCProcedure.vampireSetBitten(bittenId, reset);
                break;

            case (byte)CustomRPC.VampireTryKill:
                RPCProcedure.vampireTryKill();
                break;

            case (byte)CustomRPC.PlaceGarlic:
                RPCProcedure.placeGarlic(DOOILGKLBBF.ReadBytesAndSize());
                break;

            case (byte)CustomRPC.TrackerUsedTracker:
                RPCProcedure.trackerUsedTracker(DOOILGKLBBF.ReadByte());
                break;

            case (byte)CustomRPC.JackalKill:
                RPCProcedure.jackalKill(DOOILGKLBBF.ReadByte());
                break;

            case (byte)CustomRPC.SidekickKill:
                RPCProcedure.sidekickKill(DOOILGKLBBF.ReadByte());
                break;

            case (byte)CustomRPC.JackalCreatesSidekick:
                RPCProcedure.jackalCreatesSidekick(DOOILGKLBBF.ReadByte());
                break;

            case (byte)CustomRPC.SidekickPromotes:
                RPCProcedure.sidekickPromotes();
                break;

            case (byte)CustomRPC.ErasePlayerRole:
                RPCProcedure.erasePlayerRole(DOOILGKLBBF.ReadByte());
                break;

            case (byte)CustomRPC.SetFutureErased:
                RPCProcedure.setFutureErased(DOOILGKLBBF.ReadByte());
                break;

            case (byte)CustomRPC.SetFutureShifted:
                RPCProcedure.setFutureShifted(DOOILGKLBBF.ReadByte());
                break;
            }
        }