Skip to content

Commit

Permalink
Update v1.1.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
mxyx0412 committed Feb 9, 2025
1 parent 16767bd commit 95a14a0
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 78 deletions.
Binary file modified Strings.xlsx
Binary file not shown.
5 changes: 3 additions & 2 deletions TheOtherRoles/Buttons/CustomButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,10 @@ public static void MeetingEndedUpdate()
}
}

public static void ResetAllCooldowns(float Time = -1)
public static void ResetAllCooldowns(float Time = -1, PlayerControl target = null)
{
var player = target ?? PlayerControl.LocalPlayer;
var time = Time == -1 ? ModOption.KillCooddown : Time;
PlayerControl.LocalPlayer.killTimer = time - 0.6f;
foreach (var t in buttons)
{
var maxTime = Time == -1 ? t.MaxTimer : Time;
Expand All @@ -149,6 +149,7 @@ public static void ResetAllCooldowns(float Time = -1)
Error($"NullReferenceException from MeetingEndedUpdate().HasButton(), if theres only one warning its fine\n{e}", "CustomButton");
}
}
player.killTimer = time;
}

public static void resetKillButton(PlayerControl p, float time = -1)
Expand Down
12 changes: 4 additions & 8 deletions TheOtherRoles/Helper/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public static class Helpers
public static bool InGame => AmongUsClient.Instance != null && AmongUsClient.Instance.GameState == InnerNetClient.GameStates.Started;
public static bool IsCountDown => GameStartManager.InstanceExists && GameStartManager.Instance.startState == GameStartManager.StartingStates.Countdown;
public static bool InMeeting => InGame && MeetingHud.Instance;

public static bool ShowButtons => !(MapBehaviour.Instance && MapBehaviour.Instance.IsOpen) && !MeetingHud.Instance && !ExileController.Instance;
public static bool IsHideNSeek => GameOptionsManager.Instance.currentGameOptions.GameMode == GameModes.HideNSeek;
public static bool isSkeld => GameOptionsManager.Instance.CurrentGameOptions.MapId == 0;
public static bool isMira => GameOptionsManager.Instance.CurrentGameOptions.MapId == 1;
Expand All @@ -70,7 +72,6 @@ public static class Helpers

public static System.Random rnd => new(Guid.NewGuid().GetHashCode());

public static PlayerControl HostPlayer => GameData.Instance.GetHost().Object;
public static bool isUsingTransportation(this PlayerControl pc) => pc.inMovingPlat || pc.onLadder;


Expand Down Expand Up @@ -295,11 +296,6 @@ public static string teamString(PlayerControl player)
return killerTeam;
}

public static bool ShowButtons =>
!(MapBehaviour.Instance && MapBehaviour.Instance.IsOpen) &&
!MeetingHud.Instance &&
!ExileController.Instance;

