Skip to content

Commit

Permalink
Update v1.1.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mxyx0412 committed Feb 2, 2025
1 parent a0ee794 commit fcc7f3c
Show file tree
Hide file tree
Showing 21 changed files with 451 additions and 604 deletions.
Binary file modified Strings.xlsx
Binary file not shown.
289 changes: 253 additions & 36 deletions TheOtherRoles/Buttons/Buttons.cs

Large diffs are not rendered by default.

35 changes: 9 additions & 26 deletions TheOtherRoles/Helper/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -584,15 +584,20 @@ public static bool Any<T>(this List<T> list, Func<T, bool> func)
return false;
}

public static bool TryAdd<T>(this IEnumerable<T> list, T item)
public static bool TryAdd<T>(this List<T> list, T item)
{
if (list == null || item == null) return false;
try
{
list.AddItem(item);
list.Add(item);
Message("complete", "TryAdd");
return true;
}
catch { return false; }
catch (Exception e)
{
Message(e, "TryAdd");
return false;
}
}

public static TKey GetKeyByValue<TKey, TValue>(this Dictionary<TKey, TValue> dictionary, TValue value, TKey defaultvalue = default)
Expand Down Expand Up @@ -811,28 +816,6 @@ public static void SetActiveAllObject(this GameObject[] trans, string notdelete,
}
}

public static Vector3 GetCloseSpawnPosition(this PlayerControl player)
{
var list = new List<Vector3>();
list.AddRange(MapData.MapSpawnPosition(false));
list.AddRange(MapData.FindVentSpawnPositions(false));

var closePos = list[0];
float closeDistance = Vector3.Distance(player.transform.position, closePos);

foreach (var pos in list)
{
float distance = Vector3.Distance(player.transform.position, pos);
if (distance < closeDistance)
{
closePos = pos;
closeDistance = distance;
}
}
Message($"Revive Player{player.Data.PlayerName} To Vector3 {closePos}");
return closePos;
}

public static GameObject[] GetChildren(this GameObject ParentObject)
{
GameObject[] ChildObject = new GameObject[ParentObject.transform.childCount];
Expand Down Expand Up @@ -867,7 +850,7 @@ public static void clearAllTasks(this PlayerControl player)

public static void shareGameVersion()
{
var writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.VersionHandshake,
var writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.VersionHandshake,
SendOption.Reliable, -1);
writer.Write((byte)Main.Version.Major);
writer.Write((byte)Main.Version.Minor);
Expand Down
3 changes: 2 additions & 1 deletion TheOtherRoles/Main.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using AmongUs.Data;
using BepInEx;
using BepInEx.Configuration;
Expand Down Expand Up @@ -102,6 +102,7 @@ public override void Load()
SubmergedCompatibility.Initialize();
MainMenuPatch.addSceneChangeCallbacks();
AddToKillDistanceSetting.addKillDistance();

Info($"\n---------------\n Loading TheOtherUs completed!\n TheOtherUs-Edited v{VersionString}-Lite\n---------------");
}
}
Expand Down
4 changes: 2 additions & 2 deletions TheOtherRoles/Modules/ChatCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ private static bool Prefix(ChatController __instance)
if (target != null)
{
var writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId,
(byte)CustomRPC.HostRevive, SendOption.Reliable);
(byte)CustomRPC.RevivePlayer, SendOption.Reliable);
writer.Write(target.PlayerId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCProcedure.hostRevive(target.PlayerId);
RPCProcedure.RevivePlayer(target.PlayerId);
}
handled = true;
}
Expand Down
10 changes: 6 additions & 4 deletions TheOtherRoles/Options/CustomOptionHolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,8 @@ public class CustomOptionHolder
public static CustomOption specterSpawnRate;
public static CustomOption specterResetRole;
public static CustomOption specterDuration;
public static CustomOption specterAfterMeeting;
public static CustomOption specterAfterMeetingTakeRole;
public static CustomOption specterAfterMeetingRevived;

