From f06af53c4a4d76e11f4d4d82d2de0efbfe81db4d Mon Sep 17 00:00:00 2001 From: Gurge44 Date: Sun, 27 Apr 2025 20:16:04 +0200 Subject: [PATCH] more fixes --- CTA/CustomTeamAssigner/CustomRoles.cs | 3 +++ GameMode/MoveAndStop.cs | 5 +++-- Modules/BanManager.cs | 14 ++++++++------ Modules/CustomRoleSelector.cs | 2 ++ Patches/PlayerJoinAndLeftPatch.cs | 4 ++-- Roles/AddOns/Common/Disco.cs | 2 +- Roles/Crewmate/Beacon.cs | 7 ++++--- Roles/Neutral/Predator.cs | 26 +++++++++++++++----------- 8 files changed, 38 insertions(+), 25 deletions(-) diff --git a/CTA/CustomTeamAssigner/CustomRoles.cs b/CTA/CustomTeamAssigner/CustomRoles.cs index c82b7e368..3f5c9954a 100644 --- a/CTA/CustomTeamAssigner/CustomRoles.cs +++ b/CTA/CustomTeamAssigner/CustomRoles.cs @@ -51,6 +51,7 @@ public enum CustomRoles EvilGuesser, EvilTracker, FireWorks, + Forger, Framer, Freezer, Gambler, @@ -141,6 +142,7 @@ public enum CustomRoles Ankylosaurus, Autocrat, Bane, + Battery, Beacon, Benefactor, Bodyguard, @@ -159,6 +161,7 @@ public enum CustomRoles LovingImpostor, Crusader, Dad, + Dealer, Demolitionist, Deputy, Detective, diff --git a/GameMode/MoveAndStop.cs b/GameMode/MoveAndStop.cs index 70b20ba88..b600790bf 100644 --- a/GameMode/MoveAndStop.cs +++ b/GameMode/MoveAndStop.cs @@ -568,7 +568,8 @@ internal static class MoveAndStop data.UpdateCounters(); - LastSuffix[pc.PlayerId] = GetSuffixText(pc); + if (!IsEventActive || Event.Type != Events.FrozenTimers) + LastSuffix[pc.PlayerId] = GetSuffixText(pc); bool IsCounterRed(Counter counter) => counter.IsRed && (pc.IsHost() || counter.Timer != counter.TotalRedTime); } @@ -577,7 +578,7 @@ internal static class MoveAndStop LastFixedUpdate = now; RoundTime--; - + Utils.NotifyRoles(); } } diff --git a/Modules/BanManager.cs b/Modules/BanManager.cs index 6c3a21bb7..576ab6208 100644 --- a/Modules/BanManager.cs +++ b/Modules/BanManager.cs @@ -144,6 +144,14 @@ public static class BanManager { if (!AmongUsClient.Instance.AmHost || !Options.ApplyBanList.GetBool() || player == null) return; + if (TempBanWhiteList.Contains(player.GetHashedPuid())) + { + AmongUsClient.Instance.KickPlayer(player.Id, true); + Logger.Info($"{player.PlayerName} was in temp ban list", "BAN"); + } + + if (GameStates.CurrentServerType is GameStates.ServerType.ModdedWithCNOSupport or GameStates.ServerType.ModdedWithoutCNOSupport) return; + string friendcode = player.FriendCode.Replace(':', '#'); if (friendcode.Length < 7) // #1234 is 5 chars, and it's impossible for a friend code to only have 3 @@ -189,12 +197,6 @@ public static class BanManager Logger.Info($"{player.PlayerName} is on the EAC ban list", "BAN"); return; } - - if (TempBanWhiteList.Contains(player.GetHashedPuid())) - { - AmongUsClient.Instance.KickPlayer(player.Id, true); - Logger.Info($"{player.PlayerName} was in temp ban list", "BAN"); - } } public static bool CheckBanList(string code, string hashedpuid = "") diff --git a/Modules/CustomRoleSelector.cs b/Modules/CustomRoleSelector.cs index 0bc6fb511..da75f1d4a 100644 --- a/Modules/CustomRoleSelector.cs +++ b/Modules/CustomRoleSelector.cs @@ -115,6 +115,8 @@ internal static class CustomRoleSelector case CustomRoles.Commander when optImpNum <= 1 && Commander.CannotSpawnAsSoloImp.GetBool(): case CustomRoles.Changeling when Changeling.GetAvailableRoles(true).Count == 0: case CustomRoles.Camouflager when Camouflager.DoesntSpawnOnFungle.GetBool() && Main.CurrentMap == MapNames.Fungle: + case CustomRoles.Battery when Main.CurrentMap == MapNames.Fungle: + case CustomRoles.Beacon when Main.CurrentMap == MapNames.Fungle: case CustomRoles.DarkHide when Main.CurrentMap == MapNames.Fungle: case CustomRoles.Doormaster when Main.CurrentMap == MapNames.MiraHQ: case CustomRoles.Pelican when Roles[RoleAssignType.Impostor].Any(x => x.Role == CustomRoles.Duellist): diff --git a/Patches/PlayerJoinAndLeftPatch.cs b/Patches/PlayerJoinAndLeftPatch.cs index 5a0959862..779f73781 100644 --- a/Patches/PlayerJoinAndLeftPatch.cs +++ b/Patches/PlayerJoinAndLeftPatch.cs @@ -154,7 +154,7 @@ internal static class OnPlayerJoinedPatch catch { } }, 4f, "green bean kick late task", false); - if (AmongUsClient.Instance.AmHost && client.FriendCode == "" && Options.KickPlayerFriendCodeNotExist.GetBool() && !GameStates.IsLocalGame) + if (AmongUsClient.Instance.AmHost && client.FriendCode == "" && Options.KickPlayerFriendCodeNotExist.GetBool() && !GameStates.IsLocalGame && GameStates.CurrentServerType is not GameStates.ServerType.ModdedWithCNOSupport and not GameStates.ServerType.ModdedWithoutCNOSupport) { if (!BanManager.TempBanWhiteList.Contains(client.GetHashedPuid())) BanManager.TempBanWhiteList.Add(client.GetHashedPuid()); @@ -177,7 +177,7 @@ internal static class OnPlayerJoinedPatch Logger.SendInGame("They were probably hacking tbh"); } - if (FastDestroyableSingleton.Instance.IsPlayerBlockedUsername(client.FriendCode) && AmongUsClient.Instance.AmHost) + if (FastDestroyableSingleton.Instance.IsPlayerBlockedUsername(client.FriendCode) && AmongUsClient.Instance.AmHost && GameStates.CurrentServerType is not GameStates.ServerType.ModdedWithCNOSupport and not GameStates.ServerType.ModdedWithoutCNOSupport) { AmongUsClient.Instance.KickPlayer(client.Id, true); Logger.Info($"Blocked Player {client.PlayerName}({client.FriendCode}) has been banned.", "BAN"); diff --git a/Roles/AddOns/Common/Disco.cs b/Roles/AddOns/Common/Disco.cs index ff1f88983..9005da337 100644 --- a/Roles/AddOns/Common/Disco.cs +++ b/Roles/AddOns/Common/Disco.cs @@ -40,7 +40,7 @@ internal class Disco : IAddon public static void OnFixedUpdate(PlayerControl pc) { - if (!pc.Is(CustomRoles.Disco) || !GameStates.IsInTask || pc.IsShifted() || Camouflage.IsCamouflage || pc.inVent || pc.MyPhysics.Animations.IsPlayingEnterVentAnimation() || pc.walkingToVent || pc.onLadder || pc.MyPhysics.Animations.IsPlayingAnyLadderAnimation() || pc.inMovingPlat) return; + if (!pc.Is(CustomRoles.Disco) || !GameStates.IsInTask || ExileController.Instance || AntiBlackout.SkipTasks || pc.IsShifted() || Camouflage.IsCamouflage || pc.inVent || pc.MyPhysics.Animations.IsPlayingEnterVentAnimation() || pc.walkingToVent || pc.onLadder || pc.MyPhysics.Animations.IsPlayingAnyLadderAnimation() || pc.inMovingPlat) return; long now = Utils.TimeStamp; if (LastChange.TryGetValue(pc.PlayerId, out long change) && change + DiscoChangeInterval.GetInt() > now) return; diff --git a/Roles/Crewmate/Beacon.cs b/Roles/Crewmate/Beacon.cs index 8b55add6f..4943992c7 100644 --- a/Roles/Crewmate/Beacon.cs +++ b/Roles/Crewmate/Beacon.cs @@ -66,13 +66,14 @@ internal class Beacon : RoleBase float radius = Radius.GetFloat(); bool beaconNearby = Beacons.Any(x => Vector2.Distance(x.Pos(), pos) <= radius); bool affectedPlayer = AffectedPlayers.Contains(pc.PlayerId); + bool lightsOff = Utils.IsActive(SystemTypes.Electrical); switch (affectedPlayer) { case true when !beaconNearby: { AffectedPlayers.Remove(pc.PlayerId); - if (Utils.IsActive(SystemTypes.Electrical)) pc.MarkDirtySettings(); + if (lightsOff) pc.MarkDirtySettings(); LastChange[pc.PlayerId] = now; break; @@ -80,11 +81,11 @@ internal class Beacon : RoleBase case false when beaconNearby: { AffectedPlayers.Add(pc.PlayerId); - if (Utils.IsActive(SystemTypes.Electrical)) pc.MarkDirtySettings(); + if (lightsOff) pc.MarkDirtySettings(); LastChange[pc.PlayerId] = now; - if (pc.IsLocalPlayer()) + if (pc.IsLocalPlayer() && lightsOff) Achievements.Type.ALightInTheShadows.CompleteAfterGameEnd(); break; diff --git a/Roles/Neutral/Predator.cs b/Roles/Neutral/Predator.cs index 0a365a1d4..d8db811dc 100644 --- a/Roles/Neutral/Predator.cs +++ b/Roles/Neutral/Predator.cs @@ -60,22 +60,26 @@ internal class Predator : RoleBase for (var i = 0; i < NumOfRolesToKill.GetInt(); i++) { - int index = r.Next(allRoles.Count); - CustomRoles role = allRoles[index]; - allRoles.RemoveAt(index); - - if (role.Is(Team.Impostor)) + try { - if (impRoles >= MaxImpRolePicks.GetInt()) + int index = r.Next(allRoles.Count); + CustomRoles role = allRoles[index]; + allRoles.RemoveAt(index); + + if (role.Is(Team.Impostor)) { - i--; - continue; + if (impRoles >= MaxImpRolePicks.GetInt()) + { + i--; + continue; + } + + impRoles++; } - impRoles++; + RolesToKill.Add(role); } - - RolesToKill.Add(role); + catch (Exception e) { Utils.ThrowException(e); } } Logger.Info($"Predator Roles: {RolesToKill.Join()}", "Predator");