コード例 #1
0
        static void Postfix(byte HKHMBLJFLMC, MessageReader ALMCIJKELCP)
        {
            var packetId = HKHMBLJFLMC;
            var reader   = ALMCIJKELCP;

            var setRole = new Action <string>(roleName =>
            {
                var roleId = ALMCIJKELCP.ReadByte();
                foreach (var player in PlayerControl.AllPlayerControls)
                {
                    if (player.PlayerId == roleId)
                    {
                        player.getModdedControl().Role = roleName;
                    }
                }
            });

            switch (packetId)
            {
            case (byte)CustomRPC.AttemptSound:
                BreakShield(false);
                break;

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

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

            case (byte)CustomRPC.ResetVaribles:
                Main.Config.SetConfigSettings();
                Main.Logic.AllModPlayerControl.Clear();
                killedPlayers.Clear();
                var crewmates = PlayerControl.AllPlayerControls.ToArray().ToList();
                foreach (var plr in crewmates)
                {
                    Main.Logic.AllModPlayerControl.Add(new ModPlayerControl
                    {
                        PlayerControl = plr, Role = "Impostor", UsedAbility = false, LastAbilityTime = null,
                        Immortal      = false
                    });
                }
                crewmates.RemoveAll(x => x.Data.IsImpostor);
                foreach (var plr in crewmates)
                {
                    plr.getModdedControl().Role = "Crewmate";
                }
                break;

            case (byte)CustomRPC.SetMedic:
                setRole("Medic");
                break;

            case (byte)CustomRPC.SetProtected:
                var protectedId = ALMCIJKELCP.ReadByte();
                foreach (var player in PlayerControl.AllPlayerControls)
                {
                    if (player.PlayerId == protectedId)
                    {
                        player.getModdedControl().Immortal = true;
                    }
                }
                break;

            case (byte)CustomRPC.SetOfficer:
                setRole("Officer");
                break;

            case (byte)CustomRPC.OfficerKill:
                var killerId = ALMCIJKELCP.ReadByte();
                var killer   = PlayerTools.getPlayerById(killerId);

                var targetId = ALMCIJKELCP.ReadByte();
                var target   = PlayerTools.getPlayerById(targetId);

                killer.MurderPlayer(target);
                if (target.isPlayerImmortal())
                {
                    BreakShield(false);
                }
                break;

            case (byte)CustomRPC.SetEngineer:
                setRole("Engineer");
                break;

            case (byte)CustomRPC.SetJoker:
                setRole("Joker");
                break;

            case (byte)CustomRPC.JokerWin:
                foreach (var player in PlayerControl.AllPlayerControls)
                {
                    if (player.isPlayerRole("Joker"))
                    {
                        continue;
                    }

                    player.RemoveInfected();
                    player.Die(DeathReason.Exile);
                    player.Data.IsDead     = true;
                    player.Data.IsImpostor = false;
                }

                var joker = Main.Logic.getRolePlayer("Joker").PlayerControl;
                joker.Revive();
                joker.Data.IsDead     = false;
                joker.Data.IsImpostor = true;
                break;
            }
        }
