Skip to content

Commit

Permalink
Update v1.1.3.5 Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mxyx0412 committed Mar 2, 2025
1 parent b58b636 commit cde02b1
Show file tree
Hide file tree
Showing 14 changed files with 48 additions and 47 deletions.
2 changes: 1 addition & 1 deletion TheOtherRoles/Buttons/Buttons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1661,7 +1661,7 @@ public static void createButtonsPostfix(HudManager __instance)
vampireKillButton.actionButton.cooldownTimerText.color = Palette.EnabledColor;
},
Vampire.buttonSprite,
ButtonPositions.upperRowRight,
ButtonPositions.upperRowCenter,
__instance,
modKillInput.keyCode,
false,
Expand Down
2 changes: 1 addition & 1 deletion TheOtherRoles/Helper/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ public static int Count<T>(this Il2CppSystem.Collections.Generic.List<T> list, F
return count;
}

public static bool MContains<T>(this IEnumerable<T> source, T item) where T : class
public static bool MContains<T>(this List<T> source, T item) where T : class
{
if (source == null || item == null)
return false;
Expand Down
3 changes: 2 additions & 1 deletion TheOtherRoles/Modules/Logger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ public static void SendLog(string text, string tag = "", LogLevel logLevel = Log
{
StackFrame stack = new(2);
var time = DateTime.Now.ToString("HH:mm:ss");
var className = $" [{stack.GetMethod()?.ReflectedType?.Name}]" ?? "";
var className = stack.GetMethod()?.ReflectedType?.Name;
if (string.IsNullOrWhiteSpace(className)) className = "";
if (!string.IsNullOrWhiteSpace(tag)) text = $"[{time}]{className} [{tag}] {text}";
else text = $"[{time}]{className} {text}";

Expand Down
14 changes: 6 additions & 8 deletions TheOtherRoles/Modules/RoleDraft.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ internal class RoleDraft
private static Dictionary<byte, string> playerRoles = new();

private static readonly SimpleTable _pickTable = new SimpleTable()
.AddColumn(6, minWidth: 4, Alignment.Right)
.AddColumn(minWidth: 12);
.AddColumn(8, minWidth: 4, Alignment.Right)
.AddColumn(minWidth: 9);

[HarmonyPatch(typeof(IntroCutscene), nameof(IntroCutscene.ShowTeam))]
private class ShowRolePatch
Expand Down Expand Up @@ -158,7 +158,7 @@ public static IEnumerator CoSelectRoles(IntroCutscene __instance)
if (roleInfo.roleId == RoleId.Poucher && Poucher.spawnModifier) continue;

// 跳过概率为0的职业
if (roleData.neutralSettings.ContainsKey((byte)roleInfo.roleId) && roleData.neutralSettings[(byte)roleInfo.roleId] == 0)
if (roleData.neutralSettings.ContainsKey((byte)roleInfo.roleId) && roleData.neutralSettings[(byte)roleInfo.roleId] == 0)
continue;
else if (roleData.killerNeutralSettings.ContainsKey((byte)roleInfo.roleId) && roleData.killerNeutralSettings[(byte)roleInfo.roleId] == 0)
continue;
Expand Down Expand Up @@ -224,20 +224,18 @@ public static IEnumerator CoSelectRoles(IntroCutscene __instance)
continue;
}

bool skipDueToOverflow = false;
if (isNeutral && roleData.neutralSettings.Count(x => x.Value == 10) > neutralsMax)
{
skipDueToOverflow = (neutrals100 - neutrals100Picked > 0) && (neutralRate != 10);
if ((neutrals100 - neutrals100Picked > 0) && (neutralRate != 10)) continue;
}
else if (isKillerNeutral && roleData.killerNeutralSettings.Count(x => x.Value == 10) > killerNeutralsMax)
{
skipDueToOverflow = (killerNeutrals100 - killerNeutrals100Picked > 0) && (killerNeutralRate != 10);
if ((killerNeutrals100 - killerNeutrals100Picked > 0) && (killerNeutralRate != 10)) continue;
}
else if (isCrewmate && roleData.crewSettings.Count(x => x.Value == 10) > crewmateMax)
{
skipDueToOverflow = (crew100 - crew100Picked > 0) && (crewRate != 10);
if ((crew100 - crew100Picked > 0) && (crewRate != 10)) continue;
}
if (skipDueToOverflow) continue;

if (isNeutral &&
roleData.neutralSettings.Count(x => x.Value == 10 && !alreadyPicked.Contains(x.Key)) >=
Expand Down
2 changes: 2 additions & 0 deletions TheOtherRoles/Options/CustomOptionHolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,7 @@ public class CustomOptionHolder
public static CustomOption modifierSlueth;

public static CustomOption modifierCursed;
public static CustomOption modifierAutoJoin;
public static CustomOption modifierHideCursed;

public static CustomOption modifierVip;
Expand Down Expand Up @@ -1376,6 +1377,7 @@ public static void Load()
modifierSlueth = Create(40290, Types.Modifier, cs(Color.yellow, "Slueth"), rates, null, true);

modifierCursed = Create(40300, Types.Modifier, cs(Color.yellow, "Cursed"), rates, null, true);
modifierAutoJoin = Create(40302, Types.Modifier, cs(Color.yellow, "modifierAutoCursed"), true, modifierCursed);
modifierHideCursed = Create(40301, Types.Modifier, "modifierShowCursed", false, modifierCursed);

modifierVip = Create(40310, Types.Modifier, cs(Color.yellow, "Vip"), rates, null, true);
Expand Down
1 change: 0 additions & 1 deletion TheOtherRoles/Patches/EndGamePatch.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AmongUs.GameOptions;
using TheOtherRoles.Utilities;
using TMPro;
Expand Down
2 changes: 1 addition & 1 deletion TheOtherRoles/Patches/PlayerControlPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public static void updatePlayerInfo()
{
var mainRole = RoleInfo.GetRolesString(p, true, false, false, false);
var allRoleText = RoleInfo.GetRolesString(p, true, true, true, true);
allRoleText += $"- {RoleInfo.GetDeathReasonString(p)}";
if (p.IsDead() && CanSeeRoleInfo) allRoleText += $" - {RoleInfo.GetDeathReasonString(p)}";

var playerInfoTransform = p.cosmetics.nameText.transform.parent.FindChild("Info");
var playerInfo = playerInfoTransform != null ? playerInfoTransform.GetComponent<TextMeshPro>() : null;
Expand Down
8 changes: 5 additions & 3 deletions TheOtherRoles/Patches/RoleAssignmentPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ public static RoleAssignmentData getRoleAssignmentData()
if (!isGuesserGamemode)
crewSettings.Add((byte)RoleId.Vigilante, CustomOptionHolder.guesserSpawnRate.GetSelection());
crewSettings.Add((byte)RoleId.Trapper, CustomOptionHolder.trapperSpawnRate.GetSelection());
// Only add Spy if more than 1 impostor as the spy role is otherwise useless
if (impostors.Count > 1)
// Only add Spy if more than 1 impostor as the spy role is otherwise useless
crewSettings.Add((byte)RoleId.Spy, CustomOptionHolder.spySpawnRate.GetSelection());
crewSettings.Add((byte)RoleId.SecurityGuard, CustomOptionHolder.securityGuardSpawnRate.GetSelection());
crewSettings.Add((byte)RoleId.Jumper, CustomOptionHolder.jumperSpawnRate.GetSelection());
Expand Down Expand Up @@ -910,9 +910,11 @@ private static void assignModifiersToPlayers(List<RoleId> modifiers, List<Player
if (modifiers.Contains(RoleId.Torch))
{
var torchCount = 0;
var TPlayers = new List<PlayerControl>(crewPlayer);
TPlayers.RemoveAll(x => x == Mayor.mayor);
while (torchCount < modifiers.FindAll(x => x == RoleId.Torch).Count)
{
playerId = setModifierToRandomPlayer((byte)RoleId.Torch, crewPlayer);
playerId = setModifierToRandomPlayer((byte)RoleId.Torch, TPlayers);
crewPlayer.RemoveAll(x => x.PlayerId == playerId);
playerList.RemoveAll(x => x.PlayerId == playerId);
torchCount++;
Expand Down Expand Up @@ -1037,7 +1039,7 @@ private static int getSelectionForRoleId(RoleId roleId, bool multiplyQuantity =
selection = CustomOptionHolder.modifierTunneler.GetSelection();
break;
case RoleId.ButtonBarry:
if (Mayor.mayor != null && Mayor.meetingButton) // 杜绝双执钮!
if (Mayor.mayor != null && Mayor.meetingButton) break;
selection = CustomOptionHolder.modifierButtonBarry.GetSelection();
break;
case RoleId.Sunglasses:
Expand Down
44 changes: 22 additions & 22 deletions TheOtherRoles/RPC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1297,32 +1297,32 @@ public static void disperse()
{
Coroutines.Start(showFlashCoroutine(Palette.ImpostorRed, 1f, 0.36f));

if (!AntiTeleport.antiTeleport.Any(x => x.PlayerId == PlayerControl.LocalPlayer.PlayerId) && PlayerControl.LocalPlayer.IsAlive())
if (PlayerControl.LocalPlayer.inVent)
{
foreach (var player in PlayerControl.AllPlayerControls)
{
if (Minigame.Instance) Minigame.Instance.ForceClose();
if (MapBehaviour.Instance) MapBehaviour.Instance.Close();
PlayerControl.LocalPlayer.MyPhysics.RpcExitVent(Vent.currentVent.Id);
PlayerControl.LocalPlayer.MyPhysics.ExitAllVents();
}

if (PlayerControl.LocalPlayer.inVent)
{
PlayerControl.LocalPlayer.MyPhysics.RpcExitVent(Vent.currentVent.Id);
PlayerControl.LocalPlayer.MyPhysics.ExitAllVents();
}
if (Minigame.Instance) Minigame.Instance.ForceClose();
if (MapBehaviour.Instance) MapBehaviour.Instance.Close();

if (Disperser.DispersesToVent)
{
PlayerControl.LocalPlayer.NetTransform.RpcSnapTo
(MapData.FindVentSpawnPositions()[rnd.Next(MapData.FindVentSpawnPositions().Count)]);
}
else
{
PlayerControl.LocalPlayer.NetTransform.RpcSnapTo
(MapData.MapSpawnPosition()[rnd.Next(MapData.MapSpawnPosition().Count)]);
}
}
Disperser.remainingDisperses--;
if (PlayerControl.LocalPlayer.inVent)
{
PlayerControl.LocalPlayer.MyPhysics.RpcExitVent(Vent.currentVent.Id);
PlayerControl.LocalPlayer.MyPhysics.ExitAllVents();
}

if (Disperser.DispersesToVent)
{
PlayerControl.LocalPlayer.NetTransform.RpcSnapTo
(MapData.FindVentSpawnPositions()[rnd.Next(MapData.FindVentSpawnPositions().Count)]);
}
else
{
PlayerControl.LocalPlayer.NetTransform.RpcSnapTo
(MapData.MapSpawnPosition()[rnd.Next(MapData.MapSpawnPosition().Count)]);
}
Disperser.remainingDisperses--;
}

public static void setFutureShielded(byte playerId)
Expand Down
3 changes: 1 addition & 2 deletions TheOtherRoles/Roles/Crewmate/Sheriff.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ public static void setHandcuffedKnows(bool active = true, byte playerId = byte.M

public static void deputyCheckPromotion(bool isMeeting = false)
{
// If LocalPlayer is Deputy, the Sheriff is disconnected and Deputy promotion is enabled, then trigger promotion
if (Deputy == null || Deputy != PlayerControl.LocalPlayer || IntroCutscene.Instance != null) return;
if (Deputy == null || Deputy != PlayerControl.LocalPlayer || Intro) return;
if (promotesToSheriff == 0 || Deputy.IsDead() || (promotesToSheriff == 2 && !isMeeting)) return;
if (Player.Count == 0 || Player.All(x => x.IsDead()))
{
Expand Down
5 changes: 4 additions & 1 deletion TheOtherRoles/Roles/Modifier/Cursed.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ public static class Cursed
public static PlayerControl cursed;
public static Color color = new Color32(0, 247, 255, byte.MaxValue);
public static bool hideModifier;
public static bool autoJoin;

public static void clearAndReload()
{
cursed = null;
hideModifier = CustomOptionHolder.modifierHideCursed.GetBool();
autoJoin = CustomOptionHolder.modifierAutoJoin.GetBool();
}

[HarmonyPatch]
Expand All @@ -21,14 +23,15 @@ private static class Cursed_Patch
[HarmonyPatch(typeof(HudManager), nameof(HudManager.Update)), HarmonyPostfix]
private static void Postfix(HudManager __instance)
{
if (cursed.IsDead() || !InGame || cursed != PlayerControl.LocalPlayer) return;
if (cursed.IsDead() || !autoJoin || !InGame || cursed != PlayerControl.LocalPlayer) return;

var allPlayers = PlayerControl.AllPlayerControls.ToList();
var impostorCount = allPlayers.Count(x => x.IsImpostor() && x.IsAlive());

if (impostorCount >= allPlayers.Count(x => !x.IsImpostor() && x.IsAlive()))
{
turnToImpostorRPC(cursed);
clearAndReload();
}
}
}
Expand Down
3 changes: 0 additions & 3 deletions TheOtherRoles/Roles/Modifier/LastImpostor.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using System.Collections.Generic;
using Hazel;
using TheOtherRoles.Utilities;
using UnityEngine;

namespace TheOtherRoles.Roles.Modifier;
Expand Down
4 changes: 2 additions & 2 deletions TheOtherRoles/Roles/RoleInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ public static string GetRolesString(PlayerControl p, bool useColors, bool showMo
if (p == Arsonist.arsonist)
roleName += cs(Arsonist.color,
$" (剩余 {PlayerControl.AllPlayerControls.Count(x => { return x != Arsonist.arsonist && x.IsAlive() && !Arsonist.dousedPlayers.Any(y => y.PlayerId == x.PlayerId); })} )");
if (Akujo.keeps.Contains(p))
if (Akujo.keeps.Any(x => x.PlayerId == p.PlayerId))
roleName = cs(Color.gray, "(备胎) ") + roleName;
if (p == Akujo.honmei)
roleName = cs(Akujo.color, "(真爱) ") + roleName;
Expand All @@ -464,7 +464,7 @@ public static string GetRolesString(PlayerControl p, bool useColors, bool showMo

public static string GetDeathReasonString(PlayerControl p)
{
if (p.IsAlive()) return "";
if (p.IsAlive() || !ShowGhostInfo) return "";

var deadPlayer = GameHistory.DeadPlayers.FirstOrDefault(x => x.Player.PlayerId == p.PlayerId);
if (deadPlayer == null) return "";
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.3.5</Version>
<Version>1.1.3.6</Version>
<AssemblyName>TheOtherUs</AssemblyName>
<Authors>mxyx-club</Authors>
<LangVersion>latest</LangVersion>
Expand Down

0 comments on commit cde02b1

Please sign in to comment.