Skip to content

Commit

Permalink
Update source code
Browse files Browse the repository at this point in the history
  • Loading branch information
Eisbison committed Mar 27, 2021
1 parent fda74b8 commit 835df77
Show file tree
Hide file tree
Showing 25 changed files with 986 additions and 470 deletions.
82 changes: 75 additions & 7 deletions Source Code/Buttons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ static class HudManagerStartPatch
private static CustomButton trackerButton;
private static CustomButton vampireKillButton;
private static CustomButton garlicButton;
private static CustomButton jackalKillButton;
private static CustomButton sidekickKillButton;
private static CustomButton jackalSidekickButton;

public static void setCustomButtonCooldowns() {
engineerRepairButton.MaxTimer = 0f;
Expand All @@ -40,12 +43,16 @@ public static void setCustomButtonCooldowns() {
morphlingButton.MaxTimer = Morphling.cooldown;
camouflagerButton.MaxTimer = Camouflager.cooldown;
spyButton.MaxTimer = Spy.cooldown;
vampireKillButton.MaxTimer = PlayerControl.GameOptions.KillCooldown;
vampireKillButton.MaxTimer = Vampire.cooldown;
trackerButton.MaxTimer = 0f;
garlicButton.MaxTimer = 0f;

spyButton.EffectDuration = Spy.duration;
vampireKillButton.EffectDuration= Vampire.delay;

jackalKillButton.MaxTimer = Jackal.cooldown;
sidekickKillButton.MaxTimer = Sidekick.cooldown;
jackalSidekickButton.MaxTimer = Jackal.createSidekickCooldown;
}

public static void Postfix(HudManager __instance)
Expand Down Expand Up @@ -133,16 +140,19 @@ public static void Postfix(HudManager __instance)
MessageWriter attemptWriter = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ShieldedMurderAttempt, Hazel.SendOption.None, -1);
AmongUsClient.Instance.FinishRpcImmediately(attemptWriter);
RPCProcedure.shieldedMurderAttempt();

return;
}

byte targetId = 0;
if (Sheriff.currentTarget.Data.IsImpostor || (Sheriff.jesterCanDieToSheriff && Jester.jester != null && Jester.jester == Sheriff.currentTarget))
if (Sheriff.currentTarget.Data.IsImpostor ||
Sheriff.currentTarget == Jackal.jackal ||
Sheriff.currentTarget == Sidekick.sidekick ||
(Sheriff.jesterCanDieToSheriff && Jester.jester != null && Jester.jester == Sheriff.currentTarget)) {
targetId = Sheriff.currentTarget.PlayerId;
else
}
else {
targetId = PlayerControl.LocalPlayer.PlayerId;

}
MessageWriter killWriter = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SheriffKill, Hazel.SendOption.None, -1);
killWriter.Write(targetId);
AmongUsClient.Instance.FinishRpcImmediately(killWriter);
Expand Down Expand Up @@ -361,11 +371,11 @@ public static void Postfix(HudManager __instance)
},
() => { return Vampire.vampire != null && Vampire.vampire == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead; },
() => {
if (Vampire.targetNearGarlic)
if (Vampire.targetNearGarlic && Vampire.canKillNearGarlics)
vampireKillButton.killButtonManager.renderer.sprite = __instance.KillButton.renderer.sprite;
else
vampireKillButton.killButtonManager.renderer.sprite = Vampire.getButtonSprite();
return Vampire.currentTarget != null && PlayerControl.LocalPlayer.CanMove;
return Vampire.currentTarget != null && PlayerControl.LocalPlayer.CanMove && (!Vampire.targetNearGarlic || Vampire.canKillNearGarlics);
},
() => {
vampireKillButton.Timer = vampireKillButton.MaxTimer;
Expand Down Expand Up @@ -403,6 +413,64 @@ public static void Postfix(HudManager __instance)
__instance,
true
);


