Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop 5.1.5 #1308

Merged
merged 37 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
28fb41b
ロールベースにCheckShapeshiftのフックを追加
Hyz-sui Nov 5, 2023
1a74bb1
CheckShapeshiftのパッチを作成
Hyz-sui Nov 5, 2023
b6253dd
Merge branch 'develop' into feature/CheckShapeshift
kou-hetare Nov 6, 2023
6d44d07
desyncシェイプシフターの変身が弾かれないためのチェックを追加
Hyz-sui Nov 7, 2023
a1de5c2
イビルトラッカーの変身をキャンセル
kou-hetare Nov 21, 2023
0b09dbb
Merge branch 'feature/CheckShapeshift' of https://github.com/tukasa00…
kou-hetare Dec 5, 2023
4df5b41
自視点のみシェイプシフトの機能を追加
kou-hetare Dec 6, 2023
5ab0202
CanDesyncShapeshiftのvirtual指定漏れ
kou-hetare Dec 7, 2023
bcfc282
OnCheckShapeshiftでanimateを操作できるよう変更
kou-hetare Dec 9, 2023
81e53e9
役職用RPCをCustomRoleSyncに一本化
kou-hetare Jan 13, 2024
a90cd4f
ModによるSnapToRPCを,ラグを考慮し十分にシーケンスIDを大きくして飛ばすよう変更
Hyz-sui Jan 15, 2024
b61fe51
PlayerStateにHasSpawnedプロパティを追加
Hyz-sui Jan 16, 2024
8788455
会議開始時に湧いてない状態にする処理と,エアシップ以外での湧き処理を追加
Hyz-sui Jan 16, 2024
b2836ef
エアシップのスポーン判定をリワーク
Hyz-sui Jan 16, 2024
c89be2c
古いコードを削除
Hyz-sui Jan 16, 2024
7921d36
RpcSnapToForced内のコールIDのマジックナンバーを解消
Hyz-sui Jan 16, 2024
3af2501
RoleTypes.Engineer can use vent
Tommy-XL Jan 18, 2024
1506ee6
Use pc.Role.CanUse()
Tommy-XL Jan 23, 2024
bbd5a0f
Merge pull request #1306 from Tommy-XL/BugFix/RolesBasedEngineerCanBe…
Hyz-sui Jan 24, 2024
77ea56e
Merge pull request #458 from tukasa0001/fetch/1306
Hyz-sui Jan 28, 2024
966e632
Merge pull request #456 from tukasa0001/feature/RoleRpcIntegration
kou-hetare Jan 28, 2024
a7179d3
起動時にユーザ環境変数に現在のディレクトリを設定する機能を追加
Hyz-sui Feb 1, 2024
c770dc8
Merge pull request #459 from tukasa0001/feature/SetTOHDirToEnvVar
Hyz-sui Feb 2, 2024
b852636
Merge pull request #451 from tukasa0001/feature/CheckShapeshift
kou-hetare Feb 3, 2024
d42a765
会議後にWarlock.IsCursedがリセットされていない問題を修正
schwKatz Feb 2, 2024
00d5dd6
Merge branch 'develop' into fix/RandomSpawnTeleport
Hyz-sui Mar 2, 2024
0082fc3
Merge pull request #457 from tukasa0001/fix/RandomSpawnTeleport
Hyz-sui Mar 5, 2024
cebf583
バニラアプデによるビルドエラーを解消
Hyz-sui Mar 5, 2024
c263375
バージョンを5.1.5に変更
yurinakira Mar 6, 2024
da7a3ef
update readme AmongUsVersion
yurinakira Mar 6, 2024
5ed5617
Merge pull request #461 from tukasa0001/fix/UpdateFor202435
Hyz-sui Mar 6, 2024
efb1791
Merge pull request #462 from tukasa0001/verUp/5.1.5
yurinakira Mar 6, 2024
eb22d38
Merge pull request #463 from tukasa0001/doc/ReadMe5.1.5
yurinakira Mar 6, 2024
75ef8d3
Merge pull request #460 from tukasa0001/fetch/1307
Hyz-sui Mar 6, 2024
af2b593
Crowdinの翻訳をインポート
tanakanira0118 Mar 6, 2024
3519b4d
消された翻訳を追加
yurinakira Mar 6, 2024
8883be1
Merge pull request #464 from tukasa0001/crowdin-import-20240306
Hyz-sui Mar 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 40 additions & 2 deletions Modules/ExtendedPlayerControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,35 @@ public static void RpcResetAbilityCooldown(this PlayerControl target)
ホストのクールダウンは直接リセットします。
*/
}
public static void RpcSpecificShapeshift(this PlayerControl player, PlayerControl target, bool shouldAnimate)
{
if (!AmongUsClient.Instance.AmHost) return;
if (player.PlayerId == 0)
{
player.Shapeshift(target, shouldAnimate);
return;
}
MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(player.NetId, (byte)RpcCalls.Shapeshift, SendOption.Reliable, player.GetClientId());
messageWriter.WriteNetObject(target);
messageWriter.Write(shouldAnimate);
AmongUsClient.Instance.FinishRpcImmediately(messageWriter);
}
public static void RpcSpecificRejectShapeshift(this PlayerControl player, PlayerControl target, bool shouldAnimate)
{
if (!AmongUsClient.Instance.AmHost) return;
foreach (var seer in Main.AllPlayerControls)
{
if (seer != player)
{
MessageWriter msg = AmongUsClient.Instance.StartRpcImmediately(player.NetId, (byte)RpcCalls.RejectShapeshift, SendOption.Reliable, seer.GetClientId());
AmongUsClient.Instance.FinishRpcImmediately(msg);
}
else
{
player.RpcSpecificShapeshift(target, shouldAnimate);
}
}
}
public static void RpcDesyncUpdateSystem(this PlayerControl target, SystemTypes systemType, int amount)
{
MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(ShipStatus.Instance.NetId, (byte)RpcCalls.UpdateSystem, SendOption.Reliable, target.GetClientId());
Expand Down Expand Up @@ -570,9 +599,18 @@ public static PlainShipRoom GetPlainShipRoom(this PlayerControl pc)
}
return null;
}
public static void RpcSnapTo(this PlayerControl pc, Vector2 position)
public static void RpcSnapToForced(this PlayerControl pc, Vector2 position)
{
pc.NetTransform.RpcSnapTo(position);
var netTransform = pc.NetTransform;
if (AmongUsClient.Instance.AmClient)
{
netTransform.SnapTo(position, (ushort)(netTransform.lastSequenceId + 128));
}
ushort newSid = (ushort)(netTransform.lastSequenceId + 2);
MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(netTransform.NetId, (byte)RpcCalls.SnapTo, SendOption.Reliable);
NetHelpers.WriteVector2(position, messageWriter);
messageWriter.Write(newSid);
AmongUsClient.Instance.FinishRpcImmediately(messageWriter);
}
public static void RpcSnapToDesync(this PlayerControl pc, PlayerControl target, Vector2 position)
{
Expand Down
2 changes: 2 additions & 0 deletions Modules/GameState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public bool CanUseMovingPlatform
}
public (DateTime, byte) RealKiller;
public PlainShipRoom LastRoom;
/// <summary>会議等の後に湧いた後かどうか</summary>
public bool HasSpawned { get; set; } = false;
public Dictionary<byte, string> TargetColorData;
public PlayerState(byte playerId)
{
Expand Down
3 changes: 2 additions & 1 deletion Modules/OptionSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ public static string GenerateModOptionsString()
/// <returns>生成された文字列</returns>
public static string GenerateVanillaOptionsString()
{
byte[] bytes = GameOptionsManager.Instance.gameOptionsFactory.ToBytes(GameOptionsManager.Instance.CurrentGameOptions);
// 保存時はエイプリルフール無効
byte[] bytes = GameOptionsManager.Instance.gameOptionsFactory.ToBytes(GameOptionsManager.Instance.CurrentGameOptions, false);
return Convert.ToBase64String(bytes);
}
/// <summary>
Expand Down
20 changes: 3 additions & 17 deletions Modules/RPC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,10 @@ public enum CustomRPC
EndGame,
PlaySound,
SetCustomRole,
SetBountyTarget,
WitchSync,
SetSheriffShotLimit,
SetDousedPlayer,
SetNameColorData,
SniperSync,
SetLoversPlayers,
SetExecutionerTarget,
SetCurrentDousingTarget,
SetEvilTrackerTarget,
SetRealKiller,
SyncPuppet,
SetSchrodingerCatTeam,
StealthDarken,
EvilHackerCreateMurderNotify,
PenguinSync,
MareSync,
SyncPlagueDoctor,
CustomRoleSync,
}
public enum Sounds
{
Expand Down Expand Up @@ -153,8 +139,8 @@ public static void Postfix(PlayerControl __instance, [HarmonyArgument(0)] byte c
byte killerId = reader.ReadByte();
RPC.SetRealKiller(targetId, killerId);
break;
default:
CustomRoleManager.DispatchRpc(reader, rpcType);
case CustomRPC.CustomRoleSync:
CustomRoleManager.DispatchRpc(reader);
break;
}
}
Expand Down
12 changes: 12 additions & 0 deletions Modules/SystemEnvironment.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;

