Skip to content

Commit fcc7f3c

Browse files
committed
Update v1.1.2.1
1 parent a0ee794 commit fcc7f3c

21 files changed

+451
-604
lines changed

Strings.xlsx

1.17 KB
Binary file not shown.

TheOtherRoles/Buttons/Buttons.cs

Lines changed: 253 additions & 36 deletions
Large diffs are not rendered by default.

TheOtherRoles/Helper/Helpers.cs

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -584,15 +584,20 @@ public static bool Any<T>(this List<T> list, Func<T, bool> func)
584584
return false;
585585
}
586586

587-
public static bool TryAdd<T>(this IEnumerable<T> list, T item)
587+
public static bool TryAdd<T>(this List<T> list, T item)
588588
{
589589
if (list == null || item == null) return false;
590590
try
591591
{
592-
list.AddItem(item);
592+
list.Add(item);
593+
Message("complete", "TryAdd");
593594
return true;
594595
}
595-
catch { return false; }
596+
catch (Exception e)
597+
{
598+
Message(e, "TryAdd");
599+
return false;
600+
}
596601
}
597602

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

814-
public static Vector3 GetCloseSpawnPosition(this PlayerControl player)
815-
{
816-
var list = new List<Vector3>();
817-
list.AddRange(MapData.MapSpawnPosition(false));
818-
list.AddRange(MapData.FindVentSpawnPositions(false));
819-
820-
var closePos = list[0];
821-
float closeDistance = Vector3.Distance(player.transform.position, closePos);
822-
823-
foreach (var pos in list)
824-
{
825-
float distance = Vector3.Distance(player.transform.position, pos);
826-
if (distance < closeDistance)
827-
{
828-
closePos = pos;
829-
closeDistance = distance;
830-
}
831-
}
832-
Message($"Revive Player{player.Data.PlayerName} To Vector3 {closePos}");
833-
return closePos;
834-
}
835-
836819
public static GameObject[] GetChildren(this GameObject ParentObject)
837820
{
838821
GameObject[] ChildObject = new GameObject[ParentObject.transform.childCount];
@@ -867,7 +850,7 @@ public static void clearAllTasks(this PlayerControl player)
867850

868851
public static void shareGameVersion()
869852
{
870-
var writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.VersionHandshake,
853+
var writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.VersionHandshake,
871854
SendOption.Reliable, -1);
872855
writer.Write((byte)Main.Version.Major);
873856
writer.Write((byte)Main.Version.Minor);

TheOtherRoles/Main.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using AmongUs.Data;
33
using BepInEx;
44
using BepInEx.Configuration;
@@ -102,6 +102,7 @@ public override void Load()
102102
SubmergedCompatibility.Initialize();
103103
MainMenuPatch.addSceneChangeCallbacks();
104104
AddToKillDistanceSetting.addKillDistance();
105+
105106
Info($"\n---------------\n Loading TheOtherUs completed!\n TheOtherUs-Edited v{VersionString}-Lite\n---------------");
106107
}
107108
}

TheOtherRoles/Modules/ChatCommands.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,10 @@ private static bool Prefix(ChatController __instance)
116116
if (target != null)
117117
{
118118
var writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId,
119-
(byte)CustomRPC.HostRevive, SendOption.Reliable);
119+
(byte)CustomRPC.RevivePlayer, SendOption.Reliable);
120120
writer.Write(target.PlayerId);
121121
AmongUsClient.Instance.FinishRpcImmediately(writer);
122-
RPCProcedure.hostRevive(target.PlayerId);
122+
RPCProcedure.RevivePlayer(target.PlayerId);
123123
}
124124
handled = true;
125125
}

TheOtherRoles/Options/CustomOptionHolder.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,8 @@ public class CustomOptionHolder
236236
public static CustomOption specterSpawnRate;
237237
public static CustomOption specterResetRole;
238238
public static CustomOption specterDuration;
239-
public static CustomOption specterAfterMeeting;
239+
public static CustomOption specterAfterMeetingTakeRole;
240+
public static CustomOption specterAfterMeetingRevived;
240241

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

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

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

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

11641166
swapperSpawnRate = Create(30230, Types.Crewmate, cs(Swapper.color, "Swapper"), rates, null, true);

