Skip to content

Commit

Permalink
v5.1.2 Source Code
Browse files Browse the repository at this point in the history
  • Loading branch information
eDonnes124 committed Nov 20, 2024
1 parent 7dbccf8 commit 51a788c
Show file tree
Hide file tree
Showing 25 changed files with 336 additions and 141 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Join our [Discord](https://discord.gg/ugyc4EVUYZ) if you have any problems or wa
# Releases
| Among Us - Version| Mod Version | Link |
|----------|-------------|-----------------|
| 2024.10.29s & 2024.10.29e | v5.1.2 | [Download](https://github.com/eDonnes124/Town-Of-Us/releases/download/v5.1.2/ToU.v5.1.2.zip) |
| 2024.9.4s & 2024.9.4e | v5.1.1 | [Download](https://github.com/eDonnes124/Town-Of-Us/releases/download/v5.1.1/ToU.v5.1.1.zip) |
| 2024.9.4s & 2024.9.4e | v5.1.0 | [Download](https://github.com/eDonnes124/Town-Of-Us/releases/download/v5.1.0/ToU.v5.1.0.zip) |
| 2024.3.5s & 2024.3.5e | v5.0.4 | [Download](https://github.com/eDonnes124/Town-Of-Us/releases/download/v5.0.4/ToU.v5.0.4.zip) |
Expand Down Expand Up @@ -105,6 +106,12 @@ Join our [Discord](https://discord.gg/ugyc4EVUYZ) if you have any problems or wa
<details>
<summary> Changelog </summary>
<details>
<summary> v5.1.2 </summary>
<ul> <li>Compatibility with the new Among Us version v2024.10.29</li> </ul>
<ul> <li>Minor Bug Fixes</li> </ul>
<ul> <li>Added Retribution back to Hunter as a setting</li> </ul>
</details>
<details>
<summary> v5.1.1 </summary>
<ul> <li>Hotfix Versioning Issue</li> </ul>
</details>
Expand Down Expand Up @@ -993,6 +1000,7 @@ however the Hunter may only execute players who have given them probable cause.
| Hunter Stalk Cooldown | The cooldown of the Hunter's Stalk button | Number | 10s |
| Hunter Stalk Duration | The duration of the Hunter's Stalk | Number | 25s |
| Maximum Stalk Uses | Maximum number of times a Hunter can Stalk | Number | 5 |
| Hunter Kills Last Voter If Voted Out | Whether the Hunter kills the last person that votes them if they are voted out | Toggle | False |
| Hunter Can Report Who They've Killed | Whether the Hunter is able to report their own kills | Toggle | True |

-----------------------
Expand Down
137 changes: 137 additions & 0 deletions source/Patches/CrewmateRoles/HunterMod/Retribution.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
using HarmonyLib;
using UnityEngine;
using Object = UnityEngine.Object;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using System.Linq;
using TownOfUs.CrewmateRoles.MedicMod;
using TownOfUs.Extensions;
using TownOfUs.Patches;
using TownOfUs.Roles;
using TownOfUs.Roles.Modifiers;
using Reactor.Utilities.Extensions;
using TownOfUs.CrewmateRoles.ImitatorMod;
using TownOfUs.CrewmateRoles.SwapperMod;
using TownOfUs.CrewmateRoles.VigilanteMod;
using TownOfUs.ImpostorRoles.BlackmailerMod;
using TownOfUs.Modifiers.AssassinMod;
using TownOfUs.NeutralRoles.DoomsayerMod;
using UnityEngine.UI;

namespace TownOfUs.CrewmateRoles.HunterMod
{
[HarmonyPatch(typeof(MeetingHud), nameof(MeetingHud.CastVote))]
internal class CastVote
{
private static void Postfix(MeetingHud __instance, [HarmonyArgument(0)] byte srcPlayerId, [HarmonyArgument(1)] byte suspectPlayerId)
{
var votingPlayer = Utils.PlayerById(srcPlayerId);
var suspectPlayer = Utils.PlayerById(suspectPlayerId);
if (!suspectPlayer.Is(RoleEnum.Hunter)) return;
var hunter = Role.GetRole<Hunter>(suspectPlayer);
hunter.LastVoted = votingPlayer;
}
}

[HarmonyPatch(typeof(ExileController), nameof(ExileController.BeginForGameplay))]
internal class MeetingExiledEnd
{
private static void Postfix(ExileController __instance)
{
var exiled = __instance.initData.networkedPlayer;
if (exiled == null) return;
var player = exiled.Object;
if (player.Is(RoleEnum.Hunter) && CustomGameOptions.RetributionOnVote)
{
var hunter = Role.GetRole<Hunter>(player);
if (hunter.LastVoted != null && hunter.LastVoted != player && !hunter.LastVoted.Is(RoleEnum.Pestilence))
{
foreach (var role in Role.AllRoles.Where(x => x.RoleType == RoleEnum.Executioner))
{
var exe = (Executioner)role;
if (exe.target == player) return;
}
Utils.Rpc(CustomRPC.Retribution, hunter.Player.PlayerId, hunter.LastVoted.PlayerId);
Retribution.MurderPlayer(hunter, hunter.LastVoted);
}
}
foreach (var role in Role.AllRoles.Where(x => x.RoleType == RoleEnum.Hunter))
{
var hunter = (Hunter)role;
hunter.LastVoted = null;
}
}
}

public class Retribution
{
public static void MurderPlayer(Hunter hunter, PlayerControl player)
{
if (player.Is(Faction.Crewmates)) hunter.IncorrectKills += 1;
else hunter.CorrectKills += 1;
MurderPlayer(player);
}

public static void MurderPlayer(
PlayerControl player,
bool checkLover = true
)
{
var hudManager = DestroyableSingleton<HudManager>.Instance;
if (checkLover)
{
SoundManager.Instance.PlaySound(player.KillSfx, false, 0.8f);
hudManager.KillOverlay.ShowKillAnimation(player.Data, player.Data);
}
var amOwner = player.AmOwner;
if (amOwner)
{
Utils.ShowDeadBodies = true;
hudManager.ShadowQuad.gameObject.SetActive(false);
player.nameText().GetComponent<MeshRenderer>().material.SetInt("_Mask", 0);
player.RpcSetScanner(false);
ImportantTextTask importantTextTask = new GameObject("_Player").AddComponent<ImportantTextTask>();
importantTextTask.transform.SetParent(AmongUsClient.Instance.transform, false);
if (!GameOptionsManager.Instance.currentNormalGameOptions.GhostsDoTasks)
{
for (int i = 0; i < player.myTasks.Count; i++)
{
PlayerTask playerTask = player.myTasks.ToArray()[i];
playerTask.OnRemove();
Object.Destroy(playerTask.gameObject);
}

player.myTasks.Clear();
importantTextTask.Text = DestroyableSingleton<TranslationController>.Instance.GetString(
StringNames.GhostIgnoreTasks,
new Il2CppReferenceArray<Il2CppSystem.Object>(0)
);
}
else
{
importantTextTask.Text = DestroyableSingleton<TranslationController>.Instance.GetString(
StringNames.GhostDoTasks,
new Il2CppReferenceArray<Il2CppSystem.Object>(0));
}

player.myTasks.Insert(0, importantTextTask);
}
player.Die(DeathReason.Kill, false);
if (checkLover && player.IsLover() && CustomGameOptions.BothLoversDie)
{
var otherLover = Modifier.GetModifier<Lover>(player).OtherLover.Player;
if (!otherLover.Is(RoleEnum.Pestilence)) MurderPlayer(otherLover, false);
}

var deadPlayer = new DeadPlayer
{
PlayerId = player.PlayerId,
KillerId = player.PlayerId,
KillTime = System.DateTime.UtcNow,
};

Murder.KilledPlayers.Add(deadPlayer);

AddHauntPatch.AssassinatedPlayers.Add(player);
}
}
}
3 changes: 2 additions & 1 deletion source/Patches/CrewmateRoles/JailorMod/JailChat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ public static bool Prefix(ChatController __instance, [HarmonyArgument(0)] ref Pl
else if (chatText.ToLower().StartsWith("/ jail")) chatText = chatText[6..];
else if (chatText.ToLower().StartsWith("/ jail ")) chatText = chatText[7..];
JailorMessage = true;
if (sourcePlayer != PlayerControl.LocalPlayer && PlayerControl.LocalPlayer.IsJailed()) sourcePlayer = PlayerControl.LocalPlayer;
if (sourcePlayer != PlayerControl.LocalPlayer && PlayerControl.LocalPlayer.IsJailed() && !sourcePlayer.Data.IsDead) sourcePlayer = PlayerControl.LocalPlayer;
return true;
}
else return false;
}
if (chatText.ToLower().StartsWith("/")) return false;
if (sourcePlayer.IsJailed() && MeetingHud.Instance)
{
if (PlayerControl.LocalPlayer == sourcePlayer || PlayerControl.LocalPlayer.Is(RoleEnum.Jailor)) return true;
Expand Down
4 changes: 2 additions & 2 deletions source/Patches/CrewmateRoles/ProsecutorMod/AddProsecute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class AddProsecute
public static void UpdateButton(Prosecutor role, MeetingHud __instance)
{
var skip = __instance.SkipVoteButton;
role.Prosecute.gameObject.SetActive(skip.gameObject.active && !role.Prosecuted);
role.Prosecute.gameObject.SetActive(skip.gameObject.active && !role.Prosecuted && !role.Player.IsJailed());
role.Prosecute.voteComplete = skip.voteComplete;
role.Prosecute.GetComponent<SpriteRenderer>().enabled = skip.GetComponent<SpriteRenderer>().enabled;
role.Prosecute.GetComponentsInChildren<TextMeshPro>()[0].text = "Prosecute";
Expand All @@ -36,7 +36,7 @@ public static void Postfix(MeetingHud __instance)
{
if (!PlayerControl.LocalPlayer.Is(RoleEnum.Prosecutor)) return;
var prosRole = Role.GetRole<Prosecutor>(PlayerControl.LocalPlayer);
if (!PlayerControl.LocalPlayer.IsJailed()) GenButton(prosRole, __instance);
GenButton(prosRole, __instance);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static bool Prefix(KillButton __instance)
{
try
{
PlayerMenu.singleton.Menu.Close();
PlayerMenu.singleton.Menu.ForceClose();
}
catch {
role.TransportPlayer1 = null;
Expand Down
1 change: 1 addition & 0 deletions source/Patches/CustomGameOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ public static class CustomGameOptions
public static float HunterStalkCd => Generate.HunterStalkCd.Get();
public static float HunterStalkDuration => Generate.HunterStalkDuration.Get();
public static int HunterStalkUses => (int)Generate.HunterStalkUses.Get();
public static bool RetributionOnVote => Generate.RetributionOnVote.Get();
public static bool HunterBodyReport => Generate.HunterBodyReport.Get();
public static bool DoomsayerCantObserve => Generate.DoomsayerCantObserve.Get();
public static float HypnotiseCd => Generate.HypnotiseCooldown.Get();
Expand Down
5 changes: 4 additions & 1 deletion source/Patches/CustomOption/Generate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ public class Generate
public static CustomNumberOption HunterStalkCd;
public static CustomNumberOption HunterStalkDuration;
public static CustomNumberOption HunterStalkUses;
public static CustomToggleOption RetributionOnVote;
public static CustomToggleOption HunterBodyReport;

public static CustomHeaderOption Engineer;
Expand Down Expand Up @@ -797,7 +798,7 @@ public static void GenerateAll()
CooldownFormat);

Haunter =
new CustomHeaderOption(num++, MultiMenu.crewmate, "<color=#d3d3d3FF>Haunter</color>");
new CustomHeaderOption(num++, MultiMenu.crewmate, "<color=#D3D3D3FF>Haunter</color>");
HaunterTasksRemainingClicked =
new CustomNumberOption(num++, MultiMenu.crewmate, "Tasks Remaining When Haunter Can Be Clicked", 5, 1, 15, 1);
HaunterTasksRemainingAlert =
Expand Down Expand Up @@ -893,6 +894,8 @@ public static void GenerateAll()
new CustomNumberOption(num++, MultiMenu.crewmate, "Hunter Stalk Duration", 25f, 5f, 60f, 2.5f, CooldownFormat);
HunterStalkUses =
new CustomNumberOption(num++, MultiMenu.crewmate, "Maximum Stalk Uses", 5, 1, 15, 1);
RetributionOnVote =
new CustomToggleOption(num++, MultiMenu.crewmate, "Hunter Kills Last Voter If Voted Out", false);
HunterBodyReport =
new CustomToggleOption(num++, MultiMenu.crewmate, "Hunter Can Report Who They've Killed");

Expand Down
8 changes: 4 additions & 4 deletions source/Patches/CustomOption/Patches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -588,15 +588,15 @@ public static void AddSettings(LobbyViewSettingsPane __instance, MultiMenu menu)
{
if (option.Type == CustomOptionType.Header)
{
if (settingsThisHeader % 2 != 0) num -= 0.6f;
if (settingsThisHeader % 2 != 0) num -= 0.85f;
CategoryHeaderMasked header = UnityEngine.Object.Instantiate<CategoryHeaderMasked>(__instance.categoryHeaderOrigin);
header.SetHeader(StringNames.ImpostorsCategory, 61);
header.Title.text = option.Name;
header.transform.SetParent(__instance.settingsContainer);
header.transform.localScale = Vector3.one;
header.transform.localPosition = new Vector3(-9.8f, num, -2f);
__instance.settingsInfo.Add(header.gameObject);
num -= 0.85f;
num -= 1f;
headingCount += 1;
settingsThisHeader = 0;
continue;
Expand All @@ -610,7 +610,7 @@ public static void AddSettings(LobbyViewSettingsPane __instance, MultiMenu menu)
if (settingsThisHeader % 2 != 0)
{
panel.transform.localPosition = new Vector3(-3f, num, -2f);
num -= 0.6f;
num -= 0.85f;
}
else
{
Expand All @@ -624,7 +624,7 @@ public static void AddSettings(LobbyViewSettingsPane __instance, MultiMenu menu)
}
}

float spacing = (headingCount * 0.85f + settingRowCount * 0.6f + 0.5f) / (headingCount + settingRowCount);
float spacing = (headingCount * 1f + settingRowCount * 0.85f + 2f) / (headingCount + settingRowCount);
__instance.scrollBar.CalculateAndSetYBounds((float)(__instance.settingsInfo.Count + headingCount + settingRowCount), 4f, 6f, spacing);
}
}
Expand Down
2 changes: 1 addition & 1 deletion source/Patches/CustomOption/Rpc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static void ReceiveRpc(MessageReader reader)

var panels = GameObject.FindObjectsOfType<ViewSettingsInfoPanel>();
foreach (var panel in panels) {
if (panel.titleText.text == customOption.Name)
if (panel.titleText.text == customOption.Name && customOption.Type != CustomOptionType.Header)
{
panel.SetInfo(StringNames.ImpostorsCategory, customOption.ToString(), 61);
panel.titleText.text = customOption.Name;
Expand Down
1 change: 1 addition & 0 deletions source/Patches/CustomRPC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public enum CustomRPC
Hypnotise,
Jail,
Collect,
Retribution,

BypassKill,
BypassMultiKill,
Expand Down
Loading

0 comments on commit 51a788c

Please sign in to comment.