This commit is contained in:
Gurge44 committed 2026-08-25 17:56:49 +02:00
1 parent 4f7ceda998
commit 8ce5b45d04
3 files changed
+37 -20

No files matched your search

+25 -19
View File
@@ -368,8 +368,6 @@ public static class SabotageSystemTypeUpdateSystemPatch
public static bool IsCooldownModificationEnabled;
public static float ModifiedCooldownSec;
public static SabotageSystemType Instance;
public static void Initialize()
{
IsCooldownModificationEnabled = Options.SabotageCooldownControl.GetBool();
@@ -415,7 +413,6 @@ public static class SabotageSystemTypeUpdateSystemPatch
public static bool Prefix(SabotageSystemType __instance, [HarmonyArgument(0)] PlayerControl player, [HarmonyArgument(1)] MessageReader msgReader)
{
Instance = __instance;
if (Options.CurrentGameMode is not (CustomGameMode.Standard or CustomGameMode.Snowdown) || __instance.Timer > 0f) return false;
SystemTypes systemTypes;
@@ -472,11 +469,22 @@ public static class SabotageSystemTypeUpdateSystemPatch
}
catch (Exception e) { Utils.ThrowException(e); }
}
if (QuizMaster.On) QuizMaster.Data.NumSabotages++;
if (Main.CurrentMap == MapNames.Skeld)
LateTask.New(() => DoorsReset.SetDoors(DoorsReset.ResetMode.AllOpen), 1f, "Opening All Doors On Sabotage (Skeld)");
try
{
if (QuizMaster.On) QuizMaster.Data.NumSabotages++;
if (Main.CurrentMap == MapNames.Skeld)
LateTask.New(() => DoorsReset.SetDoors(DoorsReset.ResetMode.AllOpen), 1f, "Opening All Doors On Sabotage (Skeld)");
}
catch { }
try
{
if (Main.PlayerStates.TryGetValue(player.PlayerId, out PlayerState state))
state.Role.OnSabotage(player);
}
catch (Exception e) { Utils.ThrowException(e); }
}
return allowed;
@@ -484,7 +492,7 @@ public static class SabotageSystemTypeUpdateSystemPatch
public static bool CheckSabotage(SabotageSystemType __instance, PlayerControl player, SystemTypes systemTypes)
{
if (__instance.Timer > 0f || !CheckDisabledSabotage(systemTypes) || Stasis.IsTimeFrozen || Pelican.IsEaten(player.PlayerId)) return false;
if (__instance.Timer > 0f || !CheckDisabledSabotage(systemTypes) || Stasis.IsTimeFrozen || TimeMaster.Rewinding || Pelican.IsEaten(player.PlayerId)) return false;
if (systemTypes == SystemTypes.Electrical && Main.PlayerStates.Values.FindFirst(x => !x.IsDead && x.MainRole == CustomRoles.Battery && x.Player && x.Player.GetAbilityUseLimit() >= 1f, out var batteryState))
{
@@ -514,29 +522,27 @@ public static class SabotageSystemTypeUpdateSystemPatch
return false;
}
if (!Rhapsode.CheckAbilityUse(player) || Stasis.IsTimeFrozen || TimeMaster.Rewinding) return false;
if (!Rhapsode.CheckAbilityUse(player)) return false;
if (player.Is(CustomRoles.Trainee) && MeetingStates.FirstMeeting)
{
player.Notify(Translator.GetString("TraineeNotify"));
return false;
}
if (player.Is(CustomRoles.Mischievous)) return true;
if (player.Is(Team.Impostor) && !player.IsAlive() && Options.DeadImpCantSabotage.GetBool()) return false;
if (!player.Is(Team.Impostor) && !player.IsAlive()) return false;
bool allow = player.GetCustomRole() switch
return player.GetCustomRole() switch
{
CustomRoles.Jackal when Jackal.CanSabotage.GetBool() => true,
CustomRoles.Sidekick when Jackal.CanSabotageSK.GetBool() => true,
CustomRoles.Traitor when Traitor.CanSabotage.GetBool() => true,
CustomRoles.Parasite or CustomRoles.Renegade when player.IsAlive() => true,
_ => Main.PlayerStates[player.PlayerId].Role.CanUseSabotage(player) && Main.PlayerStates[player.PlayerId].Role.OnSabotage(player)
_ => Main.PlayerStates.TryGetValue(player.PlayerId, out PlayerState state) && state.Role.CanUseSabotage(player)
};
if (player.Is(CustomRoles.Trainee) && MeetingStates.FirstMeeting)
{
player.Notify(Translator.GetString("TraineeNotify"));
allow = false;
}
return allow;
}
public static bool CheckDisabledSabotage(SystemTypes systemTypes)
+1 -1
View File
@@ -182,7 +182,7 @@ internal static class UpdateSystemPatch
}
case SystemTypes.Sabotage when AmongUsClient.Instance.NetworkMode != NetworkModes.FreePlay:
{
var sabotageSystemType = SabotageSystemTypeUpdateSystemPatch.Instance ?? __instance.Systems[SystemTypes.Sabotage].CastFast<SabotageSystemType>();
var sabotageSystemType = __instance.Systems[SystemTypes.Sabotage].CastFast<SabotageSystemType>();
return SabotageSystemTypeUpdateSystemPatch.CheckSabotage(sabotageSystemType, player, systemType);
}
case SystemTypes.Security when amount == 1:
@@ -6,6 +6,8 @@ public class Evader : RoleBase
public override bool IsEnable => On;
private byte EvaderId;
public override void SetupCustomOption()
{
StartSetup(659800);
@@ -19,5 +21,14 @@ public class Evader : RoleBase
public override void Add(byte playerId)
{
On = true;
EvaderId = playerId;
}
public override void AfterMeetingTasks()
{
if (!Utils.IsAnySabotageActive()) return;
PlayerControl pc = EvaderId.GetPlayer();
if (!pc || !pc.IsAlive()) return;
pc.RpcMakeInvisible();
}
}