예제 #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.None, -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.None, -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 && __instance.UseButton.isActiveAndEnabled && !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);
            },
                false,
                Engineer.getButtonSprite(),
                Vector3.zero,
                __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.None, -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 && __instance.UseButton.isActiveAndEnabled && !PlayerControl.LocalPlayer.Data.IsDead); },
                () => { return(__instance.ReportButton.renderer.color == Palette.EnabledColor && PlayerControl.LocalPlayer.CanMove); },
                true,
                Janitor.getButtonSprite(),
                Vector3.zero,
                __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.None, -1);
                    AmongUsClient.Instance.FinishRpcImmediately(attemptWriter);
                    RPCProcedure.shieldedMurderAttempt();

                    return;
                }

                byte targetId = 0;
                if (Sheriff.currentTarget.Data.IsImpostor || (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.None, -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 && __instance.UseButton.isActiveAndEnabled && !PlayerControl.LocalPlayer.Data.IsDead); },
                () => { return(Sheriff.currentTarget && PlayerControl.LocalPlayer.CanMove); },
                true,
                __instance.KillButton.renderer.sprite,
                Vector3.zero,
                __instance
                );

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

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

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


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

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

                RPCProcedure.shifterShift(Shifter.currentTarget.PlayerId);
            },
                () => { return(Shifter.shifter != null && Shifter.shifter == PlayerControl.LocalPlayer && __instance.UseButton.isActiveAndEnabled && !PlayerControl.LocalPlayer.Data.IsDead); },
                () => { return(Shifter.currentTarget && PlayerControl.LocalPlayer.CanMove); },
                true,
                Shifter.getButtonSprite(),
                Vector3.zero,
                __instance
                );

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

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

                RPCProcedure.seerReveal(Seer.currentTarget.PlayerId);
            },
                () => { return(Seer.seer != null && Seer.seer == PlayerControl.LocalPlayer && __instance.UseButton.isActiveAndEnabled && !PlayerControl.LocalPlayer.Data.IsDead); },
                () => { return(Seer.currentTarget && PlayerControl.LocalPlayer.CanMove); },
                false,
                Seer.getButtonSprite(),
                Vector3.zero,
                __instance
                );

            // Morphling morph
            morphlingButton = new CustomButton(
                () => {
                if (Morphling.sampledTarget != null)
                {
                    MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.MorphlingMorph, Hazel.SendOption.None, -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 && __instance.UseButton.isActiveAndEnabled && !PlayerControl.LocalPlayer.Data.IsDead); },
                () => { return((Morphling.currentTarget || Morphling.sampledTarget) && PlayerControl.LocalPlayer.CanMove); },
                true,
                Morphling.getSampleSprite(),
                new Vector3(0f, 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.None, -1);
                AmongUsClient.Instance.FinishRpcImmediately(writer);
                RPCProcedure.camouflagerCamouflage();
            },
                () => { return(Camouflager.camouflager != null && Camouflager.camouflager == PlayerControl.LocalPlayer && __instance.UseButton.isActiveAndEnabled && !PlayerControl.LocalPlayer.Data.IsDead); },
                () => { return(PlayerControl.LocalPlayer.CanMove); },
                true,
                Camouflager.getButtonSprite(),
                new Vector3(0f, 1.3f, 0f),
                __instance,
                true,
                10f,
                () => { camouflagerButton.Timer = camouflagerButton.MaxTimer; }
                );
        }
