From 6867a9f5ab57a1c9cd0d7ecc692c4de474abf66d Mon Sep 17 00:00:00 2001 From: mxyx0412 Date: Mon, 16 Sep 2024 05:25:37 +0800 Subject: [PATCH] Remove the crew/Imp limit settings --- TheOtherRoles/CustomOptionHolder.cs | 33 +++--------- TheOtherRoles/Helper/Helpers.cs | 6 +++ TheOtherRoles/Main.cs | 7 +-- TheOtherRoles/MapOptions.cs | 5 ++ TheOtherRoles/Modules/CustomOptions.cs | 57 +++++--------------- TheOtherRoles/Patches/IntroPatch.cs | 1 - TheOtherRoles/Patches/RoleAssignmentPatch.cs | 40 +++++--------- 7 files changed, 46 insertions(+), 103 deletions(-) diff --git a/TheOtherRoles/CustomOptionHolder.cs b/TheOtherRoles/CustomOptionHolder.cs index 01d78ef25..376950124 100644 --- a/TheOtherRoles/CustomOptionHolder.cs +++ b/TheOtherRoles/CustomOptionHolder.cs @@ -13,14 +13,8 @@ public class CustomOptionHolder public static string[] presets = ["Preset 1", "Preset 2", "Preset 3", "Random Preset Skeld", "Random Preset Mira HQ", "Random Preset Polus", "Random Preset Airship", "Random Preset Fungle", "Random Preset Submerged"]; public static CustomOption presetSelection; - public static CustomOption activateRoles; - public static CustomOption crewmateRolesCountMin; - public static CustomOption crewmateRolesCountMax; - public static CustomOption crewmateRolesFill; public static CustomOption neutralRolesCountMin; public static CustomOption neutralRolesCountMax; - public static CustomOption impostorRolesCountMin; - public static CustomOption impostorRolesCountMax; public static CustomOption modifiersCountMin; public static CustomOption modifiersCountMax; @@ -609,32 +603,17 @@ public static void Load() vanillaSettings = TheOtherRolesPlugin.Instance.Config.Bind("Preset0", "VanillaOptions", ""); // Role Options - presetSelection = Create(0, Types.General, cs(new Color(204f / 255f, 204f / 255f, 0, 1f), "Preset"), presets, null, true); - activateRoles = Create(1, Types.General, cs(new Color(204f / 255f, 204f / 255f, 0, 1f), "Enable Mod Roles And Block Vanilla Roles"), true, null, true); + presetSelection = Create(0, Types.General, cs(new Color32(204, 204, 0, 255), "Preset"), presets, null, true); - anyPlayerCanStopStart = Create(2, Types.General, cs(new Color(204f / 255f, 204f / 255f, 0, 1f), "Any Player Can Stop The Start"), false, null, false); + anyPlayerCanStopStart = Create(2, Types.General, cs(new Color32(204, 204, 0, 255), "Any Player Can Stop The Start"), false, null, false); if (Utilities.EventUtility.canBeEnabled) enableEventMode = Create(3, Types.General, cs(Color.green, "Enable Special Mode"), true, null, true); // Using new id's for the options to not break compatibilty with older versions - crewmateRolesCountMin = Create(5, Types.General, - cs(new Color(204f / 255f, 204f / 255f, 0, 1f), "Minimum Crewmate Roles"), 15f, 0f, 15f, 1f, null, true); - crewmateRolesCountMax = Create(6, Types.General, - cs(new Color(204f / 255f, 204f / 255f, 0, 1f), "Maximum Crewmate Roles"), 15f, 0f, 15f, 1f); - crewmateRolesFill = Create(7, Types.General, - cs(new Color(204f / 255f, 204f / 255f, 0, 1f), "Fill Crewmate Roles\n(Ignores Min/Max)"), false); - neutralRolesCountMin = Create(8, Types.General, - cs(new Color(204f / 255f, 204f / 255f, 0, 1f), "Minimum Neutral Roles"), 15f, 0f, 15f, 1f); - neutralRolesCountMax = Create(9, Types.General, - cs(new Color(204f / 255f, 204f / 255f, 0, 1f), "Maximum Neutral Roles"), 15f, 0f, 15f, 1f); - impostorRolesCountMin = Create(10, Types.General, - cs(new Color(204f / 255f, 204f / 255f, 0, 1f), "Minimum Impostor Roles"), 15f, 0f, 15f, 1f); - impostorRolesCountMax = Create(11, Types.General, - cs(new Color(204f / 255f, 204f / 255f, 0, 1f), "Maximum Impostor Roles"), 15f, 0f, 15f, 1f); - modifiersCountMin = Create(12, Types.General, - cs(new Color(204f / 255f, 204f / 255f, 0, 1f), "Minimum Modifiers"), 15f, 0f, 15f, 1f); - modifiersCountMax = Create(13, Types.General, - cs(new Color(204f / 255f, 204f / 255f, 0, 1f), "Maximum Modifiers"), 15f, 0f, 15f, 1f); + neutralRolesCountMin = Create(8, Types.General, cs(new Color32(204, 204, 0, 255), "Minimum Neutral Roles"), 15f, 0f, 15f, 1f); + neutralRolesCountMax = Create(9, Types.General, cs(new Color32(204, 204, 0, 255), "Maximum Neutral Roles"), 15f, 0f, 15f, 1f); + modifiersCountMin = Create(12, Types.General, cs(new Color32(204, 204, 0, 255), "Minimum Modifiers"), 15f, 0f, 15f, 1f); + modifiersCountMax = Create(13, Types.General, cs(new Color32(204, 204, 0, 255), "Maximum Modifiers"), 15f, 0f, 15f, 1f); //-------------------------- Other options 1 - 599 -------------------------- // diff --git a/TheOtherRoles/Helper/Helpers.cs b/TheOtherRoles/Helper/Helpers.cs index 92df593df..13d000014 100644 --- a/TheOtherRoles/Helper/Helpers.cs +++ b/TheOtherRoles/Helper/Helpers.cs @@ -606,6 +606,12 @@ public static bool isAlive(this PlayerControl player) return !player.isDead(); } + public static List ToList(this Il2CppSystem.Collections.Generic.List list) + { + List newList = [.. list]; + return newList; + } + public static bool hasFakeTasks(this PlayerControl player) { return player == Werewolf.werewolf diff --git a/TheOtherRoles/Main.cs b/TheOtherRoles/Main.cs index ea51aa0e2..838cfd118 100644 --- a/TheOtherRoles/Main.cs +++ b/TheOtherRoles/Main.cs @@ -34,7 +34,7 @@ public class TheOtherRolesPlugin : BasePlugin public static int optionsPage = 2; - public static ConfigEntry DebugMode { get; private set; } + public static ConfigEntry DebugMode { get; private set; } public static ConfigEntry GhostsSeeInformation { get; set; } public static ConfigEntry GhostsSeeRoles { get; set; } public static ConfigEntry GhostsSeeModifier { get; set; } @@ -93,7 +93,7 @@ public override void Load() _ = checkBeta(); // Exit if running an expired beta _ = Patches.CredentialsPatch.MOTD.loadMOTDs(); - DebugMode = Config.Bind("Custom", "Enable Debug Mode", "false"); + DebugMode = Config.Bind("Custom", "Enable Debug Mode", false); GhostsSeeInformation = Config.Bind("Custom", "Ghosts See Remaining Tasks", true); GhostsSeeRoles = Config.Bind("Custom", "Ghosts See Roles", true); GhostsSeeModifier = Config.Bind("Custom", "Ghosts See Modifier", true); @@ -112,10 +112,11 @@ public override void Load() UpdateRegions(); - DebugMode = Config.Bind("Custom", "Enable Debug Mode", "false"); + DebugMode = Config.Bind("Custom", "Enable Debug Mode", false); Harmony.PatchAll(); CustomOptionHolder.Load(); + TORMapOptions.reloadPluginOptions(); CustomColors.Load(); CustomHatManager.LoadHats(); if (ToggleCursor.Value) diff --git a/TheOtherRoles/MapOptions.cs b/TheOtherRoles/MapOptions.cs index 405519642..998ef6d92 100644 --- a/TheOtherRoles/MapOptions.cs +++ b/TheOtherRoles/MapOptions.cs @@ -6,6 +6,11 @@ namespace TheOtherRoles; static class TORMapOptions { + public static float ButtonCooldown => CustomOptionHolder.resteButtonCooldown.getFloat(); + public static bool PreventTaskEnd => CustomOptionHolder.preventTaskEnd.getBool(); + public static float KillCooddown => GameOptionsManager.Instance.currentNormalGameOptions.KillCooldown; + public static int NumImpostors => GameOptionsManager.Instance.currentNormalGameOptions.NumImpostors; + // Set values public static int maxNumberOfMeetings = 10; public static bool blockSkippingInEmergencyMeetings = false; diff --git a/TheOtherRoles/Modules/CustomOptions.cs b/TheOtherRoles/Modules/CustomOptions.cs index 4a2ea4246..7379ff98e 100644 --- a/TheOtherRoles/Modules/CustomOptions.cs +++ b/TheOtherRoles/Modules/CustomOptions.cs @@ -603,8 +603,8 @@ private static void createGuesserTabs(GameOptionsMenu __instance) List menus = new List() { torMenu.transform, impostorMenu.transform, neutralMenu.transform, crewmateMenu.transform, modifierMenu.transform, guesserMenu.transform }; - List> optionBehaviours = new List>() { torOptions, impostorOptions, neutralOptions, crewmateOptions, modifierOptions, guesserOptions }; - List exludedIds = new List { 310, 311, 312, 313, 314, 315, 316, 317, 318 }; + List> optionBehaviours = new() { torOptions, impostorOptions, neutralOptions, crewmateOptions, modifierOptions, guesserOptions }; + List exludedIds = new() { 10000, 10001, 10002, 10003, 10004, 10005, 10006, 10007, 10008, 30100, 30101, 30102, 30103, 30104 }; for (int i = 0; i < options.Count; i++) { @@ -1087,11 +1087,11 @@ private static string buildOptionsOfType(CustomOption.CustomOptionType type, boo { if (type == CustomOptionType.General) options = CustomOption.options.Where(o => o.type == type || o.type == CustomOptionType.Guesser); - List remove = new List { 308, 310, 311, 312, 313, 314, 315, 316, 317, 318 }; + List remove = new List { 10000, 10001, 10002, 10003, 10004,10005, 10006, 10007, 10008, 30100, 30101, 30102, 30103, 30104 }; options = options.Where(x => !remove.Contains(x.id)); } else if (TORMapOptions.gameMode == CustomGamemodes.Classic) - options = options.Where(x => !(x.type == CustomOptionType.Guesser || x == CustomOptionHolder.crewmateRolesFill)); + options = options.Where(x => !(x.type == CustomOptionType.Guesser)); else if (TORMapOptions.gameMode == CustomGamemodes.HideNSeek) options = options.Where(x => x.type == CustomOptionType.HideNSeekMain || x.type == CustomOptionType.HideNSeekRoles); else if (TORMapOptions.gameMode == CustomGamemodes.PropHunt) @@ -1107,14 +1107,13 @@ private static string buildOptionsOfType(CustomOption.CustomOptionType type, boo } else if (option.parent.getSelection() > 0) { - if (option.id == 103) //Deputy + if (option.id == 30060) //Deputy sb.AppendLine($"- {cs(Deputy.color, "Deputy")}: {option.selections[option.selection].ToString()}"); - else if (option.id == 224) //Sidekick + else if (option.id == 20048) //Sidekick sb.AppendLine($"- {cs(Sidekick.color, "Sidekick")}: {option.selections[option.selection].ToString()}"); - else if (option.id == 358) //Prosecutor + else if (option.id == 20071) //Prosecutor sb.AppendLine($"- {cs(Lawyer.color, "Prosecutor")}: {option.selections[option.selection].ToString()}"); - - else if (option.id == 3642134) //Can Swoop + else if (option.id == 20042) //Can Swoop sb.AppendLine($"- {cs(Swooper.color, "Swooper")}: {option.selections[option.selection].ToString()}"); } @@ -1136,57 +1135,25 @@ private static string buildOptionsOfType(CustomOption.CustomOptionType type, boo } else { - if (option == CustomOptionHolder.crewmateRolesCountMin) - { - var optionName = CustomOptionHolder.cs(new Color(204f / 255f, 204f / 255f, 0, 1f), "Crewmate Roles"); - var min = CustomOptionHolder.crewmateRolesCountMin.getSelection(); - var max = CustomOptionHolder.crewmateRolesCountMax.getSelection(); - string optionValue = ""; - if (CustomOptionHolder.crewmateRolesFill.getBool()) - { - var crewCount = PlayerControl.AllPlayerControls.Count - GameOptionsManager.Instance.currentGameOptions.NumImpostors; - int minNeutral = CustomOptionHolder.neutralRolesCountMin.getSelection(); - int maxNeutral = CustomOptionHolder.neutralRolesCountMax.getSelection(); - if (minNeutral > maxNeutral) minNeutral = maxNeutral; - min = crewCount - maxNeutral; - max = crewCount - minNeutral; - if (min < 0) min = 0; - if (max < 0) max = 0; - optionValue = "Fill: "; - } - if (min > max) min = max; - optionValue += (min == max) ? $"{max}" : $"{min} - {max}"; - sb.AppendLine($"{optionName}: {optionValue}"); - } - else if (option == CustomOptionHolder.neutralRolesCountMin) + if (option == CustomOptionHolder.neutralRolesCountMin) { - var optionName = CustomOptionHolder.cs(new Color(204f / 255f, 204f / 255f, 0, 1f), "Neutral Roles"); + var optionName = CustomOptionHolder.cs(new Color32(204, 204, 0, 255), "Neutral Roles"); var min = CustomOptionHolder.neutralRolesCountMin.getSelection(); var max = CustomOptionHolder.neutralRolesCountMax.getSelection(); if (min > max) min = max; var optionValue = (min == max) ? $"{max}" : $"{min} - {max}"; sb.AppendLine($"{optionName}: {optionValue}"); } - else if (option == CustomOptionHolder.impostorRolesCountMin) - { - var optionName = CustomOptionHolder.cs(new Color(204f / 255f, 204f / 255f, 0, 1f), "Impostor Roles"); - var min = CustomOptionHolder.impostorRolesCountMin.getSelection(); - var max = CustomOptionHolder.impostorRolesCountMax.getSelection(); - if (max > GameOptionsManager.Instance.currentGameOptions.NumImpostors) max = GameOptionsManager.Instance.currentGameOptions.NumImpostors; - if (min > max) min = max; - var optionValue = (min == max) ? $"{max}" : $"{min} - {max}"; - sb.AppendLine($"{optionName}: {optionValue}"); - } else if (option == CustomOptionHolder.modifiersCountMin) { - var optionName = CustomOptionHolder.cs(new Color(204f / 255f, 204f / 255f, 0, 1f), "Modifiers"); + var optionName = CustomOptionHolder.cs(new Color32(204, 204, 0, 255), "Modifiers"); var min = CustomOptionHolder.modifiersCountMin.getSelection(); var max = CustomOptionHolder.modifiersCountMax.getSelection(); if (min > max) min = max; var optionValue = (min == max) ? $"{max}" : $"{min} - {max}"; sb.AppendLine($"{optionName}: {optionValue}"); } - else if ((option == CustomOptionHolder.crewmateRolesCountMax) || (option == CustomOptionHolder.neutralRolesCountMax) || (option == CustomOptionHolder.impostorRolesCountMax) || option == CustomOptionHolder.modifiersCountMax) + else if (option == CustomOptionHolder.neutralRolesCountMax || option == CustomOptionHolder.modifiersCountMax) { continue; } diff --git a/TheOtherRoles/Patches/IntroPatch.cs b/TheOtherRoles/Patches/IntroPatch.cs index 5247bb4c9..b0581e613 100644 --- a/TheOtherRoles/Patches/IntroPatch.cs +++ b/TheOtherRoles/Patches/IntroPatch.cs @@ -325,7 +325,6 @@ public static void SetRoleTexts(IntroCutscene __instance) } public static bool Prefix(IntroCutscene __instance) { - if (!CustomOptionHolder.activateRoles.getBool()) return true; seed = rnd.Next(5000); FastDestroyableSingleton.Instance.StartCoroutine(Effects.Lerp(1f, new Action((p) => { diff --git a/TheOtherRoles/Patches/RoleAssignmentPatch.cs b/TheOtherRoles/Patches/RoleAssignmentPatch.cs index 02c0aca79..14641eba6 100644 --- a/TheOtherRoles/Patches/RoleAssignmentPatch.cs +++ b/TheOtherRoles/Patches/RoleAssignmentPatch.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Data; using System.Linq; using AmongUs.GameOptions; using Hazel; @@ -15,7 +16,8 @@ class RoleOptionsDataGetNumPerGamePatch { public static void Postfix(ref int __result) { - if (CustomOptionHolder.activateRoles.getBool() && GameOptionsManager.Instance.CurrentGameOptions.GameMode == GameModes.Normal) __result = 0; // Deactivate Vanilla Roles if the mod roles are active + // Deactivate Vanilla Roles if the mod roles are active + if (GameOptionsManager.Instance.CurrentGameOptions.GameMode == GameModes.Normal) __result = 0; } } @@ -62,8 +64,7 @@ public static void Postfix() AmongUsClient.Instance.FinishRpcImmediately(writer); RPCProcedure.resetVariables(); if (TORMapOptions.gameMode == CustomGamemodes.HideNSeek || TORMapOptions.gameMode == CustomGamemodes.PropHunt || GameOptionsManager.Instance.currentGameOptions.GameMode == GameModes.HideNSeek) return; // Don't assign Roles in Hide N Seek - if (CustomOptionHolder.activateRoles.getBool()) // Don't assign Roles in Tutorial or if deactivated - assignRoles(); + assignRoles(); } private static void assignRoles() @@ -88,36 +89,21 @@ public static RoleAssignmentData getRoleAssignmentData() List impostors = PlayerControl.AllPlayerControls.ToArray().ToList().OrderBy(x => Guid.NewGuid()).ToList(); impostors.RemoveAll(x => !x.Data.Role.IsImpostor); - var crewmateMin = CustomOptionHolder.crewmateRolesCountMin.getSelection(); - var crewmateMax = CustomOptionHolder.crewmateRolesCountMax.getSelection(); var neutralMin = CustomOptionHolder.neutralRolesCountMin.getSelection(); var neutralMax = CustomOptionHolder.neutralRolesCountMax.getSelection(); - var impostorMin = CustomOptionHolder.impostorRolesCountMin.getSelection(); - var impostorMax = CustomOptionHolder.impostorRolesCountMax.getSelection(); + var impostorNum = TORMapOptions.NumImpostors; // Make sure min is less or equal to max - if (crewmateMin > crewmateMax) crewmateMin = crewmateMax; if (neutralMin > neutralMax) neutralMin = neutralMax; - if (impostorMin > impostorMax) impostorMin = impostorMax; - - // Automatically force everyone to get a role by setting crew Min / Max according to Neutral Settings - if (CustomOptionHolder.crewmateRolesFill.getBool()) - { - crewmateMax = crewmates.Count - neutralMin; - crewmateMin = crewmates.Count - neutralMax; - crewmateMin += neutralMax; - crewmateMax += neutralMax; - } // Get the maximum allowed count of each role type based on the minimum and maximum option - int crewCountSettings = rnd.Next(crewmateMin, crewmateMax + 1); int neutralCountSettings = rnd.Next(neutralMin, neutralMax + 1); - int impCountSettings = rnd.Next(impostorMin, impostorMax + 1); + var crewCountSettings = PlayerControl.AllPlayerControls.Count - neutralCountSettings - impostorNum; // Potentially lower the actual maximum to the assignable players int maxCrewmateRoles = Mathf.Min(crewmates.Count, crewCountSettings); int maxNeutralRoles = Mathf.Min(crewmates.Count, neutralCountSettings); - int maxImpostorRoles = Mathf.Min(impostors.Count, impCountSettings); + int maxImpostorRoles = Mathf.Min(impostors.Count, impostorNum); // Fill in the lists with the roles that should be assigned to players. Note that the special roles (like Mafia or Lovers) are NOT included in these lists Dictionary impSettings = new Dictionary(); @@ -207,14 +193,14 @@ private static void assignSpecialRoles(RoleAssignmentData data) } if (data.impostors.Count < 2 && data.maxImpostorRoles < 2 && (rnd.Next(1, 101) <= CustomOptionHolder.cultistSpawnRate.getSelection() * 10)) { - // var index = rnd.Next(0, data.impostors.Count); - // PlayerControl playerControl = data.impostors[index]; + //var index = rnd.Next(0, data.impostors.Count); + //PlayerControl playerControl = data.impostors[index]; - // Helpers.turnToCrewmate(playerControl); + //Helpers.turnToCrewmate(playerControl); - // data.impostors.RemoveAt(index); - // data.crewmates.Add(playerControl); - // setRoleToRandomPlayer((byte)RoleId.Cultist, data.impostors); + //data.impostors.RemoveAt(index); + //data.crewmates.Add(playerControl); + //setRoleToRandomPlayer((byte)RoleId.Cultist, data.impostors); //data.impostors.Count = 1; data.impostors.Capacity = 1; data.maxImpostorRoles = 1;