Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin' into HEAD
Browse files Browse the repository at this point in the history
  • Loading branch information
Anusien committed Mar 18, 2022
2 parents 9fd2999 + 66d9a65 commit de28d22
Show file tree
Hide file tree
Showing 18 changed files with 281 additions and 14 deletions.
36 changes: 35 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ An Among Us mod that adds a bunch of roles, modifiers and game settings
- [Altruist](#altruist)
- [Prophet](#prophet)
- [Covert](#covert)
- [Lighter](#lighter)

**Neutral Roles**
- [Jester](#jester)
Expand Down Expand Up @@ -81,6 +82,25 @@ An Among Us mod that adds a bunch of roles, modifiers and game settings
<summary> Changelog </summary>
<ul>

<li>
<details>
<summary> v3.1.1 </summary>
<ul>
<li> If the Lover dies because the other Lover is voted out, they will not leave a body behind. Thanks <a href="https://github.com/ItsTheNumberH/">ItsTheNumberH</a>. </li>
</ul>
</details>
</li>

<li>
<details>
<summary> v3.1.0 </summary>
<ul>
<li> Added new role: Lighter. </li>
<li> Modifiers now more visible on role assignment screen. </li>
</ul>
</details>
</li>

<li>
<details>
<summary> v3.0.0 </summary>
Expand Down Expand Up @@ -920,7 +940,21 @@ The Covert is a Crewmate that can temporarily turn invisible. Their vision is ha
|----------|:-------------:|:------:|:------:|
| Covert | The percentage probability of the Covert appearing | Percentage | 0% |
| Covert Cooldown | The cooldown of the Covert's invisibility button | Time | 30s |
| Covert Cooldown | How long the Covert is invisible | Time | 15s |
| Covert Duration | How long the Covert is invisible | Time | 15s |


----------------------
## Lighter
### **Team: Crewmates**

The Lighter is a Crewmate that can temporarily increase their vision. While their ability is active, they will
get normal crewmate vision is lights are off and normal impostor vision if lights are on.
### Game Options
| Name | Description | Type | Default |
|----------|:-------------:|:------:|:------:|
| Lighter | The percentage probability of the Lighter appearing | Percentage | 0% |
| Lighter Cooldown | The cooldown of the Lighter's visibility | Time | 20s |
| Lighter Duration | How long the Lighter gets improved visibility invisible | Time | 5s |


-----------------------
Expand Down
3 changes: 1 addition & 2 deletions source/Patches/CrewmateRoles/CovertMod/PerformKill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ namespace TownOfUs.CrewmateRoles.CovertMod
[HarmonyPatch(typeof(KillButton), nameof(KillButton.DoClick))]
public class PerformKill
{

public static bool Prefix(KillButton __instance)
{
if (!PlayerControl.LocalPlayer.Is(RoleEnum.Covert))
Expand Down Expand Up @@ -48,4 +47,4 @@ public static bool Prefix(KillButton __instance)
return false;
}
}
}
}
18 changes: 18 additions & 0 deletions source/Patches/CrewmateRoles/LighterMod/LighterUpdate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using HarmonyLib;
using TownOfUs.Roles;

namespace TownOfUs.Patches.CrewmateRoles.LighterMod
{
[HarmonyPatch(typeof(HudManager), nameof(HudManager.Update))]
public class LighterUpdate
{
public static void Postfix(HudManager __instance)
{
foreach (var role in Role.GetRoles(RoleEnum.Lighter))
{
Lighter lighter = (Lighter) role;
lighter.LightTick();
}
}
}
}
46 changes: 46 additions & 0 deletions source/Patches/CrewmateRoles/LighterMod/ManageLighterButton.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using HarmonyLib;
using TownOfUs.Roles;
using UnityEngine;

namespace TownOfUs.Patches.CrewmateRoles.LighterMod
{
[HarmonyPatch(typeof(HudManager), nameof(HudManager.Update))]
public class ManageLighterButton
{
private static Sprite Sprite => TownOfUs.LighterSprite;

public static void Postfix(HudManager __instance)
{
if (
PlayerControl.AllPlayerControls.Count <= 1
|| PlayerControl.LocalPlayer == null
|| PlayerControl.LocalPlayer.Data == null
|| !PlayerControl.LocalPlayer.Is(RoleEnum.Lighter)
)
{
return;
}

Lighter role = Role.GetRole<Lighter>(PlayerControl.LocalPlayer);

if (role.LighterButton == null)
{
role.LighterButton = Object.Instantiate(__instance.KillButton, HudManager.Instance.transform);
role.LighterButton.graphic.enabled = true;
}

role.LighterButton.graphic.sprite = Sprite;
role.LighterButton.gameObject.SetActive(!PlayerControl.LocalPlayer.Data.IsDead && !MeetingHud.Instance);

if (role.IsLighting)
{
role.LighterButton.SetCoolDown(role.LighterTimeRemaining, CustomGameOptions.LighterDuration);
return;
}

role.LighterButton.SetCoolDown(role.CooldownTimer(), CustomGameOptions.LighterCooldown);
role.LighterButton.graphic.color = Palette.EnabledColor;
role.LighterButton.graphic.material.SetFloat("_Desat", 0f);
}
}
}
49 changes: 49 additions & 0 deletions source/Patches/CrewmateRoles/LighterMod/PerformKill.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using HarmonyLib;
using Hazel;
using TownOfUs.Roles;

namespace TownOfUs.Patches.CrewmateRoles.LighterMod
{
[HarmonyPatch(typeof(KillButton), nameof(KillButton.DoClick))]
public class PerformKill
{
public static bool Prefix(KillButton __instance)
{
if (!PlayerControl.LocalPlayer.Is(RoleEnum.Lighter))
{
return true;
}

if (
!PlayerControl.LocalPlayer.CanMove
|| PlayerControl.LocalPlayer.Data.IsDead
)
{
return false;
}

Lighter role = Role.GetRole<Lighter>(PlayerControl.LocalPlayer);
if (__instance != role.LighterButton)
{
return true;
}

if (
__instance.isCoolingDown
|| !__instance.isActiveAndEnabled
|| role.CooldownTimer() != 0
)
{
return false;
}

MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId,
(byte) CustomRPC.LighterOn, SendOption.Reliable, -1);
writer.Write(PlayerControl.LocalPlayer.PlayerId);
AmongUsClient.Instance.FinishRpcImmediately(writer);

role.LightOn();
return false;
}
}
}
7 changes: 4 additions & 3 deletions source/Patches/CrewmateRoles/LoversMod/Die.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ public static bool Prefix(PlayerControl __instance, [HarmonyArgument(0)] DeathRe
var otherLover = Role.GetRole<Lover>(__instance).OtherLover.Player;
if (otherLover.Data.IsDead) return true;

if (reason == DeathReason.Exile) KillButtonTarget.DontRevive = __instance.PlayerId;

if (AmongUsClient.Instance.AmHost) Utils.RpcMurderPlayer(otherLover, otherLover);
if (reason == DeathReason.Exile) {
KillButtonTarget.DontRevive = __instance.PlayerId;
otherLover.Exiled();
} else if (AmongUsClient.Instance.AmHost) Utils.RpcMurderPlayer(otherLover, otherLover);

return true;
}
Expand Down
1 change: 0 additions & 1 deletion source/Patches/CrewmateRoles/MedicMod/StopKill.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using HarmonyLib;
using Hazel;
using Reactor;
using TownOfUs.Extensions;
using TownOfUs.Roles;
Expand Down
4 changes: 4 additions & 0 deletions source/Patches/CustomGameOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public static class CustomGameOptions
public static int AltruistOn => (int) Generate.AltruistOn.Get();
public static int ProphetOn => (int) Generate.ProphetOn.Get();
public static int CovertOn => (int) Generate.CovertOn.Get();
public static int LighterOn => (int) Generate.LighterOn.Get();
public static int PhantomOn => (int) Generate.PhantomOn.Get();
public static int UndertakerOn => (int) Generate.UndertakerOn.Get();
public static int UnderdogOn => (int) Generate.UnderdogOn.Get();
Expand Down Expand Up @@ -93,6 +94,8 @@ public static class CustomGameOptions
public static int ProphetTotalReveals => (int) Generate.ProphetTotalReveals.Get();
public static float CovertCooldown => Generate.CovertCooldown.Get();
public static float CovertDuration => Generate.CovertDuration.Get();
public static float LighterCooldown => Generate.LighterCooldown.Get();
public static float LighterDuration => Generate.LighterDuration.Get();
public static bool NeutralRed => Generate.NeutralRed.Get();
public static float MimicCooldown => Generate.MimicCooldownOption.Get();
public static float MimicDuration => Generate.MimicDurationOption.Get();
Expand Down Expand Up @@ -160,6 +163,7 @@ public static List<RoleEnum> GetEnabledRoles(params Faction[] factions)
if (On(AltruistOn)) enabledRoles.Add(RoleEnum.Altruist);
if (On(ProphetOn)) enabledRoles.Add(RoleEnum.Prophet);
if (On(CovertOn)) enabledRoles.Add(RoleEnum.Covert);
if (On(LighterOn)) enabledRoles.Add(RoleEnum.Lighter);
}
else if (faction == Faction.Neutral)
{
Expand Down
1 change: 0 additions & 1 deletion source/Patches/CustomHats/HatLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ internal static class HatLoader
{
private const string HAT_RESOURCE_NAMESPACE = "TownOfUs.Resources.Hats";
private const string HAT_METADATA_JSON = "metadata.json";
private const int HAT_ORDER_BASELINE = 99;

private static ManualLogSource Log => PluginSingleton<TownOfUs>.Instance.Log;
private static Assembly Assembly => typeof(TownOfUs).Assembly;
Expand Down
11 changes: 11 additions & 0 deletions source/Patches/CustomOption/Generate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public static class Generate
public static CustomNumberOption AltruistOn;
public static CustomNumberOption ProphetOn;
public static CustomNumberOption CovertOn;
public static CustomNumberOption LighterOn;

private static CustomHeaderOption NeutralRoles;
public static CustomNumberOption JesterOn;
Expand Down Expand Up @@ -147,6 +148,10 @@ public static class Generate
public static CustomNumberOption CovertCooldown;
public static CustomNumberOption CovertDuration;

private static CustomHeaderOption Lighter;
public static CustomNumberOption LighterCooldown;
public static CustomNumberOption LighterDuration;

private static CustomHeaderOption TheGlitch;
public static CustomNumberOption MimicCooldownOption;
public static CustomNumberOption MimicDurationOption;
Expand Down Expand Up @@ -236,6 +241,8 @@ public static void GenerateAll()
PercentFormat);
CovertOn = new CustomNumberOption(true, num++, $"{RoleDetailsAttribute.GetRoleDetails(RoleEnum.Covert).GetColoredName()}", 0f, 0f, 100f, 10f,
PercentFormat);
LighterOn = new CustomNumberOption(true, num++, $"{RoleDetailsAttribute.GetRoleDetails(RoleEnum.Lighter).GetColoredName()}", 0f, 0f, 100f, 10f,
PercentFormat);


NeutralRoles = new CustomHeaderOption(num++, "Neutral Roles");
Expand Down Expand Up @@ -435,6 +442,10 @@ public static void GenerateAll()
Covert = new CustomHeaderOption(num++, $"{RoleDetailsAttribute.GetRoleDetails(RoleEnum.Covert).GetColoredName()}");
CovertCooldown = new CustomNumberOption(num++, "Covert Cooldown", 30f, 10f, 120f, 2.5f, CooldownFormat);
CovertDuration = new CustomNumberOption(num++, "Covert Duration", 15f, 5f, 30f, 2.5f, CooldownFormat);

Lighter = new CustomHeaderOption(num++, $"{RoleDetailsAttribute.GetRoleDetails(RoleEnum.Lighter).GetColoredName()}");
LighterCooldown = new CustomNumberOption(num++, "Lighter Cooldown", 20f, 5f, 60f, 2.5f, CooldownFormat);
LighterDuration = new CustomNumberOption(num++, "Lighter Duration", 5f, 1f, 10f, 2.5f, CooldownFormat);
#endregion


Expand Down
2 changes: 2 additions & 0 deletions source/Patches/CustomRPC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public enum CustomRPC
SetAltruist,
SetProphet,
SetCovert,
SetLighter,
SetUndertaker,
SetUnderdog,
SetTeleporter,
Expand Down Expand Up @@ -89,6 +90,7 @@ public enum CustomRPC
Teleport,
Conceal,
GoCovert,
LighterOn,
FlashGrenade,

SetGlitch,
Expand Down
25 changes: 22 additions & 3 deletions source/Patches/LowLights.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ public static bool Prefix(ShipStatus __instance, [HarmonyArgument(0)] GameData.P
return false;
}

if (player.IsImpostor() || player._object.Is(RoleEnum.Glitch))
SwitchSystem switchSystem = __instance.Systems[SystemTypes.Electrical].Cast<SwitchSystem>();

if (
player.IsImpostor()
|| player._object.Is(RoleEnum.Glitch)
|| (IsLighterAndLit(player) && !switchSystem.IsActive)
)
{
__result = __instance.MaxLightRadius * PlayerControl.GameOptions.ImpostorLightMod;
if (player.Object.Is(ModifierEnum.ButtonBarry))
Expand All @@ -27,9 +33,11 @@ public static bool Prefix(ShipStatus __instance, [HarmonyArgument(0)] GameData.P
return false;
}

SwitchSystem switchSystem = __instance.Systems[SystemTypes.Electrical].Cast<SwitchSystem>();
float lightPercentage = switchSystem.Value / 255f;
if (player._object.Is(ModifierEnum.Torch)) lightPercentage = 1;
if (player._object.Is(ModifierEnum.Torch) || IsLighterAndLit(player))
{
lightPercentage = 1;
}
__result = Mathf.Lerp(__instance.MinLightRadius, __instance.MaxLightRadius, lightPercentage) *
PlayerControl.GameOptions.CrewLightMod;

Expand All @@ -43,5 +51,16 @@ public static bool Prefix(ShipStatus __instance, [HarmonyArgument(0)] GameData.P
}
return false;
}

private static bool IsLighterAndLit(GameData.PlayerInfo player)
{
if (!player._object.Is(RoleEnum.Lighter))
{
return false;
}

Lighter lighter = Role.GetRole<Lighter>(player._object);
return lighter.IsLighting;
}
}
}
2 changes: 2 additions & 0 deletions source/Patches/RoleEnum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public enum RoleEnum
Prophet,
[RoleDetails("Covert", "#7B7F1A", Faction.Crewmates)]
Covert,
[RoleDetails("Lighter", "#DE876D", Faction.Crewmates)]
Lighter,

[RoleDetails("Jester", "#FFBFCCFF", Faction.Neutral)]
Jester,
Expand Down
Loading

0 comments on commit de28d22

Please sign in to comment.