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; } } } }
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) { PlayerControl target = CurrentTarget; //code that handles the ability button presses if (PlayerControl.LocalPlayer.isPlayerRole("Officer")) { if (PlayerTools.GetOfficerKD() == 0) { //check if they're shielded by medic if (target.isPlayerImmortal()) { //officer suicide packet MessageWriter 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); } //check if they're joker and the setting is configured else if (Main.Config.jokerCanDieToOfficer && target.isPlayerRole("Joker")) { //officer joker murder packet MessageWriter 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; } //check if they're an impostor else if (target.Data.IsImpostor) { //officer impostor murder packet MessageWriter 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 else { //officer suicide packet MessageWriter 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); } return(false); } return(false); } else if (PlayerControl.LocalPlayer.isPlayerRole("Medic")) { MessageWriter 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); } } if (KillButton.CurrentTarget.isPlayerImmortal()) { if (KillButton.CurrentTarget.isPlayerImmortal() && KillButton.isActiveAndEnabled && !KillButton.isCoolingDown && Main.Config.shieldKillAttemptIndicator) { MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.AttemptSound, Hazel.SendOption.None, -1); AmongUsClient.Instance.FinishRpcImmediately(writer); BreakShield(false); } return(false); } //otherwise, continue the murder as normal return(true); }
public static bool Prefix() { if (PlayerControl.LocalPlayer == EngineerSettings.Engineer) { DestroyableSingleton <HudManager> .Instance.ShowMap((Action <MapBehaviour>) delegate(MapBehaviour m) { m.ShowInfectedMap(); m.ColorControl.baseColor = EngineerSettings.sabotageActive ? Color.gray : ModdedPalette.engineerColor; }); return(false); } if (PlayerControl.LocalPlayer.Data.IsDead) { return(false); } if (CurrentTarget != null) { PlayerControl target = CurrentTarget; //code that handles the ability button presses if (OfficerSettings.Officer != null && PlayerControl.LocalPlayer.PlayerId == OfficerSettings.Officer.PlayerId) { if (PlayerTools.GetOfficerKD() == 0) { //check if they're shielded by medic if (MedicSettings.Protected != null && target.PlayerId == MedicSettings.Protected.PlayerId) { //officer suicide packet MessageWriter 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); OfficerSettings.lastKilled = DateTime.UtcNow; return(false); } //check if they're joker and the setting is configured else if (JokerSettings.jokerCanDieToOfficer && (JokerSettings.Joker != null && target.PlayerId == JokerSettings.Joker.PlayerId)) { //officer joker murder packet MessageWriter 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); OfficerSettings.lastKilled = DateTime.UtcNow; } //check if they're an impostor else if (target.Data.IsImpostor) { //officer impostor murder packet MessageWriter 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); OfficerSettings.lastKilled = DateTime.UtcNow; return(false); } //else, they're innocent and not shielded else { //officer suicide packet MessageWriter 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); OfficerSettings.lastKilled = DateTime.UtcNow; return(false); } return(false); } return(false); } else if (MedicSettings.Medic != null && PlayerControl.LocalPlayer == MedicSettings.Medic) { MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetProtected, Hazel.SendOption.None, -1); MedicSettings.Protected = target; MedicSettings.shieldUsed = true; byte ProtectedId = MedicSettings.Protected.PlayerId; writer.Write(ProtectedId); AmongUsClient.Instance.FinishRpcImmediately(writer); return(false); } } if (MedicSettings.Protected != null && PlayerTools.closestPlayer.PlayerId == MedicSettings.Protected.PlayerId) { //cancel the kill return(false); } //otherwise, continue the murder as normal return(true); }
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; } } } }