Finishing what was started II

This commit is contained in:
Ape committed 2026-02-23 21:52:31 +01:00
1 parent cd1de51a1f
commit aa56c78c70
14 files changed
+199 -54

No files matched your search

+2 -2
View File
@@ -111,7 +111,7 @@ public static class BanManager
string friendcode = player?.FriendCode;
// Check file BanList.txt
if (Options.ApplyBanList.GetBool() && CheckBanList(friendcode, player?.GetHashedPuid()))
if (CheckBanList(friendcode, player?.GetHashedPuid()))
{
AmongUsClient.Instance.KickPlayer(player.Id, true);
Logger.Info($"{player.PlayerName} was in the BanList and has been banned", "BanListBan");
@@ -164,7 +164,7 @@ public static class BanManager
}
public static bool IsPlayerInDenyName(ClientData client, string name)
{
if (name == "" || !AmongUsClient.Instance.AmHost || !Options.ApplyDenyNameList.GetBool()) return false;
if (name == "" || !AmongUsClient.Instance.AmHost) return false;
var deniedNames = File.ReadAllLines(DenyNameListPath);
+1 -20
View File
@@ -57,11 +57,6 @@ namespace AmongUsRevamped
"None", "0 Kill Cooldown", "Shift And Seek", "Speedrun"
};
public static readonly string[] colorLevels =
{
"Moderators", "Everyone", "Nobody"
};
public static readonly string[] accessLevels =
{
"Everyone", "<color=yellow>VIP</color> And Above", "<color=purple>Moderator</color> And Above", "<color=red>Admin</color>", "Only You"
@@ -78,11 +73,6 @@ namespace AmongUsRevamped
public static OptionItem KickInvalidFriendCodes;
public static OptionItem TempBanInvalidFriendCodes;
public static OptionItem ApplyBanList;
public static OptionItem ApplyDenyNameList;
public static OptionItem ApplyModeratorList;
public static OptionItem ModeratorCanUseCommand;
public static OptionItem AutoKickStart;
public static OptionItem AutoKickStartAsBan;
public static OptionItem AutoKickStartTimes;
@@ -127,7 +117,6 @@ namespace AmongUsRevamped
public static OptionItem TabGroupGameplayGeneral;
public static OptionItem DisableAnnoyingMeetingCalls;
public static OptionItem DisableReport;
public static OptionItem ChangeDecontaminationTime;
public static OptionItem DecontaminationTimeOnMiraHQ;
@@ -332,11 +321,6 @@ namespace AmongUsRevamped
TempBanInvalidFriendCodes = BooleanOptionItem.Create(60081, Translator.Get("tempBanInvalidFriendCodes"), false, TabGroup.SystemSettings, false)
.SetParent(KickInvalidFriendCodes);
ApplyBanList = BooleanOptionItem.Create(60110, Translator.Get("applyBanList"), true, TabGroup.SystemSettings, true);
ApplyDenyNameList = BooleanOptionItem.Create(60120, Translator.Get("applyDenyNameList"), true, TabGroup.SystemSettings, false);
ApplyModeratorList = BooleanOptionItem.Create(60121, Translator.Get("applyModeratorList"), true, TabGroup.SystemSettings, false);
ModeratorCanUseCommand = BooleanOptionItem.Create(60122, Translator.Get("moderatorCanUseCommand"), true, TabGroup.SystemSettings, false);
AutoKickStart = BooleanOptionItem.Create(60123, Translator.Get("autoKickStart"), false, TabGroup.SystemSettings, false);
AutoKickStartAsBan = BooleanOptionItem.Create(60124, Translator.Get("autoKickStartAsBan"), false, TabGroup.SystemSettings, false)
.SetParent(AutoKickStart);
@@ -362,7 +346,6 @@ namespace AmongUsRevamped
StartCountdown = IntegerOptionItem.Create(60380, Translator.Get("startCountdown"), new(1, 600, 1), 5, TabGroup.SystemSettings, false)
.SetValueFormat(OptionFormat.Seconds);
ColorCommandLevel = StringOptionItem.Create(60381, Translator.Get("colorCommandLevel"), colorLevels, 0, TabGroup.SystemSettings, false);
AllowFortegreen = BooleanOptionItem.Create(60382, Translator.Get("allowFortegreen"), false, TabGroup.SystemSettings, false);
NoGameEnd = BooleanOptionItem.Create(60383, Translator.Get("noGameEnd"), false, TabGroup.SystemSettings, false)
.SetColor(Color.red);
@@ -397,7 +380,7 @@ namespace AmongUsRevamped
.SetValueFormat(OptionFormat.Percent)
.SetColor(CL.Hex("#ec62a5"));
JesterCanVent = BooleanOptionItem.Create(101002, Translator.Get("jesterCanVent"), false, TabGroup.CustomRoleSettings, false)
.SetParent(MayorPerc);
.SetParent(JesterPerc);
TabGroupImpostor = TextOptionItem.Create(102000, Translator.Get("tabGroupImpostor"), TabGroup.CustomRoleSettings)
.SetColor(CL.Hex("#ff1919"));
@@ -486,8 +469,6 @@ namespace AmongUsRevamped
.SetColor(Color.blue);
DisableAnnoyingMeetingCalls = BooleanOptionItem.Create(60565, Translator.Get("disableAnnoyingMeetingCalls"), false, TabGroup.ModSettings, false)
.SetColor(new Color32(19, 188, 233, byte.MaxValue));
DisableReport = BooleanOptionItem.Create(60520, Translator.Get("disableReport"), false, TabGroup.ModSettings, false)
.SetColor(new Color32(19, 188, 233, byte.MaxValue));
ChangeDecontaminationTime = BooleanOptionItem.Create(60550, Translator.Get("changeDecontaminationTime"), false, TabGroup.ModSettings, false)
.SetColor(new Color32(19, 188, 233, byte.MaxValue));
+15 -6
View File
@@ -1,4 +1,5 @@
using AmongUs.GameOptions;
using Hazel;
using System;
using InnerNet;
using UnityEngine;
@@ -40,14 +41,14 @@ public static class CustomRoleManagement
foreach (var (roleName, percentage) in rolesToAssign)
{
if (attemptedRoles.Contains(roleName)) continue;
if (attemptedRoles.Contains(roleName) || percentage == 0) continue;
attemptedRoles.Add(roleName);
int randomValue = random.Next(0, 101);
Logger.Info($"{roleName}, Value: {randomValue}, Percentage: {percentage}", "StartGameCustomRole1");
if (randomValue >= percentage) continue;
if (randomValue > percentage) continue;
if (PlayerRoles.ContainsKey(player.PlayerId)) continue;
PlayerRoles[player.PlayerId] = roleName;
@@ -107,16 +108,23 @@ public static class CustomRoleManagement
private static int PendingRoleMessages = 0;
public static void SendRoleMessages(Dictionary<string, string> roleMessages)
{
if (PlayerRoles.Count == 0) return;
HashSet<string> sentRoles = new HashSet<string>();
var players = PlayerControl.AllPlayerControls.ToArray().ToList();
float delay = 0f;
float delay = 2.2f;
PendingRoleMessages = 0;
HandlingRoleMessages = false;
HandlingRoleMessages = true;
PlayerControl.LocalPlayer.RpcSendChat($"{Translator.Get("customRoleAnnouncement")}");
foreach (var player in players)
{
if (!PlayerRoles.TryGetValue(player.PlayerId, out string role)) continue;
PlayerRoles.TryGetValue(player.PlayerId, out string role);
if (string.IsNullOrEmpty(role)) continue;
if (!roleMessages.ContainsKey(role)) continue;
if (sentRoles.Contains(role)) continue;
@@ -129,7 +137,7 @@ public static class CustomRoleManagement
}
else
{
Logger.Info("Role sending was forcefully canceled. This should not happen.", "SendRoleMessages")
Logger.Info("Role sending was forcefully canceled. This should not happen.", "SendRoleMessages");
}
PendingRoleMessages--;
@@ -138,6 +146,7 @@ public static class CustomRoleManagement
{
PendingRoleMessages = 0;
HandlingRoleMessages = false;
sentRoles.Clear();
}
}, delay, "SendRoleMessage");
+1 -6
View File
@@ -39,7 +39,7 @@ class FixedUpdateInGamePatch
public static void Postfix(PlayerControl __instance)
{
if (__instance == null || __instance.PlayerId == 255 || !AmongUsClient.Instance.AmHost) return;
int access = Utils.CheckAccessLevel(__instance.Data.FriendCode);
string color = access switch
{
@@ -53,11 +53,6 @@ class FixedUpdateInGamePatch
{
__instance.cosmetics.nameText.text = $"<color={color}>{__instance.Data.PlayerName}</color>";
}
if (!Utils.IsLobby && __instance.cosmetics.nameText.text != __instance.Data.PlayerName)
{
__instance.cosmetics.nameText.text = __instance.Data.PlayerName;
}
GameObject g = GameObject.Find("GameSettingsLabel");
+2
View File
@@ -205,11 +205,13 @@ public static class Utils
OnGameJoinedPatch.AutoStartCheck = false;
Main.GameTimer = 0f;
MurderPlayerPatch.misfireCount.Clear();
MurderPlayerPatch.killCount.Clear();
LateTask.Tasks.Clear();
NormalGameEndChecker.ImpCheckComplete = false;
CreateOptionsPickerPatch.SetDleks2 = false;
CanCallMeetings = true;
PlayerControlSetRolePatch.FirstAssign = true;
PlayerControlCompleteTaskPatch.playerTasksCompleted.Clear();
}
public static PlayerControl[] AllAlivePlayerControls
+8 -1
View File
@@ -107,7 +107,6 @@ internal static class SendChatPatch
__instance.freeChatField.textArea.SetText(string.Empty);
return false;
}
if (text == "/h" || text == "/help" || text == "/cmd" || text == "/commands")
{
HudManager.Instance.Chat.AddChat(PlayerControl.LocalPlayer, $"{Translator.Get("allCommandsFull")}");
@@ -146,6 +145,14 @@ internal static class SendChatPatch
Utils.ChatCommand(__instance, $"{NormalGameEndChecker.LastWinReason}", "", false);
return false;
}
if (text == "/r jester"){
Utils.ChatCommand(__instance, Translator.Get("jesterPublic"), "", false);
return false;}
if (text == "/r mayor"){
Utils.ChatCommand(__instance, Translator.Get("mayorPublic", Options.MayorExtraVoteCount.GetInt()), "", false);
return false;}
if (text == "/aur" || text == "/amongusrevamped" || text == "/socials" || text == "/github" || text == "/discord")
{
+14 -1
View File
@@ -39,9 +39,23 @@ class NormalGameEndChecker
ImpCheckComplete = true;
}
CheckWinnerText("Default");
return true;
}
public static void CheckWinnerText(string Winner)
{
var customRoles = CustomRoleManagement.PlayerToCustomRole();
var impostorList = string.Join(", ", imps.Select(p => p.Data.PlayerName));
if (Winner == "Jester")
{
LastWinReason = $"Jester wins! (Voted)\n\nImpostors: {impostorList}" + (string.IsNullOrEmpty(customRoles) ? "" : "\n\n" + customRoles);
}
if (Winner != "Default") return;
if (Utils.AliveImpostors == 0)
{
LastWinReason = $"Crewmates win!\n\nImpostors: {impostorList}" + (string.IsNullOrEmpty(customRoles) ? "" : "\n\n" + customRoles);
@@ -58,7 +72,6 @@ class NormalGameEndChecker
{
LastWinReason = $"Impostors win! (Sabotage)\n\nImpostors: {impostorList}" + (string.IsNullOrEmpty(customRoles) ? "" : "\n\n" + customRoles);
}
return true;
}
}
+12 -5
View File
@@ -27,15 +27,22 @@ class ExileControllerWrapUpPatch
if (CustomRoleManagement.PlayerRoles.TryGetValue(ejectedPlayer.PlayerId, out var role) && role == "Jester")
{
Utils.CustomWinnerEndGame(pc, 1);
NormalGameEndChecker.LastWinReason = $"Jester wins! (Voted)\n\nImpostors: {impostorList}" + (string.IsNullOrEmpty(customRoles) ? "" : "\n\n" + customRoles);
NormalGameEndChecker.CheckWinnerText("Jester");
return;
}
CustomRoleManagement.SendRoleMessages(new Dictionary<string, string>
if (CustomRoleManagement.HandlingRoleMessages)
{
{ "Jester", Translator.Get("JesterPriv")},
{ "Mayor", Translator.Get("MayorPriv", Options.MayorExtraVoteCount.GetInt())}
});
Logger.Info(" SRM2 is called before SRM1 finished. This should not happen.", "ExileController");
}
else
{
CustomRoleManagement.SendRoleMessages(new Dictionary<string, string>
{
{ "Jester", Translator.Get("jesterPriv")},
{ "Mayor", Translator.Get("mayorPriv", Options.MayorExtraVoteCount.GetInt())},
});
}
}
}
}
+7 -2
View File
@@ -17,9 +17,14 @@ internal static class CoShowIntroPatch
CustomRoleManagement.SendRoleMessages(new Dictionary<string, string>
{
{ "Jester", Translator.Get("JesterPriv")},
{ "Mayor", Translator.Get("MayorPriv", Options.MayorExtraVoteCount.GetInt())}
{ "Jester", Translator.Get("jesterPriv")},
{ "Mayor", Translator.Get("mayorPriv", Options.MayorExtraVoteCount.GetInt())},
});
foreach (var p in PlayerControl.AllPlayerControls)
{
p.cosmetics.nameText.text = p.Data.PlayerName;
}
if (Options.DisableAnnoyingMeetingCalls.GetBool())
{
+60 -1
View File
@@ -1,4 +1,6 @@
namespace AmongUsRevamped;
using UnityEngine;
namespace AmongUsRevamped;
[HarmonyPatch(typeof(MeetingHud), nameof(MeetingHud.CheckForEndVoting))]
public static class CheckForEndVotingPatch
@@ -41,4 +43,61 @@ public static class CheckForEndVotingPatch
return false;
}
}
[HarmonyPatch(typeof(MeetingHud), nameof(MeetingHud.Start))]
class MeetingHudStartPatch
{
public static void Postfix(MeetingHud __instance)
{
if (!AmongUsClient.Instance.AmHost) return;
foreach (var playerState in __instance.playerStates)
{
PlayerControl player = null;
foreach (var pc in PlayerControl.AllPlayerControls)
{
if (pc.PlayerId == playerState.TargetPlayerId)
{
player = pc;
break;
}
}
if (player == null || !PlayerControl.LocalPlayer.Data.IsDead) continue;
var textTemplate = playerState.NameText;
var taskText = GetProgressText(player);
var taskTextMeeting = UnityEngine.Object.Instantiate(textTemplate);
taskTextMeeting.transform.SetParent(textTemplate.transform);
taskTextMeeting.transform.localPosition = new Vector3(0f, 0.18f, 0f);
taskTextMeeting.fontSize = 1.6f;
taskTextMeeting.text = taskText;
taskTextMeeting.gameObject.name = "TaskTextMeeting";
taskTextMeeting.enableWordWrapping = false;
taskTextMeeting.enabled = player.AmOwner || player.PlayerId == playerState.TargetPlayerId;
}
}
public static string GetProgressText(PlayerControl player)
{
int totalTasks = 0;
int tasksCompleted = 0;
if (player.Data.Tasks != null && !player.Data.Role.IsImpostor)
{
foreach (var task in player.Data.Tasks)
{
totalTasks++;
if (task.Complete) tasksCompleted++;
}
return $"<color=green>({tasksCompleted}/{totalTasks})</color>";
}
else
{
return $"<color=red>({MurderPlayerPatch.killCount[player.Data.PlayerId]}†)</color>";
}
}
}
+2 -2
View File
@@ -15,7 +15,7 @@ public static class NumberOption_Increase
float increment = Hotkeys.IncrementMultiplier * __instance.Increment;
#endif
if (Utils.isHideNSeek || Utils.IsLobby && !Utils.isHideNSeek && __instance.Title != StringNames.GameNumImpostors && __instance.Title != StringNames.GamePlayerSpeed)
if (Utils.IsLobby)
{
if (__instance.Value <= __instance.ValidRange.min)
{
@@ -53,7 +53,7 @@ public static class NumberOption_Decrease
float increment = Hotkeys.IncrementMultiplier * __instance.Increment;
#endif
if (Utils.isHideNSeek || Utils.IsLobby && !Utils.isHideNSeek && __instance.Title != StringNames.GameNumImpostors && __instance.Title != StringNames.GamePlayerSpeed)
if (Utils.IsLobby)
{
if (__instance.Value >= __instance.ValidRange.max)
{
+1
View File
@@ -14,6 +14,7 @@ internal class CoStartGamePatch
Logger.Info(" -------- GAME STARTED --------", "StartGame");
Logger.Info($" Gamemode: {Options.Gamemode.GetValue()}", "StartGame");
Logger.Info($" Players: {PlayerControl.AllPlayerControls.Count}", "StartGame");
if ((Options.Gamemode.GetValue() == 0 || Options.Gamemode.GetValue() == 1) && !Utils.isHideNSeek)
{
+69 -4
View File
@@ -3,7 +3,9 @@ using AmongUs.GameOptions;
using Hazel;
using InnerNet;
using System;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
namespace AmongUsRevamped;
@@ -23,7 +25,7 @@ class ReportDeadBodyPatch
// target == null means meeting
if (target == null) return true;
if (Options.DisableReport.GetBool() || Options.Gamemode.GetValue() == 2 || Options.Gamemode.GetValue() == 3)
if (Options.Gamemode.GetValue() == 2 || Options.Gamemode.GetValue() == 3)
{
Logger.Info($" Stopped {__instance.Data.PlayerName} reporting the body of {target.PlayerName}", "ReportDeadBodyPatch");
return false;
@@ -36,10 +38,47 @@ class ReportDeadBodyPatch
internal static class MurderPlayerPatch
{
public static readonly Dictionary<byte, int> misfireCount = new();
public static readonly Dictionary<byte, int> killCount = new();
public static void Postfix(PlayerControl __instance, [HarmonyArgument(0)] PlayerControl target, [HarmonyArgument(1)] MurderResultFlags resultFlags, ref bool __state)
{
if (!AmongUsClient.Instance.AmHost) return;
if (!AmongUsClient.Instance.AmHost || !resultFlags.HasFlag(MurderResultFlags.Succeeded)) return;
byte playerId = __instance.Data.PlayerId;
if (!killCount.ContainsKey(playerId))
{
killCount[playerId] = 0;
}
if (!__instance.isNew)
{
killCount[playerId]++;
Logger.Info($" {__instance.Data.PlayerName} killed {target.Data.PlayerName}", "MurderPlayer");
if (target == PlayerControl.LocalPlayer || PlayerControl.LocalPlayer.Data.IsDead)
{
foreach (var p in PlayerControl.AllPlayerControls)
{
int totalTasks = p.Data.Tasks.Count;
int tasksCompleted = 0;
if (PlayerControlCompleteTaskPatch.playerTasksCompleted.ContainsKey(p))
{
tasksCompleted = PlayerControlCompleteTaskPatch.playerTasksCompleted[p];
}
if (p.Data.Role.IsImpostor)
{
p.cosmetics.nameText.text = $"{p.Data.PlayerName}<color=red>({killCount[__instance.Data.PlayerId]}†";
}
else
{
p.cosmetics.nameText.text = $"{p.Data.PlayerName}<color=green>({tasksCompleted}/{totalTasks})";
}
}
}
}
//2 = Shift and Seek
if (Options.Gamemode.GetValue() == 2 && !Utils.isHideNSeek)
@@ -47,8 +86,6 @@ internal static class MurderPlayerPatch
if (!resultFlags.HasFlag(MurderResultFlags.Succeeded))
return;
byte playerId = __instance.Data.PlayerId;
if (target.Data.PlayerId == __instance.shapeshiftTargetPlayerId)
{
Logger.Info($" {__instance.Data.PlayerName} correctly killed {target.Data.PlayerName} ", "SNSKillManager");
@@ -104,3 +141,31 @@ internal static class CheckShapeshiftPatch
else return true;
}
}
[HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.CompleteTask))]
class PlayerControlCompleteTaskPatch
{
public static Dictionary<PlayerControl, int> playerTasksCompleted = new Dictionary<PlayerControl, int>();
public static void Postfix(PlayerControl __instance, uint idx)
{
int totalTasks = 0;
int tasksCompleted = 0;
foreach (var task in __instance.Data.Tasks)
{
totalTasks++;
if (task.Complete) tasksCompleted++;
}
playerTasksCompleted[__instance] = tasksCompleted;
Logger.Info($" {__instance.Data.PlayerName} completed {idx}", "TaskPatch");
if (!PlayerControl.LocalPlayer.Data.IsDead) return;
TMP_Text nameText = __instance.cosmetics.nameText;
nameText.text = $"{__instance.Data.PlayerName}<color=green>({tasksCompleted}/{totalTasks})</color>";
}
}
+5 -4
View File
@@ -210,15 +210,16 @@
"translationReloaded": "Your file has successfully been reset.\nTo apply the changes, restart your game.",
"Mayor": "Mayor",
"MayorPublic": "Mayor:\n\nThe Mayor is a crewmate with {0} extra vote(s). Depending on settings, they can vent to call a meeting.",
"MayorPriv": "Your role is Mayor!\n\nYou are a crewmate with {0} extra vote(s). If you are an Engineer, vent to call a meeting.",
"mayorPublic": "Mayor:\n\nThe Mayor is a crewmate with {0} extra vote(s). Depending on settings, they can vent to call a meeting.",
"mayorPriv": "Your role is Mayor!\n\nYou are a crewmate with {0} extra vote(s). If you are an Engineer, vent to call a meeting.",
"mayorExtraVoteCount": "Extra Votes",
"mayorVentToMeeting": "Can Vent To Call Meetings",
"Jester": "Jester",
"JesterPublic": "Jester:\n\nThe Jester wins alone by getting voted. Their goal is to act as suspicious as possible.",
"JesterPriv": "Your role is Jester!\nYou are NOT a crewmate!\n\nYou win by getting voted. Act as suspicious as possible.",
"jesterPublic": "Jester:\n\nThe Jester wins alone by getting voted. Their goal is to act as suspicious as possible.",
"jesterPriv": "Your role is Jester!\nYou are NOT a crewmate!\n\nYou win by getting voted. Act as suspicious as possible.",
"jesterCanVent": "Can Vent",
"customRoleAnnouncement": "Custom Roles are enabled!\n\nIf you have a Custom Role, it will show in a message below this one.",
"roleDescriptionHelp": "Your Role can be seen at the start of meetings. It is shown by a private text, looking like the host."
}