From 837b5b75f04c8a0209f24ac7715bc7e28f7a4555 Mon Sep 17 00:00:00 2001 From: PEPPERcula Date: Sat, 27 Dec 2025 01:46:56 -0700 Subject: [PATCH] Fix Meeting abilities with UI working during Daybreak (#448) * Update Inspector.cs * Update Nemesis.cs * Update Councillor.cs * Update Judge.cs * Update Swapper.cs Add condition to check if it's daytime before allowing swap. * Update Imitator.cs * Update Retributionist.cs * Update Ventriloquist.cs * Update GuessManager.cs * Update PlayerJoinAndLeftPatch.cs * Update ChatCommandPatch.cs * Update EACList.txt Removed a cheater entry and added a new section for griefers and toxic players. * Update Ventriloquist.cs * Update Nemesis.cs * Update Imitator.cs * Update ChatCommandPatch.cs * Update GuessManager.cs * Fix Role buttons not working on discussion when setting is on * Update GuessManager.cs * fix --------- Co-authored-by: Gurge44 <90392754+Gurge44@users.noreply.github.com> --- Modules/GuessManager.cs | 30 ++++++++++++++++++------------ Patches/ChatCommandPatch.cs | 7 ++++++- Patches/PlayerJoinAndLeftPatch.cs | 1 + Resources/Config/EACList.txt | 4 ++-- Roles/Crewmate/Imitator.cs | 3 ++- Roles/Crewmate/Inspector.cs | 3 +-- Roles/Crewmate/Judge.cs | 2 +- Roles/Crewmate/Retributionist.cs | 2 +- Roles/Crewmate/Swapper.cs | 5 ++--- Roles/Impostor/Councillor.cs | 2 +- Roles/Impostor/Nemesis.cs | 3 ++- Roles/Impostor/Ventriloquist.cs | 3 ++- 12 files changed, 39 insertions(+), 26 deletions(-) diff --git a/Modules/GuessManager.cs b/Modules/GuessManager.cs index f4e1d6a73..7e8e77ddc 100644 --- a/Modules/GuessManager.cs +++ b/Modules/GuessManager.cs @@ -328,15 +328,17 @@ public static class GuessManager case CustomRoles.Ankylosaurus: ShowMessage("GuessAnkylosaurus"); return true; - case CustomRoles.Speedrunner when target.Is(CustomRoles.Speedrunner) && !pc.Is(Team.Crewmate) && target.GetTaskState().CompletedTasksCount >= Speedrunner.SpeedrunnerNotifyAtXTasksLeft.GetInt() && Speedrunner.SpeedrunnerNotifyKillers.GetBool(): + case CustomRoles.Car: case CustomRoles.DonutDelivery when DonutDelivery.IsUnguessable(pc, target): case CustomRoles.Shifter: - case CustomRoles.Car: + case CustomRoles.Speedrunner when target.Is(CustomRoles.Speedrunner) && !pc.Is(Team.Crewmate) && target.GetTaskState().CompletedTasksCount >= Speedrunner.SpeedrunnerNotifyAtXTasksLeft.GetInt() && Speedrunner.SpeedrunnerNotifyKillers.GetBool(): case CustomRoles.Goose when !Goose.CanBeGuessed.GetBool(): + case CustomRoles.BananaMan: case CustomRoles.Disco: + case CustomRoles.Flashman: + case CustomRoles.Giant: case CustomRoles.Glow: case CustomRoles.LastImpostor: - case CustomRoles.BananaMan: ShowMessage("GuessObviousAddon"); return true; case CustomRoles.GM: @@ -781,7 +783,7 @@ public static class GuessManager private static void GuesserOnClick(byte playerId, MeetingHud __instance) { PlayerControl pc = Utils.GetPlayerById(playerId); - if (pc == null || !pc.IsAlive() || GuesserUI != null || !GameStates.IsVoting) return; + if (pc == null || !pc.IsAlive() || GuesserUI != null || MeetingHud.Instance.state is MeetingHud.VoteStates.Results or MeetingHud.VoteStates.Proceeding || Starspawn.IsDayBreak) return; try { @@ -1003,7 +1005,7 @@ public static class GuessManager } else { - if (__instance.state is not (MeetingHud.VoteStates.Voted or MeetingHud.VoteStates.NotVoted) || !PlayerControl.LocalPlayer.IsAlive()) return; + if (MeetingHud.Instance.state is MeetingHud.VoteStates.Results or MeetingHud.VoteStates.Proceeding || !PlayerControl.LocalPlayer.IsAlive()) return; Logger.Msg($"Click: {pc.GetNameWithRole()} => {role}", "Guesser UI"); @@ -1038,20 +1040,23 @@ public static class GuessManager { if (role is CustomRoles.GM or - CustomRoles.Oblivious or - CustomRoles.Flashman or + CustomRoles.Ankylosaurus or + CustomRoles.BananaMan or + CustomRoles.Car or CustomRoles.Disco or + CustomRoles.Flashman or CustomRoles.Giant or + CustomRoles.LastImpostor or CustomRoles.NotAssigned or - CustomRoles.SoloPVP_Player or - CustomRoles.Paranoid or - CustomRoles.SuperStar or - CustomRoles.GuardianAngelEHR + CustomRoles.Shifter or + CustomRoles.Specter or + CustomRoles.SuperStar ) return false; + if (role.IsForOtherGameMode()) return false; if (!role.IsEnable() && !role.RoleExist(true) && !CanMakeRoleSpawn(role)) return false; - return Options.CurrentGameMode == CustomGameMode.Standard && !CustomHnS.AllHnSRoles.Contains(role) && !role.IsVanilla(); + return Options.CurrentGameMode == CustomGameMode.Standard && !CustomHnS.AllHnSRoles.Contains(role) && !role.IsGhostRole() && !role.IsVanilla(); bool CanMakeRoleSpawn(CustomRoles r) { @@ -1646,3 +1651,4 @@ public static class GuessManager } } + diff --git a/Patches/ChatCommandPatch.cs b/Patches/ChatCommandPatch.cs index 764a8ccb1..8a2c28554 100644 --- a/Patches/ChatCommandPatch.cs +++ b/Patches/ChatCommandPatch.cs @@ -699,17 +699,20 @@ internal static class ChatCommands if (!targetState.IsDead) { + RPC.PlaySoundRPC(player.PlayerId, Sounds.SabotageSound); Utils.SendMessage("\n", player.PlayerId, GetString("Imitator.TargetMustBeDead")); return; } if (!targetState.MainRole.Is(Team.Crewmate) || targetState.MainRole == CustomRoles.GM) { + RPC.PlaySoundRPC(player.PlayerId, Sounds.SabotageSound); Utils.SendMessage("\n", player.PlayerId, GetString("Imitator.TargetMustBeCrew")); return; } Imitator.ImitatingRole[player.PlayerId] = targetState.MainRole; + RPC.PlaySoundRPC(player.PlayerId, Sounds.TaskComplete); Logger.Info($"{player.GetRealName()} will be imitating as {targetState.MainRole}", "Imitator"); Utils.SendMessage("\n", player.PlayerId, string.Format(GetString("Imitator.Success"), targetId.ColoredPlayerName())); @@ -1336,7 +1339,7 @@ internal static class ChatCommands () => Utils.EnterQuickSetupRoles(false)); } - private static void ReadyCheckCommand(PlayerControl player, string commandKey, string text, string[] args) + public static void ReadyCheckCommand(PlayerControl player, string commandKey, string text, string[] args) { if (!AmongUsClient.Instance.AmHost) { @@ -2278,6 +2281,8 @@ internal static class ChatCommands var vl = (Ventriloquist)Main.PlayerStates[player.PlayerId].Role; vl.Target = args.Length < 2 ? byte.MaxValue : byte.TryParse(args[1], out byte targetId) ? targetId : byte.MaxValue; + player.RPCPlayCustomSound("Line"); + MeetingManager.SendCommandUsedMessage(args[0]); } diff --git a/Patches/PlayerJoinAndLeftPatch.cs b/Patches/PlayerJoinAndLeftPatch.cs index afbc38a6b..6b0614474 100644 --- a/Patches/PlayerJoinAndLeftPatch.cs +++ b/Patches/PlayerJoinAndLeftPatch.cs @@ -183,6 +183,7 @@ internal static class OnGameJoinedPatch if (Options.AutoDraftStartCommandAfterJoin.GetBool()) ChatCommands.DraftStartCommand(PlayerControl.LocalPlayer, "Command.DraftStart", "/draftstart", ["/draftstart"]); } + } if (Options.AutoReadyCheckCommandAfterJoin.GetBool()) { diff --git a/Resources/Config/EACList.txt b/Resources/Config/EACList.txt index 01c23f411..290cb40ec 100644 --- a/Resources/Config/EACList.txt +++ b/Resources/Config/EACList.txt @@ -94,8 +94,8 @@ byechic#6270 | 91e0145f1 | (Contains n word) | Harassing a streamer with a slur waiverfore#0496 | b493df896 | | Cheating in Syl's lobby | whaleutter#4768 | 9e04dc5d5 | | Cheating in Syl's lobby | No name cheater whimrecent#6558 | f8452a9d1 | | Cheating | No name cheater - pureplot#2423 | ed4c7bdf6 | hdrzz | Cheater | Cheated in Sarha's lobby + ## Griefers, Toxic, harrasing, morons setmolar#4374 | | 藏族顶针 | Toxic | overtfeast#5802 | | 黑影 | Toxic | @@ -127,4 +127,4 @@ primesnow#4272 | 65b98a6de | HiverXM | Toxic | The n word tenthrope#3476 | | Oldishwire | Other | greencorps#9587 | 4a403fe31 | ellsbells | Other | finlucky#6381 | 433b2e672 | Wuwu | Other | -nattertame#9540 | 0abd54784 | Wuwu | Other | Alt account \ No newline at end of file +nattertame#9540 | 0abd54784 | Wuwu | Other | Alt account diff --git a/Roles/Crewmate/Imitator.cs b/Roles/Crewmate/Imitator.cs index 403ecaa0f..084192017 100644 --- a/Roles/Crewmate/Imitator.cs +++ b/Roles/Crewmate/Imitator.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using EHR.Modules; +using EHR.Neutral; using Hazel; using UnityEngine; @@ -70,7 +71,7 @@ public class Imitator : RoleBase { Logger.Msg($"Click: ID {playerId}", "Imitator UI"); PlayerControl pc = Utils.GetPlayerById(playerId); - if (pc == null || pc.IsAlive() || !GameStates.IsVoting) return; + if (pc == null || pc.IsAlive() || !GameStates.IsVoting || Starspawn.IsDayBreak) return; if (AmongUsClient.Instance.AmHost) { diff --git a/Roles/Crewmate/Inspector.cs b/Roles/Crewmate/Inspector.cs index df3c60523..b82ccda19 100644 --- a/Roles/Crewmate/Inspector.cs +++ b/Roles/Crewmate/Inspector.cs @@ -8,7 +8,6 @@ using UnityEngine; using static EHR.Options; using static EHR.Translator; - namespace EHR.Crewmate; public class Inspector : RoleBase @@ -435,7 +434,7 @@ public class Inspector : RoleBase private static void PickForCompare(byte playerId, byte lpcId) { PlayerControl pc = Utils.GetPlayerById(playerId); - if (pc == null || !pc.IsAlive() || !GameStates.IsVoting) return; + if (pc == null || !pc.IsAlive() || !GameStates.IsVoting || Starspawn.IsDayBreak) return; if (FirstPick.TryGetValue(lpcId, out byte firstPick)) { diff --git a/Roles/Crewmate/Judge.cs b/Roles/Crewmate/Judge.cs index 1132ef4b0..7eed3729b 100644 --- a/Roles/Crewmate/Judge.cs +++ b/Roles/Crewmate/Judge.cs @@ -287,7 +287,7 @@ public class Judge : RoleBase { Logger.Msg($"Click: ID {playerId}", "Judge UI"); PlayerControl pc = Utils.GetPlayerById(playerId); - if (pc == null || !pc.IsAlive() || !GameStates.IsVoting) return; + if (pc == null || !pc.IsAlive() || !GameStates.IsVoting || Starspawn.IsDayBreak) return; if (AmongUsClient.Instance.AmHost) TrialMsg(PlayerControl.LocalPlayer, $"/tl {playerId}", true); diff --git a/Roles/Crewmate/Retributionist.cs b/Roles/Crewmate/Retributionist.cs index 507233453..2ea86370d 100644 --- a/Roles/Crewmate/Retributionist.cs +++ b/Roles/Crewmate/Retributionist.cs @@ -119,7 +119,7 @@ public class Retributionist : RoleBase { Logger.Msg($"Click: ID {playerId}", "Retributionist UI"); PlayerControl pc = Utils.GetPlayerById(playerId); - if (pc == null || !pc.IsAlive() || !GameStates.IsVoting) return; + if (pc == null || !pc.IsAlive() || !GameStates.IsVoting || Starspawn.IsDayBreak) return; if (AmongUsClient.Instance.AmHost) { diff --git a/Roles/Crewmate/Swapper.cs b/Roles/Crewmate/Swapper.cs index e4bfcdcdb..31a9f073a 100644 --- a/Roles/Crewmate/Swapper.cs +++ b/Roles/Crewmate/Swapper.cs @@ -7,7 +7,6 @@ using Hazel; using UnityEngine; using static EHR.Translator; - namespace EHR.Crewmate; public class Swapper : RoleBase @@ -280,7 +279,7 @@ public class Swapper : RoleBase Logger.Msg($"Click: ID {playerId}", "Swapper UI"); PlayerControl pc = Utils.GetPlayerById(playerId); - if (pc == null || !pc.IsAlive() || !GameStates.IsVoting) return; + if (pc == null || !pc.IsAlive() || !GameStates.IsVoting || Starspawn.IsDayBreak) return; if (AmongUsClient.Instance.AmHost) SwapMsg(PlayerControl.LocalPlayer, $"/sw {playerId}", true); @@ -345,4 +344,4 @@ public class Swapper : RoleBase keepGameGoing = true; countsAs = 1; } -} \ No newline at end of file +} diff --git a/Roles/Impostor/Councillor.cs b/Roles/Impostor/Councillor.cs index b8c94e7db..a44551091 100644 --- a/Roles/Impostor/Councillor.cs +++ b/Roles/Impostor/Councillor.cs @@ -319,7 +319,7 @@ public class Councillor : RoleBase { Logger.Msg($"Click: ID {playerId}", "Councillor UI"); PlayerControl pc = Utils.GetPlayerById(playerId); - if (pc == null || !pc.IsAlive() || !GameStates.IsVoting) return; + if (pc == null || !pc.IsAlive() || !GameStates.IsVoting || Starspawn.IsDayBreak) return; if (AmongUsClient.Instance.AmHost) MurderMsg(PlayerControl.LocalPlayer, $"/tl {playerId}", true); diff --git a/Roles/Impostor/Nemesis.cs b/Roles/Impostor/Nemesis.cs index 802f0bb42..b4834218c 100644 --- a/Roles/Impostor/Nemesis.cs +++ b/Roles/Impostor/Nemesis.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using AmongUs.GameOptions; using EHR.Modules; +using EHR.Neutral; using Hazel; using UnityEngine; using static EHR.Options; @@ -191,7 +192,7 @@ internal class Nemesis : RoleBase { Logger.Msg($"Click: ID {playerId}", "Nemesis UI"); PlayerControl pc = Utils.GetPlayerById(playerId); - if (pc == null || !pc.IsAlive() || !GameStates.IsVoting) return; + if (pc == null || !pc.IsAlive() || !GameStates.IsVoting || Starspawn.IsDayBreak) return; if (AmongUsClient.Instance.AmHost) NemesisMsgCheck(PlayerControl.LocalPlayer, $"/rv {playerId}", true); diff --git a/Roles/Impostor/Ventriloquist.cs b/Roles/Impostor/Ventriloquist.cs index 58c20a8b9..85259c0ce 100644 --- a/Roles/Impostor/Ventriloquist.cs +++ b/Roles/Impostor/Ventriloquist.cs @@ -1,6 +1,7 @@ using System; using System.Linq; using EHR.Modules; +using EHR.Neutral; using Hazel; using UnityEngine; @@ -58,7 +59,7 @@ public class Ventriloquist : RoleBase { Logger.Msg($"Click: ID {playerId}", "Ventriloquist UI"); PlayerControl pc = Utils.GetPlayerById(playerId); - if (pc == null || !pc.IsAlive() || !GameStates.IsVoting) return; + if (pc == null || !pc.IsAlive() || !GameStates.IsVoting || Starspawn.IsDayBreak) return; if (AmongUsClient.Instance.AmHost) {