Skip to content

Commit

Permalink
v2.8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Eisbison committed Aug 7, 2021
1 parent f2f0e99 commit 7768ceb
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 15 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ The [Role Assignment](#role-assignment) sections explains how the roles are bein
# Releases
| Among Us - Version| Mod Version | Link |
|----------|-------------|-----------------|
| 2021.6.30s| v2.8.1| [Download](https://github.com/Eisbison/TheOtherRoles/releases/download/v2.8.1/TheOtherRoles.zip)
| 2021.6.30s| v2.8.0| [Download](https://github.com/Eisbison/TheOtherRoles/releases/download/v2.8.0/TheOtherRoles.zip)
| 2021.6.30s| v2.7.3| [Download](https://github.com/Eisbison/TheOtherRoles/releases/download/v2.7.3/TheOtherRoles.zip)
| 2021.6.15s| v2.7.1| [Download](https://github.com/Eisbison/TheOtherRoles/releases/download/v2.7.1/TheOtherRoles.zip)
Expand Down Expand Up @@ -74,6 +75,9 @@ The [Role Assignment](#role-assignment) sections explains how the roles are bein
<details>
<summary>Click to show the Changelog</summary>

**Hotfix 2.8.1**
- Fixed a game breaking bug where killing the Bait resulted in a ban of the Bait

**Version 2.8.0**
- **New Role:** [Bait](#bait) created by [Mallöris](https://github.com/Mallaris)
- Added Tracker Option: "Tracker Reset Target After Meeting" (feature created by [MaximeGillot](https://github.com/MaximeGillot))
Expand Down
15 changes: 15 additions & 0 deletions TheOtherRoles/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,21 @@ public static bool handleMurderAttempt(PlayerControl target, bool isMeetingStart
return true;
}

public static void handleVampireBiteOnBodyReport() {
// Murder the bitten player before the meeting starts or reset the bitten player
if (Vampire.bitten != null && !Vampire.bitten.Data.IsDead && Helpers.handleMurderAttempt(Vampire.bitten, true)) {
MessageWriter killWriter = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.VampireTryKill, Hazel.SendOption.Reliable, -1);
AmongUsClient.Instance.FinishRpcImmediately(killWriter);
RPCProcedure.vampireTryKill();
} else {
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.VampireSetBitten, Hazel.SendOption.Reliable, -1);
writer.Write(byte.MaxValue);
writer.Write(byte.MaxValue);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCProcedure.vampireSetBitten(byte.MaxValue, byte.MaxValue);
}
}

public static void refreshRoleDescription(PlayerControl player) {
if (player == null) return;

Expand Down
2 changes: 1 addition & 1 deletion TheOtherRoles/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace TheOtherRoles
public class TheOtherRolesPlugin : BasePlugin
{
public const string Id = "me.eisbison.theotherroles";
public const string VersionString = "2.8.0";
public const string VersionString = "2.8.1";
public static System.Version Version = System.Version.Parse(VersionString);

public Harmony Harmony { get; } = new Harmony(Id);
Expand Down
22 changes: 9 additions & 13 deletions TheOtherRoles/Patches/PlayerControlPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,14 @@ static void baitUpdate() {
Bait.reportDelay -= Time.fixedDeltaTime;
DeadPlayer deadPlayer = deadPlayers?.Where(x => x.player?.PlayerId == Bait.bait.PlayerId)?.FirstOrDefault();
if (deadPlayer.killerIfExisting != null && Bait.reportDelay <= 0f) {
deadPlayer.killerIfExisting.CmdReportDeadBody(Bait.bait.Data);

Helpers.handleVampireBiteOnBodyReport(); // Manually call Vampire handling, since the CmdReportDeadBody Prefix won't be called
RPCProcedure.uncheckedCmdReportDeadBody(deadPlayer.killerIfExisting.PlayerId, Bait.bait.PlayerId);

MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.UncheckedCmdReportDeadBody, Hazel.SendOption.Reliable, -1);
writer.Write(deadPlayer.killerIfExisting.PlayerId);
writer.Write(Bait.bait.PlayerId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
Bait.reported = true;
}
}
Expand Down Expand Up @@ -630,18 +637,7 @@ public static void Prefix(PlayerPhysics __instance) {
[HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.CmdReportDeadBody))]
class PlayerControlCmdReportDeadBodyPatch {
public static void Prefix(PlayerControl __instance) {
// Murder the bitten player before the meeting starts or reset the bitten player
if (Vampire.bitten != null && !Vampire.bitten.Data.IsDead && Helpers.handleMurderAttempt(Vampire.bitten, true)) {
MessageWriter killWriter = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.VampireTryKill, Hazel.SendOption.Reliable, -1);
AmongUsClient.Instance.FinishRpcImmediately(killWriter);
RPCProcedure.vampireTryKill();
} else {
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.VampireSetBitten, Hazel.SendOption.Reliable, -1);
writer.Write(byte.MaxValue);
writer.Write(byte.MaxValue);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCProcedure.vampireSetBitten(byte.MaxValue, byte.MaxValue);
}
Helpers.handleVampireBiteOnBodyReport();
}
}
[HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.RpcMurderPlayer))]
Expand Down
13 changes: 13 additions & 0 deletions TheOtherRoles/RPC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ enum CustomRPC
VersionHandshake,
UseUncheckedVent,
UncheckedMurderPlayer,
UncheckedCmdReportDeadBody,

// Role functionality

Expand Down Expand Up @@ -271,6 +272,13 @@ public static void uncheckedMurderPlayer(byte sourceId, byte targetId) {
if (source != null && target != null) source.MurderPlayer(target);
}

public static void uncheckedCmdReportDeadBody(byte sourceId, byte targetId) {
PlayerControl source = Helpers.playerById(sourceId);
PlayerControl target = Helpers.playerById(targetId);
if (source != null && target != null) source.ReportDeadBody(target.Data);
}


// Role functionality

public static void engineerFixLights() {
Expand Down Expand Up @@ -752,6 +760,11 @@ static void Postfix([HarmonyArgument(0)]byte callId, [HarmonyArgument(1)]Message
byte target = reader.ReadByte();
RPCProcedure.uncheckedMurderPlayer(source, target);
break;
case (byte)CustomRPC.UncheckedCmdReportDeadBody:
byte reportSource = reader.ReadByte();
byte reportTarget = reader.ReadByte();
RPCProcedure.uncheckedCmdReportDeadBody(reportSource, reportTarget);
break;

// Role functionality

Expand Down
2 changes: 1 addition & 1 deletion TheOtherRoles/TheOtherRoles.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<Version>2.8.0</Version>
<Version>2.8.1</Version>
<Description>TheOtherRoles</Description>
<Authors>Eisbison</Authors>
</PropertyGroup>
Expand Down

0 comments on commit 7768ceb

Please sign in to comment.