Skip to content

Commit

Permalink
Version 2.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Eisbison committed Nov 4, 2021
1 parent 7768ceb commit 14f185f
Show file tree
Hide file tree
Showing 22 changed files with 546 additions and 104 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
.vs
.vscode/tasks.json
.vscode/tasks.json
TODO
Images/.DS_Store
Binary file modified Images/TOR_roles.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
198 changes: 126 additions & 72 deletions README.md

Large diffs are not rendered by default.

128 changes: 127 additions & 1 deletion TheOtherRoles/Buttons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ static class HudManagerStartPatch
public static CustomButton warlockCurseButton;
public static CustomButton securityGuardButton;
public static CustomButton arsonistButton;
public static CustomButton vultureEatButton;
public static CustomButton mediumButton;
public static TMPro.TMP_Text securityGuardButtonScrewsText;

public static void setCustomButtonCooldowns() {
Expand All @@ -59,6 +61,8 @@ public static void setCustomButtonCooldowns() {
warlockCurseButton.MaxTimer = Warlock.cooldown;
securityGuardButton.MaxTimer = SecurityGuard.cooldown;
arsonistButton.MaxTimer = Arsonist.cooldown;
vultureEatButton.MaxTimer = Vulture.cooldown;
mediumButton.MaxTimer = Medium.cooldown;

timeMasterShieldButton.EffectDuration = TimeMaster.shieldDuration;
hackerButton.EffectDuration = Hacker.duration;
Expand All @@ -68,6 +72,7 @@ public static void setCustomButtonCooldowns() {
morphlingButton.EffectDuration = Morphling.duration;
lightsOutButton.EffectDuration = Trickster.lightsOutDuration;
arsonistButton.EffectDuration = Arsonist.duration;
mediumButton.EffectDuration = Medium.duration;

// Already set the timer to the max, as the button is enabled during the game and not available at the start
lightsOutButton.Timer = lightsOutButton.MaxTimer;
Expand Down Expand Up @@ -175,7 +180,7 @@ public static void Postfix(HudManager __instance)
byte targetId = 0;
if ((Sheriff.currentTarget.Data.IsImpostor && (Sheriff.currentTarget != Mini.mini || Mini.isGrownUp())) ||
(Sheriff.spyCanDieToSheriff && Spy.spy == Sheriff.currentTarget) ||
(Sheriff.canKillNeutrals && (Arsonist.arsonist == Sheriff.currentTarget || Jester.jester == Sheriff.currentTarget)) ||
(Sheriff.canKillNeutrals && (Arsonist.arsonist == Sheriff.currentTarget || Jester.jester == Sheriff.currentTarget || Vulture.vulture == Sheriff.currentTarget)) ||
(Jackal.jackal == Sheriff.currentTarget || Sidekick.sidekick == Sheriff.currentTarget)) {
targetId = Sheriff.currentTarget.PlayerId;
}
Expand Down Expand Up @@ -781,6 +786,127 @@ public static void Postfix(HudManager __instance)
}
);

// Vulture Eat
vultureEatButton = new CustomButton(
() => {
foreach (Collider2D collider2D in Physics2D.OverlapCircleAll(PlayerControl.LocalPlayer.GetTruePosition(), PlayerControl.LocalPlayer.MaxReportDistance, Constants.PlayersOnlyMask)) {
if (collider2D.tag == "DeadBody") {
DeadBody component = collider2D.GetComponent<DeadBody>();
if (component && !component.Reported) {
Vector2 truePosition = PlayerControl.LocalPlayer.GetTruePosition();
Vector2 truePosition2 = component.TruePosition;
if (Vector2.Distance(truePosition2, truePosition) <= PlayerControl.LocalPlayer.MaxReportDistance && PlayerControl.LocalPlayer.CanMove && !PhysicsHelpers.AnythingBetween(truePosition, truePosition2, Constants.ShipAndObjectsMask, false)) {
GameData.PlayerInfo playerInfo = GameData.Instance.GetPlayerById(component.ParentId);

MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.CleanBody, Hazel.SendOption.Reliable, -1);
writer.Write(playerInfo.PlayerId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCProcedure.cleanBody(playerInfo.PlayerId);

Vulture.cooldown = vultureEatButton.Timer = vultureEatButton.MaxTimer;
Vulture.eatenBodies++;
break;
}
}
}
}
if (Vulture.eatenBodies == Vulture.vultureNumberToWin) {
MessageWriter winWriter = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.VultureWin, Hazel.SendOption.Reliable, -1);
AmongUsClient.Instance.FinishRpcImmediately(winWriter);
RPCProcedure.vultureWin();
return;
}
},
() => { return Vulture.vulture != null && Vulture.vulture == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead; },
() => { return __instance.ReportButton.renderer.color == Palette.EnabledColor && PlayerControl.LocalPlayer.CanMove; },
() => { vultureEatButton.Timer = vultureEatButton.MaxTimer; },
Vulture.getButtonSprite(),
new Vector3(-1.3f, 0f, 0f),
__instance,
KeyCode.F
);

