Skip to content
This repository has been archived by the owner on Dec 20, 2021. It is now read-only.

Commit

Permalink
Update for v2020.10.22 of Among Us + bump version to 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
andry08 committed Nov 11, 2020
1 parent 701bafc commit dba3317
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 69 deletions.
26 changes: 13 additions & 13 deletions RemovePlayerLimit/GenericPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ namespace RemovePlayerLimit {
class GenericPatches {
//static sbyte UniquePlayerId = 0;

[HarmonyPatch(typeof(GameData), nameof(GameData.GetAvailableId))]
[HarmonyPatch(typeof(BAGGGBBOHOH), nameof(BAGGGBBOHOH.GetAvailableId))]
public static class GameDataAvailableIdPatch {
public static bool Prefix(ref GameData __instance, ref sbyte __result) {
public static bool Prefix(ref BAGGGBBOHOH __instance, ref sbyte __result) {
//__result = UniquePlayerId++;
for (int i = 0; i < 128; i++)
if (checkId(__instance, i)) {
Expand All @@ -17,28 +17,28 @@ public static bool Prefix(ref GameData __instance, ref sbyte __result) {
return false;
}

static bool checkId(GameData __instance, int id) {
foreach (GameData.IHEKEPMDGIJ p in __instance.AllPlayers)
if (p.FIOIBHIDDOC == id)
static bool checkId(BAGGGBBOHOH __instance, int id) {
foreach (BAGGGBBOHOH.FGMBFCIIILC p in __instance.AllPlayers)
if (p.PAGHECLPIMH == id)
return false;
return true;
}
}

[HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.CheckColor), typeof(byte))]
[HarmonyPatch(typeof(GLHCHLEDNBA), nameof(GLHCHLEDNBA.CheckColor), typeof(byte))]
public static class PlayerControlCheckColorPatch {
public static bool Prefix(PlayerControl __instance, byte GBOFPFOGPJO) {
__instance.RpcSetColor(GBOFPFOGPJO);
public static bool Prefix(GLHCHLEDNBA __instance, byte AGLNDGIHLPG) {
__instance.RpcSetColor(AGLNDGIHLPG);
return false;
}
}

[HarmonyPatch(typeof(PlayerTab), nameof(PlayerTab.UpdateAvailableColors))]
[HarmonyPatch(typeof(DICIDCLJJFH), nameof(DICIDCLJJFH.UpdateAvailableColors))]
public static class PlayerTabUpdateAvailableColorsPatch {
public static bool Prefix(PlayerTab __instance) {
PlayerControl.SetPlayerMaterialColors(PlayerControl.LocalPlayer.FIPOLMBOBHM.LHKAPPDILFP, __instance.DemoImage);
for (int i = 0; i < KMGFBENDNFO.FOJPMGJFKMB.Length; i++)
__instance.FKAFOGKGPLM.Add(i);
public static bool Prefix(DICIDCLJJFH __instance) {
GLHCHLEDNBA.SetPlayerMaterialColors(GLHCHLEDNBA.LocalPlayer.HMPLOOHMKEN.LMDCNHODEAN, __instance.DemoImage);
for (int i = 0; i < KPNJLIGHOEI.FLKMIOFABCO.Length; i++)
__instance.JBGOCGMNPBP.Add(i);
return false;
}
}
Expand Down
88 changes: 46 additions & 42 deletions RemovePlayerLimit/MeetingHudPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@
using HarmonyLib;
using System.Linq;
using Hazel;
using System.Net.NetworkInformation;

namespace RemovePlayerLimit {
class MeetingHudPatches {
static string lastTimerText;
static int currentPage = 0;
static int maxPages {
get => (int)Mathf.Ceil(PlayerControl.AllPlayerControls.Count / 10f);
get => (int)Mathf.Ceil(GLHCHLEDNBA.AllPlayerControls.Count / 10f);
}

[HarmonyPatch(typeof(MeetingHud), nameof(MeetingHud.Update))]
[HarmonyPatch(typeof(GPOHFPAIEMA), nameof(GPOHFPAIEMA.Update))]
public static class VoteGuiPatch {
public static void Postfix(MeetingHud __instance) {
public static void Postfix(GPOHFPAIEMA __instance) {
if (Input.GetKeyDown(KeyCode.UpArrow) || Input.mouseScrollDelta.y > 0f)
currentPage = Mathf.Clamp(currentPage - 1, 0, maxPages - 1);
else if (Input.GetKeyDown(KeyCode.DownArrow) || Input.mouseScrollDelta.y < 0f)
Expand All @@ -22,9 +23,9 @@ public static void Postfix(MeetingHud __instance) {
if (__instance.TimerText.Text != lastTimerText)
__instance.TimerText.Text = (lastTimerText = __instance.TimerText.Text + $" ({currentPage + 1}/{maxPages})");

PlayerVoteArea[] playerButtons = __instance.FALDLDJHDDJ.OrderBy(x => x.isDead).ToArray();
LJEHDCNEKBG[] playerButtons = __instance.OMJGIAMFODK.OrderBy(x => x.isDead).ToArray();
int i = 0;
foreach (PlayerVoteArea button in playerButtons) {
foreach (LJEHDCNEKBG button in playerButtons) {
if (i >= currentPage * 10 && i < (currentPage + 1) * 10) {
button.gameObject.SetActive(true);

Expand All @@ -37,21 +38,21 @@ public static void Postfix(MeetingHud __instance) {
}
}

[HarmonyPatch(typeof(MeetingHud), nameof(MeetingHud.OIDNFMKACJP))]
[HarmonyPatch(typeof(GPOHFPAIEMA), nameof(GPOHFPAIEMA.HMHBIBHOCDO))]
public static class MeetingHudCheckForEndVotingPatch {
public static bool Prefix(MeetingHud __instance) {
if (__instance.FALDLDJHDDJ.All((PlayerVoteArea ps) => ps.isDead || ps.didVote)) {
byte[] self = calculateVotes(__instance.FALDLDJHDDJ);
public static bool Prefix(GPOHFPAIEMA __instance) {
if (__instance.OMJGIAMFODK.All((LJEHDCNEKBG ps) => ps.isDead || ps.didVote)) {
byte[] self = calculateVotes(__instance.OMJGIAMFODK);

int maxIdx = indexOfMax(self, out bool tie) - 1;
GameData.IHEKEPMDGIJ exiled = GameData.Instance.GetPlayerById((byte)maxIdx);
byte[] states = __instance.FALDLDJHDDJ.Select(s => s.GetState()).ToArray();
byte[] votes = __instance.FALDLDJHDDJ.Select(s => (byte)s.votedFor).ToArray();
BAGGGBBOHOH.FGMBFCIIILC exiled = BAGGGBBOHOH.Instance.GetPlayerById((byte)maxIdx);
byte[] states = __instance.OMJGIAMFODK.Select(s => s.GetState()).ToArray();
byte[] votes = __instance.OMJGIAMFODK.Select(s => (byte)s.votedFor).ToArray();

MessageWriter messageWriter = AmongUsClient.Instance.StartRpc(__instance.NetId, 23, SendOption.Reliable);
MessageWriter messageWriter = JNFEHNLGIFF.Instance.StartRpc(__instance.NetId, 23, SendOption.Reliable);
messageWriter.WriteBytesAndSize(states);
messageWriter.WriteBytesAndSize(votes); //Added because of the state's 4 bit vote id limit
messageWriter.Write((exiled != null) ? exiled.FIOIBHIDDOC : byte.MaxValue);
messageWriter.Write((exiled != null) ? exiled.PAGHECLPIMH : byte.MaxValue);
messageWriter.Write(tie);
messageWriter.EndMessage();

Expand All @@ -60,10 +61,10 @@ public static bool Prefix(MeetingHud __instance) {
return false;
}

static byte[] calculateVotes(PlayerVoteArea[] states) {
static byte[] calculateVotes(LJEHDCNEKBG[] states) {
byte[] self = new byte[states.Length + 1];
for (int i = 0; i < states.Length; i++) {
PlayerVoteArea playerVoteArea = states[i];
LJEHDCNEKBG playerVoteArea = states[i];
if (playerVoteArea.didVote)
if (playerVoteArea.votedFor + 1 >= 0 && playerVoteArea.votedFor + 1 < self.Length)
self[playerVoteArea.votedFor + 1]++;
Expand All @@ -90,24 +91,24 @@ static int indexOfMax(byte[] array, out bool tie) {
}
}

[HarmonyPatch(typeof(MeetingHud), nameof(MeetingHud.HandleRpc), typeof(byte), typeof(Hazel.MessageReader))]
[HarmonyPatch(typeof(GPOHFPAIEMA), nameof(GPOHFPAIEMA.HandleRpc), typeof(byte), typeof(Hazel.MessageReader))]
public static class MeetingHudHandleRpcPatch {
public static bool Prefix(MeetingHud __instance, byte DNHFGLIHAFB, Hazel.MessageReader IGFFAFNNIAB) {
switch (DNHFGLIHAFB) {
public static bool Prefix(GPOHFPAIEMA __instance, byte OPCIDHAAHLI, Hazel.MessageReader DNCHPFLHHEN) {
switch (OPCIDHAAHLI) {
case 22:
__instance.Close();
break;
case 23: {
byte[] states = IGFFAFNNIAB.ReadBytesAndSize();
byte[] votes = IGFFAFNNIAB.ReadBytesAndSize();
GameData.IHEKEPMDGIJ playerById = GameData.Instance.GetPlayerById(IGFFAFNNIAB.ReadByte());
bool tie = IGFFAFNNIAB.ReadBoolean();
byte[] states = DNCHPFLHHEN.ReadBytesAndSize();
byte[] votes = DNCHPFLHHEN.ReadBytesAndSize();
BAGGGBBOHOH.FGMBFCIIILC playerById = BAGGGBBOHOH.Instance.GetPlayerById(DNCHPFLHHEN.ReadByte());
bool tie = DNCHPFLHHEN.ReadBoolean();
VotingComplete(__instance, states, votes, playerById, tie);
break;
}
case 24: {
byte srcPlayerId = IGFFAFNNIAB.ReadByte();
sbyte suspectPlayerId = IGFFAFNNIAB.ReadSByte();
byte srcPlayerId = DNCHPFLHHEN.ReadByte();
sbyte suspectPlayerId = DNCHPFLHHEN.ReadSByte();
__instance.CastVote(srcPlayerId, suspectPlayerId);
break;
}
Expand All @@ -118,46 +119,49 @@ public static bool Prefix(MeetingHud __instance, byte DNHFGLIHAFB, Hazel.Message
return false;
}

public static void VotingComplete(MeetingHud __instance, byte[] states, byte[] votes, GameData.IHEKEPMDGIJ exiled, bool tie) {
if (__instance.FGFCFMNBKON == MeetingHud.IONNOOOEADE.Results) {
public static void VotingComplete(GPOHFPAIEMA __instance, byte[] states, byte[] votes, BAGGGBBOHOH.FGMBFCIIILC exiled, bool tie) {
if (__instance.FDLEFBMLMFM == GPOHFPAIEMA.DHLNNGGOJNI.Results) {
return;
}
__instance.FGFCFMNBKON = MeetingHud.IONNOOOEADE.Results;
__instance.JMHKAFCOGCM = __instance.discussionTimer;
__instance.BJOCHIGMCBL = exiled;
__instance.CEIGAJCFLEM = tie;
__instance.FDLEFBMLMFM = GPOHFPAIEMA.DHLNNGGOJNI.Results;
__instance.NFIBDGIOEIA = __instance.discussionTimer;
__instance.GKGOFBGECAK = exiled;
__instance.GBOFEFNNKCF = tie;
__instance.SkipVoteButton.gameObject.SetActive(false);
__instance.SkippedVoting.gameObject.SetActive(true);

PopulateResults(__instance, states, votes);
__instance.BFHIPKBGFGF();
__instance.LLMHJIDIDFK();
}

public static void PopulateResults(MeetingHud __instance, byte[] states, byte[] votes) {
public static void PopulateResults(GPOHFPAIEMA __instance, byte[] states, byte[] votes) {
__instance.TitleText.Text = "Voting Results";
int num = 0;
for (int i = 0; i < __instance.FALDLDJHDDJ.Length; i++) {
PlayerVoteArea playerVoteArea = __instance.FALDLDJHDDJ[i];
for (int i = 0; i < __instance.OMJGIAMFODK.Length; i++) {
LJEHDCNEKBG playerVoteArea = __instance.OMJGIAMFODK[i];
playerVoteArea.ClearForResults();
int num2 = 0;
for (int j = 0; j < states.Length; j++) {
if ((states[j] & 128) == 0) { //!isDead
GameData.IHEKEPMDGIJ playerById = GameData.Instance.GetPlayerById((byte)__instance.FALDLDJHDDJ[j].TargetPlayerId);
BAGGGBBOHOH.FGMBFCIIILC playerById = BAGGGBBOHOH.Instance.GetPlayerById((byte)__instance.OMJGIAMFODK[j].AGGEFFKBKLE);
int votedFor = (sbyte)votes[j];

SpriteRenderer spriteRenderer = UnityEngine.Object.Instantiate<SpriteRenderer>(__instance.PlayerVotePrefab);
PlayerControl.SetPlayerMaterialColors((int)playerById.LHKAPPDILFP, spriteRenderer);
if (GLHCHLEDNBA.GameOptions.IAFJLBELLDA)
GLHCHLEDNBA.SetPlayerMaterialColors(KPNJLIGHOEI.BAOLBIKEKEK, spriteRenderer);
else
GLHCHLEDNBA.SetPlayerMaterialColors((int)playerById.LMDCNHODEAN, spriteRenderer);
spriteRenderer.transform.localScale = Vector3.zero;

if ((int)playerVoteArea.TargetPlayerId == votedFor) {
if ((int)playerVoteArea.AGGEFFKBKLE == votedFor) {
spriteRenderer.transform.SetParent(playerVoteArea.transform);
spriteRenderer.transform.localPosition = __instance.BEDJEPCINAI + new Vector3(__instance.LNFHFGONEGA.x * (float)num2, 0f, 0f);
__instance.StartCoroutine(FBBJKJLHFKF.KGIPENFLALI((float)num2 * 0.5f, spriteRenderer.transform, 0.5f));
spriteRenderer.transform.localPosition = __instance.GOCOEAPLJFA + new Vector3(__instance.OHFLCOGINJN.x * (float)num2, 0f, 0f);
__instance.StartCoroutine(JDBGLNAEBLG.GBIKBPPNKEB((float)num2 * 0.5f, spriteRenderer.transform, 1f, 0.5f));
num2++;
} else if (i == 0 && votedFor == -1) {
spriteRenderer.transform.SetParent(__instance.SkippedVoting.transform);
spriteRenderer.transform.localPosition = __instance.BEDJEPCINAI + new Vector3(__instance.LNFHFGONEGA.x * (float)num, 0f, 0f);
__instance.StartCoroutine(FBBJKJLHFKF.KGIPENFLALI((float)num * 0.5f, spriteRenderer.transform, 0.5f));
spriteRenderer.transform.localPosition = __instance.GOCOEAPLJFA + new Vector3(__instance.OHFLCOGINJN.x * (float)num, 0f, 0f);
__instance.StartCoroutine(JDBGLNAEBLG.GBIKBPPNKEB((float)num * 0.5f, spriteRenderer.transform, 1f, 0.5f));
num++;
}
}
Expand Down
24 changes: 12 additions & 12 deletions RemovePlayerLimit/RemovePlayerLimit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,29 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="0Harmony">
<HintPath>..\..\Among.Us.Incl.DLC.v09.22.2020s\BepInEx\core\0Harmony.dll</HintPath>
<HintPath>..\..\Among.Us.v2020.10.22s\BepInEx\core\0Harmony.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp">
<HintPath>..\..\Among.Us.Incl.DLC.v09.22.2020s\BepInEx\unhollowed\Assembly-CSharp.dll</HintPath>
<HintPath>..\..\Among.Us.v2020.10.22s\BepInEx\unhollowed\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="BepInEx.Core">
<HintPath>..\..\Among.Us.Incl.DLC.v09.22.2020s\BepInEx\core\BepInEx.Core.dll</HintPath>
<HintPath>..\..\Among.Us.v2020.10.22s\BepInEx\core\BepInEx.Core.dll</HintPath>
</Reference>
<Reference Include="BepInEx.Harmony">
<HintPath>..\..\Among.Us.Incl.DLC.v09.22.2020s\BepInEx\core\BepInEx.Harmony.dll</HintPath>
<HintPath>..\..\Among.Us.v2020.10.22s\BepInEx\core\BepInEx.Harmony.dll</HintPath>
</Reference>
<Reference Include="BepInEx.IL2CPP">
<HintPath>..\..\Among.Us.Incl.DLC.v09.22.2020s\BepInEx\core\BepInEx.IL2CPP.dll</HintPath>
<HintPath>..\..\Among.Us.v2020.10.22s\BepInEx\core\BepInEx.IL2CPP.dll</HintPath>
</Reference>
<Reference Include="Hazel, Version=3.7.1.6, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Among.Us.Incl.DLC.v09.22.2020s\BepInEx\unhollowed\Hazel.dll</HintPath>
<HintPath>..\..\Among.Us.v2020.10.22s\BepInEx\unhollowed\Hazel.dll</HintPath>
</Reference>
<Reference Include="Il2Cppmscorlib">
<HintPath>..\..\Among.Us.Incl.DLC.v09.22.2020s\BepInEx\unhollowed\Il2Cppmscorlib.dll</HintPath>
<HintPath>..\..\Among.Us.v2020.10.22s\BepInEx\unhollowed\Il2Cppmscorlib.dll</HintPath>
</Reference>
<Reference Include="Il2CppSystem.Core">
<HintPath>..\..\Among.Us.Incl.DLC.v09.22.2020s\BepInEx\unhollowed\Il2CppSystem.Core.dll</HintPath>
<HintPath>..\..\Among.Us.v2020.10.22s\BepInEx\unhollowed\Il2CppSystem.Core.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand All @@ -64,17 +64,17 @@
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="UnhollowerBaseLib">
<HintPath>..\..\Among.Us.Incl.DLC.v09.22.2020s\BepInEx\unhollowed\UnhollowerBaseLib.dll</HintPath>
<HintPath>..\..\Among.Us.v2020.10.22s\BepInEx\unhollowed\UnhollowerBaseLib.dll</HintPath>
</Reference>
<Reference Include="UnityEngine">
<HintPath>..\..\Among.Us.Incl.DLC.v09.22.2020s\BepInEx\unhollowed\UnityEngine.dll</HintPath>
<HintPath>..\..\Among.Us.v2020.10.22s\BepInEx\unhollowed\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule, Version=3.7.1.6, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Among.Us.Incl.DLC.v09.22.2020s_dev\BepInEx\unhollowed\UnityEngine.CoreModule.dll</HintPath>
<HintPath>..\..\Among.Us.v2020.10.22s\BepInEx\unhollowed\UnityEngine.CoreModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.InputLegacyModule">
<HintPath>..\..\Among.Us.Incl.DLC.v09.22.2020s\BepInEx\unhollowed\UnityEngine.InputLegacyModule.dll</HintPath>
<HintPath>..\..\Among.Us.v2020.10.22s\BepInEx\unhollowed\UnityEngine.InputLegacyModule.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions RemovePlayerLimit/RemovePlayerLimitPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Reflection;

namespace RemovePlayerLimit {
[BepInPlugin("it.andry08.removeplayerlimit", "Player Limit Remove", "1.2")]
[BepInPlugin("it.andry08.removeplayerlimit", "Player Limit Remove", "2.0")]
public class RemovePlayerLimitPlugin : BasePlugin {

static internal BepInEx.Logging.ManualLogSource Logger;
Expand All @@ -14,7 +14,7 @@ public class RemovePlayerLimitPlugin : BasePlugin {
public override void Load() {
Logger = Log;

OPIJAMILNFD.DECPEFPMMMF = OPIJAMILNFD.DKLBMBAFBAE = Enumerable.Repeat<int>(255, 255).ToArray<int>();
OEFJGMAEENB.HLNGFFNMJOP = OEFJGMAEENB.ALNGMJFMDHA = Enumerable.Repeat<int>(255, 255).ToArray<int>();
_harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly());
}
}
Expand Down

0 comments on commit dba3317

Please sign in to comment.