Skip to content

Commit

Permalink
Merge pull request #1309 from tukasa0001/develop-5.1.6
Browse files Browse the repository at this point in the history
Develop 5.1.6
  • Loading branch information
Hyz-sui authored Mar 22, 2024
2 parents 24fd73d + 37d3505 commit 94cb37f
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 38 deletions.
2 changes: 1 addition & 1 deletion Modules/GameState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public bool CanUseMovingPlatform
}
public (DateTime, byte) RealKiller;
public PlainShipRoom LastRoom;
/// <summary>会議等の後に湧いた後かどうか</summary>
/// <summary>会議等の後に湧いた後かどうか<br/>ホスト以外は正しい値にならないので注意</summary>
public bool HasSpawned { get; set; } = false;
public Dictionary<byte, string> TargetColorData;
public PlayerState(byte playerId)
Expand Down
67 changes: 34 additions & 33 deletions Patches/PlayerContorolPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,22 +208,52 @@ public static bool Prefix(PlayerControl __instance, [HarmonyArgument(0)] PlayerC
__instance.RpcRejectShapeshift();
return false;
}
var shapeshifter = __instance;
var shapeshifting = shapeshifter.PlayerId != target.PlayerId;
// 変身したとき一番近い人をマッドメイトにする処理
if (shapeshifter.CanMakeMadmate() && shapeshifting)
{
var sidekickable = shapeshifter.GetRoleClass() as ISidekickable;
var targetRole = sidekickable?.SidekickTargetRole ?? CustomRoles.SKMadmate;

Vector2 shapeshifterPosition = shapeshifter.transform.position;//変身者の位置
Dictionary<PlayerControl, float> mpdistance = new();
float dis;
foreach (var p in Main.AllAlivePlayerControls)
{
if (p.Data.Role.Role != RoleTypes.Shapeshifter && !p.Is(CustomRoleTypes.Impostor) && !p.Is(targetRole))
{
dis = Vector2.Distance(shapeshifterPosition, p.transform.position);
mpdistance.Add(p, dis);
}
}
if (mpdistance.Count != 0)
{
var min = mpdistance.OrderBy(c => c.Value).FirstOrDefault();//一番値が小さい
PlayerControl targetm = min.Key;
targetm.RpcSetCustomRole(targetRole);
Logger.Info($"Make SKMadmate:{targetm.name}", "Shapeshift");
Main.SKMadmateNowCount++;
Utils.MarkEveryoneDirtySettings();
Utils.NotifyRoles();
}
}
// 役職の処理
var role = __instance.GetRoleClass();
var role = shapeshifter.GetRoleClass();
if (role?.OnCheckShapeshift(target, ref shouldAnimate) == false)
{
if (role.CanDesyncShapeshift)
{
__instance.RpcSpecificRejectShapeshift(target, shouldAnimate);
shapeshifter.RpcSpecificRejectShapeshift(target, shouldAnimate);
}
else
{
__instance.RpcRejectShapeshift();
shapeshifter.RpcRejectShapeshift();
}
return false;
}

__instance.RpcShapeshift(target, shouldAnimate);
shapeshifter.RpcShapeshift(target, shouldAnimate);
return false;
}
private static bool CheckInvalidShapeshifting(PlayerControl instance, PlayerControl target, bool animate)
Expand Down Expand Up @@ -289,35 +319,6 @@ public static void Prefix(PlayerControl __instance, [HarmonyArgument(0)] PlayerC

if (!shapeshifting) Camouflage.RpcSetSkin(__instance);

// 変身したとき一番近い人をマッドメイトにする処理
if (shapeshifter.CanMakeMadmate() && shapeshifting)
{
var sidekickable = shapeshifter.GetRoleClass() as ISidekickable;
var targetRole = sidekickable?.SidekickTargetRole ?? CustomRoles.SKMadmate;

Vector2 shapeshifterPosition = shapeshifter.transform.position;//変身者の位置
Dictionary<PlayerControl, float> mpdistance = new();
float dis;
foreach (var p in Main.AllAlivePlayerControls)
{
if (p.Data.Role.Role != RoleTypes.Shapeshifter && !p.Is(CustomRoleTypes.Impostor) && !p.Is(targetRole))
{
dis = Vector2.Distance(shapeshifterPosition, p.transform.position);
mpdistance.Add(p, dis);
}
}
if (mpdistance.Count != 0)
{
var min = mpdistance.OrderBy(c => c.Value).FirstOrDefault();//一番値が小さい
PlayerControl targetm = min.Key;
targetm.RpcSetCustomRole(targetRole);
Logger.Info($"Make SKMadmate:{targetm.name}", "Shapeshift");
Main.SKMadmateNowCount++;
Utils.MarkEveryoneDirtySettings();
Utils.NotifyRoles();
}
}

//変身解除のタイミングがずれて名前が直せなかった時のために強制書き換え
if (!shapeshifting)
{
Expand Down
5 changes: 5 additions & 0 deletions Patches/RandomSpawnPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ public class CustomNetworkTransformHandleRpcPatch
{
public static bool Prefix(CustomNetworkTransform __instance, [HarmonyArgument(0)] byte callId, [HarmonyArgument(1)] MessageReader reader)
{
if (!AmongUsClient.Instance.AmHost)
{
return true;
}

if (!__instance.isActiveAndEnabled)
{
return false;
Expand Down
1 change: 0 additions & 1 deletion README-EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,6 @@ Depending on option, they can also see kill flash when other impostor kills.<br>
- EvilTrackers can select a target after every meeting or once in a game, when marked left-triangle (◁).
- When they Shapeshift to impostor or dead player (unavailable for target), they stay able to select target.
- Shapeshift cooldown is fixed to __"5s"__ (can select target) or to __"255s"__ (cannot).
- Shapeshift duration is fixed to __"1s"__, which means EvilTrackers can hardly pretend to be someone else.
- EvilTrackers can Assign [SidekickMadmate](#sidekickmadmate) by Shapeshift.

#### Game Options
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,6 @@ GMはゲーム自体には何の影響も与えず、すべてのプレイヤー
- 「試合毎」「ターン毎」「常時」の場合は変身でターゲットを設定でき、設定可能時は左向き白三角マーク(◁)が付きます。
- 変身先がインポスターの場合は能力は消費されません。
- 変身クールダウンはターゲット設定可能時は「1秒」、不可時は「255秒」で固定です。
- 変身持続時間は「1秒」で固定されているので、変身能力自体は殆ど使えません。
- オプション次第で[サイドキックマッドメイト](#sidekickmadmateサイドキックマッドメイト)を指名できます。

#### 設定
Expand Down
4 changes: 2 additions & 2 deletions main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ public class Main : BasePlugin
// ==========
//Sorry for many Japanese comments.
public const string PluginGuid = "com.emptybottle.townofhost";
public const string PluginVersion = "5.1.5";
public const string PluginVersion = "5.1.6";
// サポートされている最低のAmongUsバージョン
public static readonly string LowestSupportedVersion = "2023.10.24";
public static readonly string LowestSupportedVersion = "2024.3.5";
// このバージョンのみで公開ルームを無効にする場合
public static readonly bool IsPublicAvailableOnThisVersion = false;
public Harmony Harmony { get; } = new Harmony(PluginGuid);
Expand Down

0 comments on commit 94cb37f

Please sign in to comment.