Skip to content

Commit

Permalink
Merge pull request #338 from Eisbison/v-4-0-0
Browse files Browse the repository at this point in the history
Version 4.0.0
  • Loading branch information
dwd0tcom authored Apr 29, 2022
2 parents 70139e3 + b75ad7b commit a5de718
Show file tree
Hide file tree
Showing 251 changed files with 2,788 additions and 988 deletions.
Binary file added Images/TOR_Roles.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed Images/TOR_roles.jpg
Binary file not shown.
867 changes: 515 additions & 352 deletions README.md

Large diffs are not rendered by default.

158 changes: 147 additions & 11 deletions TheOtherRoles/Buttons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,24 @@ static class HudManagerStartPatch
{
private static CustomButton engineerRepairButton;
private static CustomButton janitorCleanButton;
private static CustomButton sheriffKillButton;
public static CustomButton sheriffKillButton;
private static CustomButton deputyHandcuffButton;
private static CustomButton timeMasterShieldButton;
private static CustomButton medicShieldButton;
private static CustomButton shifterShiftButton;
private static CustomButton morphlingButton;
private static CustomButton camouflagerButton;
private static CustomButton portalmakerPlacePortalButton;
private static CustomButton usePortalButton;
private static CustomButton hackerButton;
private static CustomButton hackerVitalsButton;
private static CustomButton hackerAdminTableButton;
private static CustomButton trackerTrackPlayerButton;
private static CustomButton trackerTrackCorpsesButton;
private static CustomButton vampireKillButton;
public static CustomButton vampireKillButton;
private static CustomButton garlicButton;
private static CustomButton jackalKillButton;
private static CustomButton sidekickKillButton;
public static CustomButton jackalKillButton;
public static CustomButton sidekickKillButton;
private static CustomButton jackalSidekickButton;
private static CustomButton lighterButton;
private static CustomButton eraserButton;
Expand All @@ -44,6 +46,7 @@ static class HudManagerStartPatch
public static CustomButton mediumButton;
public static CustomButton pursuerButton;
public static CustomButton witchSpellButton;
public static CustomButton ninjaButton;

public static Dictionary<byte, List<CustomButton>> deputyHandcuffedButtons = null;

Expand All @@ -64,6 +67,8 @@ public static void setCustomButtonCooldowns() {
shifterShiftButton.MaxTimer = 0f;
morphlingButton.MaxTimer = Morphling.cooldown;
camouflagerButton.MaxTimer = Camouflager.cooldown;
portalmakerPlacePortalButton.MaxTimer = Portalmaker.cooldown;
usePortalButton.MaxTimer = Portalmaker.usePortalCooldown;
hackerButton.MaxTimer = Hacker.cooldown;
hackerVitalsButton.MaxTimer = Hacker.cooldown;
hackerAdminTableButton.MaxTimer = Hacker.cooldown;
Expand All @@ -86,7 +91,8 @@ public static void setCustomButtonCooldowns() {
mediumButton.MaxTimer = Medium.cooldown;
pursuerButton.MaxTimer = Pursuer.cooldown;
trackerTrackCorpsesButton.MaxTimer = Tracker.corpsesTrackingCooldown;
witchSpellButton.MaxTimer = Witch.cooldown;
witchSpellButton.MaxTimer = Witch.cooldown;
ninjaButton.MaxTimer = Ninja.cooldown;

timeMasterShieldButton.EffectDuration = TimeMaster.shieldDuration;
hackerButton.EffectDuration = Hacker.duration;
Expand Down Expand Up @@ -365,6 +371,7 @@ public static void Postfix(HudManager __instance)
RPCProcedure.setFutureShielded(Medic.currentTarget.PlayerId);
else
RPCProcedure.medicSetShielded(Medic.currentTarget.PlayerId);
Medic.meetingAfterShielding = false;
},
() => { return Medic.medic != null && Medic.medic == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead; },
() => { return !Medic.usedShield && Medic.currentTarget && PlayerControl.LocalPlayer.CanMove; },
Expand Down Expand Up @@ -713,7 +720,65 @@ public static void Postfix(HudManager __instance)
true
);


portalmakerPlacePortalButton = new CustomButton(
() => {
portalmakerPlacePortalButton.Timer = portalmakerPlacePortalButton.MaxTimer;

var pos = PlayerControl.LocalPlayer.transform.position;
byte[] buff = new byte[sizeof(float) * 2];
Buffer.BlockCopy(BitConverter.GetBytes(pos.x), 0, buff, 0 * sizeof(float), sizeof(float));
Buffer.BlockCopy(BitConverter.GetBytes(pos.y), 0, buff, 1 * sizeof(float), sizeof(float));

MessageWriter writer = AmongUsClient.Instance.StartRpc(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.PlacePortal, Hazel.SendOption.Reliable);
writer.WriteBytesAndSize(buff);
writer.EndMessage();
RPCProcedure.placePortal(buff);
},
() => { return Portalmaker.portalmaker != null && Portalmaker.portalmaker == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead && Portal.secondPortal == null; },
() => { return PlayerControl.LocalPlayer.CanMove && Portal.secondPortal == null; },
() => { portalmakerPlacePortalButton.Timer = portalmakerPlacePortalButton.MaxTimer; },
Portalmaker.getPlacePortalButtonSprite(),
new Vector3(-1.8f, -0.06f, 0),
__instance,
KeyCode.F
);

usePortalButton = new CustomButton(
() => {
bool didTeleport = false;
Vector2 exit = Portal.findExit(PlayerControl.LocalPlayer.transform.position);
Vector2 entry = Portal.findEntry(PlayerControl.LocalPlayer.transform.position);
PlayerControl.LocalPlayer.NetTransform.RpcSnapTo(entry); // TODO: check for bans on servers

if (!PlayerControl.LocalPlayer.Data.IsDead) { // Ghosts can portal too, but non-blocking and only with a local animation
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.UsePortal, Hazel.SendOption.Reliable, -1);
writer.Write((byte)PlayerControl.LocalPlayer.PlayerId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
}
RPCProcedure.usePortal(PlayerControl.LocalPlayer.PlayerId);
usePortalButton.Timer = usePortalButton.MaxTimer;
HudManager.Instance.StartCoroutine(Effects.Lerp(Portal.teleportDuration, new Action<float>((p) => { // Delayed action
PlayerControl.LocalPlayer.moveable = false;
PlayerControl.LocalPlayer.NetTransform.Halt();
if (p >= 0.5f && p <= 0.53f && !didTeleport) {
PlayerControl.LocalPlayer.NetTransform.RpcSnapTo(exit);
didTeleport = true;
}
if (p == 1f) {
PlayerControl.LocalPlayer.moveable = true;
}
})));
},
() => { return Portal.bothPlacedAndEnabled; },
() => { return PlayerControl.LocalPlayer.CanMove && Portal.locationNearEntry(PlayerControl.LocalPlayer.transform.position) && !Portal.isTeleporting; },
() => { usePortalButton.Timer = usePortalButton.MaxTimer; },
Portalmaker.getUsePortalButtonSprite(),
new Vector3(0.9f, -0.06f, 0),
__instance,
KeyCode.H,
mirror: true
);

// Jackal Sidekick Button
jackalSidekickButton = new CustomButton(
() => {
Expand Down Expand Up @@ -1288,20 +1353,91 @@ public static void Postfix(HudManager __instance)
RPCProcedure.setFutureSpelled(Witch.currentTarget.PlayerId);
}
if (attempt == MurderAttemptResult.BlankKill || attempt == MurderAttemptResult.PerformKill) {
witchSpellButton.MaxTimer += Witch.cooldownAddition;
Witch.currentCooldownAddition += Witch.cooldownAddition;
witchSpellButton.MaxTimer = Witch.cooldown + Witch.currentCooldownAddition;
Patches.PlayerControlFixedUpdatePatch.miniCooldownUpdate(); // Modifies the MaxTimer if the witch is the mini
witchSpellButton.Timer = witchSpellButton.MaxTimer;
if (Witch.triggerBothCooldowns)
Witch.witch.killTimer = PlayerControl.GameOptions.KillCooldown;
if (Witch.triggerBothCooldowns) {
float multiplier = (Mini.mini != null && PlayerControl.LocalPlayer == Mini.mini) ? (Mini.isGrownUp() ? 0.66f : 2f) : 1f;
Witch.witch.killTimer = PlayerControl.GameOptions.KillCooldown * multiplier;
}
} else {
witchSpellButton.Timer = 0f;
}
Witch.spellCastingTarget = null;
}
);