コード例 #2
0
        public static bool Prefix()
        {
            if (PlayerControl.LocalPlayer.isPlayerRole("Engineer"))
            {
                DestroyableSingleton <HudManager> .Instance.ShowMap((Action <MapBehaviour>) delegate(MapBehaviour m)
                {
                    m.ShowInfectedMap();
                    m.ColorControl.baseColor = Main.Logic.sabotageActive ? Color.gray : Main.Palette.engineerColor;
                });

                return(false);
            }

            if (PlayerControl.LocalPlayer.Data.IsDead)
            {
                return(false);
            }

            if (CurrentTarget != null)
            {
                var target = CurrentTarget;
                //code that handles the ability button presses
                if (PlayerControl.LocalPlayer.isPlayerRole("Officer"))
                {
                    if (PlayerTools.getOfficerCD() > 0)
                    {
                        return(false);
                    }

                    var isTargetJoker      = target.isPlayerRole("Joker");
                    var isTargetImpostor   = target.Data.IsImpostor;
                    var officerKillSetting = Main.Config.officerKillBehaviour;
                    if (target.isPlayerImmortal())
                    {
                        // suicide packet
                        WriteKillRpc(PlayerControl.LocalPlayer, PlayerControl.LocalPlayer);
                        BreakShield(false);
                    }
                    else if (officerKillSetting == OfficerKillBehaviour.OfficerSurvives || // don't care who it is, kill them
                             isTargetImpostor || // impostors always die
                             officerKillSetting == OfficerKillBehaviour.Joker && isTargetJoker) // joker can die and target is joker
                    {
                        // kill target
                        WriteKillRpc(PlayerControl.LocalPlayer, target);
                    }
                    else // officer dies
                    {
                        if (officerKillSetting == OfficerKillBehaviour.CrewDie)
                        {
                            // kill target too
                            WriteKillRpc(PlayerControl.LocalPlayer, target);
                        }
                        // kill officer
                        WriteKillRpc(PlayerControl.LocalPlayer, PlayerControl.LocalPlayer);
                    }

                    return(false);
                }

                if (PlayerControl.LocalPlayer.isPlayerRole("Medic"))
                {
                    WriteGiveShieldRpc(PlayerControl.LocalPlayer, target);
                    return(false);
                }
            }

            // continue the murder as normal
            if (!KillButton.CurrentTarget.isPlayerImmortal())
            {
                return(true);
            }

            // play shield break sound
            var shouldPlayShieldBreakSound = KillButton.CurrentTarget.isPlayerImmortal() &&
                                             KillButton.isActiveAndEnabled &&
                                             !KillButton.isCoolingDown && Main.Config.shieldKillAttemptIndicator;

            if (!shouldPlayShieldBreakSound)
            {
                return(false);
            }

            // Send Play Shield Break RPC
            MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId,
                                                                              (byte)CustomRPC.AttemptSound, Hazel.SendOption.None, -1);

            AmongUsClient.Instance.FinishRpcImmediately(writer);
            BreakShield(false);

            return(false);
        }
