Skip to content

Commit

Permalink
v5.0.2 Source Code
Browse files Browse the repository at this point in the history
  • Loading branch information
eDonnes124 committed Oct 6, 2023
1 parent 84de769 commit 198b9b8
Show file tree
Hide file tree
Showing 53 changed files with 646 additions and 228 deletions.
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ Join our [Discord](https://discord.gg/ugyc4EVUYZ) if you have any problems or wa
# Releases
| Among Us - Version| Mod Version | Link |
|----------|-------------|-----------------|
| 2023.7.12s & 2023.7.12e | v5.0.2 | [Download](https://github.com/eDonnes124/Town-Of-Us/releases/download/v5.0.2/ToU.v5.0.2.zip) |
| 2023.6.13s & 2023.6.13e | v5.0.1 | [Download](https://github.com/eDonnes124/Town-Of-Us/releases/download/v5.0.1/ToU.v5.0.1.zip) |
| 2023.6.13s & 2023.6.13e | v5.0.0 | [Download](https://github.com/eDonnes124/Town-Of-Us/releases/download/v5.0.0/ToU.v5.0.0.zip) |
| 2023.3.28s & 2023.3.28e | v4.0.6 | [Download](https://github.com/eDonnes124/Town-Of-Us/releases/download/v4.0.6/ToU.v4.0.6.zip) |
Expand Down Expand Up @@ -145,11 +146,19 @@ Join our [Discord](https://discord.gg/ugyc4EVUYZ) if you have any problems or wa
<details>
<summary> Changelog </summary>
<details>
<summary> v5.0.2 </summary>
<ul> <li>Compatibility with the new Among Us version v2023.7.12</li> </ul>
<ul> <li>New Setting: Detective can detect last killer</li> </ul>
<ul> <li>New Setting: Neutral Evil Win Ends Game</li> </ul>
<ul> <li>New Settings: Neutral Evils can kill players on victory</li> </ul>
</details>
<details>
<summary> v5.0.1 </summary>
<ul> <li>Bug Fix: Airship Ladders work again</li> </ul>
</details>
<details>
<summary> v5.0.0 </summary>
<ul> <li>Compatibility with the new Among Us version v2023.6.13</li> </ul>
<ul> <li>New Role: Doomsayer</li> </ul>
<ul> <li>New Role: Vampire</li> </ul>
<ul> <li>New Role: Vampire Hunter</li> </ul>
Expand Down Expand Up @@ -787,6 +796,7 @@ If the killer of the inspected player dies, the following round the examine butt
| Show Detective Reports | Whether the Detective should get information when reporting a body | Toggle | True |
| Time Where Detective Reports Will Have Role | If a body has been dead for shorter than this amount, the Detective's report will contain the killer's role | Time | 15s |
| Time Where Detective Reports Will Have Faction | If a body has been dead for shorter than this amount, the Detective's report will contain the killer's faction | Time | 30s |
| Can Detect Last Killer | Whether the Detective can also detect the last player who killed (resets on round start) | Toggle | False |

-----------------------
## Haunter
Expand Down Expand Up @@ -1245,6 +1255,7 @@ If that player gets voted out, they win the game.
| Executioner | The percentage probability of the Executioner appearing | Percentage | 0% |
| Executioner becomes on Target Dead | Which role the Executioner becomes when their target dies | Crewmate / Amnesiac / Survivor / Jester | Crewmate |
| Executioner Can Button | Whether the Executioner Can Press the Button | Toggle | True |
| Executioner Torment On Victory | Whether the Executioner can torment someone when they win | Toggle | True |

-----------------------
## Jester
Expand All @@ -1260,6 +1271,7 @@ However, the Jester does not win if the Crewmates, Impostors or another Neutral
| Jester Can Button | Whether the Jester Can Press the Button | Toggle | True |
| Jester Can Vent | Whether the Jester Can Vent | Toggle | False |
| Jester Has Impostor Vision | Whether the Jester Has Impostor Vision | Toggle | False |
| Jester Haunt On Victory | Whether the Jester can haunt someone when they win | Toggle | True |

-----------------------
## Phantom
Expand All @@ -1272,6 +1284,7 @@ They become half-invisible when they die and has to complete all their tasks wit
|----------|:-------------:|:------:|:------:|
| Phantom | The percentage probability of the Phantom appearing | Percentage | 0% |
| When Phantom Can Be Clicked | The amount of tasks remaining when the Phantom Can Be Clicked | Number | 5 |
| Phantom Spook On Victory | Whether the Phantom can spook someone when they win | Toggle | True |

-----------------------
## Arsonist
Expand Down Expand Up @@ -1837,6 +1850,7 @@ When they are the only remaining Impostor, they will have their kill cooldown sh
| Disable Meeting Skip Button | Whether the meeting button is disabled | No / Emergency / Always | No |
| Enable Hidden Roles | Whether hidden roles are added to the role selections | Toggle | True |
| First Death Shield Next Game | Whether the first player to die gets a shield for the first round next game | Toggle | False |
| Neutral Evils Win Ends Game | Whether a Neutral Evil role winning ends the game | Toggle | True |

-----------------------
# Task Tracking Settings
Expand Down Expand Up @@ -1900,7 +1914,7 @@ If you have any bugs or any need to contact me, join the [Discord Server](https:
[TheOtherRoles](https://github.com/Eisbison/TheOtherRoles) - For the inspiration of the Vigilante, Tracker and Spy roles, as well as the Bait modifier.\
[5up](https://www.twitch.tv/5uppp) and the Submarine Team - For the inspiration of the Grenadier role.\
[Guus](https://github.com/OhMyGuus) - For support for the old Among Us versions (v2021.11.9.5 and v2021.12.15).\
[MyDragonBreath](https://github.com/MyDragonBreath) - For Submerged Compatibility, the Trapper and Aurial roles, the Aftermath modifier and support for the new Among Us versions (v2022.6.21 & v2023.6.13).\
[MyDragonBreath](https://github.com/MyDragonBreath) - For Submerged Compatibility, the Trapper and Aurial roles, the Aftermath modifier and support for the new Among Us versions (v2022.6.21, v2023.6.13 & v2023.7.12).\
[ItsTheNumberH](https://github.com/itsTheNumberH/Town-Of-H) - For the code used for Blind, Bait, Poisoner and partially for Tracker, as well as other bug fixes.\
[Ruiner](https://github.com/ruiner189/Town-Of-Us-Redux) - For lovers changed into a modifier and Task Tracking.\
[Term](https://www.twitch.tv/termboii) - For creating Transporter, Medium, Blackmailer, Plaguebearer, Sleuth, Multitasker and porting v2.5.0 to the new Among Us version (v2021.12.15).\
Expand Down
89 changes: 46 additions & 43 deletions source/Patches/AmongUsClient_OnGameEnd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,57 +109,60 @@ public static void Prefix()
return;
}

foreach (var role in Role.AllRoles)
if (CustomGameOptions.NeutralEvilWinEndsGame)
{
var type = role.RoleType;

if (type == RoleEnum.Jester)
foreach (var role in Role.AllRoles)
{
var jester = (Jester)role;
if (jester.VotedOut)
var type = role.RoleType;

if (type == RoleEnum.Jester)
{
TempData.winners = new List<WinningPlayerData>();
var jestData = new WinningPlayerData(jester.Player.Data);
jestData.IsDead = false;
if (PlayerControl.LocalPlayer != jester.Player) jestData.IsYou = false;
TempData.winners.Add(jestData);
return;
var jester = (Jester)role;
if (jester.VotedOut)
{
TempData.winners = new List<WinningPlayerData>();
var jestData = new WinningPlayerData(jester.Player.Data);
jestData.IsDead = false;
if (PlayerControl.LocalPlayer != jester.Player) jestData.IsYou = false;
TempData.winners.Add(jestData);
return;
}
}
}
else if (type == RoleEnum.Executioner)
{
var executioner = (Executioner)role;
if (executioner.TargetVotedOut)
else if (type == RoleEnum.Executioner)
{
TempData.winners = new List<WinningPlayerData>();
var exeData = new WinningPlayerData(executioner.Player.Data);
if (PlayerControl.LocalPlayer != executioner.Player) exeData.IsYou = false;
TempData.winners.Add(exeData);
return;
var executioner = (Executioner)role;
if (executioner.TargetVotedOut)
{
TempData.winners = new List<WinningPlayerData>();
var exeData = new WinningPlayerData(executioner.Player.Data);
if (PlayerControl.LocalPlayer != executioner.Player) exeData.IsYou = false;
TempData.winners.Add(exeData);
return;
}
}
}
else if (type == RoleEnum.Doomsayer)
{
var doom = (Doomsayer)role;
if (doom.WonByGuessing)
else if (type == RoleEnum.Doomsayer)
{
TempData.winners = new List<WinningPlayerData>();
var doomData = new WinningPlayerData(doom.Player.Data);
if (PlayerControl.LocalPlayer != doom.Player) doomData.IsYou = false;
TempData.winners.Add(doomData);
return;
var doom = (Doomsayer)role;
if (doom.WonByGuessing)
{
TempData.winners = new List<WinningPlayerData>();
var doomData = new WinningPlayerData(doom.Player.Data);
if (PlayerControl.LocalPlayer != doom.Player) doomData.IsYou = false;
TempData.winners.Add(doomData);
return;
}
}
}
else if (type == RoleEnum.Phantom)
{
var phantom = (Phantom)role;
if (phantom.CompletedTasks)
else if (type == RoleEnum.Phantom)
{
TempData.winners = new List<WinningPlayerData>();
var phantomData = new WinningPlayerData(phantom.Player.Data);
if (PlayerControl.LocalPlayer != phantom.Player) phantomData.IsYou = false;
TempData.winners.Add(phantomData);
return;
var phantom = (Phantom)role;
if (phantom.CompletedTasks)
{
TempData.winners = new List<WinningPlayerData>();
var phantomData = new WinningPlayerData(phantom.Player.Data);
if (PlayerControl.LocalPlayer != phantom.Player) phantomData.IsYou = false;
TempData.winners.Add(phantomData);
return;
}
}
}
}
Expand Down Expand Up @@ -275,7 +278,7 @@ public static void Prefix()
var surv = (Survivor)role;
if (!surv.Player.Data.IsDead && !surv.Player.Data.Disconnected)
{
var isImp = TempData.winners[0].IsImpostor;
var isImp = TempData.winners.Count != 0 && TempData.winners[0].IsImpostor;
var survWinData = new WinningPlayerData(surv.Player.Data);
if (isImp) survWinData.IsImpostor = true;
if (PlayerControl.LocalPlayer != surv.Player) survWinData.IsYou = false;
Expand Down
2 changes: 1 addition & 1 deletion source/Patches/CanMove.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static bool Prefix(PlayerControl __instance, ref bool __result)
&& !Minigame.Instance
&& !__instance.shapeshifting
&& (!DestroyableSingleton<HudManager>.InstanceExists
|| !DestroyableSingleton<HudManager>.Instance.Chat.IsOpen
|| !DestroyableSingleton<HudManager>.Instance.Chat.IsOpenOrOpening
&& !DestroyableSingleton<HudManager>.Instance.KillOverlay.IsOpen
&& !DestroyableSingleton<HudManager>.Instance.GameMenu.IsOpen)
/*&& (!ControllerManager.Instance || !ControllerManager.Instance.IsUiControllerActive)*/
Expand Down
1 change: 0 additions & 1 deletion source/Patches/CrewmateRoles/AltruistMod/UpdateArrows.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using HarmonyLib;
using Reactor.Utilities.Extensions;
using TownOfUs.Extensions;

namespace TownOfUs.CrewmateRoles.AltruistMod
{
Expand Down
25 changes: 8 additions & 17 deletions source/Patches/CrewmateRoles/DetectiveMod/HudExamine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,30 +43,21 @@ public static void UpdateExamineButton(HudManager __instance)
&& !MeetingHud.Instance && !PlayerControl.LocalPlayer.Data.IsDead
&& AmongUsClient.Instance.GameState == InnerNet.InnerNetClient.GameStates.Started);

if (role.ExamineMode)
role.ExamineButton.SetCoolDown(role.ExamineTimer(), CustomGameOptions.ExamineCd);
Utils.SetTarget(ref role.ClosestPlayer, role.ExamineButton, float.NaN);

var renderer = role.ExamineButton.graphic;
if (role.ClosestPlayer != null)
{
role.ExamineButton.SetCoolDown(role.ExamineTimer(), CustomGameOptions.ExamineCd);
Utils.SetTarget(ref role.ClosestPlayer, role.ExamineButton, float.NaN);

var renderer = role.ExamineButton.graphic;
if (role.ClosestPlayer != null)
{
renderer.color = Palette.EnabledColor;
renderer.material.SetFloat("_Desat", 0f);
}
else
{
renderer.color = Palette.DisabledClear;
renderer.material.SetFloat("_Desat", 1f);
}
renderer.color = Palette.EnabledColor;
renderer.material.SetFloat("_Desat", 0f);
}
else
{
role.ExamineButton.SetCoolDown(0f, 1f);
var renderer = role.ExamineButton.graphic;
renderer.color = Palette.DisabledClear;
renderer.material.SetFloat("_Desat", 1f);
}

var data = PlayerControl.LocalPlayer.Data;
var isDead = data.IsDead;
var truePosition = PlayerControl.LocalPlayer.GetTruePosition();
Expand Down
11 changes: 3 additions & 8 deletions source/Patches/CrewmateRoles/DetectiveMod/PerformKill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,14 @@ public static bool Prefix(KillButton __instance)
{
var flag2 = role.ExamineTimer() == 0f;
if (!flag2) return false;
if (!role.ExamineMode) return false;
if (role.ClosestPlayer == null) return false;
if (Vector2.Distance(role.ClosestPlayer.GetTruePosition(),
PlayerControl.LocalPlayer.GetTruePosition()) > maxDistance) return false;
if (role.ClosestPlayer == null) return false;
var interact = Utils.Interact(PlayerControl.LocalPlayer, role.ClosestPlayer);
if (interact[4] == true)
{
if (role.ClosestPlayer == role.DetectedKiller) Coroutines.Start(Utils.FlashCoroutine(Color.red));
if (role.DetectedKillers.Contains(role.ClosestPlayer.PlayerId) || (CustomGameOptions.CanDetectLastKiller && role.LastKiller == role.ClosestPlayer)) Coroutines.Start(Utils.FlashCoroutine(Color.red));
else Coroutines.Start(Utils.FlashCoroutine(Color.green));
}
if (interact[0] == true)
Expand All @@ -57,17 +56,13 @@ public static bool Prefix(KillButton __instance)
PlayerControl.LocalPlayer.GetTruePosition()) > maxDistance) return false;
var playerId = role.CurrentTarget.ParentId;
var player = Utils.PlayerById(playerId);
if ((player.IsInfected() || role.Player.IsInfected()))
if (player.IsInfected() || role.Player.IsInfected())
{
foreach (var pb in Role.GetRoles(RoleEnum.Plaguebearer)) ((Plaguebearer)pb).RpcSpreadInfection(player, role.Player);
}
foreach (var deadPlayer in Murder.KilledPlayers)
{
if (deadPlayer.PlayerId == playerId)
{
role.DetectedKiller = Utils.PlayerById(deadPlayer.KillerId);
role.ExamineMode = true;
}
if (deadPlayer.PlayerId == playerId) role.DetectedKillers.Add(deadPlayer.KillerId);
}
return false;
}
Expand Down
19 changes: 16 additions & 3 deletions source/Patches/CrewmateRoles/HaunterMod/SetHaunter.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
using System;
using HarmonyLib;
using Hazel;
using TownOfUs.Roles;
using UnityEngine;
using Object = UnityEngine.Object;
using Random = UnityEngine.Random;
using TownOfUs.Patches;
using TownOfUs.CrewmateRoles.AurialMod;
using TownOfUs.Patches.ScreenEffects;
using System.Linq;
using System.Collections.Generic;

namespace TownOfUs.CrewmateRoles.HaunterMod
{
Expand Down Expand Up @@ -75,8 +76,20 @@ public static void ExileControllerPostfix(ExileController __instance)
if (PlayerControl.LocalPlayer != WillBeHaunter) return;

if (Role.GetRole<Haunter>(PlayerControl.LocalPlayer).Caught) return;
var startingVent =
ShipStatus.Instance.AllVents[Random.RandomRangeInt(0, ShipStatus.Instance.AllVents.Count)];

List<Vent> vents = new();
var CleanVentTasks = PlayerControl.LocalPlayer.myTasks.ToArray().Where(x => x.TaskType == TaskTypes.VentCleaning).ToList();
if (CleanVentTasks != null)
{
var ids = CleanVentTasks.Where(x => !x.IsComplete)
.ToList()
.ConvertAll(x => x.FindConsoles()[0].ConsoleId);

vents = ShipStatus.Instance.AllVents.Where(x => !ids.Contains(x.Id)).ToList();
}
else vents = ShipStatus.Instance.AllVents.ToList();

var startingVent = vents[Random.RandomRangeInt(0, vents.Count)];


Utils.Rpc(CustomRPC.SetPos, PlayerControl.LocalPlayer.PlayerId, startingVent.transform.position.x, startingVent.transform.position.y + 0.3636f);
Expand Down
10 changes: 10 additions & 0 deletions source/Patches/CrewmateRoles/TransporterMod/Update.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,14 @@ private static void Postfix(HudManager __instance)
Role.GetRole<Transporter>(PlayerControl.LocalPlayer).Update(__instance);
}
}

[HarmonyPatch(typeof(ChatController), nameof(ChatController.UpdateChatMode))]
class chatModeUpdate
{
private static bool Prefix(ChatController __instance)
{
if (!PlayerControl.LocalPlayer.Is(RoleEnum.Transporter)) return true;
return (__instance != Role.GetRole<Transporter>(PlayerControl.LocalPlayer).TransportList);
}
}
}
Loading

4 comments on commit 198b9b8

@JeanTheFungle
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Best change hopefully i wish next time get idea from my pulls

@AlchlcDvl
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't fully expect all of your code to make it, as it's all up to the collaborators' discretion

stop begging them to use your code

@JeanTheFungle
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't fully expect all of your code to make it, as it's all up to the collaborators' discretion

stop begging them to use your code

i'am not begging them and i wante just add my idea if they wante

@AlchlcDvl
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then stop constantly asking them to add your stuff, they'll add it when they want to add it and will let you know if they do

also it does look like begging lmao

Please sign in to comment.