loads of fixes

This commit is contained in:
Gurge44 committed 2025-05-03 12:00:34 +02:00
1 parent 982c369c50
commit 09f0f8af2b
22 files changed
+90 -55

No files matched your search

+1 -3
View File
@@ -317,8 +317,6 @@ public static class CaptureTheFlag
NetworkedPlayerInfo.PlayerOutfit blueOutfit = BlueOutfit;
NetworkedPlayerInfo.PlayerOutfit yellowOutfit = YellowOutfit;
// var sender = CustomRpcSender.Create("CTF - OnGameStart", SendOption.Reliable);
// var hasValue = false;
Dictionary<byte, CustomRpcSender> senders = [];
Dictionary<byte, bool> hasValue = [];
players.ForEach(x => senders[x.PlayerId] = CustomRpcSender.Create("CTF - OnGameStart", SendOption.Reliable));
@@ -765,7 +763,7 @@ public static class CaptureTheFlag
bool blue = team == CTFTeam.Blue;
int colorId = blue ? 1 : 5;
var sender = CustomRpcSender.Create("CTF - FixedUpdate", SendOption.Reliable);
var sender = CustomRpcSender.Create("CTF - FixedUpdate", SendOption.Reliable, log: false);
var hasValue = false;
if (__instance.CurrentOutfit.ColorId != colorId)
+1 -1
View File
@@ -457,7 +457,7 @@ internal static class CustomHnS
public static void OnCheckMurder(PlayerControl killer, PlayerControl target)
{
if (killer == null || target == null || PlayerRoles[killer.PlayerId].Interface.Team != Team.Impostor || PlayerRoles[target.PlayerId].Interface.Team == Team.Impostor || !IsBlindTime) return;
if (killer == null || target == null || PlayerRoles[killer.PlayerId].Interface.Team != Team.Impostor || PlayerRoles[target.PlayerId].Interface.Team == Team.Impostor || IsBlindTime) return;
killer.Kill(target);
+7 -5
View File
@@ -129,13 +129,13 @@ public static class NaturalDisasters
const float extend = 3.5f;
MapBounds = ((x.Min() - extend, x.Max() + extend), (y.Min() - extend, y.Max() + extend));
GameStartTimeStamp = Utils.TimeStamp + 8;
GameStartTimeStamp = Utils.TimeStamp;
LateTask.New(() =>
{
Main.AllPlayerSpeed = Main.PlayerStates.Keys.ToDictionary(k => k, _ => Main.RealOptionsData.GetFloat(FloatOptionNames.PlayerSpeedMod));
Utils.SyncAllSettings();
}, 11f, log: false);
}, 16f, log: false);
}
public static void ApplyGameOptions(IGameOptions opt, byte id)
@@ -202,7 +202,7 @@ public static class NaturalDisasters
[SuppressMessage("ReSharper", "UnusedMember.Local")]
public static void Postfix(PlayerControl __instance)
{
if (!AmongUsClient.Instance.AmHost || !GameStates.IsInTask || !CustomGameMode.NaturalDisasters.IsActiveOrIntegrated() || Main.HasJustStarted || GameStartTimeStamp + 5 > Utils.TimeStamp || __instance.PlayerId >= 254 || !__instance.IsHost()) return;
if (!AmongUsClient.Instance.AmHost || !GameStates.IsInTask || !CustomGameMode.NaturalDisasters.IsActiveOrIntegrated() || !Main.IntroDestroyed || Main.HasJustStarted || GameStartTimeStamp + 15 > Utils.TimeStamp || __instance.PlayerId >= 254 || !__instance.IsHost()) return;
UpdatePreparingDisasters();
@@ -727,7 +727,8 @@ public static class NaturalDisasters
foreach (PlayerControl pc in Main.AllAlivePlayerControls)
{
bool inRange = Vector2.Distance(pc.Pos(), Position) <= Range;
if ((inRange && AffectedPlayers.Add(pc.PlayerId)) || (!inRange && AffectedPlayers.Remove(pc.PlayerId))) pc.MarkDirtySettings();
if ((inRange && AffectedPlayers.Add(pc.PlayerId)) || (!inRange && AffectedPlayers.Remove(pc.PlayerId)))
pc.MarkDirtySettings();
}
}
@@ -816,7 +817,8 @@ public static class NaturalDisasters
_ => false
};
if (Vector2.Distance(pos, Position) <= Range && inWay) pc.Suicide(PlayerState.DeathReason.Drowned);
if (Vector2.Distance(pos, Position) <= Range && inWay)
pc.Suicide(PlayerState.DeathReason.Drowned);
}
if (Count++ < 2) return;
+1 -1
View File
@@ -201,6 +201,6 @@ public class Runner : RoleBase
public override bool CanUseVent(PlayerControl pc, int ventId)
{
return false;
return !IsThisRole(pc);
}
}
+6 -1
View File
@@ -44,10 +44,15 @@ public static class AFKDetector
{
if (!EnableDetector.GetBool() || !GameStates.IsInTask || pc == null || ExemptedPlayers.Contains(pc.PlayerId)) return;
float waitingTime = 10f;
if (MeetingStates.FirstMeeting) waitingTime += 5f;
if (!pc.IsAlive()) waitingTime += 5f;
if (pc.Is(CustomRoles.Truant) && !MeetingStates.FirstMeeting) waitingTime += Options.TruantWaitingTime.GetFloat();
PlayerData[pc.PlayerId] = new()
{
LastPosition = pc.Pos(),
Timer = 10f + (pc.Is(CustomRoles.Truant) ? Options.TruantWaitingTime.GetFloat() : 0f)
Timer = waitingTime
};
ShieldedPlayers.Remove(pc.PlayerId);
+5 -4
View File
@@ -94,16 +94,17 @@ public static class BanManager
if (!AmongUsClient.Instance.AmHost || player == null) return;
string friendCode = player.FriendCode.Replace(':', '#');
string hashedPuid = player.GetHashedPuid();
if (!CheckBanList(friendCode, player.GetHashedPuid()) && !TempBanWhiteList.Contains(player.GetHashedPuid()))
if (!CheckBanList(friendCode, hashedPuid) && !TempBanWhiteList.Contains(hashedPuid))
{
if (player.GetHashedPuid() != "" && player.GetHashedPuid() != null && player.GetHashedPuid() != "e3b0cb855")
if (!string.IsNullOrEmpty(hashedPuid))
{
File.AppendAllText(BanListPath, $"{friendCode},{player.GetHashedPuid()},{player.PlayerName.RemoveHtmlTags()}\n");
File.AppendAllText(BanListPath, $"{friendCode},{hashedPuid},{player.PlayerName.RemoveHtmlTags()}\n");
Logger.SendInGame(string.Format(GetString("Message.AddedPlayerToBanList"), player.PlayerName));
}
else
Logger.Info($"Failed to add player {player.PlayerName.RemoveHtmlTags()}/{friendCode}/{player.GetHashedPuid()} to ban list!", "AddBanPlayer");
Logger.Info($"Failed to add player {player.PlayerName.RemoveHtmlTags()}/{friendCode}/{hashedPuid} to ban list!", "AddBanPlayer");
}
}
+4 -1
View File
@@ -164,6 +164,9 @@ internal static class CustomTeamManager
Dictionary<CustomTeam, HashSet<byte>> aliveTeamPlayers = CustomTeamPlayerIds.ToDictionary(x => x.Key, x => x.Value);
aliveTeamPlayers.Do(x => x.Value.RemoveWhere(p => !Utils.GetPlayerById(p).IsAlive()));
List<CustomTeam> toRemove = aliveTeamPlayers.Where(x => x.Value.Count == 0).Select(x => x.Key).ToList();
toRemove.ForEach(x => aliveTeamPlayers.Remove(x));
CustomTeam team = aliveTeamPlayers.Keys.First();
if (aliveTeamPlayers.Count == 1 && Main.AllAlivePlayerControls.All(x =>
@@ -178,7 +181,7 @@ internal static class CustomTeamManager
return true;
}
}
catch { return false; }
catch (Exception e) { Logger.Error($"Error in CheckCustomTeamGameEnd: {e}", "CustomTeamManager"); }
return false;
}
+5 -4
View File
@@ -62,7 +62,7 @@ internal static class Logger
if (SendToGameList.Contains(tag) || IsAlsoInGame) SendInGame($"[{tag}]{text}");
string log_text;
string logText;
if (level is LogLevel.Error or LogLevel.Fatal && !multiLine && !NowDetailedErrorLog.Contains(tag))
{
@@ -70,7 +70,7 @@ internal static class Logger
StackFrame stack = new(2);
string className = stack.GetMethod()?.ReflectedType?.Name;
string memberName = stack.GetMethod()?.Name;
log_text = $"[{t}][{className}.{memberName}({Path.GetFileName(fileName)}:{lineNumber})][{tag}]{text}";
logText = $"[{t}][{className}.{memberName}({Path.GetFileName(fileName)}:{lineNumber})][{tag}]{text}";
NowDetailedErrorLog.Add(tag);
LateTask.New(() => NowDetailedErrorLog.Remove(tag), 3f, log: false);
}
@@ -79,10 +79,10 @@ internal static class Logger
if (escapeCRLF) text = text.Replace("\r", "\\r").Replace("\n", "\\n");
var t = DateTime.Now.ToString("HH:mm:ss");
log_text = $"[{t}][{tag}]{text}";
logText = $"[{t}][{tag}]{text}";
}
CustomLogger.Instance.Log(level.ToString(), log_text, multiLine);
CustomLogger.Instance.Log(level.ToString(), logText, multiLine);
}
public static void Test(object content, string tag = "======= Test =======", bool escapeCRLF = true, [CallerLineNumber] int lineNumber = 0, [CallerFilePath] string fileName = "", bool multiLine = false)
@@ -178,6 +178,7 @@ public class CustomLogger
else if (new FileInfo(LOGFilePath).Length > 4 * 1024 * 1024) // 4 MB
{
ClearLog(false);
PrivateInstance ??= new();
Logger.SendInGame("The size of the log file exceeded 4 MB and was dumped.");
}
+2 -2
View File
@@ -466,7 +466,7 @@ internal static class EAC
var msg = $"{pc.GetClientId()}|{pc.FriendCode}|{pc.Data.PlayerName}|{pc.GetClient().GetHashedPuid()}|{reason}";
//Cloud.SendData(msg);
Logger.Fatal($"EAC report: {msg}", "EAC Cloud");
if (Options.CheatResponses.GetInt() != 5) Logger.SendInGame(string.Format(GetString("Message.NoticeByEAC"), $"{pc.Data?.PlayerName} | {pc.GetClient().GetHashedPuid()}", reason));
if (Options.CheatResponses.GetInt() != 4) Logger.SendInGame(string.Format(GetString("Message.NoticeByEAC"), $"{pc.Data?.PlayerName} | {pc.GetClient().GetHashedPuid()}", reason));
}
public static bool ReceiveInvalidRpc(PlayerControl pc, byte callId)
@@ -510,7 +510,7 @@ internal static class EAC
select new Message(message, player.PlayerId, title)
).SendMultipleMessages(SendOption.None);
break;
case 4:
case 5:
string hashedPuid = pc.GetClient().GetHashedPuid();
if (!BanManager.TempBanWhiteList.Contains(hashedPuid)) BanManager.TempBanWhiteList.Add(hashedPuid);
+10 -5
View File
@@ -79,8 +79,9 @@ internal static class ExtendedPlayerControl
if (CustomGameMode.RoomRush.IsActiveOrIntegrated()) return true;
if (player.Is(CustomRoles.Trainee) && MeetingStates.FirstMeeting) return false;
if (player.Is(CustomRoles.Blocked) && player.GetClosestVent()?.Id != ventId) return false;
if (!GameStates.IsInTask) return false;
return (player.inVent && player.GetClosestVent()?.Id == ventId) || ((player.CanUseImpostorVentButton() || player.GetRoleTypes() == RoleTypes.Engineer) && Main.PlayerStates.Values.All(x => x.Role.CanUseVent(player, ventId)));
if (!GameStates.IsInTask || ExileController.Instance || AntiBlackout.SkipTasks) return false;
if (player.inVent && player.GetClosestVent()?.Id == ventId) return true;
return (player.CanUseImpostorVentButton() || player.GetRoleTypes() == RoleTypes.Engineer) && Main.PlayerStates.Values.All(x => x.Role.CanUseVent(player, ventId));
}
// Next 2: https://github.com/Rabek009/MoreGamemodes/blob/master/Modules/ExtendedPlayerControl.cs
@@ -1040,7 +1041,7 @@ internal static class ExtendedPlayerControl
}
sender.SendMessage();
}, 0.4f, log: false);
}, 0.6f, log: false);
}
public static void ReactorFlash(this PlayerControl pc, float delay = 0f, float flashDuration = float.NaN)
@@ -1532,9 +1533,10 @@ internal static class ExtendedPlayerControl
void DoKill()
{
var sender = CustomRpcSender.Create("Send Noisemaker Alerts & Kill", SendOption.Reliable);
Main.PlayerStates.Values.DoIf(x => !x.IsDead && x.Role.SeesArrowsToDeadBodies && !x.SubRoles.Contains(CustomRoles.Blind), x => sender.RpcSetRole(target, RoleTypes.Noisemaker, x.Player.GetClientId()));
Vector2 pos = target.Pos();
Main.PlayerStates.Values.DoIf(x => !x.IsDead && x.Role.SeesArrowsToDeadBodies && !x.SubRoles.Contains(CustomRoles.Blind) && x.Player != null, x => LocateArrow.Add(x.Player.PlayerId, pos));
var sender = CustomRpcSender.Create("Kill", SendOption.Reliable);
if (AmongUsClient.Instance.AmClient) killer.MurderPlayer(target, MurderResultFlags.Succeeded);
sender.AutoStartRpc(killer.NetId, 12);
sender.WriteNetObject(target);
@@ -1542,6 +1544,9 @@ internal static class ExtendedPlayerControl
sender.EndRpc();
sender.SendMessage();
if (Main.PlayerStates.TryGetValue(target.PlayerId, out var state) && !state.IsDead)
state.SetDead();
}
}
+2 -1
View File
@@ -129,7 +129,8 @@ public static class Options
"Kick",
"NoticeMe",
"NoticeEveryone",
"OnlyCancel"
"OnlyCancel",
"TempBan"
];
private static readonly string[] ConfirmEjectionsMode =
+12 -15
View File
@@ -3530,21 +3530,18 @@ public static class Utils
{
if (excludeId != byte.MaxValue && pc.PlayerId == excludeId) continue;
if (impShow && pc.Is(Team.Impostor)) impnum++;
else if (nkShow && pc.IsNeutralKiller()) neutralnum++;
else if (covenShow && pc.Is(Team.Coven)) covenNum++;
}
foreach (byte id in Forger.Forges.Keys)
{
if (excludeId != byte.MaxValue && id == excludeId) continue;
var pc = id.GetPlayer();
if (pc == null || (!ExileController.Instance && pc.IsAlive())) continue;
if (impShow && pc.Is(Team.Impostor)) impnum--;
else if (nkShow && pc.IsNeutralKiller()) neutralnum--;
else if (covenShow && pc.Is(Team.Coven)) covenNum--;
if (Forger.Forges.TryGetValue(pc.PlayerId, out var forgedRole))
{
if (impShow && forgedRole.Is(Team.Impostor)) impnum++;
else if (nkShow && forgedRole.IsNK()) neutralnum++;
else if (covenShow && forgedRole.Is(Team.Coven)) covenNum++;
}
else
{
if (impShow && pc.Is(Team.Impostor)) impnum++;
else if (nkShow && pc.IsNeutralKiller()) neutralnum++;
else if (covenShow && pc.Is(Team.Coven)) covenNum++;
}
}
impShow &= impnum > 0;
+5 -1
View File
@@ -489,7 +489,11 @@ internal static class GameEndChecker
if (CustomRoles.Sunnyboy.RoleExist() && aapc.Length > 1) return false;
if (CustomTeamManager.CheckCustomTeamGameEnd()) return true;
if (CustomTeamManager.CheckCustomTeamGameEnd())
{
ResetAndSetWinner(CustomWinner.CustomTeam);
return true;
}
if (aapc.All(x => Main.LoversPlayers.Exists(l => l.PlayerId == x.PlayerId)) && (!Main.LoversPlayers.TrueForAll(x => x.Is(Team.Crewmate)) || !Lovers.CrewLoversWinWithCrew.GetBool()))
{
+5 -2
View File
@@ -1065,8 +1065,11 @@ internal static class IntroCutsceneDestroyPatch
if (CustomGameMode.MoveAndStop.IsActiveOrIntegrated())
MoveAndStop.OnGameStart();
if (CustomGameMode.CaptureTheFlag.IsActiveOrIntegrated())
CaptureTheFlag.OnGameStart();
LateTask.New(() =>
{
if (CustomGameMode.CaptureTheFlag.IsActiveOrIntegrated())
CaptureTheFlag.OnGameStart();
}, 0.2f, log: false);
Utils.CheckAndSetVentInteractions();
+3 -1
View File
@@ -2218,7 +2218,9 @@ internal static class PlayerControlCompleteTaskPatch
try
{
var task = __instance.myTasks[(Index)Convert.ToInt32(idx)] as PlayerTask;
var index = Convert.ToInt32(idx);
if (index >= __instance.myTasks.Count || index < 0) return;
var task = __instance.myTasks[(Index)index] as PlayerTask;
Benefactor.OnTaskComplete(__instance, task);
}
catch (Exception e) { ThrowException(e); }
+5
View File
@@ -82,6 +82,7 @@ gummytub#2962,0f6992415
dollepic#0847,17be4645c // DESTRUCT10
donehoof#2148
huesassy#4051 // Harassment
daytiddly#8682,f5f420927,Wardpatchy // Nuking lobbies
## Griefer
setmolar#4374,藏族顶针
@@ -100,6 +101,10 @@ netgaff#6739,01b5992f0,李克强
## 冒充开发者
polkaoval#0453,自作Modな橋本環奈
## Lagging others' games
tenpalace#1924,6a259fcd9,Goaty
cat#2761,f70d4ddb1,ULC
## Other
tenthrope#3476,Oldishwire
greencorps#9587,4a403fe31,ellsbells
+1
View File
@@ -1232,6 +1232,7 @@
"NoticeMe": "Notify me",
"NoticeEveryone": "Notify everyone",
"OnlyCancel": "Cancel Action Only",
"TempBan": "Ban For This Session Only",
"CheatResponses": "When a cheating player is found",
"NeutralRoleWinTogether": "<color=#ffab1b>Neutrals</color> win together",
"NeutralWinTogether": "All <color=#ffab1b>Neutrals</color> win together",
+1
View File
@@ -52,6 +52,7 @@ internal class Ventguard : RoleBase
public override void Init()
{
On = false;
BlockedVents = [];
}
public override void ApplyGameOptions(IGameOptions opt, byte playerId)
+1 -1
View File
@@ -293,6 +293,6 @@ public class Swooper : RoleBase
public override bool CanUseVent(PlayerControl pc, int ventId)
{
return UsedRole != CustomRoles.Chameleon || pc.GetClosestVent()?.Id == ventId;
return !IsThisRole(pc) || UsedRole != CustomRoles.Chameleon || pc.GetClosestVent()?.Id == ventId;
}
}
+11 -5
View File
@@ -18,17 +18,23 @@ public class Juggernaut : RoleBase
{
SetupRoleOptions(Id, TabGroup.NeutralRoles, CustomRoles.Juggernaut);
DefaultKillCooldown = new FloatOptionItem(Id + 10, "SansDefaultKillCooldown", new(0f, 180f, 0.5f), 30f, TabGroup.NeutralRoles).SetParent(CustomRoleSpawnChances[CustomRoles.Juggernaut])
DefaultKillCooldown = new FloatOptionItem(Id + 10, "SansDefaultKillCooldown", new(0f, 180f, 0.5f), 30f, TabGroup.NeutralRoles)
.SetParent(CustomRoleSpawnChances[CustomRoles.Juggernaut])
.SetValueFormat(OptionFormat.Seconds);
ReduceKillCooldown = new FloatOptionItem(Id + 11, "SansReduceKillCooldown", new(0f, 30f, 0.5f), 4f, TabGroup.NeutralRoles).SetParent(CustomRoleSpawnChances[CustomRoles.Juggernaut])
ReduceKillCooldown = new FloatOptionItem(Id + 11, "SansReduceKillCooldown", new(0f, 30f, 0.5f), 4f, TabGroup.NeutralRoles)
.SetParent(CustomRoleSpawnChances[CustomRoles.Juggernaut])
.SetValueFormat(OptionFormat.Seconds);
MinKillCooldown = new FloatOptionItem(Id + 12, "SansMinKillCooldown", new(0f, 30f, 0.5f), 10f, TabGroup.NeutralRoles).SetParent(CustomRoleSpawnChances[CustomRoles.Juggernaut])
MinKillCooldown = new FloatOptionItem(Id + 12, "SansMinKillCooldown", new(0f, 30f, 0.5f), 10f, TabGroup.NeutralRoles)
.SetParent(CustomRoleSpawnChances[CustomRoles.Juggernaut])
.SetValueFormat(OptionFormat.Seconds);
HasImpostorVision = new BooleanOptionItem(Id + 13, "ImpostorVision", true, TabGroup.NeutralRoles).SetParent(CustomRoleSpawnChances[CustomRoles.Juggernaut]);
CanVent = new BooleanOptionItem(Id + 14, "CanVent", true, TabGroup.NeutralRoles).SetParent(CustomRoleSpawnChances[CustomRoles.Juggernaut]);
HasImpostorVision = new BooleanOptionItem(Id + 13, "ImpostorVision", true, TabGroup.NeutralRoles)
.SetParent(CustomRoleSpawnChances[CustomRoles.Juggernaut]);
CanVent = new BooleanOptionItem(Id + 14, "CanVent", true, TabGroup.NeutralRoles)
.SetParent(CustomRoleSpawnChances[CustomRoles.Juggernaut]);
}
public override void Init() { }
+1 -1
View File
@@ -55,7 +55,7 @@ public class Magistrate : RoleBase
public override bool CanUseVent(PlayerControl pc, int ventId)
{
return pc.PlayerId != MagistrateID || (AbilityTrigger == AbilityTriggers.Vent && pc.GetAbilityUseLimit() > 0);
return !IsThisRole(pc) || pc.PlayerId != MagistrateID || (AbilityTrigger == AbilityTriggers.Vent && pc.GetAbilityUseLimit() > 0);
}
public override void OnCoEnterVent(PlayerPhysics physics, int ventId)
+1 -1
View File
@@ -158,7 +158,7 @@ public class RoomRusher : RoleBase
public override bool CanUseVent(PlayerControl pc, int ventId)
{
return pc.PlayerId != RoomRusherId || (CanVent && VentsLeft > 0);
return !IsThisRole(pc) || pc.PlayerId != RoomRusherId || (CanVent && VentsLeft > 0);
}
public override void AfterMeetingTasks()