Skip to content

Commit

Permalink
Update v1.1.1.7
Browse files Browse the repository at this point in the history
  • Loading branch information
mxyx0412 committed Jan 21, 2025
1 parent e6b9854 commit 56edf7c
Show file tree
Hide file tree
Showing 31 changed files with 428 additions and 450 deletions.
8 changes: 3 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
v1.1.1.1更新日志
v1.1.1.6更新日志

* 新增伪装者职业:狼之主
* 新增附加能力:迷乱旋涡
* 修复巨人的体型在其他玩家不可见的问题
* 修复分散者的坐标问题
* 新增中立杀手职业:鹈鹕
* 掘墓人:修复了无法使用紧急会议按钮的问题

注:本次仅更新Lite分支
160 changes: 58 additions & 102 deletions TheOtherRoles/Buttons/Buttons.cs

Large diffs are not rendered by default.

11 changes: 5 additions & 6 deletions TheOtherRoles/Buttons/CustomButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ public void onClickEvent()
OnClick();

// Deputy skip onClickEvent if handcuffed
if (Deputy.handcuffedKnows.ContainsKey(CachedPlayer.LocalPlayer.PlayerId) &&
Deputy.handcuffedKnows[CachedPlayer.LocalPlayer.PlayerId] > 0f) return;
if (Sheriff.handcuffedKnows.ContainsKey(CachedPlayer.LocalPlayer.PlayerId) &&
Sheriff.handcuffedKnows[CachedPlayer.LocalPlayer.PlayerId] > 0f) return;