// Set the default (or settings from the previous game) timers/durations when spawning the buttons
// Ninja mark and assassinate button
ninjaButton = new CustomButton(
() => {
if (Ninja.ninjaMarked != null) {
// Murder attempt with teleport
MurderAttemptResult attempt = Helpers.checkMuderAttempt(Ninja.ninja, Ninja.ninjaMarked);
if (attempt == MurderAttemptResult.PerformKill) {
// Create first trace before killing
var pos = PlayerControl.LocalPlayer.transform.position;
byte[] buff = new byte[sizeof(float) * 2];
Buffer.BlockCopy(BitConverter.GetBytes(pos.x), 0, buff, 0 * sizeof(float), sizeof(float));
Buffer.BlockCopy(BitConverter.GetBytes(pos.y), 0, buff, 1 * sizeof(float), sizeof(float));

MessageWriter writer = AmongUsClient.Instance.StartRpc(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.PlaceNinjaTrace, Hazel.SendOption.Reliable);
writer.WriteBytesAndSize(buff);
writer.EndMessage();
RPCProcedure.placeNinjaTrace(buff);

// Perform Kill
MessageWriter writer2 = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.UncheckedMurderPlayer, Hazel.SendOption.Reliable, -1);
writer2.Write(PlayerControl.LocalPlayer.PlayerId);
writer2.Write(Ninja.ninjaMarked.PlayerId);
writer2.Write(byte.MaxValue);
AmongUsClient.Instance.FinishRpcImmediately(writer2);
RPCProcedure.uncheckedMurderPlayer(PlayerControl.LocalPlayer.PlayerId, Ninja.ninjaMarked.PlayerId, byte.MaxValue);

// Create Second trace after killing
pos = Ninja.ninjaMarked.transform.position;
buff = new byte[sizeof(float) * 2];
Buffer.BlockCopy(BitConverter.GetBytes(pos.x), 0, buff, 0 * sizeof(float), sizeof(float));
Buffer.BlockCopy(BitConverter.GetBytes(pos.y), 0, buff, 1 * sizeof(float), sizeof(float));

MessageWriter writer3 = AmongUsClient.Instance.StartRpc(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.PlaceNinjaTrace, Hazel.SendOption.Reliable);
writer3.WriteBytesAndSize(buff);
writer3.EndMessage();
RPCProcedure.placeNinjaTrace(buff);
}

if (attempt == MurderAttemptResult.BlankKill || attempt == MurderAttemptResult.PerformKill) {
ninjaButton.Timer = ninjaButton.MaxTimer;
Ninja.ninja.killTimer = PlayerControl.GameOptions.KillCooldown;
} else if (attempt == MurderAttemptResult.SuppressKill) {
ninjaButton.Timer = 0f;
}
Ninja.ninjaMarked = null;
return;
}
if (Ninja.currentTarget != null) {
Ninja.ninjaMarked = Ninja.currentTarget;
ninjaButton.Timer = 5f;
}
},
() => { return Ninja.ninja != null && Ninja.ninja == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead; },
() => { // CouldUse
ninjaButton.Sprite = Ninja.ninjaMarked != null ? Ninja.getKillButtonSprite() : Ninja.getMarkButtonSprite();
return (Ninja.currentTarget != null || Ninja.ninjaMarked != null) && PlayerControl.LocalPlayer.CanMove;
},
() => { // on meeting ends
ninjaButton.Timer = ninjaButton.MaxTimer;
Ninja.ninjaMarked = null;
},
Ninja.getMarkButtonSprite(),
new Vector3(-1.8f, -0.06f, 0),
__instance,
KeyCode.F
);

// Set the default (or settings from the previous game) timers / durations when spawning the buttons
setCustomButtonCooldowns();
deputyHandcuffedButtons = null;
}
}
}
}
Loading

0 comments on commit a5de718

Please sign in to comment.