Skip to content

Commit

Permalink
The Other Us 1.3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
SpexGH committed Feb 10, 2024
1 parent a9c23d7 commit f5f2b27
Show file tree
Hide file tree
Showing 12 changed files with 239 additions and 18 deletions.
79 changes: 74 additions & 5 deletions TheOtherRoles/Buttons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ static class HudManagerStartPatch
private static CustomButton amnisiacRememberButton;
public static CustomButton veterenAlertButton;
public static CustomButton medicShieldButton;
private static CustomButton bomber2BombButton;
private static CustomButton bomber2KillButton;
private static CustomButton cultistTurnButton;
private static CustomButton shifterShiftButton;
private static CustomButton disperserDisperseButton;
Expand Down Expand Up @@ -122,6 +124,7 @@ public static void setCustomButtonCooldowns() {
shifterShiftButton.MaxTimer = 0f;
disperserDisperseButton.MaxTimer = 0f;
morphlingButton.MaxTimer = Morphling.cooldown;
bomber2BombButton.MaxTimer = Bomber2.cooldown;
camouflagerButton.MaxTimer = Camouflager.cooldown;
portalmakerPlacePortalButton.MaxTimer = Portalmaker.cooldown;
usePortalButton.MaxTimer = Portalmaker.usePortalCooldown;
Expand Down Expand Up @@ -150,6 +153,8 @@ public static void setCustomButtonCooldowns() {
arsonistButton.MaxTimer = Arsonist.cooldown;
vultureEatButton.MaxTimer = Vulture.cooldown;
amnisiacRememberButton.MaxTimer = 0f;
bomber2KillButton.MaxTimer = 0f;
bomber2KillButton.Timer = 0f;
mediumButton.MaxTimer = Medium.cooldown;
pursuerButton.MaxTimer = Pursuer.cooldown;
trackerTrackCorpsesButton.MaxTimer = Tracker.corpsesTrackingCooldown;
Expand Down Expand Up @@ -188,6 +193,7 @@ public static void setCustomButtonCooldowns() {
minerMineButton.EffectDuration = Jackal.duration; // Jackal?
camouflagerButton.EffectDuration = Camouflager.duration;
morphlingButton.EffectDuration = Morphling.duration;
bomber2BombButton.EffectDuration = Bomber2.bombDelay + Bomber2.bombTimer;
lightsOutButton.EffectDuration = Trickster.lightsOutDuration;
arsonistButton.EffectDuration = Arsonist.duration;
mediumButton.EffectDuration = Medium.duration;
Expand Down Expand Up @@ -698,7 +704,7 @@ public static void createButtonsPostfix(HudManager __instance) {
},
() => { },
Disperser.getButtonSprite(),
new Vector3(0, 0, 0),
new Vector3(0, 0f, 0),
__instance,
null,
true
Expand Down Expand Up @@ -1116,11 +1122,11 @@ public static void createButtonsPostfix(HudManager __instance) {
RPCProcedure.placeGarlic(buff);
SoundEffectsManager.play("garlic");
},
() => { return !Vampire.localPlacedGarlic && !CachedPlayer.LocalPlayer.Data.IsDead && Vampire.garlicsActive && !HideNSeek.isHideNSeekGM && !PropHunt.isPropHuntGM; },
() => { return CachedPlayer.LocalPlayer.PlayerControl.CanMove && !Vampire.localPlacedGarlic; },
() => { return Vampire.garlicButton && !Vampire.localPlacedGarlic && !CachedPlayer.LocalPlayer.Data.IsDead && Vampire.garlicsActive && !HideNSeek.isHideNSeekGM && !PropHunt.isPropHuntGM; },
() => { return Vampire.garlicButton && CachedPlayer.LocalPlayer.PlayerControl.CanMove && !Vampire.localPlacedGarlic; },
() => { },
Vampire.getGarlicButtonSprite(),
new Vector3(0, -0.06f, 0),
new Vector3(0, 1f, 0),
__instance,
null,
true
Expand Down Expand Up @@ -1310,7 +1316,10 @@ public static void createButtonsPostfix(HudManager __instance) {
RPCProcedure.setSwoop(Jackal.jackal.PlayerId, byte.MinValue);
},
() => { /* Can See */ return Jackal.canSwoop && Jackal.jackal != null && Jackal.jackal == CachedPlayer.LocalPlayer.PlayerControl && !CachedPlayer.LocalPlayer.Data.IsDead; },
() => { /* On Click */ return Jackal.canSwoop && (CachedPlayer.LocalPlayer.PlayerControl.CanMove); },
() => { /* On Click */
Swooper.swooper = Jackal.jackal;
Jackal.canSwoop2 = true;
return Jackal.canSwoop && (CachedPlayer.LocalPlayer.PlayerControl.CanMove); },
() => { /* On Meeting End */
swooperSwoopButton.Timer = swooperSwoopButton.MaxTimer;
swooperSwoopButton.isEffectActive = false;
Expand Down Expand Up @@ -1384,6 +1393,65 @@ public static void createButtonsPostfix(HudManager __instance) {
KeyCode.V
);

bomber2BombButton = new CustomButton(
() => { /* On Use */
if (Helpers.checkAndDoVetKill(Bomber2.currentTarget)) return;
Helpers.checkWatchFlash(Bomber2.currentTarget);
MessageWriter bombWriter = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.GiveBomb, Hazel.SendOption.Reliable, -1);
bombWriter.Write(Bomber2.currentTarget.PlayerId);
AmongUsClient.Instance.FinishRpcImmediately(bombWriter);
RPCProcedure.giveBomb(Bomber2.currentTarget.PlayerId);
Bomber2.bomber2.killTimer = Bomber2.bombTimer + Bomber2.bombDelay;
bomber2BombButton.Timer = bomber2BombButton.MaxTimer;
},
() => { /* Can See */ return Bomber2.bomber2 != null && Bomber2.bomber2 == CachedPlayer.LocalPlayer.PlayerControl && !CachedPlayer.LocalPlayer.Data.IsDead; },
() => { /* On Click */ return (Bomber2.currentTarget && CachedPlayer.LocalPlayer.PlayerControl.CanMove); },
() => { /* On Meeting End */
bomber2BombButton.Timer = bomber2BombButton.MaxTimer;
bomber2BombButton.isEffectActive = false;
bomber2BombButton.actionButton.cooldownTimerText.color = Palette.EnabledColor;
Bomber2.hasBomb = null;
},
Bomber2.getButtonSprite(),
CustomButton.ButtonPositions.upperRowLeft, //brb
__instance,
KeyCode.V
);

bomber2KillButton = new CustomButton(
() => { /* On Use */
if (Bomber2.currentBombTarget == Bomber2.bomber2) {
MessageWriter killWriter = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.UncheckedMurderPlayer, Hazel.SendOption.Reliable, -1);
killWriter.Write(Bomber2.bomber2.Data.PlayerId);
killWriter.Write(Bomber2.hasBomb.Data.PlayerId);
killWriter.Write(0);
AmongUsClient.Instance.FinishRpcImmediately(killWriter);
RPCProcedure.uncheckedMurderPlayer(Bomber2.bomber2.Data.PlayerId, Bomber2.hasBomb.Data.PlayerId, 0);

MessageWriter bombWriter1 = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.GiveBomb, Hazel.SendOption.Reliable, -1);
bombWriter1.Write(byte.MaxValue);
AmongUsClient.Instance.FinishRpcImmediately(bombWriter1);
RPCProcedure.giveBomb(byte.MaxValue);
return;
}
if (Helpers.checkAndDoVetKill(Bomber2.currentBombTarget)) return;
if (Helpers.checkMuderAttemptAndKill(Bomber2.hasBomb, Bomber2.currentBombTarget) == MurderAttemptResult.SuppressKill) return;
MessageWriter bombWriter = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.GiveBomb, Hazel.SendOption.Reliable, -1);
bombWriter.Write(byte.MaxValue);
AmongUsClient.Instance.FinishRpcImmediately(bombWriter);
RPCProcedure.giveBomb(byte.MaxValue);

},
() => { /* Can See */ return Bomber2.bomber2 != null && Bomber2.hasBomb == CachedPlayer.LocalPlayer.PlayerControl && Bomber2.bombActive && !CachedPlayer.LocalPlayer.Data.IsDead; },
() => { /* Can Click */ return (Bomber2.currentBombTarget && CachedPlayer.LocalPlayer.PlayerControl.CanMove); },
() => { /* On Meeting End */ },
Bomber2.getButtonSprite(),
// 0, -0.06f, 0
new Vector3(-4.5f, 1.5f, 0),
__instance,
KeyCode.B
);