public static void NoCheckStartMeeting(this PlayerControl reporter, GameData.PlayerInfo target, bool force = false)
{
if (InMeeting) return;
Expand Down Expand Up @@ -864,7 +860,7 @@ public static void shareGameVersion()
writer.Write((byte)Main.Version.Major);
writer.Write((byte)Main.Version.Minor);
writer.Write((byte)Main.Version.Build);
writer.Write(AmongUsClient.Instance.AmHost ? Patches.GameStartManagerPatch.timer : -1f);
writer.Write(AmongUsClient.Instance.AmHost ? GameStartManagerPatch.timer : -1f);
writer.WritePacked(AmongUsClient.Instance.ClientId);
writer.Write((byte)(Main.Version.Revision < 0 ? 0xFF : Main.Version.Revision));
writer.Write(Assembly.GetExecutingAssembly().ManifestModule.ModuleVersionId.ToByteArray());
Expand Down Expand Up @@ -1224,7 +1220,7 @@ public static MurderAttemptResult checkMuderAttempt(PlayerControl killer, Player

if (Survivor.Player != null && Survivor.Player.Contains(target) && Survivor.vestActive)
{
CustomButton.resetKillButton(killer, Survivor.vestResetCooldown);
CustomButton.ResetAllCooldowns(Survivor.vestResetCooldown, killer);
SoundEffectsManager.play("fail");
return MurderAttemptResult.SuppressKill;
}
Expand Down
2 changes: 1 addition & 1 deletion TheOtherRoles/Objects/Trap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class Trap

private static int instanceCounter;

private static ResourceSprite trapSprite = new("Trapper_Trap_Ingame.png", 300);
private static Sprite trapSprite = new ResourceSprite("Trapper_Trap_Ingame.png", 300);
private Arrow arrow = new(Color.blue);
private int neededCount = Trapper.trapCountToReveal;
public int instanceId;
Expand Down
7 changes: 4 additions & 3 deletions TheOtherRoles/Patches/ExileControllerPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,14 @@ public static void Postfix(ExileController __instance, [HarmonyArgument(0)] ref
break;
}
}
if (CustomOptionHolder.exiledShowTeamNum.GetBool() && player?.PlayerId != Jester.jester?.PlayerId)

if (CustomOptionHolder.exiledShowTeamNum.GetBool())
{
var Impostors = PlayerControl.AllPlayerControls.ToArray().Count(x => x.isImpostor() && x.IsAlive() && x.PlayerId != player.PlayerId);
var Neutrals = PlayerControl.AllPlayerControls.ToArray().Count(x => x.isNeutral() && x.IsAlive() && x.PlayerId != player.PlayerId);
__instance.ImpostorText.text =
$"\n{cs(getTeamColor(RoleType.Impostor), "伪装者阵营剩余 " + Impostors)}" +
$" | {cs(getTeamColor(RoleType.Neutral), "中立阵营剩余 " + Neutrals)}";
$"\n{cs(getTeamColor(RoleType.Impostor), "伪装者阵营剩余 ") + Impostors}" +
$" | {cs(getTeamColor(RoleType.Neutral), "中立阵营剩余 ") + Neutrals}";

}
}
Expand Down
2 changes: 2 additions & 0 deletions TheOtherRoles/Patches/PlayerControlPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1568,6 +1568,8 @@ public static void Postfix(PlayerControl __instance)
Akujo.otherLover(__instance)?.Revive();
}

CustomButton.ResetAllCooldowns(-1, __instance);