if (!HasEffect || isEffectActive) return;
DeputyTimer = EffectDuration;
Expand Down Expand Up @@ -135,7 +135,7 @@ public static void MeetingEndedUpdate()
public static void ResetAllCooldowns(float Time = -1)
{
var time = Time == -1 ? ModOption.KillCooddown : Time;
CachedPlayer.LocalPlayer.PlayerControl.killTimer = time;
CachedPlayer.LocalPlayer.PlayerControl.killTimer = time - 0.6f;
foreach (var t in buttons)
{
var maxTime = Time == -1 ? t.MaxTimer : Time;
Expand Down Expand Up @@ -167,7 +167,6 @@ public static void resetKillButton(PlayerControl p, float time = -1)
vampireKillButton.Timer = time == -1 ? vampireKillButton.MaxTimer : time;
sheriffKillButton.Timer = time == -1 ? sheriffKillButton.MaxTimer : time;
jackalKillButton.Timer = time == -1 ? jackalKillButton.MaxTimer : time;
sidekickKillButton.Timer = time == -1 ? sidekickKillButton.MaxTimer : time;
swooperKillButton.Timer = time == -1 ? swooperKillButton.MaxTimer : time;
werewolfKillButton.Timer = time == -1 ? werewolfKillButton.MaxTimer : time;
juggernautKillButton.Timer = time == -1 ? juggernautKillButton.MaxTimer : time;
Expand Down Expand Up @@ -278,8 +277,8 @@ public void Update()
if (hotkey.HasValue && Input.GetKeyDown(hotkey.Value)) onClickEvent();

// Deputy disable the button and display Handcuffs instead...
if (Deputy.handcuffedPlayers.Contains(localPlayer.PlayerId))
OnClick = () => { Deputy.setHandcuffedKnows(); };
if (Sheriff.handcuffedPlayers.Contains(localPlayer.PlayerId))
OnClick = () => { Sheriff.setHandcuffedKnows(); };
else // Reset.
OnClick = InitialOnClick;
}
Expand Down
50 changes: 32 additions & 18 deletions TheOtherRoles/Helper/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public static bool hasFakeTasks(this PlayerControl player)
player == Lawyer.lawyer ||
player == Executioner.executioner ||
player == Vulture.vulture ||
player == Jackal.sidekick ||
player == Jackal.Sidekick ||
player == Pavlovsdogs.pavlovsowner ||
Jackal.jackal.Any(x => x == player) ||
Pursuer.Player.Any(x => x == player) ||
Expand All @@ -110,8 +110,8 @@ public static bool killingCrewAlive()
// This functions blocks the game from ending if specified crewmate roles are alive
if (!CustomOptionHolder.blockGameEnd.GetBool()) return false;

if (isRoleAlive(Sheriff.sheriff)) powerCrewAlive = true;
if (isRoleAlive(Deputy.deputy)) powerCrewAlive = true;
if (Sheriff.Player.Any(x => x.IsAlive())) powerCrewAlive = true;
if (isRoleAlive(Sheriff.Deputy)) powerCrewAlive = true;
if (isRoleAlive(Veteran.veteran)) powerCrewAlive = true;
if (isRoleAlive(Mayor.mayor)) powerCrewAlive = true;
if (isRoleAlive(Swapper.swapper)) powerCrewAlive = true;
Expand All @@ -128,7 +128,7 @@ public static bool hasImpVision(GameData.PlayerInfo player)
{
return player.Role.IsImpostor
|| (Jackal.jackal.Any(p => p.PlayerId == player.PlayerId) && Jackal.hasImpostorVision)
|| (Jackal.sidekick != null && Jackal.sidekick.PlayerId == player.PlayerId && Jackal.hasImpostorVision)
|| (Jackal.Sidekick != null && Jackal.Sidekick.PlayerId == player.PlayerId && Jackal.hasImpostorVision)
|| (Pavlovsdogs.pavlovsowner != null && Pavlovsdogs.pavlovsowner.PlayerId == player.PlayerId && Pavlovsdogs.hasImpostorVision)
|| (Pavlovsdogs.pavlovsdogs.Any(p => p.PlayerId == player.PlayerId) && Pavlovsdogs.hasImpostorVision)
|| (Spy.spy != null && Spy.spy.PlayerId == player.PlayerId && Spy.hasImpostorVision)
Expand Down Expand Up @@ -169,7 +169,7 @@ public static bool roleCanUseVents(this PlayerControl player)
{
roleCouldUse = true;
}
else if (Jackal.canUseVents && Jackal.sidekick != null && Jackal.sidekick == player)
else if (Jackal.canUseVents && Jackal.Sidekick != null && Jackal.Sidekick == player)
{
roleCouldUse = true;
}
Expand Down Expand Up @@ -255,7 +255,7 @@ public static bool isKillerNeutral(PlayerControl player)
player == Swooper.swooper ||
player == Arsonist.arsonist ||
player == Pelican.Player ||
player == Jackal.sidekick ||
player == Jackal.Sidekick ||
player == Pavlovsdogs.pavlovsowner ||
Jackal.jackal.Contains(player) ||
Pavlovsdogs.pavlovsdogs.Contains(player));
Expand All @@ -272,16 +272,17 @@ public static bool isEvilNeutral(PlayerControl player)

public static bool isKiller(this PlayerControl player)
{
return player != null && (player.Data.Role.IsImpostor || isKillerNeutral(player));
return player != null && (player.isImpostor() || isKillerNeutral(player));
}

public static bool isCrew(this PlayerControl player)
{
return player != null && !player.Data.Role.IsImpostor && !isNeutral(player);
}

public static bool isImpostor(this PlayerControl player)
public static bool isImpostor(this PlayerControl player, bool Spy = false)
{
if (Spy && Roles.Crewmate.Spy.spy != null && Roles.Crewmate.Spy.spy == player) return true;
return player != null && player.Data.Role.IsImpostor;
}

Expand Down Expand Up @@ -337,7 +338,7 @@ public static bool roleCanSabotage(this PlayerControl player)
{
var roleCouldUse = false;
if (ModOption.disableSabotage) return false;
if (Jackal.canSabotage && (Jackal.jackal.Contains(player) || player == Jackal.sidekick) && !ModOption.disableSabotage)
if (Jackal.canSabotage && (Jackal.jackal.Contains(player) || player == Jackal.Sidekick) && !ModOption.disableSabotage)
roleCouldUse = true;
if (Pavlovsdogs.canSabotage && (player == Pavlovsdogs.pavlovsowner || Pavlovsdogs.pavlovsdogs.Any(p => p == player)) && !ModOption.disableSabotage)
roleCouldUse = true;
Expand Down Expand Up @@ -583,6 +584,17 @@ 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)
{
if (list == null || item == null) return false;
try
{
list.AddItem(item);
return true;
}
catch { return false; }
}

public static TKey GetKeyByValue<TKey, TValue>(this Dictionary<TKey, TValue> dictionary, TValue value, TKey defaultvalue = default)
{
foreach (var pair in dictionary)
Expand Down Expand Up @@ -647,8 +659,9 @@ public static List<RoleInfo> onlineRoleInfos()
return role;
}

public static PlayerControl playerById(byte id)
public static PlayerControl playerById(byte? id)
{
if (id == null) return null;
foreach (PlayerControl player in CachedPlayer.AllPlayers)
if (player.PlayerId == id)
return player;
Expand Down Expand Up @@ -935,14 +948,14 @@ public static bool hidePlayerName(PlayerControl source, PlayerControl target)
if ((source == Lovers.lover1 || source == Lovers.lover2) &&
(target == Lovers.lover1 || target == Lovers.lover2))
return false; // Members of team Lovers see the names of each other
if ((Jackal.jackal.Any(p => p == source) || source == Jackal.sidekick)
&& (Jackal.jackal.Any(p => p == target) || target == Jackal.sidekick))
if ((Jackal.jackal.Any(p => p == source) || source == Jackal.Sidekick)
&& (Jackal.jackal.Any(p => p == target) || target == Jackal.Sidekick))
return false; // Members of team Jackal see the names of each other
if ((source == Pavlovsdogs.pavlovsowner || Pavlovsdogs.pavlovsdogs.Any(x => x == target))
&& (target == Pavlovsdogs.pavlovsowner || Pavlovsdogs.pavlovsdogs.Any(x => x == target)))
return false;
if (Deputy.knowsSheriff && (source == Sheriff.sheriff || source == Deputy.deputy) &&
(target == Sheriff.sheriff || target == Deputy.deputy))
if (Sheriff.knowsSheriff && (Sheriff.Player.Any(x => x == source) || source == Sheriff.Deputy) &&
(Sheriff.Player.Any(x => x == target) || target == Sheriff.Deputy))
return false; // Sheriff & Deputy see the names of each other
return true;
}
Expand Down Expand Up @@ -1015,6 +1028,7 @@ public static void showFlash(Color color, float duration = 1f, string message =
{
if (FastDestroyableSingleton<HudManager>.Instance == null ||
FastDestroyableSingleton<HudManager>.Instance.FullScreen == null) return;
if (Grenadier.controls.ToList().Any(x => x == PlayerControl.LocalPlayer)) return;
FastDestroyableSingleton<HudManager>.Instance.FullScreen.gameObject.SetActive(true);
FastDestroyableSingleton<HudManager>.Instance.FullScreen.enabled = true;
// Message Text
Expand Down Expand Up @@ -1043,9 +1057,9 @@ public static void showFlash(Color color, float duration = 1f, string message =
})));
}

