From a962374eebdeaeb09b490011b9c584aef99e137f Mon Sep 17 00:00:00 2001 From: Gurge44 Date: Thu, 15 Jan 2026 11:55:17 +0100 Subject: [PATCH] ACTUALLY FIX KICKING OMG --- Main.cs | 4 ++-- Modules/CustomRoleSelector.cs | 3 ++- Modules/Utils.cs | 32 +++++++++++++++++++++++++++++++- Patches/ChatCommandPatch.cs | 17 +++++++++++++++++ Patches/CheckGameEndPatch.cs | 11 ++--------- 5 files changed, 54 insertions(+), 13 deletions(-) diff --git a/Main.cs b/Main.cs index 93d73440c..b89fcb564 100644 --- a/Main.cs +++ b/Main.cs @@ -42,8 +42,8 @@ public class Main : BasePlugin private const string DebugKeyHash = "c0fd562955ba56af3ae20d7ec9e64c664f0facecef4b3e366e109306adeae29d"; private const string DebugKeySalt = "59687b"; private const string PluginGuid = "com.gurge44.endlesshostroles"; - public const string PluginVersion = "7.1.2"; - public const string PluginDisplayVersion = "7.1.2"; + public const string PluginVersion = "7.1.3"; + public const string PluginDisplayVersion = "7.1.3"; public const bool TestBuild = false; public const string NeutralColor = "#ffab1b"; diff --git a/Modules/CustomRoleSelector.cs b/Modules/CustomRoleSelector.cs index 1caad90a6..d4d514895 100644 --- a/Modules/CustomRoleSelector.cs +++ b/Modules/CustomRoleSelector.cs @@ -103,8 +103,9 @@ internal static class CustomRoleSelector switch (role) { + case CustomRoles.Ventriloquist when GameStates.CurrentServerType == GameStates.ServerType.Vanilla: + case CustomRoles.Weatherman when Main.LIMap || GameStates.CurrentServerType == GameStates.ServerType.Vanilla: case CustomRoles.RoomRusher when Main.LIMap: - case CustomRoles.Weatherman when Main.LIMap: case CustomRoles.Doctor when Options.EveryoneSeesDeathReasons.GetBool(): case CustomRoles.LovingCrewmate or CustomRoles.LovingImpostor when !loversData.Spawning: case CustomRoles.Commander when optImpNum <= 1 && Commander.CannotSpawnAsSoloImp.GetBool(): diff --git a/Modules/Utils.cs b/Modules/Utils.cs index ba958d9c8..ab1e6908e 100644 --- a/Modules/Utils.cs +++ b/Modules/Utils.cs @@ -1796,6 +1796,9 @@ public static class Utils catch (Exception e) { ThrowException(e); } } + public static bool TempReviveHostRunning; + private static Stopwatch TempReviveHostStopwatch; + public static void SendMultipleMessages(this IEnumerable messages, SendOption sendOption = SendOption.Reliable) { var sender = CustomRpcSender.Create("Utils.SendMultipleMessages", sendOption); @@ -1838,7 +1841,34 @@ public static class Utils text = text.Replace("color=", string.Empty); title = title.Replace("color=", string.Empty); - PlayerControl sender = !addtoHistory ? PlayerControl.LocalPlayer : Main.AllAlivePlayerControls.MinBy(x => x.PlayerId) ?? Main.AllPlayerControls.MinBy(x => x.PlayerId) ?? PlayerControl.LocalPlayer; + PlayerControl sender = !addtoHistory || GameStates.CurrentServerType == GameStates.ServerType.Vanilla ? PlayerControl.LocalPlayer : Main.AllAlivePlayerControls.MinBy(x => x.PlayerId) ?? Main.AllPlayerControls.MinBy(x => x.PlayerId) ?? PlayerControl.LocalPlayer; + + if (sender.AmOwner && (!sender.IsAlive() || sender.Data.IsDead)) + { + if (!TempReviveHostRunning) + Main.Instance.StartCoroutine(TempReviveHost()); + else + TempReviveHostStopwatch?.Restart(); + + IEnumerator TempReviveHost() + { + TempReviveHostRunning = true; + TempReviveHostStopwatch = Stopwatch.StartNew(); + + sender.Data.IsDead = false; + sender.Data.SendGameData(); + + while (TempReviveHostStopwatch.ElapsedMilliseconds < 1000) + yield return null; + + if (!AmongUsClient.Instance.AmHost || GameStates.IsEnded || GameStates.IsLobby) yield break; + + sender.Data.IsDead = true; + sender.Data.SendGameData(); + + TempReviveHostRunning = false; + } + } if (sendTo != byte.MaxValue && receiver.AmOwner) { diff --git a/Patches/ChatCommandPatch.cs b/Patches/ChatCommandPatch.cs index e73102aee..2ada663cc 100644 --- a/Patches/ChatCommandPatch.cs +++ b/Patches/ChatCommandPatch.cs @@ -125,6 +125,8 @@ internal static class ChatCommands public static bool HasMessageDuringEjectionScreen; + private static bool WaitingToSend; + public static void LoadCommands() { Command.AllCommands = new Dictionary @@ -466,6 +468,21 @@ internal static class ChatCommands if (text.Contains("666") && PlayerControl.LocalPlayer.Is(CustomRoles.Demon)) Achievements.Type.WhatTheHell.Complete(); + if (!canceled && AmongUsClient.Instance.AmHost && Utils.TempReviveHostRunning) + { + if (!WaitingToSend) Main.Instance.StartCoroutine(Wait()); + return false; + + IEnumerator Wait() + { + WaitingToSend = true; + while (Utils.TempReviveHostRunning && AmongUsClient.Instance.AmHost) yield return null; + if (GameStates.IsEnded || GameStates.IsLobby) yield break; + if (HudManager.InstanceExists) HudManager.Instance.Chat.SendChat(); + WaitingToSend = false; + } + } + return !canceled; } diff --git a/Patches/CheckGameEndPatch.cs b/Patches/CheckGameEndPatch.cs index 5d1bc03fa..57e770aa2 100644 --- a/Patches/CheckGameEndPatch.cs +++ b/Patches/CheckGameEndPatch.cs @@ -72,10 +72,10 @@ internal static class GameEndChecker Ended = true; LoadingEndScreen = true; - //Main.AllPlayerControls.Do(pc => Camouflage.RpcSetSkin(pc, true, true, true)); + Main.AllPlayerControls.Do(pc => Camouflage.RpcSetSkin(pc, true, true, true)); NameNotifyManager.Reset(); - //NotifyRoles(ForceLoop: true); + NotifyRoles(ForceLoop: true); CustomSabotage.Reset(); @@ -359,13 +359,6 @@ internal static class GameEndChecker try { LobbySharingAPI.NotifyLobbyStatusChanged(LobbyStatus.Ended); } catch (Exception e) { ThrowException(e); } - string msg = GetString("NotifyGameEnding"); - - Main.AllPlayerControls - .Where(x => x.GetClient() != null && !x.Data.Disconnected) - .Select(x => new Message("\n", x.PlayerId, msg)) - .SendMultipleMessages(); - SetEverythingUpPatch.LastWinsReason = WinnerTeam is CustomWinner.Crewmate or CustomWinner.Impostor ? GetString($"GameOverReason.{reason}") : string.Empty; var self = AmongUsClient.Instance; self.StartCoroutine(CoEndGame(self, reason).WrapToIl2Cpp());