Skip to content

Commit

Permalink
v3.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Eisbison committed Nov 27, 2021
1 parent 90e160e commit c450bf5
Show file tree
Hide file tree
Showing 13 changed files with 191 additions and 101 deletions.
24 changes: 20 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ The [Role Assignment](#role-assignment) sections explains how the roles are bein
# Releases
| Among Us - Version| Mod Version | Link |
|----------|-------------|-----------------|
| 2021.11.9.5s| v3.2.2| [Download](https://github.com/Eisbison/TheOtherRoles/releases/download/v3.2.2/TheOtherRoles.zip)
| 2021.11.9.5s| v3.2.1| [Download](https://github.com/Eisbison/TheOtherRoles/releases/download/v3.2.1/TheOtherRoles.zip)
| 2021.11.9.5s| v3.2.0| [Download](https://github.com/Eisbison/TheOtherRoles/releases/download/v3.2.0/TheOtherRoles.zip)
| 2021.11.9.5s| v3.1.2| [Download](https://github.com/Eisbison/TheOtherRoles/releases/download/v3.1.2/TheOtherRoles.zip)
Expand Down Expand Up @@ -85,8 +86,17 @@ The [Role Assignment](#role-assignment) sections explains how the roles are bein
<details>
<summary>Click to show the Changelog</summary>

**Version 3.2.2**
- Add new option "Play On A Random Map" created by [Alex2911](https://github.com/Alex2911)
- Add Witch option "Voting The Witch Saves All The Targets"
- We changed the win conditions of the [Lawyer](#lawyer), to make it more viable
- Bug fix: The Medium now shows the roles of players in the rigth format
- The name and the role of all winners is now being displayed on the end screen
- We changed the way settings are being shared among the players (which caused some people to be unable to join the lobby). This might resolve the problem or make it even worse... we'll see.

**Version 3.2.1**
- Hotfix for 3.2.0
- Bug fix: The Warlock is again able to kill with the curse abilty

**Version 3.2.0**
- **New Role:** [Witch](#witch) created by [Alex2911](https://github.com/Alex2911)
Expand Down Expand Up @@ -754,9 +764,14 @@ Depending on the options, there'll be an arrow pointing towards the current targ
The Witch is an Impostor who has the ability to cast a spell on other players.\
During the next meeting, the spellbound player will be highlighted and he'll die right after the meeting.\
There are multiple options listed down below with which you can configure to fit your taste.\
Similar to the Vampire, shields and blanks will be checked twice (at the end of casting the spell on the player and at the end of the meeting, when the spell will be activated).\
This can result in players being marked as spelled during the meeting, but not dying in the end (when they get a shield or the Witch gets blanked after they were spelled by the Witch).\
If the Witch dies before the meeting starts or if the Witch is being guessed during the meeting, the spellbound players will be highlighted but they'll survive in any case.\
Depending on the options you can choose whether voting the Witch out will save all the spellbound players or not.\

\
**NOTE:**
- Similar to the Vampire, shields and blanks will be checked twice (at the end of casting the spell on the player and at the end of the meeting, when the spell will be activated). This can result in players being marked as spelled during the meeting, but not dying in the end (when they get a shield or the Witch gets blanked after they were spelled by the Witch).
- The spellbound players will die before the voted player dies (which might trigger e.g. trigger an Impostor win condition, even if the Witch is the one being voted)

\
### Game Options
Expand All @@ -768,6 +783,7 @@ There are multiple options listed down below with which you can configure to fit
| Witch Can Spell Everyone | If set to false, the witch can't spell the Spy and other Impostors
| Witch Spell Casting Duration | The time that you need to stay next to the target in order to cast a spell on it
| Trigger Both Cooldowns | If set to true, casting a spell will also trigger cooldown of the kill button and vice versa (but the two cooldowns may vary)
| Voting The Witch Saves All The Targets | If set to true, all the cursed targets will survive at the end of the meeting
-----------------------


Expand Down Expand Up @@ -1286,13 +1302,13 @@ Depending on the options, when a player dies, the Vulture gets an arrow pointing
### **Team: Neutral**
The Lawyer is a neutral role that has a client.
The client might be an Impostor, Jackal or Sidekick which is no Lover.
The Lawyer needs to keep his client alive in order to win as a Lawyer.
The Lawyer needs his client to win in order to win the game.
If his client dies or gets voted out, the Lawyer gets changes his role and becomes the [Pursuer](#pursuer), which has a different goal to win the game.
The main goal of the Lawyer is to win as Lawyer, he is not allowed to betray his client.

The Lawyer can win in multiple ways:
- Lawyer dead and client alive: The Lawyer wins together with the winning team because he kept his client alive
- Lawyer alive and client alive: The Lawyer wins with the winning team because he kept his client alive. The client **doesn't** win (even if his Impostor/Team Jackal mate wins). Hence the client should keep the Lawyer alive for some time, to get some help during the meetings, but has to eliminate him soon enough to not get his win stolen.
- Lawyer dead, client alive and client team won: The Lawyer wins together with the team of his client
- Lawyer and client alive and client team won: The Lawyer wins with the team of his client. The client **doesn't** win (even if his Impostor/Team Jackal mate wins), the Lawyer steals his win. Hence the client should keep the Lawyer alive for some time, to get some help during the meetings, but has to eliminate him soon enough to not get his win stolen.

**NOTE:**
- If the client disconnects, the Lawyer will also turn into the Pursuer
Expand Down
6 changes: 3 additions & 3 deletions TheOtherRoles/Buttons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ public static void Postfix(HudManager __instance)

if (murder == MurderAttemptResult.PerformKill) {
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.WarlockCurseKill, Hazel.SendOption.Reliable, -1);
writer.Write(Warlock.curseKillTarget.PlayerId);
writer.Write(Warlock.curseVictimTarget.PlayerId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCProcedure.warlockCurseKill(Warlock.curseVictimTarget.PlayerId);

Expand Down Expand Up @@ -894,10 +894,10 @@ public static void Postfix(HudManager __instance)
string name = " (" + Medium.target.player.Data.PlayerName + ")";


if (randomNumber == 0) msg = "What is your role? My role is " + RoleInfo.GetRole(Medium.target.player) + name;
if (randomNumber == 0) msg = "What is your role? My role is " + RoleInfo.GetRolesString(Medium.target.player, false) + name;
else if (randomNumber == 1) msg = "What is your killer`s color type? My killer is a " + typeOfColor + " color" + name;
else if (randomNumber == 2) msg = "When did you die? I have died " + Math.Round(timeSinceDeath / 1000) + "s before meeting started" + name;
else msg = "What is your killer`s role? My killer is " + RoleInfo.GetRole(Medium.target.killerIfExisting) + name; //exlude mini
else msg = "What is your killer`s role? My killer is " + RoleInfo.GetRolesString(Medium.target.killerIfExisting, false) + name; //exlude mini

DestroyableSingleton<HudManager>.Instance.Chat.AddChat(PlayerControl.LocalPlayer, $"{msg}");

Expand Down
11 changes: 8 additions & 3 deletions TheOtherRoles/CustomOptionHolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public class CustomOptionHolder {
public static CustomOption witchCanSpellAnyone;
public static CustomOption witchSpellCastingDuration;
public static CustomOption witchTriggerBothCooldowns;
public static CustomOption witchVoteSavesTargets;

public static CustomOption shifterSpawnRate;
public static CustomOption shifterShiftsModifiers;
Expand Down Expand Up @@ -199,6 +200,7 @@ public class CustomOptionHolder {
public static CustomOption lawyerWinsAfterMeetings;
public static CustomOption lawyerNeededMeetings;
public static CustomOption lawyerVision;
public static CustomOption lawyerKnowsRole;
public static CustomOption pursuerCooldown;
public static CustomOption pursuerBlanksNumber;

Expand All @@ -207,6 +209,7 @@ public class CustomOptionHolder {
public static CustomOption noVoteIsSelfVote;
public static CustomOption hidePlayerNames;
public static CustomOption allowParallelMedBayScans;
public static CustomOption dynamicMap;


internal static Dictionary<byte, byte[]> blockedRolePairings = new Dictionary<byte, byte[]>();
Expand Down Expand Up @@ -279,7 +282,7 @@ public static void Load() {
witchCanSpellAnyone = CustomOption.Create(373, "Witch Can Spell Anyone", false, witchSpawnRate);
witchSpellCastingDuration = CustomOption.Create(374, "Spell Casting Duration", 1f, 0f, 10f, 1f, witchSpawnRate);
witchTriggerBothCooldowns = CustomOption.Create(375, "Trigger Both Cooldowns", true, witchSpawnRate);

witchVoteSavesTargets = CustomOption.Create(376, "Voting The Witch Saves All The Targets", true, witchSpawnRate);

miniSpawnRate = CustomOption.Create(180, cs(Mini.color, "Mini"), rates, null, true);
miniGrowingUpDuration = CustomOption.Create(181, "Mini Growing Up Duration", 400f, 100f, 1500f, 100f, miniSpawnRate);
Expand Down Expand Up @@ -326,8 +329,9 @@ public static void Load() {
lawyerWinsAfterMeetings = CustomOption.Create(352, "Lawyer Wins After Meetings", false, lawyerSpawnRate);
lawyerNeededMeetings = CustomOption.Create(353, "Lawyer Needed Meetings To Win", 5f, 1f, 15f, 1f, lawyerWinsAfterMeetings);
lawyerVision = CustomOption.Create(354, "Lawyer Vision", 1f, 0.25f, 3f, 0.25f, lawyerSpawnRate);
pursuerCooldown = CustomOption.Create(355, "Pursuer Blank Cooldown", 30f, 5f, 60f, 2.5f, lawyerSpawnRate);
pursuerBlanksNumber = CustomOption.Create(356, "Pursuer Number Of Blanks", 5f, 0f, 20f, 1f, lawyerSpawnRate);
lawyerKnowsRole = CustomOption.Create(355, "Lawyer Knows Target Role", false, lawyerSpawnRate);
pursuerCooldown = CustomOption.Create(356, "Pursuer Blank Cooldown", 30f, 5f, 60f, 2.5f, lawyerSpawnRate);
pursuerBlanksNumber = CustomOption.Create(357, "Pursuer Number Of Blanks", 5f, 0f, 20f, 1f, lawyerSpawnRate);

shifterSpawnRate = CustomOption.Create(70, cs(Shifter.color, "Shifter"), rates, null, true);
shifterShiftsModifiers = CustomOption.Create(71, "Shifter Shifts Modifiers", false, shifterSpawnRate);
Expand Down Expand Up @@ -420,6 +424,7 @@ public static void Load() {
noVoteIsSelfVote = CustomOption.Create(5, "No Vote Is Self Vote", false, blockSkippingInEmergencyMeetings);
hidePlayerNames = CustomOption.Create(6, "Hide Player Names", false);
allowParallelMedBayScans = CustomOption.Create(7, "Allow Parallel MedBay Scans", false);
dynamicMap = CustomOption.Create(8, "Play On A Random Map", false, null, false);

blockedRolePairings.Add((byte)RoleId.Vampire, new [] { (byte)RoleId.Warlock});
blockedRolePairings.Add((byte)RoleId.Warlock, new [] { (byte)RoleId.Vampire});
Expand Down
2 changes: 1 addition & 1 deletion TheOtherRoles/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace TheOtherRoles
public class TheOtherRolesPlugin : BasePlugin
{
public const string Id = "me.eisbison.theotherroles";
public const string VersionString = "3.2.1";
public const string VersionString = "3.2.2";
public static System.Version Version = System.Version.Parse(VersionString);
internal static BepInEx.Logging.ManualLogSource Logger;

Expand Down
8 changes: 5 additions & 3 deletions TheOtherRoles/Modules/CustomOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,14 @@ public static void switchPreset(int newPreset) {

public static void ShareOptionSelections() {
if (PlayerControl.AllPlayerControls.Count <= 1 || AmongUsClient.Instance?.AmHost == false && PlayerControl.LocalPlayer == null) return;

MessageWriter messageWriter = AmongUsClient.Instance.StartRpc(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ShareOptions, Hazel.SendOption.Reliable);
messageWriter.WritePacked((uint)CustomOption.options.Count);
foreach (CustomOption option in CustomOption.options) {
MessageWriter messageWriter = AmongUsClient.Instance.StartRpc(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ShareOptionSelection, Hazel.SendOption.Reliable);
messageWriter.WritePacked((uint)option.id);
messageWriter.WritePacked((uint)Convert.ToUInt32(option.selection));
messageWriter.EndMessage();
}
messageWriter.EndMessage();
}

// Getter
Expand Down Expand Up @@ -370,7 +372,7 @@ private static void Postfix(ref string __result)
var hudString = sb.ToString();

int defaultSettingsLines = 23;
int roleSettingsLines = defaultSettingsLines + 39;
int roleSettingsLines = defaultSettingsLines + 40;
int detailedSettingsP1 = roleSettingsLines + 40;
int detailedSettingsP2 = detailedSettingsP1 + 42;
int detailedSettingsP3 = detailedSettingsP2 + 42;
Expand Down
77 changes: 62 additions & 15 deletions TheOtherRoles/Patches/EndGamePatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public static void Postfix(AmongUsClient __instance, [HarmonyArgument(0)]ref End
}
}

// Lawyer solo win
// Lawyer solo win
else if (lawyerSoloWin) {
TempData.winners = new Il2CppSystem.Collections.Generic.List<WinningPlayerData>();
WinningPlayerData wpd = new WinningPlayerData(Lawyer.lawyer.Data);
Expand All @@ -190,20 +190,21 @@ public static void Postfix(AmongUsClient __instance, [HarmonyArgument(0)]ref End

// Possible Additional winner: Lawyer
if (!lawyerSoloWin && Lawyer.lawyer != null && Lawyer.target != null && !Lawyer.target.Data.IsDead) {
if (!TempData.winners.ToArray().Any(x => x.PlayerName == Lawyer.lawyer.Data.PlayerName))
TempData.winners.Add(new WinningPlayerData(Lawyer.lawyer.Data));
WinningPlayerData client = null;
WinningPlayerData winningClient = null;
foreach (WinningPlayerData winner in TempData.winners) {
if (winner.PlayerName == Lawyer.target.Data.PlayerName)
client = winner;
}

if (!Lawyer.lawyer.Data.IsDead && client != null) { // Lawyer wins with the winning team but steals the win from his client
TempData.winners.Remove(client);
AdditionalTempData.additionalWinConditions.Add(WinCondition.AdditionalLawyerStolenWin);
} else {
AdditionalTempData.additionalWinConditions.Add(WinCondition.AdditionalLawyerBonusWin);
winningClient = winner;
}
if (winningClient != null) { // The Lawyer wins if the client is winning (and alive, but if he wasn't the Lawyer shouldn't exist anymore)
if (!TempData.winners.ToArray().Any(x => x.PlayerName == Lawyer.lawyer.Data.PlayerName))
TempData.winners.Add(new WinningPlayerData(Lawyer.lawyer.Data));
if (!Lawyer.lawyer.Data.IsDead) { // The Lawyer steals the clients win
TempData.winners.Remove(winningClient);
AdditionalTempData.additionalWinConditions.Add(WinCondition.AdditionalLawyerStolenWin);
} else { // The Lawyer wins together with the client
AdditionalTempData.additionalWinConditions.Add(WinCondition.AdditionalLawyerBonusWin);
}
}
}

// Possible Additional winner: Pursuer
Expand All @@ -221,6 +222,52 @@ public static void Postfix(AmongUsClient __instance, [HarmonyArgument(0)]ref End
[HarmonyPatch(typeof(EndGameManager), nameof(EndGameManager.SetEverythingUp))]
public class EndGameManagerSetUpPatch {
public static void Postfix(EndGameManager __instance) {
// Delete and readd PoolablePlayers always showing the name and role of the player
foreach (PoolablePlayer pb in __instance.transform.GetComponentsInChildren<PoolablePlayer>()) {
UnityEngine.Object.Destroy(pb.gameObject);
}
int num = Mathf.CeilToInt(7.5f);
List<WinningPlayerData> list = TempData.winners.ToArray().ToList().OrderBy(delegate(WinningPlayerData b)
{
if (!b.IsYou)
{
return 0;
}
return -1;
}).ToList<WinningPlayerData>();
for (int i = 0; i < list.Count; i++) {
WinningPlayerData winningPlayerData2 = list[i];
int num2 = (i % 2 == 0) ? -1 : 1;
int num3 = (i + 1) / 2;
float num4 = (float)num3 / (float)num;
float num5 = Mathf.Lerp(1f, 0.75f, num4);
float num6 = (float)((i == 0) ? -8 : -1);
PoolablePlayer poolablePlayer = UnityEngine.Object.Instantiate<PoolablePlayer>(__instance.PlayerPrefab, __instance.transform);
poolablePlayer.transform.localPosition = new Vector3(1f * (float)num2 * (float)num3 * num5, FloatRange.SpreadToEdges(-1.125f, 0f, num3, num), num6 + (float)num3 * 0.01f) * 0.9f;
float num7 = Mathf.Lerp(1f, 0.65f, num4) * 0.9f;
Vector3 vector = new Vector3(num7, num7, 1f);
poolablePlayer.transform.localScale = vector;
poolablePlayer.UpdateFromPlayerOutfit(winningPlayerData2, winningPlayerData2.IsDead);
if (winningPlayerData2.IsDead) {
poolablePlayer.Body.sprite = __instance.GhostSprite;
poolablePlayer.SetDeadFlipX(i % 2 == 0);
} else {
poolablePlayer.SetFlipX(i % 2 == 0);
}

poolablePlayer.NameText.color = Color.white;
poolablePlayer.NameText.transform.localScale = new Vector3(1f / vector.x, 1f / vector.y, 1f / vector.z);
poolablePlayer.NameText.transform.localPosition = new Vector3(poolablePlayer.NameText.transform.localPosition.x, poolablePlayer.NameText.transform.localPosition.y, -15f);
poolablePlayer.NameText.text = winningPlayerData2.PlayerName;

foreach(var data in AdditionalTempData.playerRoles) {
if (data.PlayerName != winningPlayerData2.PlayerName) continue;
var roles =
poolablePlayer.NameText.text += $"\n{string.Join("\n", data.Roles.Select(x => Helpers.cs(x.color, x.name)))}";
}
}

// Additional code
GameObject bonusText = UnityEngine.Object.Instantiate(__instance.WinText.gameObject);
bonusText.transform.position = new Vector3(__instance.WinText.transform.position.x, __instance.WinText.transform.position.y - 0.5f, __instance.WinText.transform.position.z);
bonusText.transform.localScale = new Vector3(0.7f, 0.7f, 1f);
Expand Down Expand Up @@ -264,11 +311,11 @@ public static void Postfix(EndGameManager __instance) {

foreach (WinCondition cond in AdditionalTempData.additionalWinConditions) {
if (cond == WinCondition.AdditionalLawyerStolenWin) {
textRenderer.text += $"\n{Helpers.cs(Lawyer.color, "Lawyer stole the win of the client")}";
textRenderer.text += $"\n{Helpers.cs(Lawyer.color, "The Lawyer stole the win from the client")}";
} else if (cond == WinCondition.AdditionalLawyerBonusWin) {
textRenderer.text += $"\n{Helpers.cs(Lawyer.color, "Lawyer kept the client alive")}";
textRenderer.text += $"\n{Helpers.cs(Lawyer.color, "The Lawyer wins with the client")}";
} else if (cond == WinCondition.AdditionalAlivePursuerWin) {
textRenderer.text += $"\n{Helpers.cs(Pursuer.color, "Pursuer survived")}";
textRenderer.text += $"\n{Helpers.cs(Pursuer.color, "The Pursuer survived")}";
}
}

Expand Down
Loading

0 comments on commit c450bf5

Please sign in to comment.