Skip to content

Commit

Permalink
feat: 2021.3.31.3s + Oxygen Sabotage slows down the players
Browse files Browse the repository at this point in the history
  • Loading branch information
Pandraghon committed Apr 4, 2021
1 parent 631243b commit 80c0d02
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 19 deletions.
2 changes: 2 additions & 0 deletions BetterSabotage/BetterSabotage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using BepInEx;
using BepInEx.Configuration;
using BepInEx.IL2CPP;
using Epic.OnlineServices.Stats;
using Essentials.Options;
using HarmonyLib;
using Reactor;
Expand Down Expand Up @@ -67,6 +68,7 @@ public class BetterSabotage : BasePlugin
//Credit to https://github.com/DorCoMaNdO/Reactor-Essentials
public static CustomStringOption CommsSabotageAnonymous = CustomOption.AddString("Comms Sabotage Anonymous", new string[] { "Nobody", "Crewmates", "Everyone" });
public static CustomStringOption ReactorSabotageShaking = CustomOption.AddString("Reactor Sabotage Shaking", new string[] { "None", "Low", "High" });
public static CustomToggleOption OxygenSabotageSlowdown = CustomOption.AddToggle("Oxygen Sabotage Slows Down", false);

public static float[] ShakingValues { get; private set; }
public Harmony Harmony { get; } = new Harmony(Id);
Expand Down
13 changes: 4 additions & 9 deletions BetterSabotage/BetterSabotage.csproj
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<Version>1.0.5</Version>
<Mappings>NuclearPowered/Mappings:0.2.0</Mappings>
<Version>1.1.0</Version>
<Mappings>NuclearPowered/Mappings:0.3.0</Mappings>

<Description>BetterSabotage</Description>
<Authors>Pandraghon</Authors>
</PropertyGroup>

<PropertyGroup Condition="'$(GamePlatform)' == 'Steam'">
<GameVersion>2021.3.5s</GameVersion>
<GameVersion>2021.3.31.3s</GameVersion>
<DefineConstants>$(DefineConstants);STEAM</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(GamePlatform)' == 'Itch'">
<GameVersion>2020.11.17i</GameVersion>
<DefineConstants>$(DefineConstants);ITCH</DefineConstants>
</PropertyGroup>

<ItemGroup>
<Deobfuscate Include="$(AmongUs)\BepInEx\plugins\Reactor-$(GameVersion).dll" />

<PackageReference Include="Reactor.OxygenFilter.MSBuild" Version="0.2.9" />
<PackageReference Include="Reactor.OxygenFilter.MSBuild" Version="0.3.0" />
</ItemGroup>

