Exemple #1
0
        public static void Gen(List <PlayerControl> crewmates, List <PlayerControl> impostors)
        {
            //System.Console.WriteLine("LOVER2");
            if (crewmates.Count <= 0)
            {
                return;
            }
            if (crewmates.Count <= 1 && impostors.Count < 1)
            {
                return;
            }

            //System.Console.WriteLine("LOVER3");
            var b = HashRandom.Method_1(3);

            if (b == 0 & impostors.Count < 1)
            {
                b = 1;
            }

            if (b != 0 & crewmates.Count <= 1)
            {
                b = 0;
            }

            //System.Console.WriteLine("LOVER4");
            var flag2   = b == 0;
            var num     = HashRandom.Method_1(crewmates.Count);
            var player1 = crewmates[num];

            crewmates.Remove(player1);
            PlayerControl player2;

            if (flag2)
            {
                var num2 = HashRandom.Method_1(impostors.Count);
                player2 = impostors[num2];
                impostors.Remove(player2);
            }
            else
            {
                var num2 = HashRandom.Method_1(crewmates.Count);
                player2 = crewmates[num2];
                crewmates.Remove(player2);
            }

            var writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId,
                                                                    (byte)CustomRPC.SetCouple, SendOption.Reliable, -1);

            writer.Write(player1.PlayerId);
            writer.Write(player2.PlayerId);
            writer.Write(b);
            var lover1 = new Lover(player1, 1, b == 0);
            var lover2 = new Lover(player2, 2, b == 0);

            lover1.OtherLover = lover2;
            lover2.OtherLover = lover1;

            AmongUsClient.Instance.FinishRpcImmediately(writer);
        }
Exemple #2
0
            public static void Postfix(PlayerControl __instance,
                                       [HarmonyArgument(0)] Il2CppReferenceArray <GameData.Nested_1> infected)
            {
                var playersToGiveRoles = new List <GameData.Nested_1>();

                foreach (var p in GameData.Instance.AllPlayers)
                {
                    if (infected.All(imposter => imposter.FMAAJCIEMEH != p.FMAAJCIEMEH))
                    {
                        playersToGiveRoles.Add(p);
                    }
                }

                var giveRole = false;;

                switch (GameOptionsPatches.JesterMode)
                {
                case GameOptionsPatches.JesterModes.Always:
                    giveRole = true;
                    break;

                case GameOptionsPatches.JesterModes.Maybe:
                    if (HashRandom.Method_1(10000) % 2 == 0)
                    {
                        giveRole = true;
                    }
                    break;
                }

                var messageWriter = AmongUsClient.Instance.StartRpc(__instance.NetId,
                                                                    (byte)CustomRpcMessage.SetCustomRoles, SendOption.Reliable);

                CustomRoles.Clear();

                messageWriter.Write(giveRole);
                if (giveRole)
                {
                    int index = HashRandom.Method_1(playersToGiveRoles.Count);
                    CustomRoles.Add(playersToGiveRoles[index].ACBLKMFEPKC, true);
                    messageWriter.Write(playersToGiveRoles[index].ACBLKMFEPKC);
                    if (CustomRoles.ContainsKey(PlayerControl.LocalPlayer.PlayerId))
                    {
                        var role = CustomRoles[PlayerControl.LocalPlayer.PlayerId];
                        if (role)
                        {
                            __instance.nameText.Color = JesterRole.Color;
                        }
                    }
                }

                messageWriter.EndMessage();

                // foreach (var (key, value) in CustomRoles)
                // {
                //     System.Console.WriteLine(key + ": " + value.Join(null, ", "));
                // }
            }
Exemple #3
0
        public static void Gen(List <PlayerControl> impostors)
        {
            if (impostors.Count < 2)
            {
                return;
            }
            if (impostors.Count < 3 && !CustomGameOptions.TwoMafia)
            {
                return;
            }
            int rand;

            rand = HashRandom.Method_1(impostors.Count);
            var godfather = impostors[rand];

            impostors.Remove(godfather);
            rand = HashRandom.Method_1(impostors.Count);
            var janitor = impostors[rand];

            impostors.Remove(janitor);


            var g = new Godfather(godfather);
            var j = new Janitor(janitor);

            g.Janitor   = j;
            j.Godfather = g;
            var writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId,
                                                                    (byte)CustomRPC.SetMafia, SendOption.Reliable, -1);

            writer.Write(godfather.PlayerId);
            writer.Write(janitor.PlayerId);
            if (!CustomGameOptions.TwoMafia)
            {
                rand = HashRandom.Method_1(impostors.Count);
                var mafioso = impostors[rand];
                impostors.Remove(mafioso);
                var m = new Mafioso(mafioso);
                g.Mafioso   = m;
                j.Mafioso   = m;
                m.Godfather = g;
                m.Janitor   = j;
                writer.Write(mafioso.PlayerId);
            }
            AmongUsClient.Instance.FinishRpcImmediately(writer);
        }
Exemple #4
0
        public static void Gen(Type T, List <PlayerControl> crewmates, CustomRPC rpc)
        {
            //System.Console.WriteLine(nameof(rpc));
            //System.Console.WriteLine(crewmates.Count);
            if (crewmates.Count <= 0)
            {
                return;
            }
            var rand = HashRandom.Method_1(crewmates.Count);
            //var rand = 0;
            var pc = crewmates[rand];

            var role     = Activator.CreateInstance(T, new object[] { pc });
            var playerId = pc.PlayerId;

            crewmates.Remove(pc);

            var writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)rpc,
                                                                    SendOption.Reliable, -1);

            writer.Write(playerId);
            AmongUsClient.Instance.FinishRpcImmediately(writer);
        }
Exemple #5
0
            public static void Postfix(PlayerControl __instance, Il2CppStructArray <byte> JPGEIBIBJPJ)
            {
                var infected           = JPGEIBIBJPJ;
                var playersToGiveRoles = new List <GameData.PlayerInfo>();

                foreach (var p in GameData.Instance.AllPlayers)
                {
                    if (!p.IsImpostor)
                    {
                        playersToGiveRoles.Add(p);
                        System.Console.WriteLine(p.PlayerName);
                    }
                }

                var rolesToAssign = CustomRole.Roles;

                var messageWriter = AmongUsClient.Instance.StartRpc(__instance.NetId,
                                                                    (int)CustomRpcMessages.SET_CUSTOM_ROLES, SendOption.Reliable);

                messageWriter.Write((byte)rolesToAssign.Length);
                var customRoleData = new byte[rolesToAssign.Length];

                customRoles.Clear();
                foreach (var role in rolesToAssign)
                {
                    System.Console.WriteLine(role.Name);
                    var index = HashRandom.Method_1(playersToGiveRoles.Count);
                    customRoles.Add(playersToGiveRoles[index].PlayerId, new Roles.CustomRole[] { role });
                    messageWriter.Write(playersToGiveRoles[index].PlayerId);
                    messageWriter.WriteBytesAndSize(new byte[] { (byte)role.RoleId });
                    //messageWriter.Write(role.RoleId);
                    playersToGiveRoles.RemoveAt(index);
                }
                messageWriter.EndMessage();
                GameWinner = null;
            }