Exemple #1
0
        static void Postfix(byte HKHMBLJFLMC, MessageReader ALMCIJKELCP)
        {
            byte          packetId = HKHMBLJFLMC;
            MessageReader reader   = ALMCIJKELCP;

            switch (packetId)
            {
            case (byte)CustomRPC.ShieldBreak:
                if (MedicSettings.Protected != null)
                {
                    MedicSettings.Protected.myRend.material.SetColor("_VisorColor", Palette.VisorColor);
                    MedicSettings.Protected.myRend.material.SetFloat("_Outline", 0f);
                }
                MedicSettings.Protected = null;
                break;

            case (byte)CustomRPC.FixLights:
                SwitchSystem switchSystem = ShipStatus.Instance.Systems[SystemTypes.Electrical].Cast <SwitchSystem>();
                switchSystem.ActualSwitches = switchSystem.ExpectedSwitches;
                break;

            case (byte)CustomRPC.SetLocalPlayers:
                ConsoleTools.Info("Setting Local Players...");
                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)RPC.SetInfected:
            {
                ConsoleTools.Info("set infected.");
                break;
            }

            case (byte)CustomRPC.ResetVaribles:
            {
                MedicSettings.ClearSettings();
                OfficerSettings.ClearSettings();
                EngineerSettings.ClearSettings();
                JokerSettings.ClearSettings();
                MedicSettings.SetConfigSettings();
                OfficerSettings.SetConfigSettings();
                EngineerSettings.SetConfigSettings();
                JokerSettings.SetConfigSettings();
                killedPlayers.Clear();
                break;
            }

            case (byte)CustomRPC.SetMedic:
            {
                ConsoleTools.Info("Medic Set Through RPC!");
                byte MedicId = ALMCIJKELCP.ReadByte();
                foreach (PlayerControl player in PlayerControl.AllPlayerControls)
                {
                    if (player.PlayerId == MedicId)
                    {
                        MedicSettings.Medic = player;
                    }
                }
                break;
            }

            case (byte)CustomRPC.SetProtected:
            {
                byte ProtectedId = ALMCIJKELCP.ReadByte();
                foreach (PlayerControl player in PlayerControl.AllPlayerControls)
                {
                    if (player.PlayerId == ProtectedId)
                    {
                        MedicSettings.Protected = player;
                    }
                }
                break;
            }

            case (byte)CustomRPC.SetOfficer:
            {
                ConsoleTools.Info("Officer Set Through RPC!");
                byte OfficerId = ALMCIJKELCP.ReadByte();
                foreach (PlayerControl player in PlayerControl.AllPlayerControls)
                {
                    if (player.PlayerId == OfficerId)
                    {
                        OfficerSettings.Officer = player;
                    }
                }
                break;
            }

            case (byte)CustomRPC.OfficerKill:
            {
                var           killerid = ALMCIJKELCP.ReadByte();
                var           targetid = ALMCIJKELCP.ReadByte();
                PlayerControl killer   = PlayerTools.getPlayerById(killerid);
                PlayerControl target   = PlayerTools.getPlayerById(targetid);
                killer.MurderPlayer(target);
                break;
            }

            case (byte)CustomRPC.SetEngineer:
            {
                ConsoleTools.Info("Engineer Set Through RPC!");
                byte EngineerId = ALMCIJKELCP.ReadByte();
                foreach (PlayerControl player in PlayerControl.AllPlayerControls)
                {
                    if (player.PlayerId == EngineerId)
                    {
                        EngineerSettings.Engineer = player;
                    }
                }
                break;
            }

            case (byte)CustomRPC.SetJoker:
            {
                ConsoleTools.Info("Joker Set Through RPC!");
                byte JokerId = ALMCIJKELCP.ReadByte();
                foreach (PlayerControl player in PlayerControl.AllPlayerControls)
                {
                    if (player.PlayerId == JokerId)
                    {
                        JokerSettings.Joker = player;
                    }
                }
                break;
            }

            case (byte)CustomRPC.JokerWin:
                foreach (PlayerControl player in PlayerControl.AllPlayerControls)
                {
                    player.RemoveInfected();
                    player.Die(DeathReason.Exile);
                    player.Data.IsDead     = true;
                    player.Data.IsImpostor = false;
                }
                JokerSettings.Joker.Revive();
                JokerSettings.Joker.Data.IsDead     = false;
                JokerSettings.Joker.Data.IsImpostor = true;
                break;
            }
        }
