Skip to content

Commit

Permalink
Merge pull request #66 from Hyz-sui/H-dev
Browse files Browse the repository at this point in the history
2024.9.4.0
  • Loading branch information
Hyz-sui authored Sep 17, 2024
2 parents 464ebfc + 8e34168 commit d97b26d
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 64 deletions.
5 changes: 5 additions & 0 deletions Modules/AURoleOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
4 changes: 4 additions & 0 deletions Modules/GameOptionsSender/PlayerGameOptionsSender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions Patches/ExilePatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ public static void Postfix(ExileController __instance)
{
try
{
WrapUpPostfix(__instance.exiled);
WrapUpPostfix(__instance.initData.networkedPlayer);
}
finally
{
WrapUpFinalizer(__instance.exiled);
WrapUpFinalizer(__instance.initData.networkedPlayer);
}
}
}
Expand All @@ -33,11 +33,11 @@ public static void Postfix(AirshipExileController __instance)
{
try
{
WrapUpPostfix(__instance.exiled);
WrapUpPostfix(__instance.initData.networkedPlayer);
}
finally
{
WrapUpFinalizer(__instance.exiled);
WrapUpFinalizer(__instance.initData.networkedPlayer);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Patches/GameOptionsMenuPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
83 changes: 28 additions & 55 deletions Patches/onGameStartedPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,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);
}
//以下、バニラ側の役職割り当てが入る
}
Expand All @@ -173,7 +171,7 @@ public static void Postfix()

// 不要なオブジェクトの削除
RpcSetRoleReplacer.senders = null;
RpcSetRoleReplacer.OverriddenSenderList = null;
RpcSetRoleReplacer.DesyncImpostorList = null;
RpcSetRoleReplacer.StoragedData = null;

//Utils.ApplySuffix();
Expand Down Expand Up @@ -345,7 +343,7 @@ public static void Postfix()
Utils.SyncAllSettings();
SetColorPatch.IsAntiGlitchDisabled = false;
}
private static void AssignDesyncRole(CustomRoles role, List<PlayerControl> AllPlayers, Dictionary<byte, CustomRpcSender> senders, Dictionary<(byte, byte), RoleTypes> rolesMap, RoleTypes BaseRole, RoleTypes hostBaseRole = RoleTypes.Crewmate)
private static void AssignDesyncRole(CustomRoles role, List<PlayerControl> AllPlayers, Dictionary<byte, CustomRpcSender> senders, RoleTypes BaseRole, RoleTypes hostBaseRole = RoleTypes.Crewmate)
{
if (!role.IsPresent()) return;

Expand All @@ -358,53 +356,26 @@ private static void AssignDesyncRole(CustomRoles role, List<PlayerControl> 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<byte, CustomRpcSender> 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<PlayerControl> AssignCustomRolesFromList(CustomRoles role, List<PlayerControl> players, int RawCount = -1)
{
if (players == null || players.Count <= 0) return null;
Expand Down Expand Up @@ -480,8 +451,7 @@ class RpcSetRoleReplacer
public static bool doReplace = false;
public static Dictionary<byte, CustomRpcSender> senders;
public static List<(PlayerControl, RoleTypes)> StoragedData = new();
// 役職Desyncなど別の処理でSetRoleRpcを書き込み済みなため、追加の書き込みが不要なSenderのリスト
public static List<CustomRpcSender> OverriddenSenderList;
public static List<byte> DesyncImpostorList;
public static bool Prefix(PlayerControl __instance, [HarmonyArgument(0)] RoleTypes roleType)
{
if (doReplace && senders != null)
Expand All @@ -493,29 +463,32 @@ 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) ? RoleTypes.Scientist : role;
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;
}
public static void StartReplace(Dictionary<byte, CustomRpcSender> senders)
{
RpcSetRoleReplacer.senders = senders;
StoragedData = new();
OverriddenSenderList = new();
DesyncImpostorList = new();
doReplace = true;
}
}
Expand Down
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,22 @@
</div>
<!-- markdownlint-enable MD033 -->

<details><p><summary>English (Click)</summary></p>

**TownOfHost-H** is a fork of [Town Of Host](https://github.com/tukasa0001/TownOfHost), a host-only mod for AMONG US.
Everything is made for Japanese players and is all in Japanese.

If you don't understand Japanese and want to play AMONG US (i.e., you are not looking for resources or knowledge for software development), there is nothing here that you want. I recommend you to use [Town Of Host](https://github.com/tukasa0001/TownOfHost) or any other mod instead.

----

</details>

各機能や詳細な説明は[wiki](https://github.com/Hyz-sui/TownOfHost-H/wiki)を,フォーク元から変更されていない機能については[TownOfHostのreadme](https://github.com/tukasa0001/TownOfHost/blob/main/README.md#town-of-host)を参照してください

- 公開ルームは**永遠に**封印
- 知人以外からの質問やバグ報告等は[Issues](https://github.com/Hyz-sui/TownOfHost-H/issues/new)**のみ**受け付けています
TwitterやDiscord等では受け付けていません
製作者のSNSアカウントやDiscord等では受け付けていません
- 既存の説明を読めばわかるもの,低レベルなもの,日本語のコミュニケーションが怪しいもの,聞く相手を間違ってるもの等々には基本対応しません
- 11人2狼村(0-2イビルハッカー, 1シェリフ, 1マッド)以外の役職構成や特定の設定の組み合わせで発生するバグ等については低優先度で扱います
- 多言語対応はしていませんし,する予定もありません
Expand Down
6 changes: 3 additions & 3 deletions main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ public class Main : BasePlugin
// ==========
//Sorry for many Japanese comments.

public static readonly string ForkVersion = "2024.6.18.0";
public static readonly string ForkVersion = "2024.9.4.0";
public static readonly Version ParsedForkVersion = Version.Parse(ForkVersion);

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";
public static readonly string LowestSupportedVersion = "2024.8.13";
// このバージョンのみで公開ルームを無効にする場合
public static readonly bool IsPublicAvailableOnThisVersion = false;
// プレリリースかどうか
Expand Down

0 comments on commit d97b26d

Please sign in to comment.