Skip to content

Commit

Permalink
Update v1.1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mxyx0412 committed Dec 4, 2024
1 parent b75000c commit 9473db3
Show file tree
Hide file tree
Showing 39 changed files with 1,715 additions and 1,132 deletions.
Binary file modified Strings.xlsx
Binary file not shown.
120 changes: 85 additions & 35 deletions TheOtherRoles/Buttons/Buttons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ internal static class HudManagerStartPatch
private static CustomButton deputyHandcuffButton;
public static CustomButton timeMasterShieldButton;
private static CustomButton amnisiacRememberButton;
private static CustomButton specterRememberButton;
public static CustomButton veteranAlertButton;
public static CustomButton medicShieldButton;
private static CustomButton shifterShiftButton;
Expand Down Expand Up @@ -179,6 +180,7 @@ public static void setCustomButtonCooldowns()
arsonistButton.MaxTimer = Arsonist.cooldown;
vultureEatButton.MaxTimer = Vulture.cooldown;
amnisiacRememberButton.MaxTimer = defaultMaxTimer;
specterRememberButton.MaxTimer = defaultMaxTimer;
grenadierFlashButton.MaxTimer = Grenadier.cooldown;
bomberGiveButton.MaxTimer = 0f;
bomberGiveButton.Timer = 0f;
Expand Down Expand Up @@ -447,15 +449,10 @@ public static void createButtonsPostfix(HudManager __instance)
engineerRepairButton = new CustomButton(
() =>
{
engineerRepairButton.Timer = 0f;
var usedRepairWriter = StartRPC(CachedPlayer.LocalPlayer.PlayerControl, CustomRPC.EngineerUsedRepair);
usedRepairWriter.EndRPC();
RPCProcedure.engineerUsedRepair();
SoundEffectsManager.play("engineerRepair");
foreach (var task in CachedPlayer.LocalPlayer.PlayerControl.myTasks.GetFastEnumerator())
if (task.TaskType == TaskTypes.FixLights)
{
var writer = StartRPC(CachedPlayer.LocalPlayer.PlayerControl.NetId, CustomRPC.EngineerFixLights);
var writer = StartRPC(CachedPlayer.LocalPlayer.PlayerControl.NetId, CustomRPC.FixLights);
writer.EndRPC();
RPCProcedure.FixLights();
}
Expand Down Expand Up @@ -484,10 +481,13 @@ public static void createButtonsPostfix(HudManager __instance)
}
else if (SubmergedCompatibility.IsSubmerged && task.TaskType == SubmergedCompatibility.RetrieveOxygenMask)
{
var writer = StartRPC(CachedPlayer.LocalPlayer.PlayerControl, CustomRPC.EngineerFixSubmergedOxygen);
var writer = StartRPC(CachedPlayer.LocalPlayer.PlayerControl, CustomRPC.FixSubmergedOxygen);
writer.EndRPC();
RPCProcedure.FixSubmergedOxygen();
}
SoundEffectsManager.play("engineerRepair");
Engineer.remainingFixes--;
engineerRepairButton.Timer = 0f;
},
() =>
{
Expand All @@ -496,14 +496,7 @@ public static void createButtonsPostfix(HudManager __instance)
},
() =>
{
var sabotageActive = false;
foreach (var task in CachedPlayer.LocalPlayer.PlayerControl.myTasks.GetFastEnumerator())
if (task.TaskType == TaskTypes.FixLights || task.TaskType == TaskTypes.RestoreOxy ||
task.TaskType == TaskTypes.ResetReactor || task.TaskType == TaskTypes.ResetSeismic ||
task.TaskType == TaskTypes.FixComms || task.TaskType == TaskTypes.StopCharles
|| (SubmergedCompatibility.IsSubmerged && task.TaskType == SubmergedCompatibility.RetrieveOxygenMask))
sabotageActive = true;
return sabotageActive && Engineer.remainingFixes > 0 && CachedPlayer.LocalPlayer.PlayerControl.CanMove;
return isSabotageActive() && Engineer.remainingFixes > 0 && CachedPlayer.LocalPlayer.PlayerControl.CanMove;
},
() =>
{
Expand All @@ -519,12 +512,10 @@ public static void createButtonsPostfix(HudManager __instance)
ghostEngineerButton = new CustomButton(
() =>
{
ghostEngineerButton.Timer = 0f;
SoundEffectsManager.play("engineerRepair");
foreach (var task in CachedPlayer.LocalPlayer.PlayerControl.myTasks.GetFastEnumerator())
if (task.TaskType == TaskTypes.FixLights)
{
var writer = StartRPC(CachedPlayer.LocalPlayer.PlayerControl, CustomRPC.EngineerFixLights);
var writer = StartRPC(CachedPlayer.LocalPlayer.PlayerControl, CustomRPC.FixLights);
writer.EndRPC();
RPCProcedure.FixLights();
}
Expand Down Expand Up @@ -553,26 +544,22 @@ public static void createButtonsPostfix(HudManager __instance)
}
else if (SubmergedCompatibility.IsSubmerged && task.TaskType == SubmergedCompatibility.RetrieveOxygenMask)
{
var writer = StartRPC(CachedPlayer.LocalPlayer.PlayerControl, CustomRPC.EngineerFixSubmergedOxygen);
var writer = StartRPC(CachedPlayer.LocalPlayer.PlayerControl, CustomRPC.FixSubmergedOxygen);
writer.EndRPC();
RPCProcedure.FixSubmergedOxygen();
}
GhostEngineer.Fixes = true;
ghostEngineerButton.Timer = 0f;
SoundEffectsManager.play("engineerRepair");
},
() =>
{
return GhostEngineer.player != null && GhostEngineer.player == CachedPlayer.LocalPlayer.PlayerControl &&
!GhostEngineer.Fixes && CachedPlayer.LocalPlayer.Data.IsDead;
!GhostEngineer.Fixes && CachedPlayer.LocalPlayer.Data.IsDead && !GhostEngineer.Fixes;
},
() =>
{
var sabotageActive = false;
foreach (var task in CachedPlayer.LocalPlayer.PlayerControl.myTasks.GetFastEnumerator())
if (task.TaskType == TaskTypes.FixLights || task.TaskType == TaskTypes.RestoreOxy ||
task.TaskType == TaskTypes.ResetReactor || task.TaskType == TaskTypes.ResetSeismic ||
task.TaskType == TaskTypes.FixComms || task.TaskType == TaskTypes.StopCharles
|| (SubmergedCompatibility.IsSubmerged && task.TaskType == SubmergedCompatibility.RetrieveOxygenMask))
sabotageActive = true;
return sabotageActive && Engineer.remainingFixes > 0 && CachedPlayer.LocalPlayer.PlayerControl.CanMove;
return isSabotageActive() && GhostEngineer.Fixes && CachedPlayer.LocalPlayer.PlayerControl.CanMove;
},
() => { },
Engineer.buttonSprite,
Expand Down Expand Up @@ -2170,7 +2157,7 @@ public static void createButtonsPostfix(HudManager __instance)

writer.Write(0.01f);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCProcedure.Mine(id, Miner.miner, buff, 0.01f);
RPCProcedure.Mine(id, buff, 0.01f);
},
() =>
{
Expand Down Expand Up @@ -3217,15 +3204,15 @@ public static void createButtonsPostfix(HudManager __instance)
SendOption.Reliable);
writer.Write(playerInfo.PlayerId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCProcedure.amnisiacTakeRole(playerInfo.PlayerId);
Amnisiac.TakeRole(playerInfo.PlayerId, PlayerControl.LocalPlayer.PlayerId);
break;
}
}
}
},
() =>
{
return Amnisiac.amnisiac != null && Amnisiac.amnisiac == CachedPlayer.LocalPlayer.PlayerControl &&
return Amnisiac.amnisiac != null && Amnisiac.amnisiac.Any(x => x == CachedPlayer.LocalPlayer.PlayerControl) &&
!CachedPlayer.LocalPlayer.Data.IsDead;
},
() =>
Expand All @@ -3241,6 +3228,65 @@ public static void createButtonsPostfix(HudManager __instance)
buttonText: GetString("RememberText")
);