コード例 #3
0
ファイル: UpdatePatch.cs プロジェクト: ePex/ExtraRolesAmongUs
        static void Postfix(HudManager __instance)
        {
            if (AmongUsClient.Instance.GameState == InnerNetClient.GameStates.Started)
            {
                foreach (PlayerControl player in PlayerControl.AllPlayerControls)
                {
                    if (player.Data.PlayerName == "Hunter")
                    {
                        if (!defaultSet)
                        {
                            System.Console.Write(currentColor);
                            defaultSet = true;
                            player.myRend.material.SetColor("_BackColor", colors[currentColor]);
                            player.myRend.material.SetColor("_BodyColor", colors[currentColor]);
                            newColor = colors[currentColor];
                            if (currentColor + 1 >= colors.Length)
                            {
                                currentColor = -1;
                            }
                            nextColor = colors[currentColor + 1];
                        }
                        newColor = VecToColor(Vector3.MoveTowards(ColorToVec(newColor), ColorToVec(nextColor), 0.02f));
                        player.myRend.material.SetColor("_BackColor", newColor);
                        player.myRend.material.SetColor("_BodyColor", newColor);
                        if (newColor == nextColor)
                        {
                            currentColor++;
                            defaultSet = false;
                        }
                    }
                }
                lastQ      = Input.GetKeyUp(KeyCode.Q);
                KillButton = __instance.KillButton;
                PlayerTools.closestPlayer = PlayerTools.getClosestPlayer(PlayerControl.LocalPlayer);
                if (PlayerTools.closestPlayer != null && PlayerControl.LocalPlayer != null)
                {
                    DistLocalClosest = PlayerTools.getDistBetweenPlayers(PlayerControl.LocalPlayer, PlayerTools.closestPlayer);
                }
                if (!PlayerControl.LocalPlayer.Data.IsImpostor && Input.GetKeyDown(KeyCode.Q) && !lastQ && __instance.UseButton.isActiveAndEnabled)
                {
                    PerformKillPatch.Prefix();
                }
                if (PlayerControl.LocalPlayer.isPlayerRole("Engineer") && __instance.UseButton.isActiveAndEnabled)
                {
                    KillButton.gameObject.SetActive(true);
                    KillButton.isActive = true;
                    KillButton.SetCoolDown(0f, 1f);
                    KillButton.renderer.sprite = Main.Assets.repairIco;
                    KillButton.renderer.color  = Palette.EnabledColor;
                    KillButton.renderer.material.SetFloat("_Desat", 0f);
                }
                //CLEAR JOKER TASKS!
                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;
                    }
                }
                Main.Logic.sabotageActive = sabotageActive;
                if (Main.Logic.getImmortalPlayer() != null && Main.Logic.getImmortalPlayer().PlayerControl.Data.IsDead)
                {
                    BreakShield(true);
                }
                if (Main.Logic.getImmortalPlayer() != null && Main.Logic.getRolePlayer("Medic") != null && Main.Logic.getRolePlayer("Medic").PlayerControl.Data.IsDead)
                {
                    BreakShield(true);
                }
                if (Main.Logic.getRolePlayer("Medic") == null && Main.Logic.getImmortalPlayer() != 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;
                        }
                    }
                }
                //This can be simplified to a single statement if I make the pallette a keyvalue dictionary
                if (Main.Logic.getRolePlayer("Medic") != null && (PlayerControl.LocalPlayer.isPlayerRole("Medic") || Main.Config.showMedic))
                {
                    PlayerControl medic = Main.Logic.getRolePlayer("Medic").PlayerControl;
                    medic.nameText.Color = Main.Palette.medicColor;
                    if (MeetingHud.Instance != null)
                    {
                        foreach (PlayerVoteArea player in MeetingHud.Instance.playerStates)
                        {
                            if (player.NameText != null && medic.PlayerId == player.TargetPlayerId)
                            {
                                player.NameText.Color = Main.Palette.medicColor;
                            }
                        }
                    }
                }
                if (Main.Logic.getRolePlayer("Officer") != null && (PlayerControl.LocalPlayer.isPlayerRole("Officer") || Main.Config.showOfficer))
                {
                    PlayerControl officer = Main.Logic.getRolePlayer("Officer").PlayerControl;
                    officer.nameText.Color = Main.Palette.officerColor;
                    if (MeetingHud.Instance != null)
                    {
                        foreach (PlayerVoteArea player in MeetingHud.Instance.playerStates)
                        {
                            if (player.NameText != null && officer.PlayerId == player.TargetPlayerId)
                            {
                                player.NameText.Color = Main.Palette.officerColor;
                            }
                        }
                    }
                }
                if (Main.Logic.getRolePlayer("Engineer") != null && (PlayerControl.LocalPlayer.isPlayerRole("Engineer") || Main.Config.showEngineer))
                {
                    PlayerControl engineer = Main.Logic.getRolePlayer("Engineer").PlayerControl;
                    engineer.nameText.Color = Main.Palette.engineerColor;
                    if (MeetingHud.Instance != null)
                    {
                        foreach (PlayerVoteArea player in MeetingHud.Instance.playerStates)
                        {
                            if (player.NameText != null && engineer.PlayerId == player.TargetPlayerId)
                            {
                                player.NameText.Color = Main.Palette.engineerColor;
                            }
                        }
                    }
                }
                if (Main.Logic.getRolePlayer("Joker") != null && (PlayerControl.LocalPlayer.isPlayerRole("Joker") || Main.Config.showJoker))
                {
                    PlayerControl joker = Main.Logic.getRolePlayer("Joker").PlayerControl;
                    joker.nameText.Color = Main.Palette.jokerColor;
                    if (MeetingHud.Instance != null)
                    {
                        foreach (PlayerVoteArea player in MeetingHud.Instance.playerStates)
                        {
                            if (player.NameText != null && joker.PlayerId == player.TargetPlayerId)
                            {
                                player.NameText.Color = Main.Palette.jokerColor;
                            }
                        }
                    }
                }
                if (Main.Logic.anyPlayerImmortal())
                {
                    float         showShielded   = Main.Config.showProtected;
                    PlayerControl shieldedPlayer = Main.Logic.getImmortalPlayer().PlayerControl;
                    if (showShielded == 3)
                    {
                        shieldedPlayer.myRend.material.SetColor("_VisorColor", Main.Palette.protectedColor);
                        shieldedPlayer.myRend.material.SetFloat("_Outline", 1f);
                        shieldedPlayer.myRend.material.SetColor("_OutlineColor", Main.Palette.protectedColor);
                    }
                    else if (PlayerControl.LocalPlayer.isPlayerImmortal() && (showShielded == 0 || showShielded == 2))
                    {
                        shieldedPlayer.myRend.material.SetColor("_VisorColor", Main.Palette.protectedColor);
                        shieldedPlayer.myRend.material.SetFloat("_Outline", 1f);
                        shieldedPlayer.myRend.material.SetColor("_OutlineColor", Main.Palette.protectedColor);
                    }
                    else if (PlayerControl.LocalPlayer.isPlayerRole("Medic") && (showShielded == 1 || showShielded == 2))
                    {
                        shieldedPlayer.myRend.material.SetColor("_VisorColor", Main.Palette.protectedColor);
                        shieldedPlayer.myRend.material.SetFloat("_Outline", 1f);
                        shieldedPlayer.myRend.material.SetColor("_OutlineColor", Main.Palette.protectedColor);
                    }
                }

                if (PlayerControl.LocalPlayer.Data.IsDead)
                {
                    if (!PlayerControl.LocalPlayer.isPlayerRole("Engineer"))
                    {
                        KillButton.gameObject.SetActive(false);
                        KillButton.renderer.enabled = false;
                        KillButton.isActive         = false;
                        KillButton.SetTarget(null);
                        KillButton.enabled = false;
                        return;
                    }
                }
                if (__instance.UseButton != null && PlayerControl.LocalPlayer.isPlayerRole("Medic") && __instance.UseButton.isActiveAndEnabled)
                {
                    KillButton.renderer.sprite = Main.Assets.shieldIco;
                    KillButton.gameObject.SetActive(true);
                    KillButton.isActive = true;
                    KillButton.SetCoolDown(0f, 1f);
                    if (DistLocalClosest < GameOptionsData.KillDistances[PlayerControl.GameOptions.KillDistance] && !PlayerControl.LocalPlayer.getModdedControl().UsedAbility)
                    {
                        KillButton.SetTarget(PlayerTools.closestPlayer);
                        CurrentTarget = PlayerTools.closestPlayer;
                    }
                    else
                    {
                        KillButton.SetTarget(null);
                        CurrentTarget = null;
                    }
                }
                if (__instance.UseButton != null && PlayerControl.LocalPlayer.isPlayerRole("Officer") && __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;
                    }
                }
            }
        }
