Пример #1
0
        static void Postfix(byte HKHMBLJFLMC, MessageReader ALMCIJKELCP)
        {
            byte          packetId = HKHMBLJFLMC;
            MessageReader reader   = ALMCIJKELCP;

            switch (packetId)
            {
            case (byte)CustomRPC.SetSheriff:
                byte SheriffId = ALMCIJKELCP.ReadByte();
                foreach (PlayerControl player in PlayerControl.AllPlayerControls)
                {
                    if (player.PlayerId == SheriffId)
                    {
                        player.getModdedControl().Role = "Sheriff";
                    }
                }
                break;

            case (byte)CustomRPC.SheriffKill:
                PlayerControl killer = PlayerTools.getPlayerById(reader.ReadByte());
                PlayerControl target = PlayerTools.getPlayerById(reader.ReadByte());
                if (killer.isPlayerRole("Sheriff"))
                {
                    killer.MurderPlayer(target);
                }
                break;

            case (byte)CustomRPC.SetLocalPlayers:
                localPlayers.Clear();
                localPlayer = PlayerControl.LocalPlayer;
                var localPlayerBytes = ALMCIJKELCP.ReadBytesAndSize();
                foreach (byte id in localPlayerBytes)
                {
                    foreach (PlayerControl player in PlayerControl.AllPlayerControls)
                    {
                        if (player.PlayerId == id)
                        {
                            localPlayers.Add(player);
                        }
                    }
                }
                break;

            case (byte)CustomRPC.ResetVariables:
                Main.Logic.AllModPlayerControl.Clear();
                List <PlayerControl> crewmates = PlayerControl.AllPlayerControls.ToArray().ToList();
                Main.Logic.WinReason = WinReasons.Crewmates;
                foreach (PlayerControl plr in crewmates)
                {
                    Main.Logic.AllModPlayerControl.Add(new ModPlayerControl {
                        PlayerControl = plr, Role = "Impostor", reportsLeft = MaxReportCount.GetValue(), LastAbilityTime = null
                    });
                }
                crewmates.RemoveAll(x => x.Data.IsImpostor);
                foreach (PlayerControl plr in crewmates)
                {
                    plr.getModdedControl().Role = "Crewmate";
                }
                break;

            case (byte)CustomRPC.SetJester:
                byte JesterId = ALMCIJKELCP.ReadByte();
                foreach (PlayerControl player in PlayerControl.AllPlayerControls)
                {
                    if (player.PlayerId == JesterId)
                    {
                        player.getModdedControl().Role = "Jester";
                    }
                }
                break;

            case (byte)CustomRPC.JesterWin:
                foreach (PlayerControl player in PlayerControl.AllPlayerControls)
                {
                    if (!player.isPlayerRole("Jester"))
                    {
                        player.RemoveInfected();
                        player.Die(DeathReason.Exile);
                        player.Data.IsDead     = true;
                        player.Data.IsImpostor = false;
                    }
                }
                PlayerControl jester = Main.Logic.getRolePlayer("Jester").PlayerControl;
                jester.Revive();
                jester.Data.IsDead     = false;
                jester.Data.IsImpostor = true;
                Main.Logic.WinReason   = WinReasons.Jester;
                break;
            }
        }
Пример #2
0
        public static void Postfix(Il2CppReferenceArray <GameData.PlayerInfo> JPGEIBIBJPJ)
        {
            Main.Logic.AllModPlayerControl.Clear();
            Main.Logic.WinReason = WinReasons.Crewmates;
            MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId,
                                                                              (byte)CustomRPC.ResetVariables, Hazel.SendOption.None, -1);

            AmongUsClient.Instance.FinishRpcImmediately(writer);

            List <PlayerControl> crewmates = PlayerTools.getCrewMates();

            foreach (PlayerControl player in PlayerControl.AllPlayerControls.ToArray())
            {
                Main.Logic.AllModPlayerControl.Add(new ModPlayerControl {
                    PlayerControl = player, Role = "Impostor", reportsLeft = MaxReportCount.GetValue(), LastAbilityTime = null
                });
            }
            foreach (PlayerControl player in crewmates)
            {
                player.getModdedControl().Role = "Crewmate";
            }

            if (crewmates.Count > 0 && (rng.Next(0, 100) <= JesterSpawnChance.GetValue()))
            {
                var idx = rng.Next(0, crewmates.Count);
                crewmates[idx].getModdedControl().Role = "Jester";
                byte JesterId = crewmates[idx].PlayerId;
                crewmates.RemoveAt(idx);

                writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId,
                                                                    (byte)CustomRPC.SetJester, Hazel.SendOption.None, -1);
                writer.Write(JesterId);
                AmongUsClient.Instance.FinishRpcImmediately(writer);
            }
            if (crewmates.Count > 0 && (rng.Next(0, 100) <= SheriffSpawnChance.GetValue()))
            {
                var idx = rng.Next(0, crewmates.Count);
                crewmates[idx].getModdedControl().Role = "Sheriff";
                byte SheriffId = crewmates[idx].PlayerId;
                crewmates.RemoveAt(idx);

                writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId,
                                                                    (byte)CustomRPC.SetSheriff, Hazel.SendOption.None, -1);
                writer.Write(SheriffId);
                AmongUsClient.Instance.FinishRpcImmediately(writer);
            }

            localPlayers.Clear();
            localPlayer = PlayerControl.LocalPlayer;
            foreach (PlayerControl player in PlayerControl.AllPlayerControls)
            {
                if (player.Data.IsImpostor)
                {
                    continue;
                }

                localPlayers.Add(player);
            }
            var localPlayerBytes = new List <byte>();

            foreach (PlayerControl player in localPlayers)
            {
                localPlayerBytes.Add(player.PlayerId);
            }
            writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetLocalPlayers, Hazel.SendOption.None, -1);
            writer.WriteBytesAndSize(localPlayerBytes.ToArray());
            AmongUsClient.Instance.FinishRpcImmediately(writer);
        }