specterRememberButton = new CustomButton(
() => { },
() =>
{
return Specter.player != null && Specter.player == CachedPlayer.LocalPlayer.PlayerControl &&
CachedPlayer.LocalPlayer.Data.IsDead & Specter.remember;
},
() =>
{
var array = Physics2D.OverlapCircleAll(CachedPlayer.LocalPlayer.PlayerControl.GetTruePosition(),
CachedPlayer.LocalPlayer.PlayerControl.MaxReportDistance * 0.36f,
Constants.PlayersOnlyMask).Where(collider => collider.tag == "DeadBody")
.Select(collider => collider.GetComponent<DeadBody>())
.Where(deadBody => deadBody != null);

return array.Any(db => db.ParentId != CachedPlayer.LocalId) && PlayerControl.LocalPlayer.CanMove;
},
() =>
{
Specter.remember = true;
specterRememberButton.Timer = 10f;
},
Amnisiac.buttonSprite,
ButtonPositions.upperRowCenter,
__instance,
abilityInput.keyCode,
true,
2f,
() =>
{
foreach (var collider2D in Physics2D.OverlapCircleAll(CachedPlayer.LocalPlayer.PlayerControl.GetTruePosition(),
CachedPlayer.LocalPlayer.PlayerControl.MaxReportDistance, Constants.PlayersOnlyMask))
if (collider2D.tag == "DeadBody")
{
var component = collider2D.GetComponent<DeadBody>();
if (component && !component.Reported)
{
var truePosition = CachedPlayer.LocalPlayer.PlayerControl.GetTruePosition();
var truePosition2 = component.TruePosition;
if (Vector2.Distance(truePosition2, truePosition) <=
CachedPlayer.LocalPlayer.PlayerControl.MaxReportDistance &&
CachedPlayer.LocalPlayer.PlayerControl.CanMove &&
!PhysicsHelpers.AnythingBetween(truePosition, truePosition2,
Constants.ShipAndObjectsMask, false))
{
var playerInfo = GameData.Instance.GetPlayerById(component.ParentId);
PlayerControl.LocalPlayer.transform.position = component.transform.position;
var writer = StartRPC(CachedPlayer.LocalPlayer.PlayerControl, CustomRPC.SpecterTakeRole);
writer.Write(playerInfo.PlayerId);
writer.EndRPC();
Specter.TakeRole(playerInfo.PlayerId);
break;
}
}
}
},
buttonText: GetString("SpecterButton")
);

