public static MurderAttemptResult checkMuderAttempt(PlayerControl killer, PlayerControl target, bool blockRewind = false) { // Modified vanilla checks if (AmongUsClient.Instance.IsGameOver) { return(MurderAttemptResult.SuppressKill); } if (killer == null || killer.Data == null || killer.Data.IsDead || killer.Data.Disconnected) { return(MurderAttemptResult.SuppressKill); // Allow non Impostor kills compared to vanilla code } if (target == null || target.Data == null || target.Data.IsDead || target.Data.Disconnected) { return(MurderAttemptResult.SuppressKill); // Allow killing players in vents compared to vanilla code } // Handle blank shot if (Pursuer.blankedList.Any(x => x.PlayerId == killer.PlayerId)) { MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetBlanked, Hazel.SendOption.Reliable, -1); writer.Write(killer.PlayerId); writer.Write((byte)0); AmongUsClient.Instance.FinishRpcImmediately(writer); RPCProcedure.setBlanked(killer.PlayerId, 0); return(MurderAttemptResult.BlankKill); } // Block impostor shielded kill if (Medic.shielded != null && Medic.shielded == target) { MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(killer.NetId, (byte)CustomRPC.ShieldedMurderAttempt, Hazel.SendOption.Reliable, -1); AmongUsClient.Instance.FinishRpcImmediately(writer); RPCProcedure.shieldedMurderAttempt(); return(MurderAttemptResult.SuppressKill); } // Block impostor not fully grown mini kill else if (target.hasModifier(ModifierType.Mini) && !Mini.isGrownUp(target)) { return(MurderAttemptResult.SuppressKill); } // Block Time Master with time shield kill else if (TimeMaster.shieldActive && TimeMaster.timeMaster != null && TimeMaster.timeMaster == target) { if (!blockRewind) // Only rewind the attempt was not called because a meeting startet { MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(killer.NetId, (byte)CustomRPC.TimeMasterRewindTime, Hazel.SendOption.Reliable, -1); AmongUsClient.Instance.FinishRpcImmediately(writer); RPCProcedure.timeMasterRewindTime(); } return(MurderAttemptResult.SuppressKill); } return(MurderAttemptResult.PerformKill); }
public static void MakeButtons(HudManager hm) { // Sheriff Kill sheriffKillButton = new CustomButton( () => { if (local.numShots <= 0) { return; } MurderAttemptResult murderAttemptResult = Helpers.checkMuderAttempt(PlayerControl.LocalPlayer, local.currentTarget); if (murderAttemptResult == MurderAttemptResult.SuppressKill) { return; } if (murderAttemptResult == MurderAttemptResult.PerformKill) { bool misfire = false; byte targetId = local.currentTarget.PlayerId;; if ((local.currentTarget.Data.Role.IsImpostor && (!local.currentTarget.hasModifier(ModifierType.Mini) || Mini.isGrownUp(local.currentTarget))) || (Sheriff.spyCanDieToSheriff && Spy.spy == local.currentTarget) || (Sheriff.madmateCanDieToSheriff && local.currentTarget.hasModifier(ModifierType.Madmate)) || (Sheriff.createdMadmateCanDieToSheriff && local.currentTarget.hasModifier(ModifierType.CreatedMadmate)) || (Sheriff.canKillNeutrals && local.currentTarget.isNeutral()) || (Jackal.jackal == local.currentTarget || Sidekick.sidekick == local.currentTarget)) { //targetId = Sheriff.currentTarget.PlayerId; misfire = false; } else { //targetId = PlayerControl.LocalPlayer.PlayerId; misfire = true; } // Mad sheriff always misfires. if (local.player.hasModifier(ModifierType.Madmate)) { misfire = true; } MessageWriter killWriter = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SheriffKill, Hazel.SendOption.Reliable, -1); killWriter.Write(PlayerControl.LocalPlayer.Data.PlayerId); killWriter.Write(targetId); killWriter.Write(misfire); AmongUsClient.Instance.FinishRpcImmediately(killWriter); RPCProcedure.sheriffKill(PlayerControl.LocalPlayer.Data.PlayerId, targetId, misfire); } sheriffKillButton.Timer = sheriffKillButton.MaxTimer; local.currentTarget = null; }, () => { return(PlayerControl.LocalPlayer.isRole(RoleType.Sheriff) && local.numShots > 0 && !PlayerControl.LocalPlayer.Data.IsDead && local.canKill); }, () => { if (sheriffNumShotsText != null) { if (local.numShots > 0) { sheriffNumShotsText.text = String.Format(ModTranslation.getString("sheriffShots"), local.numShots); } else { sheriffNumShotsText.text = ""; } } return(local.currentTarget && PlayerControl.LocalPlayer.CanMove); }, () => { sheriffKillButton.Timer = sheriffKillButton.MaxTimer; }, hm.KillButton.graphic.sprite, new Vector3(0f, 1f, 0), hm, hm.KillButton, KeyCode.Q ); sheriffNumShotsText = GameObject.Instantiate(sheriffKillButton.actionButton.cooldownTimerText, sheriffKillButton.actionButton.cooldownTimerText.transform.parent); sheriffNumShotsText.text = ""; sheriffNumShotsText.enableWordWrapping = false; sheriffNumShotsText.transform.localScale = Vector3.one * 0.5f; sheriffNumShotsText.transform.localPosition += new Vector3(-0.05f, 0.7f, 0); }