// Medium button
mediumButton = new CustomButton(
() => {
if (Medium.target != null) {
Medium.soulTarget = Medium.target;
mediumButton.HasEffect = true;
}
},
() => { return Medium.medium != null && Medium.medium == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead; },
() => {
if (mediumButton.isEffectActive && Medium.target != Medium.soulTarget) {
Medium.soulTarget = null;
mediumButton.Timer = 0f;
mediumButton.isEffectActive = false;
}
return Medium.target != null && PlayerControl.LocalPlayer.CanMove;
},
() => {
mediumButton.Timer = mediumButton.MaxTimer;
mediumButton.isEffectActive = false;
Medium.soulTarget = null;
},
Medium.getQuestionSprite(),
new Vector3(-1.3f, 0f, 0f),
__instance,
KeyCode.Q,
true,
Medium.duration,
() => {
mediumButton.Timer = mediumButton.MaxTimer;
if (Medium.target == null || Medium.target.player == null) return;
string msg = "";

int randomNumber = Medium.target.player.PlayerId == Mini.mini?.PlayerId ? TheOtherRoles.rnd.Next(4) : TheOtherRoles.rnd.Next(5);
string typeOfColor = Helpers.isLighterColor(Medium.target.killerIfExisting.Data.ColorId) ? "lighter" : "darker";
float timeSinceDeath = ((float)(Medium.meetingStartTime - Medium.target.timeOfDeath).TotalMilliseconds);

if (randomNumber == 0) msg = "What is your Name? My name is " + Medium.target.player.Data.PlayerName;
else if (randomNumber == 1) msg = "What is your role? My role is " + RoleInfo.GetRole(Medium.target.player);
else if (randomNumber == 2) msg = "What is your killer`s color type? My killer is a " + typeOfColor + " color";
else if (randomNumber == 3) msg = "When did you die? I have died " + Math.Round(timeSinceDeath / 1000) + "s before meeting started";
else msg = "What is your killer`s role? My killer is " + RoleInfo.GetRole(Medium.target.killerIfExisting); //exlude mini

DestroyableSingleton<HudManager>.Instance.Chat.AddChat(PlayerControl.LocalPlayer, $"{msg}");

// Remove soul
if (Medium.oneTimeUse) {
float closestDistance = float.MaxValue;
SpriteRenderer target = null;

foreach ((DeadPlayer db, Vector3 ps) in Medium.deadBodies) {
if (db == Medium.target) {
Tuple<DeadPlayer, Vector3> deadBody = Tuple.Create(db, ps);
Medium.deadBodies.Remove(deadBody);
break;
}

}
foreach (SpriteRenderer rend in Medium.souls) {
float distance = Vector2.Distance(rend.transform.position, PlayerControl.LocalPlayer.GetTruePosition());
if (distance < closestDistance) {
closestDistance = distance;
target = rend;
}
}

HudManager.Instance.StartCoroutine(Effects.Lerp(5f, new Action<float>((p) => {
if (target != null) {
var tmp = target.color;
tmp.a = Mathf.Clamp01(1 - p);
target.color = tmp;
}
if (p == 1f && target != null && target.gameObject != null) UnityEngine.Object.Destroy(target.gameObject);
})));

Medium.souls.Remove(target);
}
}
);