public static CustomOption sheriffSpawnRate;
public static CustomOption sheriffMisfireKills;
Expand Down Expand Up @@ -933,7 +934,8 @@ public static void Load()
specterSpawnRate = Create(50020, Types.Neutral, cs(Specter.color, "SpecterOptions"), rates, null, true);
specterResetRole = Create(50021, Types.Neutral, "amnisiacResetRole", true, specterSpawnRate);
specterDuration = Create(50022, Types.Neutral, "specterDuration", 1.5f, 0.25f, 5f, 0.25f, specterSpawnRate);
specterAfterMeeting = Create(50023, Types.Neutral, "specterAfterMeeting", false, specterSpawnRate);
specterAfterMeetingTakeRole = Create(50023, Types.Neutral, "specterAfterMeetingTakeRole", false, specterSpawnRate);
specterAfterMeetingRevived = Create(50024, Types.Neutral, "specterAfterMeetingRevived", false, specterSpawnRate);

survivorSpawnRate = Create(20280, Types.Neutral, cs(Survivor.color, "Survivor"), rates, null, true);
survivorVestEnable = Create(20281, Types.Neutral, "survivorVestEnable", true, survivorSpawnRate);
Expand Down Expand Up @@ -1153,12 +1155,12 @@ public static void Load()
bodyGuardFlash = Create(30342, Types.Crewmate, "bodyGuardFlash", true, bodyGuardSpawnRate);

timeMasterSpawnRate = Create(30210, Types.Crewmate, cs(TimeMaster.color, "TimeMaster"), rates, null, true);
timeMasterCooldown = Create(30211, Types.Crewmate, "timeMasterCooldown", 20f, 10f, 60f, 2.5f, timeMasterSpawnRate);
timeMasterCooldown = Create(30211, Types.Crewmate, "timeMasterCooldown", 20f, 5f, 60f, 2.5f, timeMasterSpawnRate);
timeMasterShieldDuration = Create(30213, Types.Crewmate, "timeMasterShieldDuration", 15f, 2.5f, 20f, 0.5f, timeMasterSpawnRate);
timeMasterRewindTime = Create(30212, Types.Crewmate, "timeMasterRewindTime", 9f, 1f, 10f, 1f, timeMasterSpawnRate);

veteranSpawnRate = Create(30220, Types.Crewmate, cs(Veteran.color, "Veteran"), rates, null, true);
veteranCooldown = Create(30221, Types.Crewmate, "veteranCooldown", 25f, 10f, 60f, 2.5f, veteranSpawnRate);
veteranCooldown = Create(30221, Types.Crewmate, "veteranCooldown", 25f, 5f, 60f, 2.5f, veteranSpawnRate);
veteranAlertDuration = Create(30222, Types.Crewmate, "veteranAlertDuration", 12.5f, 2.5f, 20f, 0.5f, veteranSpawnRate);

swapperSpawnRate = Create(30230, Types.Crewmate, cs(Swapper.color, "Swapper"), rates, null, true);
Expand Down
2 changes: 1 addition & 1 deletion TheOtherRoles/Patches/EndGamePatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public static void Postfix(AmongUsClient __instance, [HarmonyArgument(0)] ref En
var executionerWin = Executioner.executioner != null && gameOverReason == (GameOverReason)CustomGameOverReason.ExecutionerWin;
var lawyerSoloWin = Lawyer.lawyer != null && gameOverReason == (GameOverReason)CustomGameOverReason.LawyerSoloWin;
var akujoWin = Akujo.akujo.IsAlive() && Akujo.honmei.IsAlive() && (gameOverReason == (GameOverReason)CustomGameOverReason.AkujoWin ||
(GameManager.Instance.DidHumansWin(gameOverReason) && Akujo.honmeiOptimizeWin && !Akujo.existingWithKiller()));
GameManager.Instance.DidHumansWin(gameOverReason));

bool isPursurerLose = jesterWin || witnessWin || arsonistWin || miniLose || isCanceled || executionerWin;