namespace TownOfHost.Modules;

public static class SystemEnvironment
{
public static void SetEnvironmentVariables()
{
// ユーザ環境変数に最近開かれたTOHアモアスフォルダのパスを設定
Environment.SetEnvironmentVariable("TOWN_OF_HOST_DIR_ROOT", Environment.CurrentDirectory, EnvironmentVariableTarget.User);
}
}
1 change: 0 additions & 1 deletion Patches/AirshipStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ public static bool Prefix()
{
if (PlayerControl.LocalPlayer.Is(CustomRoles.GM))
{
RandomSpawn.hostReady = true;
RandomSpawn.AirshipSpawn(PlayerControl.LocalPlayer);
// GMは湧き画面をスキップ
return false;
Expand Down
12 changes: 11 additions & 1 deletion Patches/ExilePatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ static void WrapUpPostfix(GameData.PlayerInfo exiled)
exiled = AntiBlackout_LastExiled;
}

var mapId = Main.NormalOptions.MapId;
// エアシップではまだ湧かない
if ((MapNames)mapId != MapNames.Airship)
{
foreach (var state in PlayerState.AllPlayerStates.Values)
{
state.HasSpawned = true;
}
}

bool DecidedWinner = false;
if (!AmongUsClient.Instance.AmHost) return; //ホスト以外はこれ以降の処理を実行しません
AntiBlackout.RestoreIsDead(doSend: false);
Expand Down Expand Up @@ -76,7 +86,7 @@ static void WrapUpPostfix(GameData.PlayerInfo exiled)
if (RandomSpawn.IsRandomSpawn())
{
RandomSpawn.SpawnMap map;
switch (Main.NormalOptions.MapId)
switch (mapId)
{
case 0:
map = new RandomSpawn.SkeldSpawnMap();
Expand Down
4 changes: 2 additions & 2 deletions Patches/GameStartManagerPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public static bool Prefix(GameStartManager __instance)
Main.LastShapeshifterCooldown.Value = AURoleOptions.ShapeshifterCooldown;
AURoleOptions.ShapeshifterCooldown = 0f;

PlayerControl.LocalPlayer.RpcSyncSettings(GameOptionsManager.Instance.gameOptionsFactory.ToBytes(opt));
PlayerControl.LocalPlayer.RpcSyncSettings(GameOptionsManager.Instance.gameOptionsFactory.ToBytes(opt, AprilFoolsMode.IsAprilFoolsModeToggledOn));

__instance.ReallyBegin(false);
return false;
Expand Down Expand Up @@ -250,7 +250,7 @@ public static void Prefix()
if (GameStates.IsCountDown)
{
Main.NormalOptions.KillCooldown = Options.DefaultKillCooldown;
PlayerControl.LocalPlayer.RpcSyncSettings(GameOptionsManager.Instance.gameOptionsFactory.ToBytes(GameOptionsManager.Instance.CurrentGameOptions));
PlayerControl.LocalPlayer.RpcSyncSettings(GameOptionsManager.Instance.gameOptionsFactory.ToBytes(GameOptionsManager.Instance.CurrentGameOptions, AprilFoolsMode.IsAprilFoolsModeToggledOn));
}
}
}
Expand Down
16 changes: 14 additions & 2 deletions Patches/IntroPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,22 @@ class IntroCutsceneDestroyPatch
public static void Postfix(IntroCutscene __instance)
{
if (!GameStates.IsInGame) return;

Main.introDestroyed = true;

var mapId = Main.NormalOptions.MapId;
// エアシップではまだ湧かない
if ((MapNames)mapId != MapNames.Airship)
{
foreach (var state in PlayerState.AllPlayerStates.Values)
{
state.HasSpawned = true;
}
}

if (AmongUsClient.Instance.AmHost)
{
if (Main.NormalOptions.MapId != 4)
if (mapId != 4)
{
Main.AllPlayerControls.Do(pc => pc.RpcResetAbilityCooldown());
if (Options.FixFirstKillCooldown.GetBool())
Expand All @@ -244,7 +256,7 @@ public static void Postfix(IntroCutscene __instance)
if (RandomSpawn.IsRandomSpawn())
{
RandomSpawn.SpawnMap map;
switch (Main.NormalOptions.MapId)
switch (mapId)
{
case 0:
map = new RandomSpawn.SkeldSpawnMap();
Expand Down
2 changes: 0 additions & 2 deletions Patches/MeetingHudPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,6 @@ public static void Postfix()
if (AmongUsClient.Instance.AmHost)
{
AntiBlackout.SetIsDead();
Main.AllPlayerControls.Do(pc => RandomSpawn.FirstTP[pc.PlayerId] = true);
RandomSpawn.FastSpawnPosition.Clear();
}
// MeetingVoteManagerを通さずに会議が終了した場合の後処理
MeetingVoteManager.Instance?.Destroy();
Expand Down
74 changes: 74 additions & 0 deletions Patches/PlayerContorolPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,80 @@ public static void Postfix(PlayerControl __instance, [HarmonyArgument(0)] Player
CustomRoleManager.OnMurderPlayer(__instance, target);
}
}
[HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.CheckShapeshift))]
public static class PlayerControlCheckShapeshiftPatch
{
private static readonly LogHandler logger = Logger.Handler(nameof(PlayerControl.CheckShapeshift));

public static bool Prefix(PlayerControl __instance, [HarmonyArgument(0)] PlayerControl target, [HarmonyArgument(1)] bool shouldAnimate)
{
if (AmongUsClient.Instance.IsGameOver || !AmongUsClient.Instance.AmHost)
{
return false;
}

// 無効な変身を弾く.これより前に役職等の処理をしてはいけない
if (!CheckInvalidShapeshifting(__instance, target, shouldAnimate))
{
__instance.RpcRejectShapeshift();
return false;
}
// 役職の処理
var role = __instance.GetRoleClass();
if (role?.OnCheckShapeshift(target, ref shouldAnimate) == false)
{
if (role.CanDesyncShapeshift)
{
__instance.RpcSpecificRejectShapeshift(target, shouldAnimate);
}
else
{
__instance.RpcRejectShapeshift();
}
return false;
}

__instance.RpcShapeshift(target, shouldAnimate);
return false;
}
private static bool CheckInvalidShapeshifting(PlayerControl instance, PlayerControl target, bool animate)
{
logger.Info($"Checking shapeshift {instance.GetNameWithRole()} -> {(target == null || target.Data == null ? "(null)" : target.GetNameWithRole())}");

if (!target || target.Data == null)
{
logger.Info("targetがnullのため変身をキャンセルします");
return false;
}
if (!instance.IsAlive())
{
logger.Info("変身者が死亡しているため変身をキャンセルします");
return false;
}
// RoleInfoによるdesyncシェイプシフター用の判定を追加
if (instance.Data.Role.Role != RoleTypes.Shapeshifter && instance.GetCustomRole().GetRoleInfo()?.BaseRoleType?.Invoke() != RoleTypes.Shapeshifter)
{
logger.Info("変身者がシェイプシフターではないため変身をキャンセルします");
return false;
}
if (instance.Data.Disconnected)
{
logger.Info("変身者が切断済のため変身をキャンセルします");
return false;
}
if (target.IsMushroomMixupActive() && animate)
{
logger.Info("キノコカオス中のため変身をキャンセルします");
return false;
}
if (MeetingHud.Instance && animate)
{
logger.Info("会議中のため変身をキャンセルします");
return false;
}
return true;
}
}
[HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.Shapeshift))]
class ShapeshiftPatch
{
Expand Down
Loading