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

Add Rootkit and AntiRootkit #41

Open
wants to merge 1 commit into
base: main
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
12 changes: 11 additions & 1 deletion TheOtherRoles/CustomOptionHolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 6 additions & 0 deletions TheOtherRoles/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 7 additions & 1 deletion TheOtherRoles/Patches/RoleAssignmentPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
});

Expand Down
9 changes: 9 additions & 0 deletions TheOtherRoles/RPC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ public enum RoleId {
Vip,
Invert,
Chameleon,
Rootkit,
AntiRootkit,
//Shifter
}

Expand Down Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions TheOtherRoles/RoleInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);


Expand Down Expand Up @@ -230,6 +232,8 @@ public RoleInfo(string name, Color color, RoleId roleId, bool isNeutral = false,
invert,
chameleon,
cupidLover,
rootkit,
antiRootkit,
//shifter,
};

Expand All @@ -254,6 +258,8 @@ public static List<RoleInfo> 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);
}

Expand Down
20 changes: 20 additions & 0 deletions TheOtherRoles/TheOtherRoles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<PlayerControl> sunglasses = new();
Expand Down