bruh it will never end

This commit is contained in:
Gurge44 committed 2024-10-06 14:38:02 +02:00
1 parent 60173ee3db
commit 94c2f1c6a2
22 files changed
+419 -305

No files matched your search

+1 -2
View File
@@ -100,7 +100,7 @@ internal static class CustomRolesHelper
CustomRoles.SabotageMaster => CustomRoles.Engineer,
CustomRoles.Mafia => Options.LegacyMafia.GetBool() ? CustomRoles.Shapeshifter : CustomRoles.Impostor,
CustomRoles.Terrorist => CustomRoles.Engineer,
CustomRoles.Executioner => Executioner.CRoleChangeRoles[Executioner.ChangeRolesAfterTargetKilled.GetValue()].GetVNRole(checkDesyncRole: true),
CustomRoles.Executioner => CustomRoles.Crewmate,
CustomRoles.Lawyer => CustomRoles.Crewmate,
CustomRoles.NiceSwapper => CustomRoles.Crewmate,
CustomRoles.Ignitor => CustomRoles.Crewmate,
@@ -379,7 +379,6 @@ internal static class CustomRolesHelper
// Natural Disasters
CustomRoles.NDPlayer => RoleTypes.Crewmate,
// Standard
CustomRoles.Executioner => Executioner.CRoleChangeRoles[Executioner.ChangeRolesAfterTargetKilled.GetValue()].GetDYRole(),
CustomRoles.Sheriff => UsePets && Sheriff.UsePet.GetBool() ? RoleTypes.GuardianAngel : RoleTypes.Impostor,
CustomRoles.Crusader => UsePets && Crusader.UsePet.GetBool() ? RoleTypes.GuardianAngel : RoleTypes.Impostor,
CustomRoles.CopyCat => UsePets && CopyCat.UsePet.GetBool() ? RoleTypes.GuardianAngel : RoleTypes.Impostor,
+1 -1
View File
@@ -706,7 +706,7 @@ static class CheckInvalidMovementPatch
public static void Postfix(PlayerControl __instance)
{
if (!GameStates.IsInTask || ExileController.Instance || !Options.EnableMovementChecking.GetBool() || Main.HasJustStarted || Main.RealOptionsData.GetFloat(FloatOptionNames.PlayerSpeedMod) >= 1.9f || AmongUsClient.Instance.Ping >= 300 || Options.CurrentGameMode == CustomGameMode.NaturalDisasters || Utils.GetRegionName() is not ("EU" or "NA" or "AS") || __instance == null || __instance.PlayerId == 255 || !__instance.IsAlive() || __instance.inVent) return;
if (!GameStates.IsInTask || ExileController.Instance || !Options.EnableMovementChecking.GetBool() || Main.HasJustStarted || MeetingStates.FirstMeeting || Main.RealOptionsData.GetFloat(FloatOptionNames.PlayerSpeedMod) >= 1.9f || AmongUsClient.Instance.Ping >= 300 || Options.CurrentGameMode == CustomGameMode.NaturalDisasters || Utils.GetRegionName() is not ("EU" or "NA" or "AS") || __instance == null || __instance.PlayerId == 255 || !__instance.IsAlive() || __instance.inVent) return;
var pos = __instance.Pos();
var now = Utils.TimeStamp;
+19 -2
View File
@@ -74,7 +74,7 @@ static class ExtendedPlayerControl
public static Vent GetClosestVent(this PlayerControl player)
{
var pos = player.Pos();
return ShipStatus.Instance.AllVents.Where(x => x != null).MinBy(x => Vector2.Distance(pos, x.transform.position));
return ShipStatus.Instance?.AllVents?.Where(x => x != null).MinBy(x => Vector2.Distance(pos, x.transform.position));
}
public static List<Vent> GetVentsFromClosest(this PlayerControl player)
@@ -265,6 +265,23 @@ static class ExtendedPlayerControl
AmongUsClient.Instance.FinishRpcImmediately(writer);
}
// By TommyXL
public static void RpcSetPetDesync(this PlayerControl player, string petId, PlayerControl seer)
{
var clientId = seer.GetClientId();
if (clientId == -1) return;
if (AmongUsClient.Instance.ClientId == clientId)
{
player.SetPet(petId);
return;
}
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(player.NetId, (byte)RpcCalls.SetPetStr, SendOption.Reliable, clientId);
writer.Write(petId);
writer.Write(player.GetNextRpcSequenceId(RpcCalls.SetPetStr));
AmongUsClient.Instance.FinishRpcImmediately(writer);
}
public static void RpcSetRoleDesync(this PlayerControl player, RoleTypes role, int clientId)
{
if (player == null) return;
@@ -1364,7 +1381,7 @@ static class ExtendedPlayerControl
public static void NoCheckStartMeeting(this PlayerControl reporter, NetworkedPlayerInfo target, bool force = false)
{
if (Options.DisableMeeting.GetBool() && !force) return;
ReportDeadBodyPatch.AfterReportTasks(reporter, target);
ReportDeadBodyPatch.AfterReportTasks(reporter, target, true);
MeetingRoomManager.Instance.AssignSelf(reporter, target);
DestroyableSingleton<HudManager>.Instance.OpenMeetingRoom(reporter);
reporter.RpcStartMeeting(target);
+11 -3
View File
@@ -257,9 +257,15 @@ static class RPCHandlerPatch
string tag = reader.ReadString();
string forkId = reader.ReadString();
if (!Main.PlayerVersion.ContainsKey(__instance.PlayerId))
try
{
if (!Main.PlayerVersion.ContainsKey(__instance.PlayerId))
{
RPC.RpcVersionCheck();
}
}
catch
{
RPC.RpcVersionCheck();
}
Main.PlayerVersion[__instance.PlayerId] = new(version, tag, forkId);
@@ -280,9 +286,11 @@ static class RPCHandlerPatch
}
// Kick Unmached Player End
}
catch
catch (Exception e)
{
Logger.Warn($"{__instance?.Data?.PlayerName}({__instance?.PlayerId}): error during version check", "RpcVersionCheck");
Utils.ThrowException(e);
if (GameStates.InGame || AmongUsClient.Instance.IsGameStarted) break;
LateTask.New(() =>
{
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.RequestRetryVersionCheck, SendOption.Reliable, __instance.GetClientId());
+4 -9
View File
@@ -17,6 +17,7 @@ using EHR.Crewmate;
using EHR.Impostor;
using EHR.Modules;
using EHR.Neutral;
using EHR.Patches;
using HarmonyLib;
using Hazel;
using Il2CppInterop.Runtime.InteropTypes;
@@ -1303,16 +1304,10 @@ public static class Utils
SendMessage(addonsb.Append("\n.").ToString(), PlayerId, GetString("AddonRoles"));
}
public static void ShowChildrenSettings(OptionItem option, ref StringBuilder sb, int deep = 0, bool command = false, bool disableColor = true)
public static void ShowChildrenSettings(OptionItem option, ref StringBuilder sb, int deep = 0, bool f1 = false, bool disableColor = true)
{
foreach (var opt in option.Children.Select((v, i) => new { Value = v, Index = i + 1 }))
{
if (command)
{
sb.Append("\n\n");
command = false;
}
switch (opt.Value.Name)
{
case "DisableSkeldDevices" when Main.CurrentMap is not MapNames.Skeld and not MapNames.Dleks:
@@ -1321,7 +1316,7 @@ public static class Utils
case "DisableAirshipDevices" when Main.CurrentMap != MapNames.Airship:
case "PolusReactorTimeLimit" when Main.CurrentMap != MapNames.Polus:
case "AirshipReactorTimeLimit" when Main.CurrentMap != MapNames.Airship:
case "ImpCanBeRole" or "CrewCanBeRole" or "NeutralCanBeRole":
case "ImpCanBeRole" or "CrewCanBeRole" or "NeutralCanBeRole" when f1:
continue;
}
@@ -1741,7 +1736,6 @@ public static class Utils
public static void ApplySuffix(PlayerControl player)
{
if (!AmongUsClient.Instance.AmHost || player == null) return;
if (Main.HostRealName == string.Empty) Main.HostRealName = PlayerControl.LocalPlayer.name;
if (!player.AmOwner && !player.FriendCode.GetDevUser().HasTag() && !ChatCommands.IsPlayerModerator(player.FriendCode) && !ChatCommands.IsPlayerVIP(player.FriendCode)) return;
string name = Main.AllPlayerNames.TryGetValue(player.PlayerId, out var n) ? n : string.Empty;
if (Main.NickName != string.Empty && player.AmOwner) name = Main.NickName;
@@ -2694,6 +2688,7 @@ public static class Utils
DoorsReset.ResetDoors();
RoleBlockManager.Reset();
PhantomRolePatch.AfterMeeting();
if ((MapNames)Main.NormalOptions.MapId == MapNames.Airship && AmongUsClient.Instance.AmHost && PlayerControl.LocalPlayer.Is(CustomRoles.GM))
{
+5 -2
View File
@@ -60,7 +60,10 @@ class Command(string[] commandForms, string arguments, string description, Comma
public bool CanUseCommand(PlayerControl pc, bool checkTime = true)
{
if (UsageLevel == UsageLevels.Everyone && UsageTime == UsageTimes.Always) return true;
if (UsageLevel == UsageLevels.Everyone && UsageTime == UsageTimes.Always && !Lovers.PrivateChat.GetBool()) return true;
if (Lovers.PrivateChat.GetBool() && Main.LoversPlayers.Exists(x => x.PlayerId == pc.PlayerId) && GameStates.IsInTask && pc.IsAlive())
return false;
switch (UsageLevel)
{
@@ -1218,7 +1221,7 @@ internal static class ChatCommands
Utils.SendMessage($"{GetString("InvalidArguments")}", player.PlayerId);
return;
}
if (resultId != 0 && !player.FriendCode.GetDevUser().IsUp)
{
Utils.SendMessage($"{GetString("Message.NoPermissionSetRoleOthers")}", player.PlayerId);
+4 -4
View File
@@ -35,7 +35,7 @@ internal class ControllerManagerUpdatePatch
if (KeysDown(KeyCode.Return) && GameSettingMenu.Instance != null && GameSettingMenu.Instance.isActiveAndEnabled)
{
GameSettingMenuPatch._SearchForOptions?.Invoke();
GameSettingMenuPatch.SearchForOptionsAction?.Invoke();
}
}
@@ -119,7 +119,7 @@ internal class ControllerManagerUpdatePatch
GameStartManager.Instance.countDownTimer = 0;
}
if (Input.GetKeyDown(KeyCode.C) && GameStates.IsCountDown)
if (Input.GetKeyDown(KeyCode.C) && GameStates.IsCountDown && GameStates.IsLobby)
{
GameStartManager.Instance.ResetStartState();
Logger.SendInGame(GetString("CancelStartCountDown"));
@@ -169,7 +169,7 @@ internal class ControllerManagerUpdatePatch
Logger.IsAlsoInGame = !Logger.IsAlsoInGame;
Logger.SendInGame($"In-game output log:{Logger.IsAlsoInGame}");
}
if (!Options.NoGameEnd.GetBool()) return;
#if RELEASE
@@ -381,7 +381,7 @@ public static class InGameRoleInfoMenu
sb.Append("<size=90%>");
sb.Append(player.GetRoleInfo(true).TrimStart());
if (Options.CustomRoleSpawnChances.TryGetValue(role, out var opt))
Utils.ShowChildrenSettings(opt, ref settings, disableColor: false);
Utils.ShowChildrenSettings(opt, ref settings, f1: true, disableColor: false);
settings.Append("</size>");
if (settings.Length > 0) addons.Append($"{settings}\n\n");
if (role.PetActivatedAbility()) sb.Append($"<size=80%>{GetString("SupportsPetMessage")}</size>");
+110 -104
View File
@@ -24,111 +24,117 @@ internal class ShowDisconnectPopupPatch
{
if (__instance != null)
{
switch (Reason)
try
{
switch (Reason)
{
case DisconnectReasons.Hacking:
__instance.SetText(GetString("DCNotify.Hacking"));
break;
case DisconnectReasons.Banned:
__instance.SetText(GetString("DCNotify.Banned"));
break;
case DisconnectReasons.Kicked:
__instance.SetText(GetString("DCNotify.Kicked"));
break;
case DisconnectReasons.GameNotFound:
__instance.SetText(GetString("DCNotify.GameNotFound"));
break;
case DisconnectReasons.GameStarted:
__instance.SetText(GetString("DCNotify.GameStarted"));
break;
case DisconnectReasons.GameFull:
__instance.SetText(GetString("DCNotify.GameFull"));
break;
case DisconnectReasons.IncorrectVersion:
__instance.SetText(GetString("DCNotify.IncorrectVersion"));
break;
case DisconnectReasons.LobbyInactivity:
__instance.SetText(GetString("DCNotify.Inactivity"));
break;
case DisconnectReasons.NotAuthorized:
__instance.SetText(GetString("DCNotify.Auth"));
break;
case DisconnectReasons.DuplicateConnectionDetected:
__instance.SetText(GetString("DCNotify.DupeLogin"));
break;
case DisconnectReasons.InvalidGameOptions:
__instance.SetText(GetString("DCNotify.InvalidSettings"));
break;
case DisconnectReasons.Error:
//if (StringReason.Contains("Couldn't find self")) __instance.SetText(GetString("DCNotify.DCFromServer"));
if (StringReason.Contains("Failed to send message")) __instance.SetText(GetString("DCNotify.DCFromServer"));
break;
case DisconnectReasons.Custom:
if (StringReason.Contains("Reliable packet")) __instance.SetText(GetString("DCNotify.DCFromServer"));
else if (StringReason.Contains("remote has not responded to")) __instance.SetText(GetString("DCNotify.DCFromServer"));
break;
case DisconnectReasons.ExitGame:
break;
case DisconnectReasons.InvalidName:
break;
case DisconnectReasons.ConnectionLimit:
break;
case DisconnectReasons.Destroy:
break;
case DisconnectReasons.IncorrectGame:
break;
case DisconnectReasons.ServerRequest:
break;
case DisconnectReasons.ServerFull:
break;
case DisconnectReasons.InternalPlayerMissing:
break;
case DisconnectReasons.InternalNonceFailure:
break;
case DisconnectReasons.InternalConnectionToken:
break;
case DisconnectReasons.PlatformLock:
break;
case DisconnectReasons.MatchmakerInactivity:
break;
case DisconnectReasons.NoServersAvailable:
break;
case DisconnectReasons.QuickmatchDisabled:
break;
case DisconnectReasons.TooManyGames:
break;
case DisconnectReasons.QuickchatLock:
break;
case DisconnectReasons.MatchmakerFull:
break;
case DisconnectReasons.Sanctions:
break;
case DisconnectReasons.ServerError:
break;
case DisconnectReasons.SelfPlatformLock:
break;
case DisconnectReasons.TooManyRequests:
break;
case DisconnectReasons.IntentionalLeaving:
break;
case DisconnectReasons.FocusLostBackground:
break;
case DisconnectReasons.FocusLost:
break;
case DisconnectReasons.NewConnection:
break;
case DisconnectReasons.PlatformParentalControlsBlock:
break;
case DisconnectReasons.PlatformUserBlock:
break;
case DisconnectReasons.PlatformFailedToGetUserBlock:
break;
case DisconnectReasons.ServerNotFound:
break;
case DisconnectReasons.ClientTimeout:
break;
case DisconnectReasons.Unknown:
break;
}
}
catch
{
case DisconnectReasons.Hacking:
__instance.SetText(GetString("DCNotify.Hacking"));
break;
case DisconnectReasons.Banned:
__instance.SetText(GetString("DCNotify.Banned"));
break;
case DisconnectReasons.Kicked:
__instance.SetText(GetString("DCNotify.Kicked"));
break;
case DisconnectReasons.GameNotFound:
__instance.SetText(GetString("DCNotify.GameNotFound"));
break;
case DisconnectReasons.GameStarted:
__instance.SetText(GetString("DCNotify.GameStarted"));
break;
case DisconnectReasons.GameFull:
__instance.SetText(GetString("DCNotify.GameFull"));
break;
case DisconnectReasons.IncorrectVersion:
__instance.SetText(GetString("DCNotify.IncorrectVersion"));
break;
case DisconnectReasons.LobbyInactivity:
__instance.SetText(GetString("DCNotify.Inactivity"));
break;
case DisconnectReasons.NotAuthorized:
__instance.SetText(GetString("DCNotify.Auth"));
break;
case DisconnectReasons.DuplicateConnectionDetected:
__instance.SetText(GetString("DCNotify.DupeLogin"));
break;
case DisconnectReasons.InvalidGameOptions:
__instance.SetText(GetString("DCNotify.InvalidSettings"));
break;
case DisconnectReasons.Error:
//if (StringReason.Contains("Couldn't find self")) __instance.SetText(GetString("DCNotify.DCFromServer"));
if (StringReason.Contains("Failed to send message")) __instance.SetText(GetString("DCNotify.DCFromServer"));
break;
case DisconnectReasons.Custom:
if (StringReason.Contains("Reliable packet")) __instance.SetText(GetString("DCNotify.DCFromServer"));
else if (StringReason.Contains("remote has not responded to")) __instance.SetText(GetString("DCNotify.DCFromServer"));
break;
case DisconnectReasons.ExitGame:
break;
case DisconnectReasons.InvalidName:
break;
case DisconnectReasons.ConnectionLimit:
break;
case DisconnectReasons.Destroy:
break;
case DisconnectReasons.IncorrectGame:
break;
case DisconnectReasons.ServerRequest:
break;
case DisconnectReasons.ServerFull:
break;
case DisconnectReasons.InternalPlayerMissing:
break;
case DisconnectReasons.InternalNonceFailure:
break;
case DisconnectReasons.InternalConnectionToken:
break;
case DisconnectReasons.PlatformLock:
break;
case DisconnectReasons.MatchmakerInactivity:
break;
case DisconnectReasons.NoServersAvailable:
break;
case DisconnectReasons.QuickmatchDisabled:
break;
case DisconnectReasons.TooManyGames:
break;
case DisconnectReasons.QuickchatLock:
break;
case DisconnectReasons.MatchmakerFull:
break;
case DisconnectReasons.Sanctions:
break;
case DisconnectReasons.ServerError:
break;
case DisconnectReasons.SelfPlatformLock:
break;
case DisconnectReasons.TooManyRequests:
break;
case DisconnectReasons.IntentionalLeaving:
break;
case DisconnectReasons.FocusLostBackground:
break;
case DisconnectReasons.FocusLost:
break;
case DisconnectReasons.NewConnection:
break;
case DisconnectReasons.PlatformParentalControlsBlock:
break;
case DisconnectReasons.PlatformUserBlock:
break;
case DisconnectReasons.PlatformFailedToGetUserBlock:
break;
case DisconnectReasons.ServerNotFound:
break;
case DisconnectReasons.ClientTimeout:
break;
case DisconnectReasons.Unknown:
break;
}
}
}, 0.01f, "Override Disconnect Text");
+23 -15
View File
@@ -1,31 +1,39 @@
using EHR.Patches;
using System;
using EHR.Patches;
using HarmonyLib;
using UnityEngine;
namespace EHR;
[HarmonyPatch(typeof(GameStartManager))]
class AllMapIconsPatch
static class AllMapIconsPatch
{
[HarmonyPatch(nameof(GameStartManager.Start)), HarmonyPostfix]
public static void Postfix_AllMapIcons(GameStartManager __instance)
{
if (__instance == null) return;
if (Main.NormalOptions.MapId == 3)
try
{
Main.NormalOptions.MapId = 0;
__instance.UpdateMapImage(MapNames.Skeld);
if (__instance == null) return;
if (!Options.RandomMapsMode.GetBool())
CreateOptionsPickerPatch.SetDleks = true;
if (Main.NormalOptions.MapId == 3)
{
Main.NormalOptions.MapId = 0;
__instance.UpdateMapImage(MapNames.Skeld);
if (!Options.RandomMapsMode.GetBool())
CreateOptionsPickerPatch.SetDleks = true;
}
MapIconByName dleksIcon = Object.Instantiate(__instance, __instance.gameObject.transform).AllMapIcons[0];
dleksIcon.Name = MapNames.Dleks;
dleksIcon.MapImage = Utils.LoadSprite("EHR.Resources.Images.DleksBanner.png", 100f);
dleksIcon.NameImage = Utils.LoadSprite("EHR.Resources.Images.DleksBanner-Wordart.png", 100f);
__instance.AllMapIcons.Add(dleksIcon);
}
catch (Exception e)
{
Utils.ThrowException(e);
}
MapIconByName dleksIcon = Object.Instantiate(__instance, __instance.gameObject.transform).AllMapIcons[0];
dleksIcon.Name = MapNames.Dleks;
dleksIcon.MapImage = Utils.LoadSprite("EHR.Resources.Images.DleksBanner.png", 100f);
dleksIcon.NameImage = Utils.LoadSprite("EHR.Resources.Images.DleksBanner-Wordart.png", 100f);
__instance.AllMapIcons.Add(dleksIcon);
}
}
+24 -5
View File
@@ -24,7 +24,7 @@ public static class ModGameOptionsMenu
[HarmonyPatch(typeof(GameOptionsMenu))]
public static class GameOptionsMenuPatch
{
public static GameOptionsMenu Instance;
private static GameOptionsMenu Instance;
[HarmonyPatch(nameof(GameOptionsMenu.Initialize)), HarmonyPrefix]
private static bool InitializePrefix(GameOptionsMenu __instance)
@@ -47,7 +47,26 @@ public static class GameOptionsMenuPatch
[HarmonyPatch(nameof(GameOptionsMenu.Initialize)), HarmonyPostfix]
private static void InitializePostfix()
{
GameObject.Find("PlayerOptionsMenu(Clone)")?.transform.FindChild("Background")?.gameObject.SetActive(false);
var optionMenu = GameObject.Find("PlayerOptionsMenu(Clone)");
optionMenu?.transform.FindChild("Background")?.gameObject.SetActive(false);
// By TommyXL
LateTask.New(() =>
{
var menuDescription = optionMenu?.transform.FindChild("What Is This?");
if (menuDescription == null) return;
var infoImage = menuDescription.transform.FindChild("InfoImage");
infoImage.transform.localPosition = new(-4.65f, 0.16f, -1f);
infoImage.transform.localScale = new(0.2202f, 0.2202f, 0.3202f);
var infoText = menuDescription.transform.FindChild("InfoText");
infoText.transform.localPosition = new(-3.5f, 0.83f, -2f);
infoText.transform.localScale = new(1f, 1f, 1f);
var cubeObject = menuDescription.transform.FindChild("Cube");
cubeObject.transform.localPosition = new(-3.2f, 0.55f, -0.1f);
cubeObject.transform.localScale = new(0.61f, 0.64f, 1f);
var menuDescriptionText = GameSettingMenu.Instance.MenuDescriptionText;
menuDescriptionText.m_marginWidth = 2.5f;
}, 0.1f, log: false);
}
[HarmonyPatch(nameof(GameOptionsMenu.CreateSettings)), HarmonyPrefix]
@@ -654,7 +673,7 @@ public static class StringOptionPatch
infoLong = str;
}
var info = $"<size=70%>{value.ToColoredString()}: {infoLong}</size>";
var info = $"{value.ToColoredString()}: {infoLong}";
GameSettingMenu.Instance.MenuDescriptionText.text = info;
}
}
@@ -790,7 +809,7 @@ public class GameSettingMenuPatch
public static FreeChatInputField InputField;
private static System.Collections.Generic.List<OptionItem> HiddenBySearch = [];
public static Action _SearchForOptions;
public static Action SearchForOptionsAction;
[HarmonyPatch(nameof(GameSettingMenu.Start)), HarmonyPrefix]
[HarmonyPriority(Priority.First)]
@@ -1011,7 +1030,7 @@ public class GameSettingMenuPatch
passiveButton.OnClick = new();
passiveButton.OnClick.AddListener((Action)(() => SearchForOptions(field)));
_SearchForOptions = (() =>
SearchForOptionsAction = (() =>
{
if (field.textArea.text != string.Empty)
SearchForOptions(field);
+13 -2
View File
@@ -140,6 +140,17 @@ static class HudManagerPatch
OverriddenRolesText.enabled = OverriddenRolesText.text != string.Empty;
}
else if (GameStates.IsLobby)
{
new ActionButton[]
{
__instance.ReportButton,
__instance.KillButton,
__instance.AbilityButton,
__instance.ImpostorVentButton,
__instance.SabotageButton
}.Do(x => x?.Hide());
}
// The following will not be executed unless the game is in progress
if (!AmongUsClient.Instance.IsGameStarted) return;
@@ -764,7 +775,7 @@ static class TaskPanelBehaviourPatch
AllText += "</size>";
break;
case CustomGameMode.RoomRush:
AllText += Main.AllPlayerControls
@@ -919,4 +930,4 @@ static class RepairSender
{
return SystemType + "(" + ((SystemTypes)SystemType) + ")\r\n" + Amount;
}
}
}
+1 -1
View File
@@ -798,7 +798,7 @@ static class IntroCutsceneDestroyPatch
{
if (pc.Is(CustomRoles.GM)) continue;
string petId = pet == "pet_RANDOM_FOR_EVERYONE" ? pets[r.Next(0, pets.Length - 1)] : pet;
PetsPatch.SetPet(pc, petId);
pc.RpcSetPetDesync(petId, pc);
Logger.Info($"{pc.GetNameWithRole()} => {GetString(petId)} Pet", "PetAssign");
}
+14 -2
View File
@@ -1,4 +1,6 @@
using HarmonyLib;
using System.Linq;
using HarmonyLib;
using InnerNet;
using TMPro;
using UnityEngine;
@@ -34,7 +36,17 @@ public static class HostInfoPanelUpdatePatch
public static void Postfix(HostInfoPanel __instance)
{
if (HostText == null) HostText = __instance.content.transform.FindChild("Name").GetComponent<TextMeshPro>();
var text = Main.HostRealName + (AmongUsClient.Instance.AmHost ? Translator.GetString("YouAreHostSuffix") : string.Empty);
var text = GameData.Instance.GetHost().Object.GetRealName() + (AmongUsClient.Instance.AmHost ? Translator.GetString(StringNames.HostYouLabel) : string.Empty);
HostText.text = Utils.ColorString(Palette.PlayerColors[__instance.player.ColorId], text);
}
}
public static class LobbyPatch
{
public static bool IsGlitchedRoomCode()
{
string roomCode = GameCode.IntToGameName(AmongUsClient.Instance.GameId).ToUpper();
string[] badEndings = ["IJPG", "SZAF", "LDQG", "ALGG", "UMPG", "GFXG", "JTFG", "PATG", "WMPG", "FUGG", "YTHG", "UFLG", "FBGG", "ZCQG", "RGGG", "ZHLG", "PJDG", "KJQG", "VDXG", "LCAF"];
return badEndings.Any(roomCode.EndsWith);
}
}
+12 -1
View File
@@ -5,6 +5,7 @@ using AmongUs.GameOptions;
using EHR.Impostor;
using EHR.Neutral;
using HarmonyLib;
using Hazel;
using UnityEngine;
namespace EHR.Patches;
@@ -70,7 +71,17 @@ static class ExternalRpcPetPatch
&& !Pelican.IsEaten(pc.PlayerId)
&& GameStates.IsInTask
&& pc.GetCustomRole().PetActivatedAbility())
physics.CancelPet();
{
CancelPet();
LateTask.New(CancelPet, 0.4f, log: false);
void CancelPet()
{
physics.CancelPet();
var w = AmongUsClient.Instance.StartRpcImmediately(physics.NetId, (byte)RpcCalls.CancelPet, SendOption.None);
AmongUsClient.Instance.FinishRpcImmediately(w);
}
}
if (!LastProcess.ContainsKey(pc.PlayerId)) LastProcess.TryAdd(pc.PlayerId, Utils.TimeStamp - 2);
if (LastProcess[pc.PlayerId] + 1 >= Utils.TimeStamp) return;
-28
View File
@@ -2,34 +2,6 @@
public static class PetsPatch
{
public static void SetPet(PlayerControl player, string petId)
{
if (player.Is(CustomRoles.GM)) return;
if (player.AmOwner)
{
player.SetPet(petId);
return;
}
var setEmpty = petId == "";
if (player.Data.DefaultOutfit.PetId == "" || setEmpty) player.Data.DefaultOutfit.PetId = petId;
if (player.CurrentOutfit.PetId == "" || setEmpty) player.CurrentOutfit.PetId = petId;
foreach (var kvp in player.Data.Outfits)
{
if (kvp.Value.PetId == "" || setEmpty)
{
kvp.Value.PetId = petId;
}
}
var sender = CustomRpcSender.Create(name: $"Set Pet to {petId} for {player.GetNameWithRole()}");
sender.AutoStartRpc(player.NetId, (byte)RpcCalls.SetPetStr)
.Write(petId)
.Write(player.GetNextRpcSequenceId(RpcCalls.SetPetStr))
.EndRpc();
sender.SendMessage();
}
public static void RpcRemovePet(PlayerControl pc)
{
if (pc == null || !pc.Data.IsDead || pc.IsAlive()) return;
+87 -40
View File
@@ -1,23 +1,21 @@
using System;
using System.Collections;
using AmongUs.GameOptions;
using HarmonyLib;
using Hazel;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem.Collections.Generic;
using UnityEngine;
namespace EHR.Patches;
// https://github.com/0xDrMoe/TownofHost-Enhanced/blob/12487ce1aa7e4f5087f2300be452b5af7c04d1ff/Patches/PhantomRolePatch.cs
// By TommyXL & NikoCat233
[HarmonyPatch(typeof(PlayerControl))]
public static class PhantomRolePatch
{
private static readonly List<PlayerControl> InvisibilityList = new();
/*
* InnerSloth is doing careless stuffs. They didn't put amModdedHost check in cmd check vanish appear.
* We temporarily need to patch the whole cmd function and wait for the next hotfix from them.
*/
private static readonly System.Collections.Generic.Dictionary<byte, string> PetsList = [];
[HarmonyPatch(nameof(PlayerControl.CmdCheckVanish)), HarmonyPrefix]
private static bool CmdCheckVanish_Prefix(PlayerControl __instance, float maxDuration)
@@ -50,6 +48,7 @@ public static class PhantomRolePatch
return false;
}
// Called when Phantom press vanish button when visible
[HarmonyPatch(nameof(PlayerControl.CheckVanish)), HarmonyPrefix]
private static void CheckVanish_Prefix(PlayerControl __instance)
{
@@ -66,10 +65,18 @@ public static class PhantomRolePatch
phantom.RpcCheckVanishDesync(target);
LateTask.New(() =>
{
if (GameStates.IsMeeting) return;
phantom?.RpcExileDesync(target);
}, 1.2f, "Set Phantom invisible", log: false);
{
if (GameStates.IsMeeting || phantom == null) return;
var petId = phantom.Data.DefaultOutfit.PetId;
if (petId != "")
{
PetsList[phantom.PlayerId] = petId;
phantom.RpcSetPetDesync("", target);
}
phantom.RpcExileDesync(target);
}, 1.2f, $"Set Phantom invisible {target.PlayerId}");
}
InvisibilityList.Add(phantom);
@@ -83,7 +90,7 @@ public static class PhantomRolePatch
var phantom = __instance;
Logger.Info($"Player: {phantom.GetRealName()} => shouldAnimate {shouldAnimate}", "CheckAppear");
if (phantom.walkingToVent || phantom.inVent)
if (phantom.inVent)
{
phantom.MyPhysics.RpcBootFromVent(Main.LastEnteredVent[phantom.PlayerId].Id);
}
@@ -97,19 +104,23 @@ public static class PhantomRolePatch
phantom.RpcSetRoleDesync(RoleTypes.Phantom, clientId);
LateTask.New(() =>
{
if (target != null)
{
phantom.RpcCheckAppearDesync(shouldAnimate, target);
}
}, 0.5f, "Check Appear when vanish is over", log: false);
if (target != null)
phantom.RpcCheckAppearDesync(shouldAnimate, target);
}, 0.5f, $"Check Appear when vanish is over {target.PlayerId}");
LateTask.New(() =>
{
if (GameStates.IsMeeting) return;
InvisibilityList.Remove(phantom);
phantom.RpcSetRoleDesync(RoleTypes.Scientist, clientId);
}, 1.8f, "Set Scientist when vanish is over", log: false);
{
if (GameStates.IsMeeting || phantom == null) return;
InvisibilityList.Remove(phantom);
phantom.RpcSetRoleDesync(RoleTypes.Scientist, clientId);
if (PetsList.TryGetValue(phantom.PlayerId, out var petId))
{
phantom.RpcSetPetDesync(petId, target);
}
}, 1.8f, $"Set Scientist when vanish is over {target.PlayerId}");
}
}
@@ -118,36 +129,72 @@ public static class PhantomRolePatch
{
if (!AmongUsClient.Instance.AmHost) return;
Logger.Info($"Player: {__instance.GetRealName()} => Is Active {isActive}, Animate: {shouldAnimate}, Full Animation: {playFullAnimation}", "SetRoleInvisibility");
Logger.Info($"Player: {__instance.GetRealName()} => Is Active {isActive}, Animate:{shouldAnimate}, Full Animation:{playFullAnimation}", "SetRoleInvisibility");
}
public static void OnReportBody(PlayerControl seer)
public static void OnReportDeadBody(PlayerControl seer, bool force)
{
if (InvisibilityList.Count == 0 || !seer.IsAlive() || seer.Data.Role.Role is RoleTypes.Phantom || seer.AmOwner || !seer.HasDesyncRole()) return;
foreach (var phantom in InvisibilityList)
{
if (!phantom.IsAlive()) continue;
var clientId = seer.GetClientId();
LateTask.New(() => phantom?.RpcSetRoleDesync(RoleTypes.Scientist, clientId), 0.01f, "Set Scientist in meeting", log: false);
LateTask.New(() => phantom?.RpcSetRoleDesync(RoleTypes.Phantom, clientId), 1f, "Set Phantom in meeting", log: false);
LateTask.New(() =>
if (!phantom.IsAlive())
{
if (seer != null)
phantom?.RpcStartAppearDesync(false, seer);
}, 1.5f, "Check Appear in meeting", log: false);
InvisibilityList.Remove(phantom);
continue;
}
LateTask.New(() =>
{
phantom?.RpcSetRoleDesync(RoleTypes.Scientist, clientId);
InvisibilityList.Clear();
}, 4f, "Set Scientist in meeting after reset", log: false);
Main.Instance.StartCoroutine(CoRevertInvisible(phantom, seer, force));
}
}
private static bool InValid(PlayerControl phantom, PlayerControl seer) => seer.GetClientId() == -1 || phantom == null;
private static IEnumerator CoRevertInvisible(PlayerControl phantom, PlayerControl seer, bool force)
{
// Set Scientist for meeting
if (!force)
{
yield return new WaitForSeconds(0.0001f);
}
if (InValid(phantom, seer)) yield break;
phantom?.RpcSetRoleDesync(RoleTypes.Scientist, seer.GetClientId());
// Return Phantom in meeting
yield return new WaitForSeconds(1f);
{
if (InValid(phantom, seer)) yield break;
phantom?.RpcSetRoleDesync(RoleTypes.Phantom, seer.GetClientId());
}
// Revert invis for phantom
yield return new WaitForSeconds(1f);
{
if (InValid(phantom, seer)) yield break;
phantom?.RpcStartAppearDesync(false, seer);
}
// Set Scientist back
yield return new WaitForSeconds(4f);
{
if (InValid(phantom, seer)) yield break;
phantom?.RpcSetRoleDesync(RoleTypes.Scientist, seer.GetClientId());
if (phantom != null && PetsList.TryGetValue(phantom.PlayerId, out var petId))
{
phantom.RpcSetPetDesync(petId, seer);
}
}
}
public static void AfterMeeting()
{
InvisibilityList.Clear();
PetsList.Clear();
}
}
// Fixed vanilla bug for host (from TOH-Y)
+3 -3
View File
@@ -1000,7 +1000,7 @@ static class ReportDeadBodyPatch
return true;
}
public static void AfterReportTasks(PlayerControl player, NetworkedPlayerInfo target)
public static void AfterReportTasks(PlayerControl player, NetworkedPlayerInfo target, bool force = false)
{
//====================================================================================
// Hereinafter, it is assumed that it is confirmed that the button is pressed.
@@ -1135,7 +1135,7 @@ static class ReportDeadBodyPatch
pc.FixMixedUpOutfit();
}
PhantomRolePatch.OnReportBody(pc);
PhantomRolePatch.OnReportDeadBody(pc, force);
}
MeetingTimeManager.OnReportDeadBody();
@@ -1311,7 +1311,7 @@ static class FixedUpdatePatch
BanManager.TempBanWhiteList.Add(hashedPuid);
}
if (!Main.AllPlayerControls.All(x => x.Data.PlayerLevel <= 1))
if (!Main.AllPlayerControls.All(x => x.Data.PlayerLevel <= 1) && !LobbyPatch.IsGlitchedRoomCode())
{
string msg = string.Format(GetString("KickBecauseLowLevel"), player.GetRealName().RemoveHtmlTags());
Logger.SendInGame(msg);
+4 -3
View File
@@ -479,8 +479,9 @@ static class VentilationSystemDeterioratePatch
++players;
}
if (pc.GetClosestVent().Id == LastClosestVent[pc.PlayerId] && players >= 3) continue;
LastClosestVent[pc.PlayerId] = pc.GetClosestVent().Id;
int closestVentId = pc.GetClosestVent().Id;
if (closestVentId == LastClosestVent[pc.PlayerId] && players >= 3) continue;
LastClosestVent[pc.PlayerId] = closestVentId;
MessageWriter writer = MessageWriter.Get();
writer.StartMessage(6);
writer.Write(AmongUsClient.Instance.GameId);
@@ -606,7 +607,7 @@ static class VentilationSystemDeterioratePatch
public static void CheckVentInteraction(PlayerControl pc)
{
if (!GameStates.IsInTask || ExileController.Instance) return;
if (!GameStates.IsInTask || ExileController.Instance || !ShipStatus.Instance) return;
const int bufferTimeWait = 10;
+73 -71
View File
@@ -7,7 +7,7 @@ using UnityEngine;
namespace EHR.Patches;
[HarmonyPatch(typeof(TextBoxTMP), nameof(TextBoxTMP.SetText))]
class TextBoxTMPSetTextPatch
static class TextBoxTMPSetTextPatch
{
private static TextMeshPro PlaceHolderText;
private static TextMeshPro CommandInfoText;
@@ -17,77 +17,78 @@ class TextBoxTMPSetTextPatch
// The only characters to treat specially are \r, \n and \b, allow all other characters to be written
public static bool Prefix(TextBoxTMP __instance, [HarmonyArgument(0)] string input, [HarmonyArgument(1)] string inputCompo = "")
{
bool flag = false;
char ch = ' ';
__instance.AdjustCaretPosition(input.Length - __instance.text.Length);
__instance.tempTxt.Clear();
foreach (char c in input)
{
char upperInvariant = c;
if (ch == ' ' && upperInvariant == ' ')
{
__instance.AdjustCaretPosition(-1);
}
else
{
switch (upperInvariant)
{
case '\r':
case '\n':
flag = true;
break;
case '\b':
__instance.tempTxt.Length = Math.Max(__instance.tempTxt.Length - 1, 0);
__instance.AdjustCaretPosition(-2);
break;
}
if (__instance.ForceUppercase) upperInvariant = char.ToUpperInvariant(upperInvariant);
if (upperInvariant is not '\r' and not '\n' and not '\b')
{
__instance.tempTxt.Append(upperInvariant);
ch = upperInvariant;
}
}
}
if (!__instance.tempTxt.ToString().Equals(DestroyableSingleton<TranslationController>.Instance.GetString(StringNames.EnterName), StringComparison.OrdinalIgnoreCase) && __instance.characterLimit > 0)
{
int length = __instance.tempTxt.Length;
__instance.tempTxt.Length = Math.Min(__instance.tempTxt.Length, __instance.characterLimit);
__instance.AdjustCaretPosition(-(length - __instance.tempTxt.Length));
}
input = __instance.tempTxt.ToString();
if (!input.Equals(__instance.text) || !inputCompo.Equals(__instance.compoText))
{
__instance.text = input;
__instance.compoText = inputCompo;
string str = __instance.text;
string compoText = __instance.compoText;
if (__instance.Hidden)
{
str = "";
for (int index = 0; index < __instance.text.Length; ++index)
str += "*";
}
__instance.outputText.text = str + compoText;
__instance.outputText.ForceMeshUpdate(true, true);
if (__instance.keyboard != null) __instance.keyboard.text = __instance.text;
__instance.OnChange.Invoke();
}
if (flag) __instance.OnEnter.Invoke();
try
{
bool flag = false;
char ch = ' ';
__instance.AdjustCaretPosition(input.Length - __instance.text.Length);
__instance.tempTxt.Clear();
foreach (char c in input)
{
char upperInvariant = c;
if (ch == ' ' && upperInvariant == ' ')
{
__instance.AdjustCaretPosition(-1);
}
else
{
switch (upperInvariant)
{
case '\r':
case '\n':
flag = true;
break;
case '\b':
__instance.tempTxt.Length = Math.Max(__instance.tempTxt.Length - 1, 0);
__instance.AdjustCaretPosition(-2);
break;
}
if (__instance.ForceUppercase) upperInvariant = char.ToUpperInvariant(upperInvariant);
if (upperInvariant is not '\r' and not '\n' and not '\b')
{
__instance.tempTxt.Append(upperInvariant);
ch = upperInvariant;
}
}
}
if (!__instance.tempTxt.ToString().Equals(DestroyableSingleton<TranslationController>.Instance.GetString(StringNames.EnterName), StringComparison.OrdinalIgnoreCase) && __instance.characterLimit > 0)
{
int length = __instance.tempTxt.Length;
__instance.tempTxt.Length = Math.Min(__instance.tempTxt.Length, __instance.characterLimit);
__instance.AdjustCaretPosition(-(length - __instance.tempTxt.Length));
}
input = __instance.tempTxt.ToString();
if (!input.Equals(__instance.text) || !inputCompo.Equals(__instance.compoText))
{
__instance.text = input;
__instance.compoText = inputCompo;
string str = __instance.text;
string compoText = __instance.compoText;
if (__instance.Hidden)
{
str = "";
for (int index = 0; index < __instance.text.Length; ++index)
str += "*";
}
__instance.outputText.text = str + compoText;
__instance.outputText.ForceMeshUpdate(true, true);
if (__instance.keyboard != null) __instance.keyboard.text = __instance.text;
__instance.OnChange.Invoke();
}
if (flag) __instance.OnEnter.Invoke();
__instance.SetPipePosition();
}
catch
catch (Exception e)
{
Utils.ThrowException(e);
}
return false;
@@ -249,6 +250,9 @@ class TextBoxTMPSetTextPatch
PlaceHolderText.text = text;
CommandInfoText.text = info;
PlaceHolderText.enabled = true;
CommandInfoText.enabled = true;
}
catch
{
@@ -261,14 +265,12 @@ class TextBoxTMPSetTextPatch
{
if (PlaceHolderText != null)
{
Object.Destroy(PlaceHolderText);
PlaceHolderText = null;
PlaceHolderText.enabled = false;
}
if (CommandInfoText != null)
{
Object.Destroy(CommandInfoText);
CommandInfoText = null;
CommandInfoText.enabled = false;
}
}
}
+2
View File
@@ -125,6 +125,7 @@ public class Executioner : RoleBase
var Executioner = Target.GetKeyByValue(target.PlayerId);
var ExePC = Utils.GetPlayerById(Executioner);
var newRole = CRoleChangeRoles[ChangeRolesAfterTargetKilled.GetValue()];
ExePC.RpcChangeRoleBasis(newRole);
ExePC.RpcSetCustomRole(newRole);
Target.Remove(Executioner);
SendRPC(Executioner);
@@ -136,6 +137,7 @@ public class Executioner : RoleBase
private static void ChangeRole(PlayerControl executioner)
{
var newRole = CRoleChangeRoles[ChangeRolesAfterTargetKilled.GetValue()];
executioner.RpcChangeRoleBasis(newRole);
executioner.RpcSetCustomRole(newRole);
Target.Remove(executioner.PlayerId);
SendRPC(executioner.PlayerId);
+8 -6
View File
@@ -10,19 +10,19 @@ namespace EHR.Neutral;
public class Lawyer : RoleBase
{
private const int Id = 9900;
public static List<byte> PlayerIdList = [];
private static List<byte> PlayerIdList = [];
private static OptionItem CanTargetImpostor;
private static OptionItem CanTargetNeutralKiller;
private static OptionItem CanTargetCrewmate;
private static OptionItem CanTargetJester;
public static OptionItem ChangeRolesAfterTargetKilled;
public static OptionItem KnowTargetRole;
public static OptionItem TargetKnowsLawyer;
private static OptionItem ChangeRolesAfterTargetKilled;
private static OptionItem KnowTargetRole;
private static OptionItem TargetKnowsLawyer;
public static Dictionary<byte, byte> Target = [];
public static readonly CustomRoles[] CRoleChangeRoles =
private static readonly CustomRoles[] CRoleChangeRoles =
[
CustomRoles.CrewmateEHR,
CustomRoles.Jester,
@@ -131,6 +131,7 @@ public class Lawyer : RoleBase
});
PlayerControl lawyer = Utils.GetPlayerById(Lawyer);
var newRole = CRoleChangeRoles[ChangeRolesAfterTargetKilled.GetValue()];
lawyer.RpcChangeRoleBasis(newRole);
lawyer.RpcSetCustomRole(newRole);
Target.Remove(Lawyer);
SendRPC(Lawyer);
@@ -158,9 +159,10 @@ public class Lawyer : RoleBase
return GetValue && targetId == target.PlayerId ? Utils.ColorString(Utils.GetRoleColor(CustomRoles.Lawyer), "§") : string.Empty;
}
public static void ChangeRole(PlayerControl lawyer)
private static void ChangeRole(PlayerControl lawyer)
{
var newRole = CRoleChangeRoles[ChangeRolesAfterTargetKilled.GetValue()];
lawyer.RpcChangeRoleBasis(newRole);
lawyer.RpcSetCustomRole(newRole);
Target.Remove(lawyer.PlayerId);
SendRPC(lawyer.PlayerId);
-1
View File
@@ -54,7 +54,6 @@ public class Main : BasePlugin
public static Dictionary<byte, PlayerVersion> PlayerVersion = [];
public static bool ChangedRole = false;
public static OptionBackupData RealOptionsData;
public static string HostRealName = string.Empty;
public static Dictionary<byte, float> KillTimers = [];
public static Dictionary<byte, PlayerState> PlayerStates = [];
public static Dictionary<byte, string> AllPlayerNames = [];