From d9f9a18a53a20c4b210c02163183526d2c648857 Mon Sep 17 00:00:00 2001 From: Eisbison Date: Sun, 9 May 2021 17:01:08 +0200 Subject: [PATCH] Hotfix 2.6.1 --- README.md | 8 ++++++++ Source Code/Buttons.cs | 9 ++------ Source Code/CustomColors.cs | 33 ++++++++++++++++++++++++++++++ Source Code/CustomOptions.cs | 25 +++++++++++++++++++++- Source Code/Helpers.cs | 7 +++++++ Source Code/IntroPatch.cs | 3 +-- Source Code/Main.cs | 2 +- Source Code/MeetingPatch.cs | 16 +++++++++++++++ Source Code/RoleAssignmentPatch.cs | 3 +-- Source Code/TheOtherRoles.cs | 2 +- Source Code/TheOtherRoles.csproj | 2 +- 11 files changed, 95 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index d7c6e0f..22a0fd9 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,7 @@ The [Role Assignment](#role-assignment) sections explains how the roles are bein # Releases | Among Us - Version| Mod Version | Link | |----------|-------------|-----------------| +| 2021.4.14s| v2.6.1| [Download](https://github.com/Eisbison/TheOtherRoles/releases/download/v2.6.1/TheOtherRoles.zip) | 2021.4.14s| v2.6.0| [Download](https://github.com/Eisbison/TheOtherRoles/releases/download/v2.6.0/TheOtherRoles.zip) | 2021.4.14s| v2.5.1| [Download](https://github.com/Eisbison/TheOtherRoles/releases/download/v2.5.1/TheOtherRoles.zip) | 2021.4.14s| v2.5.0| [Download](https://github.com/Eisbison/TheOtherRoles/releases/download/v2.5.0/TheOtherRoles.zip) @@ -59,6 +60,12 @@ The [Role Assignment](#role-assignment) sections explains how the roles are bein
Click to show the Changelog +**Version 2.6.1** +- Fixed a bug where the Sheriff was unable to kill the Arsonist +- Fixed a bug in the role assignment system +- Added the option to select the Dleks map +- Improved the overlay of the Arsonist + **Version 2.6.0** - **New Role:** [Arsonist](#arsonist) - Added an Ingame Updater, to make it easier to update the Mod @@ -327,6 +334,7 @@ The mod adds a few new settings to Among Us (in addition to the role settings): - **Allow Skips On Emergency Meetings:** If set to false, there will not be a skip button in emergency meetings. If a player does not vote, he'll vote himself. - **Hide Player Names:** Hides the names of all players that have role which is unknown to you. Team Lovers/Impostors/Jackal still see the names of their teammates. Impostors can alse see the name of the Spy and everyone can still see the age of the child. - **Ghosts Can See Roles And Remaining Tasks:** If set to true, ghosts can see the role and the number of remaining tasks of each player. +- **Dleks:** You are now able to select the Dleks map. # Custom Hats ## Create and submit new hat designs diff --git a/Source Code/Buttons.cs b/Source Code/Buttons.cs index 3fb0eeb..bfb4638 100644 --- a/Source Code/Buttons.cs +++ b/Source Code/Buttons.cs @@ -174,7 +174,7 @@ namespace TheOtherRoles byte targetId = 0; if ((Sheriff.currentTarget.Data.IsImpostor && (Sheriff.currentTarget != Child.child || Child.isGrownUp())) || (Sheriff.spyCanDieToSheriff && Spy.spy == Sheriff.currentTarget) || - (Sheriff.canKillNeutrals && (Jester.jester == Sheriff.currentTarget || Jackal.jackal == Sheriff.currentTarget || Sidekick.sidekick == Sheriff.currentTarget))) { + (Sheriff.canKillNeutrals && (Arsonist.arsonist == Sheriff.currentTarget || Jester.jester == Sheriff.currentTarget || Jackal.jackal == Sheriff.currentTarget || Sidekick.sidekick == Sheriff.currentTarget))) { targetId = Sheriff.currentTarget.PlayerId; } else { @@ -768,14 +768,9 @@ namespace TheOtherRoles Arsonist.douseTarget = null; arsonistButton.Timer = Arsonist.dousedEveryoneAlive() ? 0 : arsonistButton.MaxTimer; - int playerCounter = 0; - Vector3 bottomLeft = new Vector3(-HudManager.Instance.UseButton.transform.localPosition.x, HudManager.Instance.UseButton.transform.localPosition.y, HudManager.Instance.UseButton.transform.localPosition.z); - bottomLeft += new Vector3(-0.25f, -0.25f, 0); foreach (PlayerControl p in Arsonist.dousedPlayers) { if (Arsonist.dousedIcons.ContainsKey(p.PlayerId)) { - Arsonist.dousedIcons[p.PlayerId].gameObject.SetActive(true); - Arsonist.dousedIcons[p.PlayerId].transform.localPosition = bottomLeft + Vector3.right * playerCounter * 0.35f; - playerCounter++; + Arsonist.dousedIcons[p.PlayerId].setSemiTransparent(false); } } } diff --git a/Source Code/CustomColors.cs b/Source Code/CustomColors.cs index cc1e49d..cab1fbc 100644 --- a/Source Code/CustomColors.cs +++ b/Source Code/CustomColors.cs @@ -163,6 +163,39 @@ namespace TheOtherRoles { } } } + [HarmonyPatch(typeof(SaveManager), nameof(SaveManager.LoadPlayerPrefs))] + private static class LoadPlayerPrefsPatch { // Fix Potential issues with broken colors + private static bool needsPatch = false; + public static void Prefix([HarmonyArgument(0)] bool overrideLoad) { + if (!SaveManager.loaded || overrideLoad) + needsPatch = true; + } + public static void Postfix() { + if (!needsPatch) return; + SaveManager.colorConfig %= (uint)CustomColors.pickableColors; + needsPatch = false; + } + } + [HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.CheckColor))] + private static class PlayerControlCheckColorPatch { + private static bool isTaken(PlayerControl player, uint color) { + foreach (GameData.PlayerInfo p in GameData.Instance.AllPlayers) + if (!p.Disconnected && p.PlayerId != player.PlayerId && p.ColorId == color) + return true; + return false; + } + public static bool Prefix(PlayerControl __instance, [HarmonyArgument(0)] byte bodyColor) { // Fix incorrect color assignment + uint color = (uint)bodyColor; + if (isTaken(__instance, color) || color >= Palette.PlayerColors.Length) { + int num = 0; + while (num++ < 50 && (color >= CustomColors.pickableColors || isTaken(__instance, color))) { + color = (color + 1) % (uint)CustomColors.pickableColors; + } + } + __instance.RpcSetColor((byte)color); + return false; + } + } } } } diff --git a/Source Code/CustomOptions.cs b/Source Code/CustomOptions.cs index c777838..9fa7986 100644 --- a/Source Code/CustomOptions.cs +++ b/Source Code/CustomOptions.cs @@ -229,7 +229,7 @@ namespace TheOtherRoles { sheriffSpawnRate = CustomOption.Create(100, cs(Sheriff.color, "Sheriff"), rates, null, true); sheriffCooldown = CustomOption.Create(101, "Sheriff Cooldown", 30f, 10f, 60f, 2.5f, sheriffSpawnRate); - sheriffCanKillNeutrals = CustomOption.Create(102, "Neutrals Can Kill The Jester", false, sheriffSpawnRate); + sheriffCanKillNeutrals = CustomOption.Create(102, "Sheriff Can Kill Neutrals", false, sheriffSpawnRate); lighterSpawnRate = CustomOption.Create(110, cs(Lighter.color, "Lighter"), rates, null, true); @@ -510,6 +510,29 @@ namespace TheOtherRoles { public static void Prefix(GameSettingMenu __instance) { __instance.HideForOnline = new Transform[]{}; } + + public static void Postfix(GameSettingMenu __instance) { + var mapNameTransform = __instance.AllItems.FirstOrDefault(x => x.gameObject.activeSelf && x.name.Equals("MapName", StringComparison.OrdinalIgnoreCase)); + if (mapNameTransform == null) return; + + var options = new Il2CppSystem.Collections.Generic.List>(); + for (int i = 0; i < GameOptionsData.MapNames.Length; i++) { + var kvp = new Il2CppSystem.Collections.Generic.KeyValuePair(); + kvp.key = GameOptionsData.MapNames[i]; + kvp.value = i; + options.Add(kvp); + } + mapNameTransform.GetComponent().Values = options; + } + } + + [HarmonyPatch(typeof(Constants), nameof(Constants.ShouldFlipSkeld))] + class ConstantsShouldFlipSkeldPatch { + public static bool Prefix(ref bool __result) { + if (PlayerControl.GameOptions == null) return true; + __result = PlayerControl.GameOptions.MapId == 3; + return false; + } } [HarmonyPatch] diff --git a/Source Code/Helpers.cs b/Source Code/Helpers.cs index 786aa00..8e0f346 100644 --- a/Source Code/Helpers.cs +++ b/Source Code/Helpers.cs @@ -192,6 +192,13 @@ namespace TheOtherRoles { player.Data.Tasks.Clear(); } + public static void setSemiTransparent(this PoolablePlayer player, bool value) { + float alpha = value ? 0.25f : 1f; + foreach (SpriteRenderer r in player.gameObject.GetComponentsInChildren()) + r.color = new Color(r.color.r, r.color.g, r.color.b, alpha); + player.NameText.color = new Color(player.NameText.color.r, player.NameText.color.g, player.NameText.color.b, alpha); + } + public static string cs(Color c, string s) { return string.Format("{4}", ToByte(c.r), ToByte(c.g), ToByte(c.b), ToByte(c.a), s); } diff --git a/Source Code/IntroPatch.cs b/Source Code/IntroPatch.cs index 910d619..c95696a 100644 --- a/Source Code/IntroPatch.cs +++ b/Source Code/IntroPatch.cs @@ -27,8 +27,7 @@ namespace TheOtherRoles PlayerControl.SetPetImage(data.PetId, data.ColorId, poolablePlayer.PetSlot); poolablePlayer.NameText.text = data.PlayerName; poolablePlayer.SetFlipX(true); - poolablePlayer.gameObject.SetActive(false); - + poolablePlayer.setSemiTransparent(true); Arsonist.dousedIcons[player.PlayerId] = poolablePlayer; playerCounter++; } diff --git a/Source Code/Main.cs b/Source Code/Main.cs index c5e5056..a51e8db 100644 --- a/Source Code/Main.cs +++ b/Source Code/Main.cs @@ -19,7 +19,7 @@ namespace TheOtherRoles public class TheOtherRolesPlugin : BasePlugin { public const string Id = "me.eisbison.theotherroles"; - public const string VersionString = "2.6.0"; + public const string VersionString = "2.6.1"; public static System.Version Version = System.Version.Parse(VersionString); public Harmony Harmony { get; } = new Harmony(Id); diff --git a/Source Code/MeetingPatch.cs b/Source Code/MeetingPatch.cs index 43eb832..f65d4c8 100644 --- a/Source Code/MeetingPatch.cs +++ b/Source Code/MeetingPatch.cs @@ -485,6 +485,22 @@ namespace TheOtherRoles } Seer.deadBodyPositions = new List(); } + + // Arsonist deactivate dead poolable players + if (Arsonist.arsonist != null && Arsonist.arsonist == PlayerControl.LocalPlayer) { + int visibleCounter = 0; + Vector3 bottomLeft = new Vector3(-HudManager.Instance.UseButton.transform.localPosition.x, HudManager.Instance.UseButton.transform.localPosition.y, HudManager.Instance.UseButton.transform.localPosition.z); + bottomLeft += new Vector3(-0.25f, -0.25f, 0); + foreach (PlayerControl p in PlayerControl.AllPlayerControls) { + if (!Arsonist.dousedIcons.ContainsKey(p.PlayerId)) continue; + if (p.Data.IsDead || p.Data.Disconnected) { + Arsonist.dousedIcons[p.PlayerId].gameObject.SetActive(true); + } else { + Arsonist.dousedIcons[p.PlayerId].transform.localPosition = bottomLeft + Vector3.right * visibleCounter * 0.35f; + visibleCounter++; + } + } + } } } } diff --git a/Source Code/RoleAssignmentPatch.cs b/Source Code/RoleAssignmentPatch.cs index ef7ec1d..34a4dbb 100644 --- a/Source Code/RoleAssignmentPatch.cs +++ b/Source Code/RoleAssignmentPatch.cs @@ -81,7 +81,6 @@ namespace TheOtherRoles crewSettings.Add((byte)RoleId.Hacker, CustomOptionHolder.hackerSpawnRate.getSelection()); crewSettings.Add((byte)RoleId.Tracker, CustomOptionHolder.trackerSpawnRate.getSelection()); crewSettings.Add((byte)RoleId.Snitch, CustomOptionHolder.snitchSpawnRate.getSelection()); - crewSettings.Add((byte)RoleId.Jackal, CustomOptionHolder.jackalSpawnRate.getSelection()); if (impostors.Count > 1) // Spy is useless with less than 2 Impostors crewSettings.Add((byte)RoleId.Spy, CustomOptionHolder.spySpawnRate.getSelection()); crewSettings.Add((byte)RoleId.SecurityGuard, CustomOptionHolder.securityGuardSpawnRate.getSelection()); @@ -139,7 +138,7 @@ namespace TheOtherRoles } } } else { // Other - for (int j = 0; j < entry.Value; j++) crewTickets.Add(entry.Key); + for (int j = 0; j < entry.Value; j++) neutralTickets.Add(entry.Key); } } diff --git a/Source Code/TheOtherRoles.cs b/Source Code/TheOtherRoles.cs index 644b85b..067c9b3 100644 --- a/Source Code/TheOtherRoles.cs +++ b/Source Code/TheOtherRoles.cs @@ -893,7 +893,7 @@ namespace TheOtherRoles } public static bool dousedEveryoneAlive() { - return PlayerControl.AllPlayerControls.ToArray().All(x => { return x == Arsonist.arsonist || x.Data.IsDead || Arsonist.dousedPlayers.Any(y => y.PlayerId == x.PlayerId); }); + return PlayerControl.AllPlayerControls.ToArray().All(x => { return x == Arsonist.arsonist || x.Data.IsDead || x.Data.Disconnected || Arsonist.dousedPlayers.Any(y => y.PlayerId == x.PlayerId); }); } public static void clearAndReload() { diff --git a/Source Code/TheOtherRoles.csproj b/Source Code/TheOtherRoles.csproj index 30d409d..ac8e6a2 100644 --- a/Source Code/TheOtherRoles.csproj +++ b/Source Code/TheOtherRoles.csproj @@ -1,7 +1,7 @@ netstandard2.1 - 2.6.0 + 2.6.1 TheOtherRoles Eisbison -- 2.39.5