mirror of
https://github.com/D1GQ/BetterAmongUs.git
synced 2026-10-20 01:46:19 +00:00
Experimental setting and error fixes
This commit is contained in:
1 parent
af7596c406
commit
d292cc8fd0
7 files changed
+68
-21
No files matched your search
@@ -325,8 +325,6 @@ class AntiCheat
|
||||
// Check game states when sabotaging
|
||||
public static bool RpcUpdateSystemCheck(PlayerControl player, SystemTypes systemType, byte amount)
|
||||
{
|
||||
return true;
|
||||
|
||||
byte hostNum = 128; // Only host should ever send this number
|
||||
byte singleFixNum = 0;
|
||||
byte minLightNum = 0;
|
||||
@@ -360,6 +358,9 @@ class AntiCheat
|
||||
if (!GameStates.IsHost || PlayerControl.LocalPlayer == null || player == null || player == PlayerControl.LocalPlayer || player.BetterData().IsBetterHost || !IsEnabled || !Main.AntiCheat.Value
|
||||
|| (GameStates.IsBetterHostLobby && !GameStates.IsHost) || !BetterGameSettings.DetectInvalidRPCs.GetBool()) return true;
|
||||
|
||||
if (!BetterGameSettings.ExperimentalDetectInvalidSabotage.GetBool())
|
||||
return true;
|
||||
|
||||
// Single Fix: 0
|
||||
// Lights: 0-1-2-3-4
|
||||
// Fix 1: 16
|
||||
|
||||
@@ -23,6 +23,12 @@ public class BetterOptionCheckboxItem : BetterOptionItem
|
||||
optionBehaviour.OnValueChanged = new Action<OptionBehaviour>((option) => ValueChanged(id, option));
|
||||
SpacingNum += StaticSpacingNumPlus;
|
||||
|
||||
// Fix Game Crash
|
||||
foreach (RulesCategory rulesCategory in GameManager.Instance.GameSettingsList.AllCategories)
|
||||
{
|
||||
optionBehaviour.data = rulesCategory.AllGameSettings.ToArray().FirstOrDefault(item => item.Type == OptionTypes.Checkbox);
|
||||
}
|
||||
|
||||
// Set data
|
||||
optionBehaviour.CheckMark.GetComponent<SpriteRenderer>().enabled = Default;
|
||||
IsChecked = Default;
|
||||
|
||||
@@ -168,4 +168,8 @@ public class BetterOptionFloatItem : BetterOptionItem
|
||||
Type = OptionTypes.Float,
|
||||
};
|
||||
}
|
||||
|
||||
public override void ValueChanged(int id, OptionBehaviour optionBehaviour)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -168,4 +168,8 @@ public class BetterOptionIntItem : BetterOptionItem
|
||||
Type = OptionTypes.Float,
|
||||
};
|
||||
}
|
||||
|
||||
public override void ValueChanged(int id, OptionBehaviour optionBehaviour)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,12 @@ public class BetterOptionStringItem : BetterOptionItem
|
||||
optionBehaviour.OnValueChanged = new Action<OptionBehaviour>((option) => ValueChanged(id, option));
|
||||
SpacingNum += StaticSpacingNumPlus;
|
||||
|
||||
// Fix Game Crash
|
||||
foreach (RulesCategory rulesCategory in GameManager.Instance.GameSettingsList.AllCategories)
|
||||
{
|
||||
optionBehaviour.data = rulesCategory.AllGameSettings.ToArray().FirstOrDefault(item => item.Type == OptionTypes.String);
|
||||
}
|
||||
|
||||
optionBehaviour.PlusBtn.OnClick.RemoveAllListeners();
|
||||
optionBehaviour.MinusBtn.OnClick.RemoveAllListeners();
|
||||
optionBehaviour.PlusBtn.OnClick.AddListener(new Action(() => Increase()));
|
||||
@@ -124,4 +130,8 @@ public class BetterOptionStringItem : BetterOptionItem
|
||||
Type = OptionTypes.String,
|
||||
};
|
||||
}
|
||||
|
||||
public override void ValueChanged(int id, OptionBehaviour optionBehaviour)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ public class BetterOptionTitleItem : BetterOptionItem
|
||||
SpacingNum += StaticSpacingNumPlus;
|
||||
|
||||
UnityEngine.Object.Destroy(optionBehaviour.CheckMark.transform.parent.gameObject);
|
||||
UnityEngine.Object.Destroy(optionBehaviour.GetComponent<ToggleOption>());
|
||||
optionBehaviour.TitleText.alignment = TMPro.TextAlignmentOptions.Center;
|
||||
optionBehaviour.TitleText.outlineColor = Color.black;
|
||||
optionBehaviour.TitleText.outlineWidth = 0.2f;
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
using AmongUs.GameOptions;
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
using static Il2CppSystem.Linq.Expressions.Interpreter.CastInstruction.CastInstructionNoT;
|
||||
using static Logger;
|
||||
|
||||
namespace BetterAmongUs.Patches;
|
||||
|
||||
@@ -18,6 +16,8 @@ class BetterGameSettings
|
||||
public static BetterOptionItem? DetectedLevelAbove;
|
||||
public static BetterOptionItem? DetectCheatClients;
|
||||
public static BetterOptionItem? DetectInvalidRPCs;
|
||||
|
||||
public static BetterOptionItem? ExperimentalDetectInvalidSabotage;
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(GameSettingMenu))]
|
||||
@@ -25,30 +25,37 @@ static class GameSettingMenuPatch
|
||||
{
|
||||
private static PassiveButton BetterSettingsButton;
|
||||
public static GameOptionsMenu BetterSettingsTab;
|
||||
private static List<BetterOptionItem> TitleList = [];
|
||||
|
||||
public static void SetupSettings(bool IsPreload = false)
|
||||
{
|
||||
BetterOptionItem.SpacingNum = 0;
|
||||
BetterOptionItem.BetterOptionItems.Clear();
|
||||
TitleList.Clear();
|
||||
|
||||
// Anti-Cheat Settings
|
||||
{
|
||||
new BetterOptionHeaderItem().Create(BetterSettingsTab, "<color=#4f92ff>Anti-Cheat Settings</color>");
|
||||
TitleList.Add(new BetterOptionHeaderItem().Create(BetterSettingsTab, "<color=#4f92ff>Anti-Cheat Settings</color>"));
|
||||
|
||||
if (IsPreload || GameStates.IsHost)
|
||||
{
|
||||
new BetterOptionTitleItem().Create(BetterSettingsTab, $"<color=#4f92ff>Host Only</color>");
|
||||
TitleList.Add(new BetterOptionTitleItem().Create(BetterSettingsTab, $"<color=#4f92ff>Host Only</color>"));
|
||||
BetterGameSettings.WhenCheating = new BetterOptionStringItem().Create(100, BetterSettingsTab, "When a player is caught cheating", ["Do Nothing", "Kick", "Ban"], 2);
|
||||
BetterGameSettings.InvalidFriendCode = new BetterOptionCheckboxItem().Create(200, BetterSettingsTab, "Allow invalid friendCodes", true);
|
||||
BetterGameSettings.UseBanPlayerList = new BetterOptionCheckboxItem().Create(300, BetterSettingsTab, "Use Ban Player List", true);
|
||||
BetterGameSettings.UseBanNameList = new BetterOptionCheckboxItem().Create(400, BetterSettingsTab, "Use Ban Name List", true);
|
||||
BetterGameSettings.UseBanWordList = new BetterOptionCheckboxItem().Create(500, BetterSettingsTab, "Use Ban Word List", true);
|
||||
new BetterOptionDividerItem().Create(BetterSettingsTab);
|
||||
TitleList.Add(new BetterOptionDividerItem().Create(BetterSettingsTab));
|
||||
}
|
||||
|
||||
new BetterOptionTitleItem().Create(BetterSettingsTab, $"<color=#4f92ff>Detections</color>");
|
||||
TitleList.Add(new BetterOptionTitleItem().Create(BetterSettingsTab, $"<color=#4f92ff>Detections</color>"));
|
||||
BetterGameSettings.DetectedLevelAbove = new BetterOptionIntItem().Create(600, BetterSettingsTab, "Detected player level # or >", [100, 1000, 5], 200, "Lv ", "");
|
||||
BetterGameSettings.DetectCheatClients = new BetterOptionCheckboxItem().Create(700, BetterSettingsTab, "Detect Cheat Clients", true);
|
||||
BetterGameSettings.DetectInvalidRPCs = new BetterOptionCheckboxItem().Create(800, BetterSettingsTab, "Detect Invalid RPCs", true);
|
||||
|
||||
TitleList.Add(new BetterOptionDividerItem().Create(BetterSettingsTab));
|
||||
TitleList.Add(new BetterOptionTitleItem().Create(BetterSettingsTab, $"<color=#f20>Experimental</color>"));
|
||||
BetterGameSettings.ExperimentalDetectInvalidSabotage = new BetterOptionCheckboxItem().Create(100000, BetterSettingsTab, "Detect Invalid Sabotages", false);
|
||||
}
|
||||
|
||||
// Gameplay Settings
|
||||
@@ -83,7 +90,7 @@ static class GameSettingMenuPatch
|
||||
*/
|
||||
|
||||
if (BetterSettingsTab != null)
|
||||
BetterSettingsTab.scrollBar.SetYBoundsMax(1.15f * BetterOptionItem.SpacingNum / 2);
|
||||
BetterSettingsTab.scrollBar.SetYBoundsMax(1.25f * BetterOptionItem.SpacingNum / 2);
|
||||
}
|
||||
|
||||
private static void Initialize()
|
||||
@@ -92,9 +99,12 @@ static class GameSettingMenuPatch
|
||||
{
|
||||
foreach (var item in BetterOptionItem.BetterOptionItems)
|
||||
{
|
||||
if (item.TitleText != null)
|
||||
if (item != null)
|
||||
{
|
||||
item.TitleText.text = item.Name;
|
||||
if (item.TitleText != null)
|
||||
{
|
||||
item.TitleText.text = item.Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 0.005f, shoudLog: false);
|
||||
@@ -269,6 +279,7 @@ static class NumberOptionPatch
|
||||
__instance.UpdateValue();
|
||||
return false;
|
||||
}
|
||||
|
||||
[HarmonyPatch(nameof(NumberOption.Decrease))]
|
||||
[HarmonyPrefix]
|
||||
public static bool Decrease_Prefix(NumberOption __instance)
|
||||
@@ -283,6 +294,7 @@ static class NumberOptionPatch
|
||||
__instance.UpdateValue();
|
||||
return false;
|
||||
}
|
||||
|
||||
[HarmonyPatch(nameof(NumberOption.UpdateValue))]
|
||||
[HarmonyPrefix]
|
||||
public static bool UpdateValue_Prefix(NumberOption __instance)
|
||||
@@ -299,26 +311,35 @@ static class NumberOptionPatch
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
[HarmonyPatch(nameof(NumberOption.FixedUpdate))]
|
||||
[HarmonyPrefix]
|
||||
public static bool FixedUpdate_Prefix(NumberOption __instance)
|
||||
{
|
||||
__instance.MinusBtn.SetInteractable(true);
|
||||
__instance.PlusBtn.SetInteractable(true);
|
||||
|
||||
if (__instance.oldValue != __instance.Value)
|
||||
try
|
||||
{
|
||||
__instance.oldValue = __instance.Value;
|
||||
|
||||
if (__instance.Value > __instance.ValidRange.max || __instance.Value < __instance.ValidRange.min)
|
||||
if (__instance.MinusBtn != null && __instance.PlusBtn != null)
|
||||
{
|
||||
__instance.ValueText.text = $"<color=#f20>{__instance.data.GetValueString(__instance.Value)}</color>";
|
||||
__instance.MinusBtn.SetInteractable(true);
|
||||
__instance.PlusBtn.SetInteractable(true);
|
||||
}
|
||||
else
|
||||
|
||||
if (__instance.oldValue != __instance.Value)
|
||||
{
|
||||
__instance.ValueText.text = __instance.data.GetValueString(__instance.Value);
|
||||
__instance.oldValue = __instance.Value;
|
||||
|
||||
if (__instance.Value > __instance.ValidRange.max || __instance.Value < __instance.ValidRange.min)
|
||||
{
|
||||
__instance.ValueText.text = $"<color=#f20>{__instance.data.GetValueString(__instance.Value)}</color>";
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.ValueText.text = __instance.data.GetValueString(__instance.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user