TheOtherRoles/Patches/EndGamePatch.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ public static void Postfix(AmongUsClient __instance, [HarmonyArgument(0)] ref En
206206
var executionerWin = Executioner.executioner != null && gameOverReason == (GameOverReason)CustomGameOverReason.ExecutionerWin;
207207
var lawyerSoloWin = Lawyer.lawyer != null && gameOverReason == (GameOverReason)CustomGameOverReason.LawyerSoloWin;
208208
var akujoWin = Akujo.akujo.IsAlive() && Akujo.honmei.IsAlive() && (gameOverReason == (GameOverReason)CustomGameOverReason.AkujoWin ||
209-
(GameManager.Instance.DidHumansWin(gameOverReason) && Akujo.honmeiOptimizeWin && !Akujo.existingWithKiller()));
209+
GameManager.Instance.DidHumansWin(gameOverReason));
210210

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

TheOtherRoles/Patches/ExileControllerPatch.cs

Lines changed: 63 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using AmongUs.GameOptions;
66
using Hazel;
77
using PowerTools;
8+
using Sentry.Protocol;
89
using TheOtherRoles.Buttons;
910
using TheOtherRoles.Objects;
1011
using TheOtherRoles.Utilities;
@@ -359,70 +360,80 @@ private static void WrapUpPostfix(GameData.PlayerInfo exiled)
359360
if (BountyHunter.bountyHunter != null && BountyHunter.bountyHunter == CachedPlayer.LocalPlayer.PlayerControl)
360361
BountyHunter.bountyUpdateTimer = 0f;
361362

362-
// Eraser erase
363-
if (Eraser.eraser != null && AmongUsClient.Instance.AmHost && Eraser.futureErased != null)
363+
if (AmongUsClient.Instance.AmHost)
364364
{
365-
var rasePlayerList = new List<PlayerControl>(Eraser.futureErased);
366-
foreach (var target in rasePlayerList)
365+
LastImpostor.promoteToLastImpostor();
366+
367+
// Eraser erase
368+
if (Eraser.eraser != null && Eraser.futureErased != null)
367369
{
368-
var writer = StartRPC(CachedPlayer.LocalPlayer.PlayerControl.NetId, CustomRPC.ErasePlayerRoles);
369-
writer.Write(target.PlayerId);
370-
writer.EndRPC();
371-
RPCProcedure.erasePlayerRoles(target.PlayerId);
372-
Eraser.alreadyErased.Add(target.PlayerId);
370+
var rasePlayerList = new List<PlayerControl>(Eraser.futureErased);
371+
foreach (var target in rasePlayerList)
372+
{
373+
var writer = StartRPC(CachedPlayer.LocalPlayer.PlayerControl.NetId, CustomRPC.ErasePlayerRoles);
374+
writer.Write(target.PlayerId);
375+
writer.EndRPC();
376+
RPCProcedure.erasePlayerRoles(target.PlayerId);
377+
Eraser.alreadyErased.Add(target.PlayerId);
378+
}
373379
}
374-
}
375-
Eraser.futureErased = new List<PlayerControl>();
376-
377-
// Shifter shift
378-
if (Shifter.shifter != null && AmongUsClient.Instance.AmHost && Shifter.futureShift != null)
379-
{
380-
var writer = StartRPC(CachedPlayer.LocalPlayer.PlayerControl, CustomRPC.ShifterShift);
381-
writer.Write(Shifter.futureShift.PlayerId);
382-
writer.EndRPC();
383-
RPCProcedure.shifterShift(Shifter.futureShift.PlayerId);
384-
}
385380

386-
Shifter.futureShift = null;
381+
// Shifter shift
382+
if (Shifter.shifter != null && Shifter.futureShift != null)
383+
{
384+
var writer = StartRPC(CachedPlayer.LocalPlayer.PlayerControl, CustomRPC.ShifterShift);
385+
writer.Write(Shifter.futureShift.PlayerId);
386+
writer.EndRPC();
387+
RPCProcedure.shifterShift(Shifter.futureShift.PlayerId);
388+
}
387389

