Skip to content

Commit

Permalink
Hotfix 2.6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Eisbison committed May 9, 2021
1 parent 4b7b514 commit d9f9a18
Show file tree
Hide file tree
Showing 11 changed files with 95 additions and 15 deletions.
8 changes: 8 additions & 0 deletions 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.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)
| 2021.4.14s| v2.5.1| [Download](https://github.com/Eisbison/TheOtherRoles/releases/download/v2.5.1/TheOtherRoles.zip)
| 2021.4.14s| v2.5.0| [Download](https://github.com/Eisbison/TheOtherRoles/releases/download/v2.5.0/TheOtherRoles.zip)
Expand All @@ -59,6 +60,12 @@ The [Role Assignment](#role-assignment) sections explains how the roles are bein
<details>
<summary>Click to show the Changelog</summary>

**Version 2.6.1**
- Fixed a bug where the Sheriff was unable to kill the Arsonist
- Fixed a bug in the role assignment system
- Added the option to select the Dleks map
- Improved the overlay of the Arsonist

**Version 2.6.0**
- **New Role:** [Arsonist](#arsonist)
- Added an Ingame Updater, to make it easier to update the Mod
Expand Down Expand Up @@ -327,6 +334,7 @@ The mod adds a few new settings to Among Us (in addition to the role settings):
- **Allow Skips On Emergency Meetings:** If set to false, there will not be a skip button in emergency meetings. If a player does not vote, he'll vote himself.
- **Hide Player Names:** Hides the names of all players that have role which is unknown to you. Team Lovers/Impostors/Jackal still see the names of their teammates. Impostors can alse see the name of the Spy and everyone can still see the age of the child.
- **Ghosts Can See Roles And Remaining Tasks:** If set to true, ghosts can see the role and the number of remaining tasks of each player.
- **Dleks:** You are now able to select the Dleks map.

# Custom Hats
## Create and submit new hat designs
Expand Down
9 changes: 2 additions & 7 deletions Source Code/Buttons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public static void Postfix(HudManager __instance)
byte targetId = 0;
if ((Sheriff.currentTarget.Data.IsImpostor && (Sheriff.currentTarget != Child.child || Child.isGrownUp())) ||
(Sheriff.spyCanDieToSheriff && Spy.spy == Sheriff.currentTarget) ||
(Sheriff.canKillNeutrals && (Jester.jester == Sheriff.currentTarget || Jackal.jackal == Sheriff.currentTarget || Sidekick.sidekick == Sheriff.currentTarget))) {
(Sheriff.canKillNeutrals && (Arsonist.arsonist == Sheriff.currentTarget || Jester.jester == Sheriff.currentTarget || Jackal.jackal == Sheriff.currentTarget || Sidekick.sidekick == Sheriff.currentTarget))) {
targetId = Sheriff.currentTarget.PlayerId;
}
else {
Expand Down Expand Up @@ -768,14 +768,9 @@ public static void Postfix(HudManager __instance)
Arsonist.douseTarget = null;
arsonistButton.Timer = Arsonist.dousedEveryoneAlive() ? 0 : arsonistButton.MaxTimer;
int playerCounter = 0;
Vector3 bottomLeft = new Vector3(-HudManager.Instance.UseButton.transform.localPosition.x, HudManager.Instance.UseButton.transform.localPosition.y, HudManager.Instance.UseButton.transform.localPosition.z);
bottomLeft += new Vector3(-0.25f, -0.25f, 0);
foreach (PlayerControl p in Arsonist.dousedPlayers) {
if (Arsonist.dousedIcons.ContainsKey(p.PlayerId)) {
Arsonist.dousedIcons[p.PlayerId].gameObject.SetActive(true);
Arsonist.dousedIcons[p.PlayerId].transform.localPosition = bottomLeft + Vector3.right * playerCounter * 0.35f;
playerCounter++;
Arsonist.dousedIcons[p.PlayerId].setSemiTransparent(false);
}
}
}
Expand Down
33 changes: 33 additions & 0 deletions Source Code/CustomColors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,39 @@ public static void Postfix(PlayerTab __instance) { // Replace instead
}
}
}
[HarmonyPatch(typeof(SaveManager), nameof(SaveManager.LoadPlayerPrefs))]
private static class LoadPlayerPrefsPatch { // Fix Potential issues with broken colors
private static bool needsPatch = false;
public static void Prefix([HarmonyArgument(0)] bool overrideLoad) {
if (!SaveManager.loaded || overrideLoad)
needsPatch = true;
}
public static void Postfix() {
if (!needsPatch) return;
SaveManager.colorConfig %= (uint)CustomColors.pickableColors;
needsPatch = false;
}
}
[HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.CheckColor))]
private static class PlayerControlCheckColorPatch {
private static bool isTaken(PlayerControl player, uint color) {
foreach (GameData.PlayerInfo p in GameData.Instance.AllPlayers)
if (!p.Disconnected && p.PlayerId != player.PlayerId && p.ColorId == color)
return true;
return false;
}
public static bool Prefix(PlayerControl __instance, [HarmonyArgument(0)] byte bodyColor) { // Fix incorrect color assignment
uint color = (uint)bodyColor;
if (isTaken(__instance, color) || color >= Palette.PlayerColors.Length) {
int num = 0;
while (num++ < 50 && (color >= CustomColors.pickableColors || isTaken(__instance, color))) {
color = (color + 1) % (uint)CustomColors.pickableColors;
}
}
__instance.RpcSetColor((byte)color);
return false;
}
}
}
}
}
25 changes: 24 additions & 1 deletion Source Code/CustomOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public static void Load() {

sheriffSpawnRate = CustomOption.Create(100, cs(Sheriff.color, "Sheriff"), rates, null, true);
sheriffCooldown = CustomOption.Create(101, "Sheriff Cooldown", 30f, 10f, 60f, 2.5f, sheriffSpawnRate);
sheriffCanKillNeutrals = CustomOption.Create(102, "Neutrals Can Kill The Jester", false, sheriffSpawnRate);
sheriffCanKillNeutrals = CustomOption.Create(102, "Sheriff Can Kill Neutrals", false, sheriffSpawnRate);


lighterSpawnRate = CustomOption.Create(110, cs(Lighter.color, "Lighter"), rates, null, true);
Expand Down Expand Up @@ -510,6 +510,29 @@ class GameSettingMenuPatch {
public static void Prefix(GameSettingMenu __instance) {
__instance.HideForOnline = new Transform[]{};
}

public static void Postfix(GameSettingMenu __instance) {
var mapNameTransform = __instance.AllItems.FirstOrDefault(x => x.gameObject.activeSelf && x.name.Equals("MapName", StringComparison.OrdinalIgnoreCase));
if (mapNameTransform == null) return;

var options = new Il2CppSystem.Collections.Generic.List<Il2CppSystem.Collections.Generic.KeyValuePair<string, int>>();
for (int i = 0; i < GameOptionsData.MapNames.Length; i++) {
var kvp = new Il2CppSystem.Collections.Generic.KeyValuePair<string, int>();
kvp.key = GameOptionsData.MapNames[i];
kvp.value = i;
options.Add(kvp);
}
mapNameTransform.GetComponent<KeyValueOption>().Values = options;
}
}

[HarmonyPatch(typeof(Constants), nameof(Constants.ShouldFlipSkeld))]
class ConstantsShouldFlipSkeldPatch {
public static bool Prefix(ref bool __result) {
if (PlayerControl.GameOptions == null) return true;
__result = PlayerControl.GameOptions.MapId == 3;
return false;
}
}

[HarmonyPatch]
Expand Down
7 changes: 7 additions & 0 deletions Source Code/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,13 @@ public static void clearAllTasks(this PlayerControl player) {
player.Data.Tasks.Clear();
}

public static void setSemiTransparent(this PoolablePlayer player, bool value) {
float alpha = value ? 0.25f : 1f;
foreach (SpriteRenderer r in player.gameObject.GetComponentsInChildren<SpriteRenderer>())
r.color = new Color(r.color.r, r.color.g, r.color.b, alpha);
player.NameText.color = new Color(player.NameText.color.r, player.NameText.color.g, player.NameText.color.b, alpha);
}

public static string cs(Color c, string s) {
return string.Format("<color=#{0:X2}{1:X2}{2:X2}{3:X2}>{4}</color>", ToByte(c.r), ToByte(c.g), ToByte(c.b), ToByte(c.a), s);
}
Expand Down
3 changes: 1 addition & 2 deletions Source Code/IntroPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ public static void Prefix(IntroCutscene __instance) {
PlayerControl.SetPetImage(data.PetId, data.ColorId, poolablePlayer.PetSlot);
poolablePlayer.NameText.text = data.PlayerName;
poolablePlayer.SetFlipX(true);
poolablePlayer.gameObject.SetActive(false);

poolablePlayer.setSemiTransparent(true);
Arsonist.dousedIcons[player.PlayerId] = poolablePlayer;
playerCounter++;
}
Expand Down
2 changes: 1 addition & 1 deletion Source Code/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace TheOtherRoles
public class TheOtherRolesPlugin : BasePlugin
{
public const string Id = "me.eisbison.theotherroles";
public const string VersionString = "2.6.0";
public const string VersionString = "2.6.1";
public static System.Version Version = System.Version.Parse(VersionString);

public Harmony Harmony { get; } = new Harmony(Id);
Expand Down
16 changes: 16 additions & 0 deletions Source Code/MeetingPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,22 @@ static void Prefix(UnityEngine.Object obj)
}
Seer.deadBodyPositions = new List<Vector3>();
}

