Skip to content

Commit

Permalink
Version v2.6.3
Browse files Browse the repository at this point in the history
  • Loading branch information
thunderstorm584 committed May 13, 2021
1 parent db9394d commit d64de10
Show file tree
Hide file tree
Showing 10 changed files with 394 additions and 217 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ The [Role Assignment](#role-assignment) sections explains how the roles are bein
# Releases
| Among Us - Version| Mod Version | Link |
|----------|-------------|-----------------|
| 2021.5.10s| v2.6.3| [Download](https://github.com/Eisbison/TheOtherRoles/releases/download/v2.6.3/TheOtherRoles.zip)
| 2021.5.10s| v2.6.2| [Download](https://github.com/Eisbison/TheOtherRoles/releases/download/v2.6.2/TheOtherRoles.zip)
| 2021.4.14s| v2.6.1| [Download](https://github.com/Eisbison/TheOtherRoles/releases/download/v2.6.1/TheOtherRoles.zip)
| 2021.4.14s| v2.6.0| [Download](https://github.com/Eisbison/TheOtherRoles/releases/download/v2.6.0/TheOtherRoles.zip)
Expand Down Expand Up @@ -61,6 +62,10 @@ The [Role Assignment](#role-assignment) sections explains how the roles are bein
<details>
<summary>Click to show the Changelog</summary>

**Version 2.6.3**
- Changed the role limits options to allow for minimum and maximum bounds
- Changed the role assignment to be more random when assigning roles (previously assigned the neutral roles before assigning the crewmate roles)

**Version 2.6.2**
- The Other Roles now supports the new Among Us version **2021.5.10s**
- Added a chat command to kick players as the host of a lobby (/kick playerName)
Expand Down Expand Up @@ -376,7 +381,7 @@ First you need to choose how many special roles of each kind (Impostor/Neutral/C
The count you set will only be reached, if there are enough Crewmates/Impostors in the game and if enough roles are set to be in the game (i.e. they are set to > 0%). The roles are then being distributed as follows:
- First all roles that are set to 100% are being assigned to arbitrary players
- After that each role that has 10%-90% selected adds 1-9 tickets to a ticket pool (there exists a ticket pool for Crewmates, Neutrals and Impostors). Then the roles will be selected randomly from the pools as long it's possible (until the selected number is reached, until there are no more Crewmates/Impostors or until there are no more tickets). If a role is selected from the pool, obviously all the tickets of that role are being removed.
- The Mafia, Lovers and Child are being selected independently (without using the ticket system) according to the spawn chance you selected. After that all Neutral roles are being selected, then all Crewmate roles and in the very end all Impostor roles.
- The Mafia, Lovers and Child are being selected independently (without using the ticket system) according to the spawn chance you selected. After that the Crewmate, Neutral and Impostor roles are selected and assigned in a random order.

**Example:**\
Settings: 2 special Crewmate roles, Snitch: 100%, Hacker: 10%, Tracker: 30%\
Expand Down
65 changes: 49 additions & 16 deletions Source Code/CredentialsPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,39 +11,72 @@ namespace TheOtherRoles
[HarmonyPatch]
public static class CredentialsPatch {
public static string fullCredentials =
$@"<color=#FCCE03FF>TheOtherRoles</color> v{TheOtherRolesPlugin.Version.ToString()}:
- Modded by <color=#FCCE03FF>Eisbison</color>,
<color=#FFEB91FF>Thunderstorm584</color> and <color=#FFEB91FF>EndOfFile</color>
- Balanced with <color=#FFEB91FF>Dhalucard</color>
- Button design by <color=#FFEB91FF>Bavari</color>";
$@"<size=130%><color=#ff351f>TheOtherRoles</color></size> v{TheOtherRolesPlugin.Version.ToString()}
<size=80%>Modded by <color=#FCCE03FF>Eisbison</color>,
<color=#FCCE03FF>Thunderstorm584</color> & <color=#FCCE03FF>EndOfFile</color>
Balanced with <color=#FCCE03FF>Dhalucard</color>
Button design by <color=#FCCE03FF>Bavari</color></size>";

public static string mainMenuCredentials =
$@"Modded by <color=#FCCE03FF>Eisbison</color>, <color=#FCCE03FF>Thunderstorm584</color> & <color=#FCCE03FF>EndOfFile</color>
Balanced with <color=#FCCE03FF>Dhalucard</color> Design by <color=#FCCE03FF>Bavari</color>";

[HarmonyPatch(typeof(VersionShower), nameof(VersionShower.Start))]
private static class VersionShowerPatch
{
static void Postfix(VersionShower __instance) {
string spacer = new String('\n', 8);
var amongUsLogo = GameObject.Find("bannerLogo_AmongUs");
if (amongUsLogo == null) return;

var credentials = UnityEngine.Object.Instantiate<TMPro.TextMeshPro>(__instance.text);
credentials.transform.position = new Vector3(0, 0.1f, 0);
credentials.SetText(mainMenuCredentials);
credentials.alignment = TMPro.TextAlignmentOptions.Center;
credentials.fontSize *= 0.75f;

var version = UnityEngine.Object.Instantiate<TMPro.TextMeshPro>(credentials);
version.transform.position = new Vector3(0, -0.25f, 0);
version.SetText($"v{TheOtherRolesPlugin.Version.ToString()}");

if (__instance.text.text.Contains(spacer))
__instance.text.text = __instance.text.text + "\n" + fullCredentials;
else
__instance.text.text = __instance.text.text + spacer + fullCredentials;
__instance.text.alignment = TMPro.TextAlignmentOptions.TopLeft;
credentials.transform.SetParent(amongUsLogo.transform);
version.transform.SetParent(amongUsLogo.transform);
}
}

[HarmonyPatch(typeof(PingTracker), nameof(PingTracker.Update))]
private static class PingTrackerPatch
{
static void Postfix(PingTracker __instance)
{
static void Postfix(PingTracker __instance){
__instance.text.alignment = TMPro.TextAlignmentOptions.TopRight;
if (AmongUsClient.Instance.GameState == InnerNet.InnerNetClient.GameStates.Started) {
__instance.text.text = "<color=#FCCE03FF>TheOtherRoles</color>\nModded by <color=#FCCE03FF>Eisbison</color>\n" + __instance.text.text;
__instance.transform.localPosition = new Vector3(2.583f, 2.675f, __instance.transform.localPosition.z);
__instance.text.text = $"<size=130%><color=#ff351f>TheOtherRoles</color></size> v{TheOtherRolesPlugin.Version.ToString()}\n" + __instance.text.text;
if (PlayerControl.LocalPlayer.Data.IsDead) {
__instance.transform.localPosition = new Vector3(3.45f, 2.675f, __instance.transform.localPosition.z);
} else {
__instance.transform.localPosition = new Vector3(4.2f, 2.675f, __instance.transform.localPosition.z);
}
} else {
__instance.text.text = $"{fullCredentials}\n{__instance.text.text}";
__instance.transform.localPosition = new Vector3(1.25f, 2.675f, __instance.transform.localPosition.z);
__instance.transform.localPosition = new Vector3(3.5f, 2.675f, __instance.transform.localPosition.z);
}
}
}

[HarmonyPatch(typeof(MainMenuManager), nameof(MainMenuManager.Start))]
private static class LogoPatch
{
static void Postfix(PingTracker __instance) {
var amongUsLogo = GameObject.Find("bannerLogo_AmongUs");
if (amongUsLogo != null) {
amongUsLogo.transform.localScale *= 0.6f;
amongUsLogo.transform.position += Vector3.up * 0.25f;
}

var torLogo = new GameObject("bannerLogo_TOR");
torLogo.transform.position = Vector3.up;
var renderer = torLogo.AddComponent<SpriteRenderer>();
renderer.sprite = Helpers.loadSpriteFromResources("TheOtherRoles.Resources.Banner.png", 300f);
}
}
}
}
97 changes: 84 additions & 13 deletions Source Code/CustomHats.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
extern alias Il2CppNewtonsoft;
using System;
using BepInEx;
using BepInEx.Configuration;
Expand All @@ -19,8 +18,8 @@
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using System.Security.Cryptography;
using Il2CppNewtonsoft::Newtonsoft.Json.Linq;
using Il2CppNewtonsoft::Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;

namespace TheOtherRoles {
[HarmonyPatch]
Expand All @@ -29,11 +28,14 @@ public class CustomHats {
public static Material hatShader;

public static Dictionary<string, HatExtension> CustomHatRegistry = new Dictionary<string, HatExtension>();
public static HatExtension TestExt = null;

public class HatExtension {
public string author { get; set;}
public string package { get; set;}
public string condition { get; set;}
public Sprite FlipImage { get; set;}
public Sprite BackFlipImage { get; set;}

public bool isUnlocked() {
if (condition == null || condition.ToLower() == "none")
Expand All @@ -48,6 +50,8 @@ public class CustomHat {
public string condition { get; set;}
public string name { get; set;}
public string resource { get; set;}
public string flipresource { get; set;}
public string backflipresource { get; set;}
public string backresource { get; set;}
public string climbresource { get; set;}
public bool bounce { get; set;}
Expand All @@ -58,6 +62,8 @@ public class CustomHat {
private static List<CustomHat> createCustomHatDetails(string[] hats, bool fromDisk = false) {
Dictionary<string, CustomHat> fronts = new Dictionary<string, CustomHat>();
Dictionary<string, string> backs = new Dictionary<string, string>();
Dictionary<string, string> flips = new Dictionary<string, string>();
Dictionary<string, string> backflips = new Dictionary<string, string>();
Dictionary<string, string> climbs = new Dictionary<string, string>();

for (int i = 0; i < hats.Length; i++) {
Expand All @@ -68,11 +74,15 @@ private static List<CustomHat> createCustomHatDetails(string[] hats, bool fromDi
for (int j = 1; j < p.Length; j++)
options.Add(p[j]);

if (options.Contains("climb"))
if (options.Contains("back") && options.Contains("flip"))
backflips.Add(p[0], hats[i]);
else if (options.Contains("climb"))
climbs.Add(p[0], hats[i]);
if (options.Contains("back"))
else if (options.Contains("back"))
backs.Add(p[0], hats[i]);
if (!options.Contains("back") && !options.Contains("climb")) {
else if (options.Contains("flip"))
flips.Add(p[0], hats[i]);
else {
CustomHat custom = new CustomHat { resource = hats[i] };
custom.name = p[0].Replace('-', ' ');
custom.bounce = options.Contains("bounce");
Expand All @@ -87,13 +97,19 @@ private static List<CustomHat> createCustomHatDetails(string[] hats, bool fromDi

foreach (string k in fronts.Keys) {
CustomHat hat = fronts[k];
string br, cr;
string br, cr, fr, bfr;
backs.TryGetValue(k, out br);
climbs.TryGetValue(k, out cr);
flips.TryGetValue(k, out fr);
backflips.TryGetValue(k, out bfr);
if (br != null)
hat.backresource = br;
if (cr != null)
hat.climbresource = cr;
if (fr != null)
hat.flipresource = fr;
if (bfr != null)
hat.backflipresource = bfr;
if (hat.backresource != null)
hat.behind = true;

Expand Down Expand Up @@ -136,12 +152,20 @@ private static HatBehaviour CreateHatBehaviour(CustomHat ch, bool fromDisk = fal
if (ch.adaptive && hatShader != null)
hat.AltShader = hatShader;

if (!testOnly) {
HatExtension extend = new HatExtension();
extend.author = ch.author != null ? ch.author : "Unknown";
extend.package = ch.package != null ? ch.package : "Misc.";
extend.condition = ch.condition != null ? ch.condition : "none";
HatExtension extend = new HatExtension();
extend.author = ch.author != null ? ch.author : "Unknown";
extend.package = ch.package != null ? ch.package : "Misc.";
extend.condition = ch.condition != null ? ch.condition : "none";

if (ch.flipresource != null)
extend.FlipImage = CreateHatSprite(ch.flipresource, fromDisk);
if (ch.backflipresource != null)
extend.BackFlipImage = CreateHatSprite(ch.backflipresource, fromDisk);

if (testOnly) {
TestExt = extend;
TestExt.condition = hat.name;
} else {
CustomHatRegistry.Add(hat.name, extend);
}

Expand All @@ -155,6 +179,10 @@ private static HatBehaviour CreateHatBehaviour(CustomHatLoader.CustomHatOnline c
chd.backresource = filePath + chd.backresource;
if (chd.climbresource != null)
chd.climbresource = filePath + chd.climbresource;
if (chd.flipresource != null)
chd.flipresource = filePath + chd.flipresource;
if (chd.backflipresource != null)
chd.backflipresource = filePath + chd.backflipresource;
return CreateHatBehaviour(chd, true);
}

Expand Down Expand Up @@ -188,6 +216,32 @@ where r.StartsWith(hatres) && r.EndsWith(".png")
}
}

[HarmonyPatch(typeof(PlayerPhysics), nameof(PlayerPhysics.HandleAnimation))]
private static class PlayerPhysicsHandleAnimationPatch {
private static void Postfix(PlayerPhysics __instance) {
AnimationClip currentAnimation = __instance.Animator.GetCurrentAnimation();
if (currentAnimation == __instance.ClimbAnim || currentAnimation == __instance.ClimbDownAnim) return;
HatParent hp = __instance.myPlayer.HatRenderer;
if (hp.Hat == null) return;
HatExtension extend = hp.Hat.getHatExtension();
if (extend == null) return;
if (extend.FlipImage != null) {
if (__instance.rend.flipX) {
hp.FrontLayer.sprite = extend.FlipImage;
} else {
hp.FrontLayer.sprite = hp.Hat.MainImage;
}
}
if (extend.BackFlipImage != null) {
if (__instance.rend.flipX) {
hp.BackLayer.sprite = extend.BackFlipImage;
} else {
hp.BackLayer.sprite = hp.Hat.BackImage;
}
}
}
}

[HarmonyPatch(typeof(HatParent), nameof(HatParent.SetHat), new System.Type[] { typeof(uint), typeof(int) })]
private static class HatParentSetHatPatch {
static void Postfix(HatParent __instance, [HarmonyArgument(0)]uint hatId, [HarmonyArgument(1)]int color) {
Expand Down Expand Up @@ -315,7 +369,10 @@ public static bool Prefix(HatsTab __instance) {
List<System.Tuple<HatBehaviour, HatExtension>> value = packages[key];
YOffset = createHatPackage(value, key, YOffset, __instance);
}
__instance.scroller.YBounds.max = YOffset * -0.875f; // probably needs to fix up the entire messed math to solve this correctly

// __instance.scroller.YBounds.max = -(__instance.YStart - (float)(unlockedHats.Length / this.NumPerRow) * this.YOffset) - 3f;
// __instance.scroller.YBounds.max = YOffset * -0.875f; // probably needs to fix up the entire messed math to solve this correctly
__instance.scroller.YBounds.max = -(YOffset + 4.1f);
return false;
}
}
Expand Down Expand Up @@ -399,6 +456,11 @@ public static async Task<HttpStatusCode> FetchHats() {
info.reshashb = current["reshashb"]?.ToString();
info.climbresource = sanitizeResourcePath(current["climbresource"]?.ToString());
info.reshashc = current["reshashc"]?.ToString();
info.flipresource = sanitizeResourcePath(current["flipresource"]?.ToString());
info.reshashf = current["reshashf"]?.ToString();
info.backflipresource = sanitizeResourcePath(current["backflipresource"]?.ToString());
info.reshashbf = current["reshashbf"]?.ToString();

info.author = current["author"]?.ToString();
info.package = current["package"]?.ToString();
info.condition = current["condition"]?.ToString();
Expand All @@ -420,6 +482,10 @@ public static async Task<HttpStatusCode> FetchHats() {
markedfordownload.Add(data.backresource);
if (data.climbresource != null && doesResourceRequireDownload(filePath + data.climbresource, data.reshashc, md5))
markedfordownload.Add(data.climbresource);
if (data.flipresource != null && doesResourceRequireDownload(filePath + data.flipresource, data.reshashf, md5))
markedfordownload.Add(data.flipresource);
if (data.backflipresource != null && doesResourceRequireDownload(filePath + data.backflipresource, data.reshashbf, md5))
markedfordownload.Add(data.backflipresource);
}

foreach(var file in markedfordownload) {
Expand Down Expand Up @@ -455,11 +521,16 @@ public class CustomHatOnline : CustomHats.CustomHat {
public string reshasha { get; set;}
public string reshashb { get; set;}
public string reshashc { get; set;}
public string reshashf { get; set;}
public string reshashbf { get; set;}
}
}
public static class CustomHatExtensions {
public static CustomHats.HatExtension getHatExtension(this HatBehaviour hat) {
CustomHats.HatExtension ret = null;
if (CustomHats.TestExt != null && CustomHats.TestExt.condition.Equals(hat.name)) {
return CustomHats.TestExt;
}
CustomHats.CustomHatRegistry.TryGetValue(hat.name, out ret);
return ret;
}
Expand Down
Loading

0 comments on commit d64de10

Please sign in to comment.