From 0c7cf4446054de409dfe63834122eb3fae3d034f Mon Sep 17 00:00:00 2001 From: Ultradragon005 <143632280+Ultradragon005@users.noreply.github.com> Date: Sun, 11 Aug 2024 20:55:20 +0200 Subject: [PATCH 01/43] wow I already broke the game, how fun..... --- Modules/ExtendedPlayerControl.cs | 4 +- Modules/Extensions/CollectionExtensions.cs | 2 + Modules/GameState.cs | 9 ++ Modules/Utils.cs | 72 ++++++++- Patches/ChatCommandPatch.cs | 6 +- Patches/PlayerControlPatch.cs | 29 +++- Resources/Lang/en_US.json | 32 +++- Resources/roleColor.json | 3 +- Roles/(Ghosts)/Crewmate/Telepathy.cs | 172 +++++++++++++++++++++ Roles/Crewmate/Medium.cs | 1 + TOHE.csproj | 2 +- main.cs | 4 + 12 files changed, 328 insertions(+), 8 deletions(-) create mode 100644 Roles/(Ghosts)/Crewmate/Telepathy.cs diff --git a/Modules/ExtendedPlayerControl.cs b/Modules/ExtendedPlayerControl.cs index 22cbf32aa5..d8bae1c84c 100644 --- a/Modules/ExtendedPlayerControl.cs +++ b/Modules/ExtendedPlayerControl.cs @@ -786,7 +786,7 @@ public static void RpcMurderPlayer(this PlayerControl killer, PlayerControl targ DollMaster.CheckMurderAsPossessed(killer, target); return; } - + Main.PlayerKilledBy[target.PlayerId] = KilledType.Indirectly; killer.RpcMurderPlayer(target, true); } @@ -897,6 +897,8 @@ public static bool KnowLivingTeam(this PlayerControl seer, PlayerControl target) && !target.Data.IsDead; private readonly static LogHandler logger = Logger.Handler("KnowRoleTarget"); + + public static bool KnowRoleTarget(PlayerControl seer, PlayerControl target, bool isVanilla = false) { if (Options.CurrentGameMode == CustomGameMode.FFA || GameEndCheckerForNormal.ShowAllRolesWhenGameEnd) diff --git a/Modules/Extensions/CollectionExtensions.cs b/Modules/Extensions/CollectionExtensions.cs index 4d73e45bb9..86500a015e 100644 --- a/Modules/Extensions/CollectionExtensions.cs +++ b/Modules/Extensions/CollectionExtensions.cs @@ -58,6 +58,8 @@ public static IEnumerable CombineWith(this IEnumerable firstCollection, /// The shuffled collection public static IEnumerable Shuffle(this IEnumerable collection, IRandom random) { + if (!collection.Any()) return default; + var list = collection.ToList(); int n = list.Count; while (n > 1) diff --git a/Modules/GameState.cs b/Modules/GameState.cs index cd8711ff4b..d21d3089cf 100644 --- a/Modules/GameState.cs +++ b/Modules/GameState.cs @@ -398,6 +398,15 @@ public bool IsEqual(PlayerVersion pv) { return pv.version == version && pv.tag == tag; } +} +public enum KilledType +{ + Directly, + Indirectly, + Remotely, + Suicide + + } public static class GameStates { diff --git a/Modules/Utils.cs b/Modules/Utils.cs index 15fb80446d..993658a937 100644 --- a/Modules/Utils.cs +++ b/Modules/Utils.cs @@ -1663,8 +1663,76 @@ public static List GetPlayerListByIds(this IEnumerable Play } public static List GetPlayerListByRole(this CustomRoles role) => GetPlayerListByIds(Main.PlayerStates.Values.Where(x => x.MainRole == role).Select(r => r.PlayerId)); - - public static IEnumerable GetRoleBasesByType () where t : RoleBase + + public static string DetermineSetMessage(PlayerControl Player, PlayerControl killer, out Dictionary DeterminedMessage) + { + string[] Translatables = { "Messenger.KillerLastKillIn", + "Messenger.KillerExistIn", "Messenger.KillersRoleIs", + "Messenger.KilledType", "Messenger.MyTypeIs", "Messenger.TheLastKillers", + "Messenger.PlayerOnSameTeam", "Messenger.LazyFuck", "Messenger.KillersFaction", "Messenger.ThisRoleExists"}; + + static t CreateAndInvoke(Func func) + { + return func.Invoke(); + } + + List TakeMsg = Translatables.ToList(); + var Msg = ""; + DeterminedMessage = []; + for (int i = 0; i < 3; i++) + { + var ran = TakeMsg.RandomElement(); + TakeMsg.Remove(ran); + var CurrentMessage = ran switch + { + "Messenger.KillerLastKillIn" when killer != null && killer.IsAlive() && Main.LastKillerRoom.TryGetValue(Player.PlayerId, out var pokoj) => string.Format(GetString("Messenger.KillerLastKillIn"), pokoj.RoomId), + "Messenger.KillerExistIn" when Main.AllAlivePlayerControls.Where(x => x.GetCustomRole().IsImpostor() || x.IsNeutralKiller() || x.IsNeutralApocalypse()).Shuffle(IRandom.Instance).FirstOrDefault() is not null and PlayerControl killar => CreateAndInvoke(() => + { + SystemTypes room = killar.GetPlainShipRoom().RoomId; + return string.Format(GetString("Messenger.KillerExistIn"), room); + }), + "Messenger.KillersRoleIs" when killer != null => string.Format(GetString("Messenger.KillersRoleIs"), killer.GetCustomRole()), + "Messenger.KilledType" when Main.PlayerKilledBy.TryGetValue(Player.PlayerId, out var KilledType) => string.Format(GetString("Messenger.KilledType"), KilledType), + "Messenger.MyTypeIs" => string.Format(GetString("Messenger.MyTypeIs"), (!Player.IsAnySubRole(x => x.IsConverted() && !Player.Is(CustomRoles.Madmate)) ? Player.GetCustomRole().GetCustomRoleTeam() : Custom_Team.Neutral)), + "Messenger.TheLastKillers" when Main.AllAlivePlayerControls.Where(x => x.GetCustomRole().IsImpostor() || x.IsNeutralKiller() || x.IsNeutralApocalypse()).Any() => CreateAndInvoke(() => + { + var Killers = Main.AllAlivePlayerControls.Where(x => x.GetCustomRole().IsImpostor() || x.IsNeutralKiller() || x.IsNeutralApocalypse()); + string msg = ""; + Killers.Do(x => msg += $"{x.GetCustomRole()}, "); + return string.Format(GetString("Messenger.TheLastKillers"), msg); + }), + "Messenger.PlayerOnSameTeam" when !Player.IsAnySubRole(x => x.IsConverted()) + && Main.AllAlivePlayerControls.FirstOrDefault(x => !x.IsAnySubRole(x => x.IsConverted()) && x.GetCustomRole().GetCustomRoleTeam() == Player.GetCustomRole().GetCustomRoleTeam()) is not null and PlayerControl friend => string.Format(GetString("Messenger.PlayerOnSameTeam"), friend.GetRealName(clientData: true)), + "Messenger.LazyFuck" => CreateAndInvoke(() => + { + var mintask = Main.AllAlivePlayerControls.Where(x => !x.HasImpKillButton()).Min(x => x.GetPlayerTaskState().CompletedTasksCount); + var lazyfuck = Main.AllAlivePlayerControls.First(x => x.GetPlayerTaskState().CompletedTasksCount == mintask); + + var suspects = Main.AllAlivePlayerControls.Where(x => x.HasImpKillButton()).AddItem(lazyfuck); + + var ScapeGoat = suspects.Shuffle(IRandom.Instance).First(); + + return string.Format(GetString("Messenger.LazyFuck"), ScapeGoat.GetRealName(clientData: true)); + }), + + "Messenger.KillersFaction" when killer != null => string.Format(GetString("Messenger.KillersFaction"), Main.RememberedFaction), + + _ => CreateAndInvoke(() => + { + var rndPC = Main.AllAlivePlayerControls.ToArray().RandomElement(); + return string.Format(GetString("Messenger.ThisRoleExists"), rndPC.GetCustomRole()); + }), + }; + DeterminedMessage[i] = CurrentMessage; + Msg += $"{i}) " + CurrentMessage + "\n"; + } + + + return Msg; + + } + +public static IEnumerable GetRoleBasesByType () where t : RoleBase { try { diff --git a/Patches/ChatCommandPatch.cs b/Patches/ChatCommandPatch.cs index 68a4d00b84..bc0d8cb7cf 100644 --- a/Patches/ChatCommandPatch.cs +++ b/Patches/ChatCommandPatch.cs @@ -6,6 +6,7 @@ using System.Text.RegularExpressions; using TOHE.Modules; using TOHE.Modules.ChatManager; +using TOHE.Roles._Ghosts_.Crewmate; using TOHE.Roles.Core; using TOHE.Roles.Core.AssignManager; using TOHE.Roles.Crewmate; @@ -67,7 +68,9 @@ public static bool Prefix(ChatController __instance) if (Nemesis.NemesisMsgCheck(PlayerControl.LocalPlayer, text)) goto Canceled; if (Retributionist.RetributionistMsgCheck(PlayerControl.LocalPlayer, text)) goto Canceled; if (Medium.MsMsg(PlayerControl.LocalPlayer, text)) goto Canceled; - if (PlayerControl.LocalPlayer.GetRoleClass() is Swapper sw && sw.SwapMsg(PlayerControl.LocalPlayer, text)) goto Canceled; + if (PlayerControl.LocalPlayer.GetRoleClass() is Swapper sw && sw.SwapMsg(PlayerControl.LocalPlayer, text)) goto Canceled; + if (Telepathy.TelepathyMessage(PlayerControl.LocalPlayer, args)) goto Canceled; + Directory.CreateDirectory(modTagsFiles); Directory.CreateDirectory(vipTagsFiles); Directory.CreateDirectory(sponsorTagsFiles); @@ -1887,6 +1890,7 @@ public static void OnReceiveChat(PlayerControl player, string text, out bool can if (Medium.MsMsg(player, text)) { Logger.Info($"Is Medium command", "OnReceiveChat"); return; } if (Nemesis.NemesisMsgCheck(player, text)) { Logger.Info($"Is Nemesis Revenge command", "OnReceiveChat"); return; } if (Retributionist.RetributionistMsgCheck(player, text)) { Logger.Info($"Is Retributionist Revenge command", "OnReceiveChat"); return; } + if (Telepathy.TelepathyMessage(PlayerControl.LocalPlayer, args)) { Logger.Info("Is Telepathy MSG command", "OnRecieveChat"); return; } Directory.CreateDirectory(modTagsFiles); Directory.CreateDirectory(vipTagsFiles); diff --git a/Patches/PlayerControlPatch.cs b/Patches/PlayerControlPatch.cs index 23a13f137a..9e090df8b0 100644 --- a/Patches/PlayerControlPatch.cs +++ b/Patches/PlayerControlPatch.cs @@ -392,6 +392,21 @@ public static bool Prefix(PlayerControl __instance, [HarmonyArgument(0)] PlayerC target.RpcShapeshift(target, false); } } + _ = new LateTask(() => { + + if (!Main.PlayerKilledBy.ContainsKey(target.PlayerId)) + { + + if (Vector2.Distance(target.GetRealKiller().GetCustomPosition(), target.transform.position) > 2f) + Main.PlayerKilledBy[target.PlayerId] = KilledType.Remotely; + else if (__instance == target) + Main.PlayerKilledBy[target.PlayerId] = KilledType.Suicide; + else + Main.PlayerKilledBy[target.PlayerId] = KilledType.Directly; + } + + }, 0.1f, "Set Main.Playerkilled by in MurderPlayer Patch"); + if (!target.IsProtected() && !Doppelganger.CheckDoppelVictim(target.PlayerId) && !Camouflage.ResetSkinAfterDeathPlayers.Contains(target.PlayerId)) { @@ -930,6 +945,7 @@ public static void AfterReportTasks(PlayerControl player, NetworkedPlayerInfo ta Main.AllKillers.Clear(); GuessManager.GuesserGuessed.Clear(); + Logger.Info($"target is null? - {target == null}", "AfterReportTasks"); Logger.Info($"target.Object is null? - {target?.Object == null}", "AfterReportTasks"); Logger.Info($"target.PlayerId is - {target?.PlayerId}", "AfterReportTasks"); @@ -939,6 +955,8 @@ public static void AfterReportTasks(PlayerControl player, NetworkedPlayerInfo ta try { playerStates.RoleClass?.OnReportDeadBody(player, target); + + if (!Utils.GetPlayerById(playerStates.PlayerId).IsAlive()) Main.LastKillerRoom[target.PlayerId] = target.Object.GetRealKiller().GetPlainShipRoom(); } catch (Exception error) { @@ -947,7 +965,14 @@ public static void AfterReportTasks(PlayerControl player, NetworkedPlayerInfo ta Logger.SendInGame($"Error: {error}"); } } - + if (target.Object != null & target.Object.GetRealKiller() != null) + { + if (target.Object.GetRealKiller().IsAnySubRole(x => x.IsConverted() && !target.Object.Is(CustomRoles.Madmate))) + Main.RememberedFaction = target.Object.GetRealKiller().GetCustomRole().GetCustomRoleTeam(); + else + Main.RememberedFaction = Custom_Team.Neutral; + } + // Alchemist & Bloodlust Alchemist.OnReportDeadBodyGlobal(); @@ -1853,6 +1878,8 @@ public static void Postfix(PlayerControl __instance) Utils.LateExileTask.Add(SelfExile); } } + if (!Main.PlayerKilledBy.ContainsKey(__instance.PlayerId)) + Main.PlayerKilledBy[__instance.PlayerId] = KilledType.Indirectly; } catch (Exception exx) { diff --git a/Resources/Lang/en_US.json b/Resources/Lang/en_US.json index d9d8d447c0..f53ee6b12d 100644 --- a/Resources/Lang/en_US.json +++ b/Resources/Lang/en_US.json @@ -292,6 +292,7 @@ "Doppelganger": "Doppelganger", "PunchingBag": "Punching Bag", "Doomsayer": "Doomsayer", + "Telepathy": "Telepathy", "Shroud": "Shroud", "Werewolf": "Werewolf", "Shaman": "Shaman", @@ -545,6 +546,7 @@ "LawyerInfo": "Help your target win!", "VectorInfo": "Jump in! Jump out!", "JackalInfo": "Murder everyone", + "TelepathyInfo": "Connect with the living", "GodInfo": "Everything is under your control", "InnocentInfo": "Get someone ejected by making them kill you", "PelicanInfo": "Eat all players", @@ -838,6 +840,7 @@ "HuntsmanInfoLong": "(Neutrals):\nAs the Huntsman, you are given a certain number of targets that reset every meeting. If you successfully eliminate one of your targets, your kill cooldown goes down permanently by the set amount. However, if you kill someone who is not one of your targets, your kill cooldown permanently increases by the set amount. A colored name indicates your targets.", "MiniInfoLong": "(Crewmate or Impostor):\nThe Mini has two roles. A Nice or Evil Mini is chosen.\n\nUse'/r nice mini' and '/r evil mini' respectively for more details.", "JesterInfoLong": "(Neutrals):\nIf the Jester gets voted out, the Jester wins the game alone. If the Jester is still alive at the end of the game, the Jester loses the game. Note: Jester, Executioner, and Innocent can win together.", + "TelepathyInfoLong": "(Crewmates [Ghost]):\nAs the Telepathy, You can use your protect button to connect with someone, connecting with someone again simply switches your target. \n\n In the upcoming meeting you will be able to answer a /tms {yes/no} question they have, or give them a set of possible messages depending on the settings (/tms {0/1/2}).", "TerroristInfoLong": "(Neutrals):\nIf the Terrorist dies after completing all tasks, the Terrorist wins the game alone. (They can win by either being voted out or killed).", "ExecutionerInfoLong": "(Neutrals):\nThe Executioner is a role with an execution target, indicated by a diamond symbol「♦」next to their name. If the execution target is killed, the Executioner's role will change to either Crewmate, Jester, or Opportunist, depending on the game settings. However, if the execution target is voted out in the meeting, the Executioner wins. Note: Jester, Executioner, and Innocent can win together.", "LawyerInfoLong": "(Neutrals):\nLawyer has a target to defend, which will be indicated by a diamond 「♦」 next to their name.\nIf your target wins, you win.\nIf they lose, you lose.", @@ -2038,7 +2041,34 @@ "MediumNotifyTarget": "{0}, the Medium, has established contact with you. Before the end of this meeting, you have a chance to respond to their question. Type one of the following commands to answer:\nConfirm: /ms yes\nDeny: /ms no", "MediumNotifySelf": "You established contact with {0}. Please ask them questions and wait for them to respond.\n\nRemaining ability uses: {1}", "MediumKnowPlayerDead": "Someone died somewhere", - + + "Messenger.KillerLastKillIn": "My killer was last in {0}", + "Messenger.KillerExistIn": "There is a killer in {0}", + "Messenger.KillersRoleIs": "The killer's role is {0}", + "Messenger.KilledType": "I was killed by an {0} kill", + "Messenger.MyTypeIs": "I am on the {0} team", + "Messenger.TheLastKillers": "The remaining killers are:\n{0}", + "Messenger.PlayerOnSameTeam": "{0} is on my team", + "Messenger.LazyFuck": "{0} has done none or the least amount of tasks", + "Messenger.KillersFaction": "The killer's faction is {0}", + "Messenger.ThisRoleExists": "There is a {0} alive", + + "TelepathyUses": "Max Connections", + "Telepathy_MessageMode": "Message Mode", + "Telepathy_MessageMode_YesNo": "Yes/no Confirmation", + "Telepathy_MessageMode_Message": "A Helpfull Message", + "TelepathyCantConnect": "Could not connect with target", + "TelepathyConnectWith": "You have made a connection with {0}", + "TelepathyYesNoUsage": "Use /tms {yes/no} to answer the player", + "TelepathyTitle": "TELEPATHY", + "TelepathyYes": "The telepathy confirms your worries", + "TelepathyNo": "The telepathy disregards your worries", + "TelepathyConfirmSelf": "You have succesfully sent your message", + "TelepathyMODE2Usage": "Use /tms {0/1/2} to submit your answers", + "TelepathyNotifyTarget": "The Telepathy {0} has made a connection with you, meaning you may ask it a question and it might answer back confirming or disregarding it.", + "TelepathyNotifyTargetMODE2": "The Telepathy {0} has made a connection with you, meaning you might hear useful info from them", + "TelepathyNotifySelf": "null", + "SpurtMinSpeed": "Min Speed", "SpurtMaxSpeed": "Max Speed", "SpurtModule": "Speed Modulator", diff --git a/Resources/roleColor.json b/Resources/roleColor.json index 576542cea5..3e52ed4a39 100644 --- a/Resources/roleColor.json +++ b/Resources/roleColor.json @@ -239,5 +239,6 @@ "Spurt": "#c9e8f5", "Ghastly": "#9ad6d4", "Glow": "#E2F147", - "Radar": "#1eff1e" + "Radar": "#1eff1e", + "Telepathy": "#9470b8" } diff --git a/Roles/(Ghosts)/Crewmate/Telepathy.cs b/Roles/(Ghosts)/Crewmate/Telepathy.cs new file mode 100644 index 0000000000..8c6142e3ae --- /dev/null +++ b/Roles/(Ghosts)/Crewmate/Telepathy.cs @@ -0,0 +1,172 @@ +using AmongUs.GameOptions; +using TOHE.Roles.Core; +using System; +using static TOHE.Options; +using static TOHE.Translator; +using static TOHE.MeetingHudStartPatch; +using static TOHE.Utils; + +namespace TOHE.Roles._Ghosts_.Crewmate; + +internal class Telepathy : RoleBase +{ + //===========================SETUP================================\\ + private const int Id = 28900; + public static bool HasEnabled => CustomRoleManager.HasEnabled(CustomRoles.NotAssigned); + public override bool IsExperimental => true; + public override CustomRoles ThisRoleBase => CustomRoles.GuardianAngel; + public override Custom_RoleType ThisRoleType => Custom_RoleType.CrewmateGhosts; + //==================================================================\\ + + private static OptionItem AbilityCooldown; + private static OptionItem AbilityUses; + private static OptionItem MessageMode; + public bool HasMessaged; + public static Dictionary TargetPlayer = []; + private Dictionary Determinemessage = []; + private enum MessageModeCount + { + Telepathy_MessageMode_YesNo, + Telepathy_MessageMode_Message + } + + public override void SetupCustomOption() + { + SetupRoleOptions(Id, TabGroup.CrewmateRoles, CustomRoles.Telepathy); + AbilityCooldown = FloatOptionItem.Create(Id + 10, GeneralOption.GuardianAngelBase_ProtectCooldown, new(2.5f, 120f, 2.5f), 35f, TabGroup.CrewmateRoles, false).SetParent(CustomRoleSpawnChances[CustomRoles.Telepathy]) + .SetValueFormat(OptionFormat.Seconds); + AbilityUses = IntegerOptionItem.Create(Id + 11, "TelepathyUses", new(1, 14, 1), 14, TabGroup.CrewmateRoles, false).SetParent(Options.CustomRoleSpawnChances[CustomRoles.Telepathy]) + .SetValueFormat(OptionFormat.Times); + MessageMode = StringOptionItem.Create(Id + 12, "Telepathy_MessageMode", EnumHelper.GetAllNames(), 0, TabGroup.CrewmateRoles, false).SetParent(CustomRoleSpawnChances[CustomRoles.Telepathy]); + } + public override void Init() + { + TargetPlayer.Clear(); + } + public override void Add(byte playerId) + { + AbilityLimit = AbilityUses.GetFloat(); + } + public override void ApplyGameOptions(IGameOptions opt, byte playerId) + { + AURoleOptions.GuardianAngelCooldown = AbilityCooldown.GetFloat(); + AURoleOptions.ProtectionDurationSeconds = 0f; + } + public override bool OnCheckProtect(PlayerControl angel, PlayerControl target) + { + if (AbilityLimit < 1) return false; + if (target.Is(CustomRoles.Medium)) + { + angel.Notify(GetString("TelepathyCantConnect")); + return false; + } + + + TargetPlayer[angel.PlayerId] = target.PlayerId; + angel.Notify(string.Format(GetString("TelepathyConnectWith"), target.GetRealName(clientData: true))); + AbilityLimit--; + SendSkillRPC(); + + return false; + } + public override void OnOtherTargetsReducedToAtoms(PlayerControl DeadPlayer) + { + if (TargetPlayer.ContainsValue(DeadPlayer.PlayerId)) + { + TargetPlayer.Remove(TargetPlayer.First(x => x.Value == DeadPlayer.PlayerId).Key); + } + } + public static bool TelepathyMessage(PlayerControl pc, string[] args) + { + if (!GameStates.IsMeeting || pc == null) return false; + if (!TargetPlayer.TryGetValue(pc.PlayerId, out var tar) || tar == byte.MaxValue) return false; + if (args.Length < 2) return false; + if (((Telepathy)pc.GetRoleClass())?.HasMessaged is null or true) return false; + + Dictionary DetermineMessage = ((Telepathy)pc.GetRoleClass())?.Determinemessage; + + + string[] cmds = {"/tms"}; + if (!cmds.Any(x => x.Equals(args[0], StringComparison.OrdinalIgnoreCase))) return false; + + switch (MessageMode.GetInt()) + { + case 0: + var Validation = (args[1].Equals(GetString("yes"), StringComparison.OrdinalIgnoreCase) || args[1].Equals(GetString("no"), StringComparison.OrdinalIgnoreCase)); + if (!Validation) + { + SendMessage(GetString("TelepathyYesNoUsage"), pc.PlayerId, title: GetString("TelepathyTitle")); + break; + } + var confirm = args[1].Equals(GetString("yes"), StringComparison.OrdinalIgnoreCase); + + SendMessage(GetString("Telepathy" + (confirm ? "Yes" : "No")), TargetPlayer[pc.PlayerId], ColorString(GetRoleColor(CustomRoles.Telepathy), GetString("TelepathyTitle"))); + SendMessage(GetString("TelepathyConfirmSelf"), pc.PlayerId, ColorString(GetRoleColor(CustomRoles.Telepathy), GetString("TelepathyTitle"))); + + break; + + + case 1: + if (!int.TryParse(args[1], out int id) || !DetermineMessage?.ContainsKey(id) is null or true) + { + SendMessage(GetString("TelepathyMODE2Usage"), pc.PlayerId, title: ColorString(GetRoleColor(CustomRoles.Telepathy), GetString("TelepathyTitle"))); + break; + } + + Utils.SendMessage(DetermineMessage[id], TargetPlayer[pc.PlayerId], title: ColorString(GetRoleColor(CustomRoles.Telepathy), GetString("TelepathyTitle"))); + SendMessage(GetString("TelepathyConfirmSelf"), pc.PlayerId, ColorString(GetRoleColor(CustomRoles.Telepathy), GetString("TelepathyTitle"))); + + break; + } + + + return true; + } + public override void OnReportDeadBody(PlayerControl reporter, NetworkedPlayerInfo target) + { + HasMessaged = false; + } + + public override void OnOthersMeetingHudStart(PlayerControl pc) + { + if (_Player == null) return; + + switch (MessageMode.GetInt()) + { + case 0: + if (TargetPlayer.TryGetValue(_Player.PlayerId, out var t) && t == pc.PlayerId) + AddMsg(string.Format(GetString("TelepathyNotifyTarget"), _Player.GetRealName(clientData: true), AbilityLimit), pc.PlayerId, Utils.ColorString(Utils.GetRoleColor(CustomRoles.Telepathy), GetString("TelepathyTitle"))); + + break; + + + case 1: + if (TargetPlayer.TryGetValue(_Player.PlayerId, out var w) && w == pc.PlayerId) + AddMsg(string.Format(GetString("TelepathyNotifyTargetMODE2"), _Player.GetRealName(clientData: true), AbilityLimit), pc.PlayerId, Utils.ColorString(Utils.GetRoleColor(CustomRoles.Telepathy), GetString("TelepathyTitle"))); + + break; + } + } + public override void OnMeetingHudStart(PlayerControl pc) + { + + switch (MessageMode.GetInt()) + { + case 0: + if (TargetPlayer.TryGetValue(pc.PlayerId, out var tar) && Utils.GetPlayerById(tar) != null) + AddMsg(string.Format(GetString("TelepathyNotifySelf"), Utils.GetPlayerById(tar).GetRealName(clientData: true), AbilityLimit), pc.PlayerId, Utils.ColorString(Utils.GetRoleColor(CustomRoles.Telepathy), GetString("TelepathyTitle"))); + + break; + + + case 1: + if (TargetPlayer.TryGetValue(pc.PlayerId, out var rat) && Utils.GetPlayerById(rat) != null) + { + var msg = DetermineSetMessage(pc, pc.GetRealKiller(), out Determinemessage); + AddMsg(string.Format(GetString("TelepathyNotifySelfMODE2"), Utils.GetPlayerById(rat).GetRealName(clientData: true), msg), pc.PlayerId, Utils.ColorString(Utils.GetRoleColor(CustomRoles.Telepathy), GetString("TelepathyTitle"))); + } + break; + } + + } +} diff --git a/Roles/Crewmate/Medium.cs b/Roles/Crewmate/Medium.cs index c4e2d84e91..58ef40b457 100644 --- a/Roles/Crewmate/Medium.cs +++ b/Roles/Crewmate/Medium.cs @@ -7,6 +7,7 @@ using static TOHE.Translator; using static TOHE.MeetingHudStartPatch; using InnerNet; +using TOHE.Roles._Ghosts_.Crewmate; namespace TOHE.Roles.Crewmate; diff --git a/TOHE.csproj b/TOHE.csproj index c8eb1b593c..1aaef98eaa 100644 --- a/TOHE.csproj +++ b/TOHE.csproj @@ -7,7 +7,7 @@ Town Of Host Enhanced Moe preview - + C:\Program Files\Epic Games\AmongUs Debug;Release;Canary true True diff --git a/main.cs b/main.cs index 12d63ab004..c8335a642d 100644 --- a/main.cs +++ b/main.cs @@ -154,6 +154,9 @@ public class Main : BasePlugin public static readonly Dictionary AllPlayerSpeed = []; public static readonly HashSet PlayersDiedInMeeting = []; public static readonly Dictionary AllKillers = []; + public static readonly Dictionary LastKillerRoom = []; + public static readonly Dictionary PlayerKilledBy = []; + public static Custom_Team RememberedFaction; public static readonly Dictionary CheckShapeshift = []; public static readonly Dictionary ShapeshiftTarget = []; @@ -660,6 +663,7 @@ public enum CustomRoles Ghastly, Hawk, Warden, + Telepathy, //Crewmate Addict, From aa06b231b85ca68618793f7f1a576a1651779bf4 Mon Sep 17 00:00:00 2001 From: Ultradragon005 <143632280+Ultradragon005@users.noreply.github.com> Date: Mon, 12 Aug 2024 11:40:15 +0200 Subject: [PATCH 02/43] fix bugs --- Modules/GameState.cs | 4 +- Modules/Utils.cs | 94 +++++++++++++++++++--------- Patches/PlayerControlPatch.cs | 17 +++-- Patches/onGameStartedPatch.cs | 3 + Resources/Lang/en_US.json | 22 ++++--- Roles/(Ghosts)/Crewmate/Telepathy.cs | 25 ++++---- main.cs | 3 +- 7 files changed, 109 insertions(+), 59 deletions(-) diff --git a/Modules/GameState.cs b/Modules/GameState.cs index d21d3089cf..d5a162563d 100644 --- a/Modules/GameState.cs +++ b/Modules/GameState.cs @@ -404,9 +404,7 @@ public enum KilledType Directly, Indirectly, Remotely, - Suicide - - + Suicide_ } public static class GameStates { diff --git a/Modules/Utils.cs b/Modules/Utils.cs index 993658a937..50aa5832e9 100644 --- a/Modules/Utils.cs +++ b/Modules/Utils.cs @@ -1664,6 +1664,25 @@ public static List GetPlayerListByIds(this IEnumerable Play public static List GetPlayerListByRole(this CustomRoles role) => GetPlayerListByIds(Main.PlayerStates.Values.Where(x => x.MainRole == role).Select(r => r.PlayerId)); + public static bool IsSameTeammate(this PlayerControl player, PlayerControl target, out Custom_Team team) + { + team = default; + if (player.IsAnySubRole(x => x.IsConverted())) + { + var Compare = player.GetCustomSubRoles().First(x => x.IsConverted()); + + team = player.Is(CustomRoles.Madmate) ? Custom_Team.Impostor : Custom_Team.Neutral; + return target.Is(Compare); + } + else if (!target.IsAnySubRole(x => x.IsConverted())) + { + team = player.GetCustomRole().GetCustomRoleTeam(); + return target.Is(team); + } + + + return false; + } public static string DetermineSetMessage(PlayerControl Player, PlayerControl killer, out Dictionary DeterminedMessage) { string[] Translatables = { "Messenger.KillerLastKillIn", @@ -1683,46 +1702,59 @@ static t CreateAndInvoke(Func func) { var ran = TakeMsg.RandomElement(); TakeMsg.Remove(ran); - var CurrentMessage = ran switch + var CurrentMessage = ""; + try { - "Messenger.KillerLastKillIn" when killer != null && killer.IsAlive() && Main.LastKillerRoom.TryGetValue(Player.PlayerId, out var pokoj) => string.Format(GetString("Messenger.KillerLastKillIn"), pokoj.RoomId), - "Messenger.KillerExistIn" when Main.AllAlivePlayerControls.Where(x => x.GetCustomRole().IsImpostor() || x.IsNeutralKiller() || x.IsNeutralApocalypse()).Shuffle(IRandom.Instance).FirstOrDefault() is not null and PlayerControl killar => CreateAndInvoke(() => + CurrentMessage = ran switch { - SystemTypes room = killar.GetPlainShipRoom().RoomId; - return string.Format(GetString("Messenger.KillerExistIn"), room); - }), - "Messenger.KillersRoleIs" when killer != null => string.Format(GetString("Messenger.KillersRoleIs"), killer.GetCustomRole()), - "Messenger.KilledType" when Main.PlayerKilledBy.TryGetValue(Player.PlayerId, out var KilledType) => string.Format(GetString("Messenger.KilledType"), KilledType), - "Messenger.MyTypeIs" => string.Format(GetString("Messenger.MyTypeIs"), (!Player.IsAnySubRole(x => x.IsConverted() && !Player.Is(CustomRoles.Madmate)) ? Player.GetCustomRole().GetCustomRoleTeam() : Custom_Team.Neutral)), - "Messenger.TheLastKillers" when Main.AllAlivePlayerControls.Where(x => x.GetCustomRole().IsImpostor() || x.IsNeutralKiller() || x.IsNeutralApocalypse()).Any() => CreateAndInvoke(() => - { - var Killers = Main.AllAlivePlayerControls.Where(x => x.GetCustomRole().IsImpostor() || x.IsNeutralKiller() || x.IsNeutralApocalypse()); - string msg = ""; - Killers.Do(x => msg += $"{x.GetCustomRole()}, "); - return string.Format(GetString("Messenger.TheLastKillers"), msg); - }), - "Messenger.PlayerOnSameTeam" when !Player.IsAnySubRole(x => x.IsConverted()) - && Main.AllAlivePlayerControls.FirstOrDefault(x => !x.IsAnySubRole(x => x.IsConverted()) && x.GetCustomRole().GetCustomRoleTeam() == Player.GetCustomRole().GetCustomRoleTeam()) is not null and PlayerControl friend => string.Format(GetString("Messenger.PlayerOnSameTeam"), friend.GetRealName(clientData: true)), - "Messenger.LazyFuck" => CreateAndInvoke(() => - { - var mintask = Main.AllAlivePlayerControls.Where(x => !x.HasImpKillButton()).Min(x => x.GetPlayerTaskState().CompletedTasksCount); - var lazyfuck = Main.AllAlivePlayerControls.First(x => x.GetPlayerTaskState().CompletedTasksCount == mintask); + "Messenger.KillerLastKillIn" when killer != null && killer.IsAlive() && Main.LastKillerRoom.TryGetValue(Player.PlayerId, out var pokoj) => string.Format(GetString("Messenger.KillerLastKillIn"), pokoj.RoomId), + "Messenger.KillerExistIn" when Main.AllAlivePlayerControls.Where(x => x.GetCustomRole().IsImpostor() || x.IsNeutralKiller() || x.IsNeutralApocalypse()).Shuffle(IRandom.Instance).FirstOrDefault() is not null and PlayerControl killar => CreateAndInvoke(() => + { + SystemTypes room = killar.GetPlainShipRoom().RoomId; + return string.Format(GetString("Messenger.KillerExistIn"), room); + }), + "Messenger.KillersRoleIs" when Main.RememberKillerRole != "" => string.Format(GetString("Messenger.KillersRoleIs"), Main.RememberKillerRole), + "Messenger.KilledType" when Main.PlayerKilledBy.TryGetValue(Player.PlayerId, out var KilledType) => string.Format(GetString("Messenger.KilledType"), GetString($"{KilledType}")), + "Messenger.MyTypeIs" => string.Format(GetString("Messenger.MyTypeIs"), (!Player.IsAnySubRole(x => x.IsConverted() && !Player.Is(CustomRoles.Madmate)) ? Player.GetCustomRole().GetCustomRoleTeam() : Custom_Team.Neutral)), + "Messenger.TheLastKillers" when Main.AllAlivePlayerControls.Where(x => x.GetCustomRole().IsImpostor() || x.IsNeutralKiller() || x.IsNeutralApocalypse()).Any() => CreateAndInvoke(() => + { + var Killers = Main.AllAlivePlayerControls.Where(x => x.GetCustomRole().IsImpostor() || x.IsNeutralKiller() || x.IsNeutralApocalypse()); + string msg = ""; + Killers.Do(x => msg += $"{GetString($"{x.GetCustomRole()}")}, "); + return string.Format(GetString("Messenger.TheLastKillers"), msg); + }), + "Messenger.PlayerOnSameTeam" when Main.AllAlivePlayerControls.Shuffle(IRandom.Instance).FirstOrDefault(x => Player.IsSameTeammate(x, out _)) is not null and PlayerControl friend => string.Format(GetString("Messenger.PlayerOnSameTeam"), friend.GetRealName(clientData: true)), + "Messenger.LazyFuck" => CreateAndInvoke(() => + { + var mintask = Main.AllAlivePlayerControls.Where(x => !x.HasImpKillButton()).Min(x => x.GetPlayerTaskState().CompletedTasksCount); + var lazyfuck = Main.AllAlivePlayerControls.First(x => x.GetPlayerTaskState().CompletedTasksCount == mintask); - var suspects = Main.AllAlivePlayerControls.Where(x => x.HasImpKillButton()).AddItem(lazyfuck); + var suspects = Main.AllAlivePlayerControls.Where(x => x.HasImpKillButton()).AddItem(lazyfuck); - var ScapeGoat = suspects.Shuffle(IRandom.Instance).First(); + var ScapeGoat = suspects.Shuffle(IRandom.Instance).First(); - return string.Format(GetString("Messenger.LazyFuck"), ScapeGoat.GetRealName(clientData: true)); - }), + return string.Format(GetString("Messenger.LazyFuck"), ScapeGoat.GetRealName(clientData: true)); + }), - "Messenger.KillersFaction" when killer != null => string.Format(GetString("Messenger.KillersFaction"), Main.RememberedFaction), + "Messenger.KillersFaction" when Main.RememberedFaction != null => string.Format(GetString("Messenger.KillersFaction"), Main.RememberedFaction.Value), - _ => CreateAndInvoke(() => + _ => CreateAndInvoke(() => + { + var rndPC = Main.AllAlivePlayerControls.ToArray().RandomElement(); + return string.Format(GetString("Messenger.ThisRoleExists"), GetString($"{rndPC.GetCustomRole()}")); + }), + }; + } + catch(Exception exx) + { + CurrentMessage = CreateAndInvoke(() => { var rndPC = Main.AllAlivePlayerControls.ToArray().RandomElement(); - return string.Format(GetString("Messenger.ThisRoleExists"), rndPC.GetCustomRole()); - }), - }; + return string.Format(GetString("Messenger.ThisRoleExists"), GetString($"{rndPC.GetCustomRole()}")); + }); + Logger.Warn($" The case ( {ran} ) Returned an error", "Utils.DetermineSetMessag"); + Utils.ThrowException(exx); + } DeterminedMessage[i] = CurrentMessage; Msg += $"{i}) " + CurrentMessage + "\n"; } diff --git a/Patches/PlayerControlPatch.cs b/Patches/PlayerControlPatch.cs index 9e090df8b0..1278c1cfc9 100644 --- a/Patches/PlayerControlPatch.cs +++ b/Patches/PlayerControlPatch.cs @@ -399,8 +399,8 @@ public static bool Prefix(PlayerControl __instance, [HarmonyArgument(0)] PlayerC if (Vector2.Distance(target.GetRealKiller().GetCustomPosition(), target.transform.position) > 2f) Main.PlayerKilledBy[target.PlayerId] = KilledType.Remotely; - else if (__instance == target) - Main.PlayerKilledBy[target.PlayerId] = KilledType.Suicide; + else if (target.GetRealKiller() == target) + Main.PlayerKilledBy[target.PlayerId] = KilledType.Suicide_; else Main.PlayerKilledBy[target.PlayerId] = KilledType.Directly; } @@ -949,6 +949,7 @@ public static void AfterReportTasks(PlayerControl player, NetworkedPlayerInfo ta Logger.Info($"target is null? - {target == null}", "AfterReportTasks"); Logger.Info($"target.Object is null? - {target?.Object == null}", "AfterReportTasks"); Logger.Info($"target.PlayerId is - {target?.PlayerId}", "AfterReportTasks"); + Main.RememberKillerRole = ""; foreach (var playerStates in Main.PlayerStates.Values.ToArray()) { @@ -956,7 +957,11 @@ public static void AfterReportTasks(PlayerControl player, NetworkedPlayerInfo ta { playerStates.RoleClass?.OnReportDeadBody(player, target); - if (!Utils.GetPlayerById(playerStates.PlayerId).IsAlive()) Main.LastKillerRoom[target.PlayerId] = target.Object.GetRealKiller().GetPlainShipRoom(); + if (!Utils.GetPlayerById(playerStates.PlayerId).IsAlive() && target?.Object?.GetRealKiller() != null) + { + Main.RememberKillerRole = GetString($"{target.Object.GetRealKiller().GetCustomRole()}"); + Main.LastKillerRoom[target.PlayerId] = target.Object.GetRealKiller().GetPlainShipRoom(); + } } catch (Exception error) { @@ -965,14 +970,16 @@ public static void AfterReportTasks(PlayerControl player, NetworkedPlayerInfo ta Logger.SendInGame($"Error: {error}"); } } - if (target.Object != null & target.Object.GetRealKiller() != null) + + Main.RememberedFaction = null; + if (target?.Object?.GetRealKiller() != null) { if (target.Object.GetRealKiller().IsAnySubRole(x => x.IsConverted() && !target.Object.Is(CustomRoles.Madmate))) Main.RememberedFaction = target.Object.GetRealKiller().GetCustomRole().GetCustomRoleTeam(); else Main.RememberedFaction = Custom_Team.Neutral; } - + // Alchemist & Bloodlust Alchemist.OnReportDeadBodyGlobal(); diff --git a/Patches/onGameStartedPatch.cs b/Patches/onGameStartedPatch.cs index 92c98b74ea..f48e769233 100644 --- a/Patches/onGameStartedPatch.cs +++ b/Patches/onGameStartedPatch.cs @@ -65,6 +65,9 @@ public static void Postfix(AmongUsClient __instance) Main.clientIdList.Clear(); PlayerControlSetRolePatch.DidSetGhost.Clear(); + Main.LastKillerRoom.Clear(); + Main.RememberedFaction = null; + Main.PlayerKilledBy.Clear(); Main.CheckShapeshift.Clear(); Main.ShapeshiftTarget.Clear(); diff --git a/Resources/Lang/en_US.json b/Resources/Lang/en_US.json index 10b310b739..271726d9e1 100644 --- a/Resources/Lang/en_US.json +++ b/Resources/Lang/en_US.json @@ -2060,29 +2060,35 @@ "Messenger.KillerLastKillIn": "My killer was last in {0}", "Messenger.KillerExistIn": "There is a killer in {0}", "Messenger.KillersRoleIs": "The killer's role is {0}", - "Messenger.KilledType": "I was killed by an {0} kill", + "Messenger.KilledType": "I was killed {0}", "Messenger.MyTypeIs": "I am on the {0} team", "Messenger.TheLastKillers": "The remaining killers are:\n{0}", "Messenger.PlayerOnSameTeam": "{0} is on my team", "Messenger.LazyFuck": "{0} has done none or the least amount of tasks", "Messenger.KillersFaction": "The killer's faction is {0}", "Messenger.ThisRoleExists": "There is a {0} alive", + "Suicide_": "By Suicide", + "Remotely": "Remotely", + "Indirectly": "Indirectly", + "Directly": "Directly", "TelepathyUses": "Max Connections", "Telepathy_MessageMode": "Message Mode", - "Telepathy_MessageMode_YesNo": "Yes/no Confirmation", - "Telepathy_MessageMode_Message": "A Helpfull Message", + "Telepathy_MessageMode_YesNo": "Yes/No Confirmation", + "Telepathy_MessageMode_Message": "A Helpful Message", "TelepathyCantConnect": "Could not connect with target", "TelepathyConnectWith": "You have made a connection with {0}", "TelepathyYesNoUsage": "Use /tms {yes/no} to answer the player", "TelepathyTitle": "TELEPATHY", - "TelepathyYes": "The telepathy confirms your worries", - "TelepathyNo": "The telepathy disregards your worries", + "TelepathyTitleTarget": "The Telepathy whispers to you...", + "TelepathyYes": "The telepathy confirms your inquiry", + "TelepathyNo": "The telepathy denies your inquiry", "TelepathyConfirmSelf": "You have succesfully sent your message", "TelepathyMODE2Usage": "Use /tms {0/1/2} to submit your answers", - "TelepathyNotifyTarget": "The Telepathy {0} has made a connection with you, meaning you may ask it a question and it might answer back confirming or disregarding it.", - "TelepathyNotifyTargetMODE2": "The Telepathy {0} has made a connection with you, meaning you might hear useful info from them", - "TelepathyNotifySelf": "null", + "TelepathyNotifyTarget": "The Telepathy {0} has made a connection with you, meaning you may ask it a question and it might answer back confirming or denying it.", + "TelepathyNotifyTargetMODE2": "The Telepathy {0} has made a connection with you, meaning you might hear useful info from them.", + "TelepathyNotifySelf": "You have made a connection with {0}, answer with /tms [yes/no] to one of their questions.\n Note: They may try to disguise their question, so be on watch", + "TelepathyNotifySelfMODE2": "What would you like to whisper to {0}?\n{1}\n\nUse /tms [0/1/2] to answer.", "SpurtMinSpeed": "Min Speed", "SpurtMaxSpeed": "Max Speed", diff --git a/Roles/(Ghosts)/Crewmate/Telepathy.cs b/Roles/(Ghosts)/Crewmate/Telepathy.cs index 8c6142e3ae..067e5991df 100644 --- a/Roles/(Ghosts)/Crewmate/Telepathy.cs +++ b/Roles/(Ghosts)/Crewmate/Telepathy.cs @@ -55,7 +55,7 @@ public override void ApplyGameOptions(IGameOptions opt, byte playerId) public override bool OnCheckProtect(PlayerControl angel, PlayerControl target) { if (AbilityLimit < 1) return false; - if (target.Is(CustomRoles.Medium)) + if (target.Is(CustomRoles.Medium) || TargetPlayer.ContainsValue(target.PlayerId)) { angel.Notify(GetString("TelepathyCantConnect")); return false; @@ -92,15 +92,16 @@ public static bool TelepathyMessage(PlayerControl pc, string[] args) switch (MessageMode.GetInt()) { case 0: - var Validation = (args[1].Equals(GetString("yes"), StringComparison.OrdinalIgnoreCase) || args[1].Equals(GetString("no"), StringComparison.OrdinalIgnoreCase)); + var Validation = (args[1].Equals(GetString("Yes"), StringComparison.OrdinalIgnoreCase) || args[1].Equals(GetString("No"), StringComparison.OrdinalIgnoreCase)); if (!Validation) { SendMessage(GetString("TelepathyYesNoUsage"), pc.PlayerId, title: GetString("TelepathyTitle")); break; } - var confirm = args[1].Equals(GetString("yes"), StringComparison.OrdinalIgnoreCase); + var confirm = args[1].Equals(GetString("Yes"), StringComparison.OrdinalIgnoreCase); + ((Telepathy)pc.GetRoleClass()).HasMessaged = true; - SendMessage(GetString("Telepathy" + (confirm ? "Yes" : "No")), TargetPlayer[pc.PlayerId], ColorString(GetRoleColor(CustomRoles.Telepathy), GetString("TelepathyTitle"))); + SendMessage(GetString("Telepathy" + (confirm ? "Yes" : "No")), TargetPlayer[pc.PlayerId], ColorString(GetRoleColor(CustomRoles.Telepathy), GetString("TelepathyTitleTarget"))); SendMessage(GetString("TelepathyConfirmSelf"), pc.PlayerId, ColorString(GetRoleColor(CustomRoles.Telepathy), GetString("TelepathyTitle"))); break; @@ -112,8 +113,9 @@ public static bool TelepathyMessage(PlayerControl pc, string[] args) SendMessage(GetString("TelepathyMODE2Usage"), pc.PlayerId, title: ColorString(GetRoleColor(CustomRoles.Telepathy), GetString("TelepathyTitle"))); break; } + ((Telepathy)pc.GetRoleClass()).HasMessaged = true; - Utils.SendMessage(DetermineMessage[id], TargetPlayer[pc.PlayerId], title: ColorString(GetRoleColor(CustomRoles.Telepathy), GetString("TelepathyTitle"))); + Utils.SendMessage(DetermineMessage[id], TargetPlayer[pc.PlayerId], title: ColorString(GetRoleColor(CustomRoles.Telepathy), GetString("TelepathyTitleTarget"))); SendMessage(GetString("TelepathyConfirmSelf"), pc.PlayerId, ColorString(GetRoleColor(CustomRoles.Telepathy), GetString("TelepathyTitle"))); break; @@ -126,6 +128,10 @@ public override void OnReportDeadBody(PlayerControl reporter, NetworkedPlayerInf { HasMessaged = false; } + public override void AfterMeetingTasks() + { + TargetPlayer.Clear(); + } public override void OnOthersMeetingHudStart(PlayerControl pc) { @@ -135,30 +141,27 @@ public override void OnOthersMeetingHudStart(PlayerControl pc) { case 0: if (TargetPlayer.TryGetValue(_Player.PlayerId, out var t) && t == pc.PlayerId) - AddMsg(string.Format(GetString("TelepathyNotifyTarget"), _Player.GetRealName(clientData: true), AbilityLimit), pc.PlayerId, Utils.ColorString(Utils.GetRoleColor(CustomRoles.Telepathy), GetString("TelepathyTitle"))); + AddMsg(string.Format(GetString("TelepathyNotifyTarget"), _Player.GetRealName(clientData: true)), pc.PlayerId, Utils.ColorString(Utils.GetRoleColor(CustomRoles.Telepathy), GetString("TelepathyTitle"))); break; case 1: if (TargetPlayer.TryGetValue(_Player.PlayerId, out var w) && w == pc.PlayerId) - AddMsg(string.Format(GetString("TelepathyNotifyTargetMODE2"), _Player.GetRealName(clientData: true), AbilityLimit), pc.PlayerId, Utils.ColorString(Utils.GetRoleColor(CustomRoles.Telepathy), GetString("TelepathyTitle"))); + AddMsg(string.Format(GetString("TelepathyNotifyTargetMODE2"), _Player.GetRealName(clientData: true)), pc.PlayerId, Utils.ColorString(Utils.GetRoleColor(CustomRoles.Telepathy), GetString("TelepathyTitle"))); break; } } public override void OnMeetingHudStart(PlayerControl pc) { - switch (MessageMode.GetInt()) { case 0: if (TargetPlayer.TryGetValue(pc.PlayerId, out var tar) && Utils.GetPlayerById(tar) != null) - AddMsg(string.Format(GetString("TelepathyNotifySelf"), Utils.GetPlayerById(tar).GetRealName(clientData: true), AbilityLimit), pc.PlayerId, Utils.ColorString(Utils.GetRoleColor(CustomRoles.Telepathy), GetString("TelepathyTitle"))); - + AddMsg(string.Format(GetString("TelepathyNotifySelf"), Utils.GetPlayerById(tar).GetRealName(clientData: true)), pc.PlayerId, Utils.ColorString(Utils.GetRoleColor(CustomRoles.Telepathy), GetString("TelepathyTitle"))); break; - case 1: if (TargetPlayer.TryGetValue(pc.PlayerId, out var rat) && Utils.GetPlayerById(rat) != null) { diff --git a/main.cs b/main.cs index bfdb0a6f30..1a277ace99 100644 --- a/main.cs +++ b/main.cs @@ -156,7 +156,8 @@ public class Main : BasePlugin public static readonly Dictionary AllKillers = []; public static readonly Dictionary LastKillerRoom = []; public static readonly Dictionary PlayerKilledBy = []; - public static Custom_Team RememberedFaction; + public static Custom_Team? RememberedFaction; + public static string RememberKillerRole = ""; public static readonly Dictionary CheckShapeshift = []; public static readonly Dictionary ShapeshiftTarget = []; From ceb415e2db94273c73c3ac1bcc08c9f263ed6e87 Mon Sep 17 00:00:00 2001 From: Ultradragon005 <143632280+Ultradragon005@users.noreply.github.com> Date: Mon, 12 Aug 2024 12:32:15 +0200 Subject: [PATCH 03/43] now finally time to begin on Messenger --- Resources/Lang/en_US.json | 4 ++-- Roles/(Ghosts)/Crewmate/Telepathy.cs | 20 +++++++++++++++++++- Roles/Core/AssignManager/RoleAssign.cs | 7 +++++-- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/Resources/Lang/en_US.json b/Resources/Lang/en_US.json index 271726d9e1..7d6707e027 100644 --- a/Resources/Lang/en_US.json +++ b/Resources/Lang/en_US.json @@ -2087,8 +2087,8 @@ "TelepathyMODE2Usage": "Use /tms {0/1/2} to submit your answers", "TelepathyNotifyTarget": "The Telepathy {0} has made a connection with you, meaning you may ask it a question and it might answer back confirming or denying it.", "TelepathyNotifyTargetMODE2": "The Telepathy {0} has made a connection with you, meaning you might hear useful info from them.", - "TelepathyNotifySelf": "You have made a connection with {0}, answer with /tms [yes/no] to one of their questions.\n Note: They may try to disguise their question, so be on watch", - "TelepathyNotifySelfMODE2": "What would you like to whisper to {0}?\n{1}\n\nUse /tms [0/1/2] to answer.", + "TelepathyNotifySelf": "You have made a connection with {0}, answer with /tms [yes/no] to one of their questions.\n Note: They may try to disguise their question, so be on watch", + "TelepathyNotifySelfMODE2": "What would you like to whisper to {0}?\n\n{1}\n\nUse /tms [0/1/2] to answer.", "SpurtMinSpeed": "Min Speed", "SpurtMaxSpeed": "Max Speed", diff --git a/Roles/(Ghosts)/Crewmate/Telepathy.cs b/Roles/(Ghosts)/Crewmate/Telepathy.cs index 067e5991df..3c8cd2ce64 100644 --- a/Roles/(Ghosts)/Crewmate/Telepathy.cs +++ b/Roles/(Ghosts)/Crewmate/Telepathy.cs @@ -170,6 +170,24 @@ public override void OnMeetingHudStart(PlayerControl pc) } break; } - + } + + public override string GetSuffixOthers(PlayerControl seer, PlayerControl seen, bool isForMeeting = false) + { + if (!isForMeeting) return string.Empty; + + var checkTar = TargetPlayer.Where(x => x.Value == seer.PlayerId); + if (TargetPlayer.TryGetValue(seer.PlayerId, out var tar) && tar == seen.PlayerId) + { + return ColorString(GetRoleColor(CustomRoles.Telepathy), "¿"); + } + else if (checkTar.Any()) + { + var Telepathy = Utils.GetPlayerById(checkTar.First().Key); + + return seen == Telepathy ? ColorString(GetRoleColor(CustomRoles.Telepathy), "¿") : ""; + } + + return string.Empty; } } diff --git a/Roles/Core/AssignManager/RoleAssign.cs b/Roles/Core/AssignManager/RoleAssign.cs index 395e3d0b39..a56eef8d11 100644 --- a/Roles/Core/AssignManager/RoleAssign.cs +++ b/Roles/Core/AssignManager/RoleAssign.cs @@ -156,13 +156,16 @@ public static void StartSelect() // DistinctBy - Removes duplicate roles if there are any // Shuffle - Shuffles all roles in the list into a randomized order // Take - Takes the first x roles of the list ... x is the maximum number of roles we could need of that team - + Roles[RoleAssignType.Impostor] = Roles[RoleAssignType.Impostor].Shuffle(rd).Take(optImpNum).ToList(); + + // Will have to fix this later, for now disabled for testing Roles[RoleAssignType.NeutralKilling] = Roles[RoleAssignType.NeutralKilling].Shuffle(rd).Take(optNeutralKillingNum).ToList(); Roles[RoleAssignType.NeutralApocalypse] = Roles[RoleAssignType.NeutralApocalypse].Shuffle(rd).Take(optNeutralApocalypseNum).ToList(); Roles[RoleAssignType.NonKillingNeutral] = Roles[RoleAssignType.NonKillingNeutral].Shuffle(rd).Take(optNonNeutralKillingNum).ToList(); Roles[RoleAssignType.Crewmate] = Roles[RoleAssignType.Crewmate].Shuffle(rd).Take(playerCount).ToList(); + /* Roles[RoleAssignType.Impostor].AddRange(TempAlwaysImpRoles); Roles[RoleAssignType.NeutralKilling].AddRange(TempAlwaysNKRoles); Roles[RoleAssignType.NeutralApocalypse].AddRange(TempAlwaysNARoles); @@ -173,7 +176,7 @@ public static void StartSelect() Roles[RoleAssignType.NeutralKilling] = Roles[RoleAssignType.NeutralKilling].DistinctBy(x => x.Role).ToList(); Roles[RoleAssignType.NeutralApocalypse] = Roles[RoleAssignType.NeutralApocalypse].DistinctBy(x => x.Role).ToList(); Roles[RoleAssignType.NonKillingNeutral] = Roles[RoleAssignType.NonKillingNeutral].DistinctBy(x => x.Role).ToList(); - Roles[RoleAssignType.Crewmate] = Roles[RoleAssignType.Crewmate].DistinctBy(x => x.Role).ToList(); + Roles[RoleAssignType.Crewmate] = Roles[RoleAssignType.Crewmate].DistinctBy(x => x.Role).ToList();*/ Logger.Msg("======================================================", "SelectedRoles"); Logger.Info(string.Join(", ", Roles[RoleAssignType.Impostor].Select(x => x.Role.ToString())), "Selected-Impostor-Roles"); From 9f061696c49e584c9b3d5f179d3be262c287be33 Mon Sep 17 00:00:00 2001 From: Ultradragon005 <143632280+Ultradragon005@users.noreply.github.com> Date: Mon, 12 Aug 2024 12:33:33 +0200 Subject: [PATCH 04/43] . --- Roles/Core/AssignManager/RoleAssign.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Roles/Core/AssignManager/RoleAssign.cs b/Roles/Core/AssignManager/RoleAssign.cs index a56eef8d11..a7f8e8afcd 100644 --- a/Roles/Core/AssignManager/RoleAssign.cs +++ b/Roles/Core/AssignManager/RoleAssign.cs @@ -160,12 +160,11 @@ public static void StartSelect() Roles[RoleAssignType.Impostor] = Roles[RoleAssignType.Impostor].Shuffle(rd).Take(optImpNum).ToList(); // Will have to fix this later, for now disabled for testing - Roles[RoleAssignType.NeutralKilling] = Roles[RoleAssignType.NeutralKilling].Shuffle(rd).Take(optNeutralKillingNum).ToList(); + /*Roles[RoleAssignType.NeutralKilling] = Roles[RoleAssignType.NeutralKilling].Shuffle(rd).Take(optNeutralKillingNum).ToList(); Roles[RoleAssignType.NeutralApocalypse] = Roles[RoleAssignType.NeutralApocalypse].Shuffle(rd).Take(optNeutralApocalypseNum).ToList(); Roles[RoleAssignType.NonKillingNeutral] = Roles[RoleAssignType.NonKillingNeutral].Shuffle(rd).Take(optNonNeutralKillingNum).ToList(); Roles[RoleAssignType.Crewmate] = Roles[RoleAssignType.Crewmate].Shuffle(rd).Take(playerCount).ToList(); - /* Roles[RoleAssignType.Impostor].AddRange(TempAlwaysImpRoles); Roles[RoleAssignType.NeutralKilling].AddRange(TempAlwaysNKRoles); Roles[RoleAssignType.NeutralApocalypse].AddRange(TempAlwaysNARoles); From b149e430c01715cdd7715ce8502f1b00a78e80b5 Mon Sep 17 00:00:00 2001 From: Ultradragon005 <143632280+Ultradragon005@users.noreply.github.com> Date: Mon, 12 Aug 2024 12:50:22 +0200 Subject: [PATCH 05/43] nvm I guess I'm just autistic --- Modules/Extensions/CollectionExtensions.cs | 5 +++-- Roles/Core/AssignManager/RoleAssign.cs | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Modules/Extensions/CollectionExtensions.cs b/Modules/Extensions/CollectionExtensions.cs index 86500a015e..e1f8d37804 100644 --- a/Modules/Extensions/CollectionExtensions.cs +++ b/Modules/Extensions/CollectionExtensions.cs @@ -1,4 +1,5 @@ -using System; +using Mono.Cecil; +using System; namespace TOHE; @@ -58,7 +59,7 @@ public static IEnumerable CombineWith(this IEnumerable firstCollection, /// The shuffled collection public static IEnumerable Shuffle(this IEnumerable collection, IRandom random) { - if (!collection.Any()) return default; + if (!collection.Any()) return []; var list = collection.ToList(); int n = list.Count; diff --git a/Roles/Core/AssignManager/RoleAssign.cs b/Roles/Core/AssignManager/RoleAssign.cs index a7f8e8afcd..5b8a0d456c 100644 --- a/Roles/Core/AssignManager/RoleAssign.cs +++ b/Roles/Core/AssignManager/RoleAssign.cs @@ -159,12 +159,12 @@ public static void StartSelect() Roles[RoleAssignType.Impostor] = Roles[RoleAssignType.Impostor].Shuffle(rd).Take(optImpNum).ToList(); - // Will have to fix this later, for now disabled for testing - /*Roles[RoleAssignType.NeutralKilling] = Roles[RoleAssignType.NeutralKilling].Shuffle(rd).Take(optNeutralKillingNum).ToList(); + Roles[RoleAssignType.NeutralKilling] = Roles[RoleAssignType.NeutralKilling].Shuffle(rd).Take(optNeutralKillingNum).ToList(); Roles[RoleAssignType.NeutralApocalypse] = Roles[RoleAssignType.NeutralApocalypse].Shuffle(rd).Take(optNeutralApocalypseNum).ToList(); Roles[RoleAssignType.NonKillingNeutral] = Roles[RoleAssignType.NonKillingNeutral].Shuffle(rd).Take(optNonNeutralKillingNum).ToList(); Roles[RoleAssignType.Crewmate] = Roles[RoleAssignType.Crewmate].Shuffle(rd).Take(playerCount).ToList(); + Roles[RoleAssignType.Impostor].AddRange(TempAlwaysImpRoles); Roles[RoleAssignType.NeutralKilling].AddRange(TempAlwaysNKRoles); Roles[RoleAssignType.NeutralApocalypse].AddRange(TempAlwaysNARoles); @@ -175,7 +175,8 @@ public static void StartSelect() Roles[RoleAssignType.NeutralKilling] = Roles[RoleAssignType.NeutralKilling].DistinctBy(x => x.Role).ToList(); Roles[RoleAssignType.NeutralApocalypse] = Roles[RoleAssignType.NeutralApocalypse].DistinctBy(x => x.Role).ToList(); Roles[RoleAssignType.NonKillingNeutral] = Roles[RoleAssignType.NonKillingNeutral].DistinctBy(x => x.Role).ToList(); - Roles[RoleAssignType.Crewmate] = Roles[RoleAssignType.Crewmate].DistinctBy(x => x.Role).ToList();*/ + Roles[RoleAssignType.Crewmate] = Roles[RoleAssignType.Crewmate].DistinctBy(x => x.Role).ToList(); + Logger.Msg("======================================================", "SelectedRoles"); Logger.Info(string.Join(", ", Roles[RoleAssignType.Impostor].Select(x => x.Role.ToString())), "Selected-Impostor-Roles"); From 131a816a4744c451fc688acc8c9439285b9552fc Mon Sep 17 00:00:00 2001 From: Ultradragon005 <143632280+Ultradragon005@users.noreply.github.com> Date: Mon, 12 Aug 2024 12:53:13 +0200 Subject: [PATCH 06/43] revert --- Roles/Core/AssignManager/RoleAssign.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/Roles/Core/AssignManager/RoleAssign.cs b/Roles/Core/AssignManager/RoleAssign.cs index 5b8a0d456c..72c603eabf 100644 --- a/Roles/Core/AssignManager/RoleAssign.cs +++ b/Roles/Core/AssignManager/RoleAssign.cs @@ -158,13 +158,11 @@ public static void StartSelect() // Take - Takes the first x roles of the list ... x is the maximum number of roles we could need of that team Roles[RoleAssignType.Impostor] = Roles[RoleAssignType.Impostor].Shuffle(rd).Take(optImpNum).ToList(); - Roles[RoleAssignType.NeutralKilling] = Roles[RoleAssignType.NeutralKilling].Shuffle(rd).Take(optNeutralKillingNum).ToList(); Roles[RoleAssignType.NeutralApocalypse] = Roles[RoleAssignType.NeutralApocalypse].Shuffle(rd).Take(optNeutralApocalypseNum).ToList(); Roles[RoleAssignType.NonKillingNeutral] = Roles[RoleAssignType.NonKillingNeutral].Shuffle(rd).Take(optNonNeutralKillingNum).ToList(); Roles[RoleAssignType.Crewmate] = Roles[RoleAssignType.Crewmate].Shuffle(rd).Take(playerCount).ToList(); - Roles[RoleAssignType.Impostor].AddRange(TempAlwaysImpRoles); Roles[RoleAssignType.NeutralKilling].AddRange(TempAlwaysNKRoles); Roles[RoleAssignType.NeutralApocalypse].AddRange(TempAlwaysNARoles); @@ -177,7 +175,6 @@ public static void StartSelect() Roles[RoleAssignType.NonKillingNeutral] = Roles[RoleAssignType.NonKillingNeutral].DistinctBy(x => x.Role).ToList(); Roles[RoleAssignType.Crewmate] = Roles[RoleAssignType.Crewmate].DistinctBy(x => x.Role).ToList(); - Logger.Msg("======================================================", "SelectedRoles"); Logger.Info(string.Join(", ", Roles[RoleAssignType.Impostor].Select(x => x.Role.ToString())), "Selected-Impostor-Roles"); Logger.Info(string.Join(", ", Roles[RoleAssignType.NeutralKilling].Select(x => x.Role.ToString())), "Selected-NK-Roles"); From 19f85eba4a8355f068fd27f7ac2a565ec69d6fc8 Mon Sep 17 00:00:00 2001 From: Ultradragon005 <143632280+Ultradragon005@users.noreply.github.com> Date: Mon, 12 Aug 2024 12:54:10 +0200 Subject: [PATCH 07/43] skibidi toilet --- Modules/Extensions/CollectionExtensions.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/Modules/Extensions/CollectionExtensions.cs b/Modules/Extensions/CollectionExtensions.cs index e1f8d37804..6f60a1a5fc 100644 --- a/Modules/Extensions/CollectionExtensions.cs +++ b/Modules/Extensions/CollectionExtensions.cs @@ -59,8 +59,6 @@ public static IEnumerable CombineWith(this IEnumerable firstCollection, /// The shuffled collection public static IEnumerable Shuffle(this IEnumerable collection, IRandom random) { - if (!collection.Any()) return []; - var list = collection.ToList(); int n = list.Count; while (n > 1) From 696c711748e9af23609333383e2ca6c0f64937ca Mon Sep 17 00:00:00 2001 From: Ultradragon005 <143632280+Ultradragon005@users.noreply.github.com> Date: Mon, 12 Aug 2024 17:09:54 +0200 Subject: [PATCH 08/43] Almsot done, jsut need some fixes left --- Patches/ChatCommandPatch.cs | 5 +- Patches/MeetingHudPatch.cs | 1 + Patches/onGameStartedPatch.cs | 23 +-------- Resources/Lang/en_US.json | 13 ++++- Resources/roleColor.json | 3 +- Roles/(Ghosts)/Crewmate/Telepathy.cs | 17 +++++-- Roles/AddOns/Common/Antidote.cs | 2 +- Roles/AddOns/Common/Aware.cs | 2 +- Roles/AddOns/Common/Bait.cs | 2 +- Roles/AddOns/Common/Bewilder.cs | 2 +- Roles/AddOns/Common/Burst.cs | 2 +- Roles/AddOns/Common/Cyber.cs | 2 +- Roles/AddOns/Common/Diseased.cs | 2 +- Roles/AddOns/Common/DoubleShot.cs | 2 +- Roles/AddOns/Common/Fool.cs | 2 +- Roles/AddOns/Common/Glow.cs | 2 +- Roles/AddOns/Common/Lucky.cs | 2 +- Roles/AddOns/Common/Messenger.cs | 74 ++++++++++++++++++++++++++++ Roles/AddOns/Common/Oiiai.cs | 2 +- Roles/AddOns/Common/Radar.cs | 2 +- Roles/AddOns/Common/Rainbow.cs | 2 +- Roles/AddOns/Common/Sleuth.cs | 2 +- Roles/AddOns/Common/Statue.cs | 2 +- Roles/AddOns/Common/Tired.cs | 2 +- Roles/AddOns/Crewmate/Ghoul.cs | 2 +- Roles/AddOns/Crewmate/Workhorse.cs | 2 +- Roles/AddOns/IAddon.cs | 2 + Roles/AddOns/Impostor/Clumsy.cs | 2 +- main.cs | 1 + 29 files changed, 132 insertions(+), 47 deletions(-) create mode 100644 Roles/AddOns/Common/Messenger.cs diff --git a/Patches/ChatCommandPatch.cs b/Patches/ChatCommandPatch.cs index 3ca9110bde..486fc16ab5 100644 --- a/Patches/ChatCommandPatch.cs +++ b/Patches/ChatCommandPatch.cs @@ -7,6 +7,7 @@ using TOHE.Modules; using TOHE.Modules.ChatManager; using TOHE.Roles._Ghosts_.Crewmate; +using TOHE.Roles.AddOns.Common; using TOHE.Roles.Core; using TOHE.Roles.Core.AssignManager; using TOHE.Roles.Crewmate; @@ -70,6 +71,7 @@ public static bool Prefix(ChatController __instance) if (Medium.MsMsg(PlayerControl.LocalPlayer, text)) goto Canceled; if (PlayerControl.LocalPlayer.GetRoleClass() is Swapper sw && sw.SwapMsg(PlayerControl.LocalPlayer, text)) goto Canceled; if (Telepathy.TelepathyMessage(PlayerControl.LocalPlayer, args)) goto Canceled; + if (Messenger.CheckMessage(PlayerControl.LocalPlayer, args)) goto Canceled; Directory.CreateDirectory(modTagsFiles); Directory.CreateDirectory(vipTagsFiles); @@ -1891,7 +1893,8 @@ public static void OnReceiveChat(PlayerControl player, string text, out bool can if (Medium.MsMsg(player, text)) { Logger.Info($"Is Medium command", "OnReceiveChat"); return; } if (Nemesis.NemesisMsgCheck(player, text)) { Logger.Info($"Is Nemesis Revenge command", "OnReceiveChat"); return; } if (Retributionist.RetributionistMsgCheck(player, text)) { Logger.Info($"Is Retributionist Revenge command", "OnReceiveChat"); return; } - if (Telepathy.TelepathyMessage(PlayerControl.LocalPlayer, args)) { Logger.Info("Is Telepathy MSG command", "OnRecieveChat"); return; } + if (Telepathy.TelepathyMessage(player, args)) { Logger.Info("Is Telepathy MSG command", "OnRecieveChat"); return; } + if (Messenger.CheckMessage(player, args)) { Logger.Info("Is Messenger MSG command", "OnRecieveChat"); return; } Directory.CreateDirectory(modTagsFiles); Directory.CreateDirectory(vipTagsFiles); diff --git a/Patches/MeetingHudPatch.cs b/Patches/MeetingHudPatch.cs index 1529b30e36..0c68e943d5 100644 --- a/Patches/MeetingHudPatch.cs +++ b/Patches/MeetingHudPatch.cs @@ -905,6 +905,7 @@ public static void NotifyRoleSkillOnMeetingStart() { pc?.GetRoleClass()?.OnMeetingHudStart(pc); Main.PlayerStates.Do(plr => plr.Value.RoleClass.OnOthersMeetingHudStart(pc)); + Messenger.NotifyAddonOnMeeting(pc); foreach (var csId in Cyber.CyberDead) { diff --git a/Patches/onGameStartedPatch.cs b/Patches/onGameStartedPatch.cs index f48e769233..3365bb432d 100644 --- a/Patches/onGameStartedPatch.cs +++ b/Patches/onGameStartedPatch.cs @@ -198,31 +198,12 @@ public static void Postfix(AmongUsClient __instance) RoleClass?.OnInit(); } + CustomRoleManager.AddonClasses.Values.Where(x => x != null).Do(x => x.Init()); + LastImpostor.Init(); TargetArrow.Init(); LocateArrow.Init(); DoubleTrigger.Init(); - Workhorse.Init(); - Diseased.Init(); - Clumsy.Init(); - Aware.Init(); - Radar.Init(); - Glow.Init(); - Sleuth.Init(); - Bait.Init(); - Antidote.Init(); - Fool.Init(); - Burst.Init(); - DoubleShot.Init(); - Lucky.Init(); - Bewilder.Init(); - //ChiefOfPolice.Init(); - Cyber.Init(); - Oiiai.Init(); - Tired.Init(); - Statue.Init(); - Ghoul.Init(); - Rainbow.Init(); //FFA FFAManager.Init(); diff --git a/Resources/Lang/en_US.json b/Resources/Lang/en_US.json index 7d6707e027..9e4072d3b7 100644 --- a/Resources/Lang/en_US.json +++ b/Resources/Lang/en_US.json @@ -312,6 +312,7 @@ "Necromancer": "Necromancer", "Warden": "Warden", "Minion": "Minion", + "Messenger": "Messenger", "Ghastly": "Ghastly", "LastImpostor": "Last Impostor", "Overclocked": "Overclocked", @@ -461,6 +462,7 @@ "UnderdogInfo": "Start killing on a low player count", "LudopathInfo": "Your kill cooldown is random", "GodfatherInfo": "Convert players to Refugees by voting", + "MessengerInfo": "Speak from above", "ChronomancerInfo": "Kill in bursts", "PitfallInfo": "Setup traps around the map", "EvilMiniInfo": "No one can hurt you until you grow up", @@ -923,6 +925,7 @@ "TiebreakerInfoLong": "(Add-ons):\nWhen tie vote, priority will be given to the target voted by the Tiebreaker. Note: If multiple Tiebreakers choose different tie targets simultaneously, the skills of the Tiebreaker will not take effect.", "ObliviousInfoLong": "(Add-ons):\nDetective and Cleaners won't be Oblivious. The Oblivious cannot report dead bodies. Note: Bait killed by Oblivious will still report automatically, and Oblivious can still be used as a scapegoat for Anonymous.", "BewilderInfoLong": "(Add-ons):\nBewilder may have a smaller/bigger vision. When the Bewilder has died, the murderer's vision may become the same as the Bewilder's, depending on the settings.", + "MessengerInfoLong": "(Add-ons):\nAs The Messenger, when you die, the next/upcoming meeting you will have 3 messages to choose from and send for everyone to see.", "WorkhorseInfoLong": "(Add-ons):\nThe first player to complete all the tasks will become Workhorse, and Workhorse will give the player extra tasks. The Host sets the number of additional tasks.", "FoolInfoLong": "(Add-ons):\nSleuth and Mechanic won't be Fool. Fools can't repair any sabotage.", "AvangerInfoLong": "(Add-ons):\nHost can set whether the Impostor can become an Avenger. When the Avenger is killed (voted out, and irregular kills will not count), the Avenger will revenge a random player.", @@ -2067,6 +2070,14 @@ "Messenger.LazyFuck": "{0} has done none or the least amount of tasks", "Messenger.KillersFaction": "The killer's faction is {0}", "Messenger.ThisRoleExists": "There is a {0} alive", + "MessengersImpsHear": "Impostors see messenger Msg", + "MessengersNeutsHear": "Neutrals see messenger Msg", + + "MessengerTitle": "MESSENGER", + "MessengerTitleTarget": "A Voice From Above Whispers...", + "MessengerUsage": "Type /mms {0/1/2} to send a message.", + "Messenger.Msg": "What would you like the public to know?\n\n{0}\n\nUse /mms [0/1/2] to answer.", + "Suicide_": "By Suicide", "Remotely": "Remotely", "Indirectly": "Indirectly", @@ -2089,7 +2100,7 @@ "TelepathyNotifyTargetMODE2": "The Telepathy {0} has made a connection with you, meaning you might hear useful info from them.", "TelepathyNotifySelf": "You have made a connection with {0}, answer with /tms [yes/no] to one of their questions.\n Note: They may try to disguise their question, so be on watch", "TelepathyNotifySelfMODE2": "What would you like to whisper to {0}?\n\n{1}\n\nUse /tms [0/1/2] to answer.", - + "TelepathyTargetDisconnect": "Your target has Died/Disconnected", "SpurtMinSpeed": "Min Speed", "SpurtMaxSpeed": "Max Speed", "SpurtModule": "Speed Modulator", diff --git a/Resources/roleColor.json b/Resources/roleColor.json index 1a469895ba..e7f4ce3524 100644 --- a/Resources/roleColor.json +++ b/Resources/roleColor.json @@ -241,5 +241,6 @@ "Ghastly": "#9ad6d4", "Glow": "#E2F147", "Radar": "#1eff1e", - "Telepathy": "#9470b8" + "Telepathy": "#9470b8", + "Messenger": "#bca387" } diff --git a/Roles/(Ghosts)/Crewmate/Telepathy.cs b/Roles/(Ghosts)/Crewmate/Telepathy.cs index 3c8cd2ce64..c4f58a6b84 100644 --- a/Roles/(Ghosts)/Crewmate/Telepathy.cs +++ b/Roles/(Ghosts)/Crewmate/Telepathy.cs @@ -74,11 +74,22 @@ public override void OnOtherTargetsReducedToAtoms(PlayerControl DeadPlayer) if (TargetPlayer.ContainsValue(DeadPlayer.PlayerId)) { TargetPlayer.Remove(TargetPlayer.First(x => x.Value == DeadPlayer.PlayerId).Key); + if (_Player != null) + { + if (GameStates.IsMeeting || Main.MeetingIsStarted) + { + Utils.SendMessage(GetString("TelepathyTargetDisconnect"), _state.PlayerId); + } + else + { + _Player.Notify(GetString("TelepathyTargetDisconnect")); + } + } } } public static bool TelepathyMessage(PlayerControl pc, string[] args) { - if (!GameStates.IsMeeting || pc == null) return false; + if (!AmongUsClient.Instance.AmHost || !GameStates.IsMeeting || pc == null) return false; if (!TargetPlayer.TryGetValue(pc.PlayerId, out var tar) || tar == byte.MaxValue) return false; if (args.Length < 2) return false; if (((Telepathy)pc.GetRoleClass())?.HasMessaged is null or true) return false; @@ -86,7 +97,7 @@ public static bool TelepathyMessage(PlayerControl pc, string[] args) Dictionary DetermineMessage = ((Telepathy)pc.GetRoleClass())?.Determinemessage; - string[] cmds = {"/tms"}; + string[] cmds = {"/tms"}; // Here you can add custom cmds if (!cmds.Any(x => x.Equals(args[0], StringComparison.OrdinalIgnoreCase))) return false; switch (MessageMode.GetInt()) @@ -111,7 +122,7 @@ public static bool TelepathyMessage(PlayerControl pc, string[] args) if (!int.TryParse(args[1], out int id) || !DetermineMessage?.ContainsKey(id) is null or true) { SendMessage(GetString("TelepathyMODE2Usage"), pc.PlayerId, title: ColorString(GetRoleColor(CustomRoles.Telepathy), GetString("TelepathyTitle"))); - break; + return false; } ((Telepathy)pc.GetRoleClass()).HasMessaged = true; diff --git a/Roles/AddOns/Common/Antidote.cs b/Roles/AddOns/Common/Antidote.cs index 731dd38844..1668a43ac6 100644 --- a/Roles/AddOns/Common/Antidote.cs +++ b/Roles/AddOns/Common/Antidote.cs @@ -24,7 +24,7 @@ public void SetupCustomOption() AntidoteCDReset = BooleanOptionItem.Create(Id + 14, "AntidoteCDReset", true, TabGroup.Addons, false).SetParent(CustomRoleSpawnChances[CustomRoles.Antidote]); } - public static void Init() + public void Init() { KilledAntidote = []; IsEnable = false; diff --git a/Roles/AddOns/Common/Aware.cs b/Roles/AddOns/Common/Aware.cs index bd22bfca4b..e52c98801d 100644 --- a/Roles/AddOns/Common/Aware.cs +++ b/Roles/AddOns/Common/Aware.cs @@ -22,7 +22,7 @@ public void SetupCustomOption() AwareknowRole = BooleanOptionItem.Create(Id + 13, "AwareKnowRole", true, TabGroup.Addons, false).SetParent(CustomRoleSpawnChances[CustomRoles.Aware]); } - public static void Init() + public void Init() { AwareInteracted = []; IsEnable = false; diff --git a/Roles/AddOns/Common/Bait.cs b/Roles/AddOns/Common/Bait.cs index a63b425bde..ffecdb4731 100644 --- a/Roles/AddOns/Common/Bait.cs +++ b/Roles/AddOns/Common/Bait.cs @@ -30,7 +30,7 @@ public void SetupCustomOption() BaitCanBeReportedUnderAllConditions = BooleanOptionItem.Create(Id + 17, "BaitCanBeReportedUnderAllConditions", false, TabGroup.Addons, false).SetParent(CustomRoleSpawnChances[CustomRoles.Bait]); } - public static void Init() + public void Init() { BaitAlive = []; } diff --git a/Roles/AddOns/Common/Bewilder.cs b/Roles/AddOns/Common/Bewilder.cs index 255fe00802..f93420ac6d 100644 --- a/Roles/AddOns/Common/Bewilder.cs +++ b/Roles/AddOns/Common/Bewilder.cs @@ -21,7 +21,7 @@ public void SetupCustomOption() KillerGetBewilderVision = BooleanOptionItem.Create(Id + 14, "KillerGetBewilderVision", true, TabGroup.Addons, false).SetParent(CustomRoleSpawnChances[CustomRoles.Bewilder]); } - public static void Init() + public void Init() { IsEnable = false; } diff --git a/Roles/AddOns/Common/Burst.cs b/Roles/AddOns/Common/Burst.cs index 45668a2e61..6c911f3cee 100644 --- a/Roles/AddOns/Common/Burst.cs +++ b/Roles/AddOns/Common/Burst.cs @@ -19,7 +19,7 @@ public void SetupCustomOption() .SetValueFormat(OptionFormat.Seconds); } - public static void Init() + public void Init() { BurstBodies.Clear(); IsEnable = false; diff --git a/Roles/AddOns/Common/Cyber.cs b/Roles/AddOns/Common/Cyber.cs index 7ecb3378c0..28a07f6bf1 100644 --- a/Roles/AddOns/Common/Cyber.cs +++ b/Roles/AddOns/Common/Cyber.cs @@ -23,7 +23,7 @@ public void SetupCustomOption() CyberKnown = BooleanOptionItem.Create(Id + 16, "CyberKnown", true, TabGroup.Addons, false).SetParent(CustomRoleSpawnChances[CustomRoles.Cyber]); } - public static void Init() + public void Init() { CyberDead = []; } diff --git a/Roles/AddOns/Common/Diseased.cs b/Roles/AddOns/Common/Diseased.cs index ac8b77c984..193cd66130 100644 --- a/Roles/AddOns/Common/Diseased.cs +++ b/Roles/AddOns/Common/Diseased.cs @@ -21,7 +21,7 @@ public void SetupCustomOption() DiseasedCDReset = BooleanOptionItem.Create(Id + 14, "DiseasedCDReset", true, TabGroup.Addons, false).SetParent(CustomRoleSpawnChances[CustomRoles.Diseased]); } - public static void Init() + public void Init() { KilledDiseased = []; IsEnable = false; diff --git a/Roles/AddOns/Common/DoubleShot.cs b/Roles/AddOns/Common/DoubleShot.cs index 573c718023..7291bff57b 100644 --- a/Roles/AddOns/Common/DoubleShot.cs +++ b/Roles/AddOns/Common/DoubleShot.cs @@ -22,7 +22,7 @@ public void SetupCustomOption() NeutralCanBeDoubleShot = BooleanOptionItem.Create(19212, "NeutralCanBeDoubleShot", true, TabGroup.Addons, false) .SetParent(CustomRoleSpawnChances[CustomRoles.DoubleShot]); } - public static void Init() + public void Init() { IsActive = []; } diff --git a/Roles/AddOns/Common/Fool.cs b/Roles/AddOns/Common/Fool.cs index 33864f8513..a35097f6b2 100644 --- a/Roles/AddOns/Common/Fool.cs +++ b/Roles/AddOns/Common/Fool.cs @@ -12,7 +12,7 @@ public void SetupCustomOption() SetupAdtRoleOptions(Id, CustomRoles.Fool, canSetNum: true, tab: TabGroup.Addons, teamSpawnOptions: true); } - public static void Init() + public void Init() { IsEnable = false; } diff --git a/Roles/AddOns/Common/Glow.cs b/Roles/AddOns/Common/Glow.cs index 7d5cf59db2..9297d0d728 100644 --- a/Roles/AddOns/Common/Glow.cs +++ b/Roles/AddOns/Common/Glow.cs @@ -31,7 +31,7 @@ public void SetupCustomOption() .SetValueFormat(OptionFormat.Multiplier); } - public static void Init() + public void Init() { InRadius.Clear(); IsEnable = false; diff --git a/Roles/AddOns/Common/Lucky.cs b/Roles/AddOns/Common/Lucky.cs index 90d2102d3d..c1f3f16a20 100644 --- a/Roles/AddOns/Common/Lucky.cs +++ b/Roles/AddOns/Common/Lucky.cs @@ -18,7 +18,7 @@ public void SetupCustomOption() .SetValueFormat(OptionFormat.Percent); } - public static void Init() + public void Init() { LuckyAvoid = []; } diff --git a/Roles/AddOns/Common/Messenger.cs b/Roles/AddOns/Common/Messenger.cs new file mode 100644 index 0000000000..c3ee7e6331 --- /dev/null +++ b/Roles/AddOns/Common/Messenger.cs @@ -0,0 +1,74 @@ +using static TOHE.Options; +using static TOHE.Utils; +using static TOHE.Translator; +using System; +using static TOHE.MeetingHudStartPatch; +using TOHE.Roles._Ghosts_.Crewmate; +using TOHE.Roles.Core; +using System.Diagnostics.Contracts; + +namespace TOHE.Roles.AddOns.Common; + +public class Messenger : IAddon +{ + private const int Id = 29000; + private static OptionItem ImpostorsHearMessage; + private static OptionItem NeutralsHearMessage; + public AddonTypes Type => AddonTypes.Helpful; + public static Dictionary> Determinemessage = []; + public static Dictionary DidSay = []; + public void SetupCustomOption() + { + SetupAdtRoleOptions(Id, CustomRoles.Messenger, canSetNum: true, teamSpawnOptions: true); + ImpostorsHearMessage = BooleanOptionItem.Create(Id + 10, "MessengersImpsHear", true, TabGroup.Addons, false).SetParent(CustomRoleSpawnChances[CustomRoles.Messenger]); + NeutralsHearMessage = BooleanOptionItem.Create(Id + 11, "MessengersNeutsHear", true, TabGroup.Addons, false).SetParent(CustomRoleSpawnChances[CustomRoles.Messenger]); + } + public void Init() + { + DidSay.Clear(); + Determinemessage.Clear(); + } + public static void NotifyAddonOnMeeting(PlayerControl pc) + { + if (!pc.Is(CustomRoles.Messenger) || DidSay.TryGetValue(pc.PlayerId, out _) || pc.IsAlive()) return; + + var msg = DetermineSetMessage(pc, pc.GetRealKiller(), out var det); + Determinemessage[pc.PlayerId] = det; + AddMsg(string.Format(GetString("Messenger.Msg"), msg), pc.PlayerId, ColorString(GetRoleColor(CustomRoles.Messenger), GetString("MessengerTitle"))); + + } + public static bool CheckMessage(PlayerControl pc, string[] args) + { + if (!AmongUsClient.Instance.AmHost || !GameStates.IsMeeting || pc == null || pc.IsAlive()) return false; + if (!Determinemessage.TryGetValue(pc.PlayerId, out var determineMessage)) return false; + if (!pc.Is(CustomRoles.Messenger) || DidSay.TryGetValue(pc.PlayerId, out bool said) && said) return false; + if (args.Length < 2) return false; + + string[] cmds = { "/mms" }; // Here you can add custom cmds + if (!cmds.Any(x => x.Equals(args[0], StringComparison.OrdinalIgnoreCase))) return false; + + + if (!int.TryParse(args[1], out int id) || !determineMessage.ContainsKey(id)) + { + SendMessage(GetString("MessengerUsage"), pc.PlayerId, title: ColorString(GetRoleColor(CustomRoles.Messenger), GetString("MessengerTitle"))); + return false; + } + DidSay[pc.PlayerId] = true; + + List ExceptList = []; + if (!ImpostorsHearMessage.GetBool()) + ExceptList.AddRange(Main.AllAlivePlayerControls.Where(x => x.GetCustomRole().IsImpostorTeamV2()).Select(x => x.PlayerId)); + if (!NeutralsHearMessage.GetBool()) + ExceptList.AddRange(Main.AllAlivePlayerControls.Where(x => x.GetCustomRole().IsNeutralTeamV2()).Select(x => x.PlayerId)); + + foreach (var par in Main.AllAlivePlayerControls.ExceptBy(ExceptList, x => x.PlayerId)) + { + SendMessage(determineMessage[id], par.PlayerId, title: ColorString(GetRoleColor(CustomRoles.Messenger), GetString("MessengerTitleTarget"))); + } + SendMessage(GetString("TelepathyConfirmSelf"), pc.PlayerId, ColorString(GetRoleColor(CustomRoles.Messenger), GetString("MessengerTitle"))); + + + return true; + + } +} \ No newline at end of file diff --git a/Roles/AddOns/Common/Oiiai.cs b/Roles/AddOns/Common/Oiiai.cs index 4fc07e94f6..3463be3d81 100644 --- a/Roles/AddOns/Common/Oiiai.cs +++ b/Roles/AddOns/Common/Oiiai.cs @@ -36,7 +36,7 @@ public void SetupCustomOption() CanPassOn = BooleanOptionItem.Create(Id + 14, "OiiaiCanPassOn", true, TabGroup.Addons, false).SetParent(Options.CustomRoleSpawnChances[CustomRoles.Oiiai]); ChangeNeutralRole = StringOptionItem.Create(Id + 15, "NeutralChangeRolesForOiiai", EnumHelper.GetAllNames(), 1, TabGroup.Addons, false).SetParent(Options.CustomRoleSpawnChances[CustomRoles.Oiiai]); } - public static void Init() + public void Init() { playerIdList.Clear(); Eraser.ErasedRoleStorage.Clear(); diff --git a/Roles/AddOns/Common/Radar.cs b/Roles/AddOns/Common/Radar.cs index 1b55836f80..5175c7f4a4 100644 --- a/Roles/AddOns/Common/Radar.cs +++ b/Roles/AddOns/Common/Radar.cs @@ -18,7 +18,7 @@ public void SetupCustomOption() SetupAdtRoleOptions(Id, CustomRoles.Radar, canSetNum: true, tab: TabGroup.Addons, teamSpawnOptions: true); } - public static void Init() + public void Init() { ClosestPlayer.Clear(); IsEnable = false; diff --git a/Roles/AddOns/Common/Rainbow.cs b/Roles/AddOns/Common/Rainbow.cs index 1c000efb86..cfc6b440c2 100644 --- a/Roles/AddOns/Common/Rainbow.cs +++ b/Roles/AddOns/Common/Rainbow.cs @@ -21,7 +21,7 @@ public void SetupCustomOption() ChangeInCamouflage = BooleanOptionItem.Create(Id + 14, "RainbowInCamouflage", true, TabGroup.Addons, false) .SetParent(CustomRoleSpawnChances[CustomRoles.Rainbow]); } - public static void Init() + public void Init() { LastColorChange = Utils.GetTimeStamp(); isEnabled = false; diff --git a/Roles/AddOns/Common/Sleuth.cs b/Roles/AddOns/Common/Sleuth.cs index 3a1caebd4b..afa4b39625 100644 --- a/Roles/AddOns/Common/Sleuth.cs +++ b/Roles/AddOns/Common/Sleuth.cs @@ -15,7 +15,7 @@ public void SetupCustomOption() SleuthCanKnowKillerRole = BooleanOptionItem.Create(Id + 13, "SleuthCanKnowKillerRole", true, TabGroup.Addons, false).SetParent(Options.CustomRoleSpawnChances[CustomRoles.Sleuth]); } - public static void Init() + public void Init() { SleuthNotify = []; } diff --git a/Roles/AddOns/Common/Statue.cs b/Roles/AddOns/Common/Statue.cs index 3509b26ced..6d85462803 100644 --- a/Roles/AddOns/Common/Statue.cs +++ b/Roles/AddOns/Common/Statue.cs @@ -24,7 +24,7 @@ public void SetupCustomOption() .SetValueFormat(OptionFormat.Times); } - public static void Init() + public void Init() { CountNearplr = []; tempSpeed = []; diff --git a/Roles/AddOns/Common/Tired.cs b/Roles/AddOns/Common/Tired.cs index c2064e6391..2838146050 100644 --- a/Roles/AddOns/Common/Tired.cs +++ b/Roles/AddOns/Common/Tired.cs @@ -26,7 +26,7 @@ public void SetupCustomOption() .SetValueFormat(OptionFormat.Seconds); } - public static void Init() + public void Init() { playerIdList = []; } diff --git a/Roles/AddOns/Crewmate/Ghoul.cs b/Roles/AddOns/Crewmate/Ghoul.cs index d86be8dadf..05de16aa0d 100644 --- a/Roles/AddOns/Crewmate/Ghoul.cs +++ b/Roles/AddOns/Crewmate/Ghoul.cs @@ -14,7 +14,7 @@ public void SetupCustomOption() SetupAdtRoleOptions(Id, CustomRoles.Ghoul, canSetNum: true, tab: TabGroup.Addons); } - public static void Init() + public void Init() { KillGhoul = []; IsEnable = false; diff --git a/Roles/AddOns/Crewmate/Workhorse.cs b/Roles/AddOns/Crewmate/Workhorse.cs index 635444d06b..3306760036 100644 --- a/Roles/AddOns/Crewmate/Workhorse.cs +++ b/Roles/AddOns/Crewmate/Workhorse.cs @@ -32,7 +32,7 @@ public void SetupCustomOption() .SetValueFormat(OptionFormat.Pieces); OptionSnitchCanBeWorkhorse = BooleanOptionItem.Create(Id + 14, "SnitchCanBeWorkhorse", false, TabGroup.Addons, false).SetParent(CustomRoleSpawnChances[CustomRoles.Workhorse]); } - public static void Init() + public void Init() { playerIdList.Clear(); IsEnable = false; diff --git a/Roles/AddOns/IAddon.cs b/Roles/AddOns/IAddon.cs index ff53ecf272..699f1f350c 100644 --- a/Roles/AddOns/IAddon.cs +++ b/Roles/AddOns/IAddon.cs @@ -23,6 +23,8 @@ public interface IAddon public AddonTypes Type { get; } public void SetupCustomOption(); + public void Init() + { } public void OnFixedUpdate(PlayerControl pc) { } public void OnFixedUpdateLowLoad(PlayerControl pc) diff --git a/Roles/AddOns/Impostor/Clumsy.cs b/Roles/AddOns/Impostor/Clumsy.cs index 1cb50bb9cd..fa2b479dea 100644 --- a/Roles/AddOns/Impostor/Clumsy.cs +++ b/Roles/AddOns/Impostor/Clumsy.cs @@ -19,7 +19,7 @@ public void SetupCustomOption() .SetValueFormat(OptionFormat.Percent); } - public static void Init() + public void Init() { HasMissed = []; } diff --git a/main.cs b/main.cs index 1a277ace99..0f324bf7cf 100644 --- a/main.cs +++ b/main.cs @@ -880,6 +880,7 @@ public enum CustomRoles Reach, Rebound, Spurt, + Messenger, Recruit, Seer, Silent, From 40544466915bfdf7e78c42a17d7d5bef3acd6158 Mon Sep 17 00:00:00 2001 From: Ultradragon005 <143632280+Ultradragon005@users.noreply.github.com> Date: Mon, 12 Aug 2024 17:18:04 +0200 Subject: [PATCH 09/43] finishing touches --- Resources/Lang/en_US.json | 4 ++-- Roles/AddOns/Common/Messenger.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Resources/Lang/en_US.json b/Resources/Lang/en_US.json index 9e4072d3b7..77440deb07 100644 --- a/Resources/Lang/en_US.json +++ b/Resources/Lang/en_US.json @@ -2070,8 +2070,8 @@ "Messenger.LazyFuck": "{0} has done none or the least amount of tasks", "Messenger.KillersFaction": "The killer's faction is {0}", "Messenger.ThisRoleExists": "There is a {0} alive", - "MessengersImpsHear": "Impostors see messenger Msg", - "MessengersNeutsHear": "Neutrals see messenger Msg", + "MessengersImpsHear": "Impostors See Messenger Msg", + "MessengersNeutsHear": "Neutrals See Messenger Msg", "MessengerTitle": "MESSENGER", "MessengerTitleTarget": "A Voice From Above Whispers...", diff --git a/Roles/AddOns/Common/Messenger.cs b/Roles/AddOns/Common/Messenger.cs index c3ee7e6331..57bbad023f 100644 --- a/Roles/AddOns/Common/Messenger.cs +++ b/Roles/AddOns/Common/Messenger.cs @@ -57,9 +57,9 @@ public static bool CheckMessage(PlayerControl pc, string[] args) List ExceptList = []; if (!ImpostorsHearMessage.GetBool()) - ExceptList.AddRange(Main.AllAlivePlayerControls.Where(x => x.GetCustomRole().IsImpostorTeamV2()).Select(x => x.PlayerId)); + ExceptList.AddRange(Main.AllPlayerControls.Where(x => x.GetCustomRole().IsImpostorTeamV2()).Select(x => x.PlayerId)); if (!NeutralsHearMessage.GetBool()) - ExceptList.AddRange(Main.AllAlivePlayerControls.Where(x => x.GetCustomRole().IsNeutralTeamV2()).Select(x => x.PlayerId)); + ExceptList.AddRange(Main.AllPlayerControls.Where(x => x.GetCustomRole().IsNeutralTeamV2()).Select(x => x.PlayerId)); foreach (var par in Main.AllAlivePlayerControls.ExceptBy(ExceptList, x => x.PlayerId)) { From c536c2892ef46ea047d2c740d9b04ab506178ddc Mon Sep 17 00:00:00 2001 From: Ultradragon005 <143632280+Ultradragon005@users.noreply.github.com> Date: Mon, 12 Aug 2024 17:38:35 +0200 Subject: [PATCH 10/43] Updates --- Resources/Lang/en_US.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Resources/Lang/en_US.json b/Resources/Lang/en_US.json index 77440deb07..256ab4e618 100644 --- a/Resources/Lang/en_US.json +++ b/Resources/Lang/en_US.json @@ -844,7 +844,7 @@ "HuntsmanInfoLong": "(Neutrals):\nAs the Huntsman, you are given a certain number of targets that reset every meeting. If you successfully eliminate one of your targets, your kill cooldown goes down permanently by the set amount. However, if you kill someone who is not one of your targets, your kill cooldown permanently increases by the set amount. A colored name indicates your targets.", "MiniInfoLong": "(Crewmate or Impostor):\nThe Mini has two roles. A Nice or Evil Mini is chosen.\n\nUse'/r nice mini' and '/r evil mini' respectively for more details.", "JesterInfoLong": "(Neutrals):\nIf the Jester gets voted out, the Jester wins the game alone. If the Jester is still alive at the end of the game, the Jester loses the game. Note: Jester, Executioner, and Innocent can win together.", - "TelepathyInfoLong": "(Crewmates [Ghost]):\nAs the Telepathy, You can use your protect button to connect with someone, connecting with someone again simply switches your target. \n\n In the upcoming meeting you will be able to answer a /tms {yes/no} question they have, or give them a set of possible messages depending on the settings (/tms {0/1/2}).", + "TelepathyInfoLong": "(Crewmates [Ghost]):\nAs the Telepathy, You can use your protect button to connect with someone, connecting with someone again simply switches your target. \n\nIn the upcoming meeting you will be able to answer a /tms {yes/no} question they have, or give them a set of possible messages depending on the settings (/tms {0/1/2}).", "TerroristInfoLong": "(Neutrals):\nIf the Terrorist dies after completing all tasks, the Terrorist wins the game alone. (They can win by either being voted out or killed).", "ExecutionerInfoLong": "(Neutrals):\nThe Executioner is a role with an execution target, indicated by a diamond symbol「♦」next to their name. If the execution target is killed, the Executioner's role will change to either Crewmate, Jester, or Opportunist, depending on the game settings. However, if the execution target is voted out in the meeting, the Executioner wins. Note: Jester, Executioner, and Innocent can win together.", "LawyerInfoLong": "(Neutrals):\nLawyer has a target to defend, which will be indicated by a diamond 「♦」 next to their name.\nIf your target wins, you win.\nIf they lose, you lose.", @@ -925,7 +925,7 @@ "TiebreakerInfoLong": "(Add-ons):\nWhen tie vote, priority will be given to the target voted by the Tiebreaker. Note: If multiple Tiebreakers choose different tie targets simultaneously, the skills of the Tiebreaker will not take effect.", "ObliviousInfoLong": "(Add-ons):\nDetective and Cleaners won't be Oblivious. The Oblivious cannot report dead bodies. Note: Bait killed by Oblivious will still report automatically, and Oblivious can still be used as a scapegoat for Anonymous.", "BewilderInfoLong": "(Add-ons):\nBewilder may have a smaller/bigger vision. When the Bewilder has died, the murderer's vision may become the same as the Bewilder's, depending on the settings.", - "MessengerInfoLong": "(Add-ons):\nAs The Messenger, when you die, the next/upcoming meeting you will have 3 messages to choose from and send for everyone to see.", + "MessengerInfoLong": "(Add-ons):\nAs The Messenger, when you die, the next/upcoming meeting you will have 3 messages to choose from and send for everyone to see.\n\nBy using the /mms [0/1/2] command.", "WorkhorseInfoLong": "(Add-ons):\nThe first player to complete all the tasks will become Workhorse, and Workhorse will give the player extra tasks. The Host sets the number of additional tasks.", "FoolInfoLong": "(Add-ons):\nSleuth and Mechanic won't be Fool. Fools can't repair any sabotage.", "AvangerInfoLong": "(Add-ons):\nHost can set whether the Impostor can become an Avenger. When the Avenger is killed (voted out, and irregular kills will not count), the Avenger will revenge a random player.", From 467e3c5e3ffe506e3d1ca4da1b82412f557e0301 Mon Sep 17 00:00:00 2001 From: Ultradragon005 <143632280+Ultradragon005@users.noreply.github.com> Date: Mon, 12 Aug 2024 18:58:00 +0200 Subject: [PATCH 11/43] done --- Modules/ExtendedPlayerControl.cs | 2 -- Modules/Extensions/CollectionExtensions.cs | 3 +-- Modules/Utils.cs | 9 +++++---- Patches/PlayerControlPatch.cs | 2 ++ Resources/Lang/en_US.json | 1 + Roles/AddOns/Common/Messenger.cs | 8 ++++++++ 6 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Modules/ExtendedPlayerControl.cs b/Modules/ExtendedPlayerControl.cs index 12e97a5ef2..9431f438b7 100644 --- a/Modules/ExtendedPlayerControl.cs +++ b/Modules/ExtendedPlayerControl.cs @@ -898,8 +898,6 @@ public static bool KnowLivingTeam(this PlayerControl seer, PlayerControl target) && !target.Data.IsDead; private readonly static LogHandler logger = Logger.Handler("KnowRoleTarget"); - - public static bool KnowRoleTarget(PlayerControl seer, PlayerControl target, bool isVanilla = false) { if (Options.CurrentGameMode == CustomGameMode.FFA || GameEndCheckerForNormal.ShowAllRolesWhenGameEnd) diff --git a/Modules/Extensions/CollectionExtensions.cs b/Modules/Extensions/CollectionExtensions.cs index 6f60a1a5fc..4d73e45bb9 100644 --- a/Modules/Extensions/CollectionExtensions.cs +++ b/Modules/Extensions/CollectionExtensions.cs @@ -1,5 +1,4 @@ -using Mono.Cecil; -using System; +using System; namespace TOHE; diff --git a/Modules/Utils.cs b/Modules/Utils.cs index 50aa5832e9..a12774d8a4 100644 --- a/Modules/Utils.cs +++ b/Modules/Utils.cs @@ -1695,7 +1695,7 @@ static t CreateAndInvoke(Func func) return func.Invoke(); } - List TakeMsg = Translatables.ToList(); + List TakeMsg = [..Translatables]; var Msg = ""; DeterminedMessage = []; for (int i = 0; i < 3; i++) @@ -1708,8 +1708,8 @@ static t CreateAndInvoke(Func func) CurrentMessage = ran switch { "Messenger.KillerLastKillIn" when killer != null && killer.IsAlive() && Main.LastKillerRoom.TryGetValue(Player.PlayerId, out var pokoj) => string.Format(GetString("Messenger.KillerLastKillIn"), pokoj.RoomId), - "Messenger.KillerExistIn" when Main.AllAlivePlayerControls.Where(x => x.GetCustomRole().IsImpostor() || x.IsNeutralKiller() || x.IsNeutralApocalypse()).Shuffle(IRandom.Instance).FirstOrDefault() is not null and PlayerControl killar => CreateAndInvoke(() => - { + "Messenger.KillerExistIn" when Main.AllAlivePlayerControls.Where(x => x.GetCustomRole().IsImpostor() || x.IsNeutralKiller() || x.IsNeutralApocalypse() || x.IsTransformedNeutralApocalypse()).Shuffle(IRandom.Instance).FirstOrDefault() is not null and PlayerControl killar => CreateAndInvoke(() => + { // yes using Apoc/TApoc may not be 100% accurate but they may or may not keep the game keep going and I'm too lazy to make a specific check SystemTypes room = killar.GetPlainShipRoom().RoomId; return string.Format(GetString("Messenger.KillerExistIn"), room); }), @@ -1725,7 +1725,7 @@ static t CreateAndInvoke(Func func) }), "Messenger.PlayerOnSameTeam" when Main.AllAlivePlayerControls.Shuffle(IRandom.Instance).FirstOrDefault(x => Player.IsSameTeammate(x, out _)) is not null and PlayerControl friend => string.Format(GetString("Messenger.PlayerOnSameTeam"), friend.GetRealName(clientData: true)), "Messenger.LazyFuck" => CreateAndInvoke(() => - { + { var mintask = Main.AllAlivePlayerControls.Where(x => !x.HasImpKillButton()).Min(x => x.GetPlayerTaskState().CompletedTasksCount); var lazyfuck = Main.AllAlivePlayerControls.First(x => x.GetPlayerTaskState().CompletedTasksCount == mintask); @@ -2182,6 +2182,7 @@ static int GetInfoSize(string RoleInfo) TargetSuffix.Append(seerRoleClass?.GetSuffix(seer, target, isForMeeting: isForMeeting)); TargetSuffix.Append(CustomRoleManager.GetSuffixOthers(seer, target, isForMeeting: isForMeeting)); + TargetSuffix.Append(Messenger.GetSuffix(target, isForMeeting)); if (TargetSuffix.Length > 0) { diff --git a/Patches/PlayerControlPatch.cs b/Patches/PlayerControlPatch.cs index 1278c1cfc9..430520edb5 100644 --- a/Patches/PlayerControlPatch.cs +++ b/Patches/PlayerControlPatch.cs @@ -119,6 +119,8 @@ public static bool Prefix(PlayerControl __instance, [HarmonyArgument(0)] PlayerC Logger.Info($"End: CustomRoleManager.OnCheckMurder", "CheckMurder"); + Main.PlayerKilledBy[target.PlayerId] = KilledType.Directly; + //== Kill target == __instance.RpcMurderPlayer(target); //============ diff --git a/Resources/Lang/en_US.json b/Resources/Lang/en_US.json index 256ab4e618..df148161bc 100644 --- a/Resources/Lang/en_US.json +++ b/Resources/Lang/en_US.json @@ -2072,6 +2072,7 @@ "Messenger.ThisRoleExists": "There is a {0} alive", "MessengersImpsHear": "Impostors See Messenger Msg", "MessengersNeutsHear": "Neutrals See Messenger Msg", + "EveryoneKnowsMessenger": "Everyone Knows Messenger", "MessengerTitle": "MESSENGER", "MessengerTitleTarget": "A Voice From Above Whispers...", diff --git a/Roles/AddOns/Common/Messenger.cs b/Roles/AddOns/Common/Messenger.cs index 57bbad023f..2aa26fb08c 100644 --- a/Roles/AddOns/Common/Messenger.cs +++ b/Roles/AddOns/Common/Messenger.cs @@ -14,6 +14,7 @@ public class Messenger : IAddon private const int Id = 29000; private static OptionItem ImpostorsHearMessage; private static OptionItem NeutralsHearMessage; + private static OptionItem KnowMessenger; public AddonTypes Type => AddonTypes.Helpful; public static Dictionary> Determinemessage = []; public static Dictionary DidSay = []; @@ -22,12 +23,19 @@ public void SetupCustomOption() SetupAdtRoleOptions(Id, CustomRoles.Messenger, canSetNum: true, teamSpawnOptions: true); ImpostorsHearMessage = BooleanOptionItem.Create(Id + 10, "MessengersImpsHear", true, TabGroup.Addons, false).SetParent(CustomRoleSpawnChances[CustomRoles.Messenger]); NeutralsHearMessage = BooleanOptionItem.Create(Id + 11, "MessengersNeutsHear", true, TabGroup.Addons, false).SetParent(CustomRoleSpawnChances[CustomRoles.Messenger]); + KnowMessenger = BooleanOptionItem.Create(Id + 12, "EveryoneKnowsMessenger", false, TabGroup.Addons, false).SetParent(CustomRoleSpawnChances[CustomRoles.Messenger]); } public void Init() { DidSay.Clear(); Determinemessage.Clear(); } + public static string GetSuffix(PlayerControl seen, bool ismeeting) + { + if (!seen.Is(CustomRoles.Messenger) || !ismeeting || !KnowMessenger.GetBool() || seen.IsAlive() || DidSay.TryGetValue(seen.PlayerId, out var say) && say) return string.Empty; + + return ColorString(GetRoleColor(CustomRoles.Messenger), "⌘"); + } public static void NotifyAddonOnMeeting(PlayerControl pc) { if (!pc.Is(CustomRoles.Messenger) || DidSay.TryGetValue(pc.PlayerId, out _) || pc.IsAlive()) return; From c7ab50d14e7791f27c0fe8feb7132445ebacd015 Mon Sep 17 00:00:00 2001 From: Ultradragon005 <143632280+Ultradragon005@users.noreply.github.com> Date: Mon, 12 Aug 2024 19:05:05 +0200 Subject: [PATCH 12/43] update --- Modules/Utils.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Utils.cs b/Modules/Utils.cs index a12774d8a4..1a8a2cf0d8 100644 --- a/Modules/Utils.cs +++ b/Modules/Utils.cs @@ -1711,7 +1711,7 @@ static t CreateAndInvoke(Func func) "Messenger.KillerExistIn" when Main.AllAlivePlayerControls.Where(x => x.GetCustomRole().IsImpostor() || x.IsNeutralKiller() || x.IsNeutralApocalypse() || x.IsTransformedNeutralApocalypse()).Shuffle(IRandom.Instance).FirstOrDefault() is not null and PlayerControl killar => CreateAndInvoke(() => { // yes using Apoc/TApoc may not be 100% accurate but they may or may not keep the game keep going and I'm too lazy to make a specific check SystemTypes room = killar.GetPlainShipRoom().RoomId; - return string.Format(GetString("Messenger.KillerExistIn"), room); + return string.Format(GetString("Messenger.KillerExistIn"), GetString($"{room}")); }), "Messenger.KillersRoleIs" when Main.RememberKillerRole != "" => string.Format(GetString("Messenger.KillersRoleIs"), Main.RememberKillerRole), "Messenger.KilledType" when Main.PlayerKilledBy.TryGetValue(Player.PlayerId, out var KilledType) => string.Format(GetString("Messenger.KilledType"), GetString($"{KilledType}")), From 486278c8e4eeb00239cc4668b8c811d29884e259 Mon Sep 17 00:00:00 2001 From: Ultradragon005 <143632280+Ultradragon005@users.noreply.github.com> Date: Mon, 12 Aug 2024 19:06:22 +0200 Subject: [PATCH 13/43] bruh --- Modules/Utils.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Modules/Utils.cs b/Modules/Utils.cs index 1a8a2cf0d8..013ccb8ec8 100644 --- a/Modules/Utils.cs +++ b/Modules/Utils.cs @@ -23,6 +23,7 @@ using TOHE.Roles.Core; using static TOHE.Translator; using TOHE.Patches; +using MS.Internal.Xml.XPath; namespace TOHE; @@ -1707,7 +1708,7 @@ static t CreateAndInvoke(Func func) { CurrentMessage = ran switch { - "Messenger.KillerLastKillIn" when killer != null && killer.IsAlive() && Main.LastKillerRoom.TryGetValue(Player.PlayerId, out var pokoj) => string.Format(GetString("Messenger.KillerLastKillIn"), pokoj.RoomId), + "Messenger.KillerLastKillIn" when killer != null && killer.IsAlive() && Main.LastKillerRoom.TryGetValue(Player.PlayerId, out var pokoj) => string.Format(GetString("Messenger.KillerLastKillIn"), GetString($"{pokoj.RoomId}")), "Messenger.KillerExistIn" when Main.AllAlivePlayerControls.Where(x => x.GetCustomRole().IsImpostor() || x.IsNeutralKiller() || x.IsNeutralApocalypse() || x.IsTransformedNeutralApocalypse()).Shuffle(IRandom.Instance).FirstOrDefault() is not null and PlayerControl killar => CreateAndInvoke(() => { // yes using Apoc/TApoc may not be 100% accurate but they may or may not keep the game keep going and I'm too lazy to make a specific check SystemTypes room = killar.GetPlainShipRoom().RoomId; From 7781c254f42c1fb50e8a1e2239e7d2428c484e2f Mon Sep 17 00:00:00 2001 From: Ultradragon005 <143632280+Ultradragon005@users.noreply.github.com> Date: Mon, 12 Aug 2024 19:08:29 +0200 Subject: [PATCH 14/43] bruh 2.0 --- Modules/Utils.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Utils.cs b/Modules/Utils.cs index 013ccb8ec8..03997a61f4 100644 --- a/Modules/Utils.cs +++ b/Modules/Utils.cs @@ -1737,7 +1737,7 @@ static t CreateAndInvoke(Func func) return string.Format(GetString("Messenger.LazyFuck"), ScapeGoat.GetRealName(clientData: true)); }), - "Messenger.KillersFaction" when Main.RememberedFaction != null => string.Format(GetString("Messenger.KillersFaction"), Main.RememberedFaction.Value), + "Messenger.KillersFaction" when Main.RememberedFaction != null => string.Format(GetString("Messenger.KillersFaction"), GetString($"Team{Main.RememberedFaction.Value}")), _ => CreateAndInvoke(() => { From b70c2626c0e2012be79ede80d1c782756836d5ef Mon Sep 17 00:00:00 2001 From: Ultradragon005 <143632280+Ultradragon005@users.noreply.github.com> Date: Mon, 12 Aug 2024 19:14:54 +0200 Subject: [PATCH 15/43] larger delay --- Patches/PlayerControlPatch.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Patches/PlayerControlPatch.cs b/Patches/PlayerControlPatch.cs index 430520edb5..befafc70a0 100644 --- a/Patches/PlayerControlPatch.cs +++ b/Patches/PlayerControlPatch.cs @@ -407,7 +407,7 @@ public static bool Prefix(PlayerControl __instance, [HarmonyArgument(0)] PlayerC Main.PlayerKilledBy[target.PlayerId] = KilledType.Directly; } - }, 0.1f, "Set Main.Playerkilled by in MurderPlayer Patch"); + }, 1f, "Set Main.Playerkilled by in MurderPlayer Patch"); if (!target.IsProtected() && !Doppelganger.CheckDoppelVictim(target.PlayerId) && !Camouflage.ResetSkinAfterDeathPlayers.Contains(target.PlayerId)) From bc67cb73b81fdcce91b11176a1be7e100a257342 Mon Sep 17 00:00:00 2001 From: Ultradragon005 <143632280+Ultradragon005@users.noreply.github.com> Date: Mon, 12 Aug 2024 19:16:19 +0200 Subject: [PATCH 16/43] move --- Patches/PlayerControlPatch.cs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Patches/PlayerControlPatch.cs b/Patches/PlayerControlPatch.cs index befafc70a0..d7544c5b73 100644 --- a/Patches/PlayerControlPatch.cs +++ b/Patches/PlayerControlPatch.cs @@ -394,22 +394,7 @@ public static bool Prefix(PlayerControl __instance, [HarmonyArgument(0)] PlayerC target.RpcShapeshift(target, false); } } - _ = new LateTask(() => { - - if (!Main.PlayerKilledBy.ContainsKey(target.PlayerId)) - { - - if (Vector2.Distance(target.GetRealKiller().GetCustomPosition(), target.transform.position) > 2f) - Main.PlayerKilledBy[target.PlayerId] = KilledType.Remotely; - else if (target.GetRealKiller() == target) - Main.PlayerKilledBy[target.PlayerId] = KilledType.Suicide_; - else - Main.PlayerKilledBy[target.PlayerId] = KilledType.Directly; - } - - }, 1f, "Set Main.Playerkilled by in MurderPlayer Patch"); - - + if (!target.IsProtected() && !Doppelganger.CheckDoppelVictim(target.PlayerId) && !Camouflage.ResetSkinAfterDeathPlayers.Contains(target.PlayerId)) { Camouflage.ResetSkinAfterDeathPlayers.Add(target.PlayerId); @@ -504,6 +489,21 @@ public static void Postfix(PlayerControl __instance, [HarmonyArgument(0)] Player Utils.NotifyRoles(SpecifySeer: killer); Utils.NotifyRoles(SpecifySeer: target); + + _ = new LateTask(() => { + + if (!Main.PlayerKilledBy.ContainsKey(target.PlayerId)) + { + + if (Vector2.Distance(target.GetRealKiller().GetCustomPosition(), target.transform.position) > 2f) + Main.PlayerKilledBy[target.PlayerId] = KilledType.Remotely; + else if (target.GetRealKiller() == target) + Main.PlayerKilledBy[target.PlayerId] = KilledType.Suicide_; + else + Main.PlayerKilledBy[target.PlayerId] = KilledType.Directly; + } + + }, 1f, "Set Main.Playerkilled by in MurderPlayer Patch"); } public static void AfterPlayerDeathTasks(PlayerControl killer, PlayerControl target, bool inMeeting) { From 23002ffa237407da2832bef330e22d5dab6a23ca Mon Sep 17 00:00:00 2001 From: Ultradragon005 <143632280+Ultradragon005@users.noreply.github.com> Date: Mon, 12 Aug 2024 19:24:36 +0200 Subject: [PATCH 17/43] change id --- Roles/AddOns/Common/Messenger.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Roles/AddOns/Common/Messenger.cs b/Roles/AddOns/Common/Messenger.cs index 2aa26fb08c..cf9d22840b 100644 --- a/Roles/AddOns/Common/Messenger.cs +++ b/Roles/AddOns/Common/Messenger.cs @@ -11,7 +11,7 @@ namespace TOHE.Roles.AddOns.Common; public class Messenger : IAddon { - private const int Id = 29000; + private const int Id = 29100; private static OptionItem ImpostorsHearMessage; private static OptionItem NeutralsHearMessage; private static OptionItem KnowMessenger; From 87801c2a967ae4cc25713e7cc9fb4203a38a97a3 Mon Sep 17 00:00:00 2001 From: Ultradragon005 <143632280+Ultradragon005@users.noreply.github.com> Date: Mon, 12 Aug 2024 19:28:27 +0200 Subject: [PATCH 18/43] move --- Patches/PlayerControlPatch.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Patches/PlayerControlPatch.cs b/Patches/PlayerControlPatch.cs index d7544c5b73..1b3adb0e9d 100644 --- a/Patches/PlayerControlPatch.cs +++ b/Patches/PlayerControlPatch.cs @@ -951,7 +951,6 @@ public static void AfterReportTasks(PlayerControl player, NetworkedPlayerInfo ta Logger.Info($"target is null? - {target == null}", "AfterReportTasks"); Logger.Info($"target.Object is null? - {target?.Object == null}", "AfterReportTasks"); Logger.Info($"target.PlayerId is - {target?.PlayerId}", "AfterReportTasks"); - Main.RememberKillerRole = ""; foreach (var playerStates in Main.PlayerStates.Values.ToArray()) { @@ -961,7 +960,6 @@ public static void AfterReportTasks(PlayerControl player, NetworkedPlayerInfo ta if (!Utils.GetPlayerById(playerStates.PlayerId).IsAlive() && target?.Object?.GetRealKiller() != null) { - Main.RememberKillerRole = GetString($"{target.Object.GetRealKiller().GetCustomRole()}"); Main.LastKillerRoom[target.PlayerId] = target.Object.GetRealKiller().GetPlainShipRoom(); } } @@ -974,8 +972,10 @@ public static void AfterReportTasks(PlayerControl player, NetworkedPlayerInfo ta } Main.RememberedFaction = null; + Main.RememberKillerRole = ""; if (target?.Object?.GetRealKiller() != null) { + Main.RememberKillerRole = GetString($"{target.Object.GetRealKiller().GetCustomRole()}"); if (target.Object.GetRealKiller().IsAnySubRole(x => x.IsConverted() && !target.Object.Is(CustomRoles.Madmate))) Main.RememberedFaction = target.Object.GetRealKiller().GetCustomRole().GetCustomRoleTeam(); else From a5d2fdc8130c00ad572388a757be4328542fca93 Mon Sep 17 00:00:00 2001 From: Ultradragon005 <143632280+Ultradragon005@users.noreply.github.com> Date: Mon, 12 Aug 2024 19:36:53 +0200 Subject: [PATCH 19/43] how the hell did I forget that --- Roles/(Ghosts)/Crewmate/Telepathy.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Roles/(Ghosts)/Crewmate/Telepathy.cs b/Roles/(Ghosts)/Crewmate/Telepathy.cs index c4f58a6b84..93b397c9d6 100644 --- a/Roles/(Ghosts)/Crewmate/Telepathy.cs +++ b/Roles/(Ghosts)/Crewmate/Telepathy.cs @@ -1,6 +1,7 @@ using AmongUs.GameOptions; using TOHE.Roles.Core; using System; +using UnityEngine; using static TOHE.Options; using static TOHE.Translator; using static TOHE.MeetingHudStartPatch; @@ -66,6 +67,7 @@ public override bool OnCheckProtect(PlayerControl angel, PlayerControl target) angel.Notify(string.Format(GetString("TelepathyConnectWith"), target.GetRealName(clientData: true))); AbilityLimit--; SendSkillRPC(); + angel.RpcResetAbilityCooldown(); return false; } @@ -201,4 +203,6 @@ public override string GetSuffixOthers(PlayerControl seer, PlayerControl seen, b return string.Empty; } + public override string GetProgressText(byte playerId, bool coms) + => ColorString(AbilityLimit >= 1 ? GetRoleColor(CustomRoles.Telepathy).ShadeColor(0.25f) : Color.gray, $"({AbilityLimit})"); } From 789881d16aeb3666084581494862f9d0d646397f Mon Sep 17 00:00:00 2001 From: Ultradragon005 <143632280+Ultradragon005@users.noreply.github.com> Date: Mon, 12 Aug 2024 19:38:24 +0200 Subject: [PATCH 20/43] oh also not supposed to be experimental anymore --- Roles/(Ghosts)/Crewmate/Telepathy.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Roles/(Ghosts)/Crewmate/Telepathy.cs b/Roles/(Ghosts)/Crewmate/Telepathy.cs index 93b397c9d6..805265c08f 100644 --- a/Roles/(Ghosts)/Crewmate/Telepathy.cs +++ b/Roles/(Ghosts)/Crewmate/Telepathy.cs @@ -14,7 +14,6 @@ internal class Telepathy : RoleBase //===========================SETUP================================\\ private const int Id = 28900; public static bool HasEnabled => CustomRoleManager.HasEnabled(CustomRoles.NotAssigned); - public override bool IsExperimental => true; public override CustomRoles ThisRoleBase => CustomRoles.GuardianAngel; public override Custom_RoleType ThisRoleType => Custom_RoleType.CrewmateGhosts; //==================================================================\\ @@ -36,7 +35,7 @@ public override void SetupCustomOption() SetupRoleOptions(Id, TabGroup.CrewmateRoles, CustomRoles.Telepathy); AbilityCooldown = FloatOptionItem.Create(Id + 10, GeneralOption.GuardianAngelBase_ProtectCooldown, new(2.5f, 120f, 2.5f), 35f, TabGroup.CrewmateRoles, false).SetParent(CustomRoleSpawnChances[CustomRoles.Telepathy]) .SetValueFormat(OptionFormat.Seconds); - AbilityUses = IntegerOptionItem.Create(Id + 11, "TelepathyUses", new(1, 14, 1), 14, TabGroup.CrewmateRoles, false).SetParent(Options.CustomRoleSpawnChances[CustomRoles.Telepathy]) + AbilityUses = IntegerOptionItem.Create(Id + 11, "TelepathyUses", new(1, 99, 1), 14, TabGroup.CrewmateRoles, false).SetParent(Options.CustomRoleSpawnChances[CustomRoles.Telepathy]) .SetValueFormat(OptionFormat.Times); MessageMode = StringOptionItem.Create(Id + 12, "Telepathy_MessageMode", EnumHelper.GetAllNames(), 0, TabGroup.CrewmateRoles, false).SetParent(CustomRoleSpawnChances[CustomRoles.Telepathy]); } From 36dcdd24e99805a1cab931c490734e3515c48014 Mon Sep 17 00:00:00 2001 From: Ultradragon005 <143632280+Ultradragon005@users.noreply.github.com> Date: Mon, 12 Aug 2024 19:49:41 +0200 Subject: [PATCH 21/43] eh, this can break too --- Roles/(Ghosts)/Crewmate/Telepathy.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Roles/(Ghosts)/Crewmate/Telepathy.cs b/Roles/(Ghosts)/Crewmate/Telepathy.cs index 805265c08f..09ffea81f0 100644 --- a/Roles/(Ghosts)/Crewmate/Telepathy.cs +++ b/Roles/(Ghosts)/Crewmate/Telepathy.cs @@ -123,7 +123,7 @@ public static bool TelepathyMessage(PlayerControl pc, string[] args) if (!int.TryParse(args[1], out int id) || !DetermineMessage?.ContainsKey(id) is null or true) { SendMessage(GetString("TelepathyMODE2Usage"), pc.PlayerId, title: ColorString(GetRoleColor(CustomRoles.Telepathy), GetString("TelepathyTitle"))); - return false; + break; } ((Telepathy)pc.GetRoleClass()).HasMessaged = true; From f6b47fda89d9c3041bc1c0284bbb4b910b1bc652 Mon Sep 17 00:00:00 2001 From: Ultradragon005 <143632280+Ultradragon005@users.noreply.github.com> Date: Mon, 12 Aug 2024 19:54:28 +0200 Subject: [PATCH 22/43] cleanup logic --- Roles/(Ghosts)/Crewmate/Telepathy.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Roles/(Ghosts)/Crewmate/Telepathy.cs b/Roles/(Ghosts)/Crewmate/Telepathy.cs index 09ffea81f0..2505bb9af6 100644 --- a/Roles/(Ghosts)/Crewmate/Telepathy.cs +++ b/Roles/(Ghosts)/Crewmate/Telepathy.cs @@ -91,7 +91,7 @@ public override void OnOtherTargetsReducedToAtoms(PlayerControl DeadPlayer) public static bool TelepathyMessage(PlayerControl pc, string[] args) { if (!AmongUsClient.Instance.AmHost || !GameStates.IsMeeting || pc == null) return false; - if (!TargetPlayer.TryGetValue(pc.PlayerId, out var tar) || tar == byte.MaxValue) return false; + if (!TargetPlayer.TryGetValue(pc.PlayerId, out var tar) || GetPlayerById(tar) == null) return false; if (args.Length < 2) return false; if (((Telepathy)pc.GetRoleClass())?.HasMessaged is null or true) return false; From ef501d365a8772abea118b0640ab9fe347bc6214 Mon Sep 17 00:00:00 2001 From: Ultradragon005 <143632280+Ultradragon005@users.noreply.github.com> Date: Mon, 12 Aug 2024 19:55:16 +0200 Subject: [PATCH 23/43] change --- Resources/Lang/en_US.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/Lang/en_US.json b/Resources/Lang/en_US.json index df148161bc..0ef0bad60f 100644 --- a/Resources/Lang/en_US.json +++ b/Resources/Lang/en_US.json @@ -2087,7 +2087,7 @@ "TelepathyUses": "Max Connections", "Telepathy_MessageMode": "Message Mode", "Telepathy_MessageMode_YesNo": "Yes/No Confirmation", - "Telepathy_MessageMode_Message": "A Helpful Message", + "Telepathy_MessageMode_Message": "Helpful Messages", "TelepathyCantConnect": "Could not connect with target", "TelepathyConnectWith": "You have made a connection with {0}", "TelepathyYesNoUsage": "Use /tms {yes/no} to answer the player", From ab8b8da64f5b4d31277301cacca2a9110ef19aa5 Mon Sep 17 00:00:00 2001 From: Ultradragon005 <143632280+Ultradragon005@users.noreply.github.com> Date: Mon, 12 Aug 2024 19:59:20 +0200 Subject: [PATCH 24/43] forget revert --- TOHE.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TOHE.csproj b/TOHE.csproj index 1aaef98eaa..c8eb1b593c 100644 --- a/TOHE.csproj +++ b/TOHE.csproj @@ -7,7 +7,7 @@ Town Of Host Enhanced Moe preview - C:\Program Files\Epic Games\AmongUs + Debug;Release;Canary true True From b47aafb5d90af2c8c9c4e2b47881db39d334c4cf Mon Sep 17 00:00:00 2001 From: Ultradragon005 <143632280+Ultradragon005@users.noreply.github.com> Date: Mon, 12 Aug 2024 20:01:36 +0200 Subject: [PATCH 25/43] more cleanup --- Roles/(Ghosts)/Crewmate/Telepathy.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Roles/(Ghosts)/Crewmate/Telepathy.cs b/Roles/(Ghosts)/Crewmate/Telepathy.cs index 2505bb9af6..c9e807eddc 100644 --- a/Roles/(Ghosts)/Crewmate/Telepathy.cs +++ b/Roles/(Ghosts)/Crewmate/Telepathy.cs @@ -167,6 +167,8 @@ public override void OnOthersMeetingHudStart(PlayerControl pc) } public override void OnMeetingHudStart(PlayerControl pc) { + if (_Player == null) return; + switch (MessageMode.GetInt()) { case 0: From 3bfe6757ffd3f2b7b669c5465912281c0acf1d8a Mon Sep 17 00:00:00 2001 From: Ultradragon005 <143632280+Ultradragon005@users.noreply.github.com> Date: Mon, 12 Aug 2024 20:07:28 +0200 Subject: [PATCH 26/43] =?UTF-8?q?nah,=20it=20will=20be=20funny=20af=20?= =?UTF-8?q?=F0=9F=A4=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Roles/(Ghosts)/Crewmate/Telepathy.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Roles/(Ghosts)/Crewmate/Telepathy.cs b/Roles/(Ghosts)/Crewmate/Telepathy.cs index c9e807eddc..55d96c568d 100644 --- a/Roles/(Ghosts)/Crewmate/Telepathy.cs +++ b/Roles/(Ghosts)/Crewmate/Telepathy.cs @@ -55,7 +55,7 @@ public override void ApplyGameOptions(IGameOptions opt, byte playerId) public override bool OnCheckProtect(PlayerControl angel, PlayerControl target) { if (AbilityLimit < 1) return false; - if (target.Is(CustomRoles.Medium) || TargetPlayer.ContainsValue(target.PlayerId)) + if (TargetPlayer.ContainsValue(target.PlayerId)) { angel.Notify(GetString("TelepathyCantConnect")); return false; From eef3efd910810b75dfcd88fbc46e81c6c12c980b Mon Sep 17 00:00:00 2001 From: Ultradragon005 <143632280+Ultradragon005@users.noreply.github.com> Date: Tue, 13 Aug 2024 08:33:16 +0200 Subject: [PATCH 27/43] OH THIS MF --- Modules/ExtendedPlayerControl.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/ExtendedPlayerControl.cs b/Modules/ExtendedPlayerControl.cs index 9431f438b7..249658c119 100644 --- a/Modules/ExtendedPlayerControl.cs +++ b/Modules/ExtendedPlayerControl.cs @@ -787,7 +787,7 @@ public static void RpcMurderPlayer(this PlayerControl killer, PlayerControl targ DollMaster.CheckMurderAsPossessed(killer, target); return; } - Main.PlayerKilledBy[target.PlayerId] = KilledType.Indirectly; + if (!Main.PlayerKilledBy.ContainsKey(target.PlayerId)) Main.PlayerKilledBy[target.PlayerId] = KilledType.Indirectly; killer.RpcMurderPlayer(target, true); } From 35344cf88737dfc904be687f22ac340f97cb1bbc Mon Sep 17 00:00:00 2001 From: Ultradragon005 <143632280+Ultradragon005@users.noreply.github.com> Date: Tue, 13 Aug 2024 08:43:36 +0200 Subject: [PATCH 28/43] fix --- Patches/PlayerControlPatch.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Patches/PlayerControlPatch.cs b/Patches/PlayerControlPatch.cs index 1b3adb0e9d..f8e269bb54 100644 --- a/Patches/PlayerControlPatch.cs +++ b/Patches/PlayerControlPatch.cs @@ -976,7 +976,7 @@ public static void AfterReportTasks(PlayerControl player, NetworkedPlayerInfo ta if (target?.Object?.GetRealKiller() != null) { Main.RememberKillerRole = GetString($"{target.Object.GetRealKiller().GetCustomRole()}"); - if (target.Object.GetRealKiller().IsAnySubRole(x => x.IsConverted() && !target.Object.Is(CustomRoles.Madmate))) + if (!target.Object.GetRealKiller().IsAnySubRole(x => x.IsConverted() && !target.Object.Is(CustomRoles.Madmate))) Main.RememberedFaction = target.Object.GetRealKiller().GetCustomRole().GetCustomRoleTeam(); else Main.RememberedFaction = Custom_Team.Neutral; From fe63d08b53fa53dd30253ac5f519a98dbea23cf3 Mon Sep 17 00:00:00 2001 From: Ultradragon005 <143632280+Ultradragon005@users.noreply.github.com> Date: Tue, 13 Aug 2024 09:08:53 +0200 Subject: [PATCH 29/43] I already checked for null --- Roles/(Ghosts)/Crewmate/Telepathy.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Roles/(Ghosts)/Crewmate/Telepathy.cs b/Roles/(Ghosts)/Crewmate/Telepathy.cs index 55d96c568d..1f2ef1c54a 100644 --- a/Roles/(Ghosts)/Crewmate/Telepathy.cs +++ b/Roles/(Ghosts)/Crewmate/Telepathy.cs @@ -95,7 +95,7 @@ public static bool TelepathyMessage(PlayerControl pc, string[] args) if (args.Length < 2) return false; if (((Telepathy)pc.GetRoleClass())?.HasMessaged is null or true) return false; - Dictionary DetermineMessage = ((Telepathy)pc.GetRoleClass())?.Determinemessage; + Dictionary DetermineMessage = ((Telepathy)pc.GetRoleClass()).Determinemessage; string[] cmds = {"/tms"}; // Here you can add custom cmds @@ -120,7 +120,7 @@ public static bool TelepathyMessage(PlayerControl pc, string[] args) case 1: - if (!int.TryParse(args[1], out int id) || !DetermineMessage?.ContainsKey(id) is null or true) + if (!int.TryParse(args[1], out int id) || !DetermineMessage.ContainsKey(id)) { SendMessage(GetString("TelepathyMODE2Usage"), pc.PlayerId, title: ColorString(GetRoleColor(CustomRoles.Telepathy), GetString("TelepathyTitle"))); break; From 8f7477cca52d828aaadabc2f170666a824b951e9 Mon Sep 17 00:00:00 2001 From: Ultradragon005 <143632280+Ultradragon005@users.noreply.github.com> Date: Tue, 13 Aug 2024 12:45:38 +0200 Subject: [PATCH 30/43] use strinbuilder && 0 => 1 --- Modules/Utils.cs | 14 +++++++------- Resources/Lang/en_US.json | 8 ++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Modules/Utils.cs b/Modules/Utils.cs index 03997a61f4..42a8488f67 100644 --- a/Modules/Utils.cs +++ b/Modules/Utils.cs @@ -1697,9 +1697,9 @@ static t CreateAndInvoke(Func func) } List TakeMsg = [..Translatables]; - var Msg = ""; + var Msg = new StringBuilder(); DeterminedMessage = []; - for (int i = 0; i < 3; i++) + for (int i = 1; i <= 3; i++) { var ran = TakeMsg.RandomElement(); TakeMsg.Remove(ran); @@ -1720,9 +1720,9 @@ static t CreateAndInvoke(Func func) "Messenger.TheLastKillers" when Main.AllAlivePlayerControls.Where(x => x.GetCustomRole().IsImpostor() || x.IsNeutralKiller() || x.IsNeutralApocalypse()).Any() => CreateAndInvoke(() => { var Killers = Main.AllAlivePlayerControls.Where(x => x.GetCustomRole().IsImpostor() || x.IsNeutralKiller() || x.IsNeutralApocalypse()); - string msg = ""; - Killers.Do(x => msg += $"{GetString($"{x.GetCustomRole()}")}, "); - return string.Format(GetString("Messenger.TheLastKillers"), msg); + var msg = new StringBuilder(); + Killers.Do(x => msg.Append($"{GetString($"{x.GetCustomRole()}")}, ")); + return string.Format(GetString("Messenger.TheLastKillers"), msg.ToString()); }), "Messenger.PlayerOnSameTeam" when Main.AllAlivePlayerControls.Shuffle(IRandom.Instance).FirstOrDefault(x => Player.IsSameTeammate(x, out _)) is not null and PlayerControl friend => string.Format(GetString("Messenger.PlayerOnSameTeam"), friend.GetRealName(clientData: true)), "Messenger.LazyFuck" => CreateAndInvoke(() => @@ -1757,11 +1757,11 @@ static t CreateAndInvoke(Func func) Utils.ThrowException(exx); } DeterminedMessage[i] = CurrentMessage; - Msg += $"{i}) " + CurrentMessage + "\n"; + Msg.Append($"{i}) " + CurrentMessage + "\n"); } - return Msg; + return Msg.ToString(); } diff --git a/Resources/Lang/en_US.json b/Resources/Lang/en_US.json index 0ef0bad60f..1f18de9bc0 100644 --- a/Resources/Lang/en_US.json +++ b/Resources/Lang/en_US.json @@ -2076,8 +2076,8 @@ "MessengerTitle": "MESSENGER", "MessengerTitleTarget": "A Voice From Above Whispers...", - "MessengerUsage": "Type /mms {0/1/2} to send a message.", - "Messenger.Msg": "What would you like the public to know?\n\n{0}\n\nUse /mms [0/1/2] to answer.", + "MessengerUsage": "Type /mms {1/2/3} to send a message.", + "Messenger.Msg": "What would you like the public to know?\n\n{0}\n\nUse /mms [1/2/3] to answer.", "Suicide_": "By Suicide", "Remotely": "Remotely", @@ -2096,11 +2096,11 @@ "TelepathyYes": "The telepathy confirms your inquiry", "TelepathyNo": "The telepathy denies your inquiry", "TelepathyConfirmSelf": "You have succesfully sent your message", - "TelepathyMODE2Usage": "Use /tms {0/1/2} to submit your answers", + "TelepathyMODE2Usage": "Use /tms {1/2/3} to submit your answers", "TelepathyNotifyTarget": "The Telepathy {0} has made a connection with you, meaning you may ask it a question and it might answer back confirming or denying it.", "TelepathyNotifyTargetMODE2": "The Telepathy {0} has made a connection with you, meaning you might hear useful info from them.", "TelepathyNotifySelf": "You have made a connection with {0}, answer with /tms [yes/no] to one of their questions.\n Note: They may try to disguise their question, so be on watch", - "TelepathyNotifySelfMODE2": "What would you like to whisper to {0}?\n\n{1}\n\nUse /tms [0/1/2] to answer.", + "TelepathyNotifySelfMODE2": "What would you like to whisper to {0}?\n\n{1}\n\nUse /tms [1/2/3] to answer.", "TelepathyTargetDisconnect": "Your target has Died/Disconnected", "SpurtMinSpeed": "Min Speed", "SpurtMaxSpeed": "Max Speed", From 5470ce0b1076f4ae4811e30bc5c3f2aaa250a8d2 Mon Sep 17 00:00:00 2001 From: Ultradragon005 <143632280+Ultradragon005@users.noreply.github.com> Date: Tue, 13 Aug 2024 12:49:02 +0200 Subject: [PATCH 31/43] fix --- Modules/ExtendedPlayerControl.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Modules/ExtendedPlayerControl.cs b/Modules/ExtendedPlayerControl.cs index 249658c119..c1c54019dd 100644 --- a/Modules/ExtendedPlayerControl.cs +++ b/Modules/ExtendedPlayerControl.cs @@ -787,7 +787,6 @@ public static void RpcMurderPlayer(this PlayerControl killer, PlayerControl targ DollMaster.CheckMurderAsPossessed(killer, target); return; } - if (!Main.PlayerKilledBy.ContainsKey(target.PlayerId)) Main.PlayerKilledBy[target.PlayerId] = KilledType.Indirectly; killer.RpcMurderPlayer(target, true); } From 579ac5649a3791d35f374edad95790fbe6a80daf Mon Sep 17 00:00:00 2001 From: Ultradragon005 <143632280+Ultradragon005@users.noreply.github.com> Date: Tue, 13 Aug 2024 12:49:50 +0200 Subject: [PATCH 32/43] fix again.. --- Patches/PlayerControlPatch.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Patches/PlayerControlPatch.cs b/Patches/PlayerControlPatch.cs index f8e269bb54..f6aeacc0de 100644 --- a/Patches/PlayerControlPatch.cs +++ b/Patches/PlayerControlPatch.cs @@ -500,7 +500,7 @@ public static void Postfix(PlayerControl __instance, [HarmonyArgument(0)] Player else if (target.GetRealKiller() == target) Main.PlayerKilledBy[target.PlayerId] = KilledType.Suicide_; else - Main.PlayerKilledBy[target.PlayerId] = KilledType.Directly; + Main.PlayerKilledBy[target.PlayerId] = KilledType.Indirectly; } }, 1f, "Set Main.Playerkilled by in MurderPlayer Patch"); From a844c521ce831b6e7fe0c2fd6ab3edb16ae013b8 Mon Sep 17 00:00:00 2001 From: Ultradragon005 <143632280+Ultradragon005@users.noreply.github.com> Date: Tue, 13 Aug 2024 13:05:12 +0200 Subject: [PATCH 33/43] rename --- Modules/Utils.cs | 4 ++-- Patches/PlayerControlPatch.cs | 10 +++++----- Patches/onGameStartedPatch.cs | 2 +- main.cs | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Modules/Utils.cs b/Modules/Utils.cs index 42a8488f67..541c665fef 100644 --- a/Modules/Utils.cs +++ b/Modules/Utils.cs @@ -1714,7 +1714,7 @@ static t CreateAndInvoke(Func func) SystemTypes room = killar.GetPlainShipRoom().RoomId; return string.Format(GetString("Messenger.KillerExistIn"), GetString($"{room}")); }), - "Messenger.KillersRoleIs" when Main.RememberKillerRole != "" => string.Format(GetString("Messenger.KillersRoleIs"), Main.RememberKillerRole), + "Messenger.KillersRoleIs" when Main.RememberRoleOfDeadBodyKiller != "" => string.Format(GetString("Messenger.KillersRoleIs"), Main.RememberRoleOfDeadBodyKiller), "Messenger.KilledType" when Main.PlayerKilledBy.TryGetValue(Player.PlayerId, out var KilledType) => string.Format(GetString("Messenger.KilledType"), GetString($"{KilledType}")), "Messenger.MyTypeIs" => string.Format(GetString("Messenger.MyTypeIs"), (!Player.IsAnySubRole(x => x.IsConverted() && !Player.Is(CustomRoles.Madmate)) ? Player.GetCustomRole().GetCustomRoleTeam() : Custom_Team.Neutral)), "Messenger.TheLastKillers" when Main.AllAlivePlayerControls.Where(x => x.GetCustomRole().IsImpostor() || x.IsNeutralKiller() || x.IsNeutralApocalypse()).Any() => CreateAndInvoke(() => @@ -1737,7 +1737,7 @@ static t CreateAndInvoke(Func func) return string.Format(GetString("Messenger.LazyFuck"), ScapeGoat.GetRealName(clientData: true)); }), - "Messenger.KillersFaction" when Main.RememberedFaction != null => string.Format(GetString("Messenger.KillersFaction"), GetString($"Team{Main.RememberedFaction.Value}")), + "Messenger.KillersFaction" when Main.RememberTeamOfDeadBodyKiller != null => string.Format(GetString("Messenger.KillersFaction"), GetString($"Team{Main.RememberTeamOfDeadBodyKiller.Value}")), _ => CreateAndInvoke(() => { diff --git a/Patches/PlayerControlPatch.cs b/Patches/PlayerControlPatch.cs index f6aeacc0de..e4273d71a9 100644 --- a/Patches/PlayerControlPatch.cs +++ b/Patches/PlayerControlPatch.cs @@ -971,15 +971,15 @@ public static void AfterReportTasks(PlayerControl player, NetworkedPlayerInfo ta } } - Main.RememberedFaction = null; - Main.RememberKillerRole = ""; + Main.RememberTeamOfDeadBodyKiller = null; + Main.RememberRoleOfDeadBodyKiller = ""; if (target?.Object?.GetRealKiller() != null) { - Main.RememberKillerRole = GetString($"{target.Object.GetRealKiller().GetCustomRole()}"); + Main.RememberRoleOfDeadBodyKiller = GetString($"{target.Object.GetRealKiller().GetCustomRole()}"); if (!target.Object.GetRealKiller().IsAnySubRole(x => x.IsConverted() && !target.Object.Is(CustomRoles.Madmate))) - Main.RememberedFaction = target.Object.GetRealKiller().GetCustomRole().GetCustomRoleTeam(); + Main.RememberTeamOfDeadBodyKiller = target.Object.GetRealKiller().GetCustomRole().GetCustomRoleTeam(); else - Main.RememberedFaction = Custom_Team.Neutral; + Main.RememberTeamOfDeadBodyKiller = Custom_Team.Neutral; } // Alchemist & Bloodlust diff --git a/Patches/onGameStartedPatch.cs b/Patches/onGameStartedPatch.cs index 3365bb432d..bad08a3fb3 100644 --- a/Patches/onGameStartedPatch.cs +++ b/Patches/onGameStartedPatch.cs @@ -66,7 +66,7 @@ public static void Postfix(AmongUsClient __instance) PlayerControlSetRolePatch.DidSetGhost.Clear(); Main.LastKillerRoom.Clear(); - Main.RememberedFaction = null; + Main.RememberTeamOfDeadBodyKiller = null; Main.PlayerKilledBy.Clear(); Main.CheckShapeshift.Clear(); diff --git a/main.cs b/main.cs index 0f324bf7cf..499fe60467 100644 --- a/main.cs +++ b/main.cs @@ -156,8 +156,8 @@ public class Main : BasePlugin public static readonly Dictionary AllKillers = []; public static readonly Dictionary LastKillerRoom = []; public static readonly Dictionary PlayerKilledBy = []; - public static Custom_Team? RememberedFaction; - public static string RememberKillerRole = ""; + public static Custom_Team? RememberTeamOfDeadBodyKiller; + public static string RememberRoleOfDeadBodyKiller = ""; public static readonly Dictionary CheckShapeshift = []; public static readonly Dictionary ShapeshiftTarget = []; From a68a2e289dad4b81e68ca0ef9565a37eeabc5563 Mon Sep 17 00:00:00 2001 From: Ultradragon005 <143632280+Ultradragon005@users.noreply.github.com> Date: Fri, 16 Aug 2024 17:26:16 +0200 Subject: [PATCH 34/43] simplify --- Modules/Utils.cs | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/Modules/Utils.cs b/Modules/Utils.cs index 541c665fef..9923ceab6b 100644 --- a/Modules/Utils.cs +++ b/Modules/Utils.cs @@ -1667,22 +1667,8 @@ public static List GetPlayerListByRole(this CustomRoles role) public static bool IsSameTeammate(this PlayerControl player, PlayerControl target, out Custom_Team team) { - team = default; - if (player.IsAnySubRole(x => x.IsConverted())) - { - var Compare = player.GetCustomSubRoles().First(x => x.IsConverted()); - - team = player.Is(CustomRoles.Madmate) ? Custom_Team.Impostor : Custom_Team.Neutral; - return target.Is(Compare); - } - else if (!target.IsAnySubRole(x => x.IsConverted())) - { - team = player.GetCustomRole().GetCustomRoleTeam(); - return target.Is(team); - } - - - return false; + team = player.IsAnySubRole(x => x.IsConverted() && x is CustomRoles.Madmate) ? player.GetCustomRole().GetCustomRoleTeam() : Custom_Team.Neutral; + return player.GetCountTypes() == target.GetCountTypes(); } public static string DetermineSetMessage(PlayerControl Player, PlayerControl killer, out Dictionary DeterminedMessage) { From ea1cf2fb27bc2d9dc24f306ee906de7e359f7111 Mon Sep 17 00:00:00 2001 From: Ultradragon005 <143632280+Ultradragon005@users.noreply.github.com> Date: Fri, 16 Aug 2024 17:26:35 +0200 Subject: [PATCH 35/43] fix --- Modules/Utils.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Utils.cs b/Modules/Utils.cs index 9923ceab6b..0d15c9c287 100644 --- a/Modules/Utils.cs +++ b/Modules/Utils.cs @@ -1667,7 +1667,7 @@ public static List GetPlayerListByRole(this CustomRoles role) public static bool IsSameTeammate(this PlayerControl player, PlayerControl target, out Custom_Team team) { - team = player.IsAnySubRole(x => x.IsConverted() && x is CustomRoles.Madmate) ? player.GetCustomRole().GetCustomRoleTeam() : Custom_Team.Neutral; + team = player.IsAnySubRole(x => x.IsConverted() && x is not CustomRoles.Madmate) ? player.GetCustomRole().GetCustomRoleTeam() : Custom_Team.Neutral; return player.GetCountTypes() == target.GetCountTypes(); } public static string DetermineSetMessage(PlayerControl Player, PlayerControl killer, out Dictionary DeterminedMessage) From 70d2a6f58d8d393c31a375177cf5e92cceef5500 Mon Sep 17 00:00:00 2001 From: Ultradragon005 <143632280+Ultradragon005@users.noreply.github.com> Date: Fri, 16 Aug 2024 17:26:56 +0200 Subject: [PATCH 36/43] fix again... --- Modules/Utils.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Utils.cs b/Modules/Utils.cs index 0d15c9c287..9dc662e8d4 100644 --- a/Modules/Utils.cs +++ b/Modules/Utils.cs @@ -1667,7 +1667,7 @@ public static List GetPlayerListByRole(this CustomRoles role) public static bool IsSameTeammate(this PlayerControl player, PlayerControl target, out Custom_Team team) { - team = player.IsAnySubRole(x => x.IsConverted() && x is not CustomRoles.Madmate) ? player.GetCustomRole().GetCustomRoleTeam() : Custom_Team.Neutral; + team = !player.IsAnySubRole(x => x.IsConverted() && x is not CustomRoles.Madmate) ? player.GetCustomRole().GetCustomRoleTeam() : Custom_Team.Neutral; return player.GetCountTypes() == target.GetCountTypes(); } public static string DetermineSetMessage(PlayerControl Player, PlayerControl killer, out Dictionary DeterminedMessage) From a18590491afdc4b63773d983f24864022e4daefe Mon Sep 17 00:00:00 2001 From: Ultradragon005 <143632280+Ultradragon005@users.noreply.github.com> Date: Fri, 16 Aug 2024 17:29:17 +0200 Subject: [PATCH 37/43] change --- Roles/(Ghosts)/Impostor/Minion.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Roles/(Ghosts)/Impostor/Minion.cs b/Roles/(Ghosts)/Impostor/Minion.cs index 028cea3458..d28907a6d8 100644 --- a/Roles/(Ghosts)/Impostor/Minion.cs +++ b/Roles/(Ghosts)/Impostor/Minion.cs @@ -53,8 +53,8 @@ public override string GetLowerTextOthers(PlayerControl seer, PlayerControl targ } public override bool OnCheckProtect(PlayerControl killer, PlayerControl target) { - var ImpPVC = target.GetCustomRole().IsImpostor(); - if (!ImpPVC || killer.IsAnySubRole(x => x.IsConverted() && !killer.Is(CustomRoles.Madmate))) + var ImpPVC = killer.IsSameTeammate(target, out _); + if (!ImpPVC) { Main.PlayerStates[target.PlayerId].IsBlackOut = true; target.MarkDirtySettings(); From c7be73859986c8e33b6f6ea37ab71adbcd363f15 Mon Sep 17 00:00:00 2001 From: Ultradragon005 <143632280+Ultradragon005@users.noreply.github.com> Date: Fri, 16 Aug 2024 17:36:11 +0200 Subject: [PATCH 38/43] fix again.. --- Roles/(Ghosts)/Impostor/Minion.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Roles/(Ghosts)/Impostor/Minion.cs b/Roles/(Ghosts)/Impostor/Minion.cs index d28907a6d8..574de2a9da 100644 --- a/Roles/(Ghosts)/Impostor/Minion.cs +++ b/Roles/(Ghosts)/Impostor/Minion.cs @@ -44,7 +44,7 @@ public override void ApplyGameOptions(IGameOptions opt, byte playerId) } public override string GetLowerTextOthers(PlayerControl seer, PlayerControl target = null, bool isForMeeting = false, bool isForHud = false) { - if ((seer.GetCustomRole().IsImpostorTeam()) && Main.PlayerStates[target.PlayerId].IsBlackOut && !isForMeeting) + if ((_Player?.IsSameTeammate(target, out _) == true) && Main.PlayerStates[target.PlayerId].IsBlackOut && !isForMeeting) { var blinded = Translator.GetString("Minion_Blind"); return ColorString(GetRoleColor(CustomRoles.Minion), $"『{blinded}』"); From 35445b1e6600fe45389313c33841ad7144cf7ac6 Mon Sep 17 00:00:00 2001 From: Ultradragon005 <143632280+Ultradragon005@users.noreply.github.com> Date: Sat, 17 Aug 2024 10:04:25 +0200 Subject: [PATCH 39/43] fix id --- Roles/(Ghosts)/Crewmate/Telepathy.cs | 2 +- Roles/AddOns/Common/Messenger.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Roles/(Ghosts)/Crewmate/Telepathy.cs b/Roles/(Ghosts)/Crewmate/Telepathy.cs index 1f2ef1c54a..36778f731b 100644 --- a/Roles/(Ghosts)/Crewmate/Telepathy.cs +++ b/Roles/(Ghosts)/Crewmate/Telepathy.cs @@ -12,7 +12,7 @@ namespace TOHE.Roles._Ghosts_.Crewmate; internal class Telepathy : RoleBase { //===========================SETUP================================\\ - private const int Id = 28900; + private const int Id = 29300; public static bool HasEnabled => CustomRoleManager.HasEnabled(CustomRoles.NotAssigned); public override CustomRoles ThisRoleBase => CustomRoles.GuardianAngel; public override Custom_RoleType ThisRoleType => Custom_RoleType.CrewmateGhosts; diff --git a/Roles/AddOns/Common/Messenger.cs b/Roles/AddOns/Common/Messenger.cs index cf9d22840b..22140e3562 100644 --- a/Roles/AddOns/Common/Messenger.cs +++ b/Roles/AddOns/Common/Messenger.cs @@ -11,7 +11,7 @@ namespace TOHE.Roles.AddOns.Common; public class Messenger : IAddon { - private const int Id = 29100; + private const int Id = 29200; private static OptionItem ImpostorsHearMessage; private static OptionItem NeutralsHearMessage; private static OptionItem KnowMessenger; From 57c3b3e52c31ebca159b572c62394cf7c2c7a6ab Mon Sep 17 00:00:00 2001 From: Ultradragon005 <143632280+Ultradragon005@users.noreply.github.com> Date: Sat, 17 Aug 2024 11:06:29 +0200 Subject: [PATCH 40/43] CustomRoles.NotAssigned => CustomRoles.Telepathy --- Roles/(Ghosts)/Crewmate/Telepathy.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Roles/(Ghosts)/Crewmate/Telepathy.cs b/Roles/(Ghosts)/Crewmate/Telepathy.cs index 36778f731b..53f4220271 100644 --- a/Roles/(Ghosts)/Crewmate/Telepathy.cs +++ b/Roles/(Ghosts)/Crewmate/Telepathy.cs @@ -13,7 +13,7 @@ internal class Telepathy : RoleBase { //===========================SETUP================================\\ private const int Id = 29300; - public static bool HasEnabled => CustomRoleManager.HasEnabled(CustomRoles.NotAssigned); + public static bool HasEnabled => CustomRoleManager.HasEnabled(CustomRoles.Telepathy); public override CustomRoles ThisRoleBase => CustomRoles.GuardianAngel; public override Custom_RoleType ThisRoleType => Custom_RoleType.CrewmateGhosts; //==================================================================\\ From f49691ffab84ae2c1547a1366ce182c7bff30a81 Mon Sep 17 00:00:00 2001 From: Ultradragon005 <143632280+Ultradragon005@users.noreply.github.com> Date: Mon, 19 Aug 2024 19:09:20 +0200 Subject: [PATCH 41/43] I forgot .outofgame exists... --- Modules/Utils.cs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Modules/Utils.cs b/Modules/Utils.cs index 9dc662e8d4..541c665fef 100644 --- a/Modules/Utils.cs +++ b/Modules/Utils.cs @@ -1667,8 +1667,22 @@ public static List GetPlayerListByRole(this CustomRoles role) public static bool IsSameTeammate(this PlayerControl player, PlayerControl target, out Custom_Team team) { - team = !player.IsAnySubRole(x => x.IsConverted() && x is not CustomRoles.Madmate) ? player.GetCustomRole().GetCustomRoleTeam() : Custom_Team.Neutral; - return player.GetCountTypes() == target.GetCountTypes(); + team = default; + if (player.IsAnySubRole(x => x.IsConverted())) + { + var Compare = player.GetCustomSubRoles().First(x => x.IsConverted()); + + team = player.Is(CustomRoles.Madmate) ? Custom_Team.Impostor : Custom_Team.Neutral; + return target.Is(Compare); + } + else if (!target.IsAnySubRole(x => x.IsConverted())) + { + team = player.GetCustomRole().GetCustomRoleTeam(); + return target.Is(team); + } + + + return false; } public static string DetermineSetMessage(PlayerControl Player, PlayerControl killer, out Dictionary DeterminedMessage) { From d95bb1734af590f068582676182059ea1c9940b6 Mon Sep 17 00:00:00 2001 From: Ultradragon005 <143632280+Ultradragon005@users.noreply.github.com> Date: Mon, 19 Aug 2024 19:12:35 +0200 Subject: [PATCH 42/43] . --- Roles/AddOns/Common/Rebirth.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Roles/AddOns/Common/Rebirth.cs b/Roles/AddOns/Common/Rebirth.cs index 7dd98a67d1..eaf6a8c94f 100644 --- a/Roles/AddOns/Common/Rebirth.cs +++ b/Roles/AddOns/Common/Rebirth.cs @@ -23,7 +23,7 @@ public void SetupCustomOption() .SetValueFormat(OptionFormat.Times); OnlyVoted = BooleanOptionItem.Create(Id + 12, "RebirthCountVotes", false, TabGroup.Addons, false); } - public static void Init() + public void Init() { Rebirths.Clear(); VotedCount.Clear(); From 89ffd8edb305bbb08f8ecabe02bc4db5d453dc79 Mon Sep 17 00:00:00 2001 From: Ultradragon005 <143632280+Ultradragon005@users.noreply.github.com> Date: Thu, 29 Aug 2024 08:25:49 +0200 Subject: [PATCH 43/43] fix error --- Patches/onGameStartedPatch.cs | 2 -- Roles/AddOns/Common/Evader.cs | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/Patches/onGameStartedPatch.cs b/Patches/onGameStartedPatch.cs index 3b9552bb59..9a3b2c5228 100644 --- a/Patches/onGameStartedPatch.cs +++ b/Patches/onGameStartedPatch.cs @@ -207,8 +207,6 @@ public static void Postfix(AmongUsClient __instance) TargetArrow.Init(); LocateArrow.Init(); DoubleTrigger.Init(); - Rebirth.Init(); - Evader.Init(); //FFA FFAManager.Init(); diff --git a/Roles/AddOns/Common/Evader.cs b/Roles/AddOns/Common/Evader.cs index bb87f27128..4345e6d304 100644 --- a/Roles/AddOns/Common/Evader.cs +++ b/Roles/AddOns/Common/Evader.cs @@ -21,7 +21,7 @@ public void SetupCustomOption() .SetParent(Options.CustomRoleSpawnChances[CustomRoles.Evader]) .SetValueFormat(OptionFormat.Percent); } - public static void Init() + public void Init() { SkillLimit.Clear(); }