diff --git a/Strings.xlsx b/Strings.xlsx index 79ebad9..353dd48 100644 Binary files a/Strings.xlsx and b/Strings.xlsx differ diff --git a/TheOtherRoles/Buttons.cs b/TheOtherRoles/Buttons.cs index 133a0df..1c74130 100644 --- a/TheOtherRoles/Buttons.cs +++ b/TheOtherRoles/Buttons.cs @@ -723,12 +723,7 @@ public static void createButtonsPostfix(HudManager __instance) { // Shifter shift shifterShiftButton = new CustomButton( () => { - if (Veteran.veteran != null && Shifter.currentTarget == Veteran.veteran && Veteran.alertActive && Shifter.isNeutral) - { - Helpers.checkMurderAttemptAndKill(Veteran.veteran, Shifter.shifter); - return; - } - + if (Helpers.checkSuspendAction(Shifter.shifter, Shifter.currentTarget)) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.SetFutureShifted, Hazel.SendOption.Reliable, -1); writer.Write(Shifter.currentTarget.PlayerId); AmongUsClient.Instance.FinishRpcImmediately(writer); @@ -761,11 +756,7 @@ public static void createButtonsPostfix(HudManager __instance) { morphlingButton.shakeOnEnd = true; SoundEffectsManager.play("morphlingMorph"); } else if (Morphling.currentTarget != null) { - if (Morphling.currentTarget == Veteran.veteran && Veteran.alertActive && Veteran.veteran != null) - { - Helpers.checkMurderAttemptAndKill(Veteran.veteran, Morphling.morphling); - return; - } + if (Helpers.checkSuspendAction(Morphling.morphling, Morphling.currentTarget)) return; Morphling.acTokenChallenge.Value.playerId = Morphling.currentTarget.PlayerId; Morphling.acTokenChallenge.Value.kill = false; Morphling.sampledTarget = Morphling.currentTarget; @@ -1033,11 +1024,7 @@ public static void createButtonsPostfix(HudManager __instance) { vampireKillButton = new CustomButton( () => { - if (Veteran.veteran != null && Veteran.alertActive && Veteran.veteran == Vampire.currentTarget) - { - Helpers.checkMurderAttemptAndKill(Veteran.veteran, Vampire.vampire); - return; - } + if (Helpers.checkSuspendAction(Vampire.vampire, Vampire.currentTarget)) return; MurderAttemptResult murder = Helpers.checkMuderAttempt(Vampire.vampire, Vampire.currentTarget); if (murder == MurderAttemptResult.PerformKill) { if (Vampire.targetNearGarlic) { @@ -1305,11 +1292,7 @@ public static void createButtonsPostfix(HudManager __instance) { // Jackal Sidekick Button jackalSidekickButton = new CustomButton( () => { - if (Jackal.currentTarget == Veteran.veteran && Veteran.alertActive && Veteran.veteran != null) - { - Helpers.checkMurderAttemptAndKill(Veteran.veteran, Jackal.jackal); - return; - } + if (Helpers.checkSuspendAction(Jackal.jackal, Jackal.currentTarget)) return; _ = new StaticAchievementToken("jackal.common1"); MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.JackalCreatesSidekick, Hazel.SendOption.Reliable, -1); writer.Write(Jackal.currentTarget.PlayerId); @@ -1511,11 +1494,7 @@ public static void createButtonsPostfix(HudManager __instance) { plagueDoctorButton = new CustomButton( () => { - if (Veteran.veteran != null && PlagueDoctor.currentTarget == Veteran.veteran && Veteran.alertActive) - { - Helpers.checkMurderAttemptAndKill(Veteran.veteran, PlagueDoctor.plagueDoctor); - return; - } + if (Helpers.checkSuspendAction(PlagueDoctor.plagueDoctor, PlagueDoctor.currentTarget)) return; byte targetId = PlagueDoctor.currentTarget.PlayerId; @@ -1558,12 +1537,7 @@ public static void createButtonsPostfix(HudManager __instance) { /* * creates madmate */ - if (Veteran.veteran != null && Veteran.alertActive && Veteran.veteran == EvilHacker.currentTarget) - { - Helpers.checkMurderAttemptAndKill(Veteran.veteran, EvilHacker.evilHacker); - return; - } - + if (Helpers.checkSuspendAction(EvilHacker.evilHacker, EvilHacker.currentTarget)) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.EvilHackerCreatesMadmate, Hazel.SendOption.Reliable, -1); writer.Write(EvilHacker.currentTarget.PlayerId); AmongUsClient.Instance.FinishRpcImmediately(writer); @@ -1626,12 +1600,7 @@ public static void createButtonsPostfix(HudManager __instance) { () => { // Action when Pressed if (Blackmailer.currentTarget != null) { - if (Veteran.veteran != null && Veteran.alertActive && Veteran.veteran == Blackmailer.currentTarget) - { - Helpers.checkMurderAttemptAndKill(Veteran.veteran, Blackmailer.blackmailer); - return; - } - + if (Helpers.checkSuspendAction(Blackmailer.blackmailer, Blackmailer.currentTarget)) return; _ = new StaticAchievementToken("blackmailer.common1"); Blackmailer.acTokenChallenge.Value.cleared |= Blackmailer.acTokenChallenge.Value.witness.Any(x => x == Blackmailer.currentTarget.PlayerId); @@ -1677,11 +1646,7 @@ public static void createButtonsPostfix(HudManager __instance) { // Eraser erase button eraserButton = new CustomButton( () => { - if (Veteran.veteran != null && Veteran.alertActive && Veteran.veteran == Eraser.currentTarget) - { - Helpers.checkMurderAttemptAndKill(Veteran.veteran, Eraser.eraser); - return; - } + if (Helpers.checkSuspendAction(Eraser.eraser, Eraser.currentTarget)) return; eraserButton.MaxTimer += Eraser.cooldownIncrease; eraserButton.Timer = eraserButton.MaxTimer; @@ -1737,11 +1702,7 @@ public static void createButtonsPostfix(HudManager __instance) { { if (Moriarty.currentTarget != null) { - if (Veteran.veteran != null && Veteran.alertActive && Veteran.veteran == Moriarty.currentTarget) - { - Helpers.checkMurderAttemptAndKill(Veteran.veteran, Moriarty.moriarty); - return; - } + if (Helpers.checkSuspendAction(Moriarty.moriarty, Moriarty.currentTarget)) return; _ = new StaticAchievementToken("moriarty.common1"); MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetBrainwash, Hazel.SendOption.Reliable, -1); writer.Write(Moriarty.currentTarget.PlayerId); @@ -1919,12 +1880,7 @@ public static void createButtonsPostfix(HudManager __instance) { warlockCurseButton = new CustomButton( () => { if (Warlock.curseVictim == null) { - if (Veteran.veteran != null && Veteran.alertActive && Veteran.veteran == Warlock.currentTarget) - { - Helpers.checkMurderAttemptAndKill(Veteran.veteran, Warlock.warlock); - return; - } - + if (Helpers.checkSuspendAction(Warlock.warlock, Warlock.currentTarget)) return; // Apply Curse Warlock.curseVictim = Warlock.currentTarget; warlockCurseButton.Sprite = Warlock.getCurseKillButtonSprite(); @@ -2145,11 +2101,7 @@ public static void createButtonsPostfix(HudManager __instance) { RPCProcedure.arsonistWin(); arsonistButton.HasEffect = false; } else if (Arsonist.currentTarget != null) { - if (Veteran.veteran != null && Veteran.veteran == Arsonist.currentTarget && Veteran.alertActive) - { - Helpers.checkMurderAttemptAndKill(Veteran.veteran, Arsonist.arsonist); - return; - } + if (Helpers.checkSuspendAction(Arsonist.arsonist, Arsonist.currentTarget)) return; Arsonist.douseTarget = Arsonist.currentTarget; arsonistButton.HasEffect = true; SoundEffectsManager.play("arsonistDouse"); @@ -2284,11 +2236,7 @@ public static void createButtonsPostfix(HudManager __instance) { // OnClick () => { - if (Veteran.veteran != null && Veteran.alertActive && Veteran.veteran == BomberA.currentTarget) - { - Helpers.checkMurderAttemptAndKill(Veteran.veteran, BomberA.bomberA); - return; - } + if (Helpers.checkSuspendAction(BomberA.bomberA, BomberA.currentTarget)) return; if (BomberA.currentTarget != null) { @@ -2353,11 +2301,7 @@ public static void createButtonsPostfix(HudManager __instance) { // OnClick () => { - if (Veteran.veteran != null && Veteran.alertActive && Veteran.veteran == BomberB.currentTarget) - { - Helpers.checkMurderAttemptAndKill(Veteran.veteran, BomberB.bomberB); - return; - } + if (Helpers.checkSuspendAction(BomberB.bomberB, BomberB.currentTarget)) return; if (BomberB.currentTarget != null) { @@ -2419,11 +2363,7 @@ public static void createButtonsPostfix(HudManager __instance) { // OnClick () => { - if (BomberA.bombTarget == Veteran.veteran && Veteran.veteran != null && Veteran.alertActive) - { - Helpers.checkMurderAttemptAndKill(Veteran.veteran, BomberA.bomberA); - return; - } + if (Helpers.checkSuspendAction(BomberA.bomberA, BomberA.currentTarget)) return; // Use MurderAttempt to exclude eg.Medic shielded MurderAttemptResult attempt = Helpers.checkMuderAttempt(BomberA.bomberA, BomberA.bombTarget); @@ -2477,12 +2417,7 @@ public static void createButtonsPostfix(HudManager __instance) { // OnClick () => { - if (BomberB.bombTarget == Veteran.veteran && Veteran.veteran != null && Veteran.alertActive) - { - Helpers.checkMurderAttemptAndKill(Veteran.veteran, BomberB.bomberB); - return; - } - + if (Helpers.checkSuspendAction(BomberB.bomberB, BomberB.currentTarget)) return; var bomberA = BomberA.bomberA; float distance = Vector2.Distance(CachedPlayer.LocalPlayer.PlayerControl.transform.localPosition, bomberA.transform.localPosition); @@ -2813,11 +2748,7 @@ public static void createButtonsPostfix(HudManager __instance) { cupidArrowButton = new CustomButton( () => { - if (Veteran.veteran != null && Veteran.veteran == Cupid.currentTarget && Veteran.alertActive) - { - Helpers.checkMurderAttemptAndKill(Veteran.veteran, Cupid.currentTarget); - return; - } + if (Helpers.checkSuspendAction(Cupid.cupid, Cupid.currentTarget)) return; if (Cupid.lovers1 == null) { @@ -2865,12 +2796,7 @@ public static void createButtonsPostfix(HudManager __instance) { cupidShieldButton = new CustomButton( () => { - if (Veteran.veteran != null && Cupid.shieldTarget == Veteran.veteran && Veteran.alertActive) - { - Helpers.checkMurderAttemptAndKill(Veteran.veteran, Cupid.cupid); - return; - } - + if (Helpers.checkSuspendAction(Cupid.cupid, Cupid.currentTarget)) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.SetCupidShield, Hazel.SendOption.Reliable, -1); writer.Write(Cupid.shieldTarget.PlayerId); AmongUsClient.Instance.FinishRpcImmediately(writer); @@ -2892,11 +2818,7 @@ public static void createButtonsPostfix(HudManager __instance) { akujoHonmeiButton = new CustomButton( () => { - if (Veteran.veteran != null && Akujo.currentTarget == Veteran.veteran && Veteran.alertActive) - { - Helpers.checkMurderAttemptAndKill(Veteran.veteran, Akujo.akujo); - return; - } + if (Helpers.checkSuspendAction(Akujo.akujo, Akujo.currentTarget)) return; _ = new StaticAchievementToken("akujo.common2"); MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.AkujoSetHonmei, Hazel.SendOption.Reliable, -1); writer.Write(Akujo.akujo.PlayerId); @@ -2930,11 +2852,7 @@ public static void createButtonsPostfix(HudManager __instance) { akujoBackupButton = new CustomButton( () => { - if (Veteran.veteran != null && Akujo.currentTarget == Veteran.veteran && Veteran.alertActive) - { - Helpers.checkMurderAttemptAndKill(Veteran.veteran, Akujo.akujo); - return; - } + if (Helpers.checkSuspendAction(Akujo.akujo, Akujo.currentTarget)) return; _ = new StaticAchievementToken("akujo.common1"); MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.AkujoSetKeep, Hazel.SendOption.Reliable, -1); writer.Write(Akujo.akujo.PlayerId); @@ -3060,7 +2978,6 @@ public static void createButtonsPostfix(HudManager __instance) { ninjaButton.Timer = ninjaButton.MaxTimer = Ninja.stealthCooldown; ninjaButton.actionButton.cooldownTimerText.color = Palette.EnabledColor; ninjaButton.isEffectActive = false; - Ninja.stealthed = false; Ninja.ninja.SetKillTimer(GameOptionsManager.Instance.currentNormalGameOptions.KillCooldown + (Ninja.penalized ? Ninja.killPenalty : 0f)); }, Ninja.getButtonSprite(), @@ -3252,8 +3169,7 @@ public static void createButtonsPostfix(HudManager __instance) { { foxStealthButton.Timer = foxStealthButton.MaxTimer = Fox.stealthCooldown; foxStealthButton.actionButton.cooldownTimerText.color = Palette.EnabledColor; - foxStealthButton.isEffectActive = false; - Fox.stealthed = false; + foxStealthButton.isEffectActive = false; }, Fox.getHideButtonSprite(), CustomButton.ButtonPositions.upperRowCenter, @@ -3342,11 +3258,7 @@ public static void createButtonsPostfix(HudManager __instance) { foxImmoralistButton = new CustomButton( () => { - if (Veteran.veteran != null && Fox.currentTarget == Veteran.veteran && Veteran.alertActive) - { - Helpers.checkMurderAttemptAndKill(Veteran.veteran, Fox.fox); - return; - } + if (Helpers.checkSuspendAction(Fox.fox, Fox.currentTarget)) return; _ = new StaticAchievementToken("fox.common1"); MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.FoxCreatesImmoralist, Hazel.SendOption.Reliable, -1); writer.Write(Fox.currentTarget.PlayerId); @@ -3395,7 +3307,7 @@ public static void createButtonsPostfix(HudManager __instance) { { if (CachedPlayer.LocalPlayer.PlayerControl == SerialKiller.serialKiller) { - SerialKiller.serialKiller.SetKillTimer(SerialKiller.killCooldown); + SerialKiller.serialKiller.SetKillTimerUnchecked(SerialKiller.killCooldown); if (SerialKiller.resetTimer) { serialKillerButton.Timer = SerialKiller.suicideTimer; @@ -3429,11 +3341,7 @@ public static void createButtonsPostfix(HudManager __instance) { // Evil Tracker track evilTrackerButton = new CustomButton( () => { - if (Veteran.veteran != null && EvilTracker.currentTarget == Veteran.veteran && Veteran.alertActive) - { - Helpers.checkMurderAttemptAndKill(Veteran.veteran, EvilTracker.evilTracker); - return; - } + if (Helpers.checkSuspendAction(EvilTracker.evilTracker, EvilTracker.evilTracker)) return; _ = new StaticAchievementToken("evilTracker.common1"); EvilTracker.target = EvilTracker.currentTarget; }, @@ -3794,11 +3702,7 @@ Func fortuneTellerCouldUse(byte index) pursuerButton = new CustomButton( () => { if (Pursuer.target != null) { - if (Pursuer.target == Veteran.veteran && Veteran.alertActive && Veteran.veteran != null) - { - Helpers.checkMurderAttemptAndKill(Veteran.veteran, Pursuer.pursuer); - return; - } + if (Helpers.checkSuspendAction(Pursuer.pursuer, Pursuer.target)) return; if (Pursuer.target.Data.Role.IsImpostor) _ = new StaticAchievementToken("pursuer.common1"); MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.SetBlanked, Hazel.SendOption.Reliable, -1); writer.Write(Pursuer.target.PlayerId); @@ -3836,11 +3740,7 @@ Func fortuneTellerCouldUse(byte index) // Witch Spell button witchSpellButton = new CustomButton( () => { - if (Veteran.veteran != null && Veteran.alertActive && Veteran.veteran == Witch.currentTarget) - { - Helpers.checkMurderAttemptAndKill(Veteran.veteran, Witch.witch); - return; - } + if (Helpers.checkSuspendAction(Witch.witch, Witch.currentTarget)) return; if (Witch.currentTarget != null) { Witch.spellCastingTarget = Witch.currentTarget; SoundEffectsManager.play("witchSpell"); @@ -3934,7 +3834,6 @@ Func fortuneTellerCouldUse(byte index) sprintButton.Timer = sprintButton.MaxTimer = Sprinter.sprintCooldown; sprintButton.actionButton.cooldownTimerText.color = Palette.EnabledColor; sprintButton.isEffectActive = false; - Sprinter.sprinting = false; }, Sprinter.getButtonSprite(), CustomButton.ButtonPositions.lowerRowRight, @@ -4025,11 +3924,7 @@ Func fortuneTellerCouldUse(byte index) return; } if (Assassin.currentTarget != null) { - if (Assassin.currentTarget == Veteran.veteran && Veteran.alertActive && Veteran.veteran != null) - { - Helpers.checkMurderAttemptAndKill(Veteran.veteran, Assassin.assassin); - return; - } + if (Helpers.checkSuspendAction(Assassin.assassin, Assassin.currentTarget)) return; Assassin.assassinMarked = Assassin.currentTarget; assassinButton.Timer = 5f; SoundEffectsManager.play("warlockCurse"); diff --git a/TheOtherRoles/CustomGameModes/FreePlayGM.cs b/TheOtherRoles/CustomGameModes/FreePlayGM.cs index cad6dae..2878782 100644 --- a/TheOtherRoles/CustomGameModes/FreePlayGM.cs +++ b/TheOtherRoles/CustomGameModes/FreePlayGM.cs @@ -56,7 +56,7 @@ void SetWidget(int tab) if (tab == 0) { - inner = gui.Arrange(GUIAlignment.Center, RoleInfo.allRoleInfos.Where(x => x != RoleInfo.bomberB && x != RoleInfo.bomberA && x != RoleInfo.mimicA && x != RoleInfo.mimicK && x != RoleInfo.arsonist && x != RoleInfo.bountyHunter && !x.isModifier).Select(r => gui.RawButton(GUIAlignment.Center, roleMaskedTittleAttr, Helpers.cs(r.color, r.name), () => + inner = gui.Arrange(GUIAlignment.Center, RoleInfo.allRoleInfos.Where(x => x != RoleInfo.bomberB && !x.isModifier).Select(r => gui.RawButton(GUIAlignment.Center, roleMaskedTittleAttr, Helpers.cs(r.color, r.name), () => { bool isImpostorFormer = PlayerControl.LocalPlayer.Data.Role.IsImpostor; var formerRole = RoleInfo.getRoleInfoForPlayer(PlayerControl.LocalPlayer, false).FirstOrDefault(); @@ -141,7 +141,7 @@ public static void removeModifier(RoleId modifierId) break; case RoleId.Chameleon: Chameleon.chameleon.RemoveAll(x => x.PlayerId == playerId); - Chameleon.lastMoved.Clear(); + Chameleon.removeChameleonFully(player); break; case RoleId.Invert: Invert.invert.RemoveAll(x => x.PlayerId == playerId); diff --git a/TheOtherRoles/CustomOptionHolder.cs b/TheOtherRoles/CustomOptionHolder.cs index 4c4325f..cb3c0c2 100644 --- a/TheOtherRoles/CustomOptionHolder.cs +++ b/TheOtherRoles/CustomOptionHolder.cs @@ -555,7 +555,6 @@ public class CustomOptionHolder { public static CustomOption fungleElectrical; public static CustomOption miraVitals; public static CustomOption randomGameStartPosition; - public static CustomOption noticeNewDeadBodies; public static CustomOption activateProps; public static CustomOption numAccelTraps; public static CustomOption accelerationDuration; @@ -1224,7 +1223,6 @@ public static void Load() { airshipAdditionalSpawn = CustomOption.Create(6073, Types.General, "airshipAdditionalSpawn", false); fungleElectrical = CustomOption.Create(6074, Types.General, "fungleElectrical", false); randomGameStartPosition = CustomOption.Create(6071, Types.General, "randomGameStartPosition", false); - noticeNewDeadBodies = CustomOption.Create(6098, Types.General, "noticeNewDeadBodies", true); camsNightVision = CustomOption.Create(11, Types.General, "camsNightVision", false, null, true, heading: "headingNightVision"); camsNoNightVisionIfImpVision = CustomOption.Create(12, Types.General, "camsNoNightVisionIfImpVision", false, camsNightVision, false); diff --git a/TheOtherRoles/Helpers.cs b/TheOtherRoles/Helpers.cs index 6bf008b..d83bf26 100644 --- a/TheOtherRoles/Helpers.cs +++ b/TheOtherRoles/Helpers.cs @@ -550,6 +550,13 @@ static public SpriteRenderer CreateSharpBackground(SpriteRenderer renderer, Colo return renderer; } + static public float GetKillCooldown(this PlayerControl player) + { + if (player == SerialKiller.serialKiller) return SerialKiller.killCooldown; + if (player == SchrodingersCat.schrodingersCat) return SchrodingersCat.killCooldown; + return GameOptionsManager.Instance.currentNormalGameOptions.KillCooldown; + } + static public IEnumerator Sequence(params IEnumerator[] enumerator) { foreach (var e in enumerator) yield return e; @@ -978,7 +985,7 @@ public static void setLook(this PlayerControl target, String playerName, int col SkinViewData nextSkin = null; try { nextSkin = ShipStatus.Instance.CosmeticsCache.GetSkin(skinId); } catch { return; }; - + PlayerPhysics playerPhysics = target.MyPhysics; AnimationClip clip = null; var spriteAnim = playerPhysics.myPlayer.cosmetics.skin.animator; @@ -1438,6 +1445,27 @@ public static List getKillerTeamMembers(PlayerControl player) { return team; } + /// + /// Check whether the action should be done. (i.e. Veteran alert) + /// + /// The action player + /// The target of the action player + /// + public static bool checkSuspendAction(PlayerControl player, PlayerControl target) + { + if (player == null || target == null) return false; + if (Veteran.veteran != null && target == Veteran.veteran && Veteran.alertActive) + { + if (isEvil(player)) + { + _ = checkMuderAttempt(player, target); // Gives the Veteran the achievement + checkMurderAttemptAndKill(target, player); + return true; + } + } + return false; + } + public static bool isNeutral(PlayerControl player) { RoleInfo roleInfo = RoleInfo.getRoleInfoForPlayer(player, false, true).FirstOrDefault(); if (roleInfo != null) diff --git a/TheOtherRoles/Modules/CustomOptions.cs b/TheOtherRoles/Modules/CustomOptions.cs index e19fc58..740b6cb 100644 --- a/TheOtherRoles/Modules/CustomOptions.cs +++ b/TheOtherRoles/Modules/CustomOptions.cs @@ -541,9 +541,6 @@ public static void drawTab(LobbyViewSettingsPane __instance, CustomOptionType op if ((int)optionType == 99) categoryHeaderMasked.Title.text = new Dictionary() { { CustomOptionType.Impostor, ModTranslation.getString("impostorRoles") }, { CustomOptionType.Neutral, ModTranslation.getString("neutralRoles") }, { CustomOptionType.Crewmate, ModTranslation.getString("crewmateRoles") }, { CustomOptionType.Modifier, ModTranslation.getString("modifiers") } }[curType]; - var color = titleText.Contains(" opti categoryHeaderMasked.SetHeader(StringNames.ImpostorsCategory, 20); string titleText = option.heading != "" ? option.getHeading() : option.getName(); categoryHeaderMasked.Title.text = titleText; - var color = titleText.Contains(" Helpers.loadSpriteFromResources("TheOtherRoles.Resources.DeadMegaphone.png", 100f); - public static readonly List ReportedBodies = new(); - public static void Postfix(MeetingHud __instance, NetworkedPlayerInfo reportedBody, Il2CppReferenceArray deadBodies) - { - ReportedBodies.Clear(); - if (!CustomOptionHolder.noticeNewDeadBodies.getBool()) return; - foreach (var player in __instance.playerStates) - { - if (deadBodies?.Any(x => x.PlayerId == player.TargetPlayerId) == true) - { - if (reportedBody != null && player.TargetPlayerId == reportedBody.PlayerId) - { - player.Megaphone.gameObject.SetActive(true); - player.Megaphone.enabled = true; - player.Megaphone.transform.localEulerAngles = Vector3.zero; - player.Megaphone.transform.localScale = Vector3.one; - player.Megaphone.sprite = megaphone; - } - player.HighlightedFX.enabled = true; - player.HighlightedFX.color = Palette.ImpostorRed; - - ReportedBodies.Add(player.TargetPlayerId); - } - } - } - } - [HarmonyPatch(typeof(MeetingIntroAnimation), nameof(MeetingIntroAnimation.Init))] public static class MeetingIntroAnimationInitPatch { @@ -1075,6 +1044,14 @@ public static void Prefix(PlayerControl __instance, [HarmonyArgument(0)]Networke BomberA.bombTarget = null; BomberB.bombTarget = null; + Sprinter.sprinting = false; + Ninja.stealthed = false; + Fox.stealthed = false; + + // Mimic(Assistant) and Mimic(Killer) reset outfit + if (MimicA.mimicA != null) MimicA.mimicA.setDefaultLook(); + if (MimicK.mimicK != null) MimicK.mimicK.setDefaultLook(); + TranslatableTag tag = meetingTarget == null ? EventDetail.EmergencyButton : EventDetail.Report; if (meetingTarget != null) { @@ -1261,15 +1238,6 @@ static void Postfix(MeetingHud __instance) { __instance.StartCoroutine(Effects.SwayX(playerState.transform)); } } - - if (CustomOptionHolder.noticeNewDeadBodies.getBool()) - { - foreach (var state in __instance.playerStates) - { - if (ShowNewDead.ReportedBodies?.Contains(state.TargetPlayerId) == true) - if (!state.HighlightedFX.enabled) state.HighlightedFX.enabled = true; - } - } } } diff --git a/TheOtherRoles/Patches/PlayerControlPatch.cs b/TheOtherRoles/Patches/PlayerControlPatch.cs index aaffc4f..ff5d929 100644 --- a/TheOtherRoles/Patches/PlayerControlPatch.cs +++ b/TheOtherRoles/Patches/PlayerControlPatch.cs @@ -891,15 +891,15 @@ static void trackerUpdate() { } else if (Tracker.tracker.Data.IsDead) { - Tracker.DangerMeterParent?.SetActive(false); - Tracker.Meter?.gameObject?.SetActive(false); + if (Tracker.DangerMeterParent != null) Tracker.DangerMeterParent?.SetActive(false); + if (Tracker.Meter?.gameObject != null) Tracker.Meter?.gameObject?.SetActive(false); if (Tracker.arrow?.arrow != null) Tracker.arrow.arrow.SetActive(false); } } // Handle corpses tracking if (Tracker.tracker != null && Tracker.tracker == CachedPlayer.LocalPlayer.PlayerControl && Tracker.corpsesTrackingTimer >= 0f && !Tracker.tracker.Data.IsDead) { - bool arrowsCountChanged = Tracker.localArrows.Count != Tracker.deadBodyPositions.Count(); + bool arrowsCountChanged = Tracker.localArrows.Count != Tracker.deadBodyPositions.Count; int index = 0; if (arrowsCountChanged) { @@ -1923,6 +1923,7 @@ public static void miniCooldownUpdate() { HudManagerStartPatch.assassinButton.MaxTimer = Assassin.cooldown * multiplier; HudManagerStartPatch.thiefKillButton.MaxTimer = Thief.cooldown * multiplier; HudManagerStartPatch.serialKillerButton.MaxTimer = SerialKiller.suicideTimer * (Mini.isGrownUp() ? 2f : 1f); + HudManagerStartPatch.schrodingersCatKillButton.MaxTimer = SchrodingersCat.killCooldown * multiplier; } } @@ -2089,12 +2090,6 @@ public static void Postfix(PlayerControl __instance) { bomberBUpdate(); // Bait baitUpdate(); - // Ninja - //ninjaUpdate(); - // Sprinter - //sprinterUpdate(); - // Serial Killer - //serialKillerUpdate(); // Evil Tracker evilTrackerUpdate(); // Evil Hacker @@ -2446,7 +2441,7 @@ public static void Postfix(PlayerControl __instance, [HarmonyArgument(0)]PlayerC } if (CachedPlayer.LocalPlayer.PlayerControl == SchrodingersCat.schrodingersCat && __instance == SchrodingersCat.schrodingersCat && SchrodingersCat.team == SchrodingersCat.Team.Impostor) - SchrodingersCat.schrodingersCat.SetKillTimer(SchrodingersCat.killCooldown); + SchrodingersCat.schrodingersCat.SetKillTimerUnchecked(SchrodingersCat.killCooldown); if (Sheriff.sheriff != null && CachedPlayer.LocalPlayer.PlayerControl == Sheriff.sheriff && __instance == Sheriff.sheriff) { @@ -2528,7 +2523,7 @@ public static void Postfix(PlayerControl __instance, [HarmonyArgument(0)]PlayerC if (SerialKiller.serialKiller != null && CachedPlayer.LocalPlayer.PlayerControl == SerialKiller.serialKiller && __instance == SerialKiller.serialKiller && target != SerialKiller.serialKiller) { _ = new StaticAchievementToken("serialKiller.common1"); - SerialKiller.serialKiller.SetKillTimer(SerialKiller.killCooldown); + SerialKiller.serialKiller.SetKillTimerUnchecked(SerialKiller.killCooldown); HudManagerStartPatch.serialKillerButton.Timer = SerialKiller.suicideTimer; SerialKiller.isCountDown = true; } @@ -2747,11 +2742,6 @@ public static void Postfix(PlayerControl __instance, [HarmonyArgument(0)]PlayerC { MimicK.mimicK.setDefaultLook(); MimicK.victim = null; - if (MimicA.mimicA != null) - { - MimicA.mimicA.setDefaultLook(); - MimicA.isMorph = false; - } } if (MimicA.mimicA != null && target == MimicA.mimicA) @@ -2925,20 +2915,27 @@ public static bool Prefix(PlayerControl __instance) } [HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.SetKillTimer))] - class PlayerControlSetCoolDownPatch { + static class PlayerControlSetCoolDownPatch { public static bool Prefix(PlayerControl __instance, [HarmonyArgument(0)]float time) { if (GameOptionsManager.Instance.currentGameOptions.GameMode == GameModes.HideNSeek) return true; - if (GameOptionsManager.Instance.currentNormalGameOptions.KillCooldown <= 0f) return false; + if (CachedPlayer.LocalPlayer.PlayerControl.GetKillCooldown() <= 0f) return false; float multiplier = 1f; float addition = 0f; if (Mini.mini != null && CachedPlayer.LocalPlayer.PlayerControl == Mini.mini) multiplier = Mini.isGrownUp() ? 0.66f : 2f; if (BountyHunter.bountyHunter != null && CachedPlayer.LocalPlayer.PlayerControl == BountyHunter.bountyHunter) addition = BountyHunter.punishmentTime; if (Ninja.ninja != null && CachedPlayer.LocalPlayer.PlayerControl == Ninja.ninja && Ninja.penalized) addition = Ninja.killPenalty; - __instance.killTimer = Mathf.Clamp(time, 0f, GameOptionsManager.Instance.currentNormalGameOptions.KillCooldown * multiplier + addition); - FastDestroyableSingleton.Instance.KillButton.SetCoolDown(__instance.killTimer, GameOptionsManager.Instance.currentNormalGameOptions.KillCooldown * multiplier + addition); + float max = Mathf.Max(CachedPlayer.LocalPlayer.PlayerControl.GetKillCooldown() * multiplier + addition, __instance.killTimer); + __instance.SetKillTimerUnchecked(Mathf.Clamp(time, 0f, max), max); return false; } + + public static void SetKillTimerUnchecked(this PlayerControl player, float time, float max = float.NegativeInfinity) + { + if (max == float.NegativeInfinity) max = time; + player.killTimer = time; + FastDestroyableSingleton.Instance.KillButton.SetCoolDown(time, max); + } } [HarmonyPatch(typeof(KillAnimation), nameof(KillAnimation.CoPerformKill))] diff --git a/TheOtherRoles/Patches/UsablesPatch.cs b/TheOtherRoles/Patches/UsablesPatch.cs index 7262f43..38375d5 100644 --- a/TheOtherRoles/Patches/UsablesPatch.cs +++ b/TheOtherRoles/Patches/UsablesPatch.cs @@ -196,13 +196,13 @@ public static bool Prefix(KillButton __instance) { MurderAttemptResult res = Helpers.checkMurderAttemptAndKill(CachedPlayer.LocalPlayer.PlayerControl, __instance.currentTarget, showAnimation: showAnimation); // Handle blank kill if (res == MurderAttemptResult.BlankKill) { - CachedPlayer.LocalPlayer.PlayerControl.killTimer = GameOptionsManager.Instance.currentNormalGameOptions.KillCooldown; + CachedPlayer.LocalPlayer.PlayerControl.killTimer = CachedPlayer.LocalPlayer.PlayerControl.GetKillCooldown(); if (CachedPlayer.LocalPlayer.PlayerControl == Cleaner.cleaner) Cleaner.cleaner.killTimer = HudManagerStartPatch.cleanerCleanButton.Timer = HudManagerStartPatch.cleanerCleanButton.MaxTimer; else if (CachedPlayer.LocalPlayer.PlayerControl == Warlock.warlock) Warlock.warlock.killTimer = HudManagerStartPatch.warlockCurseButton.Timer = HudManagerStartPatch.warlockCurseButton.MaxTimer; else if (CachedPlayer.LocalPlayer.PlayerControl == Mini.mini && Mini.mini.Data.Role.IsImpostor) - Mini.mini.SetKillTimer(GameOptionsManager.Instance.currentNormalGameOptions.KillCooldown * (Mini.isGrownUp() ? 0.66f : 2f)); + Mini.mini.SetKillTimer(CachedPlayer.LocalPlayer.PlayerControl.GetKillCooldown() * (Mini.isGrownUp() ? 0.66f : 2f)); else if (CachedPlayer.LocalPlayer.PlayerControl == Witch.witch) Witch.witch.killTimer = HudManagerStartPatch.witchSpellButton.Timer = HudManagerStartPatch.witchSpellButton.MaxTimer; else if (CachedPlayer.LocalPlayer.PlayerControl == Assassin.assassin) diff --git a/TheOtherRoles/RPC.cs b/TheOtherRoles/RPC.cs index 3f0c69d..fa697d2 100644 --- a/TheOtherRoles/RPC.cs +++ b/TheOtherRoles/RPC.cs @@ -926,7 +926,8 @@ public static void shifterShift(byte targetId) if (Chameleon.chameleon.Any(x => x.PlayerId == player.PlayerId)) { Chameleon.chameleon.Add(oldShifter); - Chameleon.chameleon.Remove(player); + Chameleon.chameleon.Remove(player); + Chameleon.removeChameleonFully(player); } // Switch Sunglasses if (Sunglasses.sunglasses.Any(x => x.PlayerId == player.PlayerId)) @@ -1163,20 +1164,8 @@ public static void shifterShift(byte targetId) Blackmailer.blackmailer = oldShifter; Blackmailer.onAchievementActivate(); } - if (player == MimicK.mimicK) { - if (CachedPlayer.LocalPlayer.PlayerControl == player) { - if (MimicK.arrows.FirstOrDefault().arrow != null) MimicK.arrows.FirstOrDefault().arrow.SetActive(false); - } - player.setDefaultLook(); // set default look in case they are morphed - MimicK.mimicK = oldShifter; - } - if (player == MimicA.mimicA) { - if (CachedPlayer.LocalPlayer.PlayerControl == player) { - if (MimicA.arrows.FirstOrDefault().arrow != null) MimicA.arrows.FirstOrDefault().arrow.SetActive(false); - } - player.setDefaultLook(); - MimicA.mimicA = oldShifter; - } + if (player == MimicK.mimicK) MimicK.mimicK = oldShifter; + if (player == MimicA.mimicA) MimicA.mimicA = oldShifter; if (player == BomberA.bomberA) { if (CachedPlayer.LocalPlayer.PlayerControl == player) { resetPoolables(); @@ -2964,7 +2953,7 @@ public static void thiefStealsRole(byte playerId) { //if (target == Bomber.bomber) Bomber.bomber = thief; if (target.Data.Role.IsImpostor) { RoleManager.Instance.SetRole(Thief.thief, RoleTypes.Impostor); - FastDestroyableSingleton.Instance.KillButton.SetCoolDown(Thief.thief.killTimer, GameOptionsManager.Instance.currentNormalGameOptions.KillCooldown); + FastDestroyableSingleton.Instance.KillButton.SetCoolDown(Thief.thief.killTimer, CachedPlayer.LocalPlayer.PlayerControl.GetKillCooldown()); } if (Lawyer.lawyer != null && target == Lawyer.target) Lawyer.target = thief; diff --git a/TheOtherRoles/Resources/stringData.json b/TheOtherRoles/Resources/stringData.json index 27e200a..227ea73 100644 --- a/TheOtherRoles/Resources/stringData.json +++ b/TheOtherRoles/Resources/stringData.json @@ -199,10 +199,6 @@ "13": "\u968f\u673a\u51fa\u751f\u70b9", "14": "\u96a8\u6a5f\u51fa\u751f\u9ede" }, - "noticeNewDeadBodies": { - "0": "Notice New Dead Bodies", - "13": "\u4f1a\u8bae\u4e2d\u7a81\u51fa\u663e\u793a\u672c\u8f6e\u6b7b\u4ea1\u73a9\u5bb6" - }, "activateProps": { "0": "Activate Props", "11": "\u5c0f\u9053\u5177\u3092\u6709\u52b9\u5316", diff --git a/TheOtherRoles/TheOtherRoles.cs b/TheOtherRoles/TheOtherRoles.cs index d4f34b2..0b41ace 100644 --- a/TheOtherRoles/TheOtherRoles.cs +++ b/TheOtherRoles/TheOtherRoles.cs @@ -1964,20 +1964,11 @@ public static class MimicK public static void arrowUpdate() { - //if (MimicK.mimicK == null || MimicA.mimicA == null) return; - if (arrows.FirstOrDefault()?.arrow != null) - { - if (mimicK == null || MimicA.mimicA == null) - { - foreach (Arrow arrows in arrows) arrows.arrow.SetActive(false); - return; - } - } - if (CachedPlayer.LocalPlayer.PlayerControl != mimicK || mimicK == null) return; - if (mimicK.Data.IsDead) - { - if (arrows.FirstOrDefault().arrow != null) UnityEngine.Object.Destroy(arrows.FirstOrDefault().arrow); - return; + if (CachedPlayer.LocalPlayer.PlayerControl != mimicK || CachedPlayer.LocalPlayer.PlayerControl.Data.IsDead || MimicA.mimicA == null) + { + if (arrows.FirstOrDefault()?.arrow != null) + foreach (Arrow arrows in arrows) arrows.arrow.SetActive(false); + return; } // 前フレームからの経過時間をマイナスする updateTimer -= Time.fixedDeltaTime; @@ -2029,7 +2020,7 @@ public static void arrowUpdate() public static void clearAndReload() { - mimicK?.setDefaultLook(); + if (mimicK != null && mimicK?.Data != null) mimicK.setDefaultLook(); if (MimicA.mimicA != null) { MimicA.isMorph = false; @@ -2088,20 +2079,17 @@ public static Sprite getAdminSprite() public static float arrowUpdateInterval = 0.5f; public static void arrowUpdate() { - //if (MimicA.mimicA == null || MimicK.mimicK == null) return; - if (arrows.FirstOrDefault()?.arrow != null) - { - if (MimicK.mimicK == null || mimicA == null) - { - foreach (Arrow arrows in arrows) arrows.arrow.SetActive(false); - return; - } - } - if (CachedPlayer.LocalPlayer.PlayerControl != mimicA) return; + if (MimicK.mimicK == null || MimicK.mimicK.Data.IsDead || MimicK.mimicK.Data.Disconnected) { + if (mimicA != null && isMorph) { + isMorph = false; + mimicA.setDefaultLook(); + } + } - if (mimicA.Data.IsDead) + if (CachedPlayer.LocalPlayer.PlayerControl != mimicA || CachedPlayer.LocalPlayer.Data.IsDead || MimicK.mimicK == null) { - if (arrows.FirstOrDefault().arrow != null) UnityEngine.Object.Destroy(arrows.FirstOrDefault().arrow); + if (arrows.FirstOrDefault()?.arrow != null) + foreach (Arrow arrows in arrows) arrows.arrow.SetActive(false); return; } @@ -2139,7 +2127,7 @@ public static void arrowUpdate() public static void clearAndReload() { - mimicA?.setDefaultLook(); + if (mimicA != null && mimicA?.Data != null) mimicA.setDefaultLook(); mimicA = null; isMorph = false; if (arrows != null) @@ -2833,9 +2821,10 @@ public static Sprite getReleaseButtonSprite() public static void arrowUpdate() { if ((bombTarget == null || BomberB.bombTarget == null) && !alwaysShowArrow) return; - if (bomberA.Data.IsDead) + if (bomberA.Data.IsDead || BomberB.bomberB == null) { - if (arrows.FirstOrDefault().arrow != null) UnityEngine.Object.Destroy(arrows.FirstOrDefault().arrow); + if (arrows.FirstOrDefault()?.arrow != null) + foreach (Arrow arrows in arrows) arrows.arrow.SetActive(false); return; } // 前フレームからの経過時間をマイナスする @@ -3021,9 +3010,10 @@ public static void playerIconsUpdate() public static void arrowUpdate() { if ((BomberA.bombTarget == null || bombTarget == null) && !BomberA.alwaysShowArrow) return; - if (bomberB.Data.IsDead) + if (bomberB.Data.IsDead || BomberA.bomberA == null) { - if (arrows.FirstOrDefault().arrow != null) UnityEngine.Object.Destroy(arrows.FirstOrDefault().arrow); + if (arrows.FirstOrDefault()?.arrow != null) + foreach (Arrow arrows in arrows) arrows.arrow.SetActive(false); return; } // 前フレームからの経過時間をマイナスする @@ -6007,6 +5997,21 @@ public static void update() { } } + + public static void removeChameleonFully(PlayerControl player) { + try + { // Sometimes renderers are missing for weird reasons. Try catch to avoid exceptions + player.cosmetics.currentBodySprite.BodySprite.color = player.cosmetics.currentBodySprite.BodySprite.color.SetAlpha(1f); + if (DataManager.Settings.Accessibility.ColorBlindMode) player.cosmetics.colorBlindText.color = player.cosmetics.colorBlindText.color.SetAlpha(1f); + player.SetHatAndVisorAlpha(1f); + player.cosmetics.skin.layer.color = player.cosmetics.skin.layer.color.SetAlpha(1f); + player.cosmetics.nameText.color = player.cosmetics.nameText.color.SetAlpha(1f); + foreach (var rend in player.cosmetics.currentPet.renderers) rend.color = rend.color.SetAlpha(1f); + foreach (var shadowRend in player.cosmetics.currentPet.shadows) shadowRend.color = shadowRend.color.SetAlpha(1f); + if (lastMoved.ContainsKey(player.PlayerId)) lastMoved.Remove(player.PlayerId); + } + catch { } + } } /*public static class Shifter {