Skip to content

Commit

Permalink
more bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
SpexGH committed Feb 4, 2024
1 parent 7f5aa21 commit a9c23d7
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 23 deletions.
2 changes: 1 addition & 1 deletion TheOtherRoles/CustomOptionHolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ public class CustomOptionHolder {
public static CustomOption modifierRadar;

public static CustomOption modifierSlueth;
public static CustomOption modifierSwooper;
//public static CustomOption modifierSwooper;

public static CustomOption modifierCursed;

Expand Down
21 changes: 15 additions & 6 deletions TheOtherRoles/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace TheOtherRoles
public class TheOtherRolesPlugin : BasePlugin
{
public const string Id = "me.eisbison.theotherroles";
public const string VersionString = "1.3.2";
public const string VersionString = "1.3.3";
public static uint betaDays = 0; // amount of days for the build to be usable (0 for infinite!)

public static Version Version = Version.Parse(VersionString);
Expand Down Expand Up @@ -165,12 +165,12 @@ private static void Prefix() {
[HarmonyPatch(typeof(KeyboardJoystick), nameof(KeyboardJoystick.Update))]
public static class DebugManager
{
private static readonly string passwordHash = "d1f51dfdfd8d38027fd2ca9dfeb299399b5bdee58e6c0b3b5e9a45cd4e502848";
//private static readonly string passwordHash = "d1f51dfdfd8d38027fd2ca9dfeb299399b5bdee58e6c0b3b5e9a45cd4e502848";
private static readonly System.Random random = new System.Random((int)DateTime.Now.Ticks);
private static List<PlayerControl> bots = new List<PlayerControl>();

public static void Postfix(KeyboardJoystick __instance)
{
{/*
// Check if debug mode is active.
StringBuilder builder = new StringBuilder();
SHA256 sha = SHA256Managed.Create();
Expand All @@ -180,10 +180,10 @@ public static void Postfix(KeyboardJoystick __instance)
}
string enteredHash = builder.ToString();
if (enteredHash != passwordHash) return;

*/

// Spawn dummys
if (Input.GetKeyDown(KeyCode.F)) {
if (AmongUsClient.Instance.AmHost && Input.GetKeyDown(KeyCode.F) && Input.GetKey(KeyCode.RightShift)) {
var playerControl = UnityEngine.Object.Instantiate(AmongUsClient.Instance.PlayerPrefab);
var i = playerControl.PlayerId = (byte) GameData.Instance.GetAvailableId();

Expand All @@ -200,11 +200,20 @@ public static void Postfix(KeyboardJoystick __instance)
}

// Terminate round
if(Input.GetKeyDown(KeyCode.L)) {
if(AmongUsClient.Instance.AmHost && Helpers.gameStarted && Input.GetKeyDown(KeyCode.Return) && Input.GetKey(KeyCode.L) && Input.GetKey(KeyCode.LeftShift)) {
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.ForceEnd, Hazel.SendOption.Reliable, -1);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCProcedure.forceEnd();
}

if (Input.GetKeyDown(KeyCode.Return) && Input.GetKey(KeyCode.M) && Input.GetKey(KeyCode.LeftShift) && MeetingHud.Instance)
{
MeetingHud.Instance.RpcClose();
foreach (var pc in PlayerControl.AllPlayerControls)
{
if (pc == null || pc.Data.IsDead || pc.Data.Disconnected) continue;
}
}
}

public static string RandomString(int length)
Expand Down
6 changes: 3 additions & 3 deletions TheOtherRoles/Patches/PlayerControlPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ static void swooperUpdate()
invisibleWriter.Write(byte.MaxValue);
AmongUsClient.Instance.FinishRpcImmediately(invisibleWriter);
RPCProcedure.setSwoop(Jackal.jackal.PlayerId, byte.MaxValue);
}
}/*
if (Jackal.jackal != null && Jackal.canSwoop){
{
MessageWriter invisibleWriter = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.SetSwooper, Hazel.SendOption.Reliable, -1);
Expand All @@ -417,7 +417,7 @@ static void swooperUpdate()
AmongUsClient.Instance.FinishRpcImmediately(invisibleWriter);
RPCProcedure.setSwooper(Jackal.jackal.PlayerId);
}
}
}*/
}

static void ninjaUpdate()
Expand Down Expand Up @@ -589,7 +589,7 @@ public static void updatePlayerInfo() {

string playerInfoText = "";
string meetingInfoText = "";
if (p == CachedPlayer.LocalPlayer.PlayerControl || (TORMapOptions.impostorSeeRoles && Spy.spy == null && CachedPlayer.LocalPlayer.Data.Role.IsImpostor && !CachedPlayer.LocalPlayer.Data.IsDead && p == (p.Data.Role.IsImpostor && !p.Data.IsDead))) {
if (p == CachedPlayer.LocalPlayer.PlayerControl || (TORMapOptions.impostorSeeRoles && Spy.spy == null && CachedPlayer.LocalPlayer.Data.Role.IsImpostor && !CachedPlayer.LocalPlayer.Data.IsDead && p == (p.Data.Role.IsImpostor && !p.Data.IsDead))) {
if (p.Data.IsDead) roleNames = roleText;
playerInfoText = $"{roleNames}";
if (p == Swapper.swapper) playerInfoText = $"{roleNames}" + Helpers.cs(Swapper.color, $" ({Swapper.charges})");
Expand Down
20 changes: 20 additions & 0 deletions TheOtherRoles/Patches/UsablesPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,26 @@ static void Postfix() {
}
}

[HarmonyPatch(typeof(SabotageButton), nameof(SabotageButton.DoClick))]
public static class SabotageButtonDoClickPatch {
public static bool Prefix(SabotageButton __instance) {
// The sabotage button behaves just fine if it's a regular impostor
if (PlayerControl.LocalPlayer.Data.Role.TeamType == RoleTeamTypes.Impostor) return true;
//(Il2CppSystem.Action<MapBehaviour>)((m) => { m.ShowSabotageMap(); } );
// MapOptions options = DestroyableSingleton<HudManager>.Instance;
// DestroyableSingleton<HudManager>.Instance.ToggleMapVisible((Il2CppSystem.Action<MapBehaviour>)((m) => { m.ShowSabotageMap(); }));
//MapOptionsTor.Mode = MapOptionsTor.Modes.Sabotage;
//DestroyableSingleton<HudManager>.Instance.ToggleMapVisible(DestroyableSingleton<MapOptions>.Instance.Modes.Sabotage);

DestroyableSingleton<HudManager>.Instance.ToggleMapVisible(new MapOptions
{
Mode = MapOptions.Modes.Sabotage
});

return false;
}
}

[HarmonyPatch(typeof(ReportButton), nameof(ReportButton.DoClick))]
class ReportButtonDoClickPatch {
public static bool Prefix(ReportButton __instance) {
Expand Down
22 changes: 12 additions & 10 deletions TheOtherRoles/RPC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ enum CustomRPC
SetTiebreak,
SetInvisibleGen,
SetSwoop,
SetSwooper,
// SetSwooper,
SetInvisible,
ThiefStealsRole,
SetTrap,
Expand Down Expand Up @@ -491,6 +491,9 @@ public static void setModifier(byte modifierId, byte playerId, byte flag) {
case RoleId.EvilGuesser:
Guesser.evilGuesser.Add(player);
break;
case RoleId.Swooper:
Swooper.swooper = player;
break;
case RoleId.Bait:
Bait.bait.Add(player);
break;
Expand All @@ -516,9 +519,7 @@ public static void setModifier(byte modifierId, byte playerId, byte flag) {
case RoleId.Slueth:
Slueth.slueth = player;
break;
case RoleId.Swooper:
Swooper.swooper = player;
break;

case RoleId.Cursed:
Cursed.cursed = player;
break;
Expand Down Expand Up @@ -1214,7 +1215,7 @@ public static void mimicMimicRole(byte targetId) {
break;

case RoleId.NiceGuesser:
if (Amnisiac.resetRole) Guesser.clearAndReload();
if (Amnisiac.resetRole) //Guesser.clearAndReload();
Guesser.niceGuesser = Mimic.mimic;
Mimic.hasMimic = true;
break;
Expand Down Expand Up @@ -1496,6 +1497,7 @@ public static void sidekickPromotes() {
Jackal.wasTeamRed = Sidekick.wasTeamRed;
Jackal.wasSpy = Sidekick.wasSpy;
Jackal.wasImpostor = Sidekick.wasImpostor;
Jackal.canSwoop = false;
Sidekick.clearAndReload();
return;
}
Expand All @@ -1507,6 +1509,7 @@ public static void erasePlayerRoles(byte playerId, bool ignoreModifier = true) {

// Crewmate roles
if (Guesser.evilGuesser.Any(x => x.PlayerId == player.PlayerId)) Guesser.evilGuesser.RemoveAll(x => x.PlayerId == player.PlayerId);
if (player == Swooper.swooper) Swooper.clearAndReload();
if (player == Mayor.mayor) Mayor.clearAndReload();
if (player == Portalmaker.portalmaker) Portalmaker.clearAndReload();
if (player == Engineer.engineer) Engineer.clearAndReload();
Expand Down Expand Up @@ -1593,7 +1596,6 @@ public static void erasePlayerRoles(byte playerId, bool ignoreModifier = true) {
if (player == Indomitable.indomitable) Indomitable.clearAndReload();
if (player == Tunneler.tunneler) Tunneler.clearAndReload();
if (player == Slueth.slueth) Slueth.clearAndReload();
//if (player == Swooper.swooper) Swooper.clearAndReload();
if (player == Blind.blind) Blind.clearAndReload();
if (player == Cursed.cursed) Cursed.clearAndReload();
if (Vip.vip.Any(x => x.PlayerId == player.PlayerId)) Vip.vip.RemoveAll(x => x.PlayerId == player.PlayerId);
Expand Down Expand Up @@ -1898,13 +1900,13 @@ public static void setSwoop(byte playerId, byte flag) {
Jackal.swoopTimer = Jackal.duration;
Jackal.isInvisable = true;
}

/*
public static void setSwooper(byte playerId) {
PlayerControl target = Helpers.playerById(playerId);
if (target == null) return;
Swooper.swooper = Jackal.jackal;
}

*/

public static void setInvisibleGen(byte playerId, byte flag)
{
Expand Down Expand Up @@ -2800,11 +2802,11 @@ static void Postfix([HarmonyArgument(0)]byte callId, [HarmonyArgument(1)]Message
byte invisiblePlayer2 = reader.ReadByte();
byte invisibleFlag2 = reader.ReadByte();
RPCProcedure.setSwoop(invisiblePlayer2, invisibleFlag2);
break;
break; /*
case (byte)CustomRPC.SetSwooper:
byte jackalPlayer2 = reader.ReadByte();
RPCProcedure.setSwooper(jackalPlayer2);
break;
break; */
case (byte)CustomRPC.SetInvisibleGen:
byte invisiblePlayer3 = reader.ReadByte();
byte invisibleFlag3 = reader.ReadByte();
Expand Down
8 changes: 6 additions & 2 deletions TheOtherRoles/RoleInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public RoleInfo(string name, Color color, string introDescription, string shortD
vip,
indomitable,
slueth,
swooper,
//swooper,
blind,
watcher,
radar,
Expand Down Expand Up @@ -355,7 +355,11 @@ public static String GetRolesString(PlayerControl p, bool useColors, bool showMo
if (p == Arsonist.arsonist)
roleName = roleName + Helpers.cs(Arsonist.color, $" ({CachedPlayer.AllPlayers.Count(x => { return x.PlayerControl != Arsonist.arsonist && !x.Data.IsDead && !x.Data.Disconnected && !Arsonist.dousedPlayers.Any(y => y.PlayerId == x.PlayerId); })} left)");
if (p == Jackal.fakeSidekick)
roleName = Helpers.cs(Sidekick.color, $" (fake SK)") + roleName;
roleName = Helpers.cs(Sidekick.color, $" (fake SK) ") + roleName;
/*
if (p == Jackal.jackal && Jackal.canSwoop)
roleName = Helpers.cs(Swooper.color, $" (Swooper) ") + roleName;
*/

// Death Reason on Ghosts
if (p.Data.IsDead) {
Expand Down
2 changes: 2 additions & 0 deletions TheOtherRoles/TheOtherRoles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1208,6 +1208,7 @@ public static class Jackal {
public static bool wasSpy;
public static float chanceSwoop = 0f;
public static bool canSwoop = false;


public static Sprite getSidekickButtonSprite() {
if (buttonSprite) return buttonSprite;
Expand Down Expand Up @@ -1257,6 +1258,7 @@ public static void clearAndReload() {
else {
canSwoop = false;
}


}

Expand Down
2 changes: 1 addition & 1 deletion TheOtherRoles/TheOtherRoles.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Version>1.3.2</Version>
<Version>1.3.3</Version>
<Description>TheOtherUs</Description>
<Authors>Spex</Authors>
<LangVersion>latest</LangVersion>
Expand Down

0 comments on commit a9c23d7

Please sign in to comment.