diff --git a/CTA/CustomTeamAssigner/CustomRoles.cs b/CTA/CustomTeamAssigner/CustomRoles.cs index fe592aa48..c7db3541b 100644 --- a/CTA/CustomTeamAssigner/CustomRoles.cs +++ b/CTA/CustomTeamAssigner/CustomRoles.cs @@ -226,7 +226,7 @@ public enum CustomRoles Inquisitor, Jailor, Journalist, - JudgeOld, + Prosecutor, LazyGuy, Leery, Lighter, diff --git a/CustomRoles.cs b/CustomRoles.cs index fe592aa48..c7db3541b 100644 --- a/CustomRoles.cs +++ b/CustomRoles.cs @@ -226,7 +226,7 @@ public enum CustomRoles Inquisitor, Jailor, Journalist, - JudgeOld, + Prosecutor, LazyGuy, Leery, Lighter, diff --git a/Main.cs b/Main.cs index 31fac009a..c656613f6 100644 --- a/Main.cs +++ b/Main.cs @@ -581,7 +581,7 @@ public class Main : BasePlugin { CustomRoles.Medic, "#00ff97" }, { CustomRoles.FortuneTeller, "#882c83" }, { CustomRoles.Glitch, "#39FF14" }, - { CustomRoles.JudgeOld, "#f8d85a" }, + { CustomRoles.Prosecutor, "#f8d85a" }, { CustomRoles.Mortician, "#333c49" }, { CustomRoles.Medium, "#a200ff" }, { CustomRoles.Observer, "#a8e0fa" }, diff --git a/Modules/CustomRolesHelper.cs b/Modules/CustomRolesHelper.cs index c4fcbb651..e64b436b8 100644 --- a/Modules/CustomRolesHelper.cs +++ b/Modules/CustomRolesHelper.cs @@ -352,7 +352,7 @@ internal static class CustomRolesHelper CustomRoles.Hangman => CustomRoles.Shapeshifter, CustomRoles.Sunnyboy => CustomRoles.Scientist, CustomRoles.Specter => Options.PhantomCanVent.GetBool() ? CustomRoles.Engineer : CustomRoles.Crewmate, - CustomRoles.JudgeOld => CustomRoles.Crewmate, + CustomRoles.Prosecutor => CustomRoles.Crewmate, CustomRoles.Councillor => CustomRoles.Impostor, CustomRoles.Mortician => CustomRoles.Crewmate, CustomRoles.Medium => CustomRoles.Crewmate, @@ -1492,7 +1492,7 @@ internal static class CustomRolesHelper CustomRoles.Ventguard => RoleOptionType.Crewmate_Support, CustomRoles.Wizard => RoleOptionType.Crewmate_Support, CustomRoles.Drainer => RoleOptionType.Crewmate_Killing, - CustomRoles.JudgeOld => RoleOptionType.Crewmate_Killing, + CustomRoles.Prosecutor => RoleOptionType.Crewmate_Killing, CustomRoles.NiceGuesser => RoleOptionType.Crewmate_Killing, CustomRoles.Retributionist => RoleOptionType.Crewmate_Killing, CustomRoles.Sentinel => RoleOptionType.Crewmate_Killing, diff --git a/Modules/ExtendedPlayerControl.cs b/Modules/ExtendedPlayerControl.cs index 1e12ee058..ee0845bf9 100644 --- a/Modules/ExtendedPlayerControl.cs +++ b/Modules/ExtendedPlayerControl.cs @@ -57,14 +57,14 @@ internal static class ExtendedPlayerControl public bool UsesMeetingShapeshift() { CustomRoles role = player.GetCustomRole(); - // if (player.IsModdedClient() && role is CustomRoles.Councillor or CustomRoles.Inspector or CustomRoles.JudgeOld or CustomRoles.Retributionist or CustomRoles.Starspawn or CustomRoles.Swapper or CustomRoles.Ventriloquist) return false; + // if (player.IsModdedClient() && role is CustomRoles.Councillor or CustomRoles.Inspector or CustomRoles.Prosecutor or CustomRoles.Retributionist or CustomRoles.Starspawn or CustomRoles.Swapper or CustomRoles.Ventriloquist) return false; return role.UsesMeetingShapeshift(); } public bool UsesJudgeAbilityAsTrigger() { CustomRoles role = player.GetCustomRole(); - if (player.IsModdedClient() && role is CustomRoles.Councillor or CustomRoles.Inspector or CustomRoles.JudgeOld or CustomRoles.Retributionist or CustomRoles.Starspawn or CustomRoles.Swapper or CustomRoles.Ventriloquist) return false; + if (player.IsModdedClient() && role is CustomRoles.Councillor or CustomRoles.Inspector or CustomRoles.Prosecutor or CustomRoles.Retributionist or CustomRoles.Starspawn or CustomRoles.Swapper or CustomRoles.Ventriloquist) return false; return role.UsesJudgeAbilityAsTrigger(); } diff --git a/Modules/GameOptionsSender/PlayerGameOptionsSender.cs b/Modules/GameOptionsSender/PlayerGameOptionsSender.cs index a79dbe022..3e688544b 100644 --- a/Modules/GameOptionsSender/PlayerGameOptionsSender.cs +++ b/Modules/GameOptionsSender/PlayerGameOptionsSender.cs @@ -644,6 +644,9 @@ public sealed class PlayerGameOptionsSender(PlayerControl player) : GameOptionsS AURoleOptions.JudgeTaskRequirementPercentage = CrewmateVanillaRoles.JudgeTaskRequirementPercentage.GetFloat(); break; } + + if (player.UsesJudgeAbilityAsTrigger()) + AURoleOptions.JudgeTaskRequirementPercentage = 0f; // When impostor alert is off, and the player is a desync crewmate, set impostor alert as true if (role.IsDesyncRole() && role.IsCrewmate() && !CrewmateVanillaRoles.NoiseMakerImpostorAlert.GetBool()) diff --git a/Modules/GuessManager.cs b/Modules/GuessManager.cs index 726cbaf2f..edfbdf386 100644 --- a/Modules/GuessManager.cs +++ b/Modules/GuessManager.cs @@ -65,7 +65,7 @@ public static class GuessManager if (!AmongUsClient.Instance.AmHost) return false; if (!GameStates.IsMeeting || MeetingHud.Instance.state is MeetingHud.MeetingStates.Results or MeetingHud.MeetingStates.Proceeding || !pc) return false; - bool hasGuessingRole = pc.GetCustomRole() is CustomRoles.NiceGuesser or CustomRoles.EvilGuesser or CustomRoles.Doomsayer or CustomRoles.JudgeOld or CustomRoles.Swapper or CustomRoles.Councillor or CustomRoles.NecroGuesser or CustomRoles.Augur; + bool hasGuessingRole = pc.GetCustomRole() is CustomRoles.NiceGuesser or CustomRoles.EvilGuesser or CustomRoles.Doomsayer or CustomRoles.Prosecutor or CustomRoles.Swapper or CustomRoles.Councillor or CustomRoles.NecroGuesser or CustomRoles.Augur; if (!hasGuessingRole && !pc.Is(CustomRoles.Guesser) && !Options.GuesserMode.GetBool()) return false; int operate; // 1: ID, 2: Guess diff --git a/Modules/LoadingScreen.cs b/Modules/LoadingScreen.cs index 300c0cefd..b008632e5 100644 --- a/Modules/LoadingScreen.cs +++ b/Modules/LoadingScreen.cs @@ -10,7 +10,7 @@ internal static class LoadingScreen { private const int HintCount = 40; private const int JokeHintCount = 6; - private static Vector3 Position; + private static Camera Camera; private static SpriteRenderer LoadingAnimation; private static readonly HashSet ToldHints = []; private static float HintHideTimer; @@ -26,8 +26,8 @@ internal static class LoadingScreen LoadingAnimation.sprite = Utils.LoadSprite("EHR.Resources.Loading.png", 300f); LoadingAnimation.sortingOrder = 100; - var camera = HudManager.Instance.GetComponentInChildren(); - LoadingAnimation.transform.position = Position = AspectPosition.ComputeWorldPosition(camera, AspectPosition.EdgeAlignments.LeftBottom, new Vector3(0.6f, 0.6f, camera.nearClipPlane + 0.1f)); + Camera = HudManager.Instance.GetComponentInChildren(); + LoadingAnimation.transform.position = AspectPosition.ComputeWorldPosition(Camera, AspectPosition.EdgeAlignments.LeftBottom, new Vector3(0.6f, 0.6f, Camera.nearClipPlane + 0.1f)); } catch (Exception ex) { Logger.Error(ex.ToString(), "LoadingScreen.UpdateLoadingAnimation"); } } @@ -87,7 +87,7 @@ internal static class LoadingScreen if (LoadingAnimation) { - LoadingAnimation.transform.position = Position; + LoadingAnimation.transform.position = AspectPosition.ComputeWorldPosition(Camera, AspectPosition.EdgeAlignments.LeftBottom, new Vector3(0.6f, 0.6f, Camera.nearClipPlane + 0.1f)); LoadingAnimation.transform.Rotate(Vector3.back, 200f * Time.deltaTime); } diff --git a/Modules/OptionHolder.cs b/Modules/OptionHolder.cs index a69d60123..41799d0c2 100644 --- a/Modules/OptionHolder.cs +++ b/Modules/OptionHolder.cs @@ -181,7 +181,7 @@ public static class Options "TempBan" ]; - private static readonly string[] ConfirmEjectionsMode = + public static readonly string[] ConfirmEjectionsMode = [ "ConfirmEjections.None", "ConfirmEjections.Team", diff --git a/Modules/Utils.cs b/Modules/Utils.cs index 4189258ce..dc94d4381 100644 --- a/Modules/Utils.cs +++ b/Modules/Utils.cs @@ -156,47 +156,6 @@ public static class Utils try { LoadingBarManager.Instance.ToggleLoadingBar(false); } catch (Exception e) { ThrowException(e); } } - - public static IEnumerator SendGameDataContinuously() - { - float waitTime = GameData.Instance.AllPlayers.Count switch - { - <= 15 => 1f, - <= 20 => 0.8f, - _ => 0.5f - }; - - while (GameStates.InGame && !GameStates.IsEnded && ShipStatus.Instance) - { - if (ReportDeadBodyPatch.MeetingStarted || GameStates.IsMeeting || ExileController.Instance || AntiBlackout.SkipTasks) - { - yield return new WaitForSecondsRealtime(10f); - continue; - } - - for (var index = 0; index < GameData.Instance.AllPlayers.Count; index++) - { - NetworkedPlayerInfo playerInfo = GameData.Instance.AllPlayers[index]; - - if (!playerInfo || (Astral.On && Main.PlayerStates.TryGetValue(playerInfo.PlayerId, out PlayerState state) && state.Role is Astral { Timer: not null }) || (SoulCollector.On && Main.PlayerStates.Values.Any(x => x.Role is SoulCollector sc && sc.ToExile.Contains(playerInfo.PlayerId)))) continue; - - playerInfo.IsDead = !playerInfo.Object.IsAlive(); - - var qa = playerInfo.SendGameData(SendOption.None); - yield return qa.Wait(); - - if (qa.Dropped || !GameStates.InGame || GameStates.IsEnded || !ShipStatus.Instance) - { - Logger.Msg("Coroutine finished", nameof(SendGameDataContinuously)); - yield break; - } - - yield return new WaitForSecondsRealtime(waitTime); - } - } - - Logger.Msg("Coroutine finished", nameof(SendGameDataContinuously)); - } public static void CheckAndSetVentInteractions() { @@ -1103,7 +1062,7 @@ public static class Utils (pc.Is(CustomRoles.Mayor) && !Options.MayorCanBeMadmate.GetBool()) || (pc.Is(CustomRoles.NiceGuesser) && !Options.NGuesserCanBeMadmate.GetBool()) || (pc.Is(CustomRoles.Snitch) && !Options.SnitchCanBeMadmate.GetBool()) || - (pc.Is(CustomRoles.JudgeOld) && !Options.JudgeCanBeMadmate.GetBool()) || + (pc.Is(CustomRoles.Prosecutor) && !Options.JudgeCanBeMadmate.GetBool()) || (pc.Is(CustomRoles.Marshall) && !Options.MarshallCanBeMadmate.GetBool()) || (pc.Is(CustomRoles.Investigator) && !Options.InvestigatorCanBeMadmate.GetBool()) || (pc.Is(CustomRoles.President) && !Options.PresidentCanBeMadmate.GetBool()) || diff --git a/Patches/ChatCommandPatch.cs b/Patches/ChatCommandPatch.cs index 66e7c7fc5..6078310e4 100644 --- a/Patches/ChatCommandPatch.cs +++ b/Patches/ChatCommandPatch.cs @@ -985,7 +985,7 @@ internal static class ChatCommands { if (Starspawn.IsDayBreak) return; - if (!player.IsAlive() || Main.PlayerStates[player.PlayerId].Role is not Markseeker { IsEnable: true } ms || ms.MarkedId != byte.MaxValue) return; + if (!player.IsAlive() || Main.PlayerStates[player.PlayerId].Role is not Markseeker { IsEnable: true, MarkedId: byte.MaxValue } ms) return; ms.MarkedId = args.Length < 2 ? byte.MaxValue : byte.TryParse(args[1], out byte targetId) ? targetId : byte.MaxValue; diff --git a/Patches/ChatControlPatch.cs b/Patches/ChatControlPatch.cs index 4e45bda1e..bec370253 100644 --- a/Patches/ChatControlPatch.cs +++ b/Patches/ChatControlPatch.cs @@ -18,7 +18,7 @@ static class ChatControllerAwakePatch private static SpriteRenderer OpenBanMenuIcon; private static SpriteRenderer OpenKeyboardIcon; - private static readonly Color32 DarkBackgroundColor = new(40, 40, 40, byte.MaxValue); + public static readonly Color32 DarkBackgroundColor = new(40, 40, 40, byte.MaxValue); public static void Postfix(ChatController __instance) { diff --git a/Patches/GameOptionsMenuPatch.cs b/Patches/GameOptionsMenuPatch.cs index 8c13e5fdf..155f9e342 100644 --- a/Patches/GameOptionsMenuPatch.cs +++ b/Patches/GameOptionsMenuPatch.cs @@ -1370,6 +1370,10 @@ public static class GameSettingMenuPatch field.transform.SetParent(parentLeftPanel.parent, false); field.gameObject.SetActive(true); } + else + { + Main.Instance.StartCoroutine(KeepSearchBarDarkThemed()); + } field.transform.localScale = new(0.3f, 0.59f, 1); field.transform.localPosition = new(-0.47f, 2.15f, -5f); field.textArea.outputText.transform.localScale = new(3.5f, 2f, 1f); @@ -1443,6 +1447,21 @@ public static class GameSettingMenuPatch GameOptionsMenuPatch.ReCreateSettings(gameSettings); textField.Clear(); } + + IEnumerator KeepSearchBarDarkThemed() + { + while (InputField) + { + if (Main.DarkTheme.Value && GameSettingMenu.Instance && InputField.gameObject.activeSelf) + { + InputField.background.color = ChatControllerAwakePatch.DarkBackgroundColor; + InputField.textArea.compoText.Color(Color.white); + InputField.textArea.outputText.color = Color.white; + } + + yield return null; + } + } } private static void SetDefaultButton(GameSettingMenu __instance) diff --git a/Patches/HudPatch.cs b/Patches/HudPatch.cs index 7c340bff5..740a3cbc2 100644 --- a/Patches/HudPatch.cs +++ b/Patches/HudPatch.cs @@ -428,7 +428,7 @@ internal static class HudManagerPatch ActionButton button; Type type = state.Role.GetType(); - if (type.GetMethod("OnVote").DeclaringType == type || role is CustomRoles.Adrenaline or CustomRoles.Battery or CustomRoles.Dad or CustomRoles.Grappler or CustomRoles.Inquirer or CustomRoles.JudgeOld or CustomRoles.Mechanic or CustomRoles.Medium or CustomRoles.Swapper or CustomRoles.Inspector or CustomRoles.Spy or CustomRoles.Councillor or CustomRoles.CursedWolf or CustomRoles.Forger or CustomRoles.Generator or CustomRoles.Ventriloquist or CustomRoles.Bargainer or CustomRoles.Technician or CustomRoles.Virus) + if (type.GetMethod("OnVote").DeclaringType == type || role is CustomRoles.Adrenaline or CustomRoles.Battery or CustomRoles.Dad or CustomRoles.Grappler or CustomRoles.Inquirer or CustomRoles.Prosecutor or CustomRoles.Mechanic or CustomRoles.Medium or CustomRoles.Swapper or CustomRoles.Inspector or CustomRoles.Spy or CustomRoles.Councillor or CustomRoles.CursedWolf or CustomRoles.Forger or CustomRoles.Generator or CustomRoles.Ventriloquist or CustomRoles.Bargainer or CustomRoles.Technician or CustomRoles.Virus) button = null; else if (role is CustomRoles.Coroner or CustomRoles.Occultist or CustomRoles.Vulture) button = __instance.ReportButton; diff --git a/Patches/HudSpritePatch.cs b/Patches/HudSpritePatch.cs index 90ccd984f..f930e90fa 100644 --- a/Patches/HudSpritePatch.cs +++ b/Patches/HudSpritePatch.cs @@ -134,7 +134,7 @@ public static class HudSpritePatch newAbilityButton = CustomButton.Get("Kill"); break; } - case CustomRoles.JudgeOld: + case CustomRoles.Prosecutor: { newAbilityButton = CustomButton.Get("JudgeIcon"); break; diff --git a/Patches/IntroPatch.cs b/Patches/IntroPatch.cs index 0d765dfb1..9ec19e4ce 100644 --- a/Patches/IntroPatch.cs +++ b/Patches/IntroPatch.cs @@ -814,7 +814,7 @@ internal static class BeginCrewmatePatch CustomRoles.Judge or CustomRoles.JudgeEHR - or CustomRoles.JudgeOld + or CustomRoles.Prosecutor => GetIntroSound(RoleTypes.Judge), CustomRoles.Phantom @@ -1400,7 +1400,6 @@ internal static class IntroCutsceneDestroyPatch LateTask.New(() => Main.Instance.StartCoroutine(Utils.NotifyEveryoneAsync()), 6f, "NotifyEveryoneAsync On Game Start"); LateTask.New(Utils.MarkEveryoneDirtySettings, 0.5f, "SyncAllSettings On Game Start"); LateTask.New(() => Main.Instance.StartCoroutine(ShipStatusFixedUpdatePatch.Postfix()), 5f, "ShipStatusFixedUpdatePatch Postfix Start"); - LateTask.New(() => Main.Instance.StartCoroutine(Utils.SendGameDataContinuously()), 10f, "SendGameDataContinuously Start"); Utils.CheckAndSetVentInteractions(); } diff --git a/Patches/MatchInfoGuidePatch.cs b/Patches/MatchInfoGuidePatch.cs new file mode 100644 index 000000000..602480761 --- /dev/null +++ b/Patches/MatchInfoGuidePatch.cs @@ -0,0 +1,143 @@ +using System.Globalization; +using AmongUs.GameOptions; +using HarmonyLib; +using TMPro; +using UnityEngine; + +namespace EHR.Patches; + +[HarmonyPatch] +public static class MatchInfoGuidePatch +{ + [HarmonyPatch(typeof(MatchInfoGuide), nameof(MatchInfoGuide.CreateNormalModeSettings)), HarmonyPrefix] + public static bool CreateModdedSettings(MatchInfoGuide __instance) + { + int num = 6; + (OptionItem MinSetting, OptionItem MaxSetting) impSettings = Options.FactionMinMaxSettings[Team.Impostor]; + __instance.CreateSettingsEntry(StringNames.GameNumImpostors, $"{impSettings.MinSetting.GetInt()}-{impSettings.MaxSetting.GetInt()}"); + __instance.CreateSettingsEntry(StringNames.GameKillCooldown, GameManager.Instance.AllGameSettingData[StringNames.GameKillCooldown].GetValueString(GameManager.Instance.LogicOptions.GetKillCooldown())); + __instance.CreateSettingsEntry(StringNames.GameEmergencyCooldown, GameManager.Instance.AllGameSettingData[StringNames.GameEmergencyCooldown].GetValueString(GameManager.Instance.LogicOptions.GetEmergencyCooldown())); + __instance.CreateSettingsEntry(StringNames.GameVisualTasks, __instance.GetBoolString(GameManager.Instance.LogicOptions.GetVisualTasks())); + __instance.CreateSettingsEntry(StringNames.GameAnonymousVotes, __instance.GetBoolString(GameManager.Instance.LogicOptions.GetAnonymousVotes())); + __instance.CreateSettingsEntry(StringNames.GameTaskBarMode, GameManager.Instance.LogicOptions.GetTaskBarMode().ToString()); + CreateModdedSettingEntries(Options.GroupedOptions[TabGroup.GameSettings], __instance, ref num); + CreateModdedSettingEntries(Options.GroupedOptions[TabGroup.TaskSettings], __instance, ref num); + __instance.transform.FindChild("MatchInfoParent").FindChild("SettingsPanel").GetComponentInChildren().SetYBoundsMax(Mathf.Clamp(Mathf.Ceil(num / 4f), 0.0f, 999f)); + num = CreateModdedRoleEntries(__instance); + if (num == 0) __instance.rolesEnabledMessage.SetActive(true); + __instance.MatchInfoRoleScroller.SetYBoundsMax(Mathf.Clamp(Mathf.Ceil(num / 2f) + __instance.RoleEntryBoundsModifier, 0.0f, 999f)); + __instance.MatchInfoRoleMaskArea.material.SetInt(PlayerMaterial.MaskLayer, 50); + __instance.matchInfoSettingsMaskArea.material.SetInt(PlayerMaterial.MaskLayer, 50); + __instance.CreatePlayerEntries(); + ReColorTabButtons(__instance); + return false; + } + + private static int CreateModdedRoleEntries(MatchInfoGuide __instance) + { + int num = 0; + + foreach (CustomRoles role in Main.CustomRoleValues) + { + if (!role.IsVanilla() && !role.IsForOtherGameMode() && role.IsEnable()) + { + CreateModdedRoleEntry(__instance, role); + ++num; + } + } + + return num; + } + + private static void CreateModdedSettingEntries(OptionItem[] settings, MatchInfoGuide __instance, ref int num) + { + foreach (OptionItem optionItem in settings) + { + if (optionItem.IsCurrentlyHidden(checkCollapsedSection: false) || optionItem.Parent != null || optionItem is PresetOptionItem or TextOptionItem) continue; + + string value = optionItem switch + { + BooleanOptionItem b => __instance.GetBoolString(b.GetBool()), + FloatOptionItem f => f.GetFloat().ToString(CultureInfo.CurrentCulture), + IntegerOptionItem i => i.GetInt().ToString(), + StringOptionItem s => s.noTranslation ? s.Selections[s.GetValue()] : Translator.GetString(s.Selections[s.GetValue()]), + _ => string.Empty + }; + + CreateModdedSettingEntry(__instance, optionItem.GetName(), value); + ++num; + } + } + + private static void CreateModdedSettingEntry(MatchInfoGuide __instance, string settingName, string value) + { + GameObject gameObject = Object.Instantiate(__instance.MatchInfoSettingPrefab, __instance.settingsScrollArea); + MatchInfoGuideSettingLabel component = gameObject.GetComponent(); + if (component != null) component.SetInfo(settingName, value); + __instance.NormalModeSettings.Add(gameObject); + } + + private static void CreateModdedRoleEntry(MatchInfoGuide __instance, CustomRoles role) + { + MatchInfoRolePanel matchInfoRolePanel = Object.Instantiate(__instance.MatchInfoRolePanelPrefab, __instance.settingsTabs[2].GetComponent().Inner); + matchInfoRolePanel.roleName.text = role.ToColoredString(); + matchInfoRolePanel.roleDescription.text = Translator.GetString($"{role}Info"); + matchInfoRolePanel.roleIcon.sprite = GetRoleBehaviourFromBasis(role).RoleIconColor; + int roleCount = role.GetCount(); + string roleChance = Translator.GetString(Options.Rates[role.GetMode() / 5]); + matchInfoRolePanel.roleCount.text = roleCount > 1 ? $"{roleCount}x {roleChance}" : roleChance; + matchInfoRolePanel.roleIcon.material.SetInt(PlayerMaterial.MaskLayer, 50); + matchInfoRolePanel.roleName.fontMaterial.SetFloat(matchInfoRolePanel.STENCIL_NAME, 50f); + matchInfoRolePanel.roleDescription.fontMaterial.SetFloat(matchInfoRolePanel.STENCIL_NAME, 50f); + matchInfoRolePanel.roleCount.fontMaterial.SetFloat(matchInfoRolePanel.STENCIL_NAME, 50f); + } + + private static RoleBehaviour GetRoleBehaviourFromBasis(CustomRoles role) + { + var roleBehaviours = RoleManager.Instance.AllRoles; + RoleTypes roleTypes = role.IsGhostRole() ? RoleTypes.GuardianAngel : role switch + { + CustomRoles.Aid or CustomRoles.Doctor or CustomRoles.Medic => RoleTypes.Scientist, + CustomRoles.Captain or CustomRoles.Catcher or CustomRoles.Coroner or CustomRoles.Druid or CustomRoles.EvilTracker or CustomRoles.Hacker or CustomRoles.Scout or CustomRoles.Lookout => RoleTypes.Tracker, + CustomRoles.Beehive or CustomRoles.Demon or CustomRoles.Pelican or CustomRoles.Scavenger or CustomRoles.Spider or CustomRoles.Vampire or CustomRoles.Vulture or CustomRoles.Wasp => RoleTypes.Viper, + CustomRoles.Markseeker or CustomRoles.Soothsayer or CustomRoles.Specter or CustomRoles.SuperStar or CustomRoles.Sunnyboy or CustomRoles.Vacuum => RoleTypes.Noisemaker, + CustomRoles.Prosecutor or CustomRoles.Mayor or CustomRoles.Dictator or CustomRoles.Swapper or CustomRoles.President => RoleTypes.Judge, + _ when role.IsCoven() => RoleTypes.Shapeshifter, + _ when role.IsCrewmate() && role.IsDesyncRole() => RoleTypes.Engineer, + _ when role.GetCrewmateRoleCategory() == RoleOptionType.Crewmate_Investigate => RoleTypes.Detective, + _ => role.GetRoleTypes() + }; + roleTypes = roleTypes switch + { + RoleTypes.Crewmate => RoleTypes.Engineer, + RoleTypes.CrewmateGhost => RoleTypes.GuardianAngel, + RoleTypes.Impostor => RoleTypes.Viper, + RoleTypes.ImpostorGhost => RoleTypes.GuardianAngel, + _ => roleTypes + }; + + foreach (RoleBehaviour roleBehaviour in roleBehaviours) + if (roleBehaviour.Role == roleTypes) + return roleBehaviour; + + return roleBehaviours[0]; + } + + private static void ReColorTabButtons(MatchInfoGuide __instance) + { + Color32 color = new Color32(0, 165, 255, 255); + string[] stateNames = ["Highlight", "Inactive", "Selected"]; + + foreach (MatchInfoGuideTabButton matchInfoGuideTabButton in __instance.TabButtons) + { + matchInfoGuideTabButton.GetComponentInChildren().color = Color.white; + + foreach (string stateName in stateNames) + { + var child = matchInfoGuideTabButton.transform.FindChild(stateName); + child.GetComponent().color = color; + if (child.childCount > 0) child.DestroyChildren(); + } + } + } +} \ No newline at end of file diff --git a/Patches/MeetingHudPatch.cs b/Patches/MeetingHudPatch.cs index 302395b43..ffe6910a5 100644 --- a/Patches/MeetingHudPatch.cs +++ b/Patches/MeetingHudPatch.cs @@ -1316,7 +1316,7 @@ internal static class MeetingHudUpdatePatch switch (myRole) { - case CustomRoles.NiceGuesser or CustomRoles.EvilGuesser or CustomRoles.JudgeOld or CustomRoles.Swapper or CustomRoles.Councillor or CustomRoles.Guesser when !PlayerControl.LocalPlayer.IsAlive(): + case CustomRoles.NiceGuesser or CustomRoles.EvilGuesser or CustomRoles.Prosecutor or CustomRoles.Swapper or CustomRoles.Councillor or CustomRoles.Guesser when !PlayerControl.LocalPlayer.IsAlive(): ClearShootButton(__instance, true); break; case CustomRoles.Nemesis when !PlayerControl.LocalPlayer.IsAlive() && !GameObject.Find("ShootButton"): @@ -1632,7 +1632,22 @@ internal static class MeetingHudHandleRpcPatch PlayerControl target = targetPlayerId.GetPlayer(); if (judge && target && judge.UsesJudgeAbilityAsTrigger() && Main.PlayerStates.TryGetValue(judgePlayerId, out PlayerState state)) - return !state.Role.OnJudge(judge, target); + { + state.Role.OnJudge(judge, target); + + var meetingHud = MeetingHud.Instance; + + if (meetingHud && meetingHud.playerStates.FindFirst(x => x.PlayerId == judgePlayerId, out PlayerVoteArea pva)) + { + pva.UnsetVote(); + meetingHud.RpcClearVote(pva.PlayerId); + meetingHud.UpdateForeground(); + pva.VotedForId = byte.MaxValue; + } + + return false; + } + break; } case (byte)RpcCalls.CloseMeeting when AmongUsClient.Instance.AmHost: diff --git a/Resources/Lang/en_US.json b/Resources/Lang/en_US.json index 3b307fbb7..43a5f821a 100644 --- a/Resources/Lang/en_US.json +++ b/Resources/Lang/en_US.json @@ -993,9 +993,9 @@ "JournalistError.IndexOutOfRange": "You didn't provide enough arguments.", "JournalistError.InvalidArgument": "Invalid argument. Use /cmd note {add/remove/clear/view} [value]", "JournalistError.Unknown": "An unknown error occurred.", - "JudgeOld": "Judge", - "JudgeOldInfo": "Silence in the courtroom!", - "JudgeOldInfoLong": "(Crewmates):\\nThe Judge can judge a player during the meeting. If the target is evil, it's killed; if it's wrong, the Judge dies. Use the /cmd tl [player id] command to judge and /cmd id to view player IDs. Judges can judge all players when they're Madmate.", + "Prosecutor": "Judge", + "ProsecutorInfo": "Silence in the courtroom!", + "ProsecutorInfoLong": "(Crewmates):\\nThe Judge can judge a player during the meeting. If the target is evil, it's killed; if it's wrong, the Judge dies. Use the /cmd tl [player id] command to judge and /cmd id to view player IDs. Judges can judge all players when they're Madmate.", "JudgeCanBeMadmate": "Judge can become Madmate", "JudgeCanTrialContagious": "Can trial Contagious", "JudgeCanTrialConverted": "Can trial <#ffab1b>Converted players", diff --git a/Roles/Standard/Coven/Empress.cs b/Roles/Standard/Coven/Empress.cs index 1eb3e7095..77371c93a 100644 --- a/Roles/Standard/Coven/Empress.cs +++ b/Roles/Standard/Coven/Empress.cs @@ -111,6 +111,7 @@ public class Empress : CovenBase public override void OnMeetingShapeshift(PlayerControl shapeshifter, PlayerControl target) { + if (Starspawn.IsDayBreak) return; Empower(shapeshifter); } diff --git a/Roles/Standard/Crewmate/Investigate/Analyst.cs b/Roles/Standard/Crewmate/Investigate/Analyst.cs index 9b435cde0..f98d275fe 100644 --- a/Roles/Standard/Crewmate/Investigate/Analyst.cs +++ b/Roles/Standard/Crewmate/Investigate/Analyst.cs @@ -83,7 +83,7 @@ internal class Analyst : RoleBase CustomRoles.Noisemaker or CustomRoles.NoisemakerEHR => CustomRoles.Bubble.ColoredTextByRole(GetString("Noisemaker")), CustomRoles.Tracker or CustomRoles.TrackerEHR => CustomRoles.Scout.ColoredTextByRole(GetString("Tracker")), CustomRoles.Detective or CustomRoles.DetectiveEHR => CustomRoles.Forensic.ColoredTextByRole(GetString("Detective")), - CustomRoles.Judge or CustomRoles.JudgeEHR => CustomRoles.JudgeOld.ColoredTextByRole(GetString("Judge")), + CustomRoles.Judge or CustomRoles.JudgeEHR => CustomRoles.Prosecutor.ColoredTextByRole(GetString("Judge")), _ => string.Empty } : string.Empty; diff --git a/Roles/Standard/Crewmate/Investigate/Captain.cs b/Roles/Standard/Crewmate/Investigate/Captain.cs index bd925b012..aba05566b 100644 --- a/Roles/Standard/Crewmate/Investigate/Captain.cs +++ b/Roles/Standard/Crewmate/Investigate/Captain.cs @@ -53,7 +53,7 @@ public class Captain : RoleBase public override void OnMeetingShapeshift(PlayerControl shapeshifter, PlayerControl target) { - OnVote(shapeshifter, target); + OnJudge(shapeshifter, target); } public override void OnGlobalFixedUpdate(PlayerControl pc, bool lowLoad) diff --git a/Roles/Standard/Crewmate/Investigate/FortuneTeller.cs b/Roles/Standard/Crewmate/Investigate/FortuneTeller.cs index 93adabdbd..3e5bf5899 100644 --- a/Roles/Standard/Crewmate/Investigate/FortuneTeller.cs +++ b/Roles/Standard/Crewmate/Investigate/FortuneTeller.cs @@ -134,7 +134,7 @@ public class FortuneTeller : RoleBase public override void OnMeetingShapeshift(PlayerControl shapeshifter, PlayerControl target) { - OnVote(shapeshifter, target); + OnJudge(shapeshifter, target); } public static void OnRoleChange(byte id, CustomRoles previousRole, CustomRoles newRole) diff --git a/Roles/Standard/Crewmate/Investigate/Inquisitor.cs b/Roles/Standard/Crewmate/Investigate/Inquisitor.cs index 78be710e2..1c0096b67 100644 --- a/Roles/Standard/Crewmate/Investigate/Inquisitor.cs +++ b/Roles/Standard/Crewmate/Investigate/Inquisitor.cs @@ -68,6 +68,6 @@ public class Inquisitor : RoleBase public override void OnMeetingShapeshift(PlayerControl shapeshifter, PlayerControl target) { - OnVote(shapeshifter, target); + OnJudge(shapeshifter, target); } } \ No newline at end of file diff --git a/Roles/Standard/Crewmate/Investigate/Inspector.cs b/Roles/Standard/Crewmate/Investigate/Inspector.cs index 2b0797644..de45b8167 100644 --- a/Roles/Standard/Crewmate/Investigate/Inspector.cs +++ b/Roles/Standard/Crewmate/Investigate/Inspector.cs @@ -368,6 +368,13 @@ public class Inspector : RoleBase return true; } + public override bool OnJudge(PlayerControl pc, PlayerControl target) + { + if (Starspawn.IsDayBreak) return false; + PickForCompare(target.PlayerId, pc.PlayerId); + return true; + } + public override void OnMeetingShapeshift(PlayerControl shapeshifter, PlayerControl target) { if (Starspawn.IsDayBreak) return; diff --git a/Roles/Standard/Crewmate/Investigate/Markseeker.cs b/Roles/Standard/Crewmate/Investigate/Markseeker.cs index 3513035ee..d16964ccc 100644 --- a/Roles/Standard/Crewmate/Investigate/Markseeker.cs +++ b/Roles/Standard/Crewmate/Investigate/Markseeker.cs @@ -44,24 +44,18 @@ internal class Markseeker : RoleBase { MarkedId = reader.ReadByte(); } - -/* + public override bool OnJudge(PlayerControl player, PlayerControl target) { - if (Starspawn.IsDayBreak) return false; - if (player == null || target == null || player.PlayerId == target.PlayerId || MarkedId != byte.MaxValue || Main.DontCancelVoteList.Contains(player.PlayerId)) return false; - - MarkedId = target.PlayerId; - - Main.DontCancelVoteList.Add(player.PlayerId); + if (Starspawn.IsDayBreak || !player || !target) return false; + var command = $"/mark {target.PlayerId}"; + ChatCommands.MarkCommand(player, command, command.Split(' ')); return true; } -*/ public override void OnMeetingShapeshift(PlayerControl shapeshifter, PlayerControl target) { - var command = $"/mark {target.PlayerId}"; - ChatCommands.MarkCommand(shapeshifter, command, command.Split(' ')); + OnJudge(shapeshifter, target); } public static void OnDeath(PlayerControl player) diff --git a/Roles/Standard/Crewmate/Investigate/MeetingManager.cs b/Roles/Standard/Crewmate/Investigate/MeetingManager.cs index ae7547ecb..6c3d6d839 100644 --- a/Roles/Standard/Crewmate/Investigate/MeetingManager.cs +++ b/Roles/Standard/Crewmate/Investigate/MeetingManager.cs @@ -48,7 +48,7 @@ public class MeetingManager : RoleBase { if (PlayerIdList == null) return; foreach (byte id in PlayerIdList) - LateTask.New(() => Utils.SendMessage(dp == pc ? string.Format(GetString("MeetingManagerMessageAboutJudgeSuicide"), dp.GetRealName().Replace("\n", " + "), CustomRoles.JudgeOld.ToColoredString()) : string.Format(GetString("MeetingManagerMessageAboutGuessedRole"), dp.GetAllRoleName().Replace("\n", " + ")), id, CustomRoles.MeetingManager.ColoredTextByRole(GetString("MeetingManagerMessageTitle")), importance: MessageImportance.High), 1f, "Meeting Manager Messages"); + LateTask.New(() => Utils.SendMessage(dp == pc ? string.Format(GetString("MeetingManagerMessageAboutJudgeSuicide"), dp.GetRealName().Replace("\n", " + "), CustomRoles.Prosecutor.ToColoredString()) : string.Format(GetString("MeetingManagerMessageAboutGuessedRole"), dp.GetAllRoleName().Replace("\n", " + ")), id, CustomRoles.MeetingManager.ColoredTextByRole(GetString("MeetingManagerMessageTitle")), importance: MessageImportance.High), 1f, "Meeting Manager Messages"); } public static void OnSwap(PlayerControl tg1, PlayerControl tg2) diff --git a/Roles/Standard/Crewmate/Investigate/Oracle.cs b/Roles/Standard/Crewmate/Investigate/Oracle.cs index 22005b337..1bd6dedf5 100644 --- a/Roles/Standard/Crewmate/Investigate/Oracle.cs +++ b/Roles/Standard/Crewmate/Investigate/Oracle.cs @@ -95,6 +95,6 @@ public class Oracle : RoleBase public override void OnMeetingShapeshift(PlayerControl shapeshifter, PlayerControl target) { - OnVote(shapeshifter, target); + OnJudge(shapeshifter, target); } } \ No newline at end of file diff --git a/Roles/Standard/Crewmate/Investigate/Scout.cs b/Roles/Standard/Crewmate/Investigate/Scout.cs index ee564a64f..d806871b7 100644 --- a/Roles/Standard/Crewmate/Investigate/Scout.cs +++ b/Roles/Standard/Crewmate/Investigate/Scout.cs @@ -115,7 +115,7 @@ public class Scout : RoleBase public override void OnMeetingShapeshift(PlayerControl shapeshifter, PlayerControl target) { - OnVote(shapeshifter, target); + OnJudge(shapeshifter, target); } public override string GetSuffix(PlayerControl seer, PlayerControl target, bool hud = false, bool meeting = false) diff --git a/Roles/Standard/Crewmate/Investigate/Socialite.cs b/Roles/Standard/Crewmate/Investigate/Socialite.cs index 904a8cb27..a1cbcd8ac 100644 --- a/Roles/Standard/Crewmate/Investigate/Socialite.cs +++ b/Roles/Standard/Crewmate/Investigate/Socialite.cs @@ -119,7 +119,7 @@ public class Socialite : RoleBase public override void OnMeetingShapeshift(PlayerControl shapeshifter, PlayerControl target) { - OnVote(shapeshifter, target); + OnJudge(shapeshifter, target); } public void ReceiveRPC(MessageReader reader) diff --git a/Roles/Standard/Crewmate/Investigate/Soothsayer.cs b/Roles/Standard/Crewmate/Investigate/Soothsayer.cs index be0ce4b41..0dc39b3b9 100644 --- a/Roles/Standard/Crewmate/Investigate/Soothsayer.cs +++ b/Roles/Standard/Crewmate/Investigate/Soothsayer.cs @@ -55,7 +55,7 @@ public class Soothsayer : RoleBase public override void OnMeetingShapeshift(PlayerControl shapeshifter, PlayerControl target) { - OnVote(shapeshifter, target); + OnJudge(shapeshifter, target); } public static void OnAnyoneDeath(PlayerControl killer) diff --git a/Roles/Standard/Crewmate/Killing/Judge.cs b/Roles/Standard/Crewmate/Killing/Judge.cs index c0efa04bf..45fb865ff 100644 --- a/Roles/Standard/Crewmate/Killing/Judge.cs +++ b/Roles/Standard/Crewmate/Killing/Judge.cs @@ -34,19 +34,19 @@ public class Judge : RoleBase public override void SetupCustomOption() { - Options.SetupRoleOptions(Id, TabGroup.CrewmateRoles, CustomRoles.JudgeOld); - TrialLimitPerMeeting = new FloatOptionItem(Id + 10, "TrialLimitPerMeeting", new(0f, 15f, 1f), 1f, TabGroup.CrewmateRoles).SetParent(Options.CustomRoleSpawnChances[CustomRoles.JudgeOld]).SetValueFormat(OptionFormat.Times); - TrialLimitPerGame = new FloatOptionItem(Id + 9, "TrialLimitPerGame", new(0f, 30f, 1f), 3f, TabGroup.CrewmateRoles).SetParent(Options.CustomRoleSpawnChances[CustomRoles.JudgeOld]).SetValueFormat(OptionFormat.Times); - AbilityUseLimit = new FloatOptionItem(Id + 18, "AbilityUseLimit", new(0f, 30f, 0.5f), 1f, TabGroup.CrewmateRoles).SetParent(Options.CustomRoleSpawnChances[CustomRoles.JudgeOld]).SetValueFormat(OptionFormat.Times); - CanTrialMadmate = new BooleanOptionItem(Id + 12, "JudgeCanTrialMadmate", true, TabGroup.CrewmateRoles).SetParent(Options.CustomRoleSpawnChances[CustomRoles.JudgeOld]); - CanTrialConverted = new BooleanOptionItem(Id + 16, "JudgeCanTrialConverted", true, TabGroup.CrewmateRoles).SetParent(Options.CustomRoleSpawnChances[CustomRoles.JudgeOld]); - CanTrialCrewKilling = new BooleanOptionItem(Id + 13, "JudgeCanTrialnCrewKilling", false, TabGroup.CrewmateRoles).SetParent(Options.CustomRoleSpawnChances[CustomRoles.JudgeOld]); - CanTrialNeutralB = new BooleanOptionItem(Id + 14, "JudgeCanTrialNeutralB", false, TabGroup.CrewmateRoles).SetParent(Options.CustomRoleSpawnChances[CustomRoles.JudgeOld]); - CanTrialNeutralE = new BooleanOptionItem(Id + 17, "JudgeCanTrialNeutralE", false, TabGroup.CrewmateRoles).SetParent(Options.CustomRoleSpawnChances[CustomRoles.JudgeOld]); - CanTrialNeutralK = new BooleanOptionItem(Id + 15, "JudgeCanTrialNeutralK", true, TabGroup.CrewmateRoles).SetParent(Options.CustomRoleSpawnChances[CustomRoles.JudgeOld]); - CanTrialCoven = new BooleanOptionItem(Id + 21, "JudgeCanTrialCoven", true, TabGroup.CrewmateRoles).SetParent(Options.CustomRoleSpawnChances[CustomRoles.JudgeOld]); - JudgeAbilityUseGainWithEachTaskCompleted = new FloatOptionItem(Id + 19, "AbilityUseGainWithEachTaskCompleted", new(0f, 5f, 0.05f), 0.3f, TabGroup.CrewmateRoles).SetParent(Options.CustomRoleSpawnChances[CustomRoles.JudgeOld]).SetValueFormat(OptionFormat.Times); - AbilityChargesWhenFinishedTasks = new FloatOptionItem(Id + 20, "AbilityChargesWhenFinishedTasks", new(0f, 5f, 0.05f), 0.2f, TabGroup.CrewmateRoles).SetParent(Options.CustomRoleSpawnChances[CustomRoles.JudgeOld]).SetValueFormat(OptionFormat.Times); + Options.SetupRoleOptions(Id, TabGroup.CrewmateRoles, CustomRoles.Prosecutor); + TrialLimitPerMeeting = new FloatOptionItem(Id + 10, "TrialLimitPerMeeting", new(0f, 15f, 1f), 1f, TabGroup.CrewmateRoles).SetParent(Options.CustomRoleSpawnChances[CustomRoles.Prosecutor]).SetValueFormat(OptionFormat.Times); + TrialLimitPerGame = new FloatOptionItem(Id + 9, "TrialLimitPerGame", new(0f, 30f, 1f), 3f, TabGroup.CrewmateRoles).SetParent(Options.CustomRoleSpawnChances[CustomRoles.Prosecutor]).SetValueFormat(OptionFormat.Times); + AbilityUseLimit = new FloatOptionItem(Id + 18, "AbilityUseLimit", new(0f, 30f, 0.5f), 1f, TabGroup.CrewmateRoles).SetParent(Options.CustomRoleSpawnChances[CustomRoles.Prosecutor]).SetValueFormat(OptionFormat.Times); + CanTrialMadmate = new BooleanOptionItem(Id + 12, "JudgeCanTrialMadmate", true, TabGroup.CrewmateRoles).SetParent(Options.CustomRoleSpawnChances[CustomRoles.Prosecutor]); + CanTrialConverted = new BooleanOptionItem(Id + 16, "JudgeCanTrialConverted", true, TabGroup.CrewmateRoles).SetParent(Options.CustomRoleSpawnChances[CustomRoles.Prosecutor]); + CanTrialCrewKilling = new BooleanOptionItem(Id + 13, "JudgeCanTrialnCrewKilling", false, TabGroup.CrewmateRoles).SetParent(Options.CustomRoleSpawnChances[CustomRoles.Prosecutor]); + CanTrialNeutralB = new BooleanOptionItem(Id + 14, "JudgeCanTrialNeutralB", false, TabGroup.CrewmateRoles).SetParent(Options.CustomRoleSpawnChances[CustomRoles.Prosecutor]); + CanTrialNeutralE = new BooleanOptionItem(Id + 17, "JudgeCanTrialNeutralE", false, TabGroup.CrewmateRoles).SetParent(Options.CustomRoleSpawnChances[CustomRoles.Prosecutor]); + CanTrialNeutralK = new BooleanOptionItem(Id + 15, "JudgeCanTrialNeutralK", true, TabGroup.CrewmateRoles).SetParent(Options.CustomRoleSpawnChances[CustomRoles.Prosecutor]); + CanTrialCoven = new BooleanOptionItem(Id + 21, "JudgeCanTrialCoven", true, TabGroup.CrewmateRoles).SetParent(Options.CustomRoleSpawnChances[CustomRoles.Prosecutor]); + JudgeAbilityUseGainWithEachTaskCompleted = new FloatOptionItem(Id + 19, "AbilityUseGainWithEachTaskCompleted", new(0f, 5f, 0.05f), 0.3f, TabGroup.CrewmateRoles).SetParent(Options.CustomRoleSpawnChances[CustomRoles.Prosecutor]).SetValueFormat(OptionFormat.Times); + AbilityChargesWhenFinishedTasks = new FloatOptionItem(Id + 20, "AbilityChargesWhenFinishedTasks", new(0f, 5f, 0.05f), 0.2f, TabGroup.CrewmateRoles).SetParent(Options.CustomRoleSpawnChances[CustomRoles.Prosecutor]).SetValueFormat(OptionFormat.Times); } public override void Init() @@ -77,7 +77,7 @@ public class Judge : RoleBase public static bool TrialMsg(PlayerControl pc, string msg, bool isUI = false) { - if (!AmongUsClient.Instance.AmHost || !GameStates.IsInGame || !pc || !pc.Is(CustomRoles.JudgeOld)) return false; + if (!AmongUsClient.Instance.AmHost || !GameStates.IsInGame || !pc || !pc.Is(CustomRoles.Prosecutor)) return false; int operate; // 1:ID 2:Trial msg = msg.ToLower().TrimStart().TrimEnd(); @@ -187,7 +187,7 @@ public class Judge : RoleBase MeetingManager.OnTrial(dp, pc); Utils.AfterPlayerDeathTasks(dp, true); - LateTask.New(() => Utils.SendMessage(string.Format(GetString("TrialKill"), name), 255, CustomRoles.JudgeOld.ColoredTextByRole(GetString("TrialKillTitle")), importance: MessageImportance.High), 0.6f, "Guess Msg"); + LateTask.New(() => Utils.SendMessage(string.Format(GetString("TrialKill"), name), 255, CustomRoles.Prosecutor.ColoredTextByRole(GetString("TrialKillTitle")), importance: MessageImportance.High), 0.6f, "Guess Msg"); }, 0.2f, "Trial Kill"); } @@ -228,10 +228,16 @@ public class Judge : RoleBase return true; } + public override bool OnJudge(PlayerControl pc, PlayerControl target) + { + if (Starspawn.IsDayBreak) return false; + TrialMsg(pc, $"/tl {target.PlayerId}"); + return true; + } + public override void OnMeetingShapeshift(PlayerControl shapeshifter, PlayerControl target) { - if (Starspawn.IsDayBreak) return; - TrialMsg(shapeshifter, $"/tl {target.PlayerId}"); + OnJudge(shapeshifter, target); } private static void SendRPC(byte playerId) @@ -283,7 +289,7 @@ public class Judge : RoleBase { public static void Postfix(MeetingHud __instance) { - if (PlayerControl.LocalPlayer.Is(CustomRoles.JudgeOld) && PlayerControl.LocalPlayer.IsAlive()) + if (PlayerControl.LocalPlayer.Is(CustomRoles.Prosecutor) && PlayerControl.LocalPlayer.IsAlive()) CreateJudgeButton(__instance); } } diff --git a/Roles/Standard/Crewmate/Killing/Retributionist.cs b/Roles/Standard/Crewmate/Killing/Retributionist.cs index 8a97b0b65..3d1f371c1 100644 --- a/Roles/Standard/Crewmate/Killing/Retributionist.cs +++ b/Roles/Standard/Crewmate/Killing/Retributionist.cs @@ -57,11 +57,11 @@ public class Retributionist : RoleBase public override void AfterMeetingTasks() { - if (RetributionistPC == null || !RetributionistPC.IsAlive() || CanUseKillButton(RetributionistPC)) return; + if (!RetributionistPC || !RetributionistPC.IsAlive() || CanUseKillButton(RetributionistPC)) return; PlayerControl campTarget = Camping.GetPlayer(); - if (ResetCampedPlayerAfterEveryMeeting.GetBool() || campTarget == null || !campTarget.IsAlive()) + if (ResetCampedPlayerAfterEveryMeeting.GetBool() || !campTarget || !campTarget.IsAlive()) { Notified = false; Camping = byte.MaxValue; @@ -104,10 +104,17 @@ public class Retributionist : RoleBase } } + public override bool OnJudge(PlayerControl pc, PlayerControl target) + { + if (Starspawn.IsDayBreak) return false; + var command = $"/retribute {target.PlayerId}"; + ChatCommands.RetributeCommand(pc, command, command.Split(' ')); + return true; + } + public override void OnMeetingShapeshift(PlayerControl shapeshifter, PlayerControl target) { - var command = $"/retribute {target.PlayerId}"; - ChatCommands.RetributeCommand(shapeshifter, command, command.Split(' ')); + OnJudge(shapeshifter, target); } public void ReceiveRPC(MessageReader reader) diff --git a/Roles/Standard/Crewmate/Miscellaneous/Ricochet.cs b/Roles/Standard/Crewmate/Miscellaneous/Ricochet.cs index 38bc1fcc0..aab260e31 100644 --- a/Roles/Standard/Crewmate/Miscellaneous/Ricochet.cs +++ b/Roles/Standard/Crewmate/Miscellaneous/Ricochet.cs @@ -111,7 +111,7 @@ public class Ricochet : RoleBase public override void OnMeetingShapeshift(PlayerControl shapeshifter, PlayerControl target) { - OnVote(shapeshifter, target); + OnJudge(shapeshifter, target); } public override void OnReportDeadBody() diff --git a/Roles/Standard/Crewmate/Miscellaneous/Tether.cs b/Roles/Standard/Crewmate/Miscellaneous/Tether.cs index c387491c2..9a6af9ce4 100644 --- a/Roles/Standard/Crewmate/Miscellaneous/Tether.cs +++ b/Roles/Standard/Crewmate/Miscellaneous/Tether.cs @@ -133,7 +133,7 @@ public class Tether : RoleBase public override void OnMeetingShapeshift(PlayerControl shapeshifter, PlayerControl target) { - OnVote(shapeshifter, target); + OnJudge(shapeshifter, target); } public override void OnReportDeadBody() diff --git a/Roles/Standard/Crewmate/Power/CopyCat.cs b/Roles/Standard/Crewmate/Power/CopyCat.cs index c3469918c..af5f5f715 100644 --- a/Roles/Standard/Crewmate/Power/CopyCat.cs +++ b/Roles/Standard/Crewmate/Power/CopyCat.cs @@ -135,7 +135,7 @@ public class CopyCat : RoleBase CustomRoles.Workaholic or CustomRoles.Pawn => CustomRoles.Snitch, CustomRoles.Sunnyboy or CustomRoles.Fabricator => new[] {CustomRoles.Doctor, CustomRoles.ScientistEHR}.RandomElement(), CustomRoles.Vindicator or CustomRoles.Pickpocket => CustomRoles.Mayor, - CustomRoles.Councillor or CustomRoles.Magistrate => CustomRoles.JudgeOld, + CustomRoles.Councillor or CustomRoles.Magistrate => CustomRoles.Prosecutor, CustomRoles.EvilGuesser or CustomRoles.Doomsayer or CustomRoles.NecroGuesser or CustomRoles.Augur => CustomRoles.NiceGuesser, CustomRoles.Vengeance => CustomRoles.Adrenaline, CustomRoles.Occultist => CustomRoles.Altruist, diff --git a/Roles/Standard/Crewmate/Power/NiceEraser.cs b/Roles/Standard/Crewmate/Power/NiceEraser.cs index 7094fb0ba..efa6f7552 100644 --- a/Roles/Standard/Crewmate/Power/NiceEraser.cs +++ b/Roles/Standard/Crewmate/Power/NiceEraser.cs @@ -96,7 +96,7 @@ internal class NiceEraser : RoleBase public override void OnMeetingShapeshift(PlayerControl shapeshifter, PlayerControl target) { - OnVote(shapeshifter, target); + OnJudge(shapeshifter, target); } public override void OnReportDeadBody() diff --git a/Roles/Standard/Crewmate/Power/President.cs b/Roles/Standard/Crewmate/Power/President.cs index 380509f86..d4a92a255 100644 --- a/Roles/Standard/Crewmate/Power/President.cs +++ b/Roles/Standard/Crewmate/Power/President.cs @@ -263,7 +263,7 @@ public class President : RoleBase public override void OnMeetingShapeshift(PlayerControl shapeshifter, PlayerControl target) { - OnVote(shapeshifter, target); + OnJudge(shapeshifter, target); } public void ReceiveRPC(MessageReader reader) diff --git a/Roles/Standard/Crewmate/Power/Swapper.cs b/Roles/Standard/Crewmate/Power/Swapper.cs index d6ddaa776..325f81021 100644 --- a/Roles/Standard/Crewmate/Power/Swapper.cs +++ b/Roles/Standard/Crewmate/Power/Swapper.cs @@ -220,6 +220,13 @@ public class Swapper : RoleBase catch (Exception e) { Utils.ThrowException(e); } } + public override bool OnJudge(PlayerControl voter, PlayerControl target) + { + if (Starspawn.IsDayBreak) return false; + SwapMsg(voter, $"/sw {target.PlayerId}"); + return true; + } + public override void OnMeetingShapeshift(PlayerControl shapeshifter, PlayerControl target) { if (Starspawn.IsDayBreak) return; diff --git a/Roles/Standard/Crewmate/Support/Cleanser.cs b/Roles/Standard/Crewmate/Support/Cleanser.cs index c223cb0e4..3f1d39a81 100644 --- a/Roles/Standard/Crewmate/Support/Cleanser.cs +++ b/Roles/Standard/Crewmate/Support/Cleanser.cs @@ -118,7 +118,7 @@ public class Cleanser : RoleBase public override void OnMeetingShapeshift(PlayerControl shapeshifter, PlayerControl target) { - OnVote(shapeshifter, target); + OnJudge(shapeshifter, target); } public override void AfterMeetingTasks() diff --git a/Roles/Standard/Crewmate/Support/Negotiator.cs b/Roles/Standard/Crewmate/Support/Negotiator.cs index bd29e2059..b71db05a6 100644 --- a/Roles/Standard/Crewmate/Support/Negotiator.cs +++ b/Roles/Standard/Crewmate/Support/Negotiator.cs @@ -144,7 +144,7 @@ public class Negotiator : RoleBase public override void OnMeetingShapeshift(PlayerControl shapeshifter, PlayerControl target) { - OnVote(shapeshifter, target); + OnJudge(shapeshifter, target); } public static void ReceiveCommand(PlayerControl pc, int index) diff --git a/Roles/Standard/Impostor/Killing/Councillor.cs b/Roles/Standard/Impostor/Killing/Councillor.cs index 459812c6c..6608cd926 100644 --- a/Roles/Standard/Impostor/Killing/Councillor.cs +++ b/Roles/Standard/Impostor/Killing/Councillor.cs @@ -206,7 +206,7 @@ public class Councillor : RoleBase LateTask.New(() => { if (!MakeEvilJudgeClear.GetBool()) - Utils.SendMessage(string.Format(GetString("TrialKill"), name), 255, CustomRoles.JudgeOld.ColoredTextByRole(GetString("TrialKillTitle")), importance: MessageImportance.High); + Utils.SendMessage(string.Format(GetString("TrialKill"), name), 255, CustomRoles.Prosecutor.ColoredTextByRole(GetString("TrialKillTitle")), importance: MessageImportance.High); else Utils.SendMessage(string.Format(GetString("MurderKill"), name), 255, CustomRoles.Councillor.ColoredTextByRole(GetString("MurderKillTitle")), importance: MessageImportance.High); }, 0.6f, "Guess Msg"); @@ -256,10 +256,16 @@ public class Councillor : RoleBase Main.AllPlayerKillCooldown[id] = KillCooldown.GetFloat(); } + public override bool OnJudge(PlayerControl pc, PlayerControl target) + { + if (Starspawn.IsDayBreak) return false; + MurderMsg(pc, $"/tl {target.PlayerId}"); + return true; + } + public override void OnMeetingShapeshift(PlayerControl shapeshifter, PlayerControl target) { - if (Starspawn.IsDayBreak) return; - MurderMsg(shapeshifter, $"/tl {target.PlayerId}"); + OnJudge(shapeshifter, target); } private static void SendRPC(byte playerId) diff --git a/Roles/Standard/Impostor/Miscellaneous/Exorcist.cs b/Roles/Standard/Impostor/Miscellaneous/Exorcist.cs index 5a8d81c8c..fe7b0d078 100644 --- a/Roles/Standard/Impostor/Miscellaneous/Exorcist.cs +++ b/Roles/Standard/Impostor/Miscellaneous/Exorcist.cs @@ -36,10 +36,17 @@ public class Exorcist : RoleBase playerId.SetAbilityUseLimit(AbilityUseLimit.GetFloat()); } + public override bool OnJudge(PlayerControl pc, PlayerControl target) + { + if (Starspawn.IsDayBreak) return false; + const string command = "/exo"; + ChatCommands.ExoCommand(pc, command, command.Split(' ')); + return true; + } + public override void OnMeetingShapeshift(PlayerControl shapeshifter, PlayerControl target) { - const string command = "/exo"; - ChatCommands.ExoCommand(shapeshifter, command, command.Split(' ')); + OnJudge(shapeshifter, target); } private static void ExorcistOnClick(GameObject exorcistButton) diff --git a/Roles/Standard/Impostor/Miscellaneous/Loner.cs b/Roles/Standard/Impostor/Miscellaneous/Loner.cs index 073430529..9d14e13b9 100644 --- a/Roles/Standard/Impostor/Miscellaneous/Loner.cs +++ b/Roles/Standard/Impostor/Miscellaneous/Loner.cs @@ -34,23 +34,29 @@ public class Loner : RoleBase Done = false; } - public override void OnMeetingShapeshift(PlayerControl shapeshifter, PlayerControl target) + public override bool OnJudge(PlayerControl pc, PlayerControl target) { - if (Starspawn.IsDayBreak) return; - if (shapeshifter == null || target == null || shapeshifter.PlayerId == target.PlayerId || Done) return; + if (Starspawn.IsDayBreak) return false; + if (pc == null || target == null || pc.PlayerId == target.PlayerId || Done) return false; PickedPlayer = target.PlayerId; PickedRole = Main.CustomRoleValues.Where(x => x.IsImpostor() && !x.IsVanilla() && !CustomRoleSelector.RoleResult.ContainsValue(x) && x.GetMode() != 0).RandomElement(); if (PickedRole == CustomRoles.Crewmate) PickedRole = CustomRoles.ImpostorEHR; - Utils.SendMessage("\n", shapeshifter.PlayerId, string.Format(Translator.GetString("Loner.Picked"), PickedPlayer.ColoredPlayerName(), PickedRole.ToColoredString()), importance: MessageImportance.High); + Utils.SendMessage("\n", pc.PlayerId, string.Format(GetString("Loner.Picked"), PickedPlayer.ColoredPlayerName(), PickedRole.ToColoredString()), importance: MessageImportance.High); + return true; + } + + public override void OnMeetingShapeshift(PlayerControl shapeshifter, PlayerControl target) + { + OnJudge(shapeshifter, target); } public override void AfterMeetingTasks() { var pc = PickedPlayer.GetPlayer(); - if (!Done && PickedPlayer != byte.MaxValue && PickedRole != CustomRoles.Crewmate && pc != null) + if (!Done && PickedPlayer != byte.MaxValue && PickedRole != CustomRoles.Crewmate && pc) { Done = true; pc.RpcSetCustomRole(PickedRole); diff --git a/Roles/Standard/Impostor/Support/EvilEraser.cs b/Roles/Standard/Impostor/Support/EvilEraser.cs index 92065c5d0..428c67fa3 100644 --- a/Roles/Standard/Impostor/Support/EvilEraser.cs +++ b/Roles/Standard/Impostor/Support/EvilEraser.cs @@ -135,7 +135,7 @@ internal class EvilEraser : RoleBase public override void OnMeetingShapeshift(PlayerControl shapeshifter, PlayerControl target) { - OnVote(shapeshifter, target); + OnJudge(shapeshifter, target); } public override void OnReportDeadBody() diff --git a/Roles/Standard/Impostor/Support/Gangster.cs b/Roles/Standard/Impostor/Support/Gangster.cs index 684c94b79..7cf76138e 100644 --- a/Roles/Standard/Impostor/Support/Gangster.cs +++ b/Roles/Standard/Impostor/Support/Gangster.cs @@ -121,7 +121,7 @@ public class Gangster : RoleBase (pc.Is(CustomRoles.Sheriff) && !SheriffCanBeMadmate.GetBool()) || (pc.Is(CustomRoles.Mayor) && !MayorCanBeMadmate.GetBool()) || (pc.Is(CustomRoles.NiceGuesser) && !NGuesserCanBeMadmate.GetBool()) || - (pc.Is(CustomRoles.JudgeOld) && !JudgeCanBeMadmate.GetBool()) || + (pc.Is(CustomRoles.Prosecutor) && !JudgeCanBeMadmate.GetBool()) || (pc.Is(CustomRoles.Marshall) && !MarshallCanBeMadmate.GetBool()) || (pc.Is(CustomRoles.Investigator) && !InvestigatorCanBeMadmate.GetBool()) || (pc.Is(CustomRoles.President) && !PresidentCanBeMadmate.GetBool()) || diff --git a/Roles/Standard/Impostor/Support/Godfather.cs b/Roles/Standard/Impostor/Support/Godfather.cs index b413b5748..1a372087e 100644 --- a/Roles/Standard/Impostor/Support/Godfather.cs +++ b/Roles/Standard/Impostor/Support/Godfather.cs @@ -34,6 +34,6 @@ internal class Godfather : RoleBase public override void OnMeetingShapeshift(PlayerControl shapeshifter, PlayerControl target) { - OnVote(shapeshifter, target); + OnJudge(shapeshifter, target); } } \ No newline at end of file diff --git a/Roles/Standard/Impostor/Support/Ventriloquist.cs b/Roles/Standard/Impostor/Support/Ventriloquist.cs index a3ee7a51b..fd124d372 100644 --- a/Roles/Standard/Impostor/Support/Ventriloquist.cs +++ b/Roles/Standard/Impostor/Support/Ventriloquist.cs @@ -38,10 +38,17 @@ public class Ventriloquist : RoleBase playerId.SetAbilityUseLimit(UseLimit.GetFloat()); } + public override bool OnJudge(PlayerControl pc, PlayerControl target) + { + if (Starspawn.IsDayBreak) return false; + var command = $"/target {target.PlayerId}"; + ChatCommands.TargetCommand(pc, command, command.Split(' ')); + return true; + } + public override void OnMeetingShapeshift(PlayerControl shapeshifter, PlayerControl target) { - var command = $"/target {target.PlayerId}"; - ChatCommands.TargetCommand(shapeshifter, command, command.Split(' ')); + OnJudge(shapeshifter, target); } private static void VentriloquistOnClick(byte playerId /*, MeetingHud __instance*/) diff --git a/Roles/Standard/Neutral/Pariah/Clerk.cs b/Roles/Standard/Neutral/Pariah/Clerk.cs index 13e157b68..c2009907b 100644 --- a/Roles/Standard/Neutral/Pariah/Clerk.cs +++ b/Roles/Standard/Neutral/Pariah/Clerk.cs @@ -79,7 +79,7 @@ public class Clerk : RoleBase public override void OnMeetingShapeshift(PlayerControl shapeshifter, PlayerControl target) { - OnVote(shapeshifter, target); + OnJudge(shapeshifter, target); } public override void AfterMeetingTasks() diff --git a/Roles/Standard/Neutral/Pariah/Starspawn.cs b/Roles/Standard/Neutral/Pariah/Starspawn.cs index 38430fa4d..482b90b60 100644 --- a/Roles/Standard/Neutral/Pariah/Starspawn.cs +++ b/Roles/Standard/Neutral/Pariah/Starspawn.cs @@ -77,10 +77,17 @@ public class Starspawn : RoleBase return false; } + public override bool OnJudge(PlayerControl pc, PlayerControl target) + { + if (IsDayBreak) return false; + const string command = "/daybreak"; + ChatCommands.DayBreakCommand(pc, command, command.Split(' ')); + return true; + } + public override void OnMeetingShapeshift(PlayerControl shapeshifter, PlayerControl target) { - const string command = "/daybreak"; - ChatCommands.DayBreakCommand(shapeshifter, command, command.Split(' ')); + OnJudge(shapeshifter, target); } public void ReceiveRPC(MessageReader reader)