mirror of
https://github.com/Gurge44/EndlessHostRoles.git
synced 2026-10-20 01:46:25 +00:00
Fix ShapeshiftPatch - Force Name (#539)
This commit is contained in:
1 parent
ffbe33381e
commit
655ce121bc
4 files changed
+20
-9
No files matched your search
@@ -111,6 +111,7 @@ public class Main : BasePlugin
|
||||
public static bool HasJustStarted;
|
||||
public static Dictionary<byte, bool> CheckShapeshift = [];
|
||||
public static Dictionary<byte, byte> ShapeshiftTarget = [];
|
||||
public static Dictionary<byte, bool> ShapeshiftIsAnimated = [];
|
||||
public static bool VisibleTasksCount;
|
||||
public static string NickName = "";
|
||||
public static bool IntroDestroyed = true;
|
||||
|
||||
@@ -3815,6 +3815,7 @@ public static class Utils
|
||||
TaskMaster.AfterMeetingTasks(pc);
|
||||
|
||||
Main.CheckShapeshift[pc.PlayerId] = false;
|
||||
Main.ShapeshiftIsAnimated[pc.PlayerId] = false;
|
||||
}
|
||||
catch (Exception e) { ThrowException(e); }
|
||||
}
|
||||
|
||||
@@ -210,6 +210,7 @@ internal static class ChangeRoleSettings
|
||||
Main.ClientIdList = [];
|
||||
Main.CheckShapeshift = [];
|
||||
Main.ShapeshiftTarget = [];
|
||||
Main.ShapeshiftIsAnimated = [];
|
||||
Main.LoversPlayers = [];
|
||||
Main.DiedThisRound = [];
|
||||
Main.GuesserGuessed = [];
|
||||
|
||||
@@ -942,16 +942,16 @@ internal static class ShapeshiftPatch
|
||||
{
|
||||
if (!Main.ProcessShapeshifts || !GameStates.IsInTask || !__instance || !target) return;
|
||||
|
||||
if (shouldAnimate)
|
||||
if (AmongUsClient.Instance.AmHost && shouldAnimate)
|
||||
{
|
||||
LateTask.New(() =>
|
||||
{
|
||||
if (AmongUsClient.Instance.AmHost)
|
||||
{
|
||||
__instance.RpcSetName(Main.AllPlayerNames[target.PlayerId]);
|
||||
NotifyRoles(SpecifyTarget: __instance, NoCache: true);
|
||||
}
|
||||
}, 1.2f, "PlayerControl.Shapeshift Prefix Patch - Force Name");
|
||||
if (!__instance || !target) return;
|
||||
if (ReportDeadBodyPatch.MeetingStarted || GameStates.IsMeeting) return;
|
||||
|
||||
__instance.RpcSetName(Main.AllPlayerNames[target.PlayerId]);
|
||||
NotifyRoles(SpecifyTarget: __instance, NoCache: true);
|
||||
}, 1.2f, "ShapeshiftPatch - Force Name");
|
||||
}
|
||||
|
||||
bool shapeshifting = __instance.PlayerId != target.PlayerId;
|
||||
@@ -978,10 +978,11 @@ internal static class ShapeshiftPatch
|
||||
[HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.RpcShapeshift))]
|
||||
internal static class RpcShapeshiftPatch
|
||||
{
|
||||
public static void Postfix(PlayerControl __instance, [HarmonyArgument(0)] PlayerControl target)
|
||||
public static void Postfix(PlayerControl __instance, [HarmonyArgument(0)] PlayerControl target, [HarmonyArgument(1)] bool shouldAnimate)
|
||||
{
|
||||
Main.CheckShapeshift[__instance.PlayerId] = __instance.PlayerId != target.PlayerId;
|
||||
|
||||
Main.ShapeshiftIsAnimated[__instance.PlayerId] = shouldAnimate;
|
||||
|
||||
if (__instance.Is(CustomRoles.Morphling) && __instance.IsNonHostModdedClient())
|
||||
SendRPC(CustomRPC.SyncRoleData, __instance.PlayerId, __instance.PlayerId, Main.CheckShapeshift[__instance.PlayerId]);
|
||||
}
|
||||
@@ -1359,6 +1360,13 @@ internal static class ReportDeadBodyPatch
|
||||
if (Main.Invisible.Contains(pc.PlayerId))
|
||||
LateTask.New(() => pc.RpcMakeVisible(), 1f, log: false);
|
||||
|
||||
// Fix name when LateTask "Shapeshift Patch - Force Name" was not revert name back before meeting started
|
||||
if (pc.IsShifted() && Main.ShapeshiftIsAnimated.GetValueOrDefault(pc.PlayerId))
|
||||
{
|
||||
Logger.Info($"Revert name back for shifted player: {player.GetNameWithRole().RemoveHtmlTags()}", "ReportDeadBody");
|
||||
pc.RpcSetName(Main.AllPlayerNames[pc.PlayerId]);
|
||||
}
|
||||
|
||||
// PhantomRolePatch.OnReportDeadBody(pc);
|
||||
}
|
||||
catch (Exception e) { ThrowException(e); }
|
||||
|
||||
Reference in new issue
Block a user