// Set the default (or settings from the previous game) timers/durations when spawning the buttons
setCustomButtonCooldowns();
}
Expand Down
29 changes: 26 additions & 3 deletions TheOtherRoles/CustomOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public class CustomOptionHolder {
public static CustomOption guesserSpawnRate;
public static CustomOption guesserIsImpGuesserRate;
public static CustomOption guesserNumberOfShots;
public static CustomOption guesserHasMultipleShotsPerMeeting;

public static CustomOption jesterSpawnRate;
public static CustomOption jesterCanCallEmergency;
Expand All @@ -73,6 +74,7 @@ public class CustomOptionHolder {
public static CustomOption jackalPromotedFromSidekickCanCreateSidekick;
public static CustomOption jackalCanCreateSidekickFromImpostor;
public static CustomOption jackalAndSidekickHaveImpostorVision;
public static CustomOption jackalCanSeeEngineerVent;

public static CustomOption bountyHunterSpawnRate;
public static CustomOption bountyHunterBountyDuration;
Expand Down Expand Up @@ -166,6 +168,16 @@ public class CustomOptionHolder {
public static CustomOption baitHighlightAllVents;
public static CustomOption baitReportDelay;

public static CustomOption vultureSpawnRate;
public static CustomOption vultureCooldown;
public static CustomOption vultureNumberToWin;
public static CustomOption vultureCanUseVents;

public static CustomOption mediumSpawnRate;
public static CustomOption mediumCooldown;
public static CustomOption mediumDuration;
public static CustomOption mediumOneTimeUse;

public static CustomOption maxNumberOfMeetings;
public static CustomOption blockSkippingInEmergencyMeetings;
public static CustomOption noVoteIsSelfVote;
Expand Down Expand Up @@ -246,6 +258,7 @@ public static void Load() {
guesserSpawnRate = CustomOption.Create(310, cs(Guesser.color, "Guesser"), rates, null, true);
guesserIsImpGuesserRate = CustomOption.Create(311, "Chance That The Guesser Is An Impostor", rates, guesserSpawnRate);
guesserNumberOfShots = CustomOption.Create(312, "Guesser Number Of Shots", 2f, 1f, 15f, 1f, guesserSpawnRate);
guesserHasMultipleShotsPerMeeting = CustomOption.Create(313, "Guesser Can Shoot Multiple Times Per Meeting", false, guesserSpawnRate);

jesterSpawnRate = CustomOption.Create(60, cs(Jester.color, "Jester"), rates, null, true);
jesterCanCallEmergency = CustomOption.Create(61, "Jester can call emergency meeting", true, jesterSpawnRate);
Expand All @@ -266,6 +279,12 @@ public static void Load() {
jackalPromotedFromSidekickCanCreateSidekick = CustomOption.Create(228, "Jackals Promoted From Sidekick Can Create A Sidekick", true, jackalSpawnRate);
jackalCanCreateSidekickFromImpostor = CustomOption.Create(229, "Jackals Can Make An Impostor To His Sidekick", true, jackalSpawnRate);
jackalAndSidekickHaveImpostorVision = CustomOption.Create(430, "Jackal And Sidekick Have Impostor Vision", false, jackalSpawnRate);
jackalCanSeeEngineerVent = CustomOption.Create(431, "Jackal Can See If Engineer Is In A Vent", false, jackalSpawnRate);

vultureSpawnRate = CustomOption.Create(340, cs(Vulture.color, "Vulture"), rates, null, true);
vultureCooldown = CustomOption.Create(341, "Vulture Cooldown", 15f, 10f, 60f, 2.5f, vultureSpawnRate);
vultureNumberToWin = CustomOption.Create(342, "Number Of Corpses Needed To Be Eaten", 4f, 0f, 5f, 1f, vultureSpawnRate);
vultureCanUseVents = CustomOption.Create(343, "Vulture Can Use Vents", true, vultureSpawnRate);

shifterSpawnRate = CustomOption.Create(70, cs(Shifter.color, "Shifter"), rates, null, true);
shifterShiftsModifiers = CustomOption.Create(71, "Shifter Shifts Modifiers", false, shifterSpawnRate);
Expand All @@ -278,7 +297,6 @@ public static void Load() {
sheriffCooldown = CustomOption.Create(101, "Sheriff Cooldown", 30f, 10f, 60f, 2.5f, sheriffSpawnRate);
sheriffCanKillNeutrals = CustomOption.Create(102, "Sheriff Can Kill Neutrals", false, sheriffSpawnRate);


lighterSpawnRate = CustomOption.Create(110, cs(Lighter.color, "Lighter"), rates, null, true);
lighterModeLightsOnVision = CustomOption.Create(111, "Lighter Mode Vision On Lights On", 2f, 0.25f, 5f, 0.25f, lighterSpawnRate);
lighterModeLightsOffVision = CustomOption.Create(112, "Lighter Mode Vision On Lights Off", 0.75f, 0.25f, 5f, 0.25f, lighterSpawnRate);
Expand Down Expand Up @@ -340,6 +358,11 @@ public static void Load() {
baitHighlightAllVents = CustomOption.Create(331, "Highlight All Vents If A Vent Is Occupied", false, baitSpawnRate);
baitReportDelay = CustomOption.Create(332, "Bait Report Delay", 0f, 0f, 10f, 1f, baitSpawnRate);

mediumSpawnRate = CustomOption.Create(360, cs(Medium.color, "Medium"), rates, null, true);
mediumCooldown = CustomOption.Create(361, "Medium Questioning Cooldown", 30f, 5f, 120f, 5f, mediumSpawnRate);
mediumDuration = CustomOption.Create(362, "Medium Questioning Duration", 3f, 0f, 15f, 1f, mediumSpawnRate);
mediumOneTimeUse = CustomOption.Create(363, "Each Soul Can Only Be Questioned Once", false, mediumSpawnRate);

// Other options
maxNumberOfMeetings = CustomOption.Create(3, "Number Of Meetings (excluding Mayor meeting)", 10, 0, 15, 1, null, true);
blockSkippingInEmergencyMeetings = CustomOption.Create(4, "Block Skipping In Emergency Meetings", false);
Expand Down Expand Up @@ -658,7 +681,7 @@ private static void Postfix(ref string __result)
var hudString = sb.ToString();

int defaultSettingsLines = 19;
int roleSettingsLines = defaultSettingsLines + 35;
int roleSettingsLines = defaultSettingsLines + 37;
int detailedSettingsP1 = roleSettingsLines + 37;
int detailedSettingsP2 = detailedSettingsP1 + 38;
int end1 = hudString.TakeWhile(c => (defaultSettingsLines -= (c == '\n' ? 1 : 0)) > 0).Count();
Expand All @@ -680,7 +703,7 @@ private static void Postfix(ref string __result)
gap = 18;
index = hudString.TakeWhile(c => (gap -= (c == '\n' ? 1 : 0)) > 0).Count();
hudString = hudString.Insert(index + 1, "\n");
gap = 22;
gap = 23;
index = hudString.TakeWhile(c => (gap -= (c == '\n' ? 1 : 0)) > 0).Count();
hudString = hudString.Insert(index + 1, "\n");
} else if (counter == 2) {
Expand Down
2 changes: 1 addition & 1 deletion TheOtherRoles/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public static bool isCustomServer() {
}

public static bool hasFakeTasks(this PlayerControl player) {
return (player == Jester.jester || player == Jackal.jackal || player == Sidekick.sidekick || player == Arsonist.arsonist || Jackal.formerJackals.Contains(player));
return (player == Jester.jester || player == Jackal.jackal || player == Sidekick.sidekick || player == Arsonist.arsonist || player == Vulture.vulture || Jackal.formerJackals.Contains(player));
}

public static bool canBeErased(this PlayerControl player) {
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.1";
public const string VersionString = "2.9.0";
public static System.Version Version = System.Version.Parse(VersionString);

public Harmony Harmony { get; } = new Harmony(Id);
Expand Down
6 changes: 3 additions & 3 deletions TheOtherRoles/Patches/CredentialsPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ namespace TheOtherRoles.Patches {
public static class CredentialsPatch {
public static string fullCredentials =
$@"<size=130%><color=#ff351f>TheOtherRoles</color></size> v{TheOtherRolesPlugin.Version.ToString()}
<size=80%>Modded by <color=#FCCE03FF>Eisbison</color>,
<color=#FCCE03FF>Thunderstorm584</color> & <color=#FCCE03FF>EndOfFile</color>
<size=80%>Modded by <color=#FCCE03FF>Eisbison</color>, <color=#FCCE03FF>EndOfFile</color>
<color=#FCCE03FF>Thunderstorm584</color> & <color=#FCCE03FF>Mallöris</color>
Button design by <color=#FCCE03FF>Bavari</color></size>";

public static string mainMenuCredentials =
$@"Modded by <color=#FCCE03FF>Eisbison</color>, <color=#FCCE03FF>Thunderstorm584</color> & <color=#FCCE03FF>EndOfFile</color>
$@"Modded by <color=#FCCE03FF>Eisbison</color>, <color=#FCCE03FF>Thunderstorm584</color>, <color=#FCCE03FF>EndOfFile</color> & <color=#FCCE03FF>Mallöris</color>
Design by <color=#FCCE03FF>Bavari</color>";

[HarmonyPatch(typeof(VersionShower), nameof(VersionShower.Start))]
Expand Down
Loading

0 comments on commit 14f185f

Please sign in to comment.