From b55aae51b622203db4f48dc810a3cb79e9bc5dc0 Mon Sep 17 00:00:00 2001 From: XiezibanWrite <103623519+XiezibanWrite@users.noreply.github.com> Date: Sun, 20 Oct 2024 08:12:54 +0800 Subject: [PATCH] Add Rootkit and AntiRootkit --- TheOtherRoles/CustomOptionHolder.cs | 12 +++++++++++- TheOtherRoles/Helpers.cs | 6 ++++++ TheOtherRoles/Patches/RoleAssignmentPatch.cs | 8 +++++++- TheOtherRoles/RPC.cs | 9 +++++++++ TheOtherRoles/RoleInfo.cs | 6 ++++++ TheOtherRoles/TheOtherRoles.cs | 20 ++++++++++++++++++++ 6 files changed, 59 insertions(+), 2 deletions(-) diff --git a/TheOtherRoles/CustomOptionHolder.cs b/TheOtherRoles/CustomOptionHolder.cs index b90e5f3..91bb74a 100644 --- a/TheOtherRoles/CustomOptionHolder.cs +++ b/TheOtherRoles/CustomOptionHolder.cs @@ -489,7 +489,13 @@ public class CustomOptionHolder { public static CustomOption modifierSunglasses; public static CustomOption modifierSunglassesQuantity; public static CustomOption modifierSunglassesVision; - + + public static CustomOption modifierRootkit; + public static CustomOption modifierRootkitAntiKillChance; + + public static CustomOption modifierAntiRootkit; + + public static CustomOption modifierMini; public static CustomOption modifierMiniGrowingUpDuration; public static CustomOption modifierMiniGrowingUpInMeeting; @@ -1102,6 +1108,10 @@ public static void Load() { modifierMiniGrowingUpDuration = CustomOption.Create(1062, Types.Modifier, "miniGrowingUpDuration", 400f, 100f, 1500f, 100f, modifierMini, false, "unitSeconds"); modifierMiniGrowingUpInMeeting = CustomOption.Create(1063, Types.Modifier, "miniGrowingUpInMeeting", true, modifierMini); + modifierRootkit = CustomOption.Create(10000, Types.Modifier, cs(Color.yellow, "Rootkit"), rates, null, true); + modifierRootkitAntiKillChance = CustomOption.Create(10001, Types.Modifier, cs(Color.yellow, "RootkitAntiKillChance"), 1f, 1f, 6f, 1f, modifierRootkit, false, "unitShots"); + modifierAntiRootkit = CustomOption.Create(10002, Types.Modifier, "HaveAntiRootkit", true, modifierRootkit); + modifierVip = CustomOption.Create(1070, Types.Modifier, cs(Color.yellow, "vip"), rates, null, true); modifierVipQuantity = CustomOption.Create(1071, Types.Modifier, cs(Color.yellow, "vipQuantity"), ratesModifier, modifierVip); modifierVipShowColor = CustomOption.Create(1072, Types.Modifier, "vipShowColor", true, modifierVip); diff --git a/TheOtherRoles/Helpers.cs b/TheOtherRoles/Helpers.cs index c86a591..86eb2c3 100644 --- a/TheOtherRoles/Helpers.cs +++ b/TheOtherRoles/Helpers.cs @@ -1200,6 +1200,12 @@ public static MurderAttemptResult checkMuderAttempt(PlayerControl killer, Player return MurderAttemptResult.SuppressKill; } + else if (Rootkit.rootkit != null && target == Rootkit.rootkit && killer != AntiRootkit.antiRootkit && Rootkit.AntiKillChance != 0) + { + Rootkit.AntiKillChance--; + return MurderAttemptResult.SuppressKill; + } + else if (Cupid.cupid != null && Cupid.shielded == target && !Cupid.cupid.Data.IsDead) { MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.CupidSuicide, Hazel.SendOption.Reliable, -1); diff --git a/TheOtherRoles/Patches/RoleAssignmentPatch.cs b/TheOtherRoles/Patches/RoleAssignmentPatch.cs index af7d49d..6494a8d 100644 --- a/TheOtherRoles/Patches/RoleAssignmentPatch.cs +++ b/TheOtherRoles/Patches/RoleAssignmentPatch.cs @@ -221,6 +221,10 @@ private static void assignSpecialRoles(RoleAssignmentData data) { setRoleToRandomPlayer((byte)RoleId.MimicA, data.impostors); data.maxImpostorRoles -= 2; } + if (data.impostors.Count >= 1 && CustomOptionHolder.modifierAntiRootkit.getBool()) + { + setModifierToRandomPlayer((byte)RoleId.AntiRootkit, data.impostors); + } } private static void selectFactionForFactionIndependentRoles(RoleAssignmentData data) { @@ -567,7 +571,9 @@ private static void assignModifiers() { RoleId.Vip, RoleId.Invert, RoleId.Chameleon, - RoleId.Madmate + RoleId.Madmate, + RoleId.Rootkit, + //RoleId.AntiRootkit Won't give to non-killer player //RoleId.Shifter }); diff --git a/TheOtherRoles/RPC.cs b/TheOtherRoles/RPC.cs index a21c4de..2dae915 100644 --- a/TheOtherRoles/RPC.cs +++ b/TheOtherRoles/RPC.cs @@ -115,6 +115,8 @@ public enum RoleId { Vip, Invert, Chameleon, + Rootkit, + AntiRootkit, //Shifter } @@ -645,6 +647,13 @@ public static void setModifier(byte modifierId, byte playerId, byte flag) { case RoleId.Madmate: Madmate.madmate.Add(player); break; + case RoleId.Rootkit: + Rootkit.rootkit = player; + break; + case RoleId.AntiRootkit: + AntiRootkit.antiRootkit = player; + break; + //case RoleId.Shifter: //Shifter.shifter = player; //break; diff --git a/TheOtherRoles/RoleInfo.cs b/TheOtherRoles/RoleInfo.cs index 25ebf89..698c5e3 100644 --- a/TheOtherRoles/RoleInfo.cs +++ b/TheOtherRoles/RoleInfo.cs @@ -133,6 +133,8 @@ public RoleInfo(string name, Color color, RoleId roleId, bool isNeutral = false, public static RoleInfo vip = new("vip", Color.yellow, RoleId.Vip, false, true); public static RoleInfo invert = new("invert", Color.yellow, RoleId.Invert, false, true); public static RoleInfo chameleon = new("chameleon", Color.yellow, RoleId.Chameleon, false, true); + public static RoleInfo rootkit = new("rootkit", Color.yellow, RoleId.Rootkit, false, true); + public static RoleInfo antiRootkit = new("antirootkit", Color.yellow, RoleId.AntiRootkit, false, true); //public static RoleInfo shifter = new RoleInfo("Shifter", Color.yellow, "Shift your role", "Shift your role", RoleId.Shifter, false, true); @@ -230,6 +232,8 @@ public RoleInfo(string name, Color color, RoleId roleId, bool isNeutral = false, invert, chameleon, cupidLover, + rootkit, + antiRootkit, //shifter, }; @@ -254,6 +258,8 @@ public static List getRoleInfoForPlayer(PlayerControl p, bool showModi if (p == Mini.mini) infos.Add(mini); if (Invert.invert.Any(x => x.PlayerId == p.PlayerId)) infos.Add(invert); if (Chameleon.chameleon.Any(x => x.PlayerId == p.PlayerId)) infos.Add(chameleon); + if (p == Rootkit.rootkit) infos.Add(rootkit); + if (p == AntiRootkit.antiRootkit) infos.Add(antiRootkit); //if (p == Shifter.shifter) infos.Add(shifter); } diff --git a/TheOtherRoles/TheOtherRoles.cs b/TheOtherRoles/TheOtherRoles.cs index 4042db2..71fd8da 100644 --- a/TheOtherRoles/TheOtherRoles.cs +++ b/TheOtherRoles/TheOtherRoles.cs @@ -5414,6 +5414,26 @@ public static void clearAndReload() { isTiebreak = false; } } + public static class Rootkit + { + public static PlayerControl rootkit; + public static float AntiKillChance; + public static void clearAndReload() + { + rootkit = null; + AntiKillChance = CustomOptionHolder.modifierRootkitAntiKillChance.getFloat(); + + } + } + + public static class AntiRootkit + { + public static PlayerControl antiRootkit; + public static void clearAndReload() + { + antiRootkit = null; + } + } public static class Sunglasses { public static List sunglasses = new();