Exemple #2
0
        public static void Postfix(Il2CppReferenceArray <GameData.PlayerInfo> JPGEIBIBJPJ)
        {
            MedicSettings.ClearSettings();
            OfficerSettings.ClearSettings();
            EngineerSettings.ClearSettings();
            JokerSettings.ClearSettings();
            MedicSettings.SetConfigSettings();
            OfficerSettings.SetConfigSettings();
            EngineerSettings.SetConfigSettings();
            JokerSettings.SetConfigSettings();
            killedPlayers.Clear();
            MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ResetVaribles, Hazel.SendOption.None, -1);

            AmongUsClient.Instance.FinishRpcImmediately(writer);

            List <PlayerControl> crewmates = PlayerControl.AllPlayerControls.ToArray().ToList();

            crewmates.RemoveAll(x => x.Data.IsImpostor);

            if (crewmates.Count > 0 && (rng.Next(1, 101) <= HarmonyMain.medicSpawnChance.GetValue()))
            {
                writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetMedic, Hazel.SendOption.None, -1);
                var MedicRandom = rng.Next(0, crewmates.Count);
                MedicSettings.Medic = crewmates[MedicRandom];
                crewmates.RemoveAt(MedicRandom);
                byte MedicId = MedicSettings.Medic.PlayerId;

                writer.Write(MedicId);
                AmongUsClient.Instance.FinishRpcImmediately(writer);
            }

            if (crewmates.Count > 0 && (rng.Next(1, 101) <= HarmonyMain.officerSpawnChance.GetValue()))
            {
                writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetOfficer, Hazel.SendOption.None, -1);

                var OfficerRandom = rng.Next(0, crewmates.Count);
                OfficerSettings.Officer = crewmates[OfficerRandom];
                crewmates.RemoveAt(OfficerRandom);
                byte OfficerId = OfficerSettings.Officer.PlayerId;

                writer.Write(OfficerId);
                AmongUsClient.Instance.FinishRpcImmediately(writer);
            }

            if (crewmates.Count > 0 && (rng.Next(1, 101) <= HarmonyMain.engineerSpawnChance.GetValue()))
            {
                writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetEngineer, Hazel.SendOption.None, -1);
                var EngineerRandom = rng.Next(0, crewmates.Count);
                EngineerSettings.Engineer = crewmates[EngineerRandom];
                crewmates.RemoveAt(EngineerRandom);
                byte EngineerId = EngineerSettings.Engineer.PlayerId;

                writer.Write(EngineerId);
                AmongUsClient.Instance.FinishRpcImmediately(writer);
            }

            if (crewmates.Count > 0 && (rng.Next(1, 101) <= HarmonyMain.jokerSpawnChance.GetValue()))
            {
                writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetJoker, Hazel.SendOption.None, -1);
                var JokerRandom = rng.Next(0, crewmates.Count);
                ConsoleTools.Info(JokerRandom.ToString());
                JokerSettings.Joker = crewmates[JokerRandom];
                crewmates.RemoveAt(JokerRandom);
                byte JokerId = JokerSettings.Joker.PlayerId;

                writer.Write(JokerId);
                AmongUsClient.Instance.FinishRpcImmediately(writer);
            }

            localPlayers.Clear();
            localPlayer = PlayerControl.LocalPlayer;
            foreach (PlayerControl player in PlayerControl.AllPlayerControls)
            {
                if (player.Data.IsImpostor)
                {
                    continue;
                }
                if (JokerSettings.Joker != null && player.PlayerId == JokerSettings.Joker.PlayerId)
                {
                    continue;
                }
                else
                {
                    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);
        }