use SendOption.None

This commit is contained in:
Gurge44 committed 2025-02-06 18:28:52 +01:00
1 parent 4cdfdf8d1c
commit 6c10127122
84 files changed
+334 -329

No files matched your search

+1 -1
View File
@@ -7,7 +7,7 @@
<Description>EHR</Description>
<Authors>Gurge44</Authors>
<langVersion>preview</langVersion>
<AmongUs>C:\Program Files\Epic Games\AmongUs</AmongUs>
<AmongUs>D:\AmongUs</AmongUs>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Optimize>True</Optimize>
<AssemblyName>$(MSBuildProjectName)</AssemblyName>
+2 -2
View File
@@ -129,7 +129,7 @@ namespace EHR
LateTask.New(() =>
{
var sender = CustomRpcSender.Create("FixModdedClientCNOText", SendOption.Reliable);
var sender = CustomRpcSender.Create("FixModdedClientCNOText", HazelExtensions.SendOption);
sender.AutoStartRpc(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.FixModdedClientCNO, player.GetClientId())
.WriteNetObject(playerControl)
@@ -300,7 +300,7 @@ namespace EHR
// Fix for Non-Host Modded
foreach (PlayerControl visiblePC in Main.AllPlayerControls.ExceptBy(HiddenList, x => x.PlayerId))
{
var sender = CustomRpcSender.Create("FixModdedClientCNOText", SendOption.Reliable);
var sender = CustomRpcSender.Create("FixModdedClientCNOText", HazelExtensions.SendOption);
sender.AutoStartRpc(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.FixModdedClientCNO, visiblePC.GetClientId())
.WriteNetObject(playerControl)
+2 -2
View File
@@ -22,7 +22,7 @@ public static class CustomSoundsManager
return;
}
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.PlayCustomSound, SendOption.Reliable, pc.GetClientId());
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.PlayCustomSound, HazelExtensions.SendOption, pc.GetClientId());
writer.Write(sound);
AmongUsClient.Instance.FinishRpcImmediately(writer);
}
@@ -31,7 +31,7 @@ public static class CustomSoundsManager
{
if (!AmongUsClient.Instance.AmHost) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.PlayCustomSound, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.PlayCustomSound, HazelExtensions.SendOption);
writer.Write(sound);
AmongUsClient.Instance.FinishRpcImmediately(writer);
Play(sound);
+46 -2
View File
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using AmongUs.GameOptions;
using AmongUs.QuickChat;
using HarmonyLib;
using Hazel;
using InnerNet;
@@ -114,6 +115,49 @@ internal static class EAC
}
}
break;
case RpcCalls.SendQuickChat:
QuickChatPhraseType quickChatPhraseType = (QuickChatPhraseType)sr.ReadByte();
switch (quickChatPhraseType)
{
case QuickChatPhraseType.Empty:
HandleCheat(pc, "Empty message in quick chat");
return true;
case QuickChatPhraseType.PlayerId:
{
byte playerID = sr.ReadByte();
if (playerID == 255)
{
HandleCheat(pc, "Sending invalid player in quick chat");
return true;
}
if (GameStates.InGame && GameData.Instance.GetPlayerById(playerID) == null)
{
HandleCheat(pc, "Sending non existing player in quick chat");
return true;
}
break;
}
}
if (quickChatPhraseType != QuickChatPhraseType.ComplexPhrase) break;
sr.ReadUInt16();
int num = sr.ReadByte();
switch (num)
{
case 0:
HandleCheat(pc, "Complex phrase without arguments");
return true;
case > 3:
HandleCheat(pc, "Trying to crash or lag other players");
return true;
}
break;
case RpcCalls.CheckColor when !pc.IsHost():
if (!GameStates.IsLobby)
@@ -170,7 +214,7 @@ internal static class EAC
case RpcCalls.Shapeshift when !pc.IsHost():
{
Report(pc, "Directly Shapeshift");
MessageWriter swriter = AmongUsClient.Instance.StartRpcImmediately(pc.NetId, (byte)RpcCalls.Shapeshift, SendOption.Reliable);
MessageWriter swriter = AmongUsClient.Instance.StartRpcImmediately(pc.NetId, (byte)RpcCalls.Shapeshift, HazelExtensions.SendOption);
swriter.WriteNetObject(pc);
swriter.Write(false);
AmongUsClient.Instance.FinishRpcImmediately(swriter);
@@ -183,7 +227,7 @@ internal static class EAC
{
string sreason = "Direct Phantom RPCs " + rpc;
Report(pc, sreason);
MessageWriter swriter = AmongUsClient.Instance.StartRpcImmediately(pc.NetId, (byte)RpcCalls.StartAppear, SendOption.Reliable);
MessageWriter swriter = AmongUsClient.Instance.StartRpcImmediately(pc.NetId, (byte)RpcCalls.StartAppear, HazelExtensions.SendOption);
swriter.Write(false);
AmongUsClient.Instance.FinishRpcImmediately(swriter);
HandleCheat(pc, sreason);
+71 -65
View File
@@ -43,7 +43,7 @@ internal static class ExtendedPlayerControl
if (AmongUsClient.Instance.AmHost)
{
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetCustomRole, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetCustomRole, HazelExtensions.SendOption);
writer.Write(player.PlayerId);
writer.WritePacked((int)role);
writer.Write(replaceAllAddons);
@@ -55,7 +55,7 @@ internal static class ExtendedPlayerControl
{
if (AmongUsClient.Instance.AmHost)
{
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetCustomRole, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetCustomRole, HazelExtensions.SendOption);
writer.Write(PlayerId);
writer.WritePacked((int)role);
AmongUsClient.Instance.FinishRpcImmediately(writer);
@@ -100,59 +100,57 @@ internal static class ExtendedPlayerControl
public static void RpcSetVentInteraction(this PlayerControl player)
{
VentilationSystemDeterioratePatch.SerializeV2(ShipStatus.Instance.Systems[SystemTypes.Ventilation].CastFast<VentilationSystem>(), player);
var ventilationSystem = ShipStatus.Instance.Systems[SystemTypes.Ventilation].TryCast<VentilationSystem>();
if (ventilationSystem != null) VentilationSystemDeterioratePatch.SerializeV2(ventilationSystem, player);
}
public static void SetChatVisible(this PlayerControl player) // Credit: NikoCat233
// From: https://github.com/Rabek009/MoreGamemodes/blob/master/Modules/ExtendedPlayerControl.cs
public static void SetChatVisible(this PlayerControl player, bool visible)
{
if (!GameStates.IsInGame || !AmongUsClient.Instance.AmHost || GameStates.IsMeeting) return;
if (player.IsHost())
if (player.AmOwner)
{
HudManager.Instance.Chat.SetVisible(true);
HudManager.Instance.Chat.SetVisible(visible);
HudManager.Instance.Chat.HideBanButton();
return;
}
if (player.IsModClient())
{
MessageWriter modsend = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ShowChat, SendOption.Reliable, player.OwnerId);
modsend.WritePacked(player.OwnerId);
modsend.Write(true);
AmongUsClient.Instance.FinishRpcImmediately(modsend);
return;
}
uint customNetId = AmongUsClient.Instance.NetIdCnt++;
MessageWriter vanillasend = MessageWriter.Get(SendOption.Reliable);
vanillasend.StartMessage(6);
vanillasend.Write(AmongUsClient.Instance.GameId);
vanillasend.Write(player.OwnerId);
vanillasend.StartMessage((byte)GameDataTag.SpawnFlag);
vanillasend.WritePacked(1); // 1 Meeting Hud Spawn id
vanillasend.WritePacked(-2); // Owned by host
vanillasend.Write((byte)SpawnFlags.None);
vanillasend.WritePacked(1);
vanillasend.WritePacked(customNetId);
vanillasend.StartMessage(1);
vanillasend.WritePacked(0);
vanillasend.EndMessage();
vanillasend.EndMessage();
vanillasend.EndMessage();
vanillasend.StartMessage(6);
vanillasend.Write(AmongUsClient.Instance.GameId);
vanillasend.Write(player.OwnerId);
vanillasend.StartMessage((byte)GameDataTag.RpcFlag);
vanillasend.WritePacked(customNetId);
vanillasend.Write((byte)RpcCalls.CloseMeeting);
vanillasend.EndMessage();
vanillasend.EndMessage();
AmongUsClient.Instance.SendOrDisconnect(vanillasend);
vanillasend.Recycle();
bool isDead = player.Data.IsDead;
MessageWriter writer = MessageWriter.Get();
writer.StartMessage(6);
writer.Write(AmongUsClient.Instance.GameId);
writer.WritePacked(player.GetClientId());
writer.StartMessage(4);
writer.WritePacked(HudManager.Instance.MeetingPrefab.SpawnId);
writer.WritePacked(-2);
writer.Write((byte)SpawnFlags.None);
writer.WritePacked(1);
uint netIdCnt = AmongUsClient.Instance.NetIdCnt;
AmongUsClient.Instance.NetIdCnt = netIdCnt + 1U;
writer.WritePacked(netIdCnt);
writer.StartMessage(1);
writer.WritePacked(0);
writer.EndMessage();
writer.EndMessage();
player.Data.IsDead = visible;
writer.StartMessage(1);
writer.WritePacked(player.Data.NetId);
player.Data.Serialize(writer, true);
writer.EndMessage();
writer.StartMessage(2);
writer.WritePacked(netIdCnt);
writer.Write((byte)RpcCalls.CloseMeeting);
writer.EndMessage();
player.Data.IsDead = isDead;
writer.StartMessage(1);
writer.WritePacked(player.Data.NetId);
player.Data.Serialize(writer, true);
writer.EndMessage();
writer.StartMessage(5);
writer.WritePacked(netIdCnt);
writer.EndMessage();
writer.EndMessage();
AmongUsClient.Instance.SendOrDisconnect(writer);
writer.Recycle();
}
public static void RpcExile(this PlayerControl player)
@@ -266,7 +264,7 @@ internal static class ExtendedPlayerControl
int clientId = seer.GetClientId();
if (clientId == -1) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(player.NetId, (byte)RpcCalls.SetName, SendOption.Reliable, clientId);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(player.NetId, (byte)RpcCalls.SetName, HazelExtensions.SendOption, clientId);
writer.Write(seer.Data.NetId);
writer.Write(name);
AmongUsClient.Instance.FinishRpcImmediately(writer);
@@ -285,12 +283,20 @@ internal static class ExtendedPlayerControl
}
player.Data.DefaultOutfit.PetSequenceId += 10;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(player.NetId, (byte)RpcCalls.SetPetStr, SendOption.Reliable, clientId);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(player.NetId, (byte)RpcCalls.SetPetStr, HazelExtensions.SendOption, clientId);
writer.Write(petId);
writer.Write(player.GetNextRpcSequenceId(RpcCalls.SetPetStr));
AmongUsClient.Instance.FinishRpcImmediately(writer);
}
public static void RpcResetTasks(this PlayerControl player)
{
if (!AmongUsClient.Instance.AmHost || !GameStates.IsInGame || player == null) return;
player.Data.RpcSetTasks(new Il2CppStructArray<byte>(0));
Main.PlayerStates[player.PlayerId].InitTask(player);
}
public static void RpcSetRoleDesync(this PlayerControl player, RoleTypes role, int clientId)
{
if (player == null) return;
@@ -541,7 +547,7 @@ internal static class ExtendedPlayerControl
{
if (!AmongUsClient.Instance.AmHost || !GameStates.IsInGame) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncGeneralOptions, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncGeneralOptions, HazelExtensions.SendOption);
writer.Write(player.PlayerId);
writer.WritePacked((int)player.GetCustomRole());
writer.Write(Main.PlayerStates[player.PlayerId].IsDead);
@@ -580,7 +586,7 @@ internal static class ExtendedPlayerControl
return;
}
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(physics.NetId, (byte)RpcCalls.EnterVent, SendOption.Reliable, seer.GetClientId());
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(physics.NetId, (byte)RpcCalls.EnterVent, HazelExtensions.SendOption, seer.GetClientId());
writer.WritePacked(ventId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
}
@@ -598,7 +604,7 @@ internal static class ExtendedPlayerControl
return;
}
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(physics.NetId, (byte)RpcCalls.ExitVent, SendOption.Reliable, seer.GetClientId());
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(physics.NetId, (byte)RpcCalls.ExitVent, HazelExtensions.SendOption, seer.GetClientId());
writer.WritePacked(ventId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
}
@@ -615,7 +621,7 @@ internal static class ExtendedPlayerControl
return;
}
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(physics.NetId, (byte)RpcCalls.BootFromVent, SendOption.Reliable, seer.GetClientId());
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(physics.NetId, (byte)RpcCalls.BootFromVent, HazelExtensions.SendOption, seer.GetClientId());
writer.WritePacked(ventId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
}
@@ -712,7 +718,7 @@ internal static class ExtendedPlayerControl
}
else if (player.IsModClient())
{
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.KillFlash, SendOption.Reliable, player.GetClientId());
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.KillFlash, HazelExtensions.SendOption, player.GetClientId());
AmongUsClient.Instance.FinishRpcImmediately(writer);
}
else if (!ReactorCheck) player.ReactorFlash(); // Reactor flash
@@ -749,7 +755,7 @@ internal static class ExtendedPlayerControl
// Other Clients
if (!killer.IsHost())
{
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(killer.NetId, (byte)RpcCalls.MurderPlayer, SendOption.Reliable, killer.GetClientId());
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(killer.NetId, (byte)RpcCalls.MurderPlayer, HazelExtensions.SendOption, killer.GetClientId());
writer.WriteNetObject(target);
writer.Write((int)MurderResultFlags.FailedProtected);
AmongUsClient.Instance.FinishRpcImmediately(writer);
@@ -849,7 +855,7 @@ internal static class ExtendedPlayerControl
if (AmongUsClient.Instance.AmHost && playerId.IsPlayerModClient() && !playerId.IsHost() && rpc)
{
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncAbilityUseLimit, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncAbilityUseLimit, HazelExtensions.SendOption);
writer.Write(playerId);
writer.Write(limit);
AmongUsClient.Instance.FinishRpcImmediately(writer);
@@ -937,7 +943,7 @@ internal static class ExtendedPlayerControl
PlayerControl.LocalPlayer.SetKillTimer(time);
else
{
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetKillTimer, SendOption.Reliable, player.GetClientId());
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetKillTimer, HazelExtensions.SendOption, player.GetClientId());
writer.Write(time);
AmongUsClient.Instance.FinishRpcImmediately(writer);
}
@@ -956,7 +962,7 @@ internal static class ExtendedPlayerControl
killer.MurderPlayer(target, ResultFlags);
else
{
MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(killer.NetId, (byte)RpcCalls.MurderPlayer, SendOption.Reliable, killer.GetClientId());
MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(killer.NetId, (byte)RpcCalls.MurderPlayer, HazelExtensions.SendOption, killer.GetClientId());
messageWriter.WriteNetObject(target);
messageWriter.Write((byte)ResultFlags);
AmongUsClient.Instance.FinishRpcImmediately(messageWriter);
@@ -999,7 +1005,7 @@ internal static class ExtendedPlayerControl
public static void RpcDesyncRepairSystem(this PlayerControl target, SystemTypes systemType, int amount)
{
MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(ShipStatus.Instance.NetId, (byte)RpcCalls.UpdateSystem, SendOption.Reliable, target.GetClientId());
MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(ShipStatus.Instance.NetId, (byte)RpcCalls.UpdateSystem, HazelExtensions.SendOption, target.GetClientId());
messageWriter.Write((byte)systemType);
messageWriter.WriteNetObject(target);
messageWriter.Write((byte)amount);
@@ -1190,7 +1196,7 @@ internal static class ExtendedPlayerControl
return;
}
MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(target.NetId, (byte)RpcCalls.SetScanner, SendOption.Reliable, seerClientId);
MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(target.NetId, (byte)RpcCalls.SetScanner, HazelExtensions.SendOption, seerClientId);
messageWriter.Write(on);
messageWriter.Write(cnt);
AmongUsClient.Instance.FinishRpcImmediately(messageWriter);
@@ -1342,7 +1348,7 @@ internal static class ExtendedPlayerControl
public static void RpcSetDousedPlayer(this PlayerControl player, PlayerControl target, bool isDoused)
{
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetDousedPlayer, SendOption.Reliable); //RPCによる同期
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetDousedPlayer, HazelExtensions.SendOption); //RPCによる同期
writer.Write(player.PlayerId);
writer.Write(target.PlayerId);
writer.Write(isDoused);
@@ -1351,7 +1357,7 @@ internal static class ExtendedPlayerControl
public static void RpcSetDrawPlayer(this PlayerControl player, PlayerControl target, bool isDoused)
{
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetDrawPlayer, SendOption.Reliable); //RPCによる同期
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetDrawPlayer, HazelExtensions.SendOption); //RPCによる同期
writer.Write(player.PlayerId);
writer.Write(target.PlayerId);
writer.Write(isDoused);
@@ -1360,7 +1366,7 @@ internal static class ExtendedPlayerControl
public static void RpcSetRevealtPlayer(this PlayerControl player, PlayerControl target, bool isDoused)
{
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetRevealedPlayer, SendOption.Reliable); //RPCによる同期
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetRevealedPlayer, HazelExtensions.SendOption); //RPCによる同期
writer.Write(player.PlayerId);
writer.Write(target.PlayerId);
writer.Write(isDoused);
@@ -1468,7 +1474,7 @@ internal static class ExtendedPlayerControl
public static void RpcExileV2(this PlayerControl player)
{
player.Exiled();
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(player.NetId, (byte)RpcCalls.Exiled, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(player.NetId, (byte)RpcCalls.Exiled, HazelExtensions.SendOption);
AmongUsClient.Instance.FinishRpcImmediately(writer);
FixedUpdatePatch.LoversSuicide(player.PlayerId);
}
+4
View File
@@ -5,6 +5,10 @@ namespace EHR;
public static class HazelExtensions
{
// -------------------------------------------------------------------------------------------------------------------------
public static SendOption SendOption => GameStates.CurrentServerType == GameStates.ServerType.Vanilla ? SendOption.None : SendOption.Reliable;
public static void Write(this MessageWriter writer, Vector2 vector)
{
NetHelpers.WriteVector2(vector, writer);
@@ -58,7 +58,7 @@ public abstract class GameOptionsSender
{
try
{
MessageWriter writer = MessageWriter.Get(SendOption.Reliable);
MessageWriter writer = MessageWriter.Get(HazelExtensions.SendOption);
writer.StartMessage(targetClientId == -1 ? Tags.GameData : Tags.GameDataTo);
+1 -3
View File
@@ -339,9 +339,6 @@ public class PlayerState(byte playerId)
RPC.SendDeathReason(PlayerId, deathReason);
Utils.CheckAndSpawnAdditionalRefugee(Utils.GetPlayerInfoById(PlayerId));
if (Utils.DoRPC && !CustomGameMode.Standard.IsActiveOrIntegrated())
Main.AllPlayerControls.DoIf(x => x.IsNonHostModClient(), x => Player.RpcSetRoleDesync(RoleTypes.CrewmateGhost, x.GetClientId()));
}
}
@@ -387,6 +384,7 @@ public class TaskState
}
HasTasks = true;
CompletedTasksCount = 0;
AllTasksCount = player.Data.Tasks.Count;
Logger.Info($"{player.GetNameWithRole().RemoveHtmlTags()}: TaskCounts = {CompletedTasksCount}/{AllTasksCount}", "TaskState.Init");
}
+2 -2
View File
@@ -605,7 +605,7 @@ public static class GuessManager
else meetingHud.ClearVote();
}
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.GuessKill, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.GuessKill, HazelExtensions.SendOption);
writer.Write(pc.PlayerId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
}
@@ -1034,7 +1034,7 @@ public static class GuessManager
// Modded non-host client guess role/add-on
private static void SendRPC(int playerId, CustomRoles role)
{
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (int)CustomRPC.Guess, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (int)CustomRPC.Guess, HazelExtensions.SendOption);
writer.Write(playerId);
writer.Write((int)role);
AmongUsClient.Instance.FinishRpcImmediately(writer);
+1 -1
View File
@@ -282,7 +282,7 @@ public static class NameColorManager
{
if (!AmongUsClient.Instance.AmHost) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetNameColorData, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetNameColorData, HazelExtensions.SendOption);
writer.Write(seerId);
writer.Write(targetId);
writer.Write(colorCode);
+1 -1
View File
@@ -72,7 +72,7 @@ public static class NameNotifyManager
{
if (!AmongUsClient.Instance.AmHost) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncNameNotify, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncNameNotify, HazelExtensions.SendOption);
writer.Write(playerId);
writer.Write(text);
writer.Write(expireTS.ToString());
+19 -19
View File
@@ -314,7 +314,7 @@ internal static class RPCHandlerPatch
LateTask.New(() =>
{
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.RequestRetryVersionCheck, SendOption.Reliable, __instance.GetClientId());
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.RequestRetryVersionCheck, HazelExtensions.SendOption, __instance.GetClientId());
AmongUsClient.Instance.FinishRpcImmediately(writer);
}, 1f, "Retry Version Check Task");
}
@@ -1148,7 +1148,7 @@ internal static class RPC
int amountAllOptions = OptionItem.AllOptions.Count;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncCustomSettings, SendOption.Reliable, targetId);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncCustomSettings, HazelExtensions.SendOption, targetId);
writer.Write(startAmount);
writer.Write(lastAmount);
@@ -1170,7 +1170,7 @@ internal static class RPC
{
if (AmongUsClient.Instance.AmHost) PlaySound(PlayerID, sound);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.PlaySound, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.PlaySound, HazelExtensions.SendOption);
writer.Write(PlayerID);
writer.Write((byte)sound);
AmongUsClient.Instance.FinishRpcImmediately(writer);
@@ -1180,7 +1180,7 @@ internal static class RPC
{
if (!AmongUsClient.Instance.AmHost) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncAllPlayerNames, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncAllPlayerNames, HazelExtensions.SendOption);
writer.Write(Main.AllPlayerNames.Count);
foreach (KeyValuePair<byte, string> name in Main.AllPlayerNames)
@@ -1203,7 +1203,7 @@ internal static class RPC
{
if (!AmongUsClient.Instance.AmHost) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ShowPopUp, SendOption.Reliable, pc.GetClientId());
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ShowPopUp, HazelExtensions.SendOption, pc.GetClientId());
writer.Write(msg);
AmongUsClient.Instance.FinishRpcImmediately(writer);
}
@@ -1212,7 +1212,7 @@ internal static class RPC
{
if (!AmongUsClient.Instance.AmHost) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncAllClientRealNames, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncAllClientRealNames, HazelExtensions.SendOption);
writer.WritePacked(Main.AllClientRealNames.Count);
foreach (KeyValuePair<int, string> name in Main.AllClientRealNames)
@@ -1226,7 +1226,7 @@ internal static class RPC
public static void ExileAsync(PlayerControl player)
{
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(player.NetId, (byte)RpcCalls.Exiled, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(player.NetId, (byte)RpcCalls.Exiled, HazelExtensions.SendOption);
AmongUsClient.Instance.FinishRpcImmediately(writer);
player.Exiled();
}
@@ -1257,7 +1257,7 @@ internal static class RPC
public static void SendDeathReason(byte playerId, PlayerState.DeathReason deathReason)
{
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetDeathReason, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetDeathReason, HazelExtensions.SendOption);
writer.Write(playerId);
writer.Write((int)deathReason);
AmongUsClient.Instance.FinishRpcImmediately(writer);
@@ -1333,14 +1333,14 @@ internal static class RPC
{
if (!AmongUsClient.Instance.AmHost) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetLoversPlayers, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetLoversPlayers, HazelExtensions.SendOption);
writer.Write(Main.LoversPlayers.Count);
foreach (PlayerControl lp in Main.LoversPlayers) writer.Write(lp.PlayerId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
}
public static void SendRpcLogger(uint targetNetId, byte callId, int targetClientId = -1)
public static void SendRpcLogger(uint targetNetId, byte callId, SendOption sendOption, int targetClientId = -1)
{
if (!DebugModeManager.AmDebugger) return;
@@ -1355,7 +1355,7 @@ internal static class RPC
}
catch { }
Logger.Info($"FromNetID: {targetNetId} ({from}) / TargetClientID: {targetClientId} ({target}) / CallID: {callId} ({rpcName})", "SendRPC");
Logger.Info($"FromNetID: {targetNetId} ({from}) / TargetClientID: {targetClientId} ({target}) / CallID: {callId} ({rpcName}) / SendOption: {sendOption}", "SendRPC");
}
public static string GetRpcName(byte callId)
@@ -1376,7 +1376,7 @@ internal static class RPC
Arsonist.CurrentDousingTarget = targetId;
else
{
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetCurrentDousingTarget, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetCurrentDousingTarget, HazelExtensions.SendOption);
writer.Write(arsonistId);
writer.Write(targetId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
@@ -1389,7 +1389,7 @@ internal static class RPC
Revolutionist.CurrentDrawTarget = targetId;
else
{
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetCurrentDrawTarget, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetCurrentDrawTarget, HazelExtensions.SendOption);
writer.Write(arsonistId);
writer.Write(targetId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
@@ -1402,7 +1402,7 @@ internal static class RPC
Revolutionist.CurrentDrawTarget = targetId;
else
{
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetCurrentRevealTarget, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetCurrentRevealTarget, HazelExtensions.SendOption);
writer.Write(arsonistId);
writer.Write(targetId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
@@ -1432,7 +1432,7 @@ internal static class RPC
if (!AmongUsClient.Instance.AmHost) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetRealKiller, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetRealKiller, HazelExtensions.SendOption);
writer.Write(targetId);
writer.Write(killerId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
@@ -1462,17 +1462,17 @@ internal static class PlayerPhysicsRPCHandlerPatch
[HarmonyPatch(typeof(InnerNetClient), nameof(InnerNetClient.StartRpc))]
internal static class StartRpcPatch
{
public static void Prefix( /*InnerNet.InnerNetClient __instance,*/ [HarmonyArgument(0)] uint targetNetId, [HarmonyArgument(1)] byte callId)
public static void Prefix( /*InnerNet.InnerNetClient __instance,*/ [HarmonyArgument(0)] uint targetNetId, [HarmonyArgument(1)] byte callId, [HarmonyArgument(2)] SendOption option = SendOption.Reliable)
{
RPC.SendRpcLogger(targetNetId, callId);
RPC.SendRpcLogger(targetNetId, callId, option);
}
}
[HarmonyPatch(typeof(InnerNetClient), nameof(InnerNetClient.StartRpcImmediately))]
internal static class StartRpcImmediatelyPatch
{
public static void Prefix( /*InnerNet.InnerNetClient __instance,*/ [HarmonyArgument(0)] uint targetNetId, [HarmonyArgument(1)] byte callId, [HarmonyArgument(3)] int targetClientId = -1)
public static void Prefix( /*InnerNet.InnerNetClient __instance,*/ [HarmonyArgument(0)] uint targetNetId, [HarmonyArgument(1)] byte callId, [HarmonyArgument(2)] SendOption option, [HarmonyArgument(3)] int targetClientId = -1)
{
RPC.SendRpcLogger(targetNetId, callId, targetClientId);
RPC.SendRpcLogger(targetNetId, callId, option, targetClientId);
}
}
+10 -16
View File
@@ -60,6 +60,8 @@ public static class Utils
public static long GameStartTimeStamp;
public static readonly Dictionary<byte, (string Text, int Duration, bool Long)> LongRoleDescriptions = [];
private static int NumSnapToRPCsThisRound;
public static long TimeStamp => (long)(DateTime.Now.ToUniversalTime() - TimeStampStartTime).TotalSeconds;
public static bool DoRPC => AmongUsClient.Instance.AmHost && Main.AllPlayerControls.Any(x => x.IsModClient() && !x.IsHost());
public static int TotalTaskCount => Main.RealOptionsData.GetInt(Int32OptionNames.NumCommonTasks) + Main.RealOptionsData.GetInt(Int32OptionNames.NumLongTasks) + Main.RealOptionsData.GetInt(Int32OptionNames.NumShortTasks);
@@ -113,18 +115,8 @@ public static class Utils
public static void CheckAndSetVentInteractions()
{
var shouldPerformVentInteractions = false;
foreach (PlayerControl pc in Main.AllPlayerControls)
{
if (VentilationSystemDeterioratePatch.BlockVentInteraction(pc))
{
VentilationSystemDeterioratePatch.LastClosestVent[pc.PlayerId] = pc.GetVentsFromClosest()[0].Id;
shouldPerformVentInteractions = true;
}
}
if (shouldPerformVentInteractions) SetAllVentInteractions();
if (Main.AllPlayerControls.Any(VentilationSystemDeterioratePatch.BlockVentInteraction))
SetAllVentInteractions();
}
public static void TPAll(Vector2 location, bool log = true)
@@ -143,7 +135,6 @@ public static class Utils
if (pc.inVent || pc.inMovingPlat || pc.onLadder || !pc.IsAlive() || pc.MyPhysics.Animations.IsPlayingAnyLadderAnimation() || pc.MyPhysics.Animations.IsPlayingEnterVentAnimation())
{
if (log) Logger.Warn($"Target ({pc.GetNameWithRole().RemoveHtmlTags()}) is in an un-teleportable state - Teleporting canceled", "TP");
return false;
}
}
@@ -159,7 +150,8 @@ public static class Utils
}
var newSid = (ushort)(nt.lastSequenceId + 8);
MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(nt.NetId, (byte)RpcCalls.SnapTo, SendOption.Reliable);
var sendOption = NumSnapToRPCsThisRound < 100 ? SendOption.Reliable : HazelExtensions.SendOption;
MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(nt.NetId, (byte)RpcCalls.SnapTo, sendOption);
NetHelpers.WriteVector2(location, messageWriter);
messageWriter.Write(newSid);
AmongUsClient.Instance.FinishRpcImmediately(messageWriter);
@@ -169,6 +161,7 @@ public static class Utils
CheckInvalidMovementPatch.LastPosition[pc.PlayerId] = location;
CheckInvalidMovementPatch.ExemptedPlayers.Add(pc.PlayerId);
NumSnapToRPCsThisRound++;
return true;
}
@@ -587,7 +580,7 @@ public static class Utils
public static MessageWriter CreateRPC(CustomRPC rpc)
{
return AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)rpc, SendOption.Reliable);
return AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)rpc, HazelExtensions.SendOption);
}
public static void EndRPC(MessageWriter writer)
@@ -722,7 +715,8 @@ public static class Utils
public static void SetAllVentInteractions()
{
VentilationSystemDeterioratePatch.SerializeV2(ShipStatus.Instance.Systems[SystemTypes.Ventilation].CastFast<VentilationSystem>());
var ventilationSystem = ShipStatus.Instance.Systems[SystemTypes.Ventilation].TryCast<VentilationSystem>();
if (ventilationSystem != null) VentilationSystemDeterioratePatch.SerializeV2(ventilationSystem);
}
public static bool HasTasks(NetworkedPlayerInfo p, bool ForRecompute = true)
+1 -1
View File
@@ -430,7 +430,7 @@ internal static class GameEndChecker
}
// Sync of CustomWinnerHolder info
MessageWriter winnerWriter = self.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.EndGame, SendOption.Reliable);
MessageWriter winnerWriter = self.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.EndGame, HazelExtensions.SendOption);
WriteTo(winnerWriter);
self.FinishRpcImmediately(winnerWriter);
+8 -27
View File
@@ -308,7 +308,6 @@ internal static class ChangeRoleSettings
Main.AllPlayerKillCooldown[pc.PlayerId] = Main.RealOptionsData.GetFloat(FloatOptionNames.KillCooldown);
ReportDeadBodyPatch.CanReport[pc.PlayerId] = true;
ReportDeadBodyPatch.WaitReport[pc.PlayerId] = [];
VentilationSystemDeterioratePatch.LastClosestVent[pc.PlayerId] = 0;
RoleResult[pc.PlayerId] = CustomRoles.NotAssigned;
pc.cosmetics.nameText.text = pc.name;
RandomSpawn.CustomNetworkTransformHandleRpcPatch.HasSpawned.Clear();
@@ -990,7 +989,7 @@ internal static class StartGameHostPatch
playerInfo.IsDead = data;
}
MessageWriter stream = MessageWriter.Get(SendOption.Reliable);
MessageWriter stream = MessageWriter.Get(HazelExtensions.SendOption);
stream.StartMessage(5);
stream.Write(AmongUsClient.Instance.GameId);
@@ -1075,7 +1074,7 @@ internal static class StartGameHostPatch
{
foreach (PlayerControl pc in Main.AllPlayerControls)
{
Senders[pc.PlayerId] = new CustomRpcSender($"{pc.name}'s SetRole Sender", SendOption.Reliable, false)
Senders[pc.PlayerId] = new CustomRpcSender($"{pc.name}'s SetRole Sender", HazelExtensions.SendOption, false)
.StartMessage(pc.GetClientId());
}
}
@@ -1180,34 +1179,16 @@ internal static class StartGameHostPatch
public static void Release()
{
BlockSetRole = false;
Senders.Do(kvp => kvp.Value.SendMessage());
Senders.Values.Do(s => s.SendMessage());
if (!CustomRoles.DoubleAgent.IsEnable()) return;
try
System.Collections.IEnumerator ReleaseAsync()
{
RoleResult.DoIf(x => x.Value == CustomRoles.DoubleAgent, k =>
foreach (var sender in Senders.Values)
{
var da = k.Key.GetPlayer();
if (da == null) return;
var ci = da.GetClientId();
if (ci == -1) return;
RoleResult.DoIf(x => x.Value.IsImpostor(), x =>
{
var imp = x.Key.GetPlayer();
if (imp == null) return;
var previousRoleType = RoleMap[(k.Key, x.Key)].RoleType;
imp.RpcSetRoleDesync(RoleTypes.Crewmate, ci);
LateTask.New(() => imp.RpcSetRoleDesync(previousRoleType, ci), 7f, log: false);
});
});
sender.SendMessage();
yield return new WaitForSeconds(0.3f);
}
}
catch (Exception e) { Utils.ThrowException(e); }
}
public static void EndReplace()
+2 -2
View File
@@ -29,7 +29,7 @@ public static class PhantomRolePatch
}
__instance.SetRoleInvisibility(true);
MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(__instance.NetId, (byte)RpcCalls.CheckVanish, SendOption.Reliable, AmongUsClient.Instance.HostId);
MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(__instance.NetId, (byte)RpcCalls.CheckVanish, HazelExtensions.SendOption, AmongUsClient.Instance.HostId);
messageWriter.Write(maxDuration);
AmongUsClient.Instance.FinishRpcImmediately(messageWriter);
return false;
@@ -45,7 +45,7 @@ public static class PhantomRolePatch
return false;
}
MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(__instance.NetId, (byte)RpcCalls.CheckAppear, SendOption.Reliable, AmongUsClient.Instance.HostId);
MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(__instance.NetId, (byte)RpcCalls.CheckAppear, HazelExtensions.SendOption, AmongUsClient.Instance.HostId);
messageWriter.Write(shouldAnimate);
AmongUsClient.Instance.FinishRpcImmediately(messageWriter);
return false;
+41 -5
View File
@@ -81,7 +81,7 @@ internal static class RpcMurderPlayerPatch
if (AmongUsClient.Instance.AmClient)
__instance.MurderPlayer(target, murderResultFlags);
MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(__instance.NetId, (byte)RpcCalls.MurderPlayer, SendOption.Reliable);
MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(__instance.NetId, (byte)RpcCalls.MurderPlayer, HazelExtensions.SendOption);
messageWriter.WriteNetObject(target);
messageWriter.Write((int)murderResultFlags);
AmongUsClient.Instance.FinishRpcImmediately(messageWriter);
@@ -99,7 +99,7 @@ internal static class CmdCheckMurderPatch
__instance.CheckMurder(target);
else if (!CustomGameMode.FFA.IsActiveOrIntegrated())
{
MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(__instance.NetId, (byte)RpcCalls.CheckMurder, SendOption.Reliable);
MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(__instance.NetId, (byte)RpcCalls.CheckMurder, HazelExtensions.SendOption);
messageWriter.WriteNetObject(target);
AmongUsClient.Instance.FinishRpcImmediately(messageWriter);
}
@@ -1218,9 +1218,6 @@ internal static class FixedUpdatePatch
if (AmongUsClient.Instance.AmHost && __instance.AmOwner)
CustomNetObject.FixedUpdate();
if (AmongUsClient.Instance.AmHost && __instance.IsAlive())
VentilationSystemDeterioratePatch.CheckVentInteraction(__instance);
byte id = __instance.PlayerId;
if (AmongUsClient.Instance.AmHost && GameStates.IsInTask && ReportDeadBodyPatch.CanReport[id] && ReportDeadBodyPatch.WaitReport[id].Count > 0)
@@ -2349,4 +2346,43 @@ static class BootFromVentPatch
{
return !GameStates.IsInTask || ExileController.Instance || __instance == null || __instance.myPlayer == null || !__instance.myPlayer.IsAlive() || !__instance.myPlayer.Is(CustomRoles.Nimble);
}
}
// From https://github.com/Rabek009/MoreGamemodes - by Rabek009
[HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.RpcSetColor))]
static class RpcSetColorPatch
{
public static bool Prefix(PlayerControl __instance, [HarmonyArgument(0)] byte bodyColor)
{
if (!AmongUsClient.Instance.AmHost) return true;
if (AmongUsClient.Instance.AmClient)
__instance.SetColor(bodyColor);
MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(__instance.NetId, (byte)RpcCalls.SetColor, SendOption.None);
messageWriter.Write(__instance.Data.NetId);
messageWriter.Write(bodyColor);
AmongUsClient.Instance.FinishRpcImmediately(messageWriter);
return false;
}
}
// From https://github.com/Rabek009/MoreGamemodes - by Rabek009
[HarmonyPatch(typeof(CustomNetworkTransform), nameof(CustomNetworkTransform.RpcSnapTo))]
static class RpcSnapToPatch
{
public static bool Prefix(CustomNetworkTransform __instance, [HarmonyArgument(0)] Vector2 position)
{
if (!AmongUsClient.Instance.AmHost) return true;
if (AmongUsClient.Instance.AmClient)
__instance.SnapTo(position, (ushort)(__instance.lastSequenceId + 1));
ushort num = (ushort)(__instance.lastSequenceId + 2);
MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(__instance.NetId, (byte)RpcCalls.SnapTo, SendOption.None);
NetHelpers.WriteVector2(position, messageWriter);
messageWriter.Write(num);
AmongUsClient.Instance.FinishRpcImmediately(messageWriter);
return false;
}
}
+4 -4
View File
@@ -362,7 +362,7 @@ internal static class InnerNetClientSpawnPatch
{
if (client.Character == null) return;
MessageWriter sender = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.RequestRetryVersionCheck, SendOption.Reliable, client.Character.OwnerId);
MessageWriter sender = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.RequestRetryVersionCheck, HazelExtensions.SendOption, client.Character.OwnerId);
AmongUsClient.Instance.FinishRpcImmediately(sender);
}, 3f, "RPC Request Retry Version Check");
@@ -383,7 +383,7 @@ internal static class InnerNetClientSpawnPatch
// Non-host modded client
else
{
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncLobbyTimer, SendOption.Reliable, client.Id);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncLobbyTimer, HazelExtensions.SendOption, client.Id);
writer.WritePacked((int)GameStartManagerPatch.TimerStartTS);
AmongUsClient.Instance.FinishRpcImmediately(writer);
}
@@ -498,7 +498,7 @@ internal static class PlayerControlCheckNamePatch
{
if (__instance != null && !__instance.Data.Disconnected && !__instance.IsModClient())
{
MessageWriter sender = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.RequestRetryVersionCheck, SendOption.Reliable, __instance.OwnerId);
MessageWriter sender = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.RequestRetryVersionCheck, HazelExtensions.SendOption, __instance.OwnerId);
AmongUsClient.Instance.FinishRpcImmediately(sender);
}
}, 0.6f, "Retry Version Check", false);
@@ -524,7 +524,7 @@ internal static class InnerNetClientFixedUpdatePatch
}
[HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.SetColor))]
internal static class RpcSetColorPatch
internal static class SetColorPatch
{
public static void Postfix(PlayerControl __instance, byte bodyColor)
{
+31 -85
View File
@@ -431,12 +431,10 @@ internal static class ShipStatusSerializePatch
{
public static void Prefix(ShipStatus __instance, [HarmonyArgument(1)] bool initialState)
{
if (!AmongUsClient.Instance.AmHost) return;
if (initialState) return;
if (!AmongUsClient.Instance.AmHost || initialState) return;
bool cancel = Main.AllPlayerControls.Any(VentilationSystemDeterioratePatch.BlockVentInteraction);
var ventilationSystem = __instance.Systems[SystemTypes.Ventilation].CastFast<VentilationSystem>();
var ventilationSystem = __instance.Systems[SystemTypes.Ventilation].TryCast<VentilationSystem>();
if (cancel && ventilationSystem is { IsDirty: true })
{
@@ -447,33 +445,20 @@ internal static class ShipStatusSerializePatch
}
[HarmonyPatch(typeof(VentilationSystem), nameof(VentilationSystem.Deteriorate))]
internal static class VentilationSystemDeterioratePatch
static class VentilationSystemDeterioratePatch
{
public static Dictionary<byte, int> LastClosestVent = [];
private static readonly Dictionary<byte, bool> LastCanUseVent = [];
private static readonly Dictionary<byte, int> LastClosestVentForUpdate = [];
private static readonly Dictionary<byte, int> CheckBufferTime = [];
public static void Postfix(VentilationSystem __instance)
{
if (!AmongUsClient.Instance.AmHost) return;
if (!AmongUsClient.Instance.AmHost || !GameStates.IsInTask) return;
if (!GameStates.InGame) return;
foreach (PlayerControl pc in Main.AllPlayerControls)
foreach (var pc in PlayerControl.AllPlayerControls)
{
if (BlockVentInteraction(pc))
{
var players = 0;
foreach (NetworkedPlayerInfo playerInfo in GameData.Instance.AllPlayers)
if (playerInfo != null && !playerInfo.Disconnected)
++players;
int closestVentId = pc.GetClosestVent().Id;
if (closestVentId == LastClosestVent[pc.PlayerId] && players >= 3) continue;
LastClosestVent[pc.PlayerId] = closestVentId;
if (LastClosestVent.TryGetValue(pc.PlayerId, out var ventId) && pc.GetClosestVent().Id == ventId) continue;
LastClosestVent[pc.PlayerId] = pc.GetClosestVent().Id;
MessageWriter writer = MessageWriter.Get();
writer.StartMessage(6);
writer.Write(AmongUsClient.Instance.GameId);
@@ -482,26 +467,29 @@ internal static class VentilationSystemDeterioratePatch
writer.WritePacked(ShipStatus.Instance.NetId);
writer.StartMessage((byte)SystemTypes.Ventilation);
int vents = ShipStatus.Instance.AllVents.Count(vent => !pc.CanUseVent(vent.Id));
List<NetworkedPlayerInfo> AllPlayers = [];
List<NetworkedPlayerInfo> allPlayers = [];
foreach (NetworkedPlayerInfo playerInfo in GameData.Instance.AllPlayers)
foreach (var playerInfo in GameData.Instance.AllPlayers)
{
if (playerInfo != null && !playerInfo.Disconnected)
AllPlayers.Add(playerInfo);
allPlayers.Add(playerInfo);
}
int maxVents = Math.Min(vents, AllPlayers.Count);
var blockedVents = 0;
int maxVents = Math.Min(vents, allPlayers.Count);
int blockedVents = 0;
writer.WritePacked(maxVents);
foreach (Vent vent in pc.GetVentsFromClosest())
foreach (var vent in pc.GetVentsFromClosest())
{
if (!pc.CanUseVent(vent.Id))
{
writer.Write(AllPlayers[blockedVents].PlayerId);
writer.Write(allPlayers[blockedVents].PlayerId);
writer.Write((byte)vent.Id);
++blockedVents;
}
if (blockedVents >= maxVents) break;
if (blockedVents >= maxVents)
break;
}
writer.WritePacked(__instance.PlayersInsideVents.Count);
@@ -523,15 +511,14 @@ internal static class VentilationSystemDeterioratePatch
public static bool BlockVentInteraction(PlayerControl pc)
{
return !pc.AmOwner && (!pc.IsModClient() || (!pc.IsHost() && CustomGameMode.RoomRush.IsActiveOrIntegrated())) && !pc.Data.IsDead && (pc.IsImpostor() || pc.GetRoleTypes() is RoleTypes.Engineer or RoleTypes.Impostor or RoleTypes.Shapeshifter or RoleTypes.Phantom) && ShipStatus.Instance.AllVents.Any(vent => !pc.CanUseVent(vent.Id));
return !pc.AmOwner && !pc.IsModClient() && !pc.Data.IsDead && pc.GetRoleTypes() is RoleTypes.Engineer or RoleTypes.Impostor or RoleTypes.Shapeshifter or RoleTypes.Phantom && ShipStatus.Instance.AllVents.Any(vent => !pc.CanUseVent(vent.Id));
}
public static void SerializeV2(VentilationSystem __instance, PlayerControl player = null)
{
foreach (PlayerControl pc in Main.AllPlayerControls)
foreach (var pc in PlayerControl.AllPlayerControls)
{
if (pc.AmOwner) continue;
if (player != null && pc != player) continue;
if (BlockVentInteraction(pc))
@@ -544,26 +531,29 @@ internal static class VentilationSystemDeterioratePatch
writer.WritePacked(ShipStatus.Instance.NetId);
writer.StartMessage((byte)SystemTypes.Ventilation);
int vents = ShipStatus.Instance.AllVents.Count(vent => !pc.CanUseVent(vent.Id));
List<NetworkedPlayerInfo> AllPlayers = [];
List<NetworkedPlayerInfo> allPlayers = [];
foreach (NetworkedPlayerInfo playerInfo in GameData.Instance.AllPlayers)
foreach (var playerInfo in GameData.Instance.AllPlayers)
{
if (playerInfo != null && !playerInfo.Disconnected)
AllPlayers.Add(playerInfo);
allPlayers.Add(playerInfo);
}
int maxVents = Math.Min(vents, AllPlayers.Count);
var blockedVents = 0;
int maxVents = Math.Min(vents, allPlayers.Count);
int blockedVents = 0;
writer.WritePacked(maxVents);
foreach (Vent vent in pc.GetVentsFromClosest())
foreach (var vent in pc.GetVentsFromClosest())
{
if (!pc.CanUseVent(vent.Id))
{
writer.Write(AllPlayers[blockedVents].PlayerId);
writer.Write(allPlayers[blockedVents].PlayerId);
writer.Write((byte)vent.Id);
++blockedVents;
}
if (blockedVents >= maxVents) break;
if (blockedVents >= maxVents)
break;
}
writer.WritePacked(__instance.PlayersInsideVents.Count);
@@ -598,50 +588,6 @@ internal static class VentilationSystemDeterioratePatch
}
}
}
public static void CheckVentInteraction(PlayerControl pc)
{
if (!GameStates.IsInTask || ExileController.Instance || !ShipStatus.Instance) return;
const int bufferTimeWait = 10;
if (!CheckBufferTime.TryGetValue(pc.PlayerId, out int bufferTime))
{
CheckBufferTime[pc.PlayerId] = bufferTimeWait;
return;
}
if (bufferTime > 0)
{
CheckBufferTime[pc.PlayerId]--;
return;
}
CheckBufferTime[pc.PlayerId] = bufferTimeWait;
int closestVent = pc.GetClosestVent().Id;
if (!LastClosestVentForUpdate.TryGetValue(pc.PlayerId, out int lastClosestVent))
{
LastClosestVentForUpdate[pc.PlayerId] = closestVent;
return;
}
bool canUse = pc.CanUseVent(closestVent);
if (!LastCanUseVent.TryGetValue(pc.PlayerId, out bool couldUse))
{
LastCanUseVent[pc.PlayerId] = canUse;
return;
}
if (couldUse != canUse || lastClosestVent != closestVent)
{
LastCanUseVent[pc.PlayerId] = canUse;
pc.RpcSetVentInteraction();
}
}
}
[HarmonyPatch(typeof(VentilationSystem), nameof(VentilationSystem.IsVentCurrentlyBeingCleaned))]
+3 -2
View File
@@ -266,9 +266,10 @@ internal static class RpcSetTasksPatch
NormalPlayerTask[] allTasks = ShortTasks.ToArray().Concat(LongTasks.ToArray()).ToArray();
Il2CppSystem.Text.StringBuilder sb = new();
foreach (TaskTypes taskType in usedTaskTypes) { GetTaskFromTaskType(taskType).AppendTaskText(sb); }
foreach (TaskTypes taskType in usedTaskTypes)
GetTaskFromTaskType(taskType)?.AppendTaskText(sb);
Logger.Info($" Assigned tasks:\n{sb.Replace("\r\n", "\n").ToString()}", pc.GetRealName(), multiLine: true);
Logger.Info($" Changed Assigned tasks:\n{sb.Replace("\r\n", "\n").ToString()}", pc.GetRealName(), multiLine: true);
PlayerTask GetTaskFromTaskType(TaskTypes type) => allTasks.FirstOrDefault(t => t.TaskType == type);
}
+1 -1
View File
@@ -152,7 +152,7 @@ public class Stressed : IAddon
{
if (!Utils.DoRPC || !IsEnable) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncStressedTimer, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncStressedTimer, HazelExtensions.SendOption);
writer.Write(id);
writer.Write(time);
writer.Write(lastUpdate.ToString());
+1 -1
View File
@@ -101,7 +101,7 @@ public class Workhorse : IAddon
if (AmongUsClient.Instance.AmHost)
{
Add(pc.PlayerId);
pc.Data.RpcSetTasks(new(0)); // Redistribute tasks
pc.RpcResetTasks();
pc.SyncSettings();
Utils.NotifyRoles(SpecifySeer: pc, SpecifyTarget: pc);
}
+1 -1
View File
@@ -45,7 +45,7 @@ internal class Haunter : IGhostRole
taskState.CompletedTasksCount = 0;
taskState.AllTasksCount = Utils.TotalTaskCount - Main.RealOptionsData.GetInt(Int32OptionNames.NumCommonTasks);
pc.Data.RpcSetTasks(new(0));
pc.RpcResetTasks();
pc.SyncSettings();
pc.RpcResetAbilityCooldown();
Utils.NotifyRoles(SpecifySeer: pc, SpecifyTarget: pc);
+1 -1
View File
@@ -24,7 +24,7 @@ internal class Specter : IGhostRole
taskState.CompletedTasksCount = 0;
taskState.AllTasksCount = Utils.TotalTaskCount - Main.RealOptionsData.GetInt(Int32OptionNames.NumCommonTasks);
pc.Data.RpcSetTasks(new(0));
pc.RpcResetTasks();
pc.SyncSettings();
pc.RpcResetAbilityCooldown();
Utils.NotifyRoles(SpecifySeer: pc, SpecifyTarget: pc);
+1 -1
View File
@@ -91,7 +91,7 @@ public class Damocles : IAddon
{
if (!Utils.DoRPC) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncDamoclesTimer, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncDamoclesTimer, HazelExtensions.SendOption);
writer.Write(playerId);
writer.Write(Timer[playerId]);
writer.Write(LastUpdate[playerId].ToString());
+3 -3
View File
@@ -103,7 +103,7 @@ public class Alchemist : RoleBase
{
if (!IsEnable || !Utils.DoRPC) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetAlchemistPotion, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetAlchemistPotion, HazelExtensions.SendOption);
writer.Write(AlchemistId);
writer.Write(IsProtected);
writer.Write(PotionID);
@@ -250,7 +250,7 @@ public class Alchemist : RoleBase
{
if (!IsEnable || !Utils.DoRPC) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetAlchemistTimer, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetAlchemistTimer, HazelExtensions.SendOption);
writer.Write(AlchemistId);
writer.Write(InvisTime.ToString());
AmongUsClient.Instance.FinishRpcImmediately(writer);
@@ -284,7 +284,7 @@ public class Alchemist : RoleBase
{
ventedId = ventId;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(instance.NetId, 34, SendOption.Reliable, pc.GetClientId());
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(instance.NetId, 34, HazelExtensions.SendOption, pc.GetClientId());
writer.WritePacked(ventId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
+1 -1
View File
@@ -61,7 +61,7 @@ internal class Benefactor : RoleBase
{
if (!Utils.DoRPC) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncBenefactorMarkedTask, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncBenefactorMarkedTask, HazelExtensions.SendOption);
writer.Write(benefactorId);
writer.Write(taskIndex);
writer.Write(isShield);
+1 -1
View File
@@ -73,7 +73,7 @@ public class Cleanser : RoleBase
{
if (!IsEnable || !Utils.DoRPC) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetCleanserCleanLimit, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetCleanserCleanLimit, HazelExtensions.SendOption);
writer.Write(playerId);
writer.Write(CleanserUses);
AmongUsClient.Instance.FinishRpcImmediately(writer);
+2 -1
View File
@@ -301,7 +301,8 @@ public class Dad : RoleBase
if (completedTaskCount + 1 >= totalTaskCount)
{
pc.Data.RpcSetTasks(new(0));
pc.RpcResetTasks();
pc.SyncSettings();
DoneTasks = true;
GameData.Instance.RecomputeTaskCounts();
}
+1 -1
View File
@@ -85,7 +85,7 @@ public class Druid : RoleBase
{
if (!DoRPC) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.DruidAddTrigger, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.DruidAddTrigger, HazelExtensions.SendOption);
writer.Write(add);
writer.Write(playerId);
writer.Write(position.x);
+2 -2
View File
@@ -77,14 +77,14 @@ public class Jailor : RoleBase
if (!setTarget)
{
writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetJailorExeLimit, SendOption.Reliable);
writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetJailorExeLimit, HazelExtensions.SendOption);
writer.Write(jailerId);
writer.Write(JailorDidVote);
AmongUsClient.Instance.FinishRpcImmediately(writer);
return;
}
writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetJailorTarget, SendOption.Reliable);
writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetJailorTarget, HazelExtensions.SendOption);
writer.Write(jailerId);
writer.Write(targetId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
+1 -1
View File
@@ -113,7 +113,7 @@ public class Medic : RoleBase
{
if (!Utils.DoRPC) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetMedicalerProtectList, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetMedicalerProtectList, HazelExtensions.SendOption);
writer.Write(ProtectList.Count);
ProtectList.Do(x => writer.Write(x));
AmongUsClient.Instance.FinishRpcImmediately(writer);
+1 -1
View File
@@ -93,7 +93,7 @@ public class NiceHacker : RoleBase
{
if (!DoRPC) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetNiceHackerLimit, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetNiceHackerLimit, HazelExtensions.SendOption);
writer.Write(playerId);
writer.Write(secondsLeft);
AmongUsClient.Instance.FinishRpcImmediately(writer);
+1 -1
View File
@@ -255,7 +255,7 @@ public class NiceSwapper : RoleBase
{
if (!Utils.DoRPC) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetNiceSwapperVotes, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetNiceSwapperVotes, HazelExtensions.SendOption);
writer.Write(playerId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
}
+1 -1
View File
@@ -69,7 +69,7 @@ public class Psychic : RoleBase
{
if (!IsEnable || !Utils.DoRPC) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncPsychicRedList, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncPsychicRedList, HazelExtensions.SendOption);
writer.Write(PsychicId);
writer.Write(RedPlayer.Count);
foreach (byte pc in RedPlayer) writer.Write(pc);
+1 -1
View File
@@ -63,7 +63,7 @@ public class Ricochet : RoleBase
{
if (!IsEnable || !Utils.DoRPC) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetRicochetTarget, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetRicochetTarget, HazelExtensions.SendOption);
writer.Write(RicochetId);
writer.Write(targetId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
+2 -2
View File
@@ -80,7 +80,7 @@ public class SabotageMaster : RoleBase
MaxFixedViaPet = new IntegerOptionItem(Id + 21, "SMMaxFixedViaPet", new(1, 30, 1), 1, TabGroup.CrewmateRoles)
.SetParent(CanFixSabotageFromAnywhereWithPet);
CanVent = new BooleanOptionItem(Id + 22, "CanVent", true, TabGroup.CrewmateRoles)
.SetParent(Options.CustomRoleSpawnChances[CustomRoles.SabotageMaster]);
}
@@ -150,7 +150,7 @@ public class SabotageMaster : RoleBase
{
if (!IsEnable || !Utils.DoRPC) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetSabotageMasterLimit, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetSabotageMasterLimit, HazelExtensions.SendOption);
writer.Write(SMId);
writer.Write(UsedSkillCount);
AmongUsClient.Instance.FinishRpcImmediately(writer);
+1 -1
View File
@@ -80,7 +80,7 @@ public class Scout : RoleBase
{
if (!Utils.DoRPC) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetTrackerTarget, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetTrackerTarget, HazelExtensions.SendOption);
writer.Write(trackerId);
writer.Write(targetId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
+1 -1
View File
@@ -65,7 +65,7 @@ public class Spy : RoleBase
{
if (!DoRPC) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncSpy, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncSpy, HazelExtensions.SendOption);
writer.Write(operate);
switch (operate)
+1 -1
View File
@@ -82,7 +82,7 @@ public class SwordsMan : RoleBase
{
if (!Utils.DoRPC) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SwordsManKill, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SwordsManKill, HazelExtensions.SendOption);
writer.Write(playerId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
}
+1 -1
View File
@@ -68,7 +68,7 @@ public class Tether : RoleBase
{
if (!IsEnable || !Utils.DoRPC) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetTetherTarget, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetTetherTarget, HazelExtensions.SendOption);
writer.Write(TetherId);
writer.Write(Target);
AmongUsClient.Instance.FinishRpcImmediately(writer);
+1 -1
View File
@@ -93,7 +93,7 @@ internal class Tornado : RoleBase
{
if (!DoRPC) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.AddTornado, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.AddTornado, HazelExtensions.SendOption);
writer.Write(add);
writer.Write(pos.x);
writer.Write(pos.y);
+2 -2
View File
@@ -16,7 +16,7 @@ internal class Assassin : RoleBase
private static OptionItem MarkCooldownOpt;
public static OptionItem AssassinateCooldownOpt;
private static OptionItem CanKillAfterAssassinateOpt;
private float AssassinateCooldown;
private bool CanKillAfterAssassinate;
private bool IsUndertaker;
@@ -77,7 +77,7 @@ internal class Assassin : RoleBase
{
if (!IsEnable || !Utils.DoRPC) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetMarkedPlayer, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetMarkedPlayer, HazelExtensions.SendOption);
writer.Write(playerId);
writer.Write(MarkedPlayer);
AmongUsClient.Instance.FinishRpcImmediately(writer);
+1 -1
View File
@@ -60,7 +60,7 @@ public class BallLightning : RoleBase
{
if (!Utils.DoRPC) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetGhostPlayer, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetGhostPlayer, HazelExtensions.SendOption);
writer.Write(playerId);
writer.Write(IsGhost(playerId));
AmongUsClient.Instance.FinishRpcImmediately(writer);
+1 -1
View File
@@ -86,7 +86,7 @@ public class BountyHunter : RoleBase
{
if (!Utils.DoRPC) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetBountyTarget, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetBountyTarget, HazelExtensions.SendOption);
writer.Write(BountyId);
writer.Write(Target);
AmongUsClient.Instance.FinishRpcImmediately(writer);
+1 -1
View File
@@ -64,7 +64,7 @@ internal class Capitalism : RoleBase
taskState.AllTasksCount += amount;
CapitalismAddTask.Remove(player.PlayerId);
taskState.CompletedTasksCount++;
player.Data.RpcSetTasks(new(0)); // Redistribute tasks
player.RpcResetTasks();
player.SyncSettings();
Utils.NotifyRoles(SpecifySeer: player, SpecifyTarget: player);
return false;
+1 -1
View File
@@ -41,7 +41,7 @@ public class Chronomancer : RoleBase
{
if (!Utils.DoRPC) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncChronomancer, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncChronomancer, HazelExtensions.SendOption);
writer.Write(ChronomancerId);
writer.Write(IsRampaging);
writer.Write(ChargePercent);
+1 -1
View File
@@ -299,7 +299,7 @@ public class Councillor : RoleBase
{
if (!Utils.DoRPC) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.MeetingKill, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.MeetingKill, HazelExtensions.SendOption);
writer.Write(playerId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
}
+1 -1
View File
@@ -114,7 +114,7 @@ internal class Crewpostor : RoleBase
}
else
{
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetCpTasksDone, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetCpTasksDone, HazelExtensions.SendOption);
writer.Write(cpID);
writer.Write(tasksDone);
AmongUsClient.Instance.FinishRpcImmediately(writer);
+1 -1
View File
@@ -89,7 +89,7 @@ public class EvilDiviner : RoleBase
{
if (!Utils.DoRPC) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetEvilDiviner, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetEvilDiviner, HazelExtensions.SendOption);
writer.Write(playerId);
writer.Write(targetId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
+1 -1
View File
@@ -179,7 +179,7 @@ public class EvilTracker : RoleBase
if (!Utils.DoRPC) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetEvilTrackerTarget, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetEvilTrackerTarget, HazelExtensions.SendOption);
writer.Write(trackerId);
writer.Write(targetId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
+3 -9
View File
@@ -89,7 +89,7 @@ public class FireWorks : RoleBase
if (!On || !Utils.DoRPC) return;
Logger.Info($"Player{playerId}:SendRPC", "FireWorks");
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SendFireWorksState, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SendFireWorksState, HazelExtensions.SendOption);
writer.Write(playerId);
writer.Write(nowFireWorksCount);
writer.Write((int)state);
@@ -106,14 +106,8 @@ public class FireWorks : RoleBase
{
if (pc == null || pc.Data.IsDead) return false;
try
{
return CanKill.GetBool() || (state & FireWorksState.CanUseKill) != 0;
}
catch
{
return false;
}
try { return CanKill.GetBool() || (state & FireWorksState.CanUseKill) != 0; }
catch { return false; }
}
public override void OnPet(PlayerControl pc)
+1 -1
View File
@@ -92,7 +92,7 @@ public class Greedier : RoleBase // Also used for Imitator as the NK version of
{
if (!Utils.DoRPC) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetGreedierOe, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetGreedierOe, HazelExtensions.SendOption);
writer.Write(playerId);
writer.Write(IsOdd);
AmongUsClient.Instance.FinishRpcImmediately(writer);
+1 -1
View File
@@ -69,7 +69,7 @@ public class Hitman : RoleBase
{
if (!DoRPC) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetHitmanTarget, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetHitmanTarget, HazelExtensions.SendOption);
writer.Write(HitmanId);
writer.Write(TargetId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
+1 -1
View File
@@ -91,7 +91,7 @@ public class Librarian : RoleBase
{
if (!DoRPC) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetLibrarianMode, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetLibrarianMode, HazelExtensions.SendOption);
writer.Write(playerId);
writer.Write(isInSilenceMode);
AmongUsClient.Instance.FinishRpcImmediately(writer);
+1 -1
View File
@@ -182,7 +182,7 @@ internal class Mafia : RoleBase
private static void SendRPC(byte playerId)
{
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.MafiaRevenge, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.MafiaRevenge, HazelExtensions.SendOption);
writer.Write(playerId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
}
+2 -2
View File
@@ -119,7 +119,7 @@ public class Mafioso : RoleBase
{
if (!IsEnable || !DoRPC) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncMafiosoData, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncMafiosoData, HazelExtensions.SendOption);
writer.Write(MafiosoId);
writer.Write(Tier);
writer.Write(XP);
@@ -148,7 +148,7 @@ public class Mafioso : RoleBase
{
if (!IsEnable || !DoRPC) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncMafiosoPistolCD, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncMafiosoPistolCD, HazelExtensions.SendOption);
writer.Write(MafiosoId);
writer.Write(Pistol1CD);
writer.Write(Pistol2CD);
+1 -1
View File
@@ -134,7 +134,7 @@ public class Penguin : RoleBase
{
if (!IsEnable || !Utils.DoRPC) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.PenguinSync, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.PenguinSync, HazelExtensions.SendOption);
writer.Write(PenguinId);
writer.Write(1);
writer.Write(AbductVictim?.PlayerId ?? 255);
+1 -1
View File
@@ -57,7 +57,7 @@ internal class QuickShooter : RoleBase
{
if (!Utils.DoRPC) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetQuickShooterShotLimit, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetQuickShooterShotLimit, HazelExtensions.SendOption);
writer.Write(playerId);
writer.Write(ShotLimit[playerId]);
AmongUsClient.Instance.FinishRpcImmediately(writer);
+1 -1
View File
@@ -115,7 +115,7 @@ public class Sniper : RoleBase
{
if (!On || !Utils.DoRPC) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SniperSync, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SniperSync, HazelExtensions.SendOption);
writer.Write(sniperId);
writer.Write(shotNotify.Count);
foreach (byte sn in shotNotify) writer.Write(sn);
+1 -1
View File
@@ -133,7 +133,7 @@ public class Swooper : RoleBase
{
if (!IsEnable || !Utils.DoRPC) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetSwooperTimer, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetSwooperTimer, HazelExtensions.SendOption);
writer.Write(SwooperId);
writer.Write(InvisTime.ToString());
writer.Write(lastTime.ToString());
+1 -1
View File
@@ -125,7 +125,7 @@ public class Wildling : RoleBase
{
if (!IsEnable || !Utils.DoRPC) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetBkTimer, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetBkTimer, HazelExtensions.SendOption);
writer.Write(playerId);
writer.Write(TimeStamp.ToString());
AmongUsClient.Instance.FinishRpcImmediately(writer);
+2 -2
View File
@@ -75,14 +75,14 @@ public class Witch : RoleBase
if (doSpell)
{
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.DoSpell, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.DoSpell, HazelExtensions.SendOption);
writer.Write(witchId);
writer.Write(target);
AmongUsClient.Instance.FinishRpcImmediately(writer);
}
else
{
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetKillOrSpell, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetKillOrSpell, HazelExtensions.SendOption);
writer.Write(witchId);
writer.Write(spellMode);
AmongUsClient.Instance.FinishRpcImmediately(writer);
+1 -1
View File
@@ -54,7 +54,7 @@ public class YinYanger : RoleBase
{
if (!DoRPC) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncYinYanger, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncYinYanger, HazelExtensions.SendOption);
writer.Write(YinYangerId);
writer.Write(isClear);
if (!isClear) writer.Write(playerId);
+1 -1
View File
@@ -246,7 +246,7 @@ public class Agitater : RoleBase
private void SendRPC(byte newbomb, byte oldbomb)
{
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.RpcPassBomb, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.RpcPassBomb, HazelExtensions.SendOption);
writer.Write(AgitaterId);
writer.Write(newbomb);
writer.Write(oldbomb);
+1 -1
View File
@@ -86,7 +86,7 @@ public class Bandit : RoleBase
{
if (!On || !Utils.DoRPC) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetBanditStealLimit, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetBanditStealLimit, HazelExtensions.SendOption);
writer.Write(playerId);
writer.Write(TotalSteals[playerId]);
AmongUsClient.Instance.FinishRpcImmediately(writer);
+1 -1
View File
@@ -88,7 +88,7 @@ internal class Bubble : RoleBase
{
if (!IsEnable || !DoRPC) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncBubble, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncBubble, HazelExtensions.SendOption);
writer.Write(remove);
writer.Write(clear);
writer.Write(id);
+1 -1
View File
@@ -47,7 +47,7 @@ public class Collector : RoleBase
{
if (!Utils.DoRPC) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetCollectorVotes, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetCollectorVotes, HazelExtensions.SendOption);
writer.Write(playerId);
writer.Write(CollectVote[playerId]);
AmongUsClient.Instance.FinishRpcImmediately(writer);
+3 -3
View File
@@ -78,7 +78,7 @@ public class DarkHide : RoleBase
{
if (!IsEnable || !Utils.DoRPC || !AmongUsClient.Instance.AmHost) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetDarkHiderKillCount, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetDarkHiderKillCount, HazelExtensions.SendOption);
writer.Write(player.PlayerId);
writer.Write(IsWinKill);
AmongUsClient.Instance.FinishRpcImmediately(writer);
@@ -113,7 +113,7 @@ public class DarkHide : RoleBase
if (succeeded && SnatchesWin.GetBool()) IsWinKill = true;
DRpcSetKillCount(killer);
MessageWriter SabotageFixWriter = AmongUsClient.Instance.StartRpcImmediately(ShipStatus.Instance.NetId, (byte)RpcCalls.UpdateSystem, SendOption.Reliable, killer.GetClientId());
MessageWriter SabotageFixWriter = AmongUsClient.Instance.StartRpcImmediately(ShipStatus.Instance.NetId, (byte)RpcCalls.UpdateSystem, HazelExtensions.SendOption, killer.GetClientId());
SabotageFixWriter.Write((byte)SystemTypes.Electrical);
SabotageFixWriter.WriteNetObject(killer);
AmongUsClient.Instance.FinishRpcImmediately(SabotageFixWriter);
@@ -122,7 +122,7 @@ public class DarkHide : RoleBase
{
if (target.PlayerId == killer.PlayerId || target.Data.Disconnected) continue;
SabotageFixWriter = AmongUsClient.Instance.StartRpcImmediately(ShipStatus.Instance.NetId, (byte)RpcCalls.UpdateSystem, SendOption.Reliable, target.GetClientId());
SabotageFixWriter = AmongUsClient.Instance.StartRpcImmediately(ShipStatus.Instance.NetId, (byte)RpcCalls.UpdateSystem, HazelExtensions.SendOption, target.GetClientId());
SabotageFixWriter.Write((byte)SystemTypes.Electrical);
SabotageFixWriter.WriteNetObject(target);
AmongUsClient.Instance.FinishRpcImmediately(SabotageFixWriter);
+1 -1
View File
@@ -99,7 +99,7 @@ public class Doomsayer : RoleBase
{
if (!Utils.DoRPC) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetDoomsayerProgress, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetDoomsayerProgress, HazelExtensions.SendOption);
writer.Write(player.PlayerId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
}
+1 -1
View File
@@ -104,7 +104,7 @@ public class Doppelganger : RoleBase
{
if (!IsEnable || !Utils.DoRPC) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetDoppelgangerStealLimit, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetDoppelgangerStealLimit, HazelExtensions.SendOption);
writer.Write(playerId);
writer.Write(TotalSteals[playerId]);
AmongUsClient.Instance.FinishRpcImmediately(writer);
+3 -3
View File
@@ -100,7 +100,7 @@ public class Executioner : RoleBase
switch (Progress)
{
case "SetTarget":
writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetExecutionerTarget, SendOption.Reliable);
writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetExecutionerTarget, HazelExtensions.SendOption);
writer.Write(executionerId);
writer.Write(targetId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
@@ -108,7 +108,7 @@ public class Executioner : RoleBase
case "":
if (!AmongUsClient.Instance.AmHost) return;
writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.RemoveExecutionerTarget, SendOption.Reliable);
writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.RemoveExecutionerTarget, HazelExtensions.SendOption);
writer.Write(executionerId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
break;
@@ -186,4 +186,4 @@ public class Executioner : RoleBase
CustomWinnerHolder.SetWinnerOrAdditonalWinner(CustomWinner.Executioner);
CustomWinnerHolder.WinnerIds.Add(playerId);
}
}
}
+1 -1
View File
@@ -94,7 +94,7 @@ public class Gamer : RoleBase
{
if (!IsEnable || !Utils.DoRPC) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetGamerHealth, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetGamerHealth, HazelExtensions.SendOption);
writer.Write(playerId);
writer.Write(GamerHealth.TryGetValue(playerId, out int value) ? value : PlayerHealth[playerId]);
AmongUsClient.Instance.FinishRpcImmediately(writer);
+1 -1
View File
@@ -115,7 +115,7 @@ public class Glitch : RoleBase
{
if (!IsEnable || !Utils.DoRPC) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncGlitchTimers, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncGlitchTimers, HazelExtensions.SendOption);
writer.Write(GlitchId);
writer.Write(MimicCDTimer);
writer.Write(MimicDurTimer);
+1 -1
View File
@@ -77,7 +77,7 @@ internal class Hookshot : RoleBase
{
if (!IsEnable || !DoRPC) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncHookshot, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncHookshot, HazelExtensions.SendOption);
writer.Write(HookshotId);
writer.Write(ToTargetTP);
writer.Write(MarkedPlayerId);
+3 -3
View File
@@ -101,7 +101,7 @@ public class Lawyer : RoleBase
switch (Progress)
{
case "SetTarget":
writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetLawyerTarget, SendOption.Reliable);
writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetLawyerTarget, HazelExtensions.SendOption);
writer.Write(lawyerId);
writer.Write(targetId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
@@ -109,7 +109,7 @@ public class Lawyer : RoleBase
case "":
if (!AmongUsClient.Instance.AmHost) return;
writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.RemoveLawyerTarget, SendOption.Reliable);
writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.RemoveLawyerTarget, HazelExtensions.SendOption);
writer.Write(lawyerId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
break;
@@ -189,4 +189,4 @@ public class Lawyer : RoleBase
{
if (MeetingStates.FirstMeeting && TargetKnowsLawyer.GetBool() && Target.TryGetValue(LawyerId, out byte target)) LateTask.New(() => Utils.SendMessage("\n", target, string.Format(Translator.GetString("YourLawyerIsNotify"), LawyerId.ColoredPlayerName())), 10f, log: false);
}
}
}
+1 -1
View File
@@ -91,7 +91,7 @@ internal class Mycologist : RoleBase
{
if (!IsEnable || !DoRPC) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncMycologist, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncMycologist, HazelExtensions.SendOption);
writer.Write(MycologistId);
writer.Write(InfectedPlayers.Count);
+1 -1
View File
@@ -80,7 +80,7 @@ public class Pelican : RoleBase
{
if (!Utils.DoRPC) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetPelicanEtenNum, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetPelicanEtenNum, HazelExtensions.SendOption);
writer.Write(playerId);
if (playerId != byte.MaxValue)
+1 -1
View File
@@ -80,7 +80,7 @@ public class PlagueBearer : RoleBase
{
if (!Utils.DoRPC) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetPlaguedPlayer, SendOption.Reliable); //RPCによる同期
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetPlaguedPlayer, HazelExtensions.SendOption); //RPCによる同期
writer.Write(player.PlayerId);
writer.Write(target.PlayerId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
+1 -1
View File
@@ -133,7 +133,7 @@ public class PlagueDoctor : RoleBase
{
if (!IsEnable || !Utils.DoRPC) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncPlagueDoctor, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncPlagueDoctor, HazelExtensions.SendOption);
writer.Write(targetId);
writer.Write(rate);
AmongUsClient.Instance.FinishRpcImmediately(writer);
+2 -2
View File
@@ -122,7 +122,7 @@ public class Romantic : RoleBase
{
if (!Utils.DoRPC) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncRomanticTarget, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncRomanticTarget, HazelExtensions.SendOption);
writer.Write(PartnerId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
}
@@ -393,7 +393,7 @@ public class VengefulRomantic : RoleBase
{
if (!Utils.DoRPC) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncVengefulRomanticTarget, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncVengefulRomanticTarget, HazelExtensions.SendOption);
writer.Write(Target);
AmongUsClient.Instance.FinishRpcImmediately(writer);
}
+1 -1
View File
@@ -76,7 +76,7 @@ public class Totocalcio : RoleBase
{
if (!IsEnable || !Utils.DoRPC) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncTotocalcioTargetAndTimes, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncTotocalcioTargetAndTimes, HazelExtensions.SendOption);
writer.Write(playerId);
writer.Write(BetTimes);
writer.Write(BetPlayer);
+1 -1
View File
@@ -81,7 +81,7 @@ public class WeaponMaster : RoleBase
{
if (!Utils.DoRPC) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetWeaponMasterMode, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetWeaponMasterMode, HazelExtensions.SendOption);
writer.Write(WMId);
writer.Write(Mode);
writer.Write(shieldUsed);
+3 -3
View File
@@ -110,7 +110,7 @@ public class Werewolf : RoleBase
{
if (!IsEnable || !Utils.DoRPC) return;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetWwTimer, SendOption.Reliable);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetWwTimer, HazelExtensions.SendOption);
writer.Write(WWId);
writer.Write(RampageTime.ToString());
writer.Write(lastTime.ToString());
@@ -150,13 +150,13 @@ public class Werewolf : RoleBase
{
lastTime = -10;
bool unshift = UseUnshiftTrigger.GetBool() && UseUnshiftTriggerForNKs.GetBool();
if (!player.IsModClient())
{
player.Notify(GetString(unshift ? "WWCanRampageUnshift" : "WWCanRampage"));
player.RpcChangeRoleBasis(unshift ? CustomRoles.Werewolf : CustomRoles.EngineerEHR);
}
SendRPC();
CD = 0;
}