DeadBody[] array = Object.FindObjectsOfType<DeadBody>();
for (var i = 0; i < array.Length; i++)
{
Expand Down
108 changes: 48 additions & 60 deletions TheOtherRoles/Patches/UsablesPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
using AmongUs.GameOptions;
using PowerTools;
using Reactor.Utilities.Extensions;
using TheOtherRoles.Buttons;
using TheOtherRoles.Utilities;
using TMPro;
using UnityEngine;
using static TheOtherRoles.Buttons.HudManagerStartPatch;
using static TheOtherRoles.GameHistory;
using static TheOtherRoles.Options.ModOption;
using Object = UnityEngine.Object;
Expand Down Expand Up @@ -189,7 +189,7 @@ internal class VentButtonVisibilityPatch
{
private static void Postfix(HudManager __instance)
{
if (PlayerControl.LocalPlayer.AmOwner && ShowButtons)
if (PlayerControl.LocalPlayer?.AmOwner == true && ShowButtons)
{
__instance.ImpostorVentButton.Hide();
__instance.SabotageButton.Hide();
Expand Down Expand Up @@ -309,23 +309,17 @@ public static bool Prefix(KillButton __instance)
// Handle blank kill
if (res == MurderAttemptResult.BlankKill)
{
PlayerControl.LocalPlayer.killTimer =
GameOptionsManager.Instance.currentNormalGameOptions.KillCooldown;
PlayerControl.LocalPlayer.killTimer = GameOptionsManager.Instance.currentNormalGameOptions.KillCooldown;
if (PlayerControl.LocalPlayer == Cleaner.cleaner)
Cleaner.cleaner.killTimer = HudManagerStartPatch.cleanerCleanButton.Timer =
HudManagerStartPatch.cleanerCleanButton.MaxTimer;
Cleaner.cleaner.killTimer = cleanerCleanButton.Timer = cleanerCleanButton.MaxTimer;
else if (PlayerControl.LocalPlayer == Warlock.warlock)
Warlock.warlock.killTimer = HudManagerStartPatch.warlockCurseButton.Timer =
HudManagerStartPatch.warlockCurseButton.MaxTimer;
Warlock.warlock.killTimer = warlockCurseButton.Timer = warlockCurseButton.MaxTimer;
else if (PlayerControl.LocalPlayer == Mini.mini && Mini.mini.Data.Role.IsImpostor)
Mini.mini.SetKillTimer(GameOptionsManager.Instance.currentNormalGameOptions.KillCooldown *
(Mini.isGrownUp() ? 0.66f : 2f));
Mini.mini.SetKillTimer(GameOptionsManager.Instance.currentNormalGameOptions.KillCooldown * (Mini.isGrownUp() ? 0.66f : 2f));
else if (PlayerControl.LocalPlayer == Witch.witch)
Witch.witch.killTimer = HudManagerStartPatch.witchSpellButton.Timer =
HudManagerStartPatch.witchSpellButton.MaxTimer;
Witch.witch.killTimer = witchSpellButton.Timer = witchSpellButton.MaxTimer;
else if (PlayerControl.LocalPlayer == Ninja.ninja)
Ninja.ninja.killTimer = HudManagerStartPatch.ninjaButton.Timer =
HudManagerStartPatch.ninjaButton.MaxTimer;
Ninja.ninja.killTimer = ninjaButton.Timer = ninjaButton.MaxTimer;
}

__instance.SetTarget(null);
Expand Down Expand Up @@ -374,78 +368,72 @@ internal class EmergencyMinigameUpdatePatch
{
private static void Postfix(EmergencyMinigame __instance)
{
var roleCanCallEmergency = true;
var statusText = "";
if (!CanCallEmergency(out var statusText))
{
UpdateEmergencyButton(__instance, statusText, false);
return;
}

// Deactivate emergency button for Swapper
if (Swapper.swapper != null && Swapper.swapper == PlayerControl.LocalPlayer &&
!Swapper.canCallEmergency)
if (__instance.state == 1)
{
var localRemaining = PlayerControl.LocalPlayer.RemainingEmergencies;
var teamRemaining = Mathf.Max(0, maxNumberOfMeetings - meetingsCount);
var remaining = Mathf.Min(localRemaining, Mayor.mayor != null && Mayor.mayor == PlayerControl.LocalPlayer ? 1 : teamRemaining);
__instance.NumberText.text = string.Format(GetString("meetingCount"), localRemaining.ToString(), teamRemaining.ToString());
UpdateEmergencyButton(__instance, string.Empty, remaining > 0);
}
}

private static bool CanCallEmergency(out string statusText)
{
statusText = string.Empty;

if (Swapper.swapper != null && Swapper.swapper == PlayerControl.LocalPlayer && !Swapper.canCallEmergency)
{
roleCanCallEmergency = false;
statusText = GetString("swapperMeetingButton");
return false;
}

// Potentially deactivate emergency button for Jester
if (Jester.jester != null && Jester.jester == PlayerControl.LocalPlayer &&
!Jester.canCallEmergency)
if (Jester.jester != null && Jester.jester == PlayerControl.LocalPlayer && !Jester.canCallEmergency)
{
roleCanCallEmergency = false;
statusText = GetString("jesterMeetingButton");
return false;
}

// Potentially deactivate emergency button for Jester
if (Prosecutor.prosecutor != null && Prosecutor.prosecutor == PlayerControl.LocalPlayer &&
!Prosecutor.canCallEmergency)
if (Prosecutor.prosecutor != null && Prosecutor.prosecutor == PlayerControl.LocalPlayer && !Prosecutor.canCallEmergency)
{
roleCanCallEmergency = false;
statusText = GetString("prosecutorMeetingButton");
return false;
}

// Potentially deactivate emergency button for Jester
if (Lawyer.lawyer != null && Lawyer.lawyer == PlayerControl.LocalPlayer &&
!Lawyer.canCallEmergency)
if (Lawyer.lawyer != null && Lawyer.lawyer == PlayerControl.LocalPlayer && !Lawyer.canCallEmergency)
{
roleCanCallEmergency = false;
statusText = GetString("lawyerMeetingButton");
return false;
}

// Potentially deactivate emergency button for Lawyer/Prosecutor
if (Executioner.executioner != null && Executioner.executioner == PlayerControl.LocalPlayer &&
!Executioner.canCallEmergency)
if (Executioner.executioner != null && Executioner.executioner == PlayerControl.LocalPlayer && !Executioner.canCallEmergency)
{
roleCanCallEmergency = false;
if (Executioner.executioner) statusText = GetString("executionerMeetingButton");
statusText = GetString("executionerMeetingButton");
return false;
}

// Potentially deactivate emergency button for Prophet
if (Prophet.prophet != null && Prophet.prophet == PlayerControl.LocalPlayer && !Prophet.canCallEmergency)
{
roleCanCallEmergency = false;
statusText = GetString("prophetMeetingButton");
return false;
}

if (!roleCanCallEmergency)
{
__instance.StatusText.text = statusText;
__instance.NumberText.text = string.Empty;
__instance.ClosedLid.gameObject.SetActive(true);
__instance.OpenLid.gameObject.SetActive(false);
__instance.ButtonActive = false;
return;
}
return true;
}

// Handle max number of meetings
if (__instance.state == 1)
{
var localRemaining = PlayerControl.LocalPlayer.RemainingEmergencies;
var teamRemaining = Mathf.Max(0, maxNumberOfMeetings - meetingsCount);
var remaining = Mathf.Min(localRemaining,
Mayor.mayor != null && Mayor.mayor == PlayerControl.LocalPlayer ? 1 : teamRemaining);
__instance.NumberText.text = string.Format(GetString("meetingCount"), localRemaining.ToString(), teamRemaining.ToString());
__instance.ButtonActive = remaining > 0;
__instance.ClosedLid.gameObject.SetActive(!__instance.ButtonActive);
__instance.OpenLid.gameObject.SetActive(__instance.ButtonActive);
}
private static void UpdateEmergencyButton(EmergencyMinigame instance, string statusText, bool isActive)
{
instance.StatusText.text = statusText;
instance.NumberText.text = string.Empty;
instance.ClosedLid.gameObject.SetActive(!isActive);
instance.OpenLid.gameObject.SetActive(isActive);
instance.ButtonActive = isActive;
}
}

Expand Down
2 changes: 1 addition & 1 deletion TheOtherRoles/RPC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ public static void hostKill(byte targetId)
{
var target = playerById(targetId);
target.Exiled();
OverrideDeathReasonAndKiller(target, CustomDeathReason.HostCmdKill, HostPlayer);
OverrideDeathReasonAndKiller(target, CustomDeathReason.HostCmdKill, GameData.Instance.GetHost()?.Object);

DeadBody[] array = Object.FindObjectsOfType<DeadBody>();
foreach (var body in array)
Expand Down
2 changes: 1 addition & 1 deletion TheOtherRoles/Resources/stringData.json
Original file line number Diff line number Diff line change
Expand Up @@ -1542,7 +1542,7 @@
"13": "存活会取代客户胜利"
},
"executionerPromotesToLawyer": {
"13": "目标职业变更时可以晋升为律师"
"13": "目标被招募时可以晋升为律师"
},
"executionerOnTargetDead": {
"0": "Executioner Becomes On Target Dead",
Expand Down
3 changes: 2 additions & 1 deletion TheOtherRoles/Roles/Neutral/Pelican.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public static void PelicanDie(bool clear = false)
HudManager.Instance.PlayerCam.Target = PlayerControl.LocalPlayer;
PlayerControl.LocalPlayer.NetTransform.RpcSnapTo(Player.transform.position);
}
clearAndReload(clear);
Message($"Pelican Player {Player?.Data.PlayerName ?? "null"}", "Pelican");
if (clear) clearAndReload(true);
}
}

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.1.2.2</Version>
<Version>1.1.2.3</Version>
<AssemblyName>TheOtherUs</AssemblyName>
<Authors>mxyx-club</Authors>
<LangVersion>latest</LangVersion>
Expand Down

0 comments on commit 95a14a0

Please sign in to comment.