diff --git a/Strings.xlsx b/Strings.xlsx index a01d09e..a8197b8 100644 Binary files a/Strings.xlsx and b/Strings.xlsx differ diff --git a/TheOtherRoles/Buttons/CustomButton.cs b/TheOtherRoles/Buttons/CustomButton.cs index 4560bb0..7d6f9d2 100644 --- a/TheOtherRoles/Buttons/CustomButton.cs +++ b/TheOtherRoles/Buttons/CustomButton.cs @@ -131,10 +131,10 @@ public static void MeetingEndedUpdate() } } - public static void ResetAllCooldowns(float Time = -1) + public static void ResetAllCooldowns(float Time = -1, PlayerControl target = null) { + var player = target ?? PlayerControl.LocalPlayer; var time = Time == -1 ? ModOption.KillCooddown : Time; - PlayerControl.LocalPlayer.killTimer = time - 0.6f; foreach (var t in buttons) { var maxTime = Time == -1 ? t.MaxTimer : Time; @@ -149,6 +149,7 @@ public static void ResetAllCooldowns(float Time = -1) Error($"NullReferenceException from MeetingEndedUpdate().HasButton(), if theres only one warning its fine\n{e}", "CustomButton"); } } + player.killTimer = time; } public static void resetKillButton(PlayerControl p, float time = -1) diff --git a/TheOtherRoles/Helper/Helpers.cs b/TheOtherRoles/Helper/Helpers.cs index 1e11b2c..7ad029f 100644 --- a/TheOtherRoles/Helper/Helpers.cs +++ b/TheOtherRoles/Helper/Helpers.cs @@ -60,6 +60,8 @@ public static class Helpers public static bool InGame => AmongUsClient.Instance != null && AmongUsClient.Instance.GameState == InnerNetClient.GameStates.Started; public static bool IsCountDown => GameStartManager.InstanceExists && GameStartManager.Instance.startState == GameStartManager.StartingStates.Countdown; public static bool InMeeting => InGame && MeetingHud.Instance; + + public static bool ShowButtons => !(MapBehaviour.Instance && MapBehaviour.Instance.IsOpen) && !MeetingHud.Instance && !ExileController.Instance; public static bool IsHideNSeek => GameOptionsManager.Instance.currentGameOptions.GameMode == GameModes.HideNSeek; public static bool isSkeld => GameOptionsManager.Instance.CurrentGameOptions.MapId == 0; public static bool isMira => GameOptionsManager.Instance.CurrentGameOptions.MapId == 1; @@ -70,7 +72,6 @@ public static class Helpers public static System.Random rnd => new(Guid.NewGuid().GetHashCode()); - public static PlayerControl HostPlayer => GameData.Instance.GetHost().Object; public static bool isUsingTransportation(this PlayerControl pc) => pc.inMovingPlat || pc.onLadder; @@ -295,11 +296,6 @@ public static string teamString(PlayerControl player) return killerTeam; } - public static bool ShowButtons => - !(MapBehaviour.Instance && MapBehaviour.Instance.IsOpen) && - !MeetingHud.Instance && - !ExileController.Instance; - public static void NoCheckStartMeeting(this PlayerControl reporter, GameData.PlayerInfo target, bool force = false) { if (InMeeting) return; @@ -864,7 +860,7 @@ public static void shareGameVersion() writer.Write((byte)Main.Version.Major); writer.Write((byte)Main.Version.Minor); writer.Write((byte)Main.Version.Build); - writer.Write(AmongUsClient.Instance.AmHost ? Patches.GameStartManagerPatch.timer : -1f); + writer.Write(AmongUsClient.Instance.AmHost ? GameStartManagerPatch.timer : -1f); writer.WritePacked(AmongUsClient.Instance.ClientId); writer.Write((byte)(Main.Version.Revision < 0 ? 0xFF : Main.Version.Revision)); writer.Write(Assembly.GetExecutingAssembly().ManifestModule.ModuleVersionId.ToByteArray()); @@ -1224,7 +1220,7 @@ public static MurderAttemptResult checkMuderAttempt(PlayerControl killer, Player if (Survivor.Player != null && Survivor.Player.Contains(target) && Survivor.vestActive) { - CustomButton.resetKillButton(killer, Survivor.vestResetCooldown); + CustomButton.ResetAllCooldowns(Survivor.vestResetCooldown, killer); SoundEffectsManager.play("fail"); return MurderAttemptResult.SuppressKill; } diff --git a/TheOtherRoles/Objects/Trap.cs b/TheOtherRoles/Objects/Trap.cs index e016b0d..49af575 100644 --- a/TheOtherRoles/Objects/Trap.cs +++ b/TheOtherRoles/Objects/Trap.cs @@ -16,7 +16,7 @@ public class Trap private static int instanceCounter; - private static ResourceSprite trapSprite = new("Trapper_Trap_Ingame.png", 300); + private static Sprite trapSprite = new ResourceSprite("Trapper_Trap_Ingame.png", 300); private Arrow arrow = new(Color.blue); private int neededCount = Trapper.trapCountToReveal; public int instanceId; diff --git a/TheOtherRoles/Patches/ExileControllerPatch.cs b/TheOtherRoles/Patches/ExileControllerPatch.cs index 103934b..614564d 100644 --- a/TheOtherRoles/Patches/ExileControllerPatch.cs +++ b/TheOtherRoles/Patches/ExileControllerPatch.cs @@ -195,13 +195,14 @@ public static void Postfix(ExileController __instance, [HarmonyArgument(0)] ref break; } } - if (CustomOptionHolder.exiledShowTeamNum.GetBool() && player?.PlayerId != Jester.jester?.PlayerId) + + if (CustomOptionHolder.exiledShowTeamNum.GetBool()) { var Impostors = PlayerControl.AllPlayerControls.ToArray().Count(x => x.isImpostor() && x.IsAlive() && x.PlayerId != player.PlayerId); var Neutrals = PlayerControl.AllPlayerControls.ToArray().Count(x => x.isNeutral() && x.IsAlive() && x.PlayerId != player.PlayerId); __instance.ImpostorText.text = - $"\n{cs(getTeamColor(RoleType.Impostor), "伪装者阵营剩余 " + Impostors)}" + - $" | {cs(getTeamColor(RoleType.Neutral), "中立阵营剩余 " + Neutrals)}"; + $"\n{cs(getTeamColor(RoleType.Impostor), "伪装者阵营剩余 ") + Impostors}" + + $" | {cs(getTeamColor(RoleType.Neutral), "中立阵营剩余 ") + Neutrals}"; } } diff --git a/TheOtherRoles/Patches/PlayerControlPatch.cs b/TheOtherRoles/Patches/PlayerControlPatch.cs index 4ecc0c7..145698e 100644 --- a/TheOtherRoles/Patches/PlayerControlPatch.cs +++ b/TheOtherRoles/Patches/PlayerControlPatch.cs @@ -1568,6 +1568,8 @@ public static void Postfix(PlayerControl __instance) Akujo.otherLover(__instance)?.Revive(); } + CustomButton.ResetAllCooldowns(-1, __instance); + DeadBody[] array = Object.FindObjectsOfType(); for (var i = 0; i < array.Length; i++) { diff --git a/TheOtherRoles/Patches/UsablesPatch.cs b/TheOtherRoles/Patches/UsablesPatch.cs index 3e82246..368f25e 100644 --- a/TheOtherRoles/Patches/UsablesPatch.cs +++ b/TheOtherRoles/Patches/UsablesPatch.cs @@ -4,10 +4,10 @@ using AmongUs.GameOptions; using PowerTools; using Reactor.Utilities.Extensions; -using TheOtherRoles.Buttons; using TheOtherRoles.Utilities; using TMPro; using UnityEngine; +using static TheOtherRoles.Buttons.HudManagerStartPatch; using static TheOtherRoles.GameHistory; using static TheOtherRoles.Options.ModOption; using Object = UnityEngine.Object; @@ -189,7 +189,7 @@ internal class VentButtonVisibilityPatch { private static void Postfix(HudManager __instance) { - if (PlayerControl.LocalPlayer.AmOwner && ShowButtons) + if (PlayerControl.LocalPlayer?.AmOwner == true && ShowButtons) { __instance.ImpostorVentButton.Hide(); __instance.SabotageButton.Hide(); @@ -309,23 +309,17 @@ public static bool Prefix(KillButton __instance) // Handle blank kill if (res == MurderAttemptResult.BlankKill) { - PlayerControl.LocalPlayer.killTimer = - GameOptionsManager.Instance.currentNormalGameOptions.KillCooldown; + PlayerControl.LocalPlayer.killTimer = GameOptionsManager.Instance.currentNormalGameOptions.KillCooldown; if (PlayerControl.LocalPlayer == Cleaner.cleaner) - Cleaner.cleaner.killTimer = HudManagerStartPatch.cleanerCleanButton.Timer = - HudManagerStartPatch.cleanerCleanButton.MaxTimer; + Cleaner.cleaner.killTimer = cleanerCleanButton.Timer = cleanerCleanButton.MaxTimer; else if (PlayerControl.LocalPlayer == Warlock.warlock) - Warlock.warlock.killTimer = HudManagerStartPatch.warlockCurseButton.Timer = - HudManagerStartPatch.warlockCurseButton.MaxTimer; + Warlock.warlock.killTimer = warlockCurseButton.Timer = warlockCurseButton.MaxTimer; else if (PlayerControl.LocalPlayer == Mini.mini && Mini.mini.Data.Role.IsImpostor) - Mini.mini.SetKillTimer(GameOptionsManager.Instance.currentNormalGameOptions.KillCooldown * - (Mini.isGrownUp() ? 0.66f : 2f)); + Mini.mini.SetKillTimer(GameOptionsManager.Instance.currentNormalGameOptions.KillCooldown * (Mini.isGrownUp() ? 0.66f : 2f)); else if (PlayerControl.LocalPlayer == Witch.witch) - Witch.witch.killTimer = HudManagerStartPatch.witchSpellButton.Timer = - HudManagerStartPatch.witchSpellButton.MaxTimer; + Witch.witch.killTimer = witchSpellButton.Timer = witchSpellButton.MaxTimer; else if (PlayerControl.LocalPlayer == Ninja.ninja) - Ninja.ninja.killTimer = HudManagerStartPatch.ninjaButton.Timer = - HudManagerStartPatch.ninjaButton.MaxTimer; + Ninja.ninja.killTimer = ninjaButton.Timer = ninjaButton.MaxTimer; } __instance.SetTarget(null); @@ -374,78 +368,72 @@ internal class EmergencyMinigameUpdatePatch { private static void Postfix(EmergencyMinigame __instance) { - var roleCanCallEmergency = true; - var statusText = ""; + if (!CanCallEmergency(out var statusText)) + { + UpdateEmergencyButton(__instance, statusText, false); + return; + } - // Deactivate emergency button for Swapper - if (Swapper.swapper != null && Swapper.swapper == PlayerControl.LocalPlayer && - !Swapper.canCallEmergency) + if (__instance.state == 1) + { + var localRemaining = PlayerControl.LocalPlayer.RemainingEmergencies; + var teamRemaining = Mathf.Max(0, maxNumberOfMeetings - meetingsCount); + var remaining = Mathf.Min(localRemaining, Mayor.mayor != null && Mayor.mayor == PlayerControl.LocalPlayer ? 1 : teamRemaining); + __instance.NumberText.text = string.Format(GetString("meetingCount"), localRemaining.ToString(), teamRemaining.ToString()); + UpdateEmergencyButton(__instance, string.Empty, remaining > 0); + } + } + + private static bool CanCallEmergency(out string statusText) + { + statusText = string.Empty; + + if (Swapper.swapper != null && Swapper.swapper == PlayerControl.LocalPlayer && !Swapper.canCallEmergency) { - roleCanCallEmergency = false; statusText = GetString("swapperMeetingButton"); + return false; } - // Potentially deactivate emergency button for Jester - if (Jester.jester != null && Jester.jester == PlayerControl.LocalPlayer && - !Jester.canCallEmergency) + if (Jester.jester != null && Jester.jester == PlayerControl.LocalPlayer && !Jester.canCallEmergency) { - roleCanCallEmergency = false; statusText = GetString("jesterMeetingButton"); + return false; } - // Potentially deactivate emergency button for Jester - if (Prosecutor.prosecutor != null && Prosecutor.prosecutor == PlayerControl.LocalPlayer && - !Prosecutor.canCallEmergency) + if (Prosecutor.prosecutor != null && Prosecutor.prosecutor == PlayerControl.LocalPlayer && !Prosecutor.canCallEmergency) { - roleCanCallEmergency = false; statusText = GetString("prosecutorMeetingButton"); + return false; } - // Potentially deactivate emergency button for Jester - if (Lawyer.lawyer != null && Lawyer.lawyer == PlayerControl.LocalPlayer && - !Lawyer.canCallEmergency) + if (Lawyer.lawyer != null && Lawyer.lawyer == PlayerControl.LocalPlayer && !Lawyer.canCallEmergency) { - roleCanCallEmergency = false; statusText = GetString("lawyerMeetingButton"); + return false; } - // Potentially deactivate emergency button for Lawyer/Prosecutor - if (Executioner.executioner != null && Executioner.executioner == PlayerControl.LocalPlayer && - !Executioner.canCallEmergency) + if (Executioner.executioner != null && Executioner.executioner == PlayerControl.LocalPlayer && !Executioner.canCallEmergency) { - roleCanCallEmergency = false; - if (Executioner.executioner) statusText = GetString("executionerMeetingButton"); + statusText = GetString("executionerMeetingButton"); + return false; } - // Potentially deactivate emergency button for Prophet if (Prophet.prophet != null && Prophet.prophet == PlayerControl.LocalPlayer && !Prophet.canCallEmergency) { - roleCanCallEmergency = false; statusText = GetString("prophetMeetingButton"); + return false; } - if (!roleCanCallEmergency) - { - __instance.StatusText.text = statusText; - __instance.NumberText.text = string.Empty; - __instance.ClosedLid.gameObject.SetActive(true); - __instance.OpenLid.gameObject.SetActive(false); - __instance.ButtonActive = false; - return; - } + return true; + } - // Handle max number of meetings - if (__instance.state == 1) - { - var localRemaining = PlayerControl.LocalPlayer.RemainingEmergencies; - var teamRemaining = Mathf.Max(0, maxNumberOfMeetings - meetingsCount); - var remaining = Mathf.Min(localRemaining, - Mayor.mayor != null && Mayor.mayor == PlayerControl.LocalPlayer ? 1 : teamRemaining); - __instance.NumberText.text = string.Format(GetString("meetingCount"), localRemaining.ToString(), teamRemaining.ToString()); - __instance.ButtonActive = remaining > 0; - __instance.ClosedLid.gameObject.SetActive(!__instance.ButtonActive); - __instance.OpenLid.gameObject.SetActive(__instance.ButtonActive); - } + private static void UpdateEmergencyButton(EmergencyMinigame instance, string statusText, bool isActive) + { + instance.StatusText.text = statusText; + instance.NumberText.text = string.Empty; + instance.ClosedLid.gameObject.SetActive(!isActive); + instance.OpenLid.gameObject.SetActive(isActive); + instance.ButtonActive = isActive; } } diff --git a/TheOtherRoles/RPC.cs b/TheOtherRoles/RPC.cs index cd9c717..18178ea 100644 --- a/TheOtherRoles/RPC.cs +++ b/TheOtherRoles/RPC.cs @@ -846,7 +846,7 @@ public static void hostKill(byte targetId) { var target = playerById(targetId); target.Exiled(); - OverrideDeathReasonAndKiller(target, CustomDeathReason.HostCmdKill, HostPlayer); + OverrideDeathReasonAndKiller(target, CustomDeathReason.HostCmdKill, GameData.Instance.GetHost()?.Object); DeadBody[] array = Object.FindObjectsOfType(); foreach (var body in array) diff --git a/TheOtherRoles/Resources/stringData.json b/TheOtherRoles/Resources/stringData.json index 80e5742..0a7edb2 100644 --- a/TheOtherRoles/Resources/stringData.json +++ b/TheOtherRoles/Resources/stringData.json @@ -1542,7 +1542,7 @@ "13": "存活会取代客户胜利" }, "executionerPromotesToLawyer": { - "13": "目标职业变更时可以晋升为律师" + "13": "目标被招募时可以晋升为律师" }, "executionerOnTargetDead": { "0": "Executioner Becomes On Target Dead", diff --git a/TheOtherRoles/Roles/Neutral/Pelican.cs b/TheOtherRoles/Roles/Neutral/Pelican.cs index e798690..d3aeea3 100644 --- a/TheOtherRoles/Roles/Neutral/Pelican.cs +++ b/TheOtherRoles/Roles/Neutral/Pelican.cs @@ -33,7 +33,8 @@ public static void PelicanDie(bool clear = false) HudManager.Instance.PlayerCam.Target = PlayerControl.LocalPlayer; PlayerControl.LocalPlayer.NetTransform.RpcSnapTo(Player.transform.position); } - clearAndReload(clear); + Message($"Pelican Player {Player?.Data.PlayerName ?? "null"}", "Pelican"); + if (clear) clearAndReload(true); } } diff --git a/TheOtherRoles/TheOtherRoles.csproj b/TheOtherRoles/TheOtherRoles.csproj index 93bae96..bbcdd76 100644 --- a/TheOtherRoles/TheOtherRoles.csproj +++ b/TheOtherRoles/TheOtherRoles.csproj @@ -1,7 +1,7 @@  net6.0 - 1.1.2.2 + 1.1.2.3 TheOtherUs mxyx-club latest