예제 #2
0
        public static void Postfix(Il2CppReferenceArray <GameData.PlayerInfo> FMAOEJEHPAO)
        {
            MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ResetVaribles, Hazel.SendOption.None, -1);

            AmongUsClient.Instance.FinishRpcImmediately(writer);
            RPCProcedure.resetVariables();

            List <PlayerControl> crewmates = PlayerControl.AllPlayerControls.ToArray().ToList().OrderBy(x => Guid.NewGuid()).ToList();

            crewmates.RemoveAll(x => x.Data.IsImpostor);
            List <PlayerControl> impostors = PlayerControl.AllPlayerControls.ToArray().ToList().OrderBy(x => Guid.NewGuid()).ToList();

            impostors.RemoveAll(x => !x.Data.IsImpostor);

            // Special roles impostors can be converted to
            if (impostors.Count >= 3 && (rnd.Next(1, 101) <= BonusRolesPlugin.mafiaSpawnChance.GetValue()))
            {
                setRoleToRandomPlayer((byte)RoleId.Godfather, impostors);
                setRoleToRandomPlayer((byte)RoleId.Janitor, impostors);
                setRoleToRandomPlayer((byte)RoleId.Mafioso, impostors);
            }

            // Special roles that involve crewmates and impostors
            if (rnd.Next(1, 101) <= BonusRolesPlugin.loversSpawnChance.GetValue())
            {
                if (impostors.Count > 0 && crewmates.Count > 0 && rnd.Next(1, 101) <= 33)
                {
                    setRoleToRandomPlayer((byte)RoleId.Lover1, impostors);
                    setRoleToRandomPlayer((byte)RoleId.Lover2, crewmates);
                }
                else if (crewmates.Count >= 2)
                {
                    setRoleToRandomPlayer((byte)RoleId.Lover1, crewmates);
                    setRoleToRandomPlayer((byte)RoleId.Lover2, crewmates);
                }
            }

            // Special roles impostors can be converted to
            if (impostors.Count >= 1 && (rnd.Next(1, 101) <= BonusRolesPlugin.morphlingSpawnChance.GetValue()))
            {
                setRoleToRandomPlayer((byte)RoleId.Morphling, impostors);
            }

            if (impostors.Count >= 1 && (rnd.Next(1, 101) <= BonusRolesPlugin.camouflagerSpawnChance.GetValue()))
            {
                setRoleToRandomPlayer((byte)RoleId.Camouflager, impostors);
            }

            // Special roles crewmates can be converted to
            if (crewmates.Count > 0 && (rnd.Next(1, 101) <= BonusRolesPlugin.jesterSpawnChance.GetValue()))
            {
                setRoleToRandomPlayer((byte)RoleId.Jester, crewmates);
            }
            if (crewmates.Count > 0 && (rnd.Next(1, 101) <= BonusRolesPlugin.mayorSpawnChance.GetValue()))
            {
                setRoleToRandomPlayer((byte)RoleId.Mayor, crewmates);
            }
            if (crewmates.Count > 0 && (rnd.Next(1, 101) <= BonusRolesPlugin.engineerSpawnChance.GetValue()))
            {
                setRoleToRandomPlayer((byte)RoleId.Engineer, crewmates);
            }
            if (crewmates.Count > 0 && (rnd.Next(1, 101) <= BonusRolesPlugin.sheriffSpawnChance.GetValue()))
            {
                setRoleToRandomPlayer((byte)RoleId.Sheriff, crewmates);
            }
            if (crewmates.Count > 0 && (rnd.Next(1, 101) <= BonusRolesPlugin.lighterSpawnChance.GetValue()))
            {
                setRoleToRandomPlayer((byte)RoleId.Lighter, crewmates);
            }
            if (crewmates.Count > 0 && (rnd.Next(1, 101) <= BonusRolesPlugin.detectiveSpawnChance.GetValue()))
            {
                setRoleToRandomPlayer((byte)RoleId.Detective, crewmates);
            }
            if (crewmates.Count > 0 && (rnd.Next(1, 101) <= BonusRolesPlugin.timeMasterSpawnChance.GetValue()))
            {
                setRoleToRandomPlayer((byte)RoleId.TimeMaster, crewmates);
            }
            if (crewmates.Count > 0 && (rnd.Next(1, 101) <= BonusRolesPlugin.medicSpawnChance.GetValue()))
            {
                setRoleToRandomPlayer((byte)RoleId.Medic, crewmates);
            }
            if (crewmates.Count > 0 && (rnd.Next(1, 101) <= BonusRolesPlugin.shifterSpawnChance.GetValue()))
            {
                setRoleToRandomPlayer((byte)RoleId.Shifter, crewmates);
            }
            if (crewmates.Count > 0 && (rnd.Next(1, 101) <= BonusRolesPlugin.swapperSpawnChance.GetValue()))
            {
                setRoleToRandomPlayer((byte)RoleId.Swapper, crewmates);
            }
            if (crewmates.Count > 0 && (rnd.Next(1, 101) <= BonusRolesPlugin.seerSpawnChance.GetValue()))
            {
                setRoleToRandomPlayer((byte)RoleId.Seer, crewmates);
            }
            if (crewmates.Count > 0 && (rnd.Next(1, 101) <= BonusRolesPlugin.spySpawnChance.GetValue()))
            {
                setRoleToRandomPlayer((byte)RoleId.Spy, crewmates);
            }
            if (crewmates.Count > 0 && (rnd.Next(1, 101) <= BonusRolesPlugin.childSpawnChance.GetValue()))
            {
                setRoleToRandomPlayer((byte)RoleId.Child, crewmates);
            }
        }
예제 #3
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.JesterWin:
                RPCProcedure.jesterWin();
                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.ChildDied:
                RPCProcedure.childDied();
                break;

            case (byte)CustomRPC.LoverSuicide:
                RPCProcedure.loverSuicide(HFPCBBHJIPJ.ReadByte());
                break;
            }
        }
예제 #4
0
        static void onClick(int i, MeetingHud __instance)
        {
            if (__instance.state == MeetingHud.VoteStates.Results)
            {
                return;
            }
            if (__instance.playerStates[i].isDead)
            {
                return;
            }

            int            selectedCount = selections.Where(b => b).Count();
            SpriteRenderer renderer      = renderers[i];

            if (selectedCount == 0)
            {
                renderer.color = Color.green;
                selections[i]  = true;
            }
            else if (selectedCount == 1)
            {
                if (selections[i])
                {
                    renderer.color = Color.red;
                    selections[i]  = false;
                }
                else
                {
                    selections[i]  = true;
                    renderer.color = Color.green;

                    PlayerVoteArea firstPlayer  = null;
                    PlayerVoteArea secondPlayer = null;
                    for (int A = 0; A < selections.Length; A++)
                    {
                        if (selections[A])
                        {
                            if (firstPlayer != null)
                            {
                                secondPlayer = __instance.playerStates[A];
                                break;
                            }
                            else
                            {
                                firstPlayer = __instance.playerStates[A];
                            }
                        }
                    }

                    if (firstPlayer != null && secondPlayer != null)
                    {
                        MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SwapperSwap, Hazel.SendOption.None, -1);
                        writer.Write((byte)firstPlayer.TargetPlayerId);
                        writer.Write((byte)secondPlayer.TargetPlayerId);
                        AmongUsClient.Instance.FinishRpcImmediately(writer);

                        RPCProcedure.swapperSwap((byte)firstPlayer.TargetPlayerId, (byte)secondPlayer.TargetPlayerId);
                    }
                }
            }
        }