// Medium button
mediumButton = new CustomButton(
() =>
Expand Down Expand Up @@ -3901,12 +3947,11 @@ public static void createButtonsPostfix(HudManager __instance)
if (Terrorist.selfExplosion)
{
var loacl = Terrorist.terrorist.PlayerId;
var writer1 = AmongUsClient.Instance.StartRpcImmediately(Terrorist.terrorist.NetId,
(byte)CustomRPC.UncheckedMurderPlayer, SendOption.Reliable);
var writer1 = StartRPC(Terrorist.terrorist, CustomRPC.UncheckedMurderPlayer);
writer1.Write(loacl);
writer1.Write(loacl);
writer1.Write(byte.MaxValue);
AmongUsClient.Instance.FinishRpcImmediately(writer1);
writer1.EndRPC();
RPCProcedure.uncheckedMurderPlayer(loacl, loacl, byte.MaxValue);
}

Expand Down Expand Up @@ -4006,13 +4051,18 @@ public static void createButtonsPostfix(HudManager __instance)
Thief.thief.clearAllTasks();
}

if (result is MurderAttemptResult.ReverseKill or MurderAttemptResult.BodyGuardKill)
{
checkMurderAttemptAndKill(CachedPlayer.LocalPlayer.PlayerControl, target);
}

// Steal role if survived.
if (!Thief.thief.Data.IsDead && result == MurderAttemptResult.PerformKill)
{
var writer = StartRPC(CachedPlayer.LocalPlayer.PlayerControl.NetId, CustomRPC.ThiefStealsRole);
writer.Write(target.PlayerId);
writer.EndRPC();
RPCProcedure.thiefStealsRole(target.PlayerId);
Thief.StealsRole(target.PlayerId);
}

// Kill the victim (after becoming their role - so that no win is triggered for other teams)
Expand Down
2 changes: 2 additions & 0 deletions TheOtherRoles/Buttons/CustomButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ public static void ResetAllCooldowns(float Time = -1)
Error($"NullReferenceException from MeetingEndedUpdate().HasButton(), if theres only one warning its fine\n{e}", "CustomButton");
}
}
var time = Time == -1 ? ModOption.KillCooddown : Time;
CachedPlayer.LocalPlayer.PlayerControl.killTimer = time;
}

