Skip to content
This repository has been archived by the owner on Feb 19, 2022. It is now read-only.

Commit

Permalink
refactor(Sheriff): remove kills glitch option
Browse files Browse the repository at this point in the history
  • Loading branch information
NotSugden committed Jul 29, 2021
1 parent f2f5ea6 commit 465ab0e
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 24 deletions.
35 changes: 19 additions & 16 deletions source/Patches/CrewmateRoles/SheriffMod/Kill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,41 +20,44 @@ private static bool Prefix(KillButtonManager __instance)
if (PlayerControl.LocalPlayer.Data.IsDead) return false;
var flag2 = role.SheriffKillTimer() == 0f;
if (!flag2) return false;
if (!__instance.enabled || role.ClosestPlayer == null) return false;
var distBetweenPlayers = Utils.getDistBetweenPlayers(PlayerControl.LocalPlayer, role.ClosestPlayer);
var target = role.ClosestPlayer;
if (!__instance.enabled || target == null) return false;
var distBetweenPlayers = Utils.getDistBetweenPlayers(PlayerControl.LocalPlayer, target);
var flag3 = distBetweenPlayers < GameOptionsData.KillDistances[PlayerControl.GameOptions.KillDistance];
if (!flag3) return false;
if (role.ClosestPlayer.isShielded())
if (target.isShielded())
{
var medic = role.ClosestPlayer.getMedic().Player.PlayerId;
var medic = target.getMedic().Player.PlayerId;
var writer1 = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId,
(byte) CustomRPC.AttemptSound, SendOption.Reliable, -1);
writer1.Write(medic);
writer1.Write(role.ClosestPlayer.PlayerId);
writer1.Write(target.PlayerId);
AmongUsClient.Instance.FinishRpcImmediately(writer1);

if (CustomGameOptions.ShieldBreaks) role.LastKilled = DateTime.UtcNow;

StopKill.BreakShield(medic, role.ClosestPlayer.PlayerId, CustomGameOptions.ShieldBreaks);
StopKill.BreakShield(medic, target.PlayerId, CustomGameOptions.ShieldBreaks);

return false;
}

var flag4 = role.ClosestPlayer.Data.IsImpostor ||
role.ClosestPlayer.Is(RoleEnum.Jester) && CustomGameOptions.SheriffKillsJester ||
role.ClosestPlayer.Is(RoleEnum.Glitch) && CustomGameOptions.SheriffKillsGlitch ||
role.ClosestPlayer.Is(RoleEnum.Arsonist) && CustomGameOptions.SheriffKillsArsonist;
if (!flag4)
var targetRole = Role.GetRole(target)?.RoleType;

var canKill = target.Data.IsImpostor || role != null &&
targetRole == RoleEnum.Glitch ||
targetRole == RoleEnum.Jester && CustomGameOptions.SheriffKillsJester ||
targetRole == RoleEnum.Arsonist && CustomGameOptions.SheriffKillsArsonist;
if (canKill)
{
if (CustomGameOptions.SheriffKillOther)
Utils.RpcMurderPlayer(PlayerControl.LocalPlayer, role.ClosestPlayer);
Utils.RpcMurderPlayer(PlayerControl.LocalPlayer, PlayerControl.LocalPlayer);
Utils.RpcMurderPlayer(PlayerControl.LocalPlayer, target);
}
else
{
Utils.RpcMurderPlayer(PlayerControl.LocalPlayer, role.ClosestPlayer);
if (CustomGameOptions.SheriffKillOther)
Utils.RpcMurderPlayer(PlayerControl.LocalPlayer, target);
Utils.RpcMurderPlayer(PlayerControl.LocalPlayer, PlayerControl.LocalPlayer);
}

role.LastKilled = DateTime.UtcNow;

return false;
Expand Down
1 change: 0 additions & 1 deletion source/Patches/CustomGameOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public static class CustomGameOptions
public static bool ShowSheriff => Generate.ShowSheriff.Get();
public static bool SheriffKillOther => Generate.SheriffKillOther.Get();
public static bool SheriffKillsJester => Generate.SheriffKillsJester.Get();
public static bool SheriffKillsGlitch => Generate.SheriffKillsGlitch.Get();
public static bool SheriffKillsArsonist => Generate.SheriffKillsArsonist.Get();
public static float SheriffKillCd => Generate.SheriffKillCd.Get();
public static int MayorVoteBank => (int) Generate.MayorVoteBank.Get();
Expand Down
3 changes: 0 additions & 3 deletions source/Patches/CustomOption/Generate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ public class Generate
public static CustomToggleOption ShowSheriff;
public static CustomToggleOption SheriffKillOther;
public static CustomToggleOption SheriffKillsJester;
public static CustomToggleOption SheriffKillsGlitch;
public static CustomToggleOption SheriffKillsArsonist;
public static CustomNumberOption SheriffKillCd;
public static CustomToggleOption SheriffBodyReport;
Expand Down Expand Up @@ -294,8 +293,6 @@ public static void GenerateAll()

SheriffKillsJester =
new CustomToggleOption(num++, "Sheriff Kills Jester", false);
SheriffKillsGlitch =
new CustomToggleOption(num++, "Sheriff Kills The Glitch", false);
SheriffKillsArsonist =
new CustomToggleOption(num++, "Sheriff Kills Arsonist", false);

Expand Down
2 changes: 1 addition & 1 deletion source/Patches/PingTrackerUpdate.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using HarmonyLib;
using HarmonyLib;
using TownOfUs.CustomHats;
using UnityEngine;

Expand Down
2 changes: 1 addition & 1 deletion source/Patches/VersionShowerUpdate.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using HarmonyLib;
using HarmonyLib;

namespace TownOfUs
{
Expand Down
3 changes: 1 addition & 2 deletions source/TownOfUs.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Linq;
using System.Net;
using System.Net.Sockets;
Expand All @@ -25,7 +25,6 @@ namespace TownOfUs
public class TownOfUs : BasePlugin
{
public const string Id = "com.slushiegoose.townofus";

public static Sprite JanitorClean;
public static Sprite EngineerFix;
public static Sprite SwapperSwitch;
Expand Down

0 comments on commit 465ab0e

Please sign in to comment.