Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
SpexGH committed Feb 3, 2024
1 parent 3bf86a4 commit 7f5aa21
Show file tree
Hide file tree
Showing 13 changed files with 58 additions and 28 deletions.
6 changes: 4 additions & 2 deletions TheOtherRoles/Buttons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1294,7 +1294,8 @@ public static void createButtonsPostfix(HudManager __instance) {
return Jackal.currentTarget && CachedPlayer.LocalPlayer.PlayerControl.CanMove; },
() => { jackalKillButton.Timer = jackalKillButton.MaxTimer;},
__instance.KillButton.graphic.sprite,
CustomButton.ButtonPositions.upperRowRight,
//CustomButton.ButtonPositions.upperRowRight,
CustomButton.ButtonPositions.upperRowCenter,
__instance,
KeyCode.Q
);
Expand Down Expand Up @@ -1340,7 +1341,8 @@ public static void createButtonsPostfix(HudManager __instance) {
return Sidekick.currentTarget && CachedPlayer.LocalPlayer.PlayerControl.CanMove; },
() => { sidekickKillButton.Timer = sidekickKillButton.MaxTimer;},
__instance.KillButton.graphic.sprite,
CustomButton.ButtonPositions.upperRowRight,
//CustomButton.ButtonPositions.upperRowRight,
CustomButton.ButtonPositions.upperRowCenter,
__instance,
KeyCode.Q
);
Expand Down
4 changes: 2 additions & 2 deletions TheOtherRoles/CustomOptionHolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ public class CustomOptionHolder {
public static CustomOption enableCamoComms;

public static CustomOption restrictDevices;
public static CustomOption restrictAdmin;
//public static CustomOption restrictAdmin;
public static CustomOption restrictCameras;
public static CustomOption restrictVents;

Expand Down Expand Up @@ -1046,7 +1046,7 @@ public static void Load() {
enableCamoComms = CustomOption.Create(1105, Types.General, "Enable Camouflage Comms", false, null, false);
disableMedbayWalk = CustomOption.Create(8847, Types.General, "Disable MedBay Animations", false, null, false);
restrictDevices = CustomOption.Create(1101, Types.General, "Restrict Map Information", new string[] {"Off", "Per Round", "Per Game"}, null, false);
restrictAdmin = CustomOption.Create(1102, Types.General, "Restrict Admin Table", 30f, 0f, 600f, 5f, restrictDevices);
//restrictAdmin = CustomOption.Create(1102, Types.General, "Restrict Admin Table", 30f, 0f, 600f, 5f, restrictDevices);
restrictCameras = CustomOption.Create(1103, Types.General, "Restrict Cameras", 30f, 0f, 600f, 5f, restrictDevices);
restrictVents = CustomOption.Create(1104, Types.General, "Restrict Vitals", 30f, 0f, 600f, 5f, restrictDevices);
disableCamsRound1 = CustomOption.Create(8834, Types.General, "No Cameras First Round", false, null, false);
Expand Down
4 changes: 3 additions & 1 deletion TheOtherRoles/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ public static bool hidePlayerName(PlayerControl source, PlayerControl target) {
if (Patches.SurveillanceMinigamePatch.nightVisionIsActive) return true;
else if (Ninja.isInvisble && Ninja.ninja == target) return true;
else if (Jackal.isInvisable && Jackal.jackal == target) return true;
else if (TORMapOptions.hideOutOfSightNametags && PhysicsHelpers.AnythingBetween(localPlayer.GetTruePosition(), target.GetTruePosition(), Constants.ShadowMask, false)) return true;
else if (TORMapOptions.hideOutOfSightNametags && gameStarted && !source.Data.IsDead && PhysicsHelpers.AnythingBetween(localPlayer.GetTruePosition(), target.GetTruePosition(), Constants.ShadowMask, false)) return true;
/*
{
float num = (isLightsActive() ? 2f : 1.25f);
Expand Down Expand Up @@ -757,6 +757,8 @@ public static void checkWatchFlash(PlayerControl target) {

public static bool roleCanUseVents(this PlayerControl player) {
bool roleCouldUse = false;
if (player.inVent) //test
return true;
if (Engineer.engineer != null && Engineer.engineer == player)
roleCouldUse = true;
else if (Werewolf.canUseVents && Werewolf.werewolf != null && Werewolf.werewolf == player)
Expand Down
2 changes: 1 addition & 1 deletion 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.01";
public const string VersionString = "1.3.2";
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
12 changes: 6 additions & 6 deletions TheOtherRoles/MapOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ static class TORMapOptions {
public static bool ShowVentsOnMap = true;
public static bool disableMedscanWalking = false;
public static int restrictDevices = 0;
public static float restrictAdminTime = 600f;
public static float restrictAdminTimeMax = 600f;
// public static float restrictAdminTime = 600f;
//public static float restrictAdminTimeMax = 600f;
public static float restrictCamerasTime = 600f;
public static float restrictCamerasTimeMax = 600f;
public static float restrictVitalsTime = 600f;
Expand Down Expand Up @@ -67,7 +67,7 @@ public static void clearAndReloadMapOptions() {
impostorSeeRoles = CustomOptionHolder.impostorSeeRoles.getBool();
transparentTasks = CustomOptionHolder.transparentTasks.getBool();
restrictDevices = CustomOptionHolder.restrictDevices.getSelection();
restrictAdminTime = restrictAdminTimeMax = CustomOptionHolder.restrictAdmin.getFloat();
//restrictAdminTime = restrictAdminTimeMax = CustomOptionHolder.restrictAdmin.getFloat();
restrictCamerasTime = restrictCamerasTimeMax = CustomOptionHolder.restrictCameras.getFloat();
restrictVitalsTime = restrictVitalsTimeMax = CustomOptionHolder.restrictVents.getFloat();
disableCamsRoundOne = CustomOptionHolder.disableCamsRound1.getBool();
Expand All @@ -92,14 +92,14 @@ public static void reloadPluginOptions() {
//Patches.ShouldAlwaysHorseAround.isHorseMode = TheOtherRolesPlugin.EnableHorseMode.Value;
}
public static void resetDeviceTimes() {
restrictAdminTime = restrictAdminTimeMax;
//restrictAdminTime = restrictAdminTimeMax;
restrictCamerasTime = restrictCamerasTimeMax;
restrictVitalsTime = restrictVitalsTimeMax;
}

public static bool canUseAdmin { get { return restrictDevices == 0 || restrictAdminTime > 0f || CachedPlayer.LocalPlayer.PlayerControl == Hacker.hacker || CachedPlayer.LocalPlayer.Data.IsDead; }}
// public static bool canUseAdmin { get { return restrictDevices == 0 || restrictAdminTime > 0f || CachedPlayer.LocalPlayer.PlayerControl == Hacker.hacker || CachedPlayer.LocalPlayer.Data.IsDead; }}

public static bool couldUseAdmin { get { return restrictDevices == 0 || restrictAdminTimeMax > 0f || CachedPlayer.LocalPlayer.PlayerControl == Hacker.hacker || CachedPlayer.LocalPlayer.Data.IsDead; }}
//public static bool couldUseAdmin { get { return restrictDevices == 0 || restrictAdminTimeMax > 0f || CachedPlayer.LocalPlayer.PlayerControl == Hacker.hacker || CachedPlayer.LocalPlayer.Data.IsDead; }}

public static bool canUseCameras {get { return restrictDevices == 0 || restrictCamerasTime > 0f || CachedPlayer.LocalPlayer.PlayerControl == Hacker.hacker || CachedPlayer.LocalPlayer.Data.IsDead; }}

Expand Down
3 changes: 2 additions & 1 deletion TheOtherRoles/Patches/AdminPatch.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using HarmonyLib;
/*using HarmonyLib;
using Hazel;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -280,3 +280,4 @@ static void Postfix(CounterArea __instance)
}
}
}
*/
4 changes: 2 additions & 2 deletions TheOtherRoles/Patches/MeetingPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -467,8 +467,8 @@ static void guesserOnClick(int buttonTarget, MeetingHud __instance) {
button.GetComponent<SpriteRenderer>().sprite = ShipStatus.Instance.CosmeticsCache.GetNameplate("nameplate_NoPlate").Image;
buttons.Add(button);
int row = i/5, col = i%5;
buttonParent.localPosition = new Vector3(-3.47f + 1.75f * col, 1.5f - 0.45f * row, -5);
buttonParent.localScale = new Vector3(0.55f, 0.55f, 1f);
buttonParent.localPosition = new Vector3(-3.47f + 1.55f * col, 1.5f - 0.35f * row, -5);
buttonParent.localScale = new Vector3(0.45f, 0.45f, 1f);
label.text = Helpers.cs(roleInfo.color, roleInfo.name);
label.alignment = TMPro.TextAlignmentOptions.Center;
label.transform.localPosition = new Vector3(0, 0, label.transform.localPosition.z);
Expand Down
17 changes: 12 additions & 5 deletions TheOtherRoles/Patches/PlayerControlPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ static void setBasePlayerOutlines() {
bool isMorphedMorphling = target == Morphling.morphling && Morphling.morphTarget != null && Morphling.morphTimer > 0f;
bool hasVisibleShield = false;
Color color = Medic.shieldedColor;
if (Camouflager.camouflageTimer <= 0f && !Helpers.MushroomSabotageActive() && Medic.shielded != null && ((target == Medic.shielded && !isMorphedMorphling) || (isMorphedMorphling && Morphling.morphTarget == Medic.shielded))) {
if (!Helpers.isCamoComms() && Camouflager.camouflageTimer <= 0f && !Helpers.MushroomSabotageActive() && Medic.shielded != null && ((target == Medic.shielded && !isMorphedMorphling) || (isMorphedMorphling && Morphling.morphTarget == Medic.shielded))) {
hasVisibleShield = Medic.showShielded == 0 || Helpers.shouldShowGhostInfo() // Everyone or Ghost info
|| (Medic.showShielded == 1 && (CachedPlayer.LocalPlayer.PlayerControl == Medic.shielded || CachedPlayer.LocalPlayer.PlayerControl == Medic.medic)) // Shielded + Medic
|| (Medic.showShielded == 2 && CachedPlayer.LocalPlayer.PlayerControl == Medic.medic); // Medic only
Expand All @@ -82,7 +82,7 @@ static void setBasePlayerOutlines() {
color = BodyGuard.color;
}

if (Camouflager.camouflageTimer <= 0f && !Helpers.MushroomSabotageActive() && TORMapOptions.firstKillPlayer != null && TORMapOptions.shieldFirstKill && ((target == TORMapOptions.firstKillPlayer && !isMorphedMorphling) || (isMorphedMorphling && Morphling.morphTarget == TORMapOptions.firstKillPlayer))) {
if (!Helpers.isCamoComms() && Camouflager.camouflageTimer <= 0f && !Helpers.MushroomSabotageActive() && TORMapOptions.firstKillPlayer != null && TORMapOptions.shieldFirstKill && ((target == TORMapOptions.firstKillPlayer && !isMorphedMorphling) || (isMorphedMorphling && Morphling.morphTarget == TORMapOptions.firstKillPlayer))) {
hasVisibleShield = true;
color = Color.blue;
}
Expand Down Expand Up @@ -410,7 +410,13 @@ static void swooperUpdate()
RPCProcedure.setSwoop(Jackal.jackal.PlayerId, byte.MaxValue);
}
if (Jackal.jackal != null && Jackal.canSwoop){
Swooper.swooper = Jackal.jackal;
{
MessageWriter invisibleWriter = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.SetSwooper, Hazel.SendOption.Reliable, -1);
invisibleWriter.Write(Jackal.jackal.PlayerId);
invisibleWriter.Write(byte.MaxValue);
AmongUsClient.Instance.FinishRpcImmediately(invisibleWriter);
RPCProcedure.setSwooper(Jackal.jackal.PlayerId);
}
}
}

Expand Down Expand Up @@ -515,7 +521,7 @@ public static void playerSizeUpdate(PlayerControl p) {
collider.offset = Mini.defaultColliderOffset * Vector2.down;

// Set adapted player size to Mini and Morphling
if (Mini.mini == null || Camouflager.camouflageTimer > 0f || Helpers.MushroomSabotageActive() || Mini.mini == Morphling.morphling && Morphling.morphTimer > 0) return;
if (Mini.mini == null || Helpers.isCamoComms() || Camouflager.camouflageTimer > 0f || Helpers.MushroomSabotageActive() || Mini.mini == Morphling.morphling && Morphling.morphTimer > 0) return;

float growingProgress = Mini.growingProgress();
float scale = growingProgress * 0.35f + 0.35f;
Expand Down Expand Up @@ -958,6 +964,7 @@ static void morphlingAndCamouflagerUpdate() {
// Camouflage reset and set Morphling look if necessary
if (oldCamouflageTimer > 0f && Camouflager.camouflageTimer <= 0f) {
Camouflager.resetCamouflage();
Helpers.camoReset();
if (Morphling.morphTimer > 0f && Morphling.morphling != null && Morphling.morphTarget != null) {
PlayerControl target = Morphling.morphTarget;
Morphling.morphling.setLook(target.Data.PlayerName, target.Data.DefaultOutfit.ColorId, target.Data.DefaultOutfit.HatId, target.Data.DefaultOutfit.VisorId, target.Data.DefaultOutfit.SkinId, target.Data.DefaultOutfit.PetId);
Expand Down Expand Up @@ -1374,7 +1381,7 @@ public static void Postfix(PlayerControl __instance) {
class PlayerPhysicsWalkPlayerToPatch {
private static Vector2 offset = Vector2.zero;
public static void Prefix(PlayerPhysics __instance) {
bool correctOffset = Camouflager.camouflageTimer <= 0f && !Helpers.MushroomSabotageActive() && (__instance.myPlayer == Mini.mini || (Morphling.morphling != null && __instance.myPlayer == Morphling.morphling && Morphling.morphTarget == Mini.mini && Morphling.morphTimer > 0f));
bool correctOffset = !Helpers.isCamoComms() && Camouflager.camouflageTimer <= 0f && !Helpers.MushroomSabotageActive() && (__instance.myPlayer == Mini.mini || (Morphling.morphling != null && __instance.myPlayer == Morphling.morphling && Morphling.morphTarget == Mini.mini && Morphling.morphTimer > 0f));
correctOffset = correctOffset && !(Mini.mini == Morphling.morphling && Morphling.morphTimer > 0f);
if (correctOffset) {
float currentScaling = (Mini.growingProgress() + 1) * 0.5f;
Expand Down
2 changes: 1 addition & 1 deletion TheOtherRoles/Patches/UpdatePatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ static void timerUpdate() {
}

public static void miniUpdate() {
if (Mini.mini == null || Camouflager.camouflageTimer > 0f || Helpers.MushroomSabotageActive() || Mini.mini == Morphling.morphling && Morphling.morphTimer > 0f || Mini.mini == Ninja.ninja && Ninja.isInvisble || SurveillanceMinigamePatch.nightVisionIsActive || Mini.mini == Jackal.jackal && Jackal.isInvisable || Helpers.isCamoComms()) return;
if (Mini.mini == null || Camouflager.camouflageTimer > 0f || Helpers.MushroomSabotageActive() || Mini.mini == Morphling.morphling && Morphling.morphTimer > 0f || Mini.mini == Ninja.ninja && Ninja.isInvisble || SurveillanceMinigamePatch.nightVisionIsActive || Mini.mini == Jackal.jackal && Jackal.isInvisable || Helpers.isActiveCamoComms()) return;

float growingProgress = Mini.growingProgress();
float scale = growingProgress * 0.35f + 0.35f;
Expand Down
3 changes: 3 additions & 0 deletions TheOtherRoles/Patches/UsablesPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ static void Postfix(VentButton __instance) {
__instance.graphic.sprite = isSpecialVent ? Trickster.getTricksterVentButtonSprite() : defaultVentSprite;
__instance.buttonLabelText.enabled = !isSpecialVent;
}
if (Tunneler.tunneler != null && Tunneler.tunneler == CachedPlayer.LocalPlayer.PlayerControl) {
__instance.graphic.transform.localPosition = new Vector3(0, 2, 0);
}
}
}

Expand Down
26 changes: 20 additions & 6 deletions TheOtherRoles/RPC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ enum CustomRPC
SwapperSwap,
MorphlingMorph,
CamouflagerCamouflage,
CamoComms,
//CamoComms,
TrackerUsedTracker,
VampireSetBitten,
PlaceGarlic,
Expand Down Expand Up @@ -197,6 +197,7 @@ enum CustomRPC
SetTiebreak,
SetInvisibleGen,
SetSwoop,
SetSwooper,
SetInvisible,
ThiefStealsRole,
SetTrap,
Expand Down Expand Up @@ -1401,7 +1402,7 @@ public static void camouflagerCamouflage(byte setTimer) {
foreach (PlayerControl player in CachedPlayer.AllPlayers)
player.setLook("", 6, "", "", "", "");
}

/*
public static void camoComms() {
if (!Helpers.isCamoComms()) return;
Expand All @@ -1411,6 +1412,7 @@ public static void camoComms() {
player.setLook("", 6, "", "", "", "");
}
*/

public static void vampireSetBitten(byte targetId, byte performReset) {
if (performReset != 0) {
Expand Down Expand Up @@ -1897,6 +1899,12 @@ public static void setSwoop(byte playerId, byte flag) {
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 @@ -2119,11 +2127,12 @@ public static void guesserShoot(byte killerId, byte dyingTargetId, byte guessedT
FastDestroyableSingleton<UnityTelemetry>.Instance.SendWho();
}
}

/*
public static void useAdminTime(float time)
{
TORMapOptions.restrictAdminTime -= time;
}
*/

public static void useCameraTime(float time)
{
Expand Down Expand Up @@ -2589,9 +2598,10 @@ static void Postfix([HarmonyArgument(0)]byte callId, [HarmonyArgument(1)]Message
case (byte)CustomRPC.EngineerUsedRepair:
RPCProcedure.engineerUsedRepair();
break;
/*
case (byte)CustomRPC.UseAdminTime:
RPCProcedure.useAdminTime(reader.ReadSingle());
break;
break;*/
case (byte)CustomRPC.UseCameraTime:
RPCProcedure.useCameraTime(reader.ReadSingle());
break;
Expand Down Expand Up @@ -2657,10 +2667,10 @@ static void Postfix([HarmonyArgument(0)]byte callId, [HarmonyArgument(1)]Message
case (byte)CustomRPC.CamouflagerCamouflage:
byte setTimer = reader.ReadByte();
RPCProcedure.camouflagerCamouflage(setTimer);
break;
break;/*
case (byte)CustomRPC.CamoComms:
RPCProcedure.camoComms();
break;
break;*/
case (byte)CustomRPC.VampireSetBitten:
byte bittenId = reader.ReadByte();
byte reset = reader.ReadByte();
Expand Down Expand Up @@ -2791,6 +2801,10 @@ static void Postfix([HarmonyArgument(0)]byte callId, [HarmonyArgument(1)]Message
byte invisibleFlag2 = reader.ReadByte();
RPCProcedure.setSwoop(invisiblePlayer2, invisibleFlag2);
break;
case (byte)CustomRPC.SetSwooper:
byte jackalPlayer2 = reader.ReadByte();
RPCProcedure.setSwooper(jackalPlayer2);
break;
case (byte)CustomRPC.SetInvisibleGen:
byte invisiblePlayer3 = reader.ReadByte();
byte invisibleFlag3 = reader.ReadByte();
Expand Down
1 change: 1 addition & 0 deletions TheOtherRoles/TheOtherRoles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,7 @@ public static void resetCamouflage() {
if (p == Ninja.ninja && Ninja.isInvisble || p == Jackal.jackal && Jackal.isInvisable)
continue;
p.setDefaultLook();
Camouflager.camoComms = 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.01</Version>
<Version>1.3.2</Version>
<Description>TheOtherUs</Description>
<Authors>Spex</Authors>
<LangVersion>latest</LangVersion>
Expand Down

0 comments on commit 7f5aa21

Please sign in to comment.