Beispiel #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;
            }
        }
        static void Postfix(HudManager __instance)
        {
            if (AmongUsClient.Instance.GameState == InnerNetClient.GameStates.Started)
            {
                if (!PlayerControl.LocalPlayer.Data.IsImpostor && Input.GetKeyDown(KeyCode.Q) && !lastQ)
                {
                    PerformKillPatch.Prefix();
                }
                lastQ      = Input.GetKeyUp(KeyCode.Q);
                KillButton = __instance.KillButton;
                PlayerTools.closestPlayer = PlayerTools.getClosestPlayer(PlayerControl.LocalPlayer);
                DistLocalClosest          = PlayerTools.getDistBetweenPlayers(PlayerControl.LocalPlayer, PlayerTools.closestPlayer);
                if (MedicSettings.Protected != null && __instance.UseButton != null && MedicSettings.Protected.PlayerId == PlayerControl.LocalPlayer.PlayerId && __instance.UseButton.isActiveAndEnabled)
                {
                    if (rend == null)
                    {
                        rend = new GameObject("Shield Icon", new Il2CppSystem.Type[] { SpriteRenderer.Il2CppType });
                        rend.GetComponent <SpriteRenderer>().sprite = smallShieldIco;
                    }
                    int scale;
                    if (Screen.width > Screen.height)
                    {
                        scale = Screen.width / 800;
                    }
                    else
                    {
                        scale = Screen.height / 600;
                    }
                    rend.transform.localPosition = Camera.main.ScreenToWorldPoint(new Vector3(0 + (25 * scale), 0 + (25 * scale), -50f));
                    rend.SetActive(true);
                }
                if (EngineerSettings.Engineer != null && EngineerSettings.Engineer.PlayerId == PlayerControl.LocalPlayer.PlayerId && __instance.UseButton.isActiveAndEnabled)
                {
                    KillButton.gameObject.SetActive(true);
                    KillButton.isActive = true;
                    KillButton.SetCoolDown(0f, 30f);
                    KillButton.renderer.sprite = repairIco;
                    KillButton.renderer.color  = Palette.EnabledColor;
                    KillButton.renderer.material.SetFloat("_Desat", 0f);
                }
                if (JokerSettings.Joker != null)
                {
                    JokerSettings.ClearTasks();
                }
                if (rend != null)
                {
                    rend.SetActive(false);
                }
                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;
                    }
                }
                EngineerSettings.sabotageActive = sabotageActive;
                if (MedicSettings.Protected != null && MedicSettings.Protected.Data.IsDead)
                {
                    BreakShield(true);
                }
                if (MedicSettings.Protected != null && MedicSettings.Medic != null && MedicSettings.Medic.Data.IsDead)
                {
                    BreakShield(true);
                }
                if (MedicSettings.Medic == null && MedicSettings.Protected != null)
                {
                    BreakShield(true);
                }
                foreach (PlayerControl player in PlayerControl.AllPlayerControls)
                {
                    player.nameText.Color = Color.white;
                }
                if (PlayerControl.LocalPlayer.Data.IsImpostor)
                {
                    foreach (PlayerControl player in PlayerControl.AllPlayerControls)
                    {
                        if (player.Data.IsImpostor)
                        {
                            player.nameText.Color = Color.red;
                        }
                    }
                }
                if (MedicSettings.Medic != null)
                {
                    if (MedicSettings.Medic == PlayerControl.LocalPlayer || MedicSettings.showMedic)
                    {
                        MedicSettings.Medic.nameText.Color = ModdedPalette.medicColor;
                        if (MeetingHud.Instance != null)
                        {
                            foreach (PlayerVoteArea player in MeetingHud.Instance.playerStates)
                            {
                                if (player.NameText != null && MedicSettings.Medic.PlayerId == player.TargetPlayerId)
                                {
                                    player.NameText.Color = ModdedPalette.medicColor;
                                }
                            }
                        }
                    }
                }
                if (OfficerSettings.Officer != null)
                {
                    if (OfficerSettings.Officer == PlayerControl.LocalPlayer || OfficerSettings.showOfficer)
                    {
                        OfficerSettings.Officer.nameText.Color = ModdedPalette.officerColor;
                        if (MeetingHud.Instance != null)
                        {
                            foreach (PlayerVoteArea player in MeetingHud.Instance.playerStates)
                            {
                                if (player.NameText != null && OfficerSettings.Officer.PlayerId == player.TargetPlayerId)
                                {
                                    player.NameText.Color = ModdedPalette.officerColor;
                                }
                            }
                        }
                    }
                }
                if (EngineerSettings.Engineer != null)
                {
                    if (EngineerSettings.Engineer == PlayerControl.LocalPlayer || EngineerSettings.showEngineer)
                    {
                        EngineerSettings.Engineer.nameText.Color = ModdedPalette.engineerColor;
                        if (MeetingHud.Instance != null)
                        {
                            foreach (PlayerVoteArea player in MeetingHud.Instance.playerStates)
                            {
                                if (player.NameText != null && EngineerSettings.Engineer.PlayerId == player.TargetPlayerId)
                                {
                                    player.NameText.Color = ModdedPalette.engineerColor;
                                }
                            }
                        }
                    }
                }
                if (JokerSettings.Joker != null)
                {
                    if (JokerSettings.Joker == PlayerControl.LocalPlayer || JokerSettings.showJoker)
                    {
                        JokerSettings.Joker.nameText.Color = ModdedPalette.jokerColor;
                        if (MeetingHud.Instance != null)
                        {
                            foreach (PlayerVoteArea player in MeetingHud.Instance.playerStates)
                            {
                                if (player.NameText != null && JokerSettings.Joker.PlayerId == player.TargetPlayerId)
                                {
                                    player.NameText.Color = ModdedPalette.jokerColor;
                                }
                            }
                        }
                    }
                }
                if (MedicSettings.Protected != null)
                {
                    if (MedicSettings.Protected == PlayerControl.LocalPlayer || MedicSettings.showProtected)
                    {
                        MedicSettings.Protected.myRend.material.SetColor("_VisorColor", ModdedPalette.protectedColor);
                        MedicSettings.Protected.myRend.material.SetFloat("_Outline", 1f);
                        MedicSettings.Protected.myRend.material.SetColor("_OutlineColor", ModdedPalette.protectedColor);
                    }
                }

                if (PlayerControl.LocalPlayer.Data.IsDead)
                {
                    if (EngineerSettings.Engineer == null || EngineerSettings.Engineer.PlayerId != PlayerControl.LocalPlayer.PlayerId)
                    {
                        KillButton.gameObject.SetActive(false);
                        KillButton.isActive = false;
                        KillButton.SetTarget(null);
                        return;
                    }
                }
                if (MedicSettings.Medic != null && __instance.UseButton != null && MedicSettings.Medic.PlayerId == PlayerControl.LocalPlayer.PlayerId && __instance.UseButton.isActiveAndEnabled)
                {
                    KillButton.renderer.sprite = shieldIco;
                    KillButton.gameObject.SetActive(true);
                    KillButton.isActive = true;
                    KillButton.SetCoolDown(0f, PlayerControl.GameOptions.KillCooldown + 15.0f);
                    if (DistLocalClosest < GameOptionsData.KillDistances[PlayerControl.GameOptions.KillDistance] && MedicSettings.shieldUsed == false)
                    {
                        KillButton.SetTarget(PlayerTools.closestPlayer);
                        CurrentTarget = PlayerTools.closestPlayer;
                    }
                    else
                    {
                        KillButton.SetTarget(null);
                        CurrentTarget = null;
                    }
                }
                if (OfficerSettings.Officer != null && __instance.UseButton != null && OfficerSettings.Officer.PlayerId == PlayerControl.LocalPlayer.PlayerId && __instance.UseButton.isActiveAndEnabled)
                {
                    KillButton.gameObject.SetActive(true);
                    KillButton.isActive = true;
                    KillButton.SetCoolDown(PlayerTools.GetOfficerKD(), PlayerControl.GameOptions.KillCooldown + 15.0f);
                    if (DistLocalClosest < GameOptionsData.KillDistances[PlayerControl.GameOptions.KillDistance])
                    {
                        KillButton.SetTarget(PlayerTools.closestPlayer);
                        CurrentTarget = PlayerTools.closestPlayer;
                    }
                    else
                    {
                        KillButton.SetTarget(null);
                        CurrentTarget = null;
                    }
                }
            }
        }
Beispiel #3
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);
        }