// Arsonist deactivate dead poolable players
if (Arsonist.arsonist != null && Arsonist.arsonist == PlayerControl.LocalPlayer) {
int visibleCounter = 0;
Vector3 bottomLeft = new Vector3(-HudManager.Instance.UseButton.transform.localPosition.x, HudManager.Instance.UseButton.transform.localPosition.y, HudManager.Instance.UseButton.transform.localPosition.z);
bottomLeft += new Vector3(-0.25f, -0.25f, 0);
foreach (PlayerControl p in PlayerControl.AllPlayerControls) {
if (!Arsonist.dousedIcons.ContainsKey(p.PlayerId)) continue;
if (p.Data.IsDead || p.Data.Disconnected) {
Arsonist.dousedIcons[p.PlayerId].gameObject.SetActive(true);
} else {
Arsonist.dousedIcons[p.PlayerId].transform.localPosition = bottomLeft + Vector3.right * visibleCounter * 0.35f;
visibleCounter++;
}
}
}
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions Source Code/RoleAssignmentPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ public static void Postfix([HarmonyArgument(0)]Il2CppReferenceArray<GameData.Pla
crewSettings.Add((byte)RoleId.Hacker, CustomOptionHolder.hackerSpawnRate.getSelection());
crewSettings.Add((byte)RoleId.Tracker, CustomOptionHolder.trackerSpawnRate.getSelection());
crewSettings.Add((byte)RoleId.Snitch, CustomOptionHolder.snitchSpawnRate.getSelection());
crewSettings.Add((byte)RoleId.Jackal, CustomOptionHolder.jackalSpawnRate.getSelection());
if (impostors.Count > 1) // Spy is useless with less than 2 Impostors
crewSettings.Add((byte)RoleId.Spy, CustomOptionHolder.spySpawnRate.getSelection());
crewSettings.Add((byte)RoleId.SecurityGuard, CustomOptionHolder.securityGuardSpawnRate.getSelection());
Expand Down Expand Up @@ -139,7 +138,7 @@ public static void Postfix([HarmonyArgument(0)]Il2CppReferenceArray<GameData.Pla
}
}
} else { // Other
for (int j = 0; j < entry.Value; j++) crewTickets.Add(entry.Key);
for (int j = 0; j < entry.Value; j++) neutralTickets.Add(entry.Key);
}
}

Expand Down
2 changes: 1 addition & 1 deletion Source Code/TheOtherRoles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ public static Sprite getIgniteSprite() {
}

public static bool dousedEveryoneAlive() {
return PlayerControl.AllPlayerControls.ToArray().All(x => { return x == Arsonist.arsonist || x.Data.IsDead || Arsonist.dousedPlayers.Any(y => y.PlayerId == x.PlayerId); });
return PlayerControl.AllPlayerControls.ToArray().All(x => { return x == Arsonist.arsonist || x.Data.IsDead || x.Data.Disconnected || Arsonist.dousedPlayers.Any(y => y.PlayerId == x.PlayerId); });
}

public static void clearAndReload() {
Expand Down
2 changes: 1 addition & 1 deletion Source Code/TheOtherRoles.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<Version>2.6.0</Version>
<Version>2.6.1</Version>
<Description>TheOtherRoles</Description>
<Authors>Eisbison</Authors>
</PropertyGroup>
Expand Down

0 comments on commit d9f9a18

Please sign in to comment.