388-
// Witch execute casted spells
389-
if (Witch.witch != null && Witch.futureSpelled != null && AmongUsClient.Instance.AmHost)
390-
{
391-
var partner = exiled?.Object?.getPartner();
390+
// Witch execute casted spells
391+
if (Witch.witch != null && Witch.futureSpelled != null)
392+
{
393+
var partner = exiled?.Object?.getPartner();
392394

393-
var exiledIsWitch = exiled?.PlayerId == Witch.witch.PlayerId;
394-
var witchDiesWithExiledLover = partner?.PlayerId == Witch.witch.PlayerId || exiled?.PlayerId == Witch.witch.PlayerId;
395+
var exiledIsWitch = exiled?.PlayerId == Witch.witch.PlayerId;
396+
var witchDiesWithExiledLover = partner?.PlayerId == Witch.witch.PlayerId || exiled?.PlayerId == Witch.witch.PlayerId;
395397

396-
if (((witchDiesWithExiledLover || exiledIsWitch) && Witch.witchVoteSavesTargets) || Witch.witchWasGuessed)
397-
Witch.futureSpelled = new List<PlayerControl>();
398+
if (((witchDiesWithExiledLover || exiledIsWitch) && Witch.witchVoteSavesTargets) || Witch.witchWasGuessed)
399+
Witch.futureSpelled = new List<PlayerControl>();
398400

399-
foreach (var target in Witch.futureSpelled.Where(x => x.IsAlive()))
400-
{
401-
if (Lawyer.lawyer != null && target == Lawyer.target)
401+
foreach (var target in Witch.futureSpelled.Where(x => x.IsAlive()))
402402
{
403-
var writer2 = StartRPC(CachedPlayer.LocalPlayer.PlayerControl, CustomRPC.LawyerPromotesToPursuer);
404-
writer2.EndRPC();
405-
Lawyer.PromotesToPursuer();
406-
}
403+
if (Lawyer.lawyer != null && target == Lawyer.target)
404+
{
405+
var writer2 = StartRPC(CachedPlayer.LocalPlayer.PlayerControl, CustomRPC.LawyerPromotesToPursuer);
406+
writer2.EndRPC();
407+
Lawyer.PromotesToPursuer();
408+
}
407409

408-
if (Executioner.executioner.IsAlive() && target == Executioner.target)
409-
{
410-
var writer2 = StartRPC(CachedPlayer.LocalPlayer.PlayerControl, CustomRPC.ExecutionerPromotesRole);
411-
writer2.EndRPC();
412-
Executioner.PromotesRole();
413-
}
410+
if (Executioner.executioner.IsAlive() && target == Executioner.target)
411+
{
412+
var writer2 = StartRPC(CachedPlayer.LocalPlayer.PlayerControl, CustomRPC.ExecutionerPromotesRole);
413+
writer2.EndRPC();
414+
Executioner.PromotesRole();
415+
}
414416

415-
var writer = StartRPC(CachedPlayer.LocalPlayer.PlayerControl, CustomRPC.UncheckedExilePlayer);
416-
writer.Write(target.PlayerId);
417-
writer.EndRPC();
418-
RPCProcedure.uncheckedExilePlayer(target.PlayerId);
417+
var writer = StartRPC(CachedPlayer.LocalPlayer.PlayerControl, CustomRPC.UncheckedExilePlayer);
418+
writer.Write(target.PlayerId);
419+
writer.EndRPC();
420+
RPCProcedure.uncheckedExilePlayer(target.PlayerId);
419421

420-
GameHistory.RpcOverrideDeathReasonAndKiller(target, CustomDeathReason.WitchExile, Witch.witch);
422+
GameHistory.RpcOverrideDeathReasonAndKiller(target, CustomDeathReason.WitchExile, Witch.witch);
423+
}
421424
}
422425
}
423426

427+
Eraser.futureErased = new List<PlayerControl>();
428+
Shifter.futureShift = null;
424429
Witch.futureSpelled = new List<PlayerControl>();
425430

431+
if (Specter.Player != null && Specter.Player?.Data?.IsDead == true && Specter.revive)
432+
{
433+
Specter.Player.Revive();
434+
Specter.revive = false;
435+
}
436+
426437
// Medium spawn souls
427438
if (Medium.medium != null && CachedPlayer.LocalPlayer.PlayerControl == Medium.medium)
428439
{
@@ -451,11 +462,6 @@ private static void WrapUpPostfix(GameData.PlayerInfo exiled)
451462
}
452463
}
453464

454-
// AntiTeleport set position
455-
AntiTeleport.setPosition();
456-
457-
if (CustomOptionHolder.randomGameStartPosition.GetBool()) MapData.RandomSpawnPlayers();
458-
459465
if (InfoSleuth.infoSleuth != null && InfoSleuth.target != null && InfoSleuth.infoSleuth == PlayerControl.LocalPlayer)
460466
{
461467
var isNotCrew = (isNeutral(InfoSleuth.target) || InfoSleuth.target.isImpostor()) ^ Vortox.Reversal;
@@ -507,10 +513,11 @@ static string getTeam(PlayerControl player)
507513

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

510-
if (AmongUsClient.Instance.AmHost)
511-
{
512-
LastImpostor.promoteToLastImpostor();
513-
}
516+
// AntiTeleport set position
517+
AntiTeleport.setPosition();
518+
519+
if (CustomOptionHolder.randomGameStartPosition.GetBool()) MapData.RandomSpawnPlayers();
520+
514521
}
515522

516523
[HarmonyPatch(typeof(ExileController), nameof(ExileController.WrapUp))]

0 commit comments

Comments
 (0)