mirror of
https://github.com/Gurge44/EndlessHostRoles.git
synced 2026-10-20 01:46:25 +00:00
temp solution for kicking
This commit is contained in:
1 parent
7819572d1f
commit
a8ac3e840a
20 files changed
+68
-61
No files matched your search
@@ -851,7 +851,7 @@ public static class BedWars
|
||||
NameNotifyManager.Notifies.Remove(pc.PlayerId);
|
||||
RPC.PlaySoundRPC(pc.PlayerId, Sounds.TaskComplete);
|
||||
pc.ReviveFromTemporaryExile();
|
||||
pc.RpcSetColor(Team.GetColorId());
|
||||
// pc.RpcSetColor(Team.GetColorId());
|
||||
pc.TP(Base.SpawnPosition);
|
||||
pc.SetChatVisible(true);
|
||||
Utils.NotifyRoles(SpecifyTarget: pc, SendOption: SendOption.None);
|
||||
|
||||
@@ -368,7 +368,7 @@ public static class CaptureTheFlag
|
||||
players.Remove(player);
|
||||
PlayerTeams[player.PlayerId] = CTFTeam.Blue;
|
||||
bluePlayers.Add(player.PlayerId);
|
||||
player.RpcSetColor(1);
|
||||
// player.RpcSetColor(1);
|
||||
yield return WaitFrameIfNecessary();
|
||||
}
|
||||
|
||||
@@ -376,7 +376,7 @@ public static class CaptureTheFlag
|
||||
{
|
||||
PlayerTeams[player.PlayerId] = CTFTeam.Yellow;
|
||||
yellowPlayers.Add(player.PlayerId);
|
||||
player.RpcSetColor(5);
|
||||
// player.RpcSetColor(5);
|
||||
yield return WaitFrameIfNecessary();
|
||||
}
|
||||
|
||||
|
||||
@@ -970,7 +970,7 @@ public static class KingOfTheZones
|
||||
|
||||
yield return null;
|
||||
|
||||
foreach (PlayerControl player in Main.EnumerateAlivePlayerControls())
|
||||
/*foreach (PlayerControl player in Main.EnumerateAlivePlayerControls())
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -980,7 +980,7 @@ public static class KingOfTheZones
|
||||
player.RpcSetColor(colorId);
|
||||
}
|
||||
catch (Exception e) { Utils.ThrowException(e); }
|
||||
}
|
||||
}*/
|
||||
|
||||
yield return null;
|
||||
|
||||
|
||||
@@ -329,7 +329,7 @@ public static class TheMindGame
|
||||
foreach (PlayerControl pc in players)
|
||||
{
|
||||
Groups[pc.PlayerId] = group;
|
||||
pc.RpcSetColor(group.GetColorId());
|
||||
// pc.RpcSetColor(group.GetColorId());
|
||||
pc.TP(location);
|
||||
ids.Add(pc.PlayerId);
|
||||
}
|
||||
@@ -404,7 +404,7 @@ public static class TheMindGame
|
||||
|
||||
Round = 2;
|
||||
|
||||
DefaultColorIds.DoIf(x => x.Key && x.Value is >= byte.MinValue and <= byte.MaxValue, x => x.Key.RpcSetColor((byte)x.Value));
|
||||
// DefaultColorIds.DoIf(x => x.Key && x.Value is >= byte.MinValue and <= byte.MaxValue, x => x.Key.RpcSetColor((byte)x.Value));
|
||||
|
||||
yield return NotifyEveryone("TMG.Notify.Round", 2, 2);
|
||||
if (Stop) yield break;
|
||||
|
||||
@@ -103,6 +103,7 @@ internal static class CustomRoleSelector
|
||||
|
||||
switch (role)
|
||||
{
|
||||
case CustomRoles.Camouflager or CustomRoles.Magistrate or CustomRoles.Devourer or CustomRoles.Echo or CustomRoles.Venerer or CustomRoles.Amogus or CustomRoles.Shadow or CustomRoles.MoonDancer or CustomRoles.Merchant or CustomRoles.Catalyst or CustomRoles.Doppelganger when GameStates.CurrentServerType == GameStates.ServerType.Vanilla:
|
||||
case CustomRoles.Bargainer when Main.LIMap:
|
||||
case CustomRoles.AntiAdminer when Main.LIMap:
|
||||
case CustomRoles.CameraMan when Main.LIMap:
|
||||
@@ -569,6 +570,7 @@ internal static class CustomRoleSelector
|
||||
|
||||
switch (role)
|
||||
{
|
||||
case CustomRoles.Disco or CustomRoles.BananaMan or CustomRoles.Hidden or CustomRoles.Concealer when GameStates.CurrentServerType == GameStates.ServerType.Vanilla:
|
||||
case CustomRoles.Concealer or CustomRoles.Hidden when Options.AnonymousBodies.GetBool():
|
||||
case CustomRoles.Autopsy when Options.EveryoneSeesDeathReasons.GetBool():
|
||||
case CustomRoles.Gravestone when Options.EveryoneSeesDeadPlayersRoles.GetBool():
|
||||
|
||||
@@ -129,7 +129,7 @@ public class CustomRpcSender
|
||||
{
|
||||
// StartMessage processing
|
||||
if (currentState == State.InRootMessage)
|
||||
EndMessage(startNew: !packed);
|
||||
EndMessage(startNew: !packed && messages < AmongUsClient.Instance.GetMaxMessagePackingLimit());
|
||||
else if (messages > 0) // state is Ready or InRootPackedMessage
|
||||
{
|
||||
if (currentState == State.InRootPackedMessage)
|
||||
@@ -282,6 +282,7 @@ public class CustomRpcSender
|
||||
doneStreams.Add(stream);
|
||||
stream = MessageWriter.Get(sendOption);
|
||||
messages = 0;
|
||||
currentState = State.Ready;
|
||||
StartPackedMessage();
|
||||
}
|
||||
else
|
||||
|
||||
@@ -499,7 +499,7 @@ internal static class ExtendedPlayerControl
|
||||
if (Options.AnonymousBodies.GetBool() && Main.AllPlayerNames.TryGetValue(player.PlayerId, out string name))
|
||||
RpcChangeSkin(player, new NetworkedPlayerInfo.PlayerOutfit().Set(name, 15, "", "", "", "", ""), sender);
|
||||
|
||||
Camouflage.RpcSetSkin(player, sender: sender);
|
||||
// Camouflage.RpcSetSkin(player, sender: sender);
|
||||
sender.SyncSettings(player);
|
||||
|
||||
sender.SendMessage();
|
||||
@@ -713,27 +713,6 @@ internal static class ExtendedPlayerControl
|
||||
if (!forced) Logger.Info($"{player.GetNameWithRole()}'s role basis was changed to {newRoleType} ({newCustomRole}) (from role: {playerRole}) - oldRoleIsDesync: {oldRoleIsDesync}, newRoleIsDesync: {newRoleIsDesync}", "RpcChangeRoleBasis");
|
||||
}
|
||||
|
||||
public void RpcShapeshiftDesync(PlayerControl target, PlayerControl seer, bool animate)
|
||||
{
|
||||
try
|
||||
{
|
||||
int clientId = seer.OwnerId;
|
||||
|
||||
if (AmongUsClient.Instance.ClientId == clientId)
|
||||
{
|
||||
try { player.Shapeshift(target, animate); }
|
||||
catch (Exception e) { ThrowException(e); }
|
||||
return;
|
||||
}
|
||||
|
||||
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(player.NetId, (byte)RpcCalls.Shapeshift, SendOption.Reliable, clientId);
|
||||
writer.WriteNetObject(target);
|
||||
writer.Write(animate);
|
||||
AmongUsClient.Instance.FinishRpcImmediately(writer);
|
||||
}
|
||||
catch (Exception e) { ThrowException(e); }
|
||||
}
|
||||
|
||||
public bool SyncGeneralOptions()
|
||||
{
|
||||
if (!AmongUsClient.Instance.AmHost || !GameStates.IsInGame || !DoRPC) return false;
|
||||
@@ -1512,7 +1491,7 @@ internal static class ExtendedPlayerControl
|
||||
if (phantom && Options.CurrentGameMode != CustomGameMode.Standard) return;
|
||||
if (!Main.Invisible.Add(player.PlayerId)) return;
|
||||
|
||||
player.RpcSetPet("");
|
||||
// player.RpcSetPet("");
|
||||
|
||||
if (!(phantom && PlayerControl.LocalPlayer.IsImpostor()))
|
||||
player.MakeInvisible();
|
||||
|
||||
@@ -811,7 +811,7 @@ public sealed class PlayerGameOptionsSender(PlayerControl player) : GameOptionsS
|
||||
if (Options.GhostCanSeeOtherVotes.GetBool() && !player.IsAlive()) opt.SetBool(BoolOptionNames.AnonymousVotes, false);
|
||||
|
||||
if (Options.AdditionalEmergencyCooldown.GetBool() &&
|
||||
Options.AdditionalEmergencyCooldownThreshold.GetInt() <= Utils.AllAlivePlayersCount)
|
||||
Options.AdditionalEmergencyCooldownThreshold.GetInt() <= Main.AllAlivePlayerControlsCount)
|
||||
{
|
||||
opt.SetInt(
|
||||
Int32OptionNames.EmergencyCooldown,
|
||||
|
||||
@@ -12,9 +12,10 @@ public static class PetsHelper
|
||||
SetPet(pc, petId);
|
||||
}
|
||||
|
||||
public static void SetPet(PlayerControl pc, string petId)
|
||||
public static void SetPet(PlayerControl pc, string petId, CustomRpcSender writer = null)
|
||||
{
|
||||
var sender = CustomRpcSender.Create("PetsHelper.SetPet", SendOption.Reliable);
|
||||
if (GameStates.CurrentServerType == GameStates.ServerType.Vanilla) return;
|
||||
var sender = writer ?? CustomRpcSender.Create("PetsHelper.SetPet", SendOption.Reliable);
|
||||
|
||||
try { pc.SetPet(petId); }
|
||||
catch { }
|
||||
@@ -26,6 +27,8 @@ public static class PetsHelper
|
||||
.Write(petId)
|
||||
.Write(pc.GetNextRpcSequenceId(RpcCalls.SetPetStr))
|
||||
.EndRpc();
|
||||
|
||||
if (writer != null) return;
|
||||
|
||||
sender.SendMessage();
|
||||
}
|
||||
|
||||
+3
-5
@@ -97,9 +97,7 @@ public static class Utils
|
||||
private static readonly Dictionary<byte, (string Text, int Duration, bool Long)> LongRoleDescriptions = [];
|
||||
|
||||
public static bool DoRPC => AmongUsClient.Instance.AmHost && Main.EnumeratePlayerControls().Any(x => x.IsModdedClient() && !x.IsHost());
|
||||
public static int TotalTaskCount => Main.RealOptionsData.GetInt(Int32OptionNames.NumCommonTasks) + Main.RealOptionsData.GetInt(Int32OptionNames.NumLongTasks) + Main.RealOptionsData.GetInt(Int32OptionNames.NumShortTasks);
|
||||
private static int AllPlayersCount => Main.PlayerStates.Values.Count(state => state.countTypes != CountTypes.OutOfGame);
|
||||
public static int AllAlivePlayersCount => Main.EnumerateAlivePlayerControls().Count(pc => !pc.Is(CountTypes.OutOfGame));
|
||||
public static int TotalTaskCountForReset => Main.RealOptionsData.GetInt(Int32OptionNames.NumLongTasks) + Main.RealOptionsData.GetInt(Int32OptionNames.NumShortTasks);
|
||||
public static bool IsAllAlive => Main.PlayerStates.Values.All(state => state.countTypes == CountTypes.OutOfGame || !state.IsDead);
|
||||
|
||||
public static void ErrorEnd(string text)
|
||||
@@ -3758,7 +3756,7 @@ public static class Utils
|
||||
|
||||
public static bool RpcChangeSkin(PlayerControl pc, NetworkedPlayerInfo.PlayerOutfit newOutfit, CustomRpcSender writer = null, SendOption sendOption = SendOption.Reliable)
|
||||
{
|
||||
if (!AmongUsClient.Instance.AmHost) return false;
|
||||
if (!AmongUsClient.Instance.AmHost || GameStates.CurrentServerType == GameStates.ServerType.Vanilla) return false;
|
||||
|
||||
if (pc.Is(CustomRoles.BananaMan))
|
||||
newOutfit = BananaMan.GetOutfit(Main.AllPlayerNames.GetValueOrDefault(pc.PlayerId, "Banana"));
|
||||
@@ -4425,7 +4423,7 @@ public static class Utils
|
||||
}
|
||||
}
|
||||
|
||||
ContAliveLog.Append(" All: ").Append(AllAlivePlayersCount).Append('/').Append(AllPlayersCount);
|
||||
ContAliveLog.Append(" All: ").Append(Main.AllAlivePlayerControlsCount).Append('/').Append(PlayerControl.AllPlayerControls.Count);
|
||||
Logger.Info(ContAliveLog.ToString(), "CountAlivePlayers");
|
||||
}
|
||||
|
||||
|
||||
@@ -2067,7 +2067,7 @@ internal static class ChatCommands
|
||||
return;
|
||||
}
|
||||
|
||||
player.RpcSetColor(color);
|
||||
// player.RpcSetColor(color);
|
||||
Utils.SendMessage(string.Format(GetString("Message.SetColor"), subArgs), player.PlayerId, importance: MessageImportance.Low);
|
||||
}
|
||||
|
||||
|
||||
@@ -84,10 +84,10 @@ internal static class GameEndChecker
|
||||
Ended = true;
|
||||
LoadingEndScreen = true;
|
||||
|
||||
foreach (var pc in Main.CachedAllPlayerControls())
|
||||
/*foreach (var pc in Main.CachedAllPlayerControls())
|
||||
{
|
||||
Camouflage.RpcSetSkin(pc, true, true, true);
|
||||
}
|
||||
}*/
|
||||
|
||||
NameNotifyManager.Reset();
|
||||
NotifyRoles(ForceLoop: true);
|
||||
|
||||
@@ -1247,14 +1247,19 @@ internal static class IntroCutsceneDestroyPatch
|
||||
{
|
||||
void GrantPetForEveryone()
|
||||
{
|
||||
if (GameStates.CurrentServerType == GameStates.ServerType.Vanilla) return;
|
||||
CustomRpcSender sender = CustomRpcSender.Create(nameof(GrantPetForEveryone), SendOption.Reliable);
|
||||
|
||||
foreach (PlayerControl pc in aapc)
|
||||
{
|
||||
if (pc.Is(CustomRoles.GM)) continue;
|
||||
|
||||
string petId = PetsHelper.GetPetId();
|
||||
PetsHelper.SetPet(pc, petId);
|
||||
PetsHelper.SetPet(pc, petId, sender);
|
||||
Logger.Info($"{pc.GetNameWithRole()} => {GetString(petId)} Pet", "PetAssign");
|
||||
}
|
||||
|
||||
sender.SendMessage();
|
||||
}
|
||||
|
||||
LateTask.New(GrantPetForEveryone, 3f, "Grant Pet For Everyone");
|
||||
@@ -1269,7 +1274,7 @@ internal static class IntroCutsceneDestroyPatch
|
||||
|
||||
foreach (PlayerControl pc in aapc)
|
||||
{
|
||||
if (pc.AmOwner) continue; // Skip the host
|
||||
if (pc.AmOwner || pc.OwnerId < 0) continue; // Skip the host
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
@@ -637,11 +637,11 @@ internal static class MurderPlayerPatch
|
||||
|
||||
RandomSpawn.CustomNetworkTransformHandleRpcPatch.HasSpawned.Add(__instance.PlayerId);
|
||||
|
||||
if (!target.IsProtected() && !Doppelganger.DoppelVictim.ContainsKey(target.PlayerId) && !Camouflage.ResetSkinAfterDeathPlayers.Contains(target.PlayerId))
|
||||
/*if (!target.IsProtected() && !Doppelganger.DoppelVictim.ContainsKey(target.PlayerId) && !Camouflage.ResetSkinAfterDeathPlayers.Contains(target.PlayerId))
|
||||
{
|
||||
Camouflage.ResetSkinAfterDeathPlayers.Add(target.PlayerId);
|
||||
LateTask.New(() => Camouflage.RpcSetSkin(target, true), 0.2f, log: false);
|
||||
}
|
||||
}*/
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -896,7 +896,7 @@ internal static class ShapeshiftPatch
|
||||
|
||||
if (!AmongUsClient.Instance.AmHost) return true;
|
||||
|
||||
if (!shapeshifting) Camouflage.RpcSetSkin(shapeshifter);
|
||||
if (!shapeshifting) /*Camouflage.RpcSetSkin(shapeshifter);*/ {}
|
||||
else
|
||||
{
|
||||
PlagueBearer.CheckAndSpreadInfection(shapeshifter, target);
|
||||
@@ -1412,8 +1412,8 @@ internal static class ReportDeadBodyPatch
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Main.CheckShapeshift.ContainsKey(pc.PlayerId) && !Doppelganger.DoppelVictim.ContainsKey(pc.PlayerId))
|
||||
Camouflage.RpcSetSkin(pc, revertToDefault: true);
|
||||
/*if (Main.CheckShapeshift.ContainsKey(pc.PlayerId) && !Doppelganger.DoppelVictim.ContainsKey(pc.PlayerId))
|
||||
Camouflage.RpcSetSkin(pc, revertToDefault: true);*/
|
||||
|
||||
if (Main.CurrentMap == MapNames.Fungle && (pc.IsMushroomMixupActive() || IsActive(SystemTypes.MushroomMixupSabotage)))
|
||||
pc.FixMixedUpOutfit();
|
||||
|
||||
@@ -52,7 +52,7 @@ public class Tar : RoleBase
|
||||
|
||||
Main.AllPlayerSpeed[pc.PlayerId] = Main.MinSpeed;
|
||||
Main.PlayerStates[pc.PlayerId].IsBlackOut = true;
|
||||
pc.RpcSetColor(6);
|
||||
// pc.RpcSetColor(6);
|
||||
pc.MarkDirtySettings();
|
||||
|
||||
Timer = new CountdownTimer(AbilityDuration.GetFloat(), () =>
|
||||
@@ -61,7 +61,7 @@ public class Tar : RoleBase
|
||||
if (!pc || !pc.IsAlive()) return;
|
||||
Main.AllPlayerSpeed[pc.PlayerId] = Main.RealOptionsData.GetFloat(FloatOptionNames.PlayerSpeedMod);
|
||||
Main.PlayerStates[pc.PlayerId].IsBlackOut = false;
|
||||
pc.RpcSetColor((byte)ColorId);
|
||||
// pc.RpcSetColor((byte)ColorId);
|
||||
pc.MarkDirtySettings();
|
||||
}, cancelOnMeeting: false, onCanceled: () =>
|
||||
{
|
||||
@@ -93,7 +93,7 @@ public class Tar : RoleBase
|
||||
Timer = null;
|
||||
Main.AllPlayerSpeed[TarId] = Main.RealOptionsData.GetFloat(FloatOptionNames.PlayerSpeedMod);
|
||||
Main.PlayerStates[TarId].IsBlackOut = false;
|
||||
TarId.GetPlayer()?.RpcSetColor((byte)ColorId);
|
||||
// TarId.GetPlayer()?.RpcSetColor((byte)ColorId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -89,7 +89,7 @@ public class Astral : RoleBase
|
||||
GhostRolesManager.RemoveGhostRole(pc.PlayerId);
|
||||
ReportDeadBodyPatch.AlreadyReportedBodies.Remove(pc.PlayerId);
|
||||
pc.RpcSetRoleGlobal(Options.UsePets.GetBool() ? RoleTypes.Crewmate : RoleTypes.Engineer);
|
||||
Camouflage.RpcSetSkin(pc);
|
||||
// Camouflage.RpcSetSkin(pc);
|
||||
|
||||
if (onMeeting) return;
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ internal class Haunter : IGhostRole
|
||||
|
||||
taskState.HasTasks = true;
|
||||
taskState.CompletedTasksCount = 0;
|
||||
taskState.AllTasksCount = Utils.TotalTaskCount - Main.RealOptionsData.GetInt(Int32OptionNames.NumCommonTasks);
|
||||
taskState.AllTasksCount = Utils.TotalTaskCountForReset - Main.RealOptionsData.GetInt(Int32OptionNames.NumCommonTasks);
|
||||
|
||||
pc.RpcResetTasks();
|
||||
pc.SyncSettings();
|
||||
|
||||
@@ -24,7 +24,7 @@ internal class Phantasm : IGhostRole
|
||||
|
||||
taskState.HasTasks = true;
|
||||
taskState.CompletedTasksCount = 0;
|
||||
taskState.AllTasksCount = Utils.TotalTaskCount - Main.RealOptionsData.GetInt(Int32OptionNames.NumCommonTasks);
|
||||
taskState.AllTasksCount = Utils.TotalTaskCountForReset - Main.RealOptionsData.GetInt(Int32OptionNames.NumCommonTasks);
|
||||
|
||||
pc.RpcResetTasks();
|
||||
pc.SyncSettings();
|
||||
|
||||
@@ -87,10 +87,10 @@ public class Exclusionary : RoleBase
|
||||
sender.StartMessage(target.OwnerId);
|
||||
}
|
||||
|
||||
sender.StartRpc(player.NetId, RpcCalls.SetPetStr)
|
||||
/*sender.StartRpc(player.NetId, RpcCalls.SetPetStr)
|
||||
.Write("")
|
||||
.Write(player.GetNextRpcSequenceId(RpcCalls.SetPetStr))
|
||||
.EndRpc();
|
||||
.EndRpc();*/
|
||||
sender.StartRpc(player.NetTransform.NetId, RpcCalls.SnapTo)
|
||||
.WriteVector2(new Vector2(50f, 50f))
|
||||
.Write(player.NetTransform.lastSequenceId)
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
using AmongUs.GameOptions;
|
||||
using System;
|
||||
using AmongUs.GameOptions;
|
||||
using Hazel;
|
||||
using InnerNet;
|
||||
|
||||
namespace EHR.Roles;
|
||||
|
||||
@@ -47,17 +50,33 @@ public class Fakeshifter : RoleBase
|
||||
{
|
||||
MarkedId = target.PlayerId;
|
||||
PlayerControl randomPlayer = Main.CachedAlivePlayerControls().Without(target).RandomElement();
|
||||
bool hasValue = false;
|
||||
CustomRpcSender sender = CustomRpcSender.Create("Fakeshifter", SendOption.Reliable);
|
||||
sender.StartPackedMessage();
|
||||
foreach (var pc in Main.CachedAlivePlayerControls())
|
||||
{
|
||||
if (pc.PlayerId == target.PlayerId) continue;
|
||||
target.RpcShapeshiftDesync(randomPlayer, pc, false);
|
||||
if (pc.PlayerId == target.PlayerId || pc.OwnerId < 0) continue;
|
||||
|
||||
if (pc.AmOwner)
|
||||
{
|
||||
try { target.Shapeshift(randomPlayer, false); } catch { }
|
||||
continue;
|
||||
}
|
||||
|
||||
sender.AutoStartRpc(target.NetId, RpcCalls.Shapeshift, pc.OwnerId)
|
||||
.WriteNetObject(randomPlayer)
|
||||
.Write(false)
|
||||
.EndRpc();
|
||||
|
||||
hasValue = true;
|
||||
}
|
||||
sender.SendMessage(dispose: !hasValue);
|
||||
shapeshifter.RpcRemoveAbilityUse();
|
||||
LateTask.New(() =>
|
||||
{
|
||||
if (target.IsAlive())
|
||||
{
|
||||
target.RpcShapeshift(target, true);
|
||||
target.RpcShapeshift(target, false);
|
||||
MarkedId = byte.MaxValue;
|
||||
}
|
||||
}, AbilityDuration.GetFloat(), "Fakeshifter Ability Finish");
|
||||
|
||||
Reference in new issue
Block a user