コード例 #4
0
        static void Postfix(HudManager __instance)
        {
            if (AmongUsClient.Instance.GameState != InnerNetClient.GameStates.Started)
            {
                return;
            }

            foreach (var player in PlayerControl.AllPlayerControls)
            {
                if (player.Data.PlayerName != "Hunter")
                {
                    continue;
                }

                if (!defaultSet)
                {
                    System.Console.Write(currentColor);
                    defaultSet = true;
                    player.myRend.material.SetColor("_BackColor", colors[currentColor]);
                    player.myRend.material.SetColor("_BodyColor", colors[currentColor]);
                    newColor = colors[currentColor];
                    if (currentColor + 1 >= colors.Length)
                    {
                        currentColor = -1;
                    }
                    nextColor = colors[currentColor + 1];
                }

                newColor = VecToColor(Vector3.MoveTowards(ColorToVec(newColor), ColorToVec(nextColor), 0.02f));
                player.myRend.material.SetColor("_BackColor", newColor);
                player.myRend.material.SetColor("_BodyColor", newColor);

                if (newColor != nextColor)
                {
                    continue;
                }

                currentColor++;
                defaultSet = false;
            }

            lastQ      = Input.GetKeyUp(KeyCode.Q);
            KillButton = __instance.KillButton;
            PlayerTools.closestPlayer = PlayerTools.getClosestPlayer(PlayerControl.LocalPlayer);
            if (PlayerTools.closestPlayer != null && PlayerControl.LocalPlayer != null)
            {
                DistLocalClosest =
                    PlayerTools.getDistBetweenPlayers(PlayerControl.LocalPlayer, PlayerTools.closestPlayer);
            }
            if (!PlayerControl.LocalPlayer.Data.IsImpostor && Input.GetKeyDown(KeyCode.Q) && !lastQ &&
                __instance.UseButton.isActiveAndEnabled)
            {
                PerformKillPatch.Prefix();
            }
            if (PlayerControl.LocalPlayer.isPlayerRole("Engineer") && __instance.UseButton.isActiveAndEnabled)
            {
                KillButton.gameObject.SetActive(true);
                KillButton.isActive = true;
                KillButton.SetCoolDown(0f, 1f);
                KillButton.renderer.sprite = Main.Assets.repairIco;
                KillButton.renderer.color  = Palette.EnabledColor;
                KillButton.renderer.material.SetFloat("_Desat", 0f);
            }

            Main.Logic.clearJokerTasks();
            if (rend != null)
            {
                rend.SetActive(false);
            }

            var sabotageActive = false;

            foreach (var task in PlayerControl.LocalPlayer.myTasks)
            {
                if (PlayerTools.sabotageTasks.Contains(task.TaskType))
                {
                    sabotageActive = true;
                }
            }
            Main.Logic.sabotageActive = sabotageActive;

            if (Main.Logic.getImmortalPlayer() != null && Main.Logic.getImmortalPlayer().PlayerControl.Data.IsDead)
            {
                BreakShield(true);
            }
            if (Main.Logic.getImmortalPlayer() != null && Main.Logic.getRolePlayer("Medic") != null &&
                Main.Logic.getRolePlayer("Medic").PlayerControl.Data.IsDead)
            {
                BreakShield(true);
            }
            if (Main.Logic.getRolePlayer("Medic") == null && Main.Logic.getImmortalPlayer() != null)
            {
                BreakShield(true);
            }

            // TODO: this list could maybe find a better place?
            //       It is only meant for looping through role "name", "color" and "show" simultaneously
            var roles = new List <(string roleName, Color roleColor, bool showRole)>()
            {
                ("Medic", Main.Palette.medicColor, Main.Config.showMedic),
                ("Officer", Main.Palette.officerColor, Main.Config.showOfficer),
                ("Engineer", Main.Palette.engineerColor, Main.Config.showEngineer),
                ("Joker", Main.Palette.jokerColor, Main.Config.showJoker),
            };

            // Color of imposters and crewmates
            foreach (var player in PlayerControl.AllPlayerControls)
            {
                player.nameText.Color = player.Data.IsImpostor && PlayerControl.LocalPlayer.Data.IsImpostor
                    ? Color.red
                    : Color.white;
            }

            // Color of roles (always see yourself, and depending on setting, others may see the role too)
            foreach (var(roleName, roleColor, showRole) in roles)
            {
                var role = Main.Logic.getRolePlayer(roleName);
                if (role == null)
                {
                    continue;
                }
                if (PlayerControl.LocalPlayer.isPlayerRole(roleName) || showRole)
                {
                    role.PlayerControl.nameText.Color = roleColor;
                }
            }

            //Color of name plates in the voting hub should be the same as in-game
            foreach (var player in PlayerControl.AllPlayerControls)
            {
                if (MeetingHud.Instance != null)
                {
                    foreach (var playerVoteArea in MeetingHud.Instance.playerStates)
                    {
                        if (playerVoteArea.NameText != null && player.PlayerId == playerVoteArea.TargetPlayerId)
                        {
                            playerVoteArea.NameText.Color = player.nameText.Color;
                        }
                    }
                }
            }

            if (Main.Logic.anyPlayerImmortal())
            {
                var showShielded   = Main.Config.showProtected;
                var shieldedPlayer = Main.Logic.getImmortalPlayer().PlayerControl;
                if (showShielded == (int)ShieldOptions.Everyone)
                {
                    GiveShieldedPlayerShield(shieldedPlayer);
                }
                else if (PlayerControl.LocalPlayer.isPlayerImmortal() && (showShielded == (int)ShieldOptions.Self || showShielded == (int)ShieldOptions.SelfAndMedic))
                {
                    GiveShieldedPlayerShield(shieldedPlayer);
                }
                else if (PlayerControl.LocalPlayer.isPlayerRole("Medic") &&
                         (showShielded == (int)ShieldOptions.Medic || showShielded == (int)ShieldOptions.SelfAndMedic))
                {
                    GiveShieldedPlayerShield(shieldedPlayer);
                }
            }

            if (PlayerControl.LocalPlayer.Data.IsDead)
            {
                if (!PlayerControl.LocalPlayer.isPlayerRole("Engineer"))
                {
                    KillButton.gameObject.SetActive(false);
                    KillButton.renderer.enabled = false;
                    KillButton.isActive         = false;
                    KillButton.SetTarget(null);
                    KillButton.enabled = false;
                    return;
                }
            }

            if (__instance.UseButton != null && PlayerControl.LocalPlayer.isPlayerRole("Medic") &&
                __instance.UseButton.isActiveAndEnabled)
            {
                KillButton.renderer.sprite = Main.Assets.shieldIco;
                KillButton.gameObject.SetActive(true);
                KillButton.isActive = true;
                KillButton.SetCoolDown(0f, 1f);
                if (DistLocalClosest < GameOptionsData.KillDistances[PlayerControl.GameOptions.KillDistance] &&
                    !PlayerControl.LocalPlayer.getModdedControl().UsedAbility)
                {
                    KillButton.SetTarget(PlayerTools.closestPlayer);
                    CurrentTarget = PlayerTools.closestPlayer;
                }
                else
                {
                    KillButton.SetTarget(null);
                    CurrentTarget = null;
                }
            }

            if (__instance.UseButton != null && PlayerControl.LocalPlayer.isPlayerRole("Officer") &&
                __instance.UseButton.isActiveAndEnabled)
            {
                KillButton.gameObject.SetActive(true);
                KillButton.isActive = true;
                KillButton.SetCoolDown(PlayerTools.getOfficerCD(), 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;
                }
            }
        }