/// <summary>
Expand Down
28 changes: 16 additions & 12 deletions TheOtherRoles/Helper/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ public enum LogLevel
public static class Helpers
{
public static bool zoomOutStatus;

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;
Expand All @@ -90,6 +89,7 @@ public static class Helpers
/// </summary>
public static bool hasFakeTasks(this PlayerControl player)
{
if (player == Specter.player) return false;
return player == Werewolf.werewolf ||
player == Doomsayer.doomsayer ||
player == Juggernaut.juggernaut ||
Expand All @@ -98,6 +98,7 @@ public static bool hasFakeTasks(this PlayerControl player)
player == Jackal.jackal ||
player == Sidekick.sidekick ||
player == Pavlovsdogs.pavlovsowner ||
player == Witness.player ||
player == PartTimer.partTimer ||
player == Akujo.akujo ||
player == Swooper.swooper ||
Expand Down Expand Up @@ -253,7 +254,7 @@ public static bool checkAndDoVetKill(PlayerControl target)
public static bool isNeutral(PlayerControl player)
{
var roleInfo = RoleInfo.getRoleInfoForPlayer(player, false).FirstOrDefault();
return roleInfo != null && roleInfo.roleTeam == RoleType.Neutral;
return roleInfo != null && roleInfo.roleType == RoleType.Neutral;
}

public static bool isKillerNeutral(PlayerControl player)
Expand All @@ -272,8 +273,8 @@ public static bool isKillerNeutral(PlayerControl player)
public static bool isEvilNeutral(PlayerControl player)
{
return isNeutral(player) &&
player != Amnisiac.amnisiac &&
player != PartTimer.partTimer &&
!Amnisiac.amnisiac.Contains(player) &&
!Pursuer.pursuer.Contains(player) &&
!Survivor.survivor.Contains(player);
}
Expand Down Expand Up @@ -630,7 +631,7 @@ public static List<RoleInfo> allRoleInfos()
var allRoleInfo = new List<RoleInfo>();
foreach (var role in RoleInfo.allRoleInfos)
{
if (role.roleTeam == RoleType.Modifier) continue;
if (role.roleType is RoleType.Modifier or RoleType.GhostRole or RoleType.Special) continue;
allRoleInfo.Add(role);
}
return allRoleInfo;
Expand All @@ -639,7 +640,7 @@ public static List<RoleInfo> allRoleInfos()
public static List<RoleInfo> onlineRoleInfos()
{
var role = new List<RoleInfo>();
role.AddRange(CachedPlayer.AllPlayers.Select(n => RoleInfo.getRoleInfoForPlayer(n, false)).SelectMany(n => n));
role.AddRange(CachedPlayer.AllPlayers.Select(n => RoleInfo.getRoleInfoForPlayer(n, false, false)).SelectMany(x => x));
return role;
}

Expand All @@ -651,12 +652,15 @@ public static PlayerControl playerById(byte id)
return null;
}

public static Dictionary<byte, PlayerControl> allPlayersById()
public static bool isSabotageActive()
{
var res = new Dictionary<byte, PlayerControl>();
foreach (PlayerControl player in CachedPlayer.AllPlayers)
res.Add(player.PlayerId, player);
return res;
foreach (var task in CachedPlayer.LocalPlayer.PlayerControl.myTasks.GetFastEnumerator())
if (task.TaskType == TaskTypes.FixLights || task.TaskType == TaskTypes.RestoreOxy ||
task.TaskType == TaskTypes.ResetReactor || task.TaskType == TaskTypes.ResetSeismic ||
task.TaskType == TaskTypes.FixComms || task.TaskType == TaskTypes.StopCharles
|| (SubmergedCompatibility.IsSubmerged && task.TaskType == SubmergedCompatibility.RetrieveOxygenMask))
return true;
return false;
}

public static void handleVampireBiteOnBodyReport()
Expand Down Expand Up @@ -755,7 +759,7 @@ public static Color getTeamColor(RoleType team)
RoleType.Impostor => Palette.ImpostorRed,
RoleType.Neutral => Color.gray,
RoleType.Modifier => Color.yellow,
RoleType.Special => Palette.Purple,
RoleType.GhostRole => new Color32(159, 127, 209, byte.MaxValue),
_ => Palette.White
};
}
Expand Down Expand Up @@ -1289,7 +1293,7 @@ public static MurderAttemptResult checkMurderAttemptAndKill(PlayerControl killer
CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.MimicMimicRole, SendOption.Reliable);
writerMimic.Write(target.PlayerId);
AmongUsClient.Instance.FinishRpcImmediately(writerMimic);
RPCProcedure.mimicMimicRole(target.PlayerId);
Mimic.MimicRole(target.PlayerId);
}

MurderPlayer(killer, target, showAnimation);
Expand Down
Loading

0 comments on commit 9473db3

Please sign in to comment.