diff --git a/HNSRevamped.cs b/HNSRevamped.cs index 76f5e70..016271d 100644 --- a/HNSRevamped.cs +++ b/HNSRevamped.cs @@ -30,7 +30,7 @@ public partial class Main : BasePlugin public static NormalGameOptionsV10 NormalOptions => GameOptionsManager.Instance != null ? GameOptionsManager.Instance.currentNormalGameOptions : null; public static bool HasArgumentException; public static string CredentialsText; - public const string ModVersion = "v0.2.0"; + public const string ModVersion = "v0.4.0"; public static PlayerControl[] AllPlayerControls { @@ -68,7 +68,7 @@ public partial class Main : BasePlugin AutoStart = Config.Bind("Client Options", "Auto Start", false); DarkTheme = Config.Bind("Client Options", "Dark Theme", true); LobbyMusic = Config.Bind("Client Options", "Lobby Music", false); - NoKcdMode = Config.Bind("Client Options", "0Kcd Mode", false); + NoKcdMode = Config.Bind("Client Options", "0 Kill Cooldown", false); BanManager.Init(); diff --git a/Modules/Utils.cs b/Modules/Utils.cs index 7c1d41a..cbce96b 100644 --- a/Modules/Utils.cs +++ b/Modules/Utils.cs @@ -158,4 +158,10 @@ public static class Utils return name; } + + public static ClientData GetClientById(int id) + { + try { return AmongUsClient.Instance.allClients.ToArray().FirstOrDefault(cd => cd.Id == id); } + catch { return null; } + } } diff --git a/Patches/ChatControlPatch.cs b/Patches/ChatControlPatch.cs index 7f5ed31..43ce45e 100644 --- a/Patches/ChatControlPatch.cs +++ b/Patches/ChatControlPatch.cs @@ -1,4 +1,5 @@ -using InnerNet; +using Hazel; +using InnerNet; using System; using UnityEngine; @@ -20,4 +21,35 @@ internal static class ChatControllerUpdatePatch } else __instance.freeChatField.textArea.outputText.color = Color.black; } +} + +[HarmonyPatch(typeof(VoteBanSystem), nameof(VoteBanSystem.AddVote))] +internal static class AddVotePatch +{ + public static bool Prefix(VoteBanSystem __instance, [HarmonyArgument(0)] int srcClient, [HarmonyArgument(1)] int clientId) + { + if (!AmongUsClient.Instance.AmHost) return true; + + PlayerControl pc = Utils.GetClientById(srcClient)?.Character; + PlayerControl target = Utils.GetClientById(clientId)?.Character; + + if (AmongUsClient.Instance.ClientId == srcClient) + { + AmongUsClient.Instance.KickPlayer(target.Data.ClientId, false); + + Logger.Info($" Kicked {target.Data.PlayerName}, {target.Data.FriendCode}", "VoteKick"); + } + return false; + + } +} + +[HarmonyPatch(typeof(VoteBanSystem), nameof(VoteBanSystem.CmdAddVote))] +internal static class CmdAddVotePatch +{ + public static bool Prefix([HarmonyArgument(0)] int clientId) + { + if (!AmongUsClient.Instance.AmHost) return true; + else return false; + } } \ No newline at end of file diff --git a/Patches/ClientOptionsPatch.cs b/Patches/ClientOptionsPatch.cs index 1d7c227..0bc07a6 100644 --- a/Patches/ClientOptionsPatch.cs +++ b/Patches/ClientOptionsPatch.cs @@ -28,7 +28,7 @@ namespace HNSRevamped static void GMButtonToggle() { if (Main.GM.Value) - HudManager.Instance.ShowPopUp("Hi there! GM hasn't been implemented yet. Sorry for the inconvenience! -MV"); + HudManager.Instance.ShowPopUp("You will now spectate games until GM is turned off."); } } @@ -68,7 +68,7 @@ namespace HNSRevamped LobbyMusic = ClientOptionItem.Create("Lobby Music", Main.LobbyMusic, __instance); if (NoKcdMode == null || NoKcdMode.ToggleButton == null) - NoKcdMode = ClientOptionItem.Create("0Kcd Mode", Main.NoKcdMode, __instance); + NoKcdMode = ClientOptionItem.Create("0 Kill Cooldown", Main.NoKcdMode, __instance); } } diff --git a/Patches/EndGamePatches.cs b/Patches/EndGamePatches.cs index e99d5c2..c945ea3 100644 --- a/Patches/EndGamePatches.cs +++ b/Patches/EndGamePatches.cs @@ -48,5 +48,15 @@ internal class ControllerManagerUpdatePatch writer.Write((byte)GameOverReason.ImpostorDisconnect); AmongUsClient.Instance.FinishEndGame(writer); } + + if (Input.GetKey(KeyCode.M) && Input.GetKey(KeyCode.LeftShift) && Input.GetKeyDown(KeyCode.Return) && Utils.InGame) + { + if (Utils.IsMeeting) + { + MeetingHud.Instance.RpcClose(); + } + else + PlayerControl.LocalPlayer.ReportDeadBody(PlayerControl.LocalPlayer.Data); + } } } \ No newline at end of file diff --git a/Patches/KickPlayerPatch.cs b/Patches/KickPlayerPatch.cs index ab685f7..428cea4 100644 --- a/Patches/KickPlayerPatch.cs +++ b/Patches/KickPlayerPatch.cs @@ -11,15 +11,6 @@ internal class KickPlayerPatch public static bool Prefix(InnerNetClient __instance, int clientId, bool ban) { if (!AmongUsClient.Instance.AmHost) return true; - - var HashedPuid = AmongUsClient.Instance.GetClient(clientId).GetHashedPuid(); - if (!AttemptedKickPlayerList.ContainsKey(HashedPuid)) - AttemptedKickPlayerList.Add(HashedPuid, 0); - else if (AttemptedKickPlayerList[HashedPuid] < 10) - { - Logger.Fatal($"Kick player Request was too fast and has been canceled.", "KickPlayerPatch"); - return false; - } if (ban) BanManager.AddBanPlayer(AmongUsClient.Instance.GetRecentClient(clientId)); return true; diff --git a/Patches/NumberOptionsPatch.cs b/Patches/NumberOptionsPatch.cs index 3b340a4..7efc2ad 100644 --- a/Patches/NumberOptionsPatch.cs +++ b/Patches/NumberOptionsPatch.cs @@ -50,7 +50,7 @@ public static class NumberOption_Initialize if (Main.NoKcdMode.Value && !Utils.isHideNSeek) { - Main.NormalOptions.KillCooldown = 0f; + Main.NormalOptions.KillCooldown = 0.01f; Main.NormalOptions.EmergencyCooldown = 0; Main.NormalOptions.DiscussionTime = 0; @@ -59,5 +59,10 @@ public static class NumberOption_Initialize Main.NormalOptions.NumShortTasks = 1; Main.NormalOptions.NumLongTasks = 0; } + + if (!Main.NoKcdMode.Value && Main.NormalOptions.KillCooldown <= 0.01f) + { + Main.NormalOptions.KillCooldown = 25f; + } } } diff --git a/Patches/OnGameStartedPatch.cs b/Patches/OnGameStartedPatch.cs index b0dc0f4..2a4b2a8 100644 --- a/Patches/OnGameStartedPatch.cs +++ b/Patches/OnGameStartedPatch.cs @@ -9,7 +9,22 @@ internal class ApplyCustomImpostorCount { public static void Postfix(AmongUsClient __instance) { - if (!AmongUsClient.Instance.AmHost || !Utils.isHideNSeek) return; + if (!AmongUsClient.Instance.AmHost) return; + + // Normal game = Impostor to prevent blocking task win. HNS = Crewmate to prevent Seeker detection range bugging. + if (Main.GM.Value) + { + if (!Utils.isHideNSeek) + { + PlayerControl.LocalPlayer.RpcSetRole(AmongUs.GameOptions.RoleTypes.ImpostorGhost, false); + } + if (Utils.isHideNSeek) + { + PlayerControl.LocalPlayer.RpcSetRole(AmongUs.GameOptions.RoleTypes.CrewmateGhost, false); + } + } + + if (!Utils.isHideNSeek) return; int seekersCount = Options.NumSeekers.GetInt(); @@ -18,7 +33,7 @@ internal class ApplyCustomImpostorCount var candidates = new List(); foreach (var p in PlayerControl.AllPlayerControls) { - if (p.Data.Role.TeamType != RoleTeamTypes.Impostor) + if (p.Data.Role.TeamType != RoleTeamTypes.Impostor && !p.Data.IsDead) candidates.Add(p); }