improvements

This commit is contained in:
Gurge44 committed 2025-07-07 14:36:18 +02:00
1 parent 8b572eea09
commit 34b1070aa9
13 files changed
+120 -222

No files matched your search

+3 -8
View File
@@ -703,17 +703,13 @@ public static class BedWars
Inventory.Clear();
if (Reviving.Add(pc.PlayerId)) Main.Instance.StartCoroutine(ReviveCountdown(pc));
pc.Exiled();
CustomRpcSender.Create("BedWars Death", SendOption.Reliable).AutoStartRpc(pc.NetId, 4).EndRpc().SendMessage();
Main.PlayerStates[pc.PlayerId].SetDead();
pc.RpcSetRoleDesync(RoleTypes.GuardianAngel, pc.OwnerId);
pc.RpcResetAbilityCooldown();
pc.MarkDirtySettings();
pc.ExileTemporarily();
}
else
{
Inventory.Items = [];
pc.Suicide();
pc.Suicide(PlayerState.DeathReason.Kill);
}
}
}
@@ -733,7 +729,6 @@ public static class BedWars
Health = MaxHealth;
NameNotifyManager.Notifies.Remove(pc.PlayerId);
Utils.NotifyRoles(SpecifySeer: pc, SpecifyTarget: pc);
RPC.PlaySoundRPC(pc.PlayerId, Sounds.TaskComplete);
pc.RpcRevive();
pc.RpcSetColor(Team.GetColorId());
+9 -17
View File
@@ -4,7 +4,6 @@ using System.Collections.Generic;
using System.Linq;
using AmongUs.GameOptions;
using EHR.Modules;
using EHR.Neutral;
using Hazel;
using UnityEngine;
@@ -399,8 +398,9 @@ public static class CaptureTheFlag
}
}
catch (Exception e) { Utils.ThrowException(e); }
*/
yield return new WaitForSeconds(0.2f);
*/
ValidTag = true;
GameStartTS = Utils.TimeStamp;
@@ -415,7 +415,7 @@ public static class CaptureTheFlag
Vector2 flagBase = team.GetFlagBase().Position;
data.DropFlag();
data.Flag.TP(flagBase);
data.Players.ToValidPlayers().Do(x => x.TP(flagBase));
data.Players.ToValidPlayers().MassTP(flagBase);
}
}
@@ -439,7 +439,7 @@ public static class CaptureTheFlag
target.MarkDirtySettings();
break;
case 1:
target.Suicide();
target.Suicide(PlayerState.DeathReason.Kill);
string notify = string.Format(Translator.GetString("CTF_TeamMemberFallen"), target.PlayerId.ColoredPlayerName());
TeamData[targetTeam].Players.ToValidPlayers().NotifyPlayers(notify);
if (Main.GM.Value && AmongUsClient.Instance.AmHost) PlayerControl.LocalPlayer.KillFlash();
@@ -447,9 +447,7 @@ public static class CaptureTheFlag
break;
case 2:
TemporarilyOutPlayers[target.PlayerId] = Utils.TimeStamp + BackTime.GetInt();
Main.AllPlayerSpeed[target.PlayerId] = Main.MinSpeed;
target.TP(Pelican.GetBlackRoomPS());
target.MarkDirtySettings();
target.ExileTemporarily();
break;
}
@@ -474,6 +472,9 @@ public static class CaptureTheFlag
public static void ApplyGameOptions()
{
AURoleOptions.PhantomCooldown = 5f;
try { AURoleOptions.GuardianAngelCooldown = 900f; }
catch (Exception e) { Utils.ThrowException(e); }
}
public static bool IsNotInLocalPlayersTeam(PlayerControl pc)
@@ -739,28 +740,19 @@ public static class CaptureTheFlag
.SendMessage();
}
Vector2 pos = __instance.Pos();
Vector2 blackRoomPS = Pelican.GetBlackRoomPS();
if (TemporarilyOutPlayers.TryGetValue(__instance.PlayerId, out long endTS))
{
if (Utils.TimeStamp >= endTS)
{
TemporarilyOutPlayers.Remove(__instance.PlayerId);
Main.AllPlayerSpeed[__instance.PlayerId] = Main.RealOptionsData.GetFloat(FloatOptionNames.PlayerSpeedMod);
__instance.MarkDirtySettings();
__instance.RpcRevive();
__instance.TP(team.GetFlagBase().Position);
__instance.SetKillCooldown();
RPC.PlaySoundRPC(__instance.PlayerId, Sounds.TaskComplete);
}
else if (GameEndCriteria.GetValue() != 2)
{
Utils.NotifyRoles(SpecifySeer: __instance, SpecifyTarget: __instance, SendOption: SendOption.None);
if (Vector2.Distance(pos, blackRoomPS) > 2f) __instance.TP(blackRoomPS);
}
}
else if (Vector2.Distance(pos, blackRoomPS) <= 2f)
__instance.TP(team.GetFlagBase().Position);
}
}
}
+2 -6
View File
@@ -4,7 +4,6 @@ using System.Collections.Generic;
using System.Linq;
using AmongUs.GameOptions;
using EHR.Modules;
using EHR.Neutral;
using Hazel;
using UnityEngine;
using static EHR.Translator;
@@ -496,9 +495,7 @@ public static class KingOfTheZones
target.SetKillCooldown(GetKillCooldown(target));
RespawnTimes[target.PlayerId] = Utils.TimeStamp + RespawnTime.GetInt() + 1;
Main.AllPlayerSpeed[target.PlayerId] = Main.MinSpeed;
target.MarkDirtySettings();
target.TP(Pelican.GetBlackRoomPS());
target.ExileTemporarily();
}
private static float GetKillCooldown(PlayerControl player)
@@ -780,10 +777,9 @@ public static class KingOfTheZones
PlayerControl player = id.GetPlayer();
if (player == null) continue;
Main.AllPlayerSpeed[id] = Main.RealOptionsData.GetFloat(FloatOptionNames.PlayerSpeedMod);
player.RpcRevive();
player.TP(RandomSpawn.SpawnMap.GetSpawnMap().Positions.ExceptBy(Zones, x => x.Key).RandomElement().Value);
player.SetKillCooldown(GetKillCooldown(player));
player.MarkDirtySettings();
RPC.PlaySoundRPC(player.PlayerId, Sounds.TaskComplete);
int spawnProtectionTime = SpawnProtectionTime.GetInt();
+4 -7
View File
@@ -555,20 +555,17 @@ public static class RoomRush
Logger.Info("Time is up, killing everyone who didn't enter the correct room", "RoomRush");
PlayerControl[] lateAapc = Main.AllAlivePlayerControls;
PlayerControl[] playersOutsideRoom = lateAapc.ExceptBy(DonePlayers, x => x.PlayerId).ToArray();
bool everyoneDies = playersOutsideRoom.Length == lateAapc.Length;
if (WinByPointsInsteadOfDeaths.GetBool())
{
if (playersOutsideRoom.Length == lateAapc.Length)
{
Vector2 roomPos = Map.Positions.GetValueOrDefault(RoomGoal, RoomGoal.GetRoomClass().transform.position);
playersOutsideRoom.Do(x => x.TP(roomPos));
}
else playersOutsideRoom.Do(x => x.TP(DonePlayers.RandomElement().GetPlayer()));
Vector2 location = everyoneDies ? Map.Positions.GetValueOrDefault(RoomGoal, RoomGoal.GetRoomClass().transform.position) : DonePlayers.RandomElement().GetPlayer().Pos();
playersOutsideRoom.MassTP(location);
}
else
{
if (playersOutsideRoom.Length == lateAapc.Length) CustomWinnerHolder.ResetAndSetWinner(CustomWinner.None);
playersOutsideRoom.Do(x => x.Suicide());
if (everyoneDies) CustomWinnerHolder.ResetAndSetWinner(CustomWinner.None);
}
StartNewRound();
+14 -65
View File
@@ -1,9 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using AmongUs.GameOptions;
using EHR.Modules;
using EHR.Neutral;
using UnityEngine;
using static EHR.RandomSpawn;
@@ -20,7 +18,7 @@ internal static class SoloPVP
public static Dictionary<byte, int> KBScore = [];
public static int RoundTime;
private static readonly Dictionary<byte, (string Text, long TimeStamp)> NameNotify = [];
private static readonly Dictionary<byte, (string Text, long RemoveTimeStamp)> NameNotify = [];
private static Dictionary<byte, int> BackCountdown = [];
private static Dictionary<byte, long> LastHurt = [];
@@ -179,7 +177,8 @@ internal static class SoloPVP
return;
}
if (NameNotify.TryGetValue(player.PlayerId, out (string Text, long TimeStamp) value1)) name = value1.Text;
if (NameNotify.TryGetValue(player.PlayerId, out (string Text, long RemoveTimeStamp) value1))
name = value1.Text;
}
public static int GetRankFromScore(byte playerId)
@@ -232,37 +231,15 @@ internal static class SoloPVP
{
BackCountdown.Remove(pc.PlayerId);
PlayerHP[pc.PlayerId] = PlayerHPMax[pc.PlayerId];
LastHurt[pc.PlayerId] = Utils.TimeStamp;
Main.AllPlayerSpeed[pc.PlayerId] = Main.RealOptionsData.GetFloat(FloatOptionNames.PlayerSpeedMod);
pc.MarkDirtySettings();
pc.RpcRevive();
RPC.PlaySoundRPC(pc.PlayerId, Sounds.TaskComplete);
pc.RpcGuardAndKill();
if (pc.inVent) pc.MyPhysics.RpcBootFromVent(ShipStatus.Instance.AllVents.RandomElement().Id);
else SpawnMap.GetSpawnMap().RandomTeleport(pc);
SpawnMap.GetSpawnMap().RandomTeleport(pc);
}
private static void OnPlayerDead(PlayerControl target)
{
target.MyPhysics.RpcCancelPet();
PetsHelper.RpcRemovePet(target);
Main.AllPlayerSpeed[target.PlayerId] = Main.MinSpeed;
target.MarkDirtySettings();
if (target.walkingToVent || target.inVent || target.inMovingPlat || target.onLadder || target.MyPhysics.Animations.IsPlayingEnterVentAnimation())
{
LateTask.New(() =>
{
target.MyPhysics.RpcExitVent(Main.LastEnteredVent.TryGetValue(target.PlayerId, out var vent) ? vent.Id : 2);
LateTask.New(() => target.TP(Pelican.GetBlackRoomPS()), 0.6f, log: false);
}, 1f, log: false);
}
else
target.TP(Pelican.GetBlackRoomPS());
target.ExileTemporarily();
BackCountdown.TryAdd(target.PlayerId, KB_ResurrectionWaitingTime.GetInt());
}
@@ -279,6 +256,7 @@ internal static class SoloPVP
addRate *= KB_KillBonusMultiplier.GetFloat();
if (killer.IsHost()) addRate /= 2f;
var text = string.Empty;
float addin;
switch (IRandom.Instance.Next(0, 4))
@@ -286,31 +264,26 @@ internal static class SoloPVP
case 0:
addin = PlayerHPMax[killer.PlayerId] * addRate;
PlayerHPMax[killer.PlayerId] += addin;
AddNameNotify(killer, string.Format(Translator.GetString("KB_Buff_HPMax"), addin.ToString("0.0#####")));
text = string.Format(Translator.GetString("KB_Buff_HPMax"), addin.ToString("0.0#####"));
break;
case 1:
addin = PlayerHPReco[killer.PlayerId] * addRate * 2;
PlayerHPReco[killer.PlayerId] += addin;
AddNameNotify(killer, string.Format(Translator.GetString("KB_Buff_HPReco"), addin.ToString("0.0#####")));
text = string.Format(Translator.GetString("KB_Buff_HPReco"), addin.ToString("0.0#####"));
break;
case 2:
addin = PlayerATK[killer.PlayerId] * addRate;
PlayerATK[killer.PlayerId] += addin;
AddNameNotify(killer, string.Format(Translator.GetString("KB_Buff_ATK"), addin.ToString("0.0#####")));
text = string.Format(Translator.GetString("KB_Buff_ATK"), addin.ToString("0.0#####"));
break;
case 3:
addin = Math.Max(PlayerDF[killer.PlayerId], 1f) * addRate * 8;
PlayerDF[killer.PlayerId] += addin;
AddNameNotify(killer, string.Format(Translator.GetString("KB_Buff_DF"), addin.ToString("0.0#####")));
text = string.Format(Translator.GetString("KB_Buff_DF"), addin.ToString("0.0#####"));
break;
}
}
private static void AddNameNotify(PlayerControl pc, string text, int time = 5)
{
NameNotify.Remove(pc.PlayerId);
NameNotify.Add(pc.PlayerId, (text, Utils.TimeStamp + time));
Utils.NotifyRoles(SpecifySeer: pc, SpecifyTarget: pc);
NameNotify[killer.PlayerId] = (text, Utils.TimeStamp + 5);
}
//[HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.FixedUpdate))]
@@ -323,35 +296,11 @@ internal static class SoloPVP
byte id = __instance.PlayerId;
if (!GameStates.IsInTask || ExileController.Instance || !Main.IntroDestroyed || Options.CurrentGameMode != CustomGameMode.SoloKombat || !AmongUsClient.Instance.AmHost || id >= 254) return;
bool soloAlive = __instance.SoloAlive();
bool inVent = __instance.inVent;
try
{
Vector2 pos = Pelican.GetBlackRoomPS();
float dis = Vector2.Distance(pos, __instance.Pos());
switch (soloAlive)
{
case false when !inVent && !__instance.walkingToVent && !__instance.MyPhysics.Animations.IsPlayingEnterVentAnimation() && dis > 1f:
{
__instance.TP(pos);
break;
}
case true when !inVent && dis < 1.1f:
{
SpawnMap.GetSpawnMap().RandomTeleport(__instance);
break;
}
}
}
catch (Exception e) { Utils.ThrowException(e); }
long now = Utils.TimeStamp;
if (LastCountdownTime[id] == now) return;
LastCountdownTime[id] = now;
if (LastHurt[id] + KB_RecoverAfterSecond.GetInt() < now && PlayerHP[id] < PlayerHPMax[id] && soloAlive && !inVent)
if (LastHurt[id] + KB_RecoverAfterSecond.GetInt() < now && PlayerHP[id] < PlayerHPMax[id] && __instance.SoloAlive() && !__instance.inVent)
{
PlayerHP[id] += PlayerHPReco[id];
PlayerHP[id] = Math.Min(PlayerHPMax[id], PlayerHP[id]);
@@ -363,7 +312,7 @@ internal static class SoloPVP
if (BackCountdown[id] <= 0) OnPlayerBack(__instance);
}
if (NameNotify.TryGetValue(id, out (string Text, long TimeStamp) nameNotify) && nameNotify.TimeStamp < now)
if (NameNotify.TryGetValue(id, out (string Text, long RemoveTimeStamp) nameNotify) && nameNotify.RemoveTimeStamp < now)
NameNotify.Remove(id);
+16 -47
View File
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using AmongUs.InnerNet.GameDataMessages;
using EHR;
using EHR.Crewmate;
using EHR.Modules;
@@ -173,62 +174,30 @@ namespace EHR
msg.StartMessage(5);
msg.Write(AmongUsClient.Instance.GameId);
msg.StartMessage(4);
msg.WritePacked(playerControl.SpawnId);
msg.WritePacked(-2);
msg.Write((byte)SpawnFlags.None);
InnerNetObject[] componentsInChildren = playerControl.GetComponentsInChildren<InnerNetObject>();
msg.WritePacked(componentsInChildren.Length);
for (int index = 0; index < componentsInChildren.Length; ++index)
{
InnerNetObject innerNetObject = componentsInChildren[index];
innerNetObject.OwnerId = -2;
innerNetObject.SpawnFlags = SpawnFlags.None;
if (innerNetObject.NetId == 0U)
{
innerNetObject.NetId = AmongUsClient.Instance.NetIdCnt++;
InnerNetObjectCollection allObjects = AmongUsClient.Instance.allObjects;
allObjects.allObjects.Add(innerNetObject);
allObjects.allObjectsFast.Add(innerNetObject.NetId, innerNetObject);
}
msg.WritePacked(innerNetObject.NetId);
msg.StartMessage(1);
innerNetObject.Serialize(msg, true);
msg.EndMessage();
}
SpawnGameDataMessage item = AmongUsClient.Instance.CreateSpawnMessage(playerControl, -2, SpawnFlags.None);
item.SerializeValues(msg);
msg.EndMessage();
msg.EndMessage();
AmongUsClient.Instance.SendOrDisconnect(msg);
msg.Recycle();
if (GameStates.CurrentServerType == GameStates.ServerType.Vanilla)
{
MessageWriter msg2 = MessageWriter.Get(SendOption.Reliable);
msg2.StartMessage(6);
msg2.Write(AmongUsClient.Instance.GameId);
msg2.WritePacked(int.MaxValue);
for (uint i = 1; i <= 3; ++i)
{
msg2.StartMessage(4);
msg2.WritePacked(2U);
msg2.WritePacked(-2);
msg2.Write((byte)SpawnFlags.None);
msg2.WritePacked(1);
msg2.WritePacked(AmongUsClient.Instance.NetIdCnt - i);
msg2.StartMessage(1);
msg2.EndMessage();
msg2.EndMessage();
msg.StartMessage(4);
msg.WritePacked(2U);
msg.WritePacked(-2);
msg.Write((byte)SpawnFlags.None);
msg.WritePacked(1);
msg.WritePacked(AmongUsClient.Instance.NetIdCnt - i);
msg.StartMessage(1);
msg.EndMessage();
msg.EndMessage();
}
msg2.EndMessage();
AmongUsClient.Instance.SendOrDisconnect(msg2);
msg2.Recycle();
}
msg.EndMessage();
AmongUsClient.Instance.SendOrDisconnect(msg);
msg.Recycle();
if (PlayerControl.AllPlayerControls.Contains(playerControl))
PlayerControl.AllPlayerControls.Remove(playerControl);
+1
View File
@@ -892,6 +892,7 @@ internal static class CustomRolesHelper
public static bool NeedsUpdateAfterDeath(this CustomRoles role)
{
return role is
CustomRoles.KB_Normal or
CustomRoles.BedWarsPlayer or
CustomRoles.Weatherman or
CustomRoles.Altruist or
+2 -35
View File
@@ -453,26 +453,6 @@ public static class CustomRpcSenderExtensions
.EndRpc();
}
public static bool RpcExitVentDesync(this CustomRpcSender sender, PlayerPhysics physics, int ventId, PlayerControl seer)
{
if (sender == null || physics == null) return false;
int clientId = seer.OwnerId;
if (AmongUsClient.Instance.ClientId == clientId)
{
physics.StopAllCoroutines();
physics.StartCoroutine(physics.CoExitVent(ventId));
return false;
}
sender.AutoStartRpc(physics.NetId, RpcCalls.ExitVent, clientId);
sender.WritePacked(ventId);
sender.EndRpc();
return true;
}
public static bool RpcGuardAndKill(this CustomRpcSender sender, PlayerControl killer, PlayerControl target = null, bool forObserver = false, bool fromSetKCD = false)
{
if (!AmongUsClient.Instance.AmHost)
@@ -635,14 +615,6 @@ public static class CustomRpcSenderExtensions
sender.EndRpc();
}
public static void RpcExileV2(this CustomRpcSender sender, PlayerControl player)
{
player.Exiled();
sender.AutoStartRpc(player.NetId, RpcCalls.Exiled);
sender.EndRpc();
LateTask.New(() => FixedUpdatePatch.LoversSuicide(player.PlayerId), Utils.CalculatePingDelay() * 2f, log: false);
}
public static bool Notify(this CustomRpcSender sender, PlayerControl pc, string text, float time = 6f, bool overrideAll = false, bool log = true, bool setName = true)
{
if (!AmongUsClient.Instance.AmHost || pc == null) return false;
@@ -708,14 +680,9 @@ public static class CustomRpcSenderExtensions
CheckInvalidMovementPatch.LastPosition[pc.PlayerId] = location;
CheckInvalidMovementPatch.ExemptedPlayers.Add(pc.PlayerId);
return true;
}
public static bool TPToRandomVent(this CustomRpcSender sender, PlayerControl pc, bool log = true)
{
Vent vent = ShipStatus.Instance.AllVents.RandomElement();
Logger.Info($"{pc.GetNameWithRole().RemoveHtmlTags()} => {vent.transform.position} (vent)", "TP");
return sender.TP(pc, new(vent.transform.position.x, vent.transform.position.y + 0.3636f), log);
if (sender.sendOption == SendOption.Reliable) Utils.NumSnapToCallsThisRound++;
return true;
}
public static bool NotifyRolesSpecific(this CustomRpcSender sender, PlayerControl seer, PlayerControl target, out CustomRpcSender newSender, out bool senderWasCleared)
+40
View File
@@ -261,6 +261,39 @@ internal static class ExtendedPlayerControl
if (init) Main.PlayerStates[player.PlayerId].InitTask(player);
}
public static void ExileTemporarily(this PlayerControl pc)
{
pc.Exiled();
Main.PlayerStates[pc.PlayerId].SetDead();
CustomRpcSender.Create("Temporary Death", SendOption.Reliable)
.AutoStartRpc(pc.NetId, 4)
.EndRpc()
.SendMessage();
pc.SyncSettings();
if (!pc.AmOwner)
{
var sender = CustomRpcSender.Create("Temporary Death (2)", SendOption.Reliable);
sender.StartMessage(pc.OwnerId);
sender.StartRpc(pc.NetId, RpcCalls.SetRole)
.Write((ushort)RoleTypes.GuardianAngel)
.Write(true)
.EndRpc();
sender.StartRpc(pc.NetId, RpcCalls.ProtectPlayer)
.WriteNetObject(pc)
.Write(0)
.EndRpc();
sender.SendMessage();
}
else
{
pc.SetRole(RoleTypes.GuardianAngel);
pc.Data.Role.SetCooldown();
}
}
public static void RpcSetRoleDesync(this PlayerControl player, RoleTypes role, int clientId, bool setRoleMap = false)
{
if (player == null) return;
@@ -1681,6 +1714,13 @@ internal static class ExtendedPlayerControl
return (pos, roomName);
}
public static void MassTP(this IEnumerable<PlayerControl> players, Vector2 location, bool noCheckState = false, bool log = true)
{
var sender = CustomRpcSender.Create("Mass TP", SendOption.Reliable);
bool hasValue = players.Aggregate(false, (current, pc) => current | sender.TP(pc, location, noCheckState, log));
sender.SendMessage(!hasValue);
}
public static bool TP(this PlayerControl pc, PlayerControl target, bool noCheckState = false, bool log = true)
{
return Utils.TP(pc.NetTransform, target.Pos(), noCheckState, log);
@@ -208,6 +208,11 @@ public sealed class PlayerGameOptionsSender(PlayerControl player) : GameOptionsS
catch (Exception e) { Utils.ThrowException(e); }
goto case CustomGameMode.RoomRush;
case CustomGameMode.SoloKombat:
try { AURoleOptions.GuardianAngelCooldown = 900f; }
catch (Exception e) { Utils.ThrowException(e); }
break;
}
switch (player.GetCustomRoleTypes())
+6 -29
View File
@@ -11,6 +11,7 @@ using System.Text;
using System.Text.RegularExpressions;
using AmongUs.Data;
using AmongUs.GameOptions;
using AmongUs.InnerNet.GameDataMessages;
using EHR.AddOns.Common;
using EHR.AddOns.Crewmate;
using EHR.AddOns.GhostRoles;
@@ -3510,7 +3511,7 @@ public static class Utils
return num switch
{
< 15 when player != null => player.GetNameWithRole().RemoveHtmlTags(),
< 128 when player != null => player.GetNameWithRole().RemoveHtmlTags(),
253 => "Skip",
254 => "None",
255 => "Dead",
@@ -4033,35 +4034,10 @@ public static class Utils
AmongUsClient.Instance.NetIdCnt += 1U;
var sender = CustomRpcSender.Create("Utils.RpcCreateDeadBody", sendOption, true, false);
MessageWriter writer = sender.stream;
writer.StartMessage(5);
writer.Write(AmongUsClient.Instance.GameId);
sender.StartMessage();
writer.StartMessage(4);
writer.WritePacked(playerControl.SpawnId);
writer.WritePacked(-2);
writer.Write((byte)SpawnFlags.None);
InnerNetObject[] componentsInChildren = playerControl.GetComponentsInChildren<InnerNetObject>();
writer.WritePacked(componentsInChildren.Length);
for (var index = 0; index < componentsInChildren.Length; ++index)
{
InnerNetObject innerNetObject = componentsInChildren[index];
innerNetObject.OwnerId = -2;
innerNetObject.SpawnFlags = SpawnFlags.None;
if (innerNetObject.NetId == 0U)
{
innerNetObject.NetId = AmongUsClient.Instance.NetIdCnt++;
InnerNetObjectCollection allObjects = AmongUsClient.Instance.allObjects;
allObjects.allObjects.Add(innerNetObject);
allObjects.allObjectsFast.Add(innerNetObject.NetId, innerNetObject);
}
writer.WritePacked(innerNetObject.NetId);
writer.StartMessage(1);
innerNetObject.Serialize(writer, true);
writer.EndMessage();
}
SpawnGameDataMessage item = AmongUsClient.Instance.CreateSpawnMessage(playerControl, -2, SpawnFlags.None);
item.SerializeValues(writer);
writer.EndMessage();
if (GameStates.CurrentServerType == GameStates.ServerType.Vanilla)
@@ -4082,6 +4058,7 @@ public static class Utils
if (PlayerControl.AllPlayerControls.Contains(playerControl))
PlayerControl.AllPlayerControls.Remove(playerControl);
int baseColorId = playerControl.Data.DefaultOutfit.ColorId;
sender.StartRpc(playerControl.NetId, RpcCalls.SetColor)
.Write(playerControl.Data.NetId)
+12 -3
View File
@@ -1174,10 +1174,19 @@ internal static class StartGameHostPatch
? roleMap.RoleType
: RpcSetRoleReplacer.StoragedData[target.PlayerId];
bool forceDisplayCrewmate = Options.CurrentGameMode == CustomGameMode.Standard && target.Is(Team.Crewmate) && roleType is not (RoleTypes.Crewmate or RoleTypes.Scientist or RoleTypes.Engineer or RoleTypes.Noisemaker or RoleTypes.Tracker or RoleTypes.CrewmateGhost or RoleTypes.GuardianAngel);
if (forceDisplayCrewmate) RpcSetRoleReplacer.OverriddenTeamRevealScreen[target.PlayerId] = roleType;
RoleTypes displayRole = roleType;
target.RpcSetRoleDesync(forceDisplayCrewmate ? RoleTypes.Crewmate : roleType, targetClientId);
if (Options.CurrentGameMode == CustomGameMode.Standard)
{
if (target.Is(Team.Crewmate) && roleType is not (RoleTypes.Crewmate or RoleTypes.Scientist or RoleTypes.Engineer or RoleTypes.Noisemaker or RoleTypes.Tracker or RoleTypes.CrewmateGhost or RoleTypes.GuardianAngel))
displayRole = RoleTypes.Crewmate;
if (target.Is(Team.Impostor) && roleType is not (RoleTypes.Impostor or RoleTypes.Shapeshifter or RoleTypes.Phantom or RoleTypes.ImpostorGhost))
displayRole = RoleTypes.Impostor;
}
if (displayRole != roleType) RpcSetRoleReplacer.OverriddenTeamRevealScreen[target.PlayerId] = roleType;
target.RpcSetRoleDesync(displayRole, targetClientId);
}
catch (Exception e) { Utils.ThrowException(e); }
}
+6 -5
View File
@@ -86,22 +86,23 @@ internal static class RpcMurderPlayerPatch
__instance.MurderPlayer(target, murderResultFlags);
var sender = CustomRpcSender.Create("RpcMurderPlayer", SendOption.Reliable);
sender.StartMessage();
if (Main.Invisible.Contains(target.PlayerId) && murderResultFlags == MurderResultFlags.Succeeded)
{
sender.AutoStartRpc(target.NetTransform.NetId, RpcCalls.SnapTo)
sender.StartRpc(target.NetTransform.NetId, RpcCalls.SnapTo)
.WriteVector2(new Vector2(50f, 50f))
.Write((ushort)(target.NetTransform.lastSequenceId + 16383))
.EndRpc();
sender.AutoStartRpc(target.NetTransform.NetId, RpcCalls.SnapTo)
sender.StartRpc(target.NetTransform.NetId, RpcCalls.SnapTo)
.WriteVector2(new Vector2(50f, 50f))
.Write((ushort)(target.NetTransform.lastSequenceId + 32767))
.EndRpc();
sender.AutoStartRpc(target.NetTransform.NetId, RpcCalls.SnapTo)
sender.StartRpc(target.NetTransform.NetId, RpcCalls.SnapTo)
.WriteVector2(new Vector2(50f, 50f))
.Write((ushort)(target.NetTransform.lastSequenceId + 32767 + 16383))
.EndRpc();
sender.AutoStartRpc(target.NetTransform.NetId, RpcCalls.SnapTo)
sender.StartRpc(target.NetTransform.NetId, RpcCalls.SnapTo)
.WriteVector2(target.transform.position)
.Write(target.NetTransform.lastSequenceId)
.EndRpc();
@@ -109,7 +110,7 @@ internal static class RpcMurderPlayerPatch
NumSnapToCallsThisRound += 4;
}
sender.AutoStartRpc(__instance.NetId, RpcCalls.MurderPlayer)
sender.StartRpc(__instance.NetId, RpcCalls.MurderPlayer)
.WriteNetObject(target)
.Write((int)murderResultFlags)
.EndRpc();