Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V1.1.3 beta #3

Merged
merged 3 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@

| Unlock Cosmetics | Account Patches | Chat Patches |
|------------------|------------------------|------------------------------|
| Hats | Unlock free chat | No cooldown between messages |
| Visors | Unlock friend list | No character limit |
| Skins | Unlock custom name | Copy-pasting allowed |
| Pets | Unlock online gameplay | URLs and Emails allowed |
| Nameplates | Remove "minor" status | Special characters allowed |
| Hats | Unlock free chat | Copy-pasting allowed |
| Visors | Unlock friend list | URLs and Emails allowed |
| Skins | Unlock custom name | Special characters allowed |
| Pets | Unlock online gameplay |
| Nameplates | Remove "minor" status |
| Cosmicubes | |
| Bundles | |

Expand Down
37 changes: 0 additions & 37 deletions source/AUnlockerPlugin.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
using AmongUs.Data;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Hazel;
// using Assets.CoreScripts;
// using System;
// using System.Collections.Generic;
// using System.Linq;
// using System.Runtime.CompilerServices;
// using System.Text;
// using UnityEngine;


namespace AUnlocker;

Expand All @@ -25,30 +14,4 @@ public override void Load()
{
Harmony.PatchAll();
}


// ref bool __result stores the return value of the original AU method (e.g. IsFreechatAllowed)
// By setting __result to true, the original method returns true (-> e.g. enables freechat).
// In harmony, 'return false' from prefix method -> original method does NOT get executed after prefix


// Bypass Anticheat kicking you from the lobby if you send long messages
[HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.RpcSendChat))]
public static class BypassAnticheatAndRatelimit
{
public static bool Prefix(PlayerControl __instance, string chatText, ref bool __result)
{
// If the player is a client and the HudManager exists, add the chat to the local chat log
if (AmongUsClient.Instance.AmClient && DestroyableSingleton<HudManager>.Instance)
DestroyableSingleton<HudManager>.Instance.Chat.AddChat(__instance, chatText);

// Start an RPC (Remote Procedure Call) to send the chat message to other players. SendOption.None bypasses anticheat
MessageWriter messageWriter = AmongUsClient.Instance.StartRpc(__instance.NetId, (byte)RpcCalls.SendChat, SendOption.None);
messageWriter.Write(chatText);
messageWriter.EndMessage();

__result = true;
return false;
}
}
}
56 changes: 9 additions & 47 deletions source/ChatPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,57 +4,26 @@
namespace AUnlocker;


// Bypass chat limits (special characters, ctrl+v enabled, etc.)
// ChatJailbreak
[HarmonyPatch(typeof(ChatController), nameof(ChatController.Update))]
public static class BypassChatLimit
public static class ChatJailbreak_ChatController_Update_Postfix
{
public static void Postfix(ChatController __instance)
{
if (!__instance.freeChatField.textArea.hasFocus) return;
// no 3s cooldown when sending messages
__instance.timeSinceLastMessage = 3f;
// no character limit
__instance.freeChatField.textArea.characterLimit = int.MaxValue;
// allow Ctrl + C and Ctrl + V
__instance.freeChatField.textArea.AllowPaste = true;
// allow symbols
__instance.freeChatField.textArea.AllowSymbols = true;
// allow emails
__instance.freeChatField.textArea.AllowEmail = true;

}
}


// Edit Color indicators for chatbox (only visual)
[HarmonyPatch(typeof(FreeChatInputField), nameof(FreeChatInputField.UpdateCharCount))]
public static class EditColorIndicators
{
public static void Postfix(FreeChatInputField __instance)
{
int length = __instance.textArea.text.Length;
// Show new character limit of 300 / 999 instead of vanilla 100 below text field
__instance.charCountText.SetText($"{length}/{__instance.textArea.characterLimit}");
if (length < (AmongUsClient.Instance.AmHost ? 888 : 250))
// Black if not close to limit
__instance.charCountText.color = Color.black;
else if (length < (AmongUsClient.Instance.AmHost ? 999 : 300))
// Yellow if close to limit
__instance.charCountText.color = new Color(1f, 1f, 0f, 1f);
else
// Red if limit reached
__instance.charCountText.color = Color.red;
}
}


// Allow URLs in messages
[HarmonyPatch(typeof(ChatController), nameof(ChatController.SendFreeChat))]
public static class AllowURLS
public static class AllowURLS_ChatController_SendFreeChat_Prefix
{
public static bool Prefix(ChatController __instance)
{
// Remove deletion of any URLs
string text = __instance.freeChatField.Text;
ChatController.Logger.Debug("SendFreeChat () :: Sending message: '" + text + "'", null);
PlayerControl.LocalPlayer.RpcSendChat(text);
Expand All @@ -65,40 +34,33 @@ public static bool Prefix(ChatController __instance)

// Allow special characters
[HarmonyPatch(typeof(TextBoxTMP), nameof(TextBoxTMP.IsCharAllowed))]
public static class AllowAllCharacters
public static class AllowAllCharacters_TextBoxTMP_IsCharAllowed_Prefix
{
public static bool Prefix(TextBoxTMP __instance, ref bool __result)
public static bool Prefix(TextBoxTMP __instance, char i, ref bool __result)
{
// Set IsCharAllowed to always return true => every character is allowed
__result = true;
__result = !(i == '\b'); // Bugfix: '\b' messing with chat message
return false;
}

public static void Postfix(TextBoxTMP __instance)
{
__instance.allowAllCharacters = true; // not used by game's code, but I include it anyway
__instance.AllowEmail = true; // self-explanatory
__instance.AllowEmail = true;
__instance.AllowPaste = true;
__instance.AllowSymbols = true;
}

// Fix weird backspace bug that occurs when allowing any symbol
public static bool Prefix(TextBoxTMP __instance, char i, ref bool __result)
{
__result = !(i == '\b');
return false;
}
}


// Allow copying from the chatbox
[HarmonyPatch(typeof(TextBoxTMP), nameof(TextBoxTMP.Update))]
public static class AllowCopy
public static class AllowCopy_TextBoxTMP_Update_Postfix
{
public static void Postfix(TextBoxTMP __instance)
{
if (!__instance.hasFocus){return;}

// If player presses Ctrl + C, copy the text from the chatbox to the clipboard
if((Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)) && Input.GetKeyDown(KeyCode.C))
{
ClipboardHelper.PutClipboardString(__instance.text);
Expand Down
Loading