Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try fix murders instantly after meeting #1368

Open
wants to merge 1 commit into
base: dev_2.2.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions Modules/AntiBlackout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,10 @@ private static void ResetAllCooldown()
{
seer.RpcResetAbilityCooldown();
seer.ResetKillCooldown();
seer.SetKillCooldown();

if (Main.AllPlayerKillCooldown.TryGetValue(seer.PlayerId, out var kcd) && kcd >= 2f)
seer.SetKillCooldown(kcd - 2f);
if (Main.AllPlayerKillCooldown.TryGetValue(seer.PlayerId, out var kcd))
seer.SetKillCooldown(kcd + 1f);
}
else if (seer.HasGhostRole())
{
Expand All @@ -315,9 +316,14 @@ private static void ResetAllCooldown()
}
public static void ResetAfterMeeting()
{
SkipTasks = false;
ExilePlayerId = -1;
ResetAllCooldown();

// add 1 second delay
_ = new LateTask(() =>
{
SkipTasks = false;
ExilePlayerId = -1;
}, 1f, "Reset Blackout");
}
public static void Reset()
{
Expand All @@ -333,4 +339,4 @@ public static void Reset()

public static bool ShowExiledInfo = false;
public static string StoreExiledMessage = "";
}
}
5 changes: 5 additions & 0 deletions Modules/ExtendedPlayerControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,11 @@ public static void SetKillCooldown(this PlayerControl player, float time = -1f,
if (!player.HasImpKillButton(considerVanillaShift: true)) return;
if (player.HasImpKillButton(false) && !player.CanUseKillButton()) return;

if (AntiBlackout.SkipTasks)
{
Logger.Info($"player {player.PlayerId} should reset cooldown ({(time >= 0f ? time : Main.AllPlayerKillCooldown[player.PlayerId])}) while AntiBlackout", "SetKillCooldown");
}

player.SetKillTimer(CD: time);
if (target == null) target = player;
if (time >= 0f) Main.AllPlayerKillCooldown[player.PlayerId] = time * 2;
Expand Down
2 changes: 1 addition & 1 deletion Patches/ExilePatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ private static void WrapUpFinalizer(NetworkedPlayerInfo exiled)

AntiBlackout.ResetAfterMeeting();
Main.LastMeetingEnded = Utils.GetTimeStamp();
}, 2f, "Reset Cooldown After Meeting");
}, 1.9f, "Reset Cooldown After Meeting");
}

//This should happen shortly after the Exile Controller wrap up finished for clients
Expand Down
8 changes: 8 additions & 0 deletions Patches/PlayerControlPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,14 @@ public static bool Prefix(PlayerControl __instance, [HarmonyArgument(0)] PlayerC

if (isSucceeded && AmongUsClient.Instance.AmHost && GameStates.IsNormalGame)
{
// AntiBlackOut protect is active
if (AntiBlackout.SkipTasks)
{
Logger.Info("Murder while AntiBlackOut protect, the kill was canceled and reseted", "MurderPlayer");
__instance.SetKillCooldown();
return false;
}

if (target.shapeshifting)
{
// During shapeshift animation
Expand Down
Loading