mirror of
https://github.com/ApeMV/AmongUsRevamped.git
synced 2026-10-20 01:46:28 +00:00
Presets, Technical improvements, Small fixes
This commit is contained in:
1 parent
6842f3d516
commit
48eb09f448
9 files changed
+230
-98
No files matched your search
+23
-1
@@ -19,6 +19,17 @@ public partial class Main : BasePlugin
|
||||
public static BepInEx.Logging.ManualLogSource Logger;
|
||||
public static BasePlugin Instance;
|
||||
|
||||
public static ConfigEntry<string> Preset1 { get; private set; }
|
||||
public static ConfigEntry<string> Preset2 { get; private set; }
|
||||
public static ConfigEntry<string> Preset3 { get; private set; }
|
||||
public static ConfigEntry<string> Preset4 { get; private set; }
|
||||
public static ConfigEntry<string> Preset5 { get; private set; }
|
||||
public static ConfigEntry<string> Preset6 { get; private set; }
|
||||
public static ConfigEntry<string> Preset7 { get; private set; }
|
||||
public static ConfigEntry<string> Preset8 { get; private set; }
|
||||
public static ConfigEntry<string> Preset9 { get; private set; }
|
||||
public static ConfigEntry<string> Preset10 { get; private set; }
|
||||
|
||||
public static ConfigEntry<bool> GM { get; private set; }
|
||||
public static ConfigEntry<bool> UnlockFps { get; private set; }
|
||||
public static ConfigEntry<bool> ShowFps { get; private set; }
|
||||
@@ -29,7 +40,7 @@ public partial class Main : BasePlugin
|
||||
public static NormalGameOptionsV10 NormalOptions => GameOptionsManager.Instance != null ? GameOptionsManager.Instance.currentNormalGameOptions : null;
|
||||
public static bool HasArgumentException;
|
||||
public static string CredentialsText;
|
||||
public const string ModVersion = "v1.2.1";
|
||||
public const string ModVersion = "v1.3.0";
|
||||
|
||||
public static float GameTimer;
|
||||
|
||||
@@ -62,6 +73,17 @@ public partial class Main : BasePlugin
|
||||
AmongUsRevamped.Logger.Enable();
|
||||
Instance = this;
|
||||
|
||||
Preset1 = Config.Bind("Preset Name Options", "Preset1", "Preset 1");
|
||||
Preset2 = Config.Bind("Preset Name Options", "Preset2", "Preset 2");
|
||||
Preset3 = Config.Bind("Preset Name Options", "Preset3", "Preset 3");
|
||||
Preset4 = Config.Bind("Preset Name Options", "Preset4", "Preset 4");
|
||||
Preset5 = Config.Bind("Preset Name Options", "Preset5", "Preset 5");
|
||||
Preset6 = Config.Bind("Preset Name Options", "Preset6", "Preset 6");
|
||||
Preset7 = Config.Bind("Preset Name Options", "Preset7", "Preset 7");
|
||||
Preset8 = Config.Bind("Preset Name Options", "Preset8", "Preset 8");
|
||||
Preset9 = Config.Bind("Preset Name Options", "Preset9", "Preset 9");
|
||||
Preset10 = Config.Bind("Preset Name Options", "Preset10", "Preset 10");
|
||||
|
||||
AutoStart = Config.Bind("Client Options", "Auto Start", false);
|
||||
GM = Config.Bind("Client Options", "Game Master", false);
|
||||
UnlockFps = Config.Bind("Client Options", "Unlock FPS", false);
|
||||
|
||||
@@ -21,6 +21,16 @@ namespace AmongUsRevamped
|
||||
taskOptionsLoad.Wait();
|
||||
}
|
||||
|
||||
public const int PresetId = 0;
|
||||
|
||||
private static readonly string[] presets =
|
||||
{
|
||||
Main.Preset1.Value, Main.Preset2.Value, Main.Preset3.Value,
|
||||
Main.Preset4.Value, Main.Preset5.Value, Main.Preset6.Value,
|
||||
Main.Preset7.Value, Main.Preset8.Value, Main.Preset9.Value,
|
||||
Main.Preset10.Value
|
||||
};
|
||||
|
||||
public static readonly string[] gameModes =
|
||||
{
|
||||
"None", "0 Kill Cooldown", "Shift And Seek", "Speedrun"
|
||||
@@ -200,6 +210,10 @@ namespace AmongUsRevamped
|
||||
{
|
||||
if (IsLoaded) return;
|
||||
|
||||
_ = PresetOptionItem.Create(0, TabGroup.SystemSettings)
|
||||
.SetColor(new Color32(204, 204, 0, 255))
|
||||
.SetHeader(true);
|
||||
|
||||
Gamemode = StringOptionItem.Create(1, "Gamemode", gameModes, 0, TabGroup.SystemSettings, false)
|
||||
.SetColor(Color.green)
|
||||
.SetHeader(true);
|
||||
|
||||
+85
-7
@@ -22,8 +22,90 @@ public static class FixedUpdate
|
||||
{
|
||||
nr.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!AmongUsClient.Instance.AmHost) return;
|
||||
[HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.FixedUpdate))]
|
||||
class FixedUpdateInGamePatch
|
||||
{
|
||||
public static readonly HashSet<byte> ProcessedModerators = new HashSet<byte>();
|
||||
|
||||
public static void Postfix(PlayerControl __instance)
|
||||
{
|
||||
if (__instance == null || __instance.PlayerId == 255 || !AmongUsClient.Instance.AmHost) return;
|
||||
|
||||
if (Utils.IsPlayerModerator(__instance.Data.FriendCode) && !ProcessedModerators.Contains(__instance.PlayerId))
|
||||
{
|
||||
__instance.SetName($"★{__instance.Data.PlayerName}★");
|
||||
ProcessedModerators.Add(__instance.PlayerId);
|
||||
}
|
||||
|
||||
GameObject g = GameObject.Find("GameSettingsLabel");
|
||||
|
||||
// 0Kc
|
||||
if (Options.Gamemode.GetValue() == 1 && !Utils.isHideNSeek && Main.NormalOptions.KillCooldown != 0.01f)
|
||||
{
|
||||
Main.NormalOptions.KillCooldown = 0.01f;
|
||||
|
||||
if (Options.NoKcdSettingsOverride.GetBool() && g == null)
|
||||
{
|
||||
Main.NormalOptions.EmergencyCooldown = 0;
|
||||
|
||||
Main.NormalOptions.TaskBarMode = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// SnS
|
||||
if (Options.Gamemode.GetValue() == 2 && !Utils.isHideNSeek && Main.NormalOptions.KillCooldown != 2.5f)
|
||||
{
|
||||
Main.NormalOptions.KillCooldown = 2.5f;
|
||||
|
||||
if (Options.SNSSettingsOverride.GetBool() && g == null)
|
||||
{
|
||||
Main.NormalOptions.TaskBarMode = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Speedrun
|
||||
if (Options.Gamemode.GetValue() == 3 && !Utils.isHideNSeek && g == null)
|
||||
{
|
||||
Main.NormalOptions.NumEmergencyMeetings = 0;
|
||||
|
||||
Main.NormalOptions.TaskBarMode = 0;
|
||||
|
||||
if (__instance.AllTasksCompleted() && Utils.InGame && Utils.GamePastRoleSelection && !Utils.HandlingGameEnd)
|
||||
{
|
||||
if (__instance == PlayerControl.LocalPlayer && Main.GM.Value) return;
|
||||
|
||||
Utils.CustomWinnerEndGame(__instance, 1);
|
||||
NormalGameEndChecker.LastWinReason = $"★ {__instance.Data.PlayerName} Wins! (Completed tasks first)";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (Options.Gamemode.GetValue() == 0 && Main.NormalOptions.KillCooldown <= 0.01f)
|
||||
{
|
||||
Main.NormalOptions.KillCooldown = 25f;
|
||||
}
|
||||
|
||||
if (AmongUsClient.Instance.AmHost)
|
||||
{
|
||||
if (__instance.Data.PlayerLevel != 0 && __instance.Data.PlayerLevel < Options.KickLowLevelPlayer.GetInt() && __instance.Data.ClientId != AmongUsClient.Instance.HostId)
|
||||
{
|
||||
if (!Options.TempBanLowLevelPlayer.GetBool())
|
||||
{
|
||||
AmongUsClient.Instance.KickPlayer(__instance.Data.ClientId, false);
|
||||
Logger.Info($" {__instance.Data.PlayerName} was kicked for being under level {Options.KickLowLevelPlayer.GetInt()}", "KickLowLevelPlayer");
|
||||
Logger.SendInGame($" {__instance.Data.PlayerName} was kicked for being under level {Options.KickLowLevelPlayer.GetInt()}");
|
||||
}
|
||||
else
|
||||
{
|
||||
AmongUsClient.Instance.KickPlayer(__instance.Data.ClientId, true);
|
||||
Logger.Info($" {__instance.Data.PlayerName} was banned for being under level {Options.KickLowLevelPlayer.GetInt()} ", "BanLowLevelPlayer");
|
||||
Logger.SendInGame($" {__instance.Data.PlayerName} was banned for being under level {Options.KickLowLevelPlayer.GetInt()}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Utils.InGame && !Utils.IsMeeting && !ExileController.Instance)
|
||||
{
|
||||
@@ -36,9 +118,7 @@ public static class FixedUpdate
|
||||
{
|
||||
Main.GameTimer = 0f;
|
||||
|
||||
MessageWriter writer = AmongUsClient.Instance.StartEndGame();
|
||||
writer.Write((byte)GameOverReason.ImpostorDisconnect);
|
||||
AmongUsClient.Instance.FinishEndGame(writer);
|
||||
Utils.ContinueEndGame((byte)GameOverReason.CrewmatesByVote);
|
||||
Logger.Info($" Crewmates won because the game took longer than {Options.CrewAutoWinsGameAfter.GetInt()}s", "SNSManager");
|
||||
NormalGameEndChecker.LastWinReason = $"★ Crewmates win! (Timer)\n\nImpostors:\n" + string.Join("\n", NormalGameEndChecker.imps.Select(p => p.Data.PlayerName));
|
||||
}
|
||||
@@ -52,9 +132,7 @@ public static class FixedUpdate
|
||||
{
|
||||
Main.GameTimer = 0f;
|
||||
|
||||
MessageWriter writer = AmongUsClient.Instance.StartEndGame();
|
||||
writer.Write((byte)GameOverReason.CrewmatesByVote);
|
||||
AmongUsClient.Instance.FinishEndGame(writer);
|
||||
Utils.CustomWinnerEndGame(PlayerControl.LocalPlayer, 0);
|
||||
Logger.Info($" No one won because the game took longer than {Options.GameAutoEndsAfter.GetInt()}s", "SpeedrunManager");
|
||||
NormalGameEndChecker.LastWinReason = $"★ No one wins! (Timer)";
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace AmongUsRevamped
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < 1; i++)
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
AllConfigEntries[i] = Main.Instance.Config.Bind($"Preset{i + 1}", id.ToString(), DefaultValue);
|
||||
}
|
||||
@@ -174,7 +174,7 @@ namespace AmongUsRevamped
|
||||
|
||||
public static void SwitchPreset(int newPreset)
|
||||
{
|
||||
CurrentPreset = Math.Clamp(newPreset, 0, 1);
|
||||
CurrentPreset = Math.Clamp(newPreset, 0, 9);
|
||||
|
||||
foreach (var op in AllOptions)
|
||||
op.Refresh();
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
// https://github.com/tukasa0001/TownOfHost/blob/main/Modules/OptionItems/PresetOptionItem.cs
|
||||
|
||||
namespace AmongUsRevamped
|
||||
{
|
||||
public class PresetOptionItem : OptionItem
|
||||
{
|
||||
public IntegerValueRule Rule;
|
||||
|
||||
public PresetOptionItem(int defaultValue, TabGroup tab)
|
||||
: base(0, "Preset", defaultValue, tab, true)
|
||||
{
|
||||
Rule = (0, 9, 1);
|
||||
}
|
||||
public static PresetOptionItem Create(int defaultValue, TabGroup tab)
|
||||
{
|
||||
return new PresetOptionItem(defaultValue, tab);
|
||||
}
|
||||
|
||||
public override int GetInt() => Rule.GetValueByIndex(CurrentValue);
|
||||
public override float GetFloat() => Rule.GetValueByIndex(CurrentValue);
|
||||
public override string GetString()
|
||||
{
|
||||
return CurrentValue switch
|
||||
{
|
||||
0 => Main.Preset1.Value == (string)Main.Preset1.DefaultValue ? "Preset 1" : Main.Preset1.Value,
|
||||
1 => Main.Preset2.Value == (string)Main.Preset2.DefaultValue ? "Preset 2" : Main.Preset2.Value,
|
||||
2 => Main.Preset3.Value == (string)Main.Preset3.DefaultValue ? "Preset 3" : Main.Preset3.Value,
|
||||
3 => Main.Preset4.Value == (string)Main.Preset4.DefaultValue ? "Preset 4" : Main.Preset4.Value,
|
||||
4 => Main.Preset5.Value == (string)Main.Preset5.DefaultValue ? "Preset 5" : Main.Preset5.Value,
|
||||
5 => Main.Preset6.Value == (string)Main.Preset6.DefaultValue ? "Preset 6" : Main.Preset6.Value,
|
||||
6 => Main.Preset7.Value == (string)Main.Preset7.DefaultValue ? "Preset 7" : Main.Preset7.Value,
|
||||
7 => Main.Preset8.Value == (string)Main.Preset8.DefaultValue ? "Preset 8" : Main.Preset8.Value,
|
||||
8 => Main.Preset9.Value == (string)Main.Preset9.DefaultValue ? "Preset 9" : Main.Preset9.Value,
|
||||
9 => Main.Preset10.Value == (string)Main.Preset10.DefaultValue ? "Preset 10" : Main.Preset10.Value,
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
public override int GetValue()
|
||||
=> Rule.RepeatIndex(base.GetValue());
|
||||
|
||||
public override void SetValue(int value)
|
||||
{
|
||||
base.SetValue(Rule.RepeatIndex(value));
|
||||
SwitchPreset(Rule.RepeatIndex(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -42,6 +42,7 @@ public static class Utils
|
||||
public static bool IsMeeting => InGame && (MeetingHud.Instance);
|
||||
public static bool GamePastRoleSelection => Main.GameTimer > 10f;
|
||||
public static bool HandlingGameEnd;
|
||||
public static byte CustomGameOverReason;
|
||||
|
||||
public static string ColorString(Color32 color, string str) => $"<#{color.r:x2}{color.g:x2}{color.b:x2}{color.a:x2}>{str}</color>";
|
||||
public static string ColorToHex(Color32 color) => $"#{color.r:x2}{color.g:x2}{color.b:x2}{color.a:x2}";
|
||||
@@ -340,4 +341,50 @@ public static class Utils
|
||||
|
||||
return value.ToString();
|
||||
}
|
||||
|
||||
// 0 = no winner. 1 = solo winner. 2 = add winner.
|
||||
public static void CustomWinnerEndGame(PlayerControl winner, int winnerType)
|
||||
{
|
||||
HandlingGameEnd = true;
|
||||
MessageWriter writer = AmongUsClient.Instance.StartEndGame();
|
||||
|
||||
if (winnerType == 0)
|
||||
{
|
||||
foreach (PlayerControl pc in PlayerControl.AllPlayerControls)
|
||||
{
|
||||
CustomGameOverReason = (byte)GameOverReason.ImpostorsByVote;
|
||||
pc.RpcSetRole(AmongUs.GameOptions.RoleTypes.CrewmateGhost, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (winnerType == 1)
|
||||
{
|
||||
foreach (PlayerControl pc in PlayerControl.AllPlayerControls)
|
||||
{
|
||||
CustomGameOverReason = (byte)GameOverReason.ImpostorsByVote;
|
||||
|
||||
if (pc != winner)
|
||||
{
|
||||
pc.RpcSetRole(AmongUs.GameOptions.RoleTypes.CrewmateGhost, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
pc.RpcSetRole(AmongUs.GameOptions.RoleTypes.ImpostorGhost, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
new LateTask(() =>
|
||||
{
|
||||
ContinueEndGame((byte)CustomGameOverReason);
|
||||
}, 1f, "CustomWinnerEndGame");
|
||||
}
|
||||
|
||||
public static void ContinueEndGame(byte gameOverReason)
|
||||
{
|
||||
MessageWriter writer = AmongUsClient.Instance.StartEndGame();
|
||||
writer.Write(gameOverReason);
|
||||
AmongUsClient.Instance.FinishEndGame(writer);
|
||||
HandlingGameEnd = false;
|
||||
}
|
||||
}
|
||||
@@ -39,6 +39,8 @@ internal static class SendChatPatch
|
||||
{
|
||||
string text = __instance.freeChatField.textArea.text.Trim();
|
||||
|
||||
if (!AmongUsClient.Instance.AmHost) return true;
|
||||
|
||||
if (text == "/h" || text == "/help" || text == "/cmd" || text == "/commands")
|
||||
{
|
||||
HudManager.Instance.Chat.AddChat(PlayerControl.LocalPlayer, $"{allCommandsFull}");
|
||||
|
||||
@@ -290,6 +290,16 @@ namespace AmongUsRevamped
|
||||
Index = stringItem.GetInt(),
|
||||
};
|
||||
}
|
||||
else if (item is PresetOptionItem)
|
||||
{
|
||||
PresetOptionItem presetItem = item as PresetOptionItem;
|
||||
baseGameSetting = new StringGameSetting
|
||||
{
|
||||
Type = OptionTypes.String,
|
||||
Values = new StringNames[10],
|
||||
Index = presetItem.GetInt(),
|
||||
};
|
||||
}
|
||||
if (baseGameSetting != null)
|
||||
baseGameSetting.Title = StringNames.Accept;
|
||||
return baseGameSetting;
|
||||
|
||||
@@ -6,94 +6,6 @@ using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AmongUsRevamped;
|
||||
[HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.FixedUpdate))]
|
||||
class FixedUpdateInGamePatch
|
||||
{
|
||||
public static readonly HashSet<byte> ProcessedModerators = new HashSet<byte>();
|
||||
|
||||
public static void Postfix(PlayerControl __instance)
|
||||
{
|
||||
if (__instance == null || __instance.PlayerId == 255) return;
|
||||
|
||||
if (Utils.IsPlayerModerator(__instance.Data.FriendCode) && !ProcessedModerators.Contains(__instance.PlayerId))
|
||||
{
|
||||
__instance.SetName($"★{__instance.Data.PlayerName}★");
|
||||
ProcessedModerators.Add(__instance.PlayerId);
|
||||
}
|
||||
|
||||
GameObject g = GameObject.Find("GameSettingsLabel");
|
||||
|
||||
// 0Kc
|
||||
if (Options.Gamemode.GetValue() == 1 && !Utils.isHideNSeek && Main.NormalOptions.KillCooldown != 0.01f)
|
||||
{
|
||||
Main.NormalOptions.KillCooldown = 0.01f;
|
||||
|
||||
if (Options.NoKcdSettingsOverride.GetBool() && g == null)
|
||||
{
|
||||
Main.NormalOptions.EmergencyCooldown = 0;
|
||||
|
||||
Main.NormalOptions.TaskBarMode = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// SnS
|
||||
if (Options.Gamemode.GetValue() == 2 && !Utils.isHideNSeek && Main.NormalOptions.KillCooldown != 2.5f)
|
||||
{
|
||||
Main.NormalOptions.KillCooldown = 2.5f;
|
||||
|
||||
if (Options.SNSSettingsOverride.GetBool() && g == null)
|
||||
{
|
||||
Main.NormalOptions.TaskBarMode = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Speedrun
|
||||
if (Options.Gamemode.GetValue() == 3 && !Utils.isHideNSeek && g == null)
|
||||
{
|
||||
Main.NormalOptions.NumEmergencyMeetings = 0;
|
||||
|
||||
Main.NormalOptions.TaskBarMode = 0;
|
||||
|
||||
if (__instance.AllTasksCompleted() && Utils.InGame && Utils.GamePastRoleSelection && !Utils.HandlingGameEnd)
|
||||
{
|
||||
Utils.HandlingGameEnd = true;
|
||||
__instance.RpcSetRole(AmongUs.GameOptions.RoleTypes.ImpostorGhost, false);
|
||||
|
||||
new LateTask(() =>
|
||||
{
|
||||
NormalGameEndChecker.LastWinReason = $"★ {__instance.Data.PlayerName} Wins! (Completed tasks first)";
|
||||
MessageWriter writer = AmongUsClient.Instance.StartEndGame();
|
||||
writer.Write((byte)GameOverReason.ImpostorsByVote);
|
||||
AmongUsClient.Instance.FinishEndGame(writer);
|
||||
}, 1f, "SpeedrunSetWinner");
|
||||
}
|
||||
}
|
||||
|
||||
if (Options.Gamemode.GetValue() == 0 && Main.NormalOptions.KillCooldown <= 0.01f)
|
||||
{
|
||||
Main.NormalOptions.KillCooldown = 25f;
|
||||
}
|
||||
|
||||
if (AmongUsClient.Instance.AmHost)
|
||||
{
|
||||
if (__instance.Data.PlayerLevel != 0 && __instance.Data.PlayerLevel < Options.KickLowLevelPlayer.GetInt() && __instance.Data.ClientId != AmongUsClient.Instance.HostId)
|
||||
{
|
||||
if (!Options.TempBanLowLevelPlayer.GetBool())
|
||||
{
|
||||
AmongUsClient.Instance.KickPlayer(__instance.Data.ClientId, false);
|
||||
Logger.Info($" {__instance.Data.PlayerName} was kicked for being under level {Options.KickLowLevelPlayer.GetInt()}", "KickLowLevelPlayer");
|
||||
Logger.SendInGame($" {__instance.Data.PlayerName} was kicked for being under level {Options.KickLowLevelPlayer.GetInt()}");
|
||||
}
|
||||
else
|
||||
{
|
||||
AmongUsClient.Instance.KickPlayer(__instance.Data.ClientId, true);
|
||||
Logger.Info($" {__instance.Data.PlayerName} was banned for being under level {Options.KickLowLevelPlayer.GetInt()} ", "BanLowLevelPlayer");
|
||||
Logger.SendInGame($" {__instance.Data.PlayerName} was banned for being under level {Options.KickLowLevelPlayer.GetInt()}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.ReportDeadBody))]
|
||||
class ReportDeadBodyPatch
|
||||
|
||||
Reference in new issue
Block a user