// Werewolf Kill
werewolfKillButton = new CustomButton(
() => {
Expand Down Expand Up @@ -2309,6 +2377,7 @@ public static void createButtonsPostfix(HudManager __instance) {
CachedPlayer.LocalPlayer.NetTransform.Halt(); // Stop current movement
Mayor.remoteMeetingsLeft--;
Helpers.handleVampireBiteOnBodyReport(); // Manually call Vampire handling, since the CmdReportDeadBody Prefix won't be called
Helpers.handleBomber2ExplodeOnBodyReport(); // Manually call Vampire handling, since the CmdReportDeadBody Prefix won't be called
RPCProcedure.uncheckedCmdReportDeadBody(CachedPlayer.LocalPlayer.PlayerId, Byte.MaxValue);

MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.UncheckedCmdReportDeadBody, Hazel.SendOption.Reliable, -1);
Expand Down
20 changes: 18 additions & 2 deletions TheOtherRoles/CustomOptionHolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ public class CustomOptionHolder {
public static CustomOption morphlingCooldown;
public static CustomOption morphlingDuration;

public static CustomOption bomber2SpawnRate;
public static CustomOption bomber2BombCooldown;
public static CustomOption bomber2Delay;
public static CustomOption bomber2Timer;
//public static CustomOption bomber2HotPotatoMode;

public static CustomOption undertakerSpawnRate;
public static CustomOption undertakerDragingDelaiAfterKill;
public static CustomOption undertakerCanDragAndVent;
Expand All @@ -46,6 +52,7 @@ public class CustomOptionHolder {
public static CustomOption vampireSpawnRate;
public static CustomOption vampireKillDelay;
public static CustomOption vampireCooldown;
public static CustomOption vampireGarlicButton;
public static CustomOption vampireCanKillNearGarlics;

public static CustomOption poucherSpawnRate;
Expand Down Expand Up @@ -571,6 +578,12 @@ public static void Load() {
morphlingCooldown = CustomOption.Create(21, Types.Impostor, "Morphling Cooldown", 30f, 10f, 60f, 2.5f, morphlingSpawnRate);
morphlingDuration = CustomOption.Create(22, Types.Impostor, "Morph Duration", 10f, 1f, 20f, 0.5f, morphlingSpawnRate);

bomber2SpawnRate = CustomOption.Create(8840, Types.Impostor, cs(Bomber2.color, "Bomber [BETA]"), rates, null, true);
bomber2BombCooldown = CustomOption.Create(8841, Types.Impostor, "Bomber2 Cooldown", 30f, 25f, 60f, 2.5f, bomber2SpawnRate);
bomber2Delay = CustomOption.Create(8842, Types.Impostor, "Bomb Delay", 10f, 1f, 20f, 0.5f, bomber2SpawnRate);
bomber2Timer = CustomOption.Create(8843, Types.Impostor, "Bomb Timer", 10f, 5f, 30f, 5f, bomber2SpawnRate);
//bomber2HotPotatoMode = CustomOption.Create(2526236, Types.Impostor, "Hot Potato Mode", false, bomber2SpawnRate);

undertakerSpawnRate = CustomOption.Create(1201, Types.Impostor, cs(Undertaker.color, "Undertaker"), rates, null, true);
undertakerDragingDelaiAfterKill = CustomOption.Create(1202, Types.Impostor, "Draging Delay After Kill", 0f, 0f, 15, 1f, undertakerSpawnRate);
undertakerCanDragAndVent = CustomOption.Create(1203, Types.Impostor, "Can Vent While Dragging", true, undertakerSpawnRate);
Expand All @@ -582,7 +595,8 @@ public static void Load() {
vampireSpawnRate = CustomOption.Create(40, Types.Impostor, cs(Vampire.color, "Vampire"), rates, null, true);
vampireKillDelay = CustomOption.Create(41, Types.Impostor, "Vampire Kill Delay", 10f, 1f, 20f, 1f, vampireSpawnRate);
vampireCooldown = CustomOption.Create(42, Types.Impostor, "Vampire Cooldown", 30f, 10f, 60f, 2.5f, vampireSpawnRate);
vampireCanKillNearGarlics = CustomOption.Create(43, Types.Impostor, "Vampire Can Kill Near Garlics", true, vampireSpawnRate);
vampireGarlicButton = CustomOption.Create(43277854, Types.Impostor, "Enable Garlic", true, vampireSpawnRate);
vampireCanKillNearGarlics = CustomOption.Create(43, Types.Impostor, "Vampire Can Kill Near Garlics", true, vampireGarlicButton);

eraserSpawnRate = CustomOption.Create(230, Types.Impostor, cs(Eraser.color, "Eraser"), rates, null, true);
eraserCooldown = CustomOption.Create(231, Types.Impostor, "Eraser Cooldown", 30f, 10f, 120f, 5f, eraserSpawnRate);
Expand Down Expand Up @@ -637,7 +651,7 @@ public static void Load() {
blackmailerSpawnRate = CustomOption.Create(710, Types.Impostor, cs(Blackmailer.color, "Blackmailer"), rates, null, true);
blackmailerCooldown = CustomOption.Create(711, Types.Impostor, "Blackmail Cooldown", 30f, 5f, 120f, 5f, blackmailerSpawnRate);

bomberSpawnRate = CustomOption.Create(460, Types.Impostor, cs(Bomber.color, "Bomber"), rates, null, true);
bomberSpawnRate = CustomOption.Create(460, Types.Impostor, cs(Bomber.color, "Terrorist"), rates, null, true);
bomberBombDestructionTime = CustomOption.Create(461, Types.Impostor, "Bomb Destruction Time", 20f, 2.5f, 120f, 2.5f, bomberSpawnRate);
bomberBombDestructionRange = CustomOption.Create(462, Types.Impostor, "Bomb Destruction Range", 50f, 5f, 150f, 5f, bomberSpawnRate);
bomberBombHearRange = CustomOption.Create(463, Types.Impostor, "Bomb Hear Range", 60f, 5f, 150f, 5f, bomberSpawnRate);
Expand Down Expand Up @@ -1068,6 +1082,8 @@ public static void Load() {
blockedRolePairings.Add((byte)RoleId.Watcher, new [] { (byte)RoleId.Mayor});
blockedRolePairings.Add((byte)RoleId.Engineer, new [] { (byte)RoleId.Tunneler});
blockedRolePairings.Add((byte)RoleId.Tunneler, new [] { (byte)RoleId.Engineer});
blockedRolePairings.Add((byte)RoleId.Bomber2, new [] { (byte)RoleId.Bait});
blockedRolePairings.Add((byte)RoleId.Bait, new [] { (byte)RoleId.Bomber2});

}
}
Expand Down
9 changes: 9 additions & 0 deletions TheOtherRoles/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,15 @@ public static void handleVampireBiteOnBodyReport() {
RPCProcedure.vampireSetBitten(byte.MaxValue, byte.MaxValue);
}

public static void handleBomber2ExplodeOnBodyReport() {
// Murder the bitten player and reset bitten (regardless whether the kill was successful or not)
Helpers.checkMuderAttemptAndKill(Bomber2.bomber2, Bomber2.hasBomb, true, false);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.GiveBomb, Hazel.SendOption.Reliable, -1);
writer.Write(byte.MaxValue);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCProcedure.giveBomb(byte.MaxValue);
}

public static void refreshRoleDescription(PlayerControl player) {
List<RoleInfo> infos = RoleInfo.getRoleInfoForPlayer(player);
List<string> taskTexts = new(infos.Count);
Expand Down
2 changes: 1 addition & 1 deletion TheOtherRoles/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace TheOtherRoles
public class TheOtherRolesPlugin : BasePlugin
{
public const string Id = "me.eisbison.theotherroles";
public const string VersionString = "1.3.3";
public const string VersionString = "1.3.4";
public static uint betaDays = 0; // amount of days for the build to be usable (0 for infinite!)

public static Version Version = Version.Parse(VersionString);
Expand Down
24 changes: 24 additions & 0 deletions TheOtherRoles/Patches/PlayerControlPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,19 @@ static void medicSetTarget() {
if (!Medic.usedShield) setPlayerOutline(Medic.currentTarget, Medic.shieldedColor);
}

static void bomber2SetTarget() {
setBomber2BombTarget();
if (Bomber2.bomber2 == null || Bomber2.bomber2 != CachedPlayer.LocalPlayer.PlayerControl) return;
Bomber2.currentTarget = setTarget();
if (Bomber2.hasBomb == null) setPlayerOutline(Bomber2.currentTarget, Bomber2.color);
}

static void setBomber2BombTarget() {
if (Bomber2.bomber2 == null || Bomber2.hasBomb != CachedPlayer.LocalPlayer.PlayerControl) return;
Bomber2.currentBombTarget = setTarget();
// if (Bomber2.hasBomb != null) setPlayerOutline(Bomber2.currentBombTarget, Bomber2.color);
}

static void bodyGuardSetTarget() {
if (BodyGuard.bodyguard == null || BodyGuard.bodyguard != CachedPlayer.LocalPlayer.PlayerControl) return;
BodyGuard.currentTarget = setTarget();
Expand Down Expand Up @@ -418,6 +431,13 @@ static void swooperUpdate()
RPCProcedure.setSwooper(Jackal.jackal.PlayerId);
}
}*/
/*
if ((Swooper.swooper = Jackal.jackal) && Jackal.canSwoop2){
foreach (PlayerControl player in CachedPlayer.AllPlayers) {
Swooper.swooper = Jackal.jackal;
}
}
*/
}

static void ninjaUpdate()
Expand Down Expand Up @@ -1075,6 +1095,7 @@ static void baitUpdate() {
Bait.active.Remove(entry.Key);
if (entry.Key.killerIfExisting != null && entry.Key.killerIfExisting.PlayerId == CachedPlayer.LocalPlayer.PlayerId) {
Helpers.handleVampireBiteOnBodyReport(); // Manually call Vampire handling, since the CmdReportDeadBody Prefix won't be called
Helpers.handleBomber2ExplodeOnBodyReport(); // Manually call Vampire handling, since the CmdReportDeadBody Prefix won't be called
RPCProcedure.uncheckedCmdReportDeadBody(entry.Key.killerIfExisting.PlayerId, entry.Key.player.PlayerId);

MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.UncheckedCmdReportDeadBody, Hazel.SendOption.Reliable, -1);
Expand Down Expand Up @@ -1274,6 +1295,8 @@ public static void Postfix(PlayerControl __instance) {
privateInvestigatorSetTarget();
// Medic
medicSetTarget();
// Bomber2
bomber2SetTarget();
// Set Werewolf Target
werewolfSetTarget();
// Shifter
Expand Down Expand Up @@ -1395,6 +1418,7 @@ class PlayerControlCmdReportDeadBodyPatch {
public static bool Prefix(PlayerControl __instance) {
if (HideNSeek.isHideNSeekGM || PropHunt.isPropHuntGM) return false;
Helpers.handleVampireBiteOnBodyReport();
Helpers.handleBomber2ExplodeOnBodyReport();
return true;
}
}
Expand Down
Loading

0 comments on commit f5f2b27

Please sign in to comment.