From 11839697f395bf36af697e3334be5514dc7409ac Mon Sep 17 00:00:00 2001 From: Eisbison Date: Wed, 14 Apr 2021 19:19:51 +0200 Subject: [PATCH] Version 2.2.1 --- README.md | 8 +++++++ Source Code/Buttons.cs | 2 +- Source Code/CredentialsPatch.cs | 2 +- Source Code/Footprint.cs | 2 +- Source Code/GameStartManagerPatch.cs | 31 ++++++++++++++-------------- Source Code/Helpers.cs | 4 +++- Source Code/JackInTheBox.cs | 2 +- Source Code/Main.cs | 4 ++-- Source Code/MeetingPatch.cs | 2 +- Source Code/PlayerControlPatch.cs | 17 +++++++++++---- Source Code/RPC.cs | 24 ++++++++++++++------- Source Code/TheOtherRoles.cs | 9 ++++++++ Source Code/TheOtherRoles.csproj | 3 ++- Source Code/UsablesPatch.cs | 10 +++++++-- 14 files changed, 82 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index ec32fc3..c243bb1 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,7 @@ The [Role Assignment](#role-assignment) sections explains how the roles are bein # Releases | Among Us - Version| Mod Version | Link | |----------|-------------|-----------------| +| 2021.4.12s| v2.2.1| [Download](https://github.com/Eisbison/TheOtherRoles/releases/download/v2.2.1/TheOtherRoles.zip) | 2021.4.12s| v2.2.0| [Download](https://github.com/Eisbison/TheOtherRoles/releases/download/v2.2.0/TheOtherRoles.zip) | 2021.3.31.3s| v2.1.0| [Download](https://github.com/Eisbison/TheOtherRoles/releases/download/v2.1.0/TheOtherRoles.zip) | 2021.3.31.3s| v2.0.1 beta| [Download](https://github.com/Eisbison/TheOtherRoles/releases/download/v2.0.1/TheOtherRoles.zip) @@ -65,6 +66,13 @@ The [Role Assignment](#role-assignment) sections explains how the roles are bein
Click to show the Changelog +**Version 2.2.1** +- Trickster: The vent button now has a custom texture. Fixed a bug where the Trickster could clip out of bounds when his box was close to a wall. +- Fixed a bug where the Bad Child's kill button went on cooldown when someone else performed a kill +- Fixed a few bugs with footprints, Seer souls and the Vampire delayed kill +- Fixed a bug where the Child was banned for hacking (because of its reduced kill cooldown) +- Improved the version handshake + **Version 2.2.0** - **Works with the latest Among Us version (2021.4.12s)** - **Added support for 10+ player lobbies on custom servers:** Check the [Custom Servers and 10+ Players](#Custom-Servers-and-10+-Players) section. During meetings use the up/down keys, on vitals use the left/right keys. diff --git a/Source Code/Buttons.cs b/Source Code/Buttons.cs index 3d4f6b8..dd0ed07 100644 --- a/Source Code/Buttons.cs +++ b/Source Code/Buttons.cs @@ -362,7 +362,7 @@ namespace TheOtherRoles AmongUsClient.Instance.FinishRpcImmediately(writer); RPCProcedure.vampireSetBitten(Vampire.bitten.PlayerId, 0); - PlayerControl.LocalPlayer.StartCoroutine(Effects.DCHLMIDMBHG(Vampire.delay, new Action((p) => { // Delayed action + HudManager.CHNDKKBEIDG.StartCoroutine(Effects.DCHLMIDMBHG(Vampire.delay, new Action((p) => { // Delayed action if (p == 1f) { if (Vampire.bitten != null && !Vampire.bitten.PPMOEEPBHJO.IAGJEKLJCCI && Helpers.handleMurderAttempt(Vampire.bitten)) { // Perform kill diff --git a/Source Code/CredentialsPatch.cs b/Source Code/CredentialsPatch.cs index cdc0742..490d344 100644 --- a/Source Code/CredentialsPatch.cs +++ b/Source Code/CredentialsPatch.cs @@ -15,7 +15,7 @@ namespace TheOtherRoles { static void Postfix(VersionShower __instance) { string spacer = new String('\n', 21); - string fullCredentials = $"TheOtherRoles v{TheOtherRolesPlugin.Major}.{TheOtherRolesPlugin.Minor}.{TheOtherRolesPlugin.Patch}:\n- Modded by TheOtherRoles and Thunderstorm584\n- Balanced with Dhalucard\n- Button design by Bavari"; + string fullCredentials = $"TheOtherRoles v{TheOtherRolesPlugin.Major}.{TheOtherRolesPlugin.Minor}.{TheOtherRolesPlugin.Patch}:\n- Modded by Eisbison and Thunderstorm584\n- Balanced with Dhalucard\n- Button design by Bavari"; if (__instance.text.text.Contains(spacer)) __instance.text.text += "\n" + fullCredentials; else diff --git a/Source Code/Footprint.cs b/Source Code/Footprint.cs index 85246dc..3aa7143 100644 --- a/Source Code/Footprint.cs +++ b/Source Code/Footprint.cs @@ -47,7 +47,7 @@ namespace TheOtherRoles{ footprint.SetActive(true); footprints.Add(this); - PlayerControl.LocalPlayer.StartCoroutine(Effects.DCHLMIDMBHG(footprintDuration, new Action((p) => { + HudManager.CHNDKKBEIDG.StartCoroutine(Effects.DCHLMIDMBHG(footprintDuration, new Action((p) => { Color c = color; if (!anonymousFootprints && owner != null) { if (owner == Morphling.morphling && Morphling.morphTimer > 0 && Morphling.morphTarget?.PPMOEEPBHJO != null) diff --git a/Source Code/GameStartManagerPatch.cs b/Source Code/GameStartManagerPatch.cs index 225c61e..3635852 100644 --- a/Source Code/GameStartManagerPatch.cs +++ b/Source Code/GameStartManagerPatch.cs @@ -9,17 +9,15 @@ using Palette = BLMBFIODBKL; namespace TheOtherRoles { public class GameStartManagerPatch { - public static Dictionary> playerVersions = new Dictionary>(); + public static Dictionary> playerVersions = new Dictionary>(); private static float timer = 600f; private static bool versionSent = false; [HarmonyPatch(typeof(GameStartManager), nameof(GameStartManager.Start))] public class GameStartManagerStartPatch { public static void Postfix() { - // Refresh version infos - playerVersions = new Dictionary>(); + // Trigger version refresh versionSent = false; - // Reset lobby countdown timer timer = 600f; } @@ -43,25 +41,26 @@ namespace TheOtherRoles { writer.Write(TheOtherRolesPlugin.Major); writer.Write(TheOtherRolesPlugin.Minor); writer.Write(TheOtherRolesPlugin.Patch); - writer.Write(PlayerControl.LocalPlayer.PlayerId); + writer.WritePacked(AmongUsClient.Instance.ClientId); AmongUsClient.Instance.FinishRpcImmediately(writer); - RPCProcedure.versionHandshake(TheOtherRolesPlugin.Major, TheOtherRolesPlugin.Minor, TheOtherRolesPlugin.Patch, PlayerControl.LocalPlayer.PlayerId); + RPCProcedure.versionHandshake(TheOtherRolesPlugin.Major, TheOtherRolesPlugin.Minor, TheOtherRolesPlugin.Patch, AmongUsClient.Instance.ClientId); } // Host update with version handshake infos if (AmongUsClient.Instance.HHBLOCGKFAB) { bool blockStart = false; string message = ""; - foreach (PlayerControl player in PlayerControl.AllPlayerControls) { - var dummyComponent = player.GetComponent(); + foreach (InnerNet.ClientData client in AmongUsClient.Instance.allClients) { + if (client.Character == null) continue; + var dummyComponent = client.Character.GetComponent(); if (dummyComponent != null && dummyComponent.enabled) continue; - else if (!playerVersions.ContainsKey(player.PlayerId)) { + else if (!playerVersions.ContainsKey(client.Id)) { blockStart = true; - message += $"{player.PPMOEEPBHJO.PCLLABJCIPC} has an outdated or no version of The Other Roles\n"; - } else if (playerVersions[player.PlayerId].Item1 != TheOtherRolesPlugin.Major || playerVersions[player.PlayerId].Item2 != TheOtherRolesPlugin.Minor || playerVersions[player.PlayerId].Item3 != TheOtherRolesPlugin.Patch) { + message += $"{client.Character.PPMOEEPBHJO.PCLLABJCIPC} has an outdated or no version of The Other Roles\n"; + } else if (playerVersions[client.Id].Item1 != TheOtherRolesPlugin.Major || playerVersions[client.Id].Item2 != TheOtherRolesPlugin.Minor || playerVersions[client.Id].Item3 != TheOtherRolesPlugin.Patch) { blockStart = true; - message += $"{player.PPMOEEPBHJO.PCLLABJCIPC} has an outdated version (v{playerVersions[player.PlayerId].Item1}.{playerVersions[player.PlayerId].Item2}.{playerVersions[player.PlayerId].Item3}) of The Other Roles\n"; + message += $"{client.Character.PPMOEEPBHJO.PCLLABJCIPC} has an outdated version (v{playerVersions[client.Id].Item1}.{playerVersions[client.Id].Item2}.{playerVersions[client.Id].Item3}) of The Other Roles\n"; } } if (blockStart) { @@ -97,11 +96,11 @@ namespace TheOtherRoles { // Allow the start for this version to test the feature, blocking it with the next version // if (AmongUsClient.Instance.HHBLOCGKFAB) { - // uint hostVersion = Convert.ToUInt32(TheOtherRolesPlugin.Version.Replace(".", string.Empty)); - // foreach (PlayerControl player in PlayerControl.AllPlayerControls) { - // var dummyComponent = player.GetComponent(); + // foreach (InnerNet.ClientData client in AmongUsClient.Instance.allClients) { + // if (client.Character == null) continue; + // var dummyComponent = client.Character.GetComponent(); // if (dummyComponent != null && dummyComponent.enabled) continue; - // if (!playerVersions.ContainsKey(player.PlayerId) || (playerVersions[player.PlayerId].Item1 != TheOtherRolesPlugin.Major || playerVersions[player.PlayerId].Item2 != TheOtherRolesPlugin.Minor || playerVersions[player.PlayerId].Item3 != TheOtherRolesPlugin.Patch)) + // if (!playerVersions.ContainsKey(client.Id) || (playerVersions[client.Id].Item1 != TheOtherRolesPlugin.Major || playerVersions[client.Id].Item2 != TheOtherRolesPlugin.Minor || playerVersions[client.Id].Item3 != TheOtherRolesPlugin.Patch)) // continueStart = false; // } // } diff --git a/Source Code/Helpers.cs b/Source Code/Helpers.cs index abeb1c1..ffb894a 100644 --- a/Source Code/Helpers.cs +++ b/Source Code/Helpers.cs @@ -170,7 +170,9 @@ namespace TheOtherRoles { } public static bool isCustomServer() { - return DestroyableSingleton.CHNDKKBEIDG?.KEABFOHAECE == TheOtherRolesPlugin.Ip.Value; + if (DestroyableSingleton.CHNDKKBEIDG == null) return false; + StringNames n = DestroyableSingleton.CHNDKKBEIDG.HMIJGFFKBNN.TranslateName; + return n != StringNames.ServerNA && n != StringNames.ServerEU && n != StringNames.ServerAS; } public static string cs(Color c, string s) { diff --git a/Source Code/JackInTheBox.cs b/Source Code/JackInTheBox.cs index 3e28d7b..8b379c9 100644 --- a/Source Code/JackInTheBox.cs +++ b/Source Code/JackInTheBox.cs @@ -24,7 +24,7 @@ namespace TheOtherRoles{ public JackInTheBox(Vector2 p) { gameObject = new GameObject("JackInTheBox"); Vector3 position = new Vector3(p.x, p.y, PlayerControl.LocalPlayer.transform.position.z + 1f); - + position += (Vector3)PlayerControl.LocalPlayer.Collider.offset; // add Player Collider offset as this gets subtracted again on Vent.DoMove // Create the marker gameObject.transform.position = position; var boxRenderer = gameObject.AddComponent(); diff --git a/Source Code/Main.cs b/Source Code/Main.cs index f0ee5ae..996a591 100644 --- a/Source Code/Main.cs +++ b/Source Code/Main.cs @@ -19,10 +19,10 @@ namespace TheOtherRoles public class TheOtherRolesPlugin : BasePlugin { public const string Id = "me.eisbison.theotherroles"; - public const string Version = "2.2.0"; + public const string Version = "2.2.1"; public const byte Major = 2; public const byte Minor = 2; - public const byte Patch = 0; + public const byte Patch = 1; public Harmony Harmony { get; } = new Harmony(Id); public static TheOtherRolesPlugin Instance; diff --git a/Source Code/MeetingPatch.cs b/Source Code/MeetingPatch.cs index 04bdd23..e4e3e84 100644 --- a/Source Code/MeetingPatch.cs +++ b/Source Code/MeetingPatch.cs @@ -416,7 +416,7 @@ namespace TheOtherRoles rend.sprite = Seer.getSoulSprite(); if(Seer.limitSoulDuration) { - PlayerControl.LocalPlayer.StartCoroutine(Effects.DCHLMIDMBHG(Seer.soulDuration, new Action((p) => { + HudManager.CHNDKKBEIDG.StartCoroutine(Effects.DCHLMIDMBHG(Seer.soulDuration, new Action((p) => { if (rend != null) { var tmp = rend.color; tmp.a = Mathf.Clamp01(1 - p); diff --git a/Source Code/PlayerControlPatch.cs b/Source Code/PlayerControlPatch.cs index 48f66ce..7b66e45 100644 --- a/Source Code/PlayerControlPatch.cs +++ b/Source Code/PlayerControlPatch.cs @@ -335,10 +335,19 @@ namespace TheOtherRoles { } } [HarmonyPatch(typeof(KillButtonManager), nameof(KillButtonManager.PerformKill))] - class PerformKillPatch - { + class PerformKillPatch { public static bool Prefix(KillButtonManager __instance) { - return Helpers.handleMurderAttempt(__instance.CurrentTarget); + if (__instance.isActiveAndEnabled && __instance.CurrentTarget && !__instance.isCoolingDown && !PlayerControl.LocalPlayer.PPMOEEPBHJO.IAGJEKLJCCI && PlayerControl.LocalPlayer.POECPOEKKNO) { // Among Us default checks + if (Helpers.handleMurderAttempt(__instance.CurrentTarget)) { // Custom checks + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.UncheckedMurderPlayer, Hazel.SendOption.Reliable, -1); + writer.Write(PlayerControl.LocalPlayer.PlayerId); + writer.Write(__instance.CurrentTarget.PlayerId); + AmongUsClient.Instance.FinishRpcImmediately(writer); + RPCProcedure.uncheckedMurderPlayer(PlayerControl.LocalPlayer.PlayerId, __instance.CurrentTarget.PlayerId); + __instance.SetTarget(null); + } + } + return false; } } @@ -448,7 +457,7 @@ namespace TheOtherRoles { if (Seer.deadBodyPositions != null) Seer.deadBodyPositions.Add(DGDGDKCCKHJ.transform.position); // Child set adapted kill cooldown - if (Child.child != null && PlayerControl.LocalPlayer == Child.child && Child.child.PPMOEEPBHJO.FDNMBJOAPFL) { + if (Child.child != null && PlayerControl.LocalPlayer == Child.child && Child.child.PPMOEEPBHJO.FDNMBJOAPFL && Child.child == __instance) { var multiplier = Child.isGrownUp() ? 0.66f : 2f; Child.child.SetKillTimer(PlayerControl.GameOptions.DGOPNLEEAAJ * multiplier); } diff --git a/Source Code/RPC.cs b/Source Code/RPC.cs index e182f41..d1e2861 100644 --- a/Source Code/RPC.cs +++ b/Source Code/RPC.cs @@ -59,6 +59,7 @@ namespace TheOtherRoles SetUncheckedColor, VersionHandshake, UseUncheckedVent, + UncheckedMurderPlayer, // Role functionality @@ -217,10 +218,8 @@ namespace TheOtherRoles if (player != null) player.SetColor(colorId); } - public static void versionHandshake(byte major, byte minor, byte patch, byte playerId) { - if (AmongUsClient.Instance.HHBLOCGKFAB) { // If lobby host - GameStartManagerPatch.playerVersions[playerId] = new Tuple(major, minor, patch); - } + public static void versionHandshake(byte major, byte minor, byte patch, int clientId) { + GameStartManagerPatch.playerVersions[clientId] = new Tuple(major, minor, patch); } public static void useUncheckedVent(int ventId, byte playerId, byte isEnter) { @@ -236,6 +235,12 @@ namespace TheOtherRoles player.MyPhysics.HandleRpc(isEnter != 0 ? (byte)19 : (byte)20, reader); } + public static void uncheckedMurderPlayer(byte sourceId, byte targetId) { + PlayerControl source = Helpers.playerById(sourceId); + PlayerControl target = Helpers.playerById(targetId); + if (source != null && target != null) source.MurderPlayer(target); + } + // Role functionality public static void engineerFixLights() { @@ -273,7 +278,7 @@ namespace TheOtherRoles } HudManager.CHNDKKBEIDG.FullScreen.color = new Color(0f, 0.5f, 0.8f, 0.3f); HudManager.CHNDKKBEIDG.FullScreen.enabled = true; - PlayerControl.LocalPlayer.StartCoroutine(Effects.DCHLMIDMBHG(TimeMaster.rewindTime / 2, new Action((p) => { + HudManager.CHNDKKBEIDG.StartCoroutine(Effects.DCHLMIDMBHG(TimeMaster.rewindTime / 2, new Action((p) => { if (p == 1f) HudManager.CHNDKKBEIDG.FullScreen.enabled = false; }))); @@ -307,7 +312,7 @@ namespace TheOtherRoles public static void timeMasterShield() { TimeMaster.shieldActive = true; - PlayerControl.LocalPlayer.StartCoroutine(Effects.DCHLMIDMBHG(TimeMaster.shieldDuration, new Action((p) => { + HudManager.CHNDKKBEIDG.StartCoroutine(Effects.DCHLMIDMBHG(TimeMaster.shieldDuration, new Action((p) => { if (p == 1f) TimeMaster.shieldActive = false; }))); } @@ -627,7 +632,7 @@ namespace TheOtherRoles byte major = JIGFBHFFNFI.ReadByte(); byte minor = JIGFBHFFNFI.ReadByte(); byte patch = JIGFBHFFNFI.ReadByte(); - byte versionOwnerId = JIGFBHFFNFI.ReadByte(); + int versionOwnerId = JIGFBHFFNFI.ReadPackedInt32(); RPCProcedure.versionHandshake(major, minor, patch, versionOwnerId); break; case (byte)CustomRPC.UseUncheckedVent: @@ -636,6 +641,11 @@ namespace TheOtherRoles byte isEnter = JIGFBHFFNFI.ReadByte(); RPCProcedure.useUncheckedVent(ventId, ventingPlayer, isEnter); break; + case (byte)CustomRPC.UncheckedMurderPlayer: + byte source = JIGFBHFFNFI.ReadByte(); + byte target = JIGFBHFFNFI.ReadByte(); + RPCProcedure.uncheckedMurderPlayer(source, target); + break; // Role functionality diff --git a/Source Code/TheOtherRoles.cs b/Source Code/TheOtherRoles.cs index 7a63134..02177bd 100644 --- a/Source Code/TheOtherRoles.cs +++ b/Source Code/TheOtherRoles.cs @@ -709,17 +709,26 @@ namespace TheOtherRoles private static Sprite placeBoxButtonSprite; private static Sprite lightOutButtonSprite; + private static Sprite tricksterVentButtonSprite; + public static Sprite getPlaceBoxButtonSprite() { if (placeBoxButtonSprite) return placeBoxButtonSprite; placeBoxButtonSprite = Helpers.loadSpriteFromResources("TheOtherRoles.Resources.PlaceJackInTheBoxButton.png", 115f); return placeBoxButtonSprite; } + public static Sprite getLightsOutButtonSprite() { if (lightOutButtonSprite) return lightOutButtonSprite; lightOutButtonSprite = Helpers.loadSpriteFromResources("TheOtherRoles.Resources.LightsOutButton.png", 115f); return lightOutButtonSprite; } + public static Sprite getTricksterVentButtonSprite() { + if (tricksterVentButtonSprite) return tricksterVentButtonSprite; + tricksterVentButtonSprite = Helpers.loadSpriteFromResources("TheOtherRoles.Resources.TricksterVentButton.png", 115f); + return tricksterVentButtonSprite; + } + public static void clearAndReload() { trickster = null; lightsOutTimer = 0f; diff --git a/Source Code/TheOtherRoles.csproj b/Source Code/TheOtherRoles.csproj index c28ef65..81fd962 100644 --- a/Source Code/TheOtherRoles.csproj +++ b/Source Code/TheOtherRoles.csproj @@ -1,7 +1,7 @@ netstandard2.1 - 2.2.0 + 2.2.1 TheOtherRoles Eisbison @@ -33,6 +33,7 @@ + diff --git a/Source Code/UsablesPatch.cs b/Source Code/UsablesPatch.cs index 1b7f715..c2ad464 100644 --- a/Source Code/UsablesPatch.cs +++ b/Source Code/UsablesPatch.cs @@ -101,12 +101,18 @@ namespace TheOtherRoles [HarmonyPatch(typeof(UseButtonManager), nameof(UseButtonManager.SetTarget))] class UseButtonSetTargetPatch { static void Postfix(UseButtonManager __instance) { - if (__instance.LHAKKAAOLLM != null) return; + // Trickster render special vent button + if (__instance.LHAKKAAOLLM != null && Trickster.trickster != null && Trickster.trickster == PlayerControl.LocalPlayer) { + Vent possibleVent = __instance.LHAKKAAOLLM.TryCast(); + if (possibleVent?.gameObject != null && possibleVent.gameObject.name.StartsWith("JackInTheBoxVent_")) { + __instance.UseButton.sprite = Trickster.getTricksterVentButtonSprite(); + } + } // Mafia sabotage button render patch bool blockSabotageJanitor = (Janitor.janitor != null && Janitor.janitor == PlayerControl.LocalPlayer); bool blockSabotageMafioso = (Mafioso.mafioso != null && Mafioso.mafioso == PlayerControl.LocalPlayer && Godfather.godfather != null && !Godfather.godfather.PPMOEEPBHJO.IAGJEKLJCCI); - if (blockSabotageJanitor || blockSabotageMafioso) { + if (__instance.LHAKKAAOLLM == null && (blockSabotageJanitor || blockSabotageMafioso)) { __instance.UseButton.sprite = DestroyableSingleton.CHNDKKBEIDG.GetImage(ImageNames.UseButton); __instance.UseButton.color = new Color(1f, 1f, 1f, 0.3f); } -- 2.39.5