Expand Down
119 changes: 63 additions & 56 deletions TheOtherRoles/Patches/ExileControllerPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using AmongUs.GameOptions;
using Hazel;
using PowerTools;
using Sentry.Protocol;
using TheOtherRoles.Buttons;
using TheOtherRoles.Objects;
using TheOtherRoles.Utilities;
Expand Down Expand Up @@ -359,70 +360,80 @@ private static void WrapUpPostfix(GameData.PlayerInfo exiled)
if (BountyHunter.bountyHunter != null && BountyHunter.bountyHunter == CachedPlayer.LocalPlayer.PlayerControl)
BountyHunter.bountyUpdateTimer = 0f;

// Eraser erase
if (Eraser.eraser != null && AmongUsClient.Instance.AmHost && Eraser.futureErased != null)
if (AmongUsClient.Instance.AmHost)
{
var rasePlayerList = new List<PlayerControl>(Eraser.futureErased);
foreach (var target in rasePlayerList)
LastImpostor.promoteToLastImpostor();

// Eraser erase
if (Eraser.eraser != null && Eraser.futureErased != null)
{
var writer = StartRPC(CachedPlayer.LocalPlayer.PlayerControl.NetId, CustomRPC.ErasePlayerRoles);
writer.Write(target.PlayerId);
writer.EndRPC();
RPCProcedure.erasePlayerRoles(target.PlayerId);
Eraser.alreadyErased.Add(target.PlayerId);
var rasePlayerList = new List<PlayerControl>(Eraser.futureErased);
foreach (var target in rasePlayerList)
{
var writer = StartRPC(CachedPlayer.LocalPlayer.PlayerControl.NetId, CustomRPC.ErasePlayerRoles);
writer.Write(target.PlayerId);
writer.EndRPC();
RPCProcedure.erasePlayerRoles(target.PlayerId);
Eraser.alreadyErased.Add(target.PlayerId);
}
}
}
Eraser.futureErased = new List<PlayerControl>();

// Shifter shift
if (Shifter.shifter != null && AmongUsClient.Instance.AmHost && Shifter.futureShift != null)
{
var writer = StartRPC(CachedPlayer.LocalPlayer.PlayerControl, CustomRPC.ShifterShift);
writer.Write(Shifter.futureShift.PlayerId);
writer.EndRPC();
RPCProcedure.shifterShift(Shifter.futureShift.PlayerId);
}

Shifter.futureShift = null;
// Shifter shift
if (Shifter.shifter != null && Shifter.futureShift != null)
{
var writer = StartRPC(CachedPlayer.LocalPlayer.PlayerControl, CustomRPC.ShifterShift);
writer.Write(Shifter.futureShift.PlayerId);
writer.EndRPC();
RPCProcedure.shifterShift(Shifter.futureShift.PlayerId);
}

