Skip to content

Commit

Permalink
Version v2.6.4
Browse files Browse the repository at this point in the history
  • Loading branch information
EoF-1141 committed May 20, 2021
1 parent 1ddf23e commit 7691501
Show file tree
Hide file tree
Showing 27 changed files with 1,316 additions and 1,290 deletions.
Binary file removed Images/Banner.png
Binary file not shown.
Binary file removed Images/Colors.png
Binary file not shown.
Binary file removed Images/Preview_2.6.0.png
Binary file not shown.
Binary file added Images/TOR_colors.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/TOR_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/TOR_roles.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/TOR_server.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1,949 changes: 983 additions & 966 deletions README.md

Large diffs are not rendered by default.

23 changes: 19 additions & 4 deletions Source Code/ClientOptionsPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ public class OptionsMenuBehaviourStartPatch {
private static ToggleButtonBehaviour streamerModeButton;
private static ToggleButtonBehaviour ghostsSeeTasksButton;
private static ToggleButtonBehaviour ghostsSeeRolesButton;
private static ToggleButtonBehaviour ghostsSeeVotesButton;

public static float xOffset = 1.75f;
public static float yOffset = -0.5f;

private static void updateToggle(ToggleButtonBehaviour button, string text, bool on) {
if (button == null || button.gameObject == null) return;
Expand Down Expand Up @@ -41,11 +45,12 @@ private static ToggleButtonBehaviour createCustomToggle(string text, bool on, Ve
public static void Postfix(OptionsMenuBehaviour __instance) {
if (__instance.CensorChatButton != null) {
if (origin == null) origin = __instance.CensorChatButton.transform.localPosition + Vector3.up * 0.25f;
__instance.CensorChatButton.transform.localPosition = origin.Value + Vector3.left * 1.3f;
__instance.CensorChatButton.transform.localPosition = origin.Value + Vector3.left * xOffset;
__instance.CensorChatButton.transform.localScale = Vector3.one * 2f / 3f;
}

if ((streamerModeButton == null || streamerModeButton.gameObject == null)) {
streamerModeButton = createCustomToggle("Streamer Mode: ", TheOtherRolesPlugin.StreamerMode.Value, Vector3.right * 1.3f, (UnityEngine.Events.UnityAction)streamerModeToggle, __instance);
streamerModeButton = createCustomToggle("Streamer Mode: ", TheOtherRolesPlugin.StreamerMode.Value, Vector3.zero, (UnityEngine.Events.UnityAction)streamerModeToggle, __instance);

void streamerModeToggle() {
TheOtherRolesPlugin.StreamerMode.Value = !TheOtherRolesPlugin.StreamerMode.Value;
Expand All @@ -54,7 +59,7 @@ void streamerModeToggle() {
}

if ((ghostsSeeTasksButton == null || ghostsSeeTasksButton.gameObject == null)) {
ghostsSeeTasksButton = createCustomToggle("Ghosts See Remaining Tasks: ", TheOtherRolesPlugin.GhostsSeeTasks.Value, new Vector2(-1.3f, -0.5f), (UnityEngine.Events.UnityAction)ghostsSeeTaskToggle, __instance);
ghostsSeeTasksButton = createCustomToggle("Ghosts See Remaining Tasks: ", TheOtherRolesPlugin.GhostsSeeTasks.Value, Vector3.right * xOffset, (UnityEngine.Events.UnityAction)ghostsSeeTaskToggle, __instance);

void ghostsSeeTaskToggle() {
TheOtherRolesPlugin.GhostsSeeTasks.Value = !TheOtherRolesPlugin.GhostsSeeTasks.Value;
Expand All @@ -64,14 +69,24 @@ void ghostsSeeTaskToggle() {
}

if ((ghostsSeeRolesButton == null || ghostsSeeRolesButton.gameObject == null)) {
ghostsSeeRolesButton = createCustomToggle("Ghosts See Roles: ", TheOtherRolesPlugin.GhostsSeeRoles.Value, new Vector2(1.3f, -0.5f), (UnityEngine.Events.UnityAction)ghostsSeeRolesToggle, __instance);
ghostsSeeRolesButton = createCustomToggle("Ghosts See Roles: ", TheOtherRolesPlugin.GhostsSeeRoles.Value, new Vector2(-xOffset, yOffset), (UnityEngine.Events.UnityAction)ghostsSeeRolesToggle, __instance);

void ghostsSeeRolesToggle() {
TheOtherRolesPlugin.GhostsSeeRoles.Value = !TheOtherRolesPlugin.GhostsSeeRoles.Value;
MapOptions.ghostsSeeRoles = TheOtherRolesPlugin.GhostsSeeRoles.Value;
updateToggle(ghostsSeeRolesButton, "Ghosts See Roles: ", TheOtherRolesPlugin.GhostsSeeRoles.Value);
}
}

if ((ghostsSeeVotesButton == null || ghostsSeeVotesButton.gameObject == null)) {
ghostsSeeVotesButton = createCustomToggle("Ghosts See votes: ", TheOtherRolesPlugin.GhostsSeeVotes.Value, new Vector2(0, yOffset), (UnityEngine.Events.UnityAction)ghostsSeeVotesToggle, __instance);

void ghostsSeeVotesToggle() {
TheOtherRolesPlugin.GhostsSeeVotes.Value = !TheOtherRolesPlugin.GhostsSeeVotes.Value;
MapOptions.ghostsSeeVotes = TheOtherRolesPlugin.GhostsSeeVotes.Value;
updateToggle(ghostsSeeVotesButton, "Ghosts See Roles: ", TheOtherRolesPlugin.GhostsSeeVotes.Value);
}
}
}
}

Expand Down
9 changes: 8 additions & 1 deletion Source Code/CustomHats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,14 @@ private static List<CustomHat> createCustomHatDetails(string[] hats, bool fromDi

private static Sprite CreateHatSprite(string path, bool fromDisk = false) {
Texture2D texture = fromDisk ? Helpers.loadTextureFromDisk(path) : Helpers.loadTextureFromResources(path);
return texture == null ? null : Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.8f), texture.width * 0.75f);
if (texture == null)
return null;
Sprite sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.8f), texture.width * 0.75f);
if (sprite == null)
return null;
texture.hideFlags |= HideFlags.HideAndDontSave | HideFlags.DontUnloadUnusedAsset;
sprite.hideFlags |= HideFlags.HideAndDontSave | HideFlags.DontUnloadUnusedAsset;
return sprite;
}

private static HatBehaviour CreateHatBehaviour(CustomHat ch, bool fromDisk = false, bool testOnly = false) {
Expand Down
10 changes: 9 additions & 1 deletion Source Code/CustomOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ public class CustomOptionHolder {
public static CustomOption loversSpawnRate;
public static CustomOption loversImpLoverRate;
public static CustomOption loversBothDie;
public static CustomOption loversCanHaveAnotherRole;

public static CustomOption jesterSpawnRate;
public static CustomOption jesterCanCallEmergency;
public static CustomOption jesterCanSabotage;

public static CustomOption arsonistSpawnRate;
public static CustomOption arsonistCooldown;
Expand All @@ -66,6 +68,7 @@ public class CustomOptionHolder {
public static CustomOption sidekickCanUseVents;
public static CustomOption jackalPromotedFromSidekickCanCreateSidekick;
public static CustomOption jackalCanCreateSidekickFromImpostor;
public static CustomOption jackalAndSidekickHaveImpostorVision;

public static CustomOption shifterSpawnRate;

Expand Down Expand Up @@ -101,6 +104,7 @@ public class CustomOptionHolder {

public static CustomOption swapperSpawnRate;
public static CustomOption swapperCanCallEmergency;
public static CustomOption swapperCanOnlySwapOthers;

public static CustomOption seerSpawnRate;
public static CustomOption seerMode;
Expand Down Expand Up @@ -207,12 +211,14 @@ public static void Load() {
loversSpawnRate = CustomOption.Create(50, cs(Lovers.color, "Lovers"), rates, null, true);
loversImpLoverRate = CustomOption.Create(51, "Chance That One Lover Is Impostor", rates, loversSpawnRate);
loversBothDie = CustomOption.Create(52, "Both Lovers Die", true, loversSpawnRate);
loversCanHaveAnotherRole = CustomOption.Create(53, "Lovers Can Have Another Role", true, loversSpawnRate);

jesterSpawnRate = CustomOption.Create(60, cs(Jester.color, "Jester"), rates, null, true);
jesterCanCallEmergency = CustomOption.Create(61, "Jester can call emergency meeting", true, jesterSpawnRate);
jesterCanSabotage = CustomOption.Create(62, "Jester can sabotage", true, jesterSpawnRate);

arsonistSpawnRate = CustomOption.Create(290, cs(Arsonist.color, "Arsonist"), rates, null, true);
arsonistCooldown = CustomOption.Create(291, "Arsonist Cooldown", 30f, 5f, 60f, 2.5f, arsonistSpawnRate);
arsonistCooldown = CustomOption.Create(291, "Arsonist Cooldown", 12.5f, 2.5f, 60f, 2.5f, arsonistSpawnRate);
arsonistDuration = CustomOption.Create(292, "Arsonist Douse Duration", 3f, 1f, 10f, 1f, arsonistSpawnRate);

jackalSpawnRate = CustomOption.Create(220, cs(Jackal.color, "Jackal"), rates, null, true);
Expand All @@ -225,6 +231,7 @@ public static void Load() {
sidekickCanUseVents = CustomOption.Create(227, "Sidekick Can Use Vents", true, jackalSpawnRate);
jackalPromotedFromSidekickCanCreateSidekick = CustomOption.Create(228, "Jackals Promoted From Sidekick Can Create A Sidekick", true, jackalSpawnRate);
jackalCanCreateSidekickFromImpostor = CustomOption.Create(229, "Jackals Can Make An Impostor To His Sidekick", true, jackalSpawnRate);
jackalAndSidekickHaveImpostorVision = CustomOption.Create(430, "Jackal And Sidekick Have Impostor Vision", false, jackalSpawnRate);

shifterSpawnRate = CustomOption.Create(70, cs(Shifter.color, "Shifter"), rates, null, true);

Expand Down Expand Up @@ -261,6 +268,7 @@ public static void Load() {

swapperSpawnRate = CustomOption.Create(150, cs(Swapper.color, "Swapper"), rates, null, true);
swapperCanCallEmergency = CustomOption.Create(151, "Swapper can call emergency meeting", false, swapperSpawnRate);
swapperCanOnlySwapOthers = CustomOption.Create(152, "Swapper can only swap others", false, swapperSpawnRate);

seerSpawnRate = CustomOption.Create(160, cs(Seer.color, "Seer"), rates, null, true);
seerMode = CustomOption.Create(161, "Seer Mode", new string[]{ "Show Death Flash + Souls", "Show Death Flash", "Show Souls"}, seerSpawnRate);
Expand Down
11 changes: 2 additions & 9 deletions Source Code/EndGamePatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,10 @@ enum WinCondition {
static class AdditionalTempData {
// Should be implemented using a proper GameOverReason in the future
public static WinCondition winCondition = WinCondition.Default;
public static bool localIsLover = false;


public static void clear() {
winCondition = WinCondition.Default;
localIsLover = false;

}
}

Expand Down Expand Up @@ -71,7 +68,7 @@ public static void Postfix(AmongUsClient __instance, [HarmonyArgument(0)]ref Gam
bool jesterWin = Jester.jester != null && gameOverReason == (GameOverReason)CustomGameOverReason.JesterWin;
bool arsonistWin = Arsonist.arsonist != null && gameOverReason == (GameOverReason)CustomGameOverReason.ArsonistWin;
bool childLose = Child.child != null && gameOverReason == (GameOverReason)CustomGameOverReason.ChildLose;
bool loversWin = Lovers.existingAndAlive() && (gameOverReason == (GameOverReason)CustomGameOverReason.LoversWin || (TempData.DidHumansWin(gameOverReason) && Lovers.existingAndCrewLovers())); // Either they win if they are among the last 3 players, or they win if they are both Crewmates and both alive and the Crew wins (Team Imp/Jackal Lovers can only win solo wins)
bool loversWin = Lovers.existingAndAlive() && (gameOverReason == (GameOverReason)CustomGameOverReason.LoversWin || (TempData.DidHumansWin(gameOverReason) && !Lovers.existingWithKiller())); // Either they win if they are among the last 3 players, or they win if they are both Crewmates and both alive and the Crew wins (Team Imp/Jackal Lovers can only win solo wins)
bool teamJackalWin = gameOverReason == (GameOverReason)CustomGameOverReason.TeamJackalWin && ((Jackal.jackal != null && !Jackal.jackal.Data.IsDead) || (Sidekick.sidekick != null && !Sidekick.sidekick.Data.IsDead));

// Child lose
Expand Down Expand Up @@ -101,9 +98,8 @@ public static void Postfix(AmongUsClient __instance, [HarmonyArgument(0)]ref Gam

// Lovers win conditions
else if (loversWin) {
AdditionalTempData.localIsLover = (PlayerControl.LocalPlayer == Lovers.lover1 || PlayerControl.LocalPlayer == Lovers.lover2);
// Double win for lovers, crewmates also win
if (Lovers.existingAndCrewLovers()) {
if (!Lovers.existingWithKiller()) {
AdditionalTempData.winCondition = WinCondition.LoversTeamWin;
TempData.winners = new Il2CppSystem.Collections.Generic.List<WinningPlayerData>();
foreach (PlayerControl p in PlayerControl.AllPlayerControls) {
Expand Down Expand Up @@ -167,9 +163,6 @@ public static void Postfix(EndGameManager __instance) {
textRenderer.color = Arsonist.color;
}
else if (AdditionalTempData.winCondition == WinCondition.LoversTeamWin) {
if (AdditionalTempData.localIsLover) {
__instance.WinText.text = "Double Victory";
}
textRenderer.text = "Lovers And Crewmates Win";
textRenderer.color = Lovers.color;
__instance.BackgroundBar.material.SetColor("_Color", Lovers.color);
Expand Down
2 changes: 1 addition & 1 deletion Source Code/GameStartManagerPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public static void Postfix(GameStartManager __instance) {
if (diff > 0) {
message += $"<color=#FF0000FF>{client.Character.Data.PlayerName} has an older version of The Other Roles (v{playerVersions[client.Id].ToString()})\n</color>";
blockStart = true;
} else if (diff > 0) {
} else if (diff < 0) {
message += $"<color=#FF0000FF>{client.Character.Data.PlayerName} has a newer version of The Other Roles (v{playerVersions[client.Id].ToString()}) \n</color>";
blockStart = true;
}
Expand Down
66 changes: 40 additions & 26 deletions Source Code/IntroPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,14 @@ public static void Prefix(IntroCutscene __instance) {
}
}

[HarmonyPatch(typeof(IntroCutscene._CoBegin_d__11), nameof(IntroCutscene._CoBegin_d__11.MoveNext))]
class IntroPatch
{
static void Prefix(IntroCutscene._CoBegin_d__11 __instance)
{
[HarmonyPatch]
class IntroPatch {
public static void setupIntroTeam(IntroCutscene __instance, ref Il2CppSystem.Collections.Generic.List<PlayerControl> yourTeam) {
// Intro solo teams
if (PlayerControl.LocalPlayer == Jester.jester || PlayerControl.LocalPlayer == Jackal.jackal || PlayerControl.LocalPlayer == Arsonist.arsonist) {
var soloTeam = new Il2CppSystem.Collections.Generic.List<PlayerControl>();
soloTeam.Add(PlayerControl.LocalPlayer);
__instance.yourTeam = soloTeam;
yourTeam = soloTeam;
}

// Add the Spy to the Impostor team (for the Impostors)
Expand All @@ -56,33 +54,49 @@ static void Prefix(IntroCutscene._CoBegin_d__11 __instance)
if (p == Spy.spy || p.Data.IsImpostor)
fakeImpostorTeam.Add(p);
}
__instance.yourTeam = fakeImpostorTeam;
yourTeam = fakeImpostorTeam;
}
}

// Intro display role
static void Postfix(IntroCutscene._CoBegin_d__11 __instance)
{
public static void setupIntroRole(IntroCutscene __instance, ref Il2CppSystem.Collections.Generic.List<PlayerControl> yourTeam) {
List<RoleInfo> infos = RoleInfo.getRoleInfoForPlayer(PlayerControl.LocalPlayer);
if (infos.Count == 0) return;
RoleInfo roleInfo = infos[0];
RoleInfo roleInfo = infos.Where(info => info.roleId != RoleId.Lover).FirstOrDefault();

if (PlayerControl.LocalPlayer == Lovers.lover1 || PlayerControl.LocalPlayer == Lovers.lover2)
{
if (roleInfo != null) {
__instance.Title.text = roleInfo.name;
__instance.Title.color = roleInfo.color;
__instance.ImpostorText.gameObject.SetActive(true);
__instance.ImpostorText.text = roleInfo.introDescription;
__instance.BackgroundBar.material.color = roleInfo.color;
}

if (infos.Any(info => info.roleId == RoleId.Lover)) {
var loversText = UnityEngine.Object.Instantiate<TMPro.TextMeshPro>(__instance.ImpostorText, __instance.ImpostorText.transform.parent);
loversText.transform.localPosition += Vector3.down * 3f;
PlayerControl otherLover = PlayerControl.LocalPlayer == Lovers.lover1 ? Lovers.lover2 : Lovers.lover1;
__instance.__4__this.Title.text = PlayerControl.LocalPlayer.Data.IsImpostor ? "<color=#FF1919FF>Imp</color><color=#FC03BEFF>Lover</color>" : "<color=#FC03BEFF>Lover</color>";
__instance.__4__this.Title.color = PlayerControl.LocalPlayer.Data.IsImpostor ? Color.white : Lovers.color;
__instance.__4__this.ImpostorText.text = "You are in <color=#FC03BEFF>Love</color><color=#FFFFFFFF> with </color><color=#FC03BEFF>" + (otherLover?.Data?.PlayerName ?? "") + "</color>";
__instance.__4__this.ImpostorText.gameObject.SetActive(true);
__instance.__4__this.BackgroundBar.material.color = Lovers.color;
loversText.text = Helpers.cs(Lovers.color, $"❤ You are in lover with {otherLover?.Data?.PlayerName ?? ""}");
}
}

[HarmonyPatch(typeof(IntroCutscene), nameof(IntroCutscene.BeginCrewmate))]
class BeginCrewmatePatch {
public static void Prefix(IntroCutscene __instance, ref Il2CppSystem.Collections.Generic.List<PlayerControl> yourTeam) {
setupIntroTeam(__instance, ref yourTeam);
}
else if (roleInfo.name == "Crewmate" || roleInfo.name == "Impostor") {}
else {
__instance.__4__this.Title.text = roleInfo.name;
__instance.__4__this.Title.color = roleInfo.color;
__instance.__4__this.ImpostorText.gameObject.SetActive(true);
__instance.__4__this.ImpostorText.text = roleInfo.introDescription;
__instance.__4__this.BackgroundBar.material.color = roleInfo.color;

public static void Postfix(IntroCutscene __instance, ref Il2CppSystem.Collections.Generic.List<PlayerControl> yourTeam) {
setupIntroRole(__instance, ref yourTeam);
}
}

[HarmonyPatch(typeof(IntroCutscene), nameof(IntroCutscene.BeginImpostor))]
class BeginImpostorPatch {
public static void Prefix(IntroCutscene __instance, ref Il2CppSystem.Collections.Generic.List<PlayerControl> yourTeam) {
setupIntroTeam(__instance, ref yourTeam);
}

public static void Postfix(IntroCutscene __instance, ref Il2CppSystem.Collections.Generic.List<PlayerControl> yourTeam) {
setupIntroRole(__instance, ref yourTeam);
}
}
}
Expand Down
Loading

0 comments on commit 7691501

Please sign in to comment.