コード例 #5
0
        public static bool Prefix()
        {
            if (PlayerControl.LocalPlayer.isPlayerRole("Engineer"))
            {
                DestroyableSingleton <HudManager> .Instance.ShowMap((Action <MapBehaviour>) delegate(MapBehaviour m)
                {
                    m.ShowInfectedMap();
                    m.ColorControl.baseColor = Main.Logic.sabotageActive ? Color.gray : Main.Palette.engineerColor;
                });

                return(false);
            }

            if (PlayerControl.LocalPlayer.Data.IsDead)
            {
                return(false);
            }

            MessageWriter writer;

            if (CurrentTarget != null)
            {
                var target = CurrentTarget;
                //code that handles the ability button presses
                if (PlayerControl.LocalPlayer.isPlayerRole("Officer"))
                {
                    if (PlayerTools.getOfficerCD() != 0)
                    {
                        return(false);
                    }

                    if (target.isPlayerImmortal())
                    {
                        // officer suicide packet
                        writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId,
                                                                            (byte)CustomRPC.OfficerKill, Hazel.SendOption.None, -1);
                        writer.Write(PlayerControl.LocalPlayer.PlayerId);
                        writer.Write(PlayerControl.LocalPlayer.PlayerId);
                        AmongUsClient.Instance.FinishRpcImmediately(writer);
                        PlayerControl.LocalPlayer.MurderPlayer(PlayerControl.LocalPlayer);
                        PlayerControl.LocalPlayer.getModdedControl().LastAbilityTime = DateTime.UtcNow;
                        writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId,
                                                                            (byte)CustomRPC.AttemptSound, Hazel.SendOption.None, -1);
                        AmongUsClient.Instance.FinishRpcImmediately(writer);
                        BreakShield(false);
                        return(false);
                    }

                    var isPlayerJokerAndCanDieToOfficer =
                        Main.Config.jokerCanDieToOfficer && target.isPlayerRole("Joker");

                    if (isPlayerJokerAndCanDieToOfficer)
                    {
                        //officer joker murder packet
                        writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId,
                                                                            (byte)CustomRPC.OfficerKill, Hazel.SendOption.None, -1);
                        writer.Write(PlayerControl.LocalPlayer.PlayerId);
                        writer.Write(target.PlayerId);
                        AmongUsClient.Instance.FinishRpcImmediately(writer);
                        PlayerControl.LocalPlayer.MurderPlayer(target);
                        PlayerControl.LocalPlayer.getModdedControl().LastAbilityTime = DateTime.UtcNow;
                        return(false);
                    }

                    if (target.Data.IsImpostor)
                    {
                        //officer impostor murder packet
                        writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId,
                                                                            (byte)CustomRPC.OfficerKill, Hazel.SendOption.None, -1);
                        writer.Write(PlayerControl.LocalPlayer.PlayerId);
                        writer.Write(target.PlayerId);
                        AmongUsClient.Instance.FinishRpcImmediately(writer);
                        PlayerControl.LocalPlayer.MurderPlayer(target);
                        PlayerControl.LocalPlayer.getModdedControl().LastAbilityTime = DateTime.UtcNow;
                        return(false);
                    }

                    // Else they're innocent and not shielded
                    // officer suicide packet
                    writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId,
                                                                        (byte)CustomRPC.OfficerKill, Hazel.SendOption.None, -1);
                    writer.Write(PlayerControl.LocalPlayer.PlayerId);
                    writer.Write(PlayerControl.LocalPlayer.PlayerId);
                    AmongUsClient.Instance.FinishRpcImmediately(writer);
                    PlayerControl.LocalPlayer.MurderPlayer(PlayerControl.LocalPlayer);
                    PlayerControl.LocalPlayer.getModdedControl().LastAbilityTime = DateTime.UtcNow;
                    return(false);
                }

                if (PlayerControl.LocalPlayer.isPlayerRole("Medic"))
                {
                    writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId,
                                                                        (byte)CustomRPC.SetProtected, Hazel.SendOption.None, -1);
                    target.getModdedControl().Immortal = true;
                    PlayerControl.LocalPlayer.getModdedControl().UsedAbility = true;
                    writer.Write(target.PlayerId);
                    AmongUsClient.Instance.FinishRpcImmediately(writer);
                    return(false);
                }
            }

            // continue the murder as normal
            if (!KillButton.CurrentTarget.isPlayerImmortal())
            {
                return(true);
            }

            // play shield break sound
            var shouldPlayShieldBreakSound = KillButton.CurrentTarget.isPlayerImmortal() &&
                                             KillButton.isActiveAndEnabled &&
                                             !KillButton.isCoolingDown && Main.Config.shieldKillAttemptIndicator;

            if (!shouldPlayShieldBreakSound)
            {
                return(false);
            }

            writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId,
                                                                (byte)CustomRPC.AttemptSound, Hazel.SendOption.None, -1);
            AmongUsClient.Instance.FinishRpcImmediately(writer);
            BreakShield(false);

            return(false);
        }