// Witch execute casted spells
if (Witch.witch != null && Witch.futureSpelled != null && AmongUsClient.Instance.AmHost)
{
var partner = exiled?.Object?.getPartner();
// Witch execute casted spells
if (Witch.witch != null && Witch.futureSpelled != null)
{
var partner = exiled?.Object?.getPartner();

var exiledIsWitch = exiled?.PlayerId == Witch.witch.PlayerId;
var witchDiesWithExiledLover = partner?.PlayerId == Witch.witch.PlayerId || exiled?.PlayerId == Witch.witch.PlayerId;
var exiledIsWitch = exiled?.PlayerId == Witch.witch.PlayerId;
var witchDiesWithExiledLover = partner?.PlayerId == Witch.witch.PlayerId || exiled?.PlayerId == Witch.witch.PlayerId;

if (((witchDiesWithExiledLover || exiledIsWitch) && Witch.witchVoteSavesTargets) || Witch.witchWasGuessed)
Witch.futureSpelled = new List<PlayerControl>();
if (((witchDiesWithExiledLover || exiledIsWitch) && Witch.witchVoteSavesTargets) || Witch.witchWasGuessed)
Witch.futureSpelled = new List<PlayerControl>();

foreach (var target in Witch.futureSpelled.Where(x => x.IsAlive()))
{
if (Lawyer.lawyer != null && target == Lawyer.target)
foreach (var target in Witch.futureSpelled.Where(x => x.IsAlive()))
{
var writer2 = StartRPC(CachedPlayer.LocalPlayer.PlayerControl, CustomRPC.LawyerPromotesToPursuer);
writer2.EndRPC();
Lawyer.PromotesToPursuer();
}
if (Lawyer.lawyer != null && target == Lawyer.target)
{
var writer2 = StartRPC(CachedPlayer.LocalPlayer.PlayerControl, CustomRPC.LawyerPromotesToPursuer);
writer2.EndRPC();
Lawyer.PromotesToPursuer();
}

if (Executioner.executioner.IsAlive() && target == Executioner.target)
{
var writer2 = StartRPC(CachedPlayer.LocalPlayer.PlayerControl, CustomRPC.ExecutionerPromotesRole);
writer2.EndRPC();
Executioner.PromotesRole();
}
if (Executioner.executioner.IsAlive() && target == Executioner.target)
{
var writer2 = StartRPC(CachedPlayer.LocalPlayer.PlayerControl, CustomRPC.ExecutionerPromotesRole);
writer2.EndRPC();
Executioner.PromotesRole();
}

var writer = StartRPC(CachedPlayer.LocalPlayer.PlayerControl, CustomRPC.UncheckedExilePlayer);
writer.Write(target.PlayerId);
writer.EndRPC();
RPCProcedure.uncheckedExilePlayer(target.PlayerId);
var writer = StartRPC(CachedPlayer.LocalPlayer.PlayerControl, CustomRPC.UncheckedExilePlayer);
writer.Write(target.PlayerId);
writer.EndRPC();
RPCProcedure.uncheckedExilePlayer(target.PlayerId);

GameHistory.RpcOverrideDeathReasonAndKiller(target, CustomDeathReason.WitchExile, Witch.witch);
GameHistory.RpcOverrideDeathReasonAndKiller(target, CustomDeathReason.WitchExile, Witch.witch);
}
}
}

Eraser.futureErased = new List<PlayerControl>();
Shifter.futureShift = null;
Witch.futureSpelled = new List<PlayerControl>();

if (Specter.Player != null && Specter.Player?.Data?.IsDead == true && Specter.revive)
{
Specter.Player.Revive();
Specter.revive = false;
}

// Medium spawn souls
if (Medium.medium != null && CachedPlayer.LocalPlayer.PlayerControl == Medium.medium)
{
Expand Down Expand Up @@ -451,11 +462,6 @@ private static void WrapUpPostfix(GameData.PlayerInfo exiled)
}
}

// AntiTeleport set position
AntiTeleport.setPosition();

if (CustomOptionHolder.randomGameStartPosition.GetBool()) MapData.RandomSpawnPlayers();

if (InfoSleuth.infoSleuth != null && InfoSleuth.target != null && InfoSleuth.infoSleuth == PlayerControl.LocalPlayer)
{
var isNotCrew = (isNeutral(InfoSleuth.target) || InfoSleuth.target.isImpostor()) ^ Vortox.Reversal;
Expand Down Expand Up @@ -507,10 +513,11 @@ static string getTeam(PlayerControl player)

if (!Yoyo.markStaysOverMeeting) Silhouette.clearSilhouettes();

if (AmongUsClient.Instance.AmHost)
{
LastImpostor.promoteToLastImpostor();
}
// AntiTeleport set position
AntiTeleport.setPosition();

if (CustomOptionHolder.randomGameStartPosition.GetBool()) MapData.RandomSpawnPlayers();

}

[HarmonyPatch(typeof(ExileController), nameof(ExileController.WrapUp))]
Expand Down
Loading

0 comments on commit fcc7f3c

Please sign in to comment.