From 0db493a0839fa11f4eb7abd520ce506f2cae9d95 Mon Sep 17 00:00:00 2001 From: kou-hetare <96226646+kou-hetare@users.noreply.github.com> Date: Mon, 15 Jul 2024 00:35:38 +0900 Subject: [PATCH 1/8] =?UTF-8?q?SetRole=20RPC=E3=81=AE=E7=99=BA=E8=A1=8C?= =?UTF-8?q?=E6=95=B0=E3=82=92=E6=9C=80=E9=81=A9=E5=8C=96=E3=80=82DesyncImp?= =?UTF-8?q?ostor=E3=81=AB=E3=82=82=E6=AD=A3=E3=81=97=E3=81=8F=E9=85=8D?= =?UTF-8?q?=E5=BD=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Patches/onGameStartedPatch.cs | 83 ++++++++++++----------------------- 1 file changed, 28 insertions(+), 55 deletions(-) diff --git a/Patches/onGameStartedPatch.cs b/Patches/onGameStartedPatch.cs index 860f63609..4b16a6d39 100644 --- a/Patches/onGameStartedPatch.cs +++ b/Patches/onGameStartedPatch.cs @@ -145,15 +145,13 @@ public static void Prefix() PlayerControl.LocalPlayer.RpcSetRole(RoleTypes.Crewmate); PlayerControl.LocalPlayer.Data.IsDead = true; } - Dictionary<(byte, byte), RoleTypes> rolesMap = new(); foreach (var (role, info) in CustomRoleManager.AllRolesInfo) { if (info.IsDesyncImpostor) { - AssignDesyncRole(role, AllPlayers, senders, rolesMap, BaseRole: info.BaseRoleType.Invoke()); + AssignDesyncRole(role, AllPlayers, senders, BaseRole: info.BaseRoleType.Invoke()); } } - MakeDesyncSender(senders, rolesMap); } //以下、バニラ側の役職割り当てが入る } @@ -165,7 +163,7 @@ public static void Postfix() // 不要なオブジェクトの削除 RpcSetRoleReplacer.senders = null; - RpcSetRoleReplacer.OverriddenSenderList = null; + RpcSetRoleReplacer.DesyncImpostorList = null; RpcSetRoleReplacer.StoragedData = null; //Utils.ApplySuffix(); @@ -337,7 +335,7 @@ public static void Postfix() Utils.SyncAllSettings(); SetColorPatch.IsAntiGlitchDisabled = false; } - private static void AssignDesyncRole(CustomRoles role, List AllPlayers, Dictionary senders, Dictionary<(byte, byte), RoleTypes> rolesMap, RoleTypes BaseRole, RoleTypes hostBaseRole = RoleTypes.Crewmate) + private static void AssignDesyncRole(CustomRoles role, List AllPlayers, Dictionary senders, RoleTypes BaseRole, RoleTypes hostBaseRole = RoleTypes.Crewmate) { if (!role.IsPresent()) return; @@ -350,53 +348,26 @@ private static void AssignDesyncRole(CustomRoles role, List AllPl var player = AllPlayers[rand.Next(0, AllPlayers.Count)]; AllPlayers.Remove(player); PlayerState.GetByPlayerId(player.PlayerId).SetMainRole(role); + RpcSetRoleReplacer.DesyncImpostorList.Add(player.PlayerId); - var selfRole = player.PlayerId == hostId ? hostBaseRole : BaseRole; - var othersRole = player.PlayerId == hostId ? RoleTypes.Crewmate : RoleTypes.Scientist; - - //Desync役職視点 - foreach (var target in Main.AllPlayerControls) + var hostRole = player.PlayerId == hostId ? hostBaseRole : RoleTypes.Crewmate; + foreach (var seer in Main.AllPlayerControls) { - if (player.PlayerId != target.PlayerId) + if (seer.PlayerId == hostId) { - rolesMap[(player.PlayerId, target.PlayerId)] = othersRole; + //ホスト視点は即確定 + player.StartCoroutine(player.CoSetRole(hostRole, false)); } else { - rolesMap[(player.PlayerId, target.PlayerId)] = selfRole; - } - } - - //他者視点 - foreach (var seer in Main.AllPlayerControls) - { - if (player.PlayerId != seer.PlayerId) - { - rolesMap[(seer.PlayerId, player.PlayerId)] = othersRole; + var assignRole = seer.PlayerId == player.PlayerId ? BaseRole : RoleTypes.Scientist; + senders[player.PlayerId].RpcSetRole(player, assignRole, seer.GetClientId()); } } - RpcSetRoleReplacer.OverriddenSenderList.Add(senders[player.PlayerId]); - //ホスト視点はロール決定 - player.StartCoroutine(player.CoSetRole(othersRole, false)); + //vailla配役の回避 player.Data.IsDead = true; } } - public static void MakeDesyncSender(Dictionary senders, Dictionary<(byte, byte), RoleTypes> rolesMap) - { - var hostId = PlayerControl.LocalPlayer.PlayerId; - foreach (var seer in Main.AllPlayerControls) - { - var sender = senders[seer.PlayerId]; - foreach (var target in Main.AllPlayerControls) - { - if (rolesMap.TryGetValue((seer.PlayerId, target.PlayerId), out var role)) - { - sender.RpcSetRole(seer, role, target.GetClientId()); - } - } - } - } - private static List AssignCustomRolesFromList(CustomRoles role, List players, int RawCount = -1) { if (players == null || players.Count <= 0) return null; @@ -472,8 +443,7 @@ class RpcSetRoleReplacer public static bool doReplace = false; public static Dictionary senders; public static List<(PlayerControl, RoleTypes)> StoragedData = new(); - // 役職Desyncなど別の処理でSetRoleRpcを書き込み済みなため、追加の書き込みが不要なSenderのリスト - public static List OverriddenSenderList; + public static List DesyncImpostorList; public static bool Prefix(PlayerControl __instance, [HarmonyArgument(0)] RoleTypes roleType) { if (doReplace && senders != null) @@ -485,21 +455,24 @@ public static bool Prefix(PlayerControl __instance, [HarmonyArgument(0)] RoleTyp } public static void Release() { - foreach (var sender in senders) + foreach (var (player, role) in StoragedData) { - if (OverriddenSenderList.Contains(sender.Value)) continue; - if (sender.Value.CurrentState != CustomRpcSender.State.InRootMessage) - throw new InvalidOperationException("A CustomRpcSender had Invalid State."); + //ホスト視点は即確定 + player.StartCoroutine(player.CoSetRole(role, false)); - foreach (var pair in StoragedData) + var impostorRole = role is RoleTypes.Impostor or RoleTypes.Shapeshifter or RoleTypes.Phantom; + if (impostorRole && DesyncImpostorList.Count != 0) + { + foreach (var seer in Main.AllPlayerControls) + { + var assignRole = DesyncImpostorList.Contains(seer.PlayerId) ? role : RoleTypes.Scientist; + senders[player.PlayerId].RpcSetRole(player, assignRole, seer.GetClientId()); + } + } + else { - pair.Item1.StartCoroutine(pair.Item1.CoSetRole(pair.Item2, false)); - sender.Value.AutoStartRpc(pair.Item1.NetId, (byte)RpcCalls.SetRole, Utils.GetPlayerById(sender.Key).GetClientId()) - .Write((ushort)pair.Item2) - .Write(false) - .EndRpc(); + senders[player.PlayerId].RpcSetRole(player, role); } - sender.Value.EndMessage(); } doReplace = false; } @@ -507,7 +480,7 @@ public static void StartReplace(Dictionary senders) { RpcSetRoleReplacer.senders = senders; StoragedData = new(); - OverriddenSenderList = new(); + DesyncImpostorList = new(); doReplace = true; } } From 362694f620356b267ba6e0bfa0ac43f208335074 Mon Sep 17 00:00:00 2001 From: kou-hetare <96226646+kou-hetare@users.noreply.github.com> Date: Mon, 15 Jul 2024 17:19:44 +0900 Subject: [PATCH 2/8] =?UTF-8?q?=20DesyncImpostor=E3=81=AERole=E5=88=A4?= =?UTF-8?q?=E5=AE=9A=E3=81=8C=E9=80=86=E3=81=A0=E3=81=A3=E3=81=9F=E3=81=9F?= =?UTF-8?q?=E3=82=81=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Patches/onGameStartedPatch.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Patches/onGameStartedPatch.cs b/Patches/onGameStartedPatch.cs index 4b16a6d39..520d7d5b1 100644 --- a/Patches/onGameStartedPatch.cs +++ b/Patches/onGameStartedPatch.cs @@ -465,7 +465,7 @@ public static void Release() { foreach (var seer in Main.AllPlayerControls) { - var assignRole = DesyncImpostorList.Contains(seer.PlayerId) ? role : RoleTypes.Scientist; + var assignRole = DesyncImpostorList.Contains(seer.PlayerId) ? RoleTypes.Scientist : role; senders[player.PlayerId].RpcSetRole(player, assignRole, seer.GetClientId()); } } From b77028b278aa9fc296f6d930fe12d7fa4485f619 Mon Sep 17 00:00:00 2001 From: kou-hetare <96226646+kou-hetare@users.noreply.github.com> Date: Mon, 15 Jul 2024 17:16:28 +0900 Subject: [PATCH 3/8] =?UTF-8?q?Noise=E3=81=AEDesyncImpostor=E5=AF=BE?= =?UTF-8?q?=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Modules/AURoleOptions.cs | 5 +++++ Modules/GameOptionsSender/PlayerGameOptionsSender.cs | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/Modules/AURoleOptions.cs b/Modules/AURoleOptions.cs index 18ac4a4e5..f83163363 100644 --- a/Modules/AURoleOptions.cs +++ b/Modules/AURoleOptions.cs @@ -66,5 +66,10 @@ public static bool ShapeshifterLeaveSkin get => Opt.GetBool(BoolOptionNames.ShapeshifterLeaveSkin); set => Opt.SetBool(BoolOptionNames.ShapeshifterLeaveSkin, value); } + public static bool NoisemakerImpostorAlert + { + get => Opt.GetBool(BoolOptionNames.NoisemakerImpostorAlert); + set => Opt.SetBool(BoolOptionNames.NoisemakerImpostorAlert, value); + } } } \ No newline at end of file diff --git a/Modules/GameOptionsSender/PlayerGameOptionsSender.cs b/Modules/GameOptionsSender/PlayerGameOptionsSender.cs index adece0901..93315e846 100644 --- a/Modules/GameOptionsSender/PlayerGameOptionsSender.cs +++ b/Modules/GameOptionsSender/PlayerGameOptionsSender.cs @@ -93,6 +93,10 @@ public override IGameOptions BuildGameOptions() opt.SetBool(BoolOptionNames.AnonymousVotes, false); break; } + if (!role.IsImpostor()) + { + AURoleOptions.NoisemakerImpostorAlert = true; + } var roleClass = player.GetRoleClass(); roleClass?.ApplyGameOptions(opt); From 88b5126eceaa55d4fe61c50c686e89d4712b94e3 Mon Sep 17 00:00:00 2001 From: yurinakira Date: Wed, 14 Aug 2024 05:18:07 +0900 Subject: [PATCH 4/8] =?UTF-8?q?20240813=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Patches/ExilePatch.cs | 8 ++++---- Patches/GameOptionsMenuPatch.cs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Patches/ExilePatch.cs b/Patches/ExilePatch.cs index e2614bc06..2eb772dfe 100644 --- a/Patches/ExilePatch.cs +++ b/Patches/ExilePatch.cs @@ -16,11 +16,11 @@ public static void Postfix(ExileController __instance) { try { - WrapUpPostfix(__instance.exiled); + WrapUpPostfix(__instance.initData.networkedPlayer); } finally { - WrapUpFinalizer(__instance.exiled); + WrapUpFinalizer(__instance.initData.networkedPlayer); } } } @@ -32,11 +32,11 @@ public static void Postfix(AirshipExileController __instance) { try { - WrapUpPostfix(__instance.exiled); + WrapUpPostfix(__instance.initData.networkedPlayer); } finally { - WrapUpFinalizer(__instance.exiled); + WrapUpFinalizer(__instance.initData.networkedPlayer); } } } diff --git a/Patches/GameOptionsMenuPatch.cs b/Patches/GameOptionsMenuPatch.cs index be86fb1e3..386305651 100644 --- a/Patches/GameOptionsMenuPatch.cs +++ b/Patches/GameOptionsMenuPatch.cs @@ -339,7 +339,7 @@ public static void Postfix() OptionItem.SyncAllOptions(); } } - [HarmonyPatch(typeof(RolesSettingsMenu), nameof(RolesSettingsMenu.Start))] + [HarmonyPatch(typeof(RolesSettingsMenu), nameof(RolesSettingsMenu.InitialSetup))] public static class RolesSettingsMenuPatch { public static void Postfix(RolesSettingsMenu __instance) From 7b1ee205fd81769facbd96878cb777a7bd0cb208 Mon Sep 17 00:00:00 2001 From: yurinakira Date: Wed, 14 Aug 2024 05:35:21 +0900 Subject: [PATCH 5/8] =?UTF-8?q?=E3=83=90=E3=83=BC=E3=82=B8=E3=83=A7?= =?UTF-8?q?=E3=83=B3=E3=82=925.1.8=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.cs b/main.cs index e7bbe660c..702c03d8c 100644 --- a/main.cs +++ b/main.cs @@ -51,7 +51,7 @@ public class Main : BasePlugin // ========== //Sorry for many Japanese comments. public const string PluginGuid = "com.emptybottle.townofhost"; - public const string PluginVersion = "5.1.7"; + public const string PluginVersion = "5.1.8"; // サポートされている最低のAmongUsバージョン public static readonly string LowestSupportedVersion = "2024.6.18"; // このバージョンのみで公開ルームを無効にする場合 From 1880523c3c896936d1065c7b903a2e0a131c8ed3 Mon Sep 17 00:00:00 2001 From: yurinakira Date: Wed, 14 Aug 2024 05:35:48 +0900 Subject: [PATCH 6/8] =?UTF-8?q?=E3=82=B5=E3=83=9D=E3=83=BC=E3=83=88?= =?UTF-8?q?=E3=81=95=E3=82=8C=E3=81=A6=E3=81=84=E3=82=8B=E6=9C=80=E4=BD=8E?= =?UTF-8?q?=E3=81=AEAmongUs=E3=83=90=E3=83=BC=E3=82=B8=E3=83=A7=E3=83=B3?= =?UTF-8?q?=E3=82=922024.8.13=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.cs b/main.cs index 702c03d8c..cf8783694 100644 --- a/main.cs +++ b/main.cs @@ -53,7 +53,7 @@ public class Main : BasePlugin public const string PluginGuid = "com.emptybottle.townofhost"; public const string PluginVersion = "5.1.8"; // サポートされている最低のAmongUsバージョン - public static readonly string LowestSupportedVersion = "2024.6.18"; + public static readonly string LowestSupportedVersion = "2024.8.13"; // このバージョンのみで公開ルームを無効にする場合 public static readonly bool IsPublicAvailableOnThisVersion = false; // プレリリースかどうか From bf516e96a07d3374df6c5592ab1a38775dbea301 Mon Sep 17 00:00:00 2001 From: yurinakira Date: Wed, 14 Aug 2024 15:13:06 +0900 Subject: [PATCH 7/8] =?UTF-8?q?README=20AmongUs=E3=83=90=E3=83=BC=E3=82=B8?= =?UTF-8?q?=E3=83=A7=E3=83=B3=E3=82=926.18=E3=81=AB=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README-EN.md | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README-EN.md b/README-EN.md index 3dff4a9da..739963a69 100644 --- a/README-EN.md +++ b/README-EN.md @@ -15,7 +15,7 @@ This mod is not affiliated with Among Us or Innersloth LLC, and the content cont ## Releases -AmongUs Version: **2024.6.18** +AmongUs Version: **2024.8.13** **Latest Version: [Here](https://github.com/tukasa0001/TownOfHost/releases/latest)** diff --git a/README.md b/README.md index 4bf706573..bdc72ca4c 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ ## リリース -AmongUsバージョン : **2024.6.18** +AmongUsバージョン : **2024.8.13** **最新版は[こちら](https://github.com/tukasa0001/TownOfHost/releases/latest)** From f9d09e0984b3c4e0bbb8d38f74efbf69043d9dc1 Mon Sep 17 00:00:00 2001 From: yurinakira Date: Wed, 14 Aug 2024 15:19:52 +0900 Subject: [PATCH 8/8] =?UTF-8?q?5.1.8=E3=81=A7=E3=83=97=E3=83=AC=E3=83=AA?= =?UTF-8?q?=E3=83=AA=E3=83=BC=E3=82=B9=E5=A4=96=E3=81=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.cs b/main.cs index e7bbe660c..edf0f2ac2 100644 --- a/main.cs +++ b/main.cs @@ -57,7 +57,7 @@ public class Main : BasePlugin // このバージョンのみで公開ルームを無効にする場合 public static readonly bool IsPublicAvailableOnThisVersion = false; // プレリリースかどうか - public static bool IsPrerelease { get; } = true; + public static bool IsPrerelease { get; } = false; public Harmony Harmony { get; } = new Harmony(PluginGuid); public static Version version = Version.Parse(PluginVersion); public static Color UnityModColor