<ItemGroup>
Expand Down
18 changes: 18 additions & 0 deletions BetterSabotage/HubManagerPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ static void Postfix(HudManager __instance)
if (AmongUsClient.Instance.GameState == InnerNetClient.GameStates.Started)
{
ReactorTask reactorTask = Object.FindObjectOfType<ReactorTask>();
NoOxyTask oxygenTask = Object.FindObjectOfType<NoOxyTask>();
if (reactorTask && ReactorSabotageShaking.GetValue() != 0)
{
float reactorCountdown = reactorTask.reactor.Countdown;
Expand All @@ -27,6 +28,23 @@ static void Postfix(HudManager __instance)
__instance.PlayerCam.shakeAmount = 0;
__instance.PlayerCam.shakePeriod = 0;
}

if (oxygenTask && OxygenSabotageSlowdown.GetValue())
{
foreach (PlayerControl player in PlayerControl.AllPlayerControls)
{
player.MyPhysics.Speed = Math.Max(1.5f,
Math.Min(2.5f,
2.5f * oxygenTask.reactor.Countdown / oxygenTask.reactor.LifeSuppDuration));
}
}
else
{
foreach (PlayerControl player in PlayerControl.AllPlayerControls)
{
player.MyPhysics.Speed = 2.5f;
}
}
}
}
}
Expand Down
20 changes: 10 additions & 10 deletions BetterSabotage/PlayerControlPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ namespace Glaucus
[HarmonyPatch(typeof(PlayerControl))]
class PlayerControlPatch
{
[HarmonyPatch("CAMJPMDIIMN" /* PlayerControl.Visible */, MethodType.Setter)]
static void Postfix(PlayerControl __instance, ref bool NJFHEFBMBOD)
[HarmonyPatch("FHBHBMIJFID" /* PlayerControl.Visible */, MethodType.Setter)]
static void Postfix(PlayerControl __instance, ref bool IKGGJMHPDGH)
{
if (!PlayerControl.LocalPlayer || PlayerControl.LocalPlayer.myTasks == null) return;
if (PlayerControl.LocalPlayer.myTasks.ToArray().Any(task => task.TaskType == TaskTypes.FixComms)
Expand All @@ -28,9 +28,9 @@ static void Postfix(PlayerControl __instance, ref bool NJFHEFBMBOD)
}

[HarmonyPatch(nameof(PlayerControl.SetPlayerMaterialColors), new Type[] {typeof(int), typeof(Renderer)})]
static void Postfix(int FGAOHLPPBDL /* colorId */, Renderer FNEEAAEEGLD)
static void Postfix(int PNGKEHIHPLJ /* colorId */, Renderer AGOAPDBAHKG)
{
Renderer rend = FNEEAAEEGLD;
Renderer rend = AGOAPDBAHKG;
if (!rend || !PlayerControl.LocalPlayer || PlayerControl.LocalPlayer.myTasks == null) return;
if (PlayerControl.LocalPlayer.myTasks.ToArray().Any(task => task.TaskType == TaskTypes.FixComms)
&& (BetterSabotage.CommsSabotageAnonymous.GetValue() == 1 && !PlayerControl.LocalPlayer.Data.IsImpostor
Expand All @@ -42,9 +42,9 @@ static void Postfix(int FGAOHLPPBDL /* colorId */, Renderer FNEEAAEEGLD)
}

[HarmonyPatch(nameof(PlayerControl.SetPlayerMaterialColors), new Type[] {typeof(Color), typeof(Renderer)})]
static void Postfix(Color JMDILEGDONK, Renderer FNEEAAEEGLD)
static void Postfix(Color JBOMEMICJJM, Renderer AGOAPDBAHKG)
{
Renderer rend = FNEEAAEEGLD;
Renderer rend = AGOAPDBAHKG;
if (!rend || !PlayerControl.LocalPlayer) return;
if (BetterSabotage.CommsSabotageAnonymous.GetValue() == 1 && !PlayerControl.LocalPlayer.Data.IsImpostor
|| BetterSabotage.CommsSabotageAnonymous.GetValue() == 2)
Expand All @@ -55,9 +55,9 @@ static void Postfix(Color JMDILEGDONK, Renderer FNEEAAEEGLD)
}

[HarmonyPatch(nameof(PlayerControl.AddSystemTask))]
static void Postfix(SystemTypes IBKONFPFHAB)
static void Postfix(SystemTypes LEDKOPINDJL)
{
SystemTypes system = IBKONFPFHAB;
SystemTypes system = LEDKOPINDJL;
switch (system)
{
case SystemTypes.Comms:
Expand All @@ -70,9 +70,9 @@ static void Postfix(SystemTypes IBKONFPFHAB)
}

[HarmonyPatch(nameof(PlayerControl.RemoveTask))]
static void Postfix(PlayerTask HHCGLKKJDLA)
static void Postfix(PlayerTask NBPIFFEDABA)
{
PlayerTask task = HHCGLKKJDLA;
PlayerTask task = NBPIFFEDABA;
switch (task.TaskType)
{
case TaskTypes.FixComms:
Expand Down

0 comments on commit 80c0d02

Please sign in to comment.