// From TownOfUs-R
public static IEnumerator showFlashCoroutine(Color color, float waitfor = 1f, float alpha = 0.3f)
{
if (Grenadier.controls.ToList().Any(x => x == PlayerControl.LocalPlayer)) yield return null;
color.a = alpha;
if (HudManager.InstanceExists && HudManager.Instance.FullScreen)
{
Expand All @@ -1068,11 +1082,11 @@ public static IEnumerator showFlashCoroutine(Color color, float waitfor = 1f, fl
}
}

public static Il2CppSystem.Collections.Generic.List<PlayerControl> GetClosestPlayers(Vector2 truePosition, float radius, bool includeDead)
public static List<PlayerControl> GetClosestPlayers(Vector2 truePosition, float radius, bool includeDead)
{
Il2CppSystem.Collections.Generic.List<PlayerControl> playerControlList = new Il2CppSystem.Collections.Generic.List<PlayerControl>();
List<PlayerControl> playerControlList = new List<PlayerControl>();
float lightRadius = radius * ShipStatus.Instance.MaxLightRadius;
Il2CppSystem.Collections.Generic.List<GameData.PlayerInfo> allPlayers = GameData.Instance.AllPlayers;
List<GameData.PlayerInfo> allPlayers = GameData.Instance.AllPlayers.ToList();
for (int index = 0; index < allPlayers.Count; ++index)
{
GameData.PlayerInfo playerInfo = allPlayers[index];
Expand Down
2 changes: 1 addition & 1 deletion TheOtherRoles/Helper/LogHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ internal static void SetLogSource(ManualLogSource Source)
public static void SendLog(string text, string tag = "", LogLevel logLevel = LogLevel.Info)
{
string time = DateTime.Now.ToString("HH:mm:ss");
if (!string.IsNullOrWhiteSpace(tag)) text = $"[{time}][{tag}] {text}";
if (!string.IsNullOrWhiteSpace(tag)) text = $"[{time}] [{tag}] {text}";
else text = $"[{time}] {text}";

switch (logLevel)
Expand Down
4 changes: 2 additions & 2 deletions TheOtherRoles/Options/CustomOptionHolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1066,7 +1066,7 @@ public static void Load()
thiefSpawnRate = Create(20240, Types.Neutral, cs(Thief.color, "Thief"), rates, null, true);
thiefCooldown = Create(20241, Types.Neutral, "thiefCooldown", 25f, 5f, 120f, 2.5f, thiefSpawnRate);
thiefCanKillSheriff = Create(20242, Types.Neutral, $"{"thiefCanKill".Translate()}{cs(Sheriff.color, "Sheriff".Translate())}", true, thiefSpawnRate);
thiefCanKillDeputy = Create(20246, Types.Neutral, $"{"thiefCanKill".Translate()}{cs(Deputy.color, "Deputy".Translate())}", true, thiefSpawnRate);
thiefCanKillDeputy = Create(20246, Types.Neutral, $"{"thiefCanKill".Translate()}{cs(Sheriff.color, "Deputy".Translate())}", true, thiefSpawnRate);
thiefCanKillVeteran = Create(20247, Types.Neutral, $"{"thiefCanKill".Translate()}{cs(Veteran.color, "Veteran".Translate())}", true, thiefSpawnRate);
thiefHasImpVision = Create(20243, Types.Neutral, "thiefHasImpVision", true, thiefSpawnRate);
thiefCanUseVents = Create(20244, Types.Neutral, "thiefCanUseVents", true, thiefSpawnRate);
Expand Down Expand Up @@ -1098,7 +1098,7 @@ public static void Load()
sheriffCanKillDoomsayer = Create(30159, Types.Crewmate, $"{"sheriffCanKill".Translate()}{cs(Doomsayer.color, "Doomsayer".Translate())}", true, sheriffCanKillNeutrals);
sheriffCanKillThief = Create(30157, Types.Crewmate, $"{"sheriffCanKill".Translate()}{cs(Thief.color, "Thief".Translate())}", true, sheriffCanKillNeutrals);

deputySpawnRate = Create(30170, Types.Crewmate, cs(Deputy.color, "deputySpawnRate"), rates, sheriffSpawnRate);
deputySpawnRate = Create(30170, Types.Crewmate, cs(Sheriff.color, "deputySpawnRate"), rates, sheriffSpawnRate);
deputyNumberOfHandcuffs = Create(30171, Types.Crewmate, "deputyNumberOfHandcuffs", 5f, 1f, 15f, 1f, deputySpawnRate);
deputyHandcuffCooldown = Create(30172, Types.Crewmate, "deputyHandcuffCooldown", 20f, 10f, 60f, 2.5f, deputySpawnRate);
deputyHandcuffDuration = Create(30173, Types.Crewmate, "deputyHandcuffDuration", 10f, 5f, 60f, 2.5f, deputySpawnRate);
Expand Down
2 changes: 1 addition & 1 deletion TheOtherRoles/Options/CustomOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,7 @@ private static string buildOptionsOfType(CustomOptionType type, bool headerOnly)
else if (option.parent.GetSelection() > 0)
{
if (option.id == 30170) //Deputy
sb.AppendLine($"- {cs(Deputy.color, "Deputy".Translate())}: {option.GetString()}");
sb.AppendLine($"- {cs(Sheriff.color, "Deputy".Translate())}: {option.GetString()}");
else if (option.id == 20142)
sb.AppendLine($"- {cs(Jackal.color, "jackalSwoopChance".Translate())}: {option.GetString()}");
else if (option.id == 20135) //Sidekick
Expand Down
30 changes: 15 additions & 15 deletions TheOtherRoles/Patches/EndGamePatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public static void Postfix(AmongUsClient __instance, [HarmonyArgument(0)] ref En
notWinners.AddRange(new[]
{
Jester.jester,
Jackal.sidekick,
Jackal.Sidekick,
Arsonist.arsonist,
Swooper.swooper,
Vulture.vulture,
Expand Down Expand Up @@ -197,18 +197,18 @@ public static void Postfix(AmongUsClient __instance, [HarmonyArgument(0)] ref En
var loversWin = Lovers.existingAndAlive() && (gameOverReason == (GameOverReason)CustomGameOverReason.LoversWin ||
(GameManager.Instance.DidHumansWin(gameOverReason) && !Lovers.existingWithKiller()));
var teamJackalWin = gameOverReason == (GameOverReason)CustomGameOverReason.TeamJackalWin &&
(Jackal.jackal.Any(x => x.IsAlive()) || Jackal.sidekick.IsAlive());
(Jackal.jackal.Any(x => x.IsAlive()) || Jackal.Sidekick.IsAlive());
var teamPavlovsWin = gameOverReason == (GameOverReason)CustomGameOverReason.TeamPavlovsWin &&
(Pavlovsdogs.pavlovsowner.IsAlive() || Pavlovsdogs.pavlovsdogs.Any(p => p.IsAlive()));
var crewmateWin = GameManager.Instance.DidHumansWin(gameOverReason) ||
(gameOverReason is GameOverReason.HumansByVote or GameOverReason.HumansByTask);
var vultureWin = Vulture.vulture != null && gameOverReason == (GameOverReason)CustomGameOverReason.VultureWin;
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() &&
(Akujo.honmeiOptimizeWin
? !Akujo.existingWithKiller() &&
(gameOverReason == (GameOverReason)CustomGameOverReason.AkujoWin || GameManager.Instance.DidHumansWin(gameOverReason))
: gameOverReason == (GameOverReason)CustomGameOverReason.AkujoWin);
bool isPursurerLose = jesterWin || arsonistWin || miniLose || isCanceled || executionerWin;
var akujoWin = Akujo.akujo.IsAlive() && Akujo.honmei.IsAlive() && (gameOverReason == (GameOverReason)CustomGameOverReason.AkujoWin ||
(GameManager.Instance.DidHumansWin(gameOverReason) && Akujo.honmeiOptimizeWin && !Akujo.existingWithKiller()));

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

// Mini lose
if (miniLose)
Expand Down Expand Up @@ -321,9 +321,9 @@ public static void Postfix(AmongUsClient __instance, [HarmonyArgument(0)] ref En
TempData.winners.Add(wpdFormerJackal);
}
// If there is a sidekick. The sidekick also wins
if (Jackal.sidekick != null)
if (Jackal.Sidekick != null)
{
var wpdSidekick = new WinningPlayerData(Jackal.sidekick.Data);
var wpdSidekick = new WinningPlayerData(Jackal.Sidekick.Data);
wpdSidekick.IsImpostor = false;
TempData.winners.Add(wpdSidekick);
}
Expand Down Expand Up @@ -402,8 +402,7 @@ public static void Postfix(AmongUsClient __instance, [HarmonyArgument(0)] ref En
// Swooper wins if nobody except jackal is alive
AdditionalTempData.winCondition = WinCondition.SwooperWin;
TempData.winners = new Il2CppSystem.Collections.Generic.List<WinningPlayerData>();
var wpd = new WinningPlayerData(Swooper.swooper.Data);
wpd.IsImpostor = false;
var wpd = new WinningPlayerData(Swooper.swooper.Data) { IsImpostor = false };
TempData.winners.Add(wpd);
}

Expand Down Expand Up @@ -494,7 +493,8 @@ public static void Postfix(AmongUsClient __instance, [HarmonyArgument(0)] ref En
AdditionalTempData.additionalWinConditions.Add(WinCondition.AdditionalAliveSurvivorWin);
}

if (PartTimer.partTimer != null && PartTimer.target != null && TempData.winners.ToArray().Any(x => x.PlayerName == PartTimer.target.Data.PlayerName))
if (PartTimer.partTimer != null && PartTimer.target != null &&
TempData.winners.ToArray().Any(x => x.PlayerName == PartTimer.target.Data.PlayerName))
{
TempData.winners.Add(new WinningPlayerData(PartTimer.partTimer.Data));
AdditionalTempData.additionalWinConditions.Add(WinCondition.AdditionalPartTimerWin);
Expand Down Expand Up @@ -564,7 +564,7 @@ public static void Postfix(EndGameManager __instance)
{ WinCondition.JesterWin, (Jester.color, "JesterWin") },
{ WinCondition.DoomsayerWin, (Doomsayer.color, "DoomsayerWin") },
{ WinCondition.ArsonistWin, (Arsonist.color, "ArsonistWin") },
{ WinCondition.PelicanWin, (Arsonist.color, "鹈鹕胜利!") },
{ WinCondition.PelicanWin, (Pelican.color, "PelicanWin") },
{ WinCondition.VultureWin, (Vulture.color, "VultureWin") },
{ WinCondition.LawyerSoloWin, (Lawyer.color, "LawyerSoloWin") },
{ WinCondition.WerewolfWin, (Werewolf.color, "WerewolfWin") },
Expand Down Expand Up @@ -1141,7 +1141,7 @@ private void GetPlayerCounts()
if (lover) jackalLover = true;
}

if (Jackal.sidekick != null && Jackal.sidekick.PlayerId == playerInfo.PlayerId)
if (Jackal.Sidekick != null && Jackal.Sidekick.PlayerId == playerInfo.PlayerId)
{
numJackalAlive++;
if (lover) jackalLover = true;
Expand Down
Loading

0 comments on commit 56edf7c

Please sign in to comment.