// Jackal Sidekick Button
jackalSidekickButton = new CustomButton(
() => {
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.JackalCreatesSidekick, Hazel.SendOption.None, -1);
writer.Write(Jackal.currentTarget.PlayerId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCProcedure.jackalCreatesSidekick(Jackal.currentTarget.PlayerId);
},
() => { return Jackal.canCreateSidekick && Sidekick.sidekick == null && Jackal.fakeSidekick == null && Jackal.jackal != null && Jackal.jackal == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead; },
() => { return Sidekick.sidekick == null && Jackal.fakeSidekick == null && Jackal.currentTarget != null && PlayerControl.LocalPlayer.CanMove; },
() => { jackalSidekickButton.Timer = jackalSidekickButton.MaxTimer;},
Jackal.getSidekickButtonSprite(),
new Vector3(-1.3f, 1.3f, 0f),
__instance
);

// Jackal Kill
jackalKillButton = new CustomButton(
() => {
if (!Helpers.handleMurderAttempt(Jackal.currentTarget)) return;
byte targetId = Jackal.currentTarget.PlayerId;
MessageWriter killWriter = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.JackalKill, Hazel.SendOption.None, -1);
killWriter.Write(targetId);
AmongUsClient.Instance.FinishRpcImmediately(killWriter);
RPCProcedure.jackalKill(targetId);
jackalKillButton.Timer = jackalKillButton.MaxTimer;
Jackal.currentTarget = null;
},
() => { return Jackal.jackal != null && Jackal.jackal == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead; },
() => { return Jackal.currentTarget && PlayerControl.LocalPlayer.CanMove; },
() => { jackalKillButton.Timer = jackalKillButton.MaxTimer;},
__instance.KillButton.renderer.sprite,
new Vector3(-1.3f, 0, 0),
__instance
);

// Sidekick Kill
sidekickKillButton = new CustomButton(
() => {
if (!Helpers.handleMurderAttempt(Sidekick.currentTarget)) return;
byte targetId = Sidekick.currentTarget.PlayerId;
MessageWriter killWriter = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SidekickKill, Hazel.SendOption.None, -1);
killWriter.Write(targetId);
AmongUsClient.Instance.FinishRpcImmediately(killWriter);
RPCProcedure.sidekickKill(targetId);

sidekickKillButton.Timer = sidekickKillButton.MaxTimer;
Sidekick.currentTarget = null;
},
() => { return Sidekick.canKill && Sidekick.sidekick != null && Sidekick.sidekick == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead; },
() => { return Sidekick.currentTarget && PlayerControl.LocalPlayer.CanMove; },
() => { sidekickKillButton.Timer = sidekickKillButton.MaxTimer;},
__instance.KillButton.renderer.sprite,
new Vector3(-1.3f, 0, 0),
__instance
);
}
}
}
7 changes: 4 additions & 3 deletions Source Code/CredentialsPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ public static class VersionShowerPatch
{
static void Postfix(VersionShower __instance) {
string spacer = new String('\n', 15);
string text = "[FCCE03FF]TheOtherRoles[] v1.8.1:\n- Modded by [FCCE03FF]Eisbison[] and [FFEB91FF]Thunderstorm584[]\n- Balanced with [FFEB91FF]Dhalucard";
if (__instance.text.Text.Contains(spacer))
__instance.text.Text += "\n[FFFFFFFF]- Loaded [FCCE03FF]TheOtherRoles[FFFFFFFF] v1.7\n by [FCCE03FF]Eisbison";
__instance.text.Text += "\n" + text;
else
__instance.text.Text += spacer + "[FFFFFFFF]- Loaded [FCCE03FF]TheOtherRoles[FFFFFFFF] v1.7\n by [FCCE03FF]Eisbison";
__instance.text.Text += spacer + text;
}
}

Expand All @@ -25,7 +26,7 @@ public static class PingTrackerPatch
static void Postfix(VersionShower __instance)
{
__instance.text.Text += "\n[FCCE03FF]TheOtherRoles[FFFFFFFF]";
__instance.text.Text += "\nModded by [FCCE03FF]Eisbison";
__instance.text.Text += "\nModded by [FCCE03FF]Eisbison[FFFFFFFF]";
}
}
}
5 changes: 4 additions & 1 deletion Source Code/CustomButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,10 @@ private void Update()
}

if (Timer >= 0) {
Timer -= Time.deltaTime;
if (HasEffect && isEffectActive)
Timer -= Time.deltaTime;
else if (!PlayerControl.LocalPlayer.inVent)
Timer -= Time.deltaTime;
}

if (Timer <= 0 && HasEffect && isEffectActive) {
Expand Down
Loading

0 comments on commit 835df77

Please sign in to comment.