From c17dd4b6adeec78cfaf378de97b8f8b244efd1ef Mon Sep 17 00:00:00 2001 From: Alex <896956+Alex2911@users.noreply.github.com> Date: Mon, 24 Jan 2022 17:38:07 +0100 Subject: [PATCH 01/12] Lighter / Darker Color for all --- TheOtherRoles/Patches/UpdatePatch.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TheOtherRoles/Patches/UpdatePatch.cs b/TheOtherRoles/Patches/UpdatePatch.cs index 34243014b..a8c01af7a 100644 --- a/TheOtherRoles/Patches/UpdatePatch.cs +++ b/TheOtherRoles/Patches/UpdatePatch.cs @@ -196,8 +196,8 @@ static void setNameTags() { player.NameText.text += suffix; } - // Hacker and Detective - if (PlayerControl.LocalPlayer != null && !PlayerControl.LocalPlayer.Data.IsDead && (PlayerControl.LocalPlayer == Hacker.hacker || PlayerControl.LocalPlayer == Detective.detective || PlayerControl.LocalPlayer == Medium.medium)) { + // Display lighter / darker color for all alive players + if (PlayerControl.LocalPlayer != null && !PlayerControl.LocalPlayer.Data.IsDead) { if (MeetingHud.Instance != null) { foreach (PlayerVoteArea player in MeetingHud.Instance.playerStates) { var target = Helpers.playerById(player.TargetPlayerId); From da4572db49bfeb1932061e2f9b50f98bacb165a2 Mon Sep 17 00:00:00 2001 From: Alex <896956+Alex2911@users.noreply.github.com> Date: Tue, 25 Jan 2022 02:38:58 +0100 Subject: [PATCH 02/12] Fix for dynamic Map --- TheOtherRoles/Buttons.cs | 56 ++++++++++++++----- TheOtherRoles/Main.cs | 2 + TheOtherRoles/MapOptions.cs | 4 +- TheOtherRoles/Patches/ClientOptionsPatch.cs | 1 + .../Patches/GameStartManagerPatch.cs | 22 ++++---- TheOtherRoles/Patches/UpdatePatch.cs | 19 ++++++- 6 files changed, 77 insertions(+), 27 deletions(-) diff --git a/TheOtherRoles/Buttons.cs b/TheOtherRoles/Buttons.cs index 2687284f1..3eba88610 100644 --- a/TheOtherRoles/Buttons.cs +++ b/TheOtherRoles/Buttons.cs @@ -106,6 +106,37 @@ public static void setCustomButtonCooldowns() { lightsOutButton.Timer = lightsOutButton.MaxTimer; } + public static byte returnCurrentMapId() + { + byte chosenMapId = 0; + var camsExisting = UnityEngine.Object.FindObjectsOfType().FirstOrDefault(x => x.gameObject.name.Contains("Surv_Panel")); + var vitalsExisting = UnityEngine.Object.FindObjectsOfType().FirstOrDefault(x => x.gameObject.name.Contains("panel_vitals")); + var survconsoleExisting = UnityEngine.Object.FindObjectsOfType().FirstOrDefault(x => x.gameObject.name.Contains("SurvConsole")); + + if (camsExisting != null) + { + // Polus + chosenMapId = 2; + } + else if (vitalsExisting != null) + { + // Airship ? + chosenMapId = 4; + } + else if (survconsoleExisting != null) + { + // Skeld + chosenMapId = 0; + } + else + { + // Mira HQ + chosenMapId = 1; + } + return chosenMapId; + } + + public static void resetTimeMasterButton() { timeMasterShieldButton.Timer = timeMasterShieldButton.MaxTimer; timeMasterShieldButton.isEffectActive = false; @@ -484,7 +515,6 @@ public static void Postfix(HudManager __instance) if (Hacker.cantMove) PlayerControl.LocalPlayer.moveable = false; PlayerControl.LocalPlayer.NetTransform.Halt(); // Stop current movement - Hacker.chargesAdminTable--; }, () => { return Hacker.hacker != null && Hacker.hacker == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead;}, @@ -508,7 +538,7 @@ public static void Postfix(HudManager __instance) if (!hackerVitalsButton.isEffectActive) PlayerControl.LocalPlayer.moveable = true; if (MapBehaviour.Instance && MapBehaviour.Instance.isActiveAndEnabled) MapBehaviour.Instance.Close(); }, - PlayerControl.GameOptions.MapId == 3, + returnCurrentMapId() == 3, "ADMIN" ); @@ -521,7 +551,7 @@ public static void Postfix(HudManager __instance) hackerVitalsButton = new CustomButton( () => { - if (PlayerControl.GameOptions.MapId != 1) { + if (returnCurrentMapId() != 1) { if (Hacker.vitals == null) { var e = UnityEngine.Object.FindObjectsOfType().FirstOrDefault(x => x.gameObject.name.Contains("panel_vitals")); if (e == null || Camera.main == null) return; @@ -546,11 +576,11 @@ public static void Postfix(HudManager __instance) Hacker.chargesVitals--; }, - () => { return Hacker.hacker != null && Hacker.hacker == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead && PlayerControl.GameOptions.MapId != 0 && PlayerControl.GameOptions.MapId != 3; }, + () => { return Hacker.hacker != null && Hacker.hacker == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead && returnCurrentMapId() != 0 && returnCurrentMapId() != 3; }, () => { if (hackerVitalsChargesText != null) hackerVitalsChargesText.text = $"{Hacker.chargesVitals} / {Hacker.toolsNumber}"; - hackerVitalsButton.actionButton.graphic.sprite = PlayerControl.GameOptions.MapId == 1 ? Hacker.getLogSprite() : Hacker.getVitalsSprite(); - hackerVitalsButton.actionButton.OverrideText(PlayerControl.GameOptions.MapId == 1 ? "DOORLOG" : "VITALS"); + hackerVitalsButton.actionButton.graphic.sprite = returnCurrentMapId() == 1 ? Hacker.getLogSprite() : Hacker.getVitalsSprite(); + hackerVitalsButton.actionButton.OverrideText(returnCurrentMapId() == 1 ? "DOORLOG" : "VITALS"); return Hacker.chargesVitals > 0; }, () => { @@ -568,7 +598,7 @@ public static void Postfix(HudManager __instance) hackerVitalsButton.Timer = hackerVitalsButton.MaxTimer; if(!hackerAdminTableButton.isEffectActive) PlayerControl.LocalPlayer.moveable = true; if (Minigame.Instance) { - if (PlayerControl.GameOptions.MapId == 1) Hacker.doorLog.ForceClose(); + if (returnCurrentMapId() == 1) Hacker.doorLog.ForceClose(); else Hacker.vitals.ForceClose(); } }, @@ -942,7 +972,7 @@ public static void Postfix(HudManager __instance) RPCProcedure.sealVent(SecurityGuard.ventTarget.Id); SecurityGuard.ventTarget = null; - } else if (PlayerControl.GameOptions.MapId != 1) { // Place camera if there's no vent and it's not MiraHQ + } else if (returnCurrentMapId() != 1) { // Place camera if there's no vent and it's not MiraHQ var pos = PlayerControl.LocalPlayer.transform.position; byte[] buff = new byte[sizeof(float) * 2]; Buffer.BlockCopy(BitConverter.GetBytes(pos.x), 0, buff, 0*sizeof(float), sizeof(float)); @@ -957,12 +987,12 @@ public static void Postfix(HudManager __instance) }, () => { return SecurityGuard.securityGuard != null && SecurityGuard.securityGuard == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead && SecurityGuard.remainingScrews >= Mathf.Min(SecurityGuard.ventPrice, SecurityGuard.camPrice); }, () => { - securityGuardButton.actionButton.graphic.sprite = (SecurityGuard.ventTarget == null && PlayerControl.GameOptions.MapId != 1) ? SecurityGuard.getPlaceCameraButtonSprite() : SecurityGuard.getCloseVentButtonSprite(); + securityGuardButton.actionButton.graphic.sprite = (SecurityGuard.ventTarget == null && returnCurrentMapId() != 1) ? SecurityGuard.getPlaceCameraButtonSprite() : SecurityGuard.getCloseVentButtonSprite(); if (securityGuardButtonScrewsText != null) securityGuardButtonScrewsText.text = $"{SecurityGuard.remainingScrews}/{SecurityGuard.totalScrews}"; if (SecurityGuard.ventTarget != null) return SecurityGuard.remainingScrews >= SecurityGuard.ventPrice && PlayerControl.LocalPlayer.CanMove; - return PlayerControl.GameOptions.MapId != 1 && SecurityGuard.remainingScrews >= SecurityGuard.camPrice && PlayerControl.LocalPlayer.CanMove; + return returnCurrentMapId() != 1 && SecurityGuard.remainingScrews >= SecurityGuard.camPrice && PlayerControl.LocalPlayer.CanMove; }, () => { securityGuardButton.Timer = securityGuardButton.MaxTimer; }, SecurityGuard.getPlaceCameraButtonSprite(), @@ -1007,8 +1037,8 @@ public static void Postfix(HudManager __instance) () => { return SecurityGuard.securityGuard != null && SecurityGuard.securityGuard == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead && SecurityGuard.remainingScrews < Mathf.Min(SecurityGuard.ventPrice, SecurityGuard.camPrice); }, () => { if (securityGuardChargesText != null) securityGuardChargesText.text = $"{SecurityGuard.charges} / {SecurityGuard.maxCharges}"; - securityGuardCamButton.actionButton.graphic.sprite = PlayerControl.GameOptions.MapId == 1 ? SecurityGuard.getLogSprite() : SecurityGuard.getCamSprite(); - securityGuardCamButton.actionButton.OverrideText(PlayerControl.GameOptions.MapId == 1 ? "DOORLOG" : "SECURITY"); + securityGuardCamButton.actionButton.graphic.sprite = returnCurrentMapId() == 1 ? SecurityGuard.getLogSprite() : SecurityGuard.getCamSprite(); + securityGuardCamButton.actionButton.OverrideText(returnCurrentMapId() == 1 ? "DOORLOG" : "SECURITY"); return PlayerControl.LocalPlayer.CanMove && SecurityGuard.charges > 0; }, () => { @@ -1030,7 +1060,7 @@ public static void Postfix(HudManager __instance) PlayerControl.LocalPlayer.moveable = true; }, false, - PlayerControl.GameOptions.MapId == 1 ? "DOORLOG" : "SECURITY" + returnCurrentMapId() == 1 ? "DOORLOG" : "SECURITY" ); // Security Guard cam button charges diff --git a/TheOtherRoles/Main.cs b/TheOtherRoles/Main.cs index 580f70518..d51ba8750 100644 --- a/TheOtherRoles/Main.cs +++ b/TheOtherRoles/Main.cs @@ -37,6 +37,7 @@ public class TheOtherRolesPlugin : BasePlugin public static ConfigEntry GhostsSeeRoles { get; set; } public static ConfigEntry GhostsSeeVotes{ get; set; } public static ConfigEntry ShowRoleSummary { get; set; } + public static ConfigEntry ShowLighterDarker { get; set; } public static ConfigEntry StreamerModeReplacementText { get; set; } public static ConfigEntry StreamerModeReplacementColor { get; set; } public static ConfigEntry Ip { get; set; } @@ -64,6 +65,7 @@ public override void Load() { GhostsSeeRoles = Config.Bind("Custom", "Ghosts See Roles", true); GhostsSeeVotes = Config.Bind("Custom", "Ghosts See Votes", true); ShowRoleSummary = Config.Bind("Custom", "Show Role Summary", true); + ShowLighterDarker = Config.Bind("Custom", "Show Lighter / Darker", true); ShowPopUpVersion = Config.Bind("Custom", "Show PopUp", "0"); StreamerModeReplacementText = Config.Bind("Custom", "Streamer Mode Replacement Text", "\n\nThe Other Roles"); StreamerModeReplacementColor = Config.Bind("Custom", "Streamer Mode Replacement Text Hex Color", "#87AAF5FF"); diff --git a/TheOtherRoles/MapOptions.cs b/TheOtherRoles/MapOptions.cs index 94531fe7d..2c69f53df 100644 --- a/TheOtherRoles/MapOptions.cs +++ b/TheOtherRoles/MapOptions.cs @@ -16,6 +16,7 @@ static class MapOptions { public static bool ghostsSeeVotes = true; public static bool showRoleSummary = true; public static bool allowParallelMedBayScans = false; + public static bool showLighterDarker = true; // Updating values public static int meetingsCount = 0; @@ -38,6 +39,7 @@ public static void clearAndReloadMapOptions() { ghostsSeeTasks = TheOtherRolesPlugin.GhostsSeeTasks.Value; ghostsSeeVotes = TheOtherRolesPlugin.GhostsSeeVotes.Value; showRoleSummary = TheOtherRolesPlugin.ShowRoleSummary.Value; + showLighterDarker = TheOtherRolesPlugin.ShowLighterDarker.Value; } } -} \ No newline at end of file +} \ No newline at end of file diff --git a/TheOtherRoles/Patches/ClientOptionsPatch.cs b/TheOtherRoles/Patches/ClientOptionsPatch.cs index 2e50869ae..9f5a77bcf 100644 --- a/TheOtherRoles/Patches/ClientOptionsPatch.cs +++ b/TheOtherRoles/Patches/ClientOptionsPatch.cs @@ -19,6 +19,7 @@ public static class ClientOptionsPatch new SelectionBehaviour("Ghosts Can See Votes", () => MapOptions.ghostsSeeVotes = TheOtherRolesPlugin.GhostsSeeVotes.Value = !TheOtherRolesPlugin.GhostsSeeVotes.Value, TheOtherRolesPlugin.GhostsSeeVotes.Value), new SelectionBehaviour("Ghosts Can See Roles", () => MapOptions.ghostsSeeRoles = TheOtherRolesPlugin.GhostsSeeRoles.Value = !TheOtherRolesPlugin.GhostsSeeRoles.Value, TheOtherRolesPlugin.GhostsSeeRoles.Value), new SelectionBehaviour("Show Role Summary", () => MapOptions.showRoleSummary = TheOtherRolesPlugin.ShowRoleSummary.Value = !TheOtherRolesPlugin.ShowRoleSummary.Value, TheOtherRolesPlugin.ShowRoleSummary.Value), + new SelectionBehaviour("Show Lighter / Darker", () => MapOptions.showLighterDarker = TheOtherRolesPlugin.ShowLighterDarker.Value = !TheOtherRolesPlugin.ShowLighterDarker.Value, TheOtherRolesPlugin.ShowLighterDarker.Value), }; private static GameObject popUp; diff --git a/TheOtherRoles/Patches/GameStartManagerPatch.cs b/TheOtherRoles/Patches/GameStartManagerPatch.cs index 0f895fb95..c57b9799f 100644 --- a/TheOtherRoles/Patches/GameStartManagerPatch.cs +++ b/TheOtherRoles/Patches/GameStartManagerPatch.cs @@ -139,6 +139,7 @@ public static bool Prefix(GameStartManager __instance) { // Block game start if not everyone has the same mod version bool continueStart = true; + byte chosenMapId = PlayerControl.GameOptions.MapId; if (AmongUsClient.Instance.AmHost) { foreach (InnerNet.ClientData client in AmongUsClient.Instance.allClients) { if (client.Character == null) continue; @@ -158,18 +159,19 @@ public static bool Prefix(GameStartManager __instance) { break; } } - } - if (CustomOptionHolder.dynamicMap.getBool()) { - // 0 = Skeld - // 1 = Mira HQ - // 2 = Polus - // 3 = Dleks - deactivated - // 4 = Airship - List possibleMaps = new List(){0, 1, 2, 4}; - PlayerControl.GameOptions.MapId = possibleMaps[TheOtherRoles.rnd.Next(possibleMaps.Count)]; + if (CustomOptionHolder.dynamicMap.getBool()) + { + // 0 = Skeld + // 1 = Mira HQ + // 2 = Polus + // 3 = Dleks - deactivated + // 4 = Airship + List possibleMaps = new List() { 0, 1, 2, 4 }; + chosenMapId = possibleMaps[TheOtherRoles.rnd.Next(possibleMaps.Count)]; + } } - + PlayerControl.GameOptions.MapId = chosenMapId; return continueStart; } } diff --git a/TheOtherRoles/Patches/UpdatePatch.cs b/TheOtherRoles/Patches/UpdatePatch.cs index a8c01af7a..2a6d923d3 100644 --- a/TheOtherRoles/Patches/UpdatePatch.cs +++ b/TheOtherRoles/Patches/UpdatePatch.cs @@ -199,10 +199,23 @@ static void setNameTags() { // Display lighter / darker color for all alive players if (PlayerControl.LocalPlayer != null && !PlayerControl.LocalPlayer.Data.IsDead) { if (MeetingHud.Instance != null) { - foreach (PlayerVoteArea player in MeetingHud.Instance.playerStates) { - var target = Helpers.playerById(player.TargetPlayerId); - if (target != null) player.NameText.text += $" ({(Helpers.isLighterColor(target.Data.DefaultOutfit.ColorId) ? "L" : "D")})"; + if (MapOptions.showLighterDarker) + { + foreach (PlayerVoteArea player in MeetingHud.Instance.playerStates) { + var target = Helpers.playerById(player.TargetPlayerId); + if (target != null) player.NameText.text += $" ({(Helpers.isLighterColor(target.Data.DefaultOutfit.ColorId) ? "L" : "D")})"; + } } + else + { + if (PlayerControl.LocalPlayer == Hacker.hacker || PlayerControl.LocalPlayer == Detective.detective || PlayerControl.LocalPlayer == Medium.medium) + { + foreach (PlayerVoteArea player in MeetingHud.Instance.playerStates) + { + var target = Helpers.playerById(player.TargetPlayerId); + if (target != null) player.NameText.text += $" ({(Helpers.isLighterColor(target.Data.DefaultOutfit.ColorId) ? "L" : "D")})"; + } + } } } } From e7f104202c3a99d9a3d7e7d7b2c34304c75bfa3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mall=C3=B6ris?= <|||||@||.||> Date: Tue, 25 Jan 2022 19:55:10 +0100 Subject: [PATCH 03/12] make assignDependentRoles fair again + BountyHunter fix --- TheOtherRoles/Modules/ModUpdater.cs | 2 +- TheOtherRoles/Patches/PlayerControlPatch.cs | 1 - TheOtherRoles/Patches/RoleAssignmentPatch.cs | 163 ++++++++----------- 3 files changed, 65 insertions(+), 101 deletions(-) diff --git a/TheOtherRoles/Modules/ModUpdater.cs b/TheOtherRoles/Modules/ModUpdater.cs index 512a6c1c2..87b9b5bc2 100644 --- a/TheOtherRoles/Modules/ModUpdater.cs +++ b/TheOtherRoles/Modules/ModUpdater.cs @@ -158,7 +158,7 @@ update to v{ver} is available } } } else { - announcement = $@"Version {ver}: + announcement = $@"THE OTHER ROLES Version {ver}: {announcement}"; } diff --git a/TheOtherRoles/Patches/PlayerControlPatch.cs b/TheOtherRoles/Patches/PlayerControlPatch.cs index c9667ba29..cbc9e8da4 100644 --- a/TheOtherRoles/Patches/PlayerControlPatch.cs +++ b/TheOtherRoles/Patches/PlayerControlPatch.cs @@ -565,7 +565,6 @@ static void bountyHunterUpdate() { BountyHunter.arrowUpdateTimer = 0f; // Force arrow to update BountyHunter.bountyUpdateTimer = BountyHunter.bountyDuration; var possibleTargets = new List(); - if (Lovers.getPartner(BountyHunter.bountyHunter) != null) foreach (PlayerControl p in PlayerControl.AllPlayerControls) { if (!p.Data.IsDead && !p.Data.Disconnected && p != p.Data.Role.IsImpostor && p != Spy.spy && (p != Mini.mini || Mini.isGrownUp()) && (Lovers.getPartner(BountyHunter.bountyHunter) == null || p != Lovers.getPartner(BountyHunter.bountyHunter))) possibleTargets.Add(p); } diff --git a/TheOtherRoles/Patches/RoleAssignmentPatch.cs b/TheOtherRoles/Patches/RoleAssignmentPatch.cs index cf672a533..b8c6fb847 100644 --- a/TheOtherRoles/Patches/RoleAssignmentPatch.cs +++ b/TheOtherRoles/Patches/RoleAssignmentPatch.cs @@ -235,110 +235,75 @@ private static void assignEnsuredRoles(RoleAssignmentData data) { } private static void assignDependentRoles(RoleAssignmentData data) { + // Roles that prob have a dependent role + bool guesserFlag = CustomOptionHolder.guesserSpawnBothRate.getSelection() > 0 && CustomOptionHolder.guesserSpawnRate.getSelection() > 0; + bool sheriffFlag = CustomOptionHolder.deputySpawnRate.getSelection() > 0 && CustomOptionHolder.sheriffSpawnRate.getSelection() > 0; + if (!guesserFlag && !sheriffFlag) return; // assignDependentRoles is not needed + + int crew = data.crewmates.Count < data.maxCrewmateRoles ? data.crewmates.Count : data.maxCrewmateRoles; // Max number of crew loops + int imp = data.impostors.Count < data.maxImpostorRoles ? data.impostors.Count : data.maxImpostorRoles; // Max number of imp loops + int crewSteps = crew / data.crewSettings.Keys.Count(); // Avarage crewvalues deducted after each loop + int impSteps = imp / data.impSettings.Keys.Count(); // Avarage impvalues deducted after each loop + + // set to false if needed, otherwise we can skip the loop + bool isSheriff = !sheriffFlag; + bool isGuesser = !guesserFlag; + + bool isEvilGuesser = (rnd.Next(1, 101) <= CustomOptionHolder.guesserIsImpGuesserRate.getSelection() * 10); + + // --- Simulate Crew & Imp ticket system --- + while (crew > 0 && (!isSheriff || (!isEvilGuesser && !isGuesser))) { + if (!isSheriff && rnd.Next(crewValues) < CustomOptionHolder.sheriffSpawnRate.getSelection()) isSheriff = true; + if (!isEvilGuesser && !isGuesser && rnd.Next(crewValues) < CustomOptionHolder.guesserSpawnRate.getSelection()) isGuesser = true; + crew--; + crewValues -= crewSteps; + } + while (imp > 0 && (isEvilGuesser && !isGuesser)) { + if (rnd.Next(crewValues) < CustomOptionHolder.guesserSpawnRate.getSelection()) isGuesser = true; + imp--; + impValues -= impSteps; + } - int crew = data.crewmates.Count < data.maxCrewmateRoles ? data.crewmates.Count : data.maxCrewmateRoles; - int imp = data.impostors.Count < data.maxImpostorRoles ? data.impostors.Count : data.maxImpostorRoles; - int leftCrewRolesCount = crew - data.crewSettings.Where(x => x.Value != 0 && x.Value != 10).ToList().Count; - int leftImpRolesCount = imp - data.impSettings.Where(x => x.Value != 0 && x.Value != 10).ToList().Count; - - // Other Guesser - if (CustomOptionHolder.guesserSpawnBothRate.getSelection() > 0) { - bool isEvilGuesser = (rnd.Next(1, 101) <= CustomOptionHolder.guesserIsImpGuesserRate.getSelection() * 10); - int guesserSpawnValues = isEvilGuesser ? impValues : crewValues; - - if (Guesser.evilGuesser != null || Guesser.niceGuesser != null) { - if (CustomOptionHolder.guesserSpawnBothRate.getSelection() == 10) { // Force both Guesser - if (Guesser.niceGuesser == null && data.crewmates.Count > 0 && data.maxCrewmateRoles > 0) { // Other Guesser = Nice Guesser - byte niceGuesser = setRoleToRandomPlayer((byte)RoleId.NiceGuesser, data.crewmates); - data.crewmates.ToList().RemoveAll(x => x.PlayerId == niceGuesser); - data.maxCrewmateRoles--; - leftCrewRolesCount--; - } - else if (Guesser.evilGuesser == null && data.impostors.Count > 0 && data.maxImpostorRoles > 0) { // Other Guesser = Evil Guesser - byte evilGuesser = setRoleToRandomPlayer((byte)RoleId.EvilGuesser, data.impostors); - data.impostors.ToList().RemoveAll(x => x.PlayerId == evilGuesser); - data.maxImpostorRoles--; - leftImpRolesCount--; - } - } - else if (Guesser.niceGuesser == null && data.crewmates.Count > 0 && data.maxCrewmateRoles > 0) { // Dont force, add other guesser (nice) to pool - data.crewSettings.Add((byte)RoleId.NiceGuesser, CustomOptionHolder.guesserSpawnBothRate.getSelection()); - crewValues += CustomOptionHolder.guesserSpawnBothRate.getSelection(); - leftCrewRolesCount--; - } - else if (Guesser.evilGuesser == null && data.impostors.Count > 0 && data.maxImpostorRoles > 0) { // Dont force, add other guesser (evil) to pool - data.impSettings.Add((byte)RoleId.EvilGuesser, CustomOptionHolder.guesserSpawnBothRate.getSelection()); - impValues += CustomOptionHolder.guesserSpawnBothRate.getSelection(); - leftImpRolesCount--; - } - } - else if ((CustomOptionHolder.guesserSpawnRate.getSelection() < 10 && rnd.Next(guesserSpawnValues + CustomOptionHolder.guesserSpawnRate.getSelection()) < CustomOptionHolder.guesserSpawnRate.getSelection()) - || (isEvilGuesser && leftImpRolesCount > 0) || - (!isEvilGuesser && leftCrewRolesCount > 0)) { // Guesser is < 100%, but won the lottery or there are roles left to assign - if (isEvilGuesser && data.impostors.Count > 0 && data.maxImpostorRoles > 0) { // Add Evil Guesser - byte evilGuesser = setRoleToRandomPlayer((byte)RoleId.EvilGuesser, data.impostors); - data.impostors.ToList().RemoveAll(x => x.PlayerId == evilGuesser); - data.maxImpostorRoles--; - leftImpRolesCount--; - if (CustomOptionHolder.guesserSpawnBothRate.getSelection() == 10 && data.crewmates.Count > 0 && data.maxCrewmateRoles > 0) { // Force Other Guesser (nice) - byte niceGuesser = setRoleToRandomPlayer((byte)RoleId.NiceGuesser, data.crewmates); - data.crewmates.ToList().RemoveAll(x => x.PlayerId == niceGuesser); - data.maxCrewmateRoles--; - leftCrewRolesCount--; - } - else if (CustomOptionHolder.guesserSpawnBothRate.getSelection() < 10) { // Dont force, add other guesser (nice) to pool - data.crewSettings.Add((byte)RoleId.NiceGuesser, CustomOptionHolder.guesserSpawnBothRate.getSelection()); - crewValues += CustomOptionHolder.guesserSpawnBothRate.getSelection(); - leftCrewRolesCount--; - } - } - else if (!isEvilGuesser && data.crewmates.Count > 0 && data.maxCrewmateRoles > 0) { // Add Nice Guesser - byte niceGuesser = setRoleToRandomPlayer((byte)RoleId.NiceGuesser, data.crewmates); - data.crewmates.ToList().RemoveAll(x => x.PlayerId == niceGuesser); - data.maxCrewmateRoles--; - leftCrewRolesCount--; - if (CustomOptionHolder.guesserSpawnBothRate.getSelection() == 10 && data.impostors.Count > 0 && data.maxImpostorRoles > 0) { // Force Other Guesser (evil) - byte evilGuesser = setRoleToRandomPlayer((byte)RoleId.EvilGuesser, data.impostors); - data.impostors.ToList().RemoveAll(x => x.PlayerId == evilGuesser); - data.maxImpostorRoles--; - leftImpRolesCount--; - } - else if (CustomOptionHolder.guesserSpawnBothRate.getSelection() < 10) { // Dont force, add other guesser (evil) to pool - data.impSettings.Add((byte)RoleId.EvilGuesser, CustomOptionHolder.guesserSpawnBothRate.getSelection()); - impValues += CustomOptionHolder.guesserSpawnBothRate.getSelection(); - leftImpRolesCount--; - } - } - } + // --- Assign Main Roles if they won the lottery --- + if (isSheriff && Sheriff.sheriff == null && data.crewmates.Count > 0 && data.maxCrewmateRoles > 0 && sheriffFlag) { // Set Sheriff cause he won the lottery + byte sheriff = setRoleToRandomPlayer((byte)RoleId.Sheriff, data.crewmates); + data.crewmates.ToList().RemoveAll(x => x.PlayerId == sheriff); + data.maxCrewmateRoles--; + } + if (!isEvilGuesser && isGuesser && Guesser.niceGuesser == null && data.crewmates.Count > 0 && data.maxCrewmateRoles > 0 && guesserFlag) { // Set Nice Guesser cause he won the lottery + byte niceGuesser = setRoleToRandomPlayer((byte)RoleId.NiceGuesser, data.crewmates); + data.crewmates.ToList().RemoveAll(x => x.PlayerId == niceGuesser); + data.maxCrewmateRoles--; + } else if (isEvilGuesser && isGuesser && Guesser.evilGuesser == null && data.impostors.Count > 0 && data.maxImpostorRoles > 0 && guesserFlag) { // Set Evil Guesser cause he won the lottery + byte evilGuesser = setRoleToRandomPlayer((byte)RoleId.EvilGuesser, data.impostors); + data.impostors.ToList().RemoveAll(x => x.PlayerId == evilGuesser); + data.maxImpostorRoles--; } - // Deputy - if (CustomOptionHolder.deputySpawnRate.getSelection() > 0 && data.crewmates.Count > 0 && data.maxCrewmateRoles > 0) { - if (Sheriff.sheriff != null) { - if (CustomOptionHolder.deputySpawnRate.getSelection() == 10) { // Force Deputy - byte deputy = setRoleToRandomPlayer((byte)RoleId.Deputy, data.crewmates); - data.crewmates.ToList().RemoveAll(x => x.PlayerId == deputy); - data.maxCrewmateRoles--; - } else if (CustomOptionHolder.deputySpawnRate.getSelection() < 10) { // Dont force, add Deputy to pool - data.crewSettings.Add((byte)RoleId.Deputy, CustomOptionHolder.deputySpawnRate.getSelection()); - } - } else if ((CustomOptionHolder.sheriffSpawnRate.getSelection() < 10 && rnd.Next(crewValues + CustomOptionHolder.sheriffSpawnRate.getSelection()) < CustomOptionHolder.sheriffSpawnRate.getSelection()) - || leftCrewRolesCount > 0) { // Sheriff is < 100%, but won the lottery or there are roles left to assign - byte sheriff = setRoleToRandomPlayer((byte)RoleId.Sheriff, data.crewmates); - data.crewmates.ToList().RemoveAll(x => x.PlayerId == sheriff); + // --- Assign Dependent Roles if main role exists --- + if (Sheriff.sheriff != null) { // Deputy + if (CustomOptionHolder.deputySpawnRate.getSelection() == 10 && data.crewmates.Count > 0 && data.maxCrewmateRoles > 0) { // Force Deputy + byte deputy = setRoleToRandomPlayer((byte)RoleId.NiceGuesser, data.crewmates); + data.crewmates.ToList().RemoveAll(x => x.PlayerId == deputy); + data.maxCrewmateRoles--; + } else if (CustomOptionHolder.deputySpawnRate.getSelection() < 10) // Dont force, add Deputy to the ticket system + data.crewSettings.Add((byte)RoleId.Deputy, CustomOptionHolder.deputySpawnRate.getSelection()); + } + if (!isEvilGuesser && Guesser.niceGuesser != null) { // Other Guesser (evil) + if (CustomOptionHolder.guesserSpawnBothRate.getSelection() == 10 && data.impostors.Count > 0 && data.maxImpostorRoles > 0) { // Force other guesser (evil) + byte bothGuesser = setRoleToRandomPlayer((byte)RoleId.EvilGuesser, data.impostors); + data.crewmates.ToList().RemoveAll(x => x.PlayerId == bothGuesser); + data.maxImpostorRoles--; + } else if (CustomOptionHolder.guesserSpawnBothRate.getSelection() < 10) // Dont force, add Guesser (evil) to the ticket system + data.impSettings.Add((byte)RoleId.EvilGuesser, CustomOptionHolder.guesserSpawnBothRate.getSelection()); + } else if (isEvilGuesser && Guesser.evilGuesser != null) { // ELSE other Guesser (nice) + if (CustomOptionHolder.guesserSpawnBothRate.getSelection() == 10 && data.crewmates.Count > 0 && data.maxCrewmateRoles > 0) { // Force other guesser (nice) + byte bothGuesser = setRoleToRandomPlayer((byte)RoleId.NiceGuesser, data.crewmates); + data.crewmates.ToList().RemoveAll(x => x.PlayerId == bothGuesser); data.maxCrewmateRoles--; - leftCrewRolesCount--; - if (CustomOptionHolder.deputySpawnRate.getSelection() == 10 && data.crewmates.Count > 0 && data.maxCrewmateRoles > 0) { // Force Deputy - byte deputy = setRoleToRandomPlayer((byte)RoleId.Deputy, data.crewmates); - data.crewmates.ToList().RemoveAll(x => x.PlayerId == deputy); - data.maxCrewmateRoles--; - leftCrewRolesCount--; - } else { // Dont force, add Deputy to pool - data.crewSettings.Add((byte)RoleId.Deputy, CustomOptionHolder.deputySpawnRate.getSelection()); - crewValues += CustomOptionHolder.deputySpawnRate.getSelection(); - leftCrewRolesCount--; - } } + else if (CustomOptionHolder.guesserSpawnBothRate.getSelection() < 10) // Dont force, add Guesser (nice) to the ticket system + data.crewSettings.Add((byte)RoleId.NiceGuesser, CustomOptionHolder.guesserSpawnBothRate.getSelection()); } } private static void assignChanceRoles(RoleAssignmentData data) { From f81346cb26480238a802ddb7c503d3daff0dd61c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mall=C3=B6ris?= <|||||@||.||> Date: Tue, 25 Jan 2022 19:56:02 +0100 Subject: [PATCH 04/12] version bump --- TheOtherRoles/Main.cs | 2 +- TheOtherRoles/TheOtherRoles.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/TheOtherRoles/Main.cs b/TheOtherRoles/Main.cs index 580f70518..41616f868 100644 --- a/TheOtherRoles/Main.cs +++ b/TheOtherRoles/Main.cs @@ -21,7 +21,7 @@ namespace TheOtherRoles public class TheOtherRolesPlugin : BasePlugin { public const string Id = "me.eisbison.theotherroles"; - public const string VersionString = "3.4.0"; + public const string VersionString = "3.4.1"; public static System.Version Version = System.Version.Parse(VersionString); internal static BepInEx.Logging.ManualLogSource Logger; diff --git a/TheOtherRoles/TheOtherRoles.csproj b/TheOtherRoles/TheOtherRoles.csproj index aebc258d8..a7c3121d9 100644 --- a/TheOtherRoles/TheOtherRoles.csproj +++ b/TheOtherRoles/TheOtherRoles.csproj @@ -1,7 +1,7 @@ netstandard2.1 - 3.4.0 + 3.4.1 TheOtherRoles Eisbison From f2892f1e42a6fe6fb134b09c69d32e8234deda13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mall=C3=B6ris?= <|||||@||.||> Date: Tue, 25 Jan 2022 21:30:31 +0100 Subject: [PATCH 05/12] fix dynamic map option + security guard cams on skeld/dleks & airship --- TheOtherRoles/Buttons.cs | 61 +++++-------------- .../Patches/GameStartManagerPatch.cs | 9 ++- TheOtherRoles/Patches/UpdatePatch.cs | 21 ++----- TheOtherRoles/RPC.cs | 9 +++ 4 files changed, 35 insertions(+), 65 deletions(-) diff --git a/TheOtherRoles/Buttons.cs b/TheOtherRoles/Buttons.cs index 3eba88610..0fca0e40b 100644 --- a/TheOtherRoles/Buttons.cs +++ b/TheOtherRoles/Buttons.cs @@ -106,37 +106,6 @@ public static void setCustomButtonCooldowns() { lightsOutButton.Timer = lightsOutButton.MaxTimer; } - public static byte returnCurrentMapId() - { - byte chosenMapId = 0; - var camsExisting = UnityEngine.Object.FindObjectsOfType().FirstOrDefault(x => x.gameObject.name.Contains("Surv_Panel")); - var vitalsExisting = UnityEngine.Object.FindObjectsOfType().FirstOrDefault(x => x.gameObject.name.Contains("panel_vitals")); - var survconsoleExisting = UnityEngine.Object.FindObjectsOfType().FirstOrDefault(x => x.gameObject.name.Contains("SurvConsole")); - - if (camsExisting != null) - { - // Polus - chosenMapId = 2; - } - else if (vitalsExisting != null) - { - // Airship ? - chosenMapId = 4; - } - else if (survconsoleExisting != null) - { - // Skeld - chosenMapId = 0; - } - else - { - // Mira HQ - chosenMapId = 1; - } - return chosenMapId; - } - - public static void resetTimeMasterButton() { timeMasterShieldButton.Timer = timeMasterShieldButton.MaxTimer; timeMasterShieldButton.isEffectActive = false; @@ -216,7 +185,6 @@ public static void Postfix(HudManager __instance) engineerRepairButton = new CustomButton( () => { engineerRepairButton.Timer = 0f; - MessageWriter usedRepairWriter = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.EngineerUsedRepair, Hazel.SendOption.Reliable, -1); AmongUsClient.Instance.FinishRpcImmediately(usedRepairWriter); RPCProcedure.engineerUsedRepair(); @@ -493,7 +461,7 @@ public static void Postfix(HudManager __instance) Hacker.hackerTimer = Hacker.duration; }, () => { return Hacker.hacker != null && Hacker.hacker == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead; }, - () => { return PlayerControl.LocalPlayer.CanMove; }, + () => { return true; }, () => { hackerButton.Timer = hackerButton.MaxTimer; hackerButton.isEffectActive = false; @@ -538,7 +506,7 @@ public static void Postfix(HudManager __instance) if (!hackerVitalsButton.isEffectActive) PlayerControl.LocalPlayer.moveable = true; if (MapBehaviour.Instance && MapBehaviour.Instance.isActiveAndEnabled) MapBehaviour.Instance.Close(); }, - returnCurrentMapId() == 3, + PlayerControl.GameOptions.MapId == 3, "ADMIN" ); @@ -551,7 +519,7 @@ public static void Postfix(HudManager __instance) hackerVitalsButton = new CustomButton( () => { - if (returnCurrentMapId() != 1) { + if (PlayerControl.GameOptions.MapId != 1) { if (Hacker.vitals == null) { var e = UnityEngine.Object.FindObjectsOfType().FirstOrDefault(x => x.gameObject.name.Contains("panel_vitals")); if (e == null || Camera.main == null) return; @@ -576,11 +544,11 @@ public static void Postfix(HudManager __instance) Hacker.chargesVitals--; }, - () => { return Hacker.hacker != null && Hacker.hacker == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead && returnCurrentMapId() != 0 && returnCurrentMapId() != 3; }, + () => { return Hacker.hacker != null && Hacker.hacker == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead && PlayerControl.GameOptions.MapId != 0 && PlayerControl.GameOptions.MapId != 3; }, () => { if (hackerVitalsChargesText != null) hackerVitalsChargesText.text = $"{Hacker.chargesVitals} / {Hacker.toolsNumber}"; - hackerVitalsButton.actionButton.graphic.sprite = returnCurrentMapId() == 1 ? Hacker.getLogSprite() : Hacker.getVitalsSprite(); - hackerVitalsButton.actionButton.OverrideText(returnCurrentMapId() == 1 ? "DOORLOG" : "VITALS"); + hackerVitalsButton.actionButton.graphic.sprite = PlayerControl.GameOptions.MapId == 1 ? Hacker.getLogSprite() : Hacker.getVitalsSprite(); + hackerVitalsButton.actionButton.OverrideText(PlayerControl.GameOptions.MapId == 1 ? "DOORLOG" : "VITALS"); return Hacker.chargesVitals > 0; }, () => { @@ -598,7 +566,7 @@ public static void Postfix(HudManager __instance) hackerVitalsButton.Timer = hackerVitalsButton.MaxTimer; if(!hackerAdminTableButton.isEffectActive) PlayerControl.LocalPlayer.moveable = true; if (Minigame.Instance) { - if (returnCurrentMapId() == 1) Hacker.doorLog.ForceClose(); + if (PlayerControl.GameOptions.MapId == 1) Hacker.doorLog.ForceClose(); else Hacker.vitals.ForceClose(); } }, @@ -972,7 +940,7 @@ public static void Postfix(HudManager __instance) RPCProcedure.sealVent(SecurityGuard.ventTarget.Id); SecurityGuard.ventTarget = null; - } else if (returnCurrentMapId() != 1) { // Place camera if there's no vent and it's not MiraHQ + } else if (PlayerControl.GameOptions.MapId != 1) { // Place camera if there's no vent and it's not MiraHQ var pos = PlayerControl.LocalPlayer.transform.position; byte[] buff = new byte[sizeof(float) * 2]; Buffer.BlockCopy(BitConverter.GetBytes(pos.x), 0, buff, 0*sizeof(float), sizeof(float)); @@ -987,12 +955,12 @@ public static void Postfix(HudManager __instance) }, () => { return SecurityGuard.securityGuard != null && SecurityGuard.securityGuard == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead && SecurityGuard.remainingScrews >= Mathf.Min(SecurityGuard.ventPrice, SecurityGuard.camPrice); }, () => { - securityGuardButton.actionButton.graphic.sprite = (SecurityGuard.ventTarget == null && returnCurrentMapId() != 1) ? SecurityGuard.getPlaceCameraButtonSprite() : SecurityGuard.getCloseVentButtonSprite(); + securityGuardButton.actionButton.graphic.sprite = (SecurityGuard.ventTarget == null && PlayerControl.GameOptions.MapId != 1) ? SecurityGuard.getPlaceCameraButtonSprite() : SecurityGuard.getCloseVentButtonSprite(); if (securityGuardButtonScrewsText != null) securityGuardButtonScrewsText.text = $"{SecurityGuard.remainingScrews}/{SecurityGuard.totalScrews}"; if (SecurityGuard.ventTarget != null) return SecurityGuard.remainingScrews >= SecurityGuard.ventPrice && PlayerControl.LocalPlayer.CanMove; - return returnCurrentMapId() != 1 && SecurityGuard.remainingScrews >= SecurityGuard.camPrice && PlayerControl.LocalPlayer.CanMove; + return PlayerControl.GameOptions.MapId != 1 && SecurityGuard.remainingScrews >= SecurityGuard.camPrice && PlayerControl.LocalPlayer.CanMove; }, () => { securityGuardButton.Timer = securityGuardButton.MaxTimer; }, SecurityGuard.getPlaceCameraButtonSprite(), @@ -1012,7 +980,10 @@ public static void Postfix(HudManager __instance) () => { if (PlayerControl.GameOptions.MapId != 1) { if (SecurityGuard.minigame == null) { + byte mapId = PlayerControl.GameOptions.MapId; var e = UnityEngine.Object.FindObjectsOfType().FirstOrDefault(x => x.gameObject.name.Contains("Surv_Panel")); + if (mapId == 0 || mapId == 3) e = UnityEngine.Object.FindObjectsOfType().FirstOrDefault(x => x.gameObject.name.Contains("SurvConsole")); + else if (mapId == 4) e = UnityEngine.Object.FindObjectsOfType().FirstOrDefault(x => x.gameObject.name.Contains("task_cams")); if (e == null || Camera.main == null) return; SecurityGuard.minigame = UnityEngine.Object.Instantiate(e.MinigamePrefab, Camera.main.transform, false); } @@ -1037,8 +1008,8 @@ public static void Postfix(HudManager __instance) () => { return SecurityGuard.securityGuard != null && SecurityGuard.securityGuard == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead && SecurityGuard.remainingScrews < Mathf.Min(SecurityGuard.ventPrice, SecurityGuard.camPrice); }, () => { if (securityGuardChargesText != null) securityGuardChargesText.text = $"{SecurityGuard.charges} / {SecurityGuard.maxCharges}"; - securityGuardCamButton.actionButton.graphic.sprite = returnCurrentMapId() == 1 ? SecurityGuard.getLogSprite() : SecurityGuard.getCamSprite(); - securityGuardCamButton.actionButton.OverrideText(returnCurrentMapId() == 1 ? "DOORLOG" : "SECURITY"); + securityGuardCamButton.actionButton.graphic.sprite = PlayerControl.GameOptions.MapId == 1 ? SecurityGuard.getLogSprite() : SecurityGuard.getCamSprite(); + securityGuardCamButton.actionButton.OverrideText(PlayerControl.GameOptions.MapId == 1 ? "DOORLOG" : "SECURITY"); return PlayerControl.LocalPlayer.CanMove && SecurityGuard.charges > 0; }, () => { @@ -1060,7 +1031,7 @@ public static void Postfix(HudManager __instance) PlayerControl.LocalPlayer.moveable = true; }, false, - returnCurrentMapId() == 1 ? "DOORLOG" : "SECURITY" + PlayerControl.GameOptions.MapId == 1 ? "DOORLOG" : "SECURITY" ); // Security Guard cam button charges diff --git a/TheOtherRoles/Patches/GameStartManagerPatch.cs b/TheOtherRoles/Patches/GameStartManagerPatch.cs index c57b9799f..ee867bddf 100644 --- a/TheOtherRoles/Patches/GameStartManagerPatch.cs +++ b/TheOtherRoles/Patches/GameStartManagerPatch.cs @@ -160,8 +160,7 @@ public static bool Prefix(GameStartManager __instance) { } } - if (CustomOptionHolder.dynamicMap.getBool()) - { + if (CustomOptionHolder.dynamicMap.getBool() && continueStart) { // 0 = Skeld // 1 = Mira HQ // 2 = Polus @@ -169,9 +168,13 @@ public static bool Prefix(GameStartManager __instance) { // 4 = Airship List possibleMaps = new List() { 0, 1, 2, 4 }; chosenMapId = possibleMaps[TheOtherRoles.rnd.Next(possibleMaps.Count)]; + + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.DynamicMapOption, Hazel.SendOption.Reliable, -1); + writer.Write(chosenMapId); + AmongUsClient.Instance.FinishRpcImmediately(writer); + RPCProcedure.dynamicMapOption(chosenMapId); } } - PlayerControl.GameOptions.MapId = chosenMapId; return continueStart; } } diff --git a/TheOtherRoles/Patches/UpdatePatch.cs b/TheOtherRoles/Patches/UpdatePatch.cs index 2a6d923d3..cb4955103 100644 --- a/TheOtherRoles/Patches/UpdatePatch.cs +++ b/TheOtherRoles/Patches/UpdatePatch.cs @@ -198,24 +198,11 @@ static void setNameTags() { // Display lighter / darker color for all alive players if (PlayerControl.LocalPlayer != null && !PlayerControl.LocalPlayer.Data.IsDead) { - if (MeetingHud.Instance != null) { - if (MapOptions.showLighterDarker) - { - foreach (PlayerVoteArea player in MeetingHud.Instance.playerStates) { - var target = Helpers.playerById(player.TargetPlayerId); - if (target != null) player.NameText.text += $" ({(Helpers.isLighterColor(target.Data.DefaultOutfit.ColorId) ? "L" : "D")})"; - } + if (MeetingHud.Instance != null && MapOptions.showLighterDarker) { + foreach (PlayerVoteArea player in MeetingHud.Instance.playerStates) { + var target = Helpers.playerById(player.TargetPlayerId); + if (target != null) player.NameText.text += $" ({(Helpers.isLighterColor(target.Data.DefaultOutfit.ColorId) ? "L" : "D")})"; } - else - { - if (PlayerControl.LocalPlayer == Hacker.hacker || PlayerControl.LocalPlayer == Detective.detective || PlayerControl.LocalPlayer == Medium.medium) - { - foreach (PlayerVoteArea player in MeetingHud.Instance.playerStates) - { - var target = Helpers.playerById(player.TargetPlayerId); - if (target != null) player.NameText.text += $" ({(Helpers.isLighterColor(target.Data.DefaultOutfit.ColorId) ? "L" : "D")})"; - } - } } } } diff --git a/TheOtherRoles/RPC.cs b/TheOtherRoles/RPC.cs index 207a4ffa2..5a0201374 100644 --- a/TheOtherRoles/RPC.cs +++ b/TheOtherRoles/RPC.cs @@ -72,6 +72,7 @@ enum CustomRPC UncheckedMurderPlayer, UncheckedCmdReportDeadBody, UncheckedExilePlayer, + DynamicMapOption, // Role functionality @@ -325,6 +326,10 @@ public static void uncheckedExilePlayer(byte targetId) { if (target != null) target.Exiled(); } + public static void dynamicMapOption(byte mapId) { + PlayerControl.GameOptions.MapId = mapId; + } + // Role functionality public static void engineerFixLights() { @@ -866,6 +871,10 @@ static void Postfix([HarmonyArgument(0)]byte callId, [HarmonyArgument(1)]Message byte reportTarget = reader.ReadByte(); RPCProcedure.uncheckedCmdReportDeadBody(reportSource, reportTarget); break; + case (byte)CustomRPC.DynamicMapOption: + byte mapId = reader.ReadByte(); + RPCProcedure.dynamicMapOption(mapId); + break; // Role functionality From ddcbf83e4ab17d6d0173c643863d1ef01790d777 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mall=C3=B6ris?= <|||||@||.||> Date: Tue, 25 Jan 2022 22:16:12 +0100 Subject: [PATCH 06/12] fixes --- TheOtherRoles/Patches/RoleAssignmentPatch.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TheOtherRoles/Patches/RoleAssignmentPatch.cs b/TheOtherRoles/Patches/RoleAssignmentPatch.cs index b8c6fb847..c642d1c38 100644 --- a/TheOtherRoles/Patches/RoleAssignmentPatch.cs +++ b/TheOtherRoles/Patches/RoleAssignmentPatch.cs @@ -283,7 +283,7 @@ private static void assignDependentRoles(RoleAssignmentData data) { // --- Assign Dependent Roles if main role exists --- if (Sheriff.sheriff != null) { // Deputy if (CustomOptionHolder.deputySpawnRate.getSelection() == 10 && data.crewmates.Count > 0 && data.maxCrewmateRoles > 0) { // Force Deputy - byte deputy = setRoleToRandomPlayer((byte)RoleId.NiceGuesser, data.crewmates); + byte deputy = setRoleToRandomPlayer((byte)RoleId.Deputy, data.crewmates); data.crewmates.ToList().RemoveAll(x => x.PlayerId == deputy); data.maxCrewmateRoles--; } else if (CustomOptionHolder.deputySpawnRate.getSelection() < 10) // Dont force, add Deputy to the ticket system @@ -292,7 +292,7 @@ private static void assignDependentRoles(RoleAssignmentData data) { if (!isEvilGuesser && Guesser.niceGuesser != null) { // Other Guesser (evil) if (CustomOptionHolder.guesserSpawnBothRate.getSelection() == 10 && data.impostors.Count > 0 && data.maxImpostorRoles > 0) { // Force other guesser (evil) byte bothGuesser = setRoleToRandomPlayer((byte)RoleId.EvilGuesser, data.impostors); - data.crewmates.ToList().RemoveAll(x => x.PlayerId == bothGuesser); + data.impostors.ToList().RemoveAll(x => x.PlayerId == bothGuesser); data.maxImpostorRoles--; } else if (CustomOptionHolder.guesserSpawnBothRate.getSelection() < 10) // Dont force, add Guesser (evil) to the ticket system data.impSettings.Add((byte)RoleId.EvilGuesser, CustomOptionHolder.guesserSpawnBothRate.getSelection()); From f5306c6124b1470e3954bdf79dfd6419d87c703d Mon Sep 17 00:00:00 2001 From: K3ndoo <92563515+K3ndoo@users.noreply.github.com> Date: Tue, 25 Jan 2022 22:53:23 +0100 Subject: [PATCH 07/12] Update README.md --- README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 43436f8f8..642fca071 100644 --- a/README.md +++ b/README.md @@ -97,6 +97,13 @@ The [Role Assignment](#role-assignment) sections explains how the roles are bein
Click to show the Changelog +**Version 3.4.1** +- Added a new mod option "Show Lighter/Darker" for meetings +- Fixed a bug where the Bounty Hunter had no bounty +- Fixed a bug where the Guesser & Sheriff were not assigned properly (fingers crossed) +- Fixed a bug where Hacker buttons didn't work as intended with "random map" option +- Fixed a bug where the Security Guard could not access cams on Skeld, dlekS & Airship + **Version 3.4.0** - Added new Role [Deputy](#deputy) thanks [gendelo3](https://github.com/gendelo3) - Added Hacker option "Cant Move During Mobile Gadget Duration" @@ -110,7 +117,6 @@ The [Role Assignment](#role-assignment) sections explains how the roles are bein - Fixed a bug where the spy had a white name for Impostors in chat - Fixed a bug where the Guesser and Swapper UI in meetings was behind the visor cosmetics - **Version 3.3.3** - Fixed a bug where a guessed Guesser could guess - Fixed a bug where buttons were visible during the meeting @@ -566,6 +572,7 @@ The mod adds a few new settings to Among Us (in addition to the role settings): - **Dleks:** You are now able to select the Dleks map. - **Task Counts:** You are now able to select more tasks. - **Role Summary:** When a game ends there will be a list of all players and their roles and their task progress +- **Darker/Lighter:** Displays color type of each player in meetings ### Task Count Limits per map You can configure: From c3c143e65066967ab5fc28f86bd9318b5456e897 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mall=C3=B6ris?= <|||||@||.||> Date: Wed, 26 Jan 2022 17:22:37 +0100 Subject: [PATCH 08/12] configureable dynamic map options --- TheOtherRoles/CustomOptionHolder.cs | 12 ++++++++++++ TheOtherRoles/Patches/GameStartManagerPatch.cs | 15 ++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/TheOtherRoles/CustomOptionHolder.cs b/TheOtherRoles/CustomOptionHolder.cs index c9c80f6fd..556d154e0 100644 --- a/TheOtherRoles/CustomOptionHolder.cs +++ b/TheOtherRoles/CustomOptionHolder.cs @@ -229,7 +229,13 @@ public class CustomOptionHolder { public static CustomOption noVoteIsSelfVote; public static CustomOption hidePlayerNames; public static CustomOption allowParallelMedBayScans; + public static CustomOption dynamicMap; + public static CustomOption dynamicMapEnableSkeld; + public static CustomOption dynamicMapEnableMira; + public static CustomOption dynamicMapEnablePolus; + public static CustomOption dynamicMapEnableDleks; + public static CustomOption dynamicMapEnableAirShip; internal static Dictionary blockedRolePairings = new Dictionary(); @@ -463,7 +469,13 @@ public static void Load() { noVoteIsSelfVote = CustomOption.Create(5, "No Vote Is Self Vote", false, blockSkippingInEmergencyMeetings); hidePlayerNames = CustomOption.Create(6, "Hide Player Names", false); allowParallelMedBayScans = CustomOption.Create(7, "Allow Parallel MedBay Scans", false); + dynamicMap = CustomOption.Create(8, "Play On A Random Map", false, null, false); + dynamicMapEnableSkeld = CustomOption.Create(501, "Enable Skeld Rotation", true, dynamicMap, false); + dynamicMapEnableMira = CustomOption.Create(502, "Enable Mira Rotation", true, dynamicMap, false); + dynamicMapEnablePolus = CustomOption.Create(503, "Enable Polus Rotation", true, dynamicMap, false); + dynamicMapEnableAirShip = CustomOption.Create(504, "Enable Airship Rotation", true, dynamicMap, false); + dynamicMapEnableDleks = CustomOption.Create(505, "Enable dlekS Rotation", false, dynamicMap, false); blockedRolePairings.Add((byte)RoleId.Vampire, new [] { (byte)RoleId.Warlock}); blockedRolePairings.Add((byte)RoleId.Warlock, new [] { (byte)RoleId.Vampire}); diff --git a/TheOtherRoles/Patches/GameStartManagerPatch.cs b/TheOtherRoles/Patches/GameStartManagerPatch.cs index ee867bddf..5229a8123 100644 --- a/TheOtherRoles/Patches/GameStartManagerPatch.cs +++ b/TheOtherRoles/Patches/GameStartManagerPatch.cs @@ -139,7 +139,6 @@ public static bool Prefix(GameStartManager __instance) { // Block game start if not everyone has the same mod version bool continueStart = true; - byte chosenMapId = PlayerControl.GameOptions.MapId; if (AmongUsClient.Instance.AmHost) { foreach (InnerNet.ClientData client in AmongUsClient.Instance.allClients) { if (client.Character == null) continue; @@ -166,8 +165,18 @@ public static bool Prefix(GameStartManager __instance) { // 2 = Polus // 3 = Dleks - deactivated // 4 = Airship - List possibleMaps = new List() { 0, 1, 2, 4 }; - chosenMapId = possibleMaps[TheOtherRoles.rnd.Next(possibleMaps.Count)]; + List possibleMaps = new List(); + if (CustomOptionHolder.dynamicMapEnableSkeld.getBool()) + possibleMaps.Add(0); + if (CustomOptionHolder.dynamicMapEnableMira.getBool()) + possibleMaps.Add(1); + if (CustomOptionHolder.dynamicMapEnablePolus.getBool()) + possibleMaps.Add(2); + if (CustomOptionHolder.dynamicMapEnableDleks.getBool()) + possibleMaps.Add(3); + if (CustomOptionHolder.dynamicMapEnableAirShip.getBool()) + possibleMaps.Add(4); + byte chosenMapId = possibleMaps[TheOtherRoles.rnd.Next(possibleMaps.Count)]; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.DynamicMapOption, Hazel.SendOption.Reliable, -1); writer.Write(chosenMapId); From 9672ab6470d063c2ed99492eef69f9c937f26f1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mall=C3=B6ris?= <|||||@||.||> Date: Wed, 26 Jan 2022 17:30:21 +0100 Subject: [PATCH 09/12] Jester option "has Impostor vision" --- TheOtherRoles/CustomOptionHolder.cs | 4 +++- TheOtherRoles/Patches/ShipStatusPatch.cs | 3 ++- TheOtherRoles/TheOtherRoles.cs | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/TheOtherRoles/CustomOptionHolder.cs b/TheOtherRoles/CustomOptionHolder.cs index 556d154e0..9f70b32ac 100644 --- a/TheOtherRoles/CustomOptionHolder.cs +++ b/TheOtherRoles/CustomOptionHolder.cs @@ -64,6 +64,7 @@ public class CustomOptionHolder { public static CustomOption jesterSpawnRate; public static CustomOption jesterCanCallEmergency; + public static CustomOption jesterHasImpostorVision; public static CustomOption arsonistSpawnRate; public static CustomOption arsonistCooldown; @@ -330,7 +331,8 @@ public static void Load() { guesserCantGuessSnitchIfTaksDone = CustomOption.Create(318, "Guesser Can't Guess Snitch When Tasks Completed", true, guesserSpawnRate); jesterSpawnRate = CustomOption.Create(60, cs(Jester.color, "Jester"), rates, null, true); - jesterCanCallEmergency = CustomOption.Create(61, "Jester can call emergency meeting", true, jesterSpawnRate); + jesterCanCallEmergency = CustomOption.Create(61, "Jester Can Call Emergency Meeting", true, jesterSpawnRate); + jesterCanCallEmergency = CustomOption.Create(62, "Jester Has Impostor Vision", false, jesterSpawnRate); arsonistSpawnRate = CustomOption.Create(290, cs(Arsonist.color, "Arsonist"), rates, null, true); arsonistCooldown = CustomOption.Create(291, "Arsonist Cooldown", 12.5f, 2.5f, 60f, 2.5f, arsonistSpawnRate); diff --git a/TheOtherRoles/Patches/ShipStatusPatch.cs b/TheOtherRoles/Patches/ShipStatusPatch.cs index 23fbcc42e..896239a45 100644 --- a/TheOtherRoles/Patches/ShipStatusPatch.cs +++ b/TheOtherRoles/Patches/ShipStatusPatch.cs @@ -22,7 +22,8 @@ public static bool Prefix(ref float __result, ShipStatus __instance, [HarmonyArg else if (player.Role.IsImpostor || (Jackal.jackal != null && Jackal.jackal.PlayerId == player.PlayerId && Jackal.hasImpostorVision) || (Sidekick.sidekick != null && Sidekick.sidekick.PlayerId == player.PlayerId && Sidekick.hasImpostorVision) - || (Spy.spy != null && Spy.spy.PlayerId == player.PlayerId && Spy.hasImpostorVision)) // Impostor, Jackal/Sidekick or Spy with Impostor vision + || (Spy.spy != null && Spy.spy.PlayerId == player.PlayerId && Spy.hasImpostorVision) + || (Jester.jester != null && Jester.jester.PlayerId == player.PlayerId && Jester.hasImpostorVision)) // Impostor, Jackal/Sidekick, Spy or Jester with Impostor vision __result = __instance.MaxLightRadius * PlayerControl.GameOptions.ImpostorLightMod; else if (Lighter.lighter != null && Lighter.lighter.PlayerId == player.PlayerId && Lighter.lighterTimer > 0f) // if player is Lighter and Lighter has his ability active __result = Mathf.Lerp(__instance.MaxLightRadius * Lighter.lighterModeLightsOffVision, __instance.MaxLightRadius * Lighter.lighterModeLightsOnVision, num); diff --git a/TheOtherRoles/TheOtherRoles.cs b/TheOtherRoles/TheOtherRoles.cs index da9785a8f..298b52e3e 100644 --- a/TheOtherRoles/TheOtherRoles.cs +++ b/TheOtherRoles/TheOtherRoles.cs @@ -68,11 +68,13 @@ public static class Jester { public static bool triggerJesterWin = false; public static bool canCallEmergency = true; + public static bool hasImpostorVision = false; public static void clearAndReload() { jester = null; triggerJesterWin = false; canCallEmergency = CustomOptionHolder.jesterCanCallEmergency.getBool(); + hasImpostorVision = CustomOptionHolder.jesterHasImpostorVision.getBool(); } } From 117e7b46f00bc9e6938e7568221b63eae37e91b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mall=C3=B6ris?= <|||||@||.||> Date: Wed, 26 Jan 2022 17:31:01 +0100 Subject: [PATCH 10/12] changes Tracker update intervall to min 1 --- TheOtherRoles/CustomOptionHolder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TheOtherRoles/CustomOptionHolder.cs b/TheOtherRoles/CustomOptionHolder.cs index 9f70b32ac..1089c27e0 100644 --- a/TheOtherRoles/CustomOptionHolder.cs +++ b/TheOtherRoles/CustomOptionHolder.cs @@ -428,7 +428,7 @@ public static void Load() { hackerNoMove = CustomOption.Create(176, "Cant Move During Mobile Gadget Duration", true, hackerSpawnRate); trackerSpawnRate = CustomOption.Create(200, cs(Tracker.color, "Tracker"), rates, null, true); - trackerUpdateIntervall = CustomOption.Create(201, "Tracker Update Intervall", 5f, 2.5f, 30f, 2.5f, trackerSpawnRate); + trackerUpdateIntervall = CustomOption.Create(201, "Tracker Update Intervall", 5f, 1f, 30f, 1f, trackerSpawnRate); trackerResetTargetAfterMeeting = CustomOption.Create(202, "Tracker Reset Target After Meeting", false, trackerSpawnRate); trackerCanTrackCorpses = CustomOption.Create(203, "Tracker Can Track Corpses", true, trackerSpawnRate); trackerCorpsesTrackingCooldown = CustomOption.Create(204, "Corpses Tracking Cooldown", 30f, 5f, 120f, 5f, trackerCanTrackCorpses); From e2c135eaaa2977909b1450b4e9da32f2b3990cda Mon Sep 17 00:00:00 2001 From: Mallaris <85371585+Mallaris@users.noreply.github.com> Date: Wed, 26 Jan 2022 17:49:50 +0100 Subject: [PATCH 11/12] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 642fca071..64d396175 100644 --- a/README.md +++ b/README.md @@ -103,6 +103,9 @@ The [Role Assignment](#role-assignment) sections explains how the roles are bein - Fixed a bug where the Guesser & Sheriff were not assigned properly (fingers crossed) - Fixed a bug where Hacker buttons didn't work as intended with "random map" option - Fixed a bug where the Security Guard could not access cams on Skeld, dlekS & Airship +- Added options for choosing which maps are enabled for random maps thanks [EvilScum](https://github.com/JustASysAdmin) +- Added Jester option "Jester Has Impostor Vision" thanks [EvilScum](https://github.com/JustASysAdmin) +- Changed Tracker update intervall to a minimum of 1 thanks [LaicosVK](https://github.com/LaicosVK) **Version 3.4.0** - Added new Role [Deputy](#deputy) thanks [gendelo3](https://github.com/gendelo3) From b5c35e62a92b2f697193f4cebc2d32caf620fe00 Mon Sep 17 00:00:00 2001 From: Mallaris <85371585+Mallaris@users.noreply.github.com> Date: Wed, 26 Jan 2022 17:53:07 +0100 Subject: [PATCH 12/12] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 64d396175..164c5d475 100644 --- a/README.md +++ b/README.md @@ -99,12 +99,12 @@ The [Role Assignment](#role-assignment) sections explains how the roles are bein **Version 3.4.1** - Added a new mod option "Show Lighter/Darker" for meetings +- Added options for choosing which maps are enabled for random maps thanks [EvilScum](https://github.com/JustASysAdmin) +- Added Jester option "Jester Has Impostor Vision" thanks [EvilScum](https://github.com/JustASysAdmin) - Fixed a bug where the Bounty Hunter had no bounty - Fixed a bug where the Guesser & Sheriff were not assigned properly (fingers crossed) - Fixed a bug where Hacker buttons didn't work as intended with "random map" option - Fixed a bug where the Security Guard could not access cams on Skeld, dlekS & Airship -- Added options for choosing which maps are enabled for random maps thanks [EvilScum](https://github.com/JustASysAdmin) -- Added Jester option "Jester Has Impostor Vision" thanks [EvilScum](https://github.com/JustASysAdmin) - Changed Tracker update intervall to a minimum of 1 thanks [LaicosVK](https://github.com/LaicosVK) **Version 3.4.0**