コード例 #6
0
        public static bool Prefix(KillButtonManager __instance)
        {
            if (PlayerControl.LocalPlayer.isPlayerRole(Role.Engineer))
            {
                DestroyableSingleton <HudManager> .Instance.ShowMap((Action <MapBehaviour>) delegate(MapBehaviour m)
                {
                    m.ShowInfectedMap();
                    m.ColorControl.baseColor = Main.Logic.sabotageActive ? Color.gray : Main.Palette.engineerColor;
                });

                return(false);
            }

            if (PlayerControl.LocalPlayer.Data.IsDead)
            {
                return(false);
            }

            var target = __instance.CurrentTarget;

            if (target != null)
            {
                //code that handles the ability button presses
                if (PlayerControl.LocalPlayer.isPlayerRole(Role.Officer))
                {
                    if (PlayerTools.getOfficerCD() > 0)
                    {
                        return(false);
                    }

                    var isTargetJoker      = target.isPlayerRole(Role.Joker);
                    var isTargetImpostor   = target.Data.IsImpostor;
                    var officerKillSetting = Main.Config.officerKillBehaviour;
                    if (target.isPlayerImmortal())
                    {
                        if (Main.Config.officerShouldDieToShieldedPlayers)
                        {
                            // suicide packet
                            SendOfficerKillRpc(PlayerControl.LocalPlayer);
                        }
                        BreakShield(false);
                    }
                    else if (officerKillSetting == OfficerKillBehaviour.OfficerSurvives || // don't care who it is, kill them
                             isTargetImpostor || // impostors always die
                             (officerKillSetting != OfficerKillBehaviour.Impostor && isTargetJoker)) // joker can die and target is joker
                    {
                        // kill target
                        SendOfficerKillRpc(target);
                    }
                    else // officer dies
                    {
                        if (officerKillSetting == OfficerKillBehaviour.CrewDie)
                        {
                            // kill target too
                            SendOfficerKillRpc(target);
                        }
                        // kill officer
                        SendOfficerKillRpc(PlayerControl.LocalPlayer);
                    }

                    return(false);
                }

                if (PlayerControl.LocalPlayer.isPlayerRole(Role.Medic))
                {
                    WriteGiveShieldRpc(target);
                    return(false);
                }
            }

            // continue the murder as normal
            if (!KillButton.CurrentTarget.isPlayerImmortal())
            {
                return(true);
            }

            // play shield break sound
            var shouldPlayShieldBreakSound = KillButton.CurrentTarget.isPlayerImmortal() &&
                                             KillButton.isActiveAndEnabled &&
                                             !KillButton.isCoolingDown && Main.Config.shieldKillAttemptIndicator;

            if (!shouldPlayShieldBreakSound)
            {
                return(false);
            }

            // Send Play Shield Break RPC
            Rpc <AttemptKillShieldedPlayerRpc> .Instance.Send(data : PlayerControl.LocalPlayer.PlayerId, immediately : true);

            return(false);
        }