| [Cleaner](#cleaner) | [Swapper](#swapper) | [Thief](#thief) | [Invert](#invert) |
| [Warlock](#warlock) | [Seer](#seer) | | [Chameleon](#chameleon) |
| [Bounty Hunter](#bounty-hunter) | [Hacker](#hacker) | | [Shifter](#shifter)
-| [Witch](#witch) | [Tracker](#tracker) | | |
+| [Witch](#witch) | [Tracker](#tracker) | | [Armored](#armored) |
| [Ninja](#ninja) | [Snitch](#snitch) | | |
| [Bomber](#bomber) | [Spy](#spy) | | |
| [Yo-Yo](#yoyo) | [Portalmaker](#portalmaker) | | |
# Releases
| Among Us - Version| Mod Version | Link |
|----------|-------------|-----------------|
-| 2024.6.18s| v4.6.0| [Download](https://github.com/TheOtherRolesAU/TheOtherRoles/releases/download/v4.6.0/TheOtherRoles.zip)
-| 2024.3.5s| v4.5.3| [Download](https://github.com/TheOtherRolesAU/TheOtherRoles/releases/download/v4.5.3/TheOtherRoles.zip)
+| 2024.11.26| v4.7.0| [Download](https://github.com/TheOtherRolesAU/TheOtherRoles/releases/download/v4.7.0/TheOtherRoles.zip)
+| 2024.6.18| v4.6.0| [Download](https://github.com/TheOtherRolesAU/TheOtherRoles/releases/download/v4.6.0/TheOtherRoles.zip)
+
<details>
<summary>Click to show older versions</summary>
| Among Us - Version| Mod Version | Link |
|----------|-------------|-----------------|
+| 2024.3.5s| v4.5.3| [Download](https://github.com/TheOtherRolesAU/TheOtherRoles/releases/download/v4.5.3/TheOtherRoles.zip)
| 2024.3.5s| v4.5.2| [Download](https://github.com/TheOtherRolesAU/TheOtherRoles/releases/download/v4.5.2/TheOtherRoles.zip)
| 2023.11.28s| v4.5.1| [Download](https://github.com/TheOtherRolesAU/TheOtherRoles/releases/download/v4.5.1/TheOtherRoles.zip)
| 2023.11.28s| v4.5.0| [Download](https://github.com/TheOtherRolesAU/TheOtherRoles/releases/download/v4.5.0/TheOtherRoles.zip)
# Changelog
<details>
<summary>Click to show the Changelog</summary>
+
+**Version 4.7.0**
+- Updated to Among Us version 2024.11.26 (Vanilla Updates)
+- Added a new modifier, Armored. The first time the armored would die by an ordinary kill, they are protected by their Armor. (NesTT17 & Gendelo, idea by zFinnyX)
+- Added the possibility to use the shift keys to (re-)join a lobby, if you just left a lobby or you have a lobby code copied to the clipboard. (twix & Gendelo)
+- Added a setting to Guesser Mode: "Number Of Tasks Needed To Unlock Shooting For Crew Guesser" (NesTT17, idea by DracoL1ch & multiple other players)
+- Fixed a bug with the Tracker's Proximity Meter - it now disappears after the meeting if the target is dead and no new target can be tracked.
+- Fixed a bug with the "Fill Crewmates" option, where selecting a range for min/max neutral roles would often lead to players being plain crewmates without a role
+- Fixed a bug where a passive lover death of a role that can suicide would sometimes give the medium incorrect info.
+- Fixed a bug where the zoom out button would be shown to ghosts during meetings.
+- Changed the way options are shown in the menu: Disabling an option (e.g. a role or modifier spawn chance) will now hide its depending sub-options again (like pre 4.6.0 with the old menu)
+- Change: Significantly decreased the size of our mod by using compression. (Thanks to miniduikboat for giving us a gentle push)
+
-
-** Version 4.6.0**
+**Version 4.6.0**
- Updated to Among Us version 2024.6.18 (Vanilla Update with new UI elements and many Server Side Changes)
- Added a completely new UI for the Mod's Options, using the new Vanilla Design.
- Added a button to switch gamemodes in the lobby
- Fixed a bug where guessing a player would sometimes not return the votes to the voters
- Fixed a bug where the Lawyer would not properly die when guessing the client
- Removed: Disabled Vanilla Servers for now, as the mod is incompatible with them in its / their current state. Thanks to Miniduikboat for making custom servers great again!
-- Experimental: Advanded users can try to install the mod on the Windows Store Version of Among Us. No Support Provided!
+- Experimental: Advanced users can try to install the mod on the Windows Store Version of Among Us. No Support Provided!
**Version 4.5.3**
Please note, that if the configured option exceeds the available number of tasks of a map, the tasks will be limited to that number of tasks. \
Example: If you configure 4 common tasks on Airship crewmates will only receive 2 common tasks, as airship doesn't offer more than 2 common tasks.
-
-| Map | Common Tasks | Short Tasks | Long Tasks |
-|----------|:-------------:|:-------------:|:-------------:|
-| Skeld / Dleks | 2 | 19 | 8
-| Mira HQ | 2 | 13 | 11
-| Polus | 4 | 14 | 15
-| Airship | 2 | 23 | 15
-----------------------
### Random Maps
## Morphling
### **Team: Impostors**
-The Morphling is an Impostor which can additionally scan the appearance of a player. After an arbitrary time they can take on that appearance for 10s.\
+The Morphling is an Impostor which can additionally scan the appearance of a player.\
+After an arbitrary time they can take on that appearance for a set duration which can be changed in the options.\
\
**NOTE:**
- They shrink to the size of the Mini when they copy its look.
|----------|:-------------:|
| Jester Spawn Chance | -
| Jester Can Call Emergency Meeting | Option to disable the emergency button for the Jester
+|Jester Has Impostor Vision | -
-----------------------
## Arsonist
| Name | Description |
|----------|:-------------:|
| Arsonist Spawn Chance | -
-| Arsonist Countdown | -
+| Arsonist Cooldown | -
| Arsonist Douse Duration | The time it takes to douse a player
-----------------------
- The Crew could be eliminated, then the Team Jackal fight against the Impostors (The Crew can still make a task win in this scenario)
The priority of the win conditions is the following:
-1. Crewmate Mini lose by vote
-2. Jester wins by vote
+1. Jester wins by vote (even as Mini)
+2. Crewmate Mini lose by vote
3. Arsonist win
4. Team Impostor wins by sabotage
5. Team Crew wins by tasks (also possible if the whole Crew is dead)
### Game Options
| Name | Description
|----------|:-------------:|
-| Jackal Spawn Chance | - |
-| Jackal/Sidekick Kill Cooldown | Kill cooldown |
-| Jackal Create Sidekick Cooldown | Cooldown before a Sidekick can be created |
-| Jackal can use vents | Yes/No |
-| Jackal can sabotage Lights | Yes/No |
-| Jackal can create a Sidekick | Yes/No |
-| Sidekick gets promoted to Jackal on Jackal Death | Yes/No |
-| Sidekick can kill | Yes/No |
-| Sidekick can Vent | Yes/No |
-| Jackal can sabotage Lights | Yes/No |
-| Jackals promoted from Sidekick can create a Sidekick | Yes/No (to prevent the Jackal team from growing) |
-| Jackals can make an Impostor to their Sidekick | Yes/No (to prevent a Jackal from turning an Impostor into a Sidekick, if they use the ability on an Impostor they see the Impostor as Sidekick, but the Impostor isn't converted to Sidekick. If this option is set to "No" Jackal and Sidekick can kill each other.) |
-| Jackal and Sidekick have Impostor vision | - |
+| Jackal Spawn Chance | -
+| Jackal/Sidekick Kill Cooldown | Kill Cooldown
+| Jackal Create Sidekick Cooldown | Cooldown before a Sidekick can be created
+| Jackal Can Use Vents | Yes/No
+| Jackal Can Sabotage Lights | Yes/No
+| Jackal Can Create A Sidekick | Yes/No
+| Sidekick Gets Promoted To Jackal On Jackal Death | Yes/No
+| Sidekick Can Kill | Yes/No
+| Sidekick Can Vent | Yes/No
+| Sidekick Can Sabotage Lights | Yes/No
+| Jackals Promoted From Sidekick Can Create A Sidekick | Yes/No (to prevent the Jackal team from growing)
+| Jackals Can Make An Impostor To His Sidekick | Yes/No (to prevent a Jackal from turning an Impostor into a Sidekick, if they use the ability on an Impostor they see the Impostor as Sidekick, but the Impostor isn't converted to Sidekick. If this option is set to "No" Jackal and Sidekick can kill each other.)
+| Jackal And Sidekick Have Impostor Vision | -
-----------------------
## Sidekick
| Name | Description
|----------|:-------------:|
| Jackal/Sidekick Kill Cooldown | Uses the same kill cooldown setting as the Jackal |
-| Sidekick gets promoted to Jackal on Jackal death | Yes/No |
-| Sidekick can kill | Yes/No |
-| Sidekick can use vents | Yes/No |
+| Sidekick Gets Promoted To Jackal On Jackal Death | Yes/No |
+| Sidekick Can Kill | Yes/No |
+| Sidekick Can Use Vents | Yes/No |
-----------------------
## Vulture
The Engineer (if alive) can fix a certain amount of sabotages per game from anywhere on the map.\
The Engineer can use vents.\
If the Engineer is inside a vent, depending on the options the members of the team Jackal/Impostors will see a blue outline around all vents on the map (in order to warn them).\
-Because of the vents the Engineer might not be able to start some tasks using the "Use" button, you can double-click on the tasks instead.
**NOTE:**
- The kill button of Impostors activates if they stand next to a vent where the Engineer is. They can also kill them there. No other action (e.g. Morphling sample, Shifter shift, ...) can affect players inside vents.
| Engineer Spawn Chance | -
| Number Of Sabotage Fixes| -
| Impostors See Vents Highlighted | -
-| Jackal and Sidekick See Vents Highlighted | -
+| Jackal And Sidekick See Vents Highlighted | -
-----------------------
## Sheriff
| Name | Description
|----------|:-------------:|
| Swapper Spawn Chance | -
-| Swapper can call emergency meeting | Option to disable the emergency button for the Swapper
-| Swapper can only swap others | Sets whether the Swapper can swap themself or not
+| Swapper Can Call Emergency Meeting | Option to disable the emergency button for the Swapper
+| Swapper Can Only Swap Others | Sets whether the Swapper can swap themself or not
| Initial Swap Charges | -
| Number Of Tasks Needed For Recharging | -
-----------------------
|----------|:-------------:|
| Bloody Spawn Chance | -
| Bloody Quantity | -
-| Trail duration | -
+| Trail Duration | -
-----------------------
## Anti Teleport
|----------|:-------------:|
| Sunglasses Spawn Chance | -
| Sunglasses Quantity | -
-| Vision with sunglasses | -
+| Vision With Sunglasses | -
-----------------------
## Mini
| Shifter Spawn Chance | -
-----------------------
+## Armored
+
+The Armored is a Modifier that protects the player from the first shot that would have killed them. There can only be one Armored player per round.
+\
+**NOTE:**
+- Armored is only active during the round and does not protect from guesses or votes.
+- Armored is applied after all other shields or protections, so that the Armor only breaks if the player would have otherwise died.
+- If a killer tries to kill the Armored, they will see the Armor break with a nice animation.
+- The Armored player has no indicator whatsoever if the Armor is still active, unless they break it (Warlock, Sheriff, Thief)
+
+### Game Options
+| Name | Description
+|----------|:-------------:|
+| Armored Spawn Chance | -
+-----------------------
+
# Gamemodes
Gamemodes can be switched when creating a lobby or inside the lobby by using a command in the chat:
`/gm <gamemode>`. Use the following gamemodes: `guess` or `gm`,`prophunt` or `ph`, `hidenseek` or `hns`. If `/gm` is used without argument or the argument can't be parsed, the lobby will switch to classic mode.
| Guessers Can Have A Modifier | -
| Guesser Number Of Shots | -
| Guesser Can Shoot Multiple Times Per Meeting | -
+| Number Of Tasks Needed To Unlock Shooting For Crew Guesser | -
| Guesses Ignore The Medic Shield | -
| Evil Guesser Can Guess The Spy | -
| Guesser Can't Guess Snitch When Tasks Completed | -
| Unstuck Duration | - | Kill Cooldown After Hit | - | Invisibility Duration | -
| Hunter Vision | - | Reveal Prop Cooldown | - | Speedboost Enabled | -
| Prop Vision | - | Reveal Prop Duration | - | Speedboost Cooldown | -
-| | - | Reveal Time Punish | deducted from rem. timer | Speedboost Duration | -
+| | - | Reveal Time Punish | Deducted from rem. timer | Speedboost Duration | -
| | - | Hunter Admin Cooldown | - | Speedboost Ratio | Factor with which speed is multiplied
| | - | Find Cooldown | -
| | - | Find Duration | -
using TheOtherRoles.Objects;
using System.Linq;
using System.Collections.Generic;
-using TheOtherRoles.Players;
using TheOtherRoles.Utilities;
using TheOtherRoles.CustomGameModes;
using TheOtherRoles.Patches;
replacementHandcuffedButton.Timer = replacementHandcuffedButton.EffectDuration;
replacementHandcuffedButton.actionButton.cooldownTimerText.color = new Color(0F, 0.8F, 0F);
replacementHandcuffedButton.isEffectActive = true;
- if (deputyHandcuffedButtons.ContainsKey(CachedPlayer.LocalPlayer.PlayerId))
- deputyHandcuffedButtons[CachedPlayer.LocalPlayer.PlayerId].Add(replacementHandcuffedButton);
+ if (deputyHandcuffedButtons.ContainsKey(PlayerControl.LocalPlayer.PlayerId))
+ deputyHandcuffedButtons[PlayerControl.LocalPlayer.PlayerId].Add(replacementHandcuffedButton);
else
- deputyHandcuffedButtons.Add(CachedPlayer.LocalPlayer.PlayerId, new List<CustomButton> { replacementHandcuffedButton });
+ deputyHandcuffedButtons.Add(PlayerControl.LocalPlayer.PlayerId, new List<CustomButton> { replacementHandcuffedButton });
}
// Disables / Enables all Buttons (except the ones disabled in the Deputy class), and replaces them with new buttons.
deputyHandcuffedButtons = new Dictionary<byte, List<CustomButton>>();
return;
}
- if (handcuffed && !deputyHandcuffedButtons.ContainsKey(CachedPlayer.LocalPlayer.PlayerId))
+ if (handcuffed && !deputyHandcuffedButtons.ContainsKey(PlayerControl.LocalPlayer.PlayerId))
{
int maxI = CustomButton.buttons.Count;
for (int i = 0; i < maxI; i++)
// Kill Button if enabled for the Role
if (FastDestroyableSingleton<HudManager>.Instance.KillButton.isActiveAndEnabled) addReplacementHandcuffedButton(arsonistButton, CustomButton.ButtonPositions.upperRowRight, couldUse: () => { return FastDestroyableSingleton<HudManager>.Instance.KillButton.currentTarget != null; });
// Vent Button if enabled
- if (CachedPlayer.LocalPlayer.PlayerControl.roleCanUseVents()) addReplacementHandcuffedButton(arsonistButton, CustomButton.ButtonPositions.upperRowCenter, couldUse: () => { return FastDestroyableSingleton<HudManager>.Instance.ImpostorVentButton.currentTarget != null; });
+ if (PlayerControl.LocalPlayer.roleCanUseVents()) addReplacementHandcuffedButton(arsonistButton, CustomButton.ButtonPositions.upperRowCenter, couldUse: () => { return FastDestroyableSingleton<HudManager>.Instance.ImpostorVentButton.currentTarget != null; });
// Report Button
- addReplacementHandcuffedButton(arsonistButton, (!CachedPlayer.LocalPlayer.Data.Role.IsImpostor) ? new Vector3(-1f, -0.06f, 0): CustomButton.ButtonPositions.lowerRowRight, () => { return FastDestroyableSingleton<HudManager>.Instance.ReportButton.graphic.color == Palette.EnabledColor; });
+ addReplacementHandcuffedButton(arsonistButton, (!PlayerControl.LocalPlayer.Data.Role.IsImpostor) ? new Vector3(-1f, -0.06f, 0): CustomButton.ButtonPositions.lowerRowRight, () => { return FastDestroyableSingleton<HudManager>.Instance.ReportButton.graphic.color == Palette.EnabledColor; });
}
- else if (!handcuffed && deputyHandcuffedButtons.ContainsKey(CachedPlayer.LocalPlayer.PlayerId)) // Reset to original. Disables the replacements, enables the original buttons.
+ else if (!handcuffed && deputyHandcuffedButtons.ContainsKey(PlayerControl.LocalPlayer.PlayerId)) // Reset to original. Disables the replacements, enables the original buttons.
{
- foreach (CustomButton replacementButton in deputyHandcuffedButtons[CachedPlayer.LocalPlayer.PlayerId])
+ foreach (CustomButton replacementButton in deputyHandcuffedButtons[PlayerControl.LocalPlayer.PlayerId])
{
replacementButton.HasButton = () => { return false; };
replacementButton.Update(); // To make it disappear properly.
CustomButton.buttons.Remove(replacementButton);
}
- deputyHandcuffedButtons.Remove(CachedPlayer.LocalPlayer.PlayerId);
+ deputyHandcuffedButtons.Remove(PlayerControl.LocalPlayer.PlayerId);
foreach (CustomButton button in CustomButton.buttons)
{
engineerRepairButton = new CustomButton(
() => {
engineerRepairButton.Timer = 0f;
- MessageWriter usedRepairWriter = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.EngineerUsedRepair, Hazel.SendOption.Reliable, -1);
+ MessageWriter usedRepairWriter = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.EngineerUsedRepair, Hazel.SendOption.Reliable, -1);
AmongUsClient.Instance.FinishRpcImmediately(usedRepairWriter);
RPCProcedure.engineerUsedRepair();
SoundEffectsManager.play("engineerRepair");
- foreach (PlayerTask task in CachedPlayer.LocalPlayer.PlayerControl.myTasks.GetFastEnumerator()) {
+ foreach (PlayerTask task in PlayerControl.LocalPlayer.myTasks.GetFastEnumerator()) {
if (task.TaskType == TaskTypes.FixLights) {
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.EngineerFixLights, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.EngineerFixLights, Hazel.SendOption.Reliable, -1);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCProcedure.engineerFixLights();
} else if (task.TaskType == TaskTypes.RestoreOxy) {
MapUtilities.CachedShipStatus.RpcRepairSystem(SystemTypes.Reactor, 0 | 16);
MapUtilities.CachedShipStatus.RpcRepairSystem(SystemTypes.Reactor, 1 | 16);
} else if (SubmergedCompatibility.IsSubmerged && task.TaskType == SubmergedCompatibility.RetrieveOxygenMask) {
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.EngineerFixSubmergedOxygen, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.EngineerFixSubmergedOxygen, Hazel.SendOption.Reliable, -1);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCProcedure.engineerFixSubmergedOxygen();
}
}
},
- () => { return Engineer.engineer != null && Engineer.engineer == CachedPlayer.LocalPlayer.PlayerControl && Engineer.remainingFixes > 0 && !CachedPlayer.LocalPlayer.Data.IsDead; },
+ () => { return Engineer.engineer != null && Engineer.engineer == PlayerControl.LocalPlayer && Engineer.remainingFixes > 0 && !PlayerControl.LocalPlayer.Data.IsDead; },
() => {
bool sabotageActive = false;
- foreach (PlayerTask task in CachedPlayer.LocalPlayer.PlayerControl.myTasks.GetFastEnumerator())
+ foreach (PlayerTask task in PlayerControl.LocalPlayer.myTasks.GetFastEnumerator())
if (task.TaskType == TaskTypes.FixLights || task.TaskType == TaskTypes.RestoreOxy || task.TaskType == TaskTypes.ResetReactor || task.TaskType == TaskTypes.ResetSeismic || task.TaskType == TaskTypes.FixComms || task.TaskType == TaskTypes.StopCharles
|| SubmergedCompatibility.IsSubmerged && task.TaskType == SubmergedCompatibility.RetrieveOxygenMask)
sabotageActive = true;
- return sabotageActive && Engineer.remainingFixes > 0 && CachedPlayer.LocalPlayer.PlayerControl.CanMove;
+ return sabotageActive && Engineer.remainingFixes > 0 && PlayerControl.LocalPlayer.CanMove;
},
() => {},
Engineer.getButtonSprite(),
// Janitor Clean
janitorCleanButton = new CustomButton(
() => {
- foreach (Collider2D collider2D in Physics2D.OverlapCircleAll(CachedPlayer.LocalPlayer.PlayerControl.GetTruePosition(), CachedPlayer.LocalPlayer.PlayerControl.MaxReportDistance, Constants.PlayersOnlyMask)) {
+ 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 = CachedPlayer.LocalPlayer.PlayerControl.GetTruePosition();
+ Vector2 truePosition = PlayerControl.LocalPlayer.GetTruePosition();
Vector2 truePosition2 = component.TruePosition;
- if (Vector2.Distance(truePosition2, truePosition) <= CachedPlayer.LocalPlayer.PlayerControl.MaxReportDistance && CachedPlayer.LocalPlayer.PlayerControl.CanMove && !PhysicsHelpers.AnythingBetween(truePosition, truePosition2, Constants.ShipAndObjectsMask, false))
+ if (Vector2.Distance(truePosition2, truePosition) <= PlayerControl.LocalPlayer.MaxReportDistance && PlayerControl.LocalPlayer.CanMove && !PhysicsHelpers.AnythingBetween(truePosition, truePosition2, Constants.ShipAndObjectsMask, false))
{
NetworkedPlayerInfo playerInfo = GameData.Instance.GetPlayerById(component.ParentId);
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.CleanBody, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.CleanBody, Hazel.SendOption.Reliable, -1);
writer.Write(playerInfo.PlayerId);
writer.Write(Janitor.janitor.PlayerId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
}
}
},
- () => { return Janitor.janitor != null && Janitor.janitor == CachedPlayer.LocalPlayer.PlayerControl && !CachedPlayer.LocalPlayer.Data.IsDead; },
- () => { return __instance.ReportButton.graphic.color == Palette.EnabledColor && CachedPlayer.LocalPlayer.PlayerControl.CanMove; },
+ () => { return Janitor.janitor != null && Janitor.janitor == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead; },
+ () => { return __instance.ReportButton.graphic.color == Palette.EnabledColor && PlayerControl.LocalPlayer.CanMove; },
() => { janitorCleanButton.Timer = janitorCleanButton.MaxTimer; },
Janitor.getButtonSprite(),
CustomButton.ButtonPositions.upperRowLeft,
targetId = Sheriff.currentTarget.PlayerId;
}
else {
- targetId = CachedPlayer.LocalPlayer.PlayerId;
+ targetId = PlayerControl.LocalPlayer.PlayerId;
}
- MessageWriter killWriter = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.UncheckedMurderPlayer, Hazel.SendOption.Reliable, -1);
+ // Armored sheriff shot doesnt kill if backfired
+ if (targetId == Sheriff.sheriff.PlayerId && Helpers.checkArmored(Sheriff.sheriff, true, true))
+ return;
+ MessageWriter killWriter = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.UncheckedMurderPlayer, Hazel.SendOption.Reliable, -1);
killWriter.Write(Sheriff.sheriff.Data.PlayerId);
killWriter.Write(targetId);
killWriter.Write(byte.MaxValue);
sheriffKillButton.Timer = sheriffKillButton.MaxTimer;
Sheriff.currentTarget = null;
},
- () => { return Sheriff.sheriff != null && Sheriff.sheriff == CachedPlayer.LocalPlayer.PlayerControl && !CachedPlayer.LocalPlayer.Data.IsDead; },
- () => { return Sheriff.currentTarget && CachedPlayer.LocalPlayer.PlayerControl.CanMove; },
+ () => { return Sheriff.sheriff != null && Sheriff.sheriff == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead; },
+ () => { return Sheriff.currentTarget && PlayerControl.LocalPlayer.CanMove; },
() => { sheriffKillButton.Timer = sheriffKillButton.MaxTimer;},
__instance.KillButton.graphic.sprite,
CustomButton.ButtonPositions.upperRowRight,
deputyHandcuffButton = new CustomButton(
() => {
byte targetId = 0;
- targetId = Sheriff.sheriff == CachedPlayer.LocalPlayer.PlayerControl ? Sheriff.currentTarget.PlayerId : Deputy.currentTarget.PlayerId; // If the deputy is now the sheriff, sheriffs target, else deputies target
+ targetId = Sheriff.sheriff == PlayerControl.LocalPlayer ? Sheriff.currentTarget.PlayerId : Deputy.currentTarget.PlayerId; // If the deputy is now the sheriff, sheriffs target, else deputies target
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.DeputyUsedHandcuffs, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.DeputyUsedHandcuffs, Hazel.SendOption.Reliable, -1);
writer.Write(targetId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCProcedure.deputyUsedHandcuffs(targetId);
SoundEffectsManager.play("deputyHandcuff");
},
- () => { return (Deputy.deputy != null && Deputy.deputy == CachedPlayer.LocalPlayer.PlayerControl || Sheriff.sheriff != null && Sheriff.sheriff == CachedPlayer.LocalPlayer.PlayerControl && Sheriff.sheriff == Sheriff.formerDeputy && Deputy.keepsHandcuffsOnPromotion) && !CachedPlayer.LocalPlayer.Data.IsDead; },
+ () => { return (Deputy.deputy != null && Deputy.deputy == PlayerControl.LocalPlayer || Sheriff.sheriff != null && Sheriff.sheriff == PlayerControl.LocalPlayer && Sheriff.sheriff == Sheriff.formerDeputy && Deputy.keepsHandcuffsOnPromotion) && !PlayerControl.LocalPlayer.Data.IsDead; },
() => {
if (deputyButtonHandcuffsText != null) deputyButtonHandcuffsText.text = $"{Deputy.remainingHandcuffs}";
- return ((Deputy.deputy != null && Deputy.deputy == CachedPlayer.LocalPlayer.PlayerControl && Deputy.currentTarget || Sheriff.sheriff != null && Sheriff.sheriff == CachedPlayer.LocalPlayer.PlayerControl && Sheriff.sheriff == Sheriff.formerDeputy && Sheriff.currentTarget) && Deputy.remainingHandcuffs > 0 && CachedPlayer.LocalPlayer.PlayerControl.CanMove);
+ return ((Deputy.deputy != null && Deputy.deputy == PlayerControl.LocalPlayer && Deputy.currentTarget || Sheriff.sheriff != null && Sheriff.sheriff == PlayerControl.LocalPlayer && Sheriff.sheriff == Sheriff.formerDeputy && Sheriff.currentTarget) && Deputy.remainingHandcuffs > 0 && PlayerControl.LocalPlayer.CanMove);
},
() => { deputyHandcuffButton.Timer = deputyHandcuffButton.MaxTimer; },
Deputy.getButtonSprite(),
// Time Master Rewind Time
timeMasterShieldButton = new CustomButton(
() => {
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.TimeMasterShield, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.TimeMasterShield, Hazel.SendOption.Reliable, -1);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCProcedure.timeMasterShield();
SoundEffectsManager.play("timemasterShield");
},
- () => { return TimeMaster.timeMaster != null && TimeMaster.timeMaster == CachedPlayer.LocalPlayer.PlayerControl && !CachedPlayer.LocalPlayer.Data.IsDead; },
- () => { return CachedPlayer.LocalPlayer.PlayerControl.CanMove; },
+ () => { return TimeMaster.timeMaster != null && TimeMaster.timeMaster == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead; },
+ () => { return PlayerControl.LocalPlayer.CanMove; },
() => {
timeMasterShieldButton.Timer = timeMasterShieldButton.MaxTimer;
timeMasterShieldButton.isEffectActive = false;
() => {
medicShieldButton.Timer = 0f;
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, Medic.setShieldAfterMeeting ? (byte)CustomRPC.SetFutureShielded : (byte)CustomRPC.MedicSetShielded, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, Medic.setShieldAfterMeeting ? (byte)CustomRPC.SetFutureShielded : (byte)CustomRPC.MedicSetShielded, Hazel.SendOption.Reliable, -1);
writer.Write(Medic.currentTarget.PlayerId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
if (Medic.setShieldAfterMeeting)
SoundEffectsManager.play("medicShield");
},
- () => { return Medic.medic != null && Medic.medic == CachedPlayer.LocalPlayer.PlayerControl && !CachedPlayer.LocalPlayer.Data.IsDead; },
- () => { return !Medic.usedShield && Medic.currentTarget && CachedPlayer.LocalPlayer.PlayerControl.CanMove; },
+ () => { return Medic.medic != null && Medic.medic == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead; },
+ () => { return !Medic.usedShield && Medic.currentTarget && PlayerControl.LocalPlayer.CanMove; },
() => {},
Medic.getButtonSprite(),
CustomButton.ButtonPositions.lowerRowRight,
// Shifter shift
shifterShiftButton = new CustomButton(
() => {
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.SetFutureShifted, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetFutureShifted, Hazel.SendOption.Reliable, -1);
writer.Write(Shifter.currentTarget.PlayerId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCProcedure.setFutureShifted(Shifter.currentTarget.PlayerId);
SoundEffectsManager.play("shifterShift");
},
- () => { return Shifter.shifter != null && Shifter.shifter == CachedPlayer.LocalPlayer.PlayerControl && Shifter.futureShift == null && !CachedPlayer.LocalPlayer.Data.IsDead; },
- () => { return Shifter.currentTarget && Shifter.futureShift == null && CachedPlayer.LocalPlayer.PlayerControl.CanMove; },
+ () => { return Shifter.shifter != null && Shifter.shifter == PlayerControl.LocalPlayer && Shifter.futureShift == null && !PlayerControl.LocalPlayer.Data.IsDead; },
+ () => { return Shifter.currentTarget && Shifter.futureShift == null && PlayerControl.LocalPlayer.CanMove; },
() => { },
Shifter.getButtonSprite(),
new Vector3(0, 1f, 0),
morphlingButton = new CustomButton(
() => {
if (Morphling.sampledTarget != null) {
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.MorphlingMorph, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.MorphlingMorph, Hazel.SendOption.Reliable, -1);
writer.Write(Morphling.sampledTarget.PlayerId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCProcedure.morphlingMorph(Morphling.sampledTarget.PlayerId);
setButtonTargetDisplay(Morphling.sampledTarget, morphlingButton);
}
},
- () => { return Morphling.morphling != null && Morphling.morphling == CachedPlayer.LocalPlayer.PlayerControl && !CachedPlayer.LocalPlayer.Data.IsDead; },
- () => { return (Morphling.currentTarget || Morphling.sampledTarget) && CachedPlayer.LocalPlayer.PlayerControl.CanMove && !Helpers.MushroomSabotageActive(); },
+ () => { return Morphling.morphling != null && Morphling.morphling == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead; },
+ () => { return (Morphling.currentTarget || Morphling.sampledTarget) && PlayerControl.LocalPlayer.CanMove && !Helpers.MushroomSabotageActive(); },
() => {
morphlingButton.Timer = morphlingButton.MaxTimer;
morphlingButton.Sprite = Morphling.getSampleSprite();
// Camouflager camouflage
camouflagerButton = new CustomButton(
() => {
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.CamouflagerCamouflage, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.CamouflagerCamouflage, Hazel.SendOption.Reliable, -1);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCProcedure.camouflagerCamouflage();
SoundEffectsManager.play("morphlingMorph");
},
- () => { return Camouflager.camouflager != null && Camouflager.camouflager == CachedPlayer.LocalPlayer.PlayerControl && !CachedPlayer.LocalPlayer.Data.IsDead; },
- () => { return CachedPlayer.LocalPlayer.PlayerControl.CanMove; },
+ () => { return Camouflager.camouflager != null && Camouflager.camouflager == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead; },
+ () => { return PlayerControl.LocalPlayer.CanMove; },
() => {
camouflagerButton.Timer = camouflagerButton.MaxTimer;
camouflagerButton.isEffectActive = false;
Hacker.hackerTimer = Hacker.duration;
SoundEffectsManager.play("hackerHack");
},
- () => { return Hacker.hacker != null && Hacker.hacker == CachedPlayer.LocalPlayer.PlayerControl && !CachedPlayer.LocalPlayer.Data.IsDead; },
+ () => { return Hacker.hacker != null && Hacker.hacker == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead; },
() => { return true; },
() => {
hackerButton.Timer = hackerButton.MaxTimer;
__instance.InitMap();
MapBehaviour.Instance.ShowCountOverlay(allowedToMove: true, showLivePlayerPosition: true, includeDeadBodies: true);
}
- if (Hacker.cantMove) CachedPlayer.LocalPlayer.PlayerControl.moveable = false;
- CachedPlayer.LocalPlayer.NetTransform.Halt(); // Stop current movement
+ if (Hacker.cantMove) PlayerControl.LocalPlayer.moveable = false;
+ PlayerControl.LocalPlayer.NetTransform.Halt(); // Stop current movement
Hacker.chargesAdminTable--;
},
- () => { return Hacker.hacker != null && Hacker.hacker == CachedPlayer.LocalPlayer.PlayerControl && !CachedPlayer.LocalPlayer.Data.IsDead;},
+ () => { return Hacker.hacker != null && Hacker.hacker == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead;},
() => {
if (hackerAdminTableChargesText != null) hackerAdminTableChargesText.text = $"{Hacker.chargesAdminTable} / {Hacker.toolsNumber}";
return Hacker.chargesAdminTable > 0;
0f,
() => {
hackerAdminTableButton.Timer = hackerAdminTableButton.MaxTimer;
- if (!hackerVitalsButton.isEffectActive) CachedPlayer.LocalPlayer.PlayerControl.moveable = true;
+ if (!hackerVitalsButton.isEffectActive) PlayerControl.LocalPlayer.moveable = true;
if (MapBehaviour.Instance && MapBehaviour.Instance.isActiveAndEnabled) MapBehaviour.Instance.Close();
},
GameOptionsManager.Instance.currentNormalGameOptions.MapId == 3,
Hacker.doorLog.Begin(null);
}
- if (Hacker.cantMove) CachedPlayer.LocalPlayer.PlayerControl.moveable = false;
- CachedPlayer.LocalPlayer.NetTransform.Halt(); // Stop current movement
+ if (Hacker.cantMove) PlayerControl.LocalPlayer.moveable = false;
+ PlayerControl.LocalPlayer.NetTransform.Halt(); // Stop current movement
Hacker.chargesVitals--;
},
- () => { return Hacker.hacker != null && Hacker.hacker == CachedPlayer.LocalPlayer.PlayerControl && !CachedPlayer.LocalPlayer.Data.IsDead && GameOptionsManager.Instance.currentGameOptions.MapId != 0 && GameOptionsManager.Instance.currentNormalGameOptions.MapId != 3; },
+ () => { return Hacker.hacker != null && Hacker.hacker == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead && GameOptionsManager.Instance.currentGameOptions.MapId != 0 && GameOptionsManager.Instance.currentNormalGameOptions.MapId != 3; },
() => {
if (hackerVitalsChargesText != null) hackerVitalsChargesText.text = $"{Hacker.chargesVitals} / {Hacker.toolsNumber}";
hackerVitalsButton.actionButton.graphic.sprite = Helpers.isMira() ? Hacker.getLogSprite() : Hacker.getVitalsSprite();
0f,
() => {
hackerVitalsButton.Timer = hackerVitalsButton.MaxTimer;
- if (!hackerAdminTableButton.isEffectActive) CachedPlayer.LocalPlayer.PlayerControl.moveable = true;
+ if (!hackerAdminTableButton.isEffectActive) PlayerControl.LocalPlayer.moveable = true;
if (Minigame.Instance) {
if (Helpers.isMira()) Hacker.doorLog.ForceClose();
else Hacker.vitals.ForceClose();
// Tracker button
trackerTrackPlayerButton = new CustomButton(
() => {
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.TrackerUsedTracker, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.TrackerUsedTracker, Hazel.SendOption.Reliable, -1);
writer.Write(Tracker.currentTarget.PlayerId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCProcedure.trackerUsedTracker(Tracker.currentTarget.PlayerId);
SoundEffectsManager.play("trackerTrackPlayer");
},
- () => { return Tracker.tracker != null && Tracker.tracker == CachedPlayer.LocalPlayer.PlayerControl && !CachedPlayer.LocalPlayer.Data.IsDead; },
- () => { return CachedPlayer.LocalPlayer.PlayerControl.CanMove && Tracker.currentTarget != null && !Tracker.usedTracker; },
- () => { if(Tracker.resetTargetAfterMeeting) Tracker.resetTracked(); },
+ () => { return Tracker.tracker != null && Tracker.tracker == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead; },
+ () => { return PlayerControl.LocalPlayer.CanMove && Tracker.currentTarget != null && !Tracker.usedTracker; },
+ () => { if (Tracker.resetTargetAfterMeeting) Tracker.resetTracked();
+ else if (Tracker.currentTarget != null && Tracker.currentTarget.Data.IsDead) Tracker.currentTarget = null; },
Tracker.getButtonSprite(),
CustomButton.ButtonPositions.lowerRowRight,
__instance,
trackerTrackCorpsesButton = new CustomButton(
() => { Tracker.corpsesTrackingTimer = Tracker.corpsesTrackingDuration;
SoundEffectsManager.play("trackerTrackCorpses"); },
- () => { return Tracker.tracker != null && Tracker.tracker == CachedPlayer.LocalPlayer.PlayerControl && !CachedPlayer.LocalPlayer.Data.IsDead && Tracker.canTrackCorpses; },
- () => { return CachedPlayer.LocalPlayer.PlayerControl.CanMove; },
+ () => { return Tracker.tracker != null && Tracker.tracker == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead && Tracker.canTrackCorpses; },
+ () => { return PlayerControl.LocalPlayer.CanMove; },
() => {
trackerTrackCorpsesButton.Timer = trackerTrackCorpsesButton.MaxTimer;
trackerTrackCorpsesButton.isEffectActive = false;
MurderAttemptResult murder = Helpers.checkMuderAttempt(Vampire.vampire, Vampire.currentTarget);
if (murder == MurderAttemptResult.PerformKill) {
if (Vampire.targetNearGarlic) {
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.UncheckedMurderPlayer, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.UncheckedMurderPlayer, Hazel.SendOption.Reliable, -1);
writer.Write(Vampire.vampire.PlayerId);
writer.Write(Vampire.currentTarget.PlayerId);
writer.Write(Byte.MaxValue);
} else {
Vampire.bitten = Vampire.currentTarget;
// Notify players about bitten
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.VampireSetBitten, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.VampireSetBitten, Hazel.SendOption.Reliable, -1);
writer.Write(Vampire.bitten.PlayerId);
writer.Write((byte)0);
AmongUsClient.Instance.FinishRpcImmediately(writer);
byte timer = (byte)vampireKillButton.Timer;
if (timer != lastTimer) {
lastTimer = timer;
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.ShareGhostInfo, Hazel.SendOption.Reliable, -1);
- writer.Write(CachedPlayer.LocalPlayer.PlayerId);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ShareGhostInfo, Hazel.SendOption.Reliable, -1);
+ writer.Write(PlayerControl.LocalPlayer.PlayerId);
writer.Write((byte)RPCProcedure.GhostInfoTypes.VampireTimer);
writer.Write(timer);
AmongUsClient.Instance.FinishRpcImmediately(writer);
// Perform kill if possible and reset bitten (regardless whether the kill was successful or not)
var res = Helpers.checkMurderAttemptAndKill(Vampire.vampire, Vampire.bitten, showAnimation: false);
if (res == MurderAttemptResult.PerformKill) {
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.VampireSetBitten, Hazel.SendOption.Reliable, -1);
+ 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);
vampireKillButton.HasEffect = false;
}
},
- () => { return Vampire.vampire != null && Vampire.vampire == CachedPlayer.LocalPlayer.PlayerControl && !CachedPlayer.LocalPlayer.Data.IsDead; },
+ () => { return Vampire.vampire != null && Vampire.vampire == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead; },
() => {
if (Vampire.targetNearGarlic && Vampire.canKillNearGarlics) {
vampireKillButton.actionButton.graphic.sprite = __instance.KillButton.graphic.sprite;
vampireKillButton.actionButton.graphic.sprite = Vampire.getButtonSprite();
vampireKillButton.showButtonText = false;
}
- return Vampire.currentTarget != null && CachedPlayer.LocalPlayer.PlayerControl.CanMove && (!Vampire.targetNearGarlic || Vampire.canKillNearGarlics);
+ return Vampire.currentTarget != null && PlayerControl.LocalPlayer.CanMove && (!Vampire.targetNearGarlic || Vampire.canKillNearGarlics);
},
() => {
vampireKillButton.Timer = vampireKillButton.MaxTimer;
garlicButton = new CustomButton(
() => {
Vampire.localPlacedGarlic = true;
- var pos = CachedPlayer.LocalPlayer.transform.position;
+ 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(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.PlaceGarlic, Hazel.SendOption.Reliable);
+ MessageWriter writer = AmongUsClient.Instance.StartRpc(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.PlaceGarlic, Hazel.SendOption.Reliable);
writer.WriteBytesAndSize(buff);
writer.EndMessage();
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.localPlacedGarlic && !PlayerControl.LocalPlayer.Data.IsDead && Vampire.garlicsActive && !HideNSeek.isHideNSeekGM && !PropHunt.isPropHuntGM; },
+ () => { return PlayerControl.LocalPlayer.CanMove && !Vampire.localPlacedGarlic; },
() => { },
Vampire.getGarlicButtonSprite(),
new Vector3(0, -0.06f, 0),
() => {
portalmakerPlacePortalButton.Timer = portalmakerPlacePortalButton.MaxTimer;
- var pos = CachedPlayer.LocalPlayer.transform.position;
+ 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(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.PlacePortal, Hazel.SendOption.Reliable);
+ MessageWriter writer = AmongUsClient.Instance.StartRpc(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.PlacePortal, Hazel.SendOption.Reliable);
writer.WriteBytesAndSize(buff);
writer.EndMessage();
RPCProcedure.placePortal(buff);
SoundEffectsManager.play("tricksterPlaceBox");
},
- () => { return Portalmaker.portalmaker != null && Portalmaker.portalmaker == CachedPlayer.LocalPlayer.PlayerControl && !CachedPlayer.LocalPlayer.Data.IsDead && Portal.secondPortal == null; },
- () => { return CachedPlayer.LocalPlayer.PlayerControl.CanMove && Portal.secondPortal == null; },
+ () => { 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(),
CustomButton.ButtonPositions.lowerRowRight,
usePortalButton = new CustomButton(
() => {
bool didTeleport = false;
- Vector3 exit = Portal.findExit(CachedPlayer.LocalPlayer.transform.position);
- Vector3 entry = Portal.findEntry(CachedPlayer.LocalPlayer.transform.position);
+ Vector3 exit = Portal.findExit(PlayerControl.LocalPlayer.transform.position);
+ Vector3 entry = Portal.findEntry(PlayerControl.LocalPlayer.transform.position);
- bool portalMakerSoloTeleport = !Portal.locationNearEntry(CachedPlayer.LocalPlayer.transform.position);
+ bool portalMakerSoloTeleport = !Portal.locationNearEntry(PlayerControl.LocalPlayer.transform.position);
if (portalMakerSoloTeleport) {
exit = Portal.firstPortal.portalGameObject.transform.position;
- entry = CachedPlayer.LocalPlayer.transform.position;
+ entry = PlayerControl.LocalPlayer.transform.position;
}
- CachedPlayer.LocalPlayer.NetTransform.RpcSnapTo(entry);
+ PlayerControl.LocalPlayer.NetTransform.RpcSnapTo(entry);
- if (!CachedPlayer.LocalPlayer.Data.IsDead) { // Ghosts can portal too, but non-blocking and only with a local animation
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.UsePortal, Hazel.SendOption.Reliable, -1);
- writer.Write((byte)CachedPlayer.LocalPlayer.PlayerId);
+ 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);
writer.Write(portalMakerSoloTeleport ? (byte)1 : (byte)0);
AmongUsClient.Instance.FinishRpcImmediately(writer);
}
- RPCProcedure.usePortal(CachedPlayer.LocalPlayer.PlayerId, portalMakerSoloTeleport ? (byte)1 : (byte)0);
+ RPCProcedure.usePortal(PlayerControl.LocalPlayer.PlayerId, portalMakerSoloTeleport ? (byte)1 : (byte)0);
usePortalButton.Timer = usePortalButton.MaxTimer;
portalmakerMoveToPortalButton.Timer = usePortalButton.MaxTimer;
SoundEffectsManager.play("portalUse");
FastDestroyableSingleton<HudManager>.Instance.StartCoroutine(Effects.Lerp(Portal.teleportDuration, new Action<float>((p) => { // Delayed action
- CachedPlayer.LocalPlayer.PlayerControl.moveable = false;
- CachedPlayer.LocalPlayer.NetTransform.Halt();
+ PlayerControl.LocalPlayer.moveable = false;
+ PlayerControl.LocalPlayer.NetTransform.Halt();
if (p >= 0.5f && p <= 0.53f && !didTeleport && !MeetingHud.Instance) {
if (SubmergedCompatibility.IsSubmerged) {
SubmergedCompatibility.ChangeFloor(exit.y > -7);
}
- CachedPlayer.LocalPlayer.NetTransform.RpcSnapTo(exit);
+ PlayerControl.LocalPlayer.NetTransform.RpcSnapTo(exit);
didTeleport = true;
}
if (p == 1f) {
- CachedPlayer.LocalPlayer.PlayerControl.moveable = true;
+ PlayerControl.LocalPlayer.moveable = true;
}
})));
},
() => {
- if (CachedPlayer.LocalPlayer.PlayerControl == Portalmaker.portalmaker && Portal.bothPlacedAndEnabled)
- portalmakerButtonText1.text = Portal.locationNearEntry(CachedPlayer.LocalPlayer.transform.position) || !Portalmaker.canPortalFromAnywhere ? "" : "1. " + Portal.firstPortal.room;
+ if (PlayerControl.LocalPlayer == Portalmaker.portalmaker && Portal.bothPlacedAndEnabled)
+ portalmakerButtonText1.text = Portal.locationNearEntry(PlayerControl.LocalPlayer.transform.position) || !Portalmaker.canPortalFromAnywhere ? "" : "1. " + Portal.firstPortal.room;
return Portal.bothPlacedAndEnabled; },
- () => { return CachedPlayer.LocalPlayer.PlayerControl.CanMove && (Portal.locationNearEntry(CachedPlayer.LocalPlayer.transform.position) || Portalmaker.canPortalFromAnywhere && CachedPlayer.LocalPlayer.PlayerControl == Portalmaker.portalmaker) && !Portal.isTeleporting; },
+ () => { return PlayerControl.LocalPlayer.CanMove && (Portal.locationNearEntry(PlayerControl.LocalPlayer.transform.position) || Portalmaker.canPortalFromAnywhere && PlayerControl.LocalPlayer == Portalmaker.portalmaker) && !Portal.isTeleporting; },
() => { usePortalButton.Timer = usePortalButton.MaxTimer; },
Portalmaker.getUsePortalButtonSprite(),
new Vector3(0.9f, -0.06f, 0),
bool didTeleport = false;
Vector3 exit = Portal.secondPortal.portalGameObject.transform.position;
- if (!CachedPlayer.LocalPlayer.Data.IsDead) { // Ghosts can portal too, but non-blocking and only with a local animation
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.UsePortal, Hazel.SendOption.Reliable, -1);
- writer.Write((byte)CachedPlayer.LocalPlayer.PlayerId);
+ 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);
writer.Write((byte)2);
AmongUsClient.Instance.FinishRpcImmediately(writer);
}
- RPCProcedure.usePortal(CachedPlayer.LocalPlayer.PlayerId, 2);
+ RPCProcedure.usePortal(PlayerControl.LocalPlayer.PlayerId, 2);
usePortalButton.Timer = usePortalButton.MaxTimer;
portalmakerMoveToPortalButton.Timer = usePortalButton.MaxTimer;
SoundEffectsManager.play("portalUse");
FastDestroyableSingleton<HudManager>.Instance.StartCoroutine(Effects.Lerp(Portal.teleportDuration, new Action<float>((p) => { // Delayed action
- CachedPlayer.LocalPlayer.PlayerControl.moveable = false;
- CachedPlayer.LocalPlayer.NetTransform.Halt();
+ PlayerControl.LocalPlayer.moveable = false;
+ PlayerControl.LocalPlayer.NetTransform.Halt();
if (p >= 0.5f && p <= 0.53f && !didTeleport && !MeetingHud.Instance) {
if (SubmergedCompatibility.IsSubmerged) {
SubmergedCompatibility.ChangeFloor(exit.y > -7);
}
- CachedPlayer.LocalPlayer.NetTransform.RpcSnapTo(exit);
+ PlayerControl.LocalPlayer.NetTransform.RpcSnapTo(exit);
didTeleport = true;
}
if (p == 1f) {
- CachedPlayer.LocalPlayer.PlayerControl.moveable = true;
+ PlayerControl.LocalPlayer.moveable = true;
}
})));
},
- () => { return Portalmaker.canPortalFromAnywhere && Portal.bothPlacedAndEnabled && CachedPlayer.LocalPlayer.PlayerControl == Portalmaker.portalmaker; },
- () => { return CachedPlayer.LocalPlayer.PlayerControl.CanMove && !Portal.locationNearEntry(CachedPlayer.LocalPlayer.transform.position) && !Portal.isTeleporting; },
+ () => { return Portalmaker.canPortalFromAnywhere && Portal.bothPlacedAndEnabled && PlayerControl.LocalPlayer == Portalmaker.portalmaker; },
+ () => { return PlayerControl.LocalPlayer.CanMove && !Portal.locationNearEntry(PlayerControl.LocalPlayer.transform.position) && !Portal.isTeleporting; },
() => { portalmakerMoveToPortalButton.Timer = usePortalButton.MaxTimer; },
Portalmaker.getUsePortalButtonSprite(),
new Vector3(0.9f, 1f, 0),
// Jackal Sidekick Button
jackalSidekickButton = new CustomButton(
() => {
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.JackalCreatesSidekick, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.JackalCreatesSidekick, Hazel.SendOption.Reliable, -1);
writer.Write(Jackal.currentTarget.PlayerId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCProcedure.jackalCreatesSidekick(Jackal.currentTarget.PlayerId);
SoundEffectsManager.play("jackalSidekick");
},
- () => { return Jackal.canCreateSidekick && Jackal.jackal != null && Jackal.jackal == CachedPlayer.LocalPlayer.PlayerControl && !CachedPlayer.LocalPlayer.Data.IsDead; },
- () => { return Jackal.canCreateSidekick && Jackal.currentTarget != null && CachedPlayer.LocalPlayer.PlayerControl.CanMove; },
+ () => { return Jackal.canCreateSidekick && Jackal.jackal != null && Jackal.jackal == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead; },
+ () => { return Jackal.canCreateSidekick && Jackal.currentTarget != null && PlayerControl.LocalPlayer.CanMove; },
() => { jackalSidekickButton.Timer = jackalSidekickButton.MaxTimer;},
Jackal.getSidekickButtonSprite(),
CustomButton.ButtonPositions.lowerRowCenter,
jackalKillButton.Timer = jackalKillButton.MaxTimer;
Jackal.currentTarget = null;
},
- () => { return Jackal.jackal != null && Jackal.jackal == CachedPlayer.LocalPlayer.PlayerControl && !CachedPlayer.LocalPlayer.Data.IsDead; },
- () => { return Jackal.currentTarget && CachedPlayer.LocalPlayer.PlayerControl.CanMove; },
+ () => { return Jackal.jackal != null && Jackal.jackal == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead; },
+ () => { return Jackal.currentTarget && PlayerControl.LocalPlayer.CanMove; },
() => { jackalKillButton.Timer = jackalKillButton.MaxTimer;},
__instance.KillButton.graphic.sprite,
CustomButton.ButtonPositions.upperRowRight,
sidekickKillButton.Timer = sidekickKillButton.MaxTimer;
Sidekick.currentTarget = null;
},
- () => { return Sidekick.canKill && Sidekick.sidekick != null && Sidekick.sidekick == CachedPlayer.LocalPlayer.PlayerControl && !CachedPlayer.LocalPlayer.Data.IsDead; },
- () => { return Sidekick.currentTarget && CachedPlayer.LocalPlayer.PlayerControl.CanMove; },
+ () => { 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.graphic.sprite,
CustomButton.ButtonPositions.upperRowRight,
jackalAndSidekickSabotageLightsButton = new CustomButton(
() => {
ShipStatus.Instance.RpcUpdateSystem(SystemTypes.Sabotage, (byte)SystemTypes.Electrical);
+ SoundEffectsManager.play("ligherLight");
},
() => {
- return (Jackal.jackal != null && Jackal.jackal == CachedPlayer.LocalPlayer.PlayerControl && Jackal.canSabotageLights ||
- Sidekick.sidekick != null && Sidekick.sidekick == CachedPlayer.LocalPlayer.PlayerControl && Sidekick.canSabotageLights) && !CachedPlayer.LocalPlayer.Data.IsDead;
+ return (Jackal.jackal != null && Jackal.jackal == PlayerControl.LocalPlayer && Jackal.canSabotageLights ||
+ Sidekick.sidekick != null && Sidekick.sidekick == PlayerControl.LocalPlayer && Sidekick.canSabotageLights) && !PlayerControl.LocalPlayer.Data.IsDead;
},
() => {
if (Helpers.sabotageTimer() > jackalAndSidekickSabotageLightsButton.Timer || Helpers.sabotageActive())
eraserButton.MaxTimer += 10;
eraserButton.Timer = eraserButton.MaxTimer;
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.SetFutureErased, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetFutureErased, Hazel.SendOption.Reliable, -1);
writer.Write(Eraser.currentTarget.PlayerId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCProcedure.setFutureErased(Eraser.currentTarget.PlayerId);
SoundEffectsManager.play("eraserErase");
},
- () => { return Eraser.eraser != null && Eraser.eraser == CachedPlayer.LocalPlayer.PlayerControl && !CachedPlayer.LocalPlayer.Data.IsDead; },
- () => { return CachedPlayer.LocalPlayer.PlayerControl.CanMove && Eraser.currentTarget != null; },
+ () => { return Eraser.eraser != null && Eraser.eraser == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead; },
+ () => { return PlayerControl.LocalPlayer.CanMove && Eraser.currentTarget != null; },
() => { eraserButton.Timer = eraserButton.MaxTimer;},
Eraser.getButtonSprite(),
CustomButton.ButtonPositions.upperRowLeft,
() => {
placeJackInTheBoxButton.Timer = placeJackInTheBoxButton.MaxTimer;
- var pos = CachedPlayer.LocalPlayer.transform.position;
+ 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(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.PlaceJackInTheBox, Hazel.SendOption.Reliable);
+ MessageWriter writer = AmongUsClient.Instance.StartRpc(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.PlaceJackInTheBox, Hazel.SendOption.Reliable);
writer.WriteBytesAndSize(buff);
writer.EndMessage();
RPCProcedure.placeJackInTheBox(buff);
SoundEffectsManager.play("tricksterPlaceBox");
},
- () => { return Trickster.trickster != null && Trickster.trickster == CachedPlayer.LocalPlayer.PlayerControl && !CachedPlayer.LocalPlayer.Data.IsDead && !JackInTheBox.hasJackInTheBoxLimitReached(); },
- () => { return CachedPlayer.LocalPlayer.PlayerControl.CanMove && !JackInTheBox.hasJackInTheBoxLimitReached(); },
+ () => { return Trickster.trickster != null && Trickster.trickster == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead && !JackInTheBox.hasJackInTheBoxLimitReached(); },
+ () => { return PlayerControl.LocalPlayer.CanMove && !JackInTheBox.hasJackInTheBoxLimitReached(); },
() => { placeJackInTheBoxButton.Timer = placeJackInTheBoxButton.MaxTimer;},
Trickster.getPlaceBoxButtonSprite(),
CustomButton.ButtonPositions.upperRowLeft,
lightsOutButton = new CustomButton(
() => {
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.LightsOut, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.LightsOut, Hazel.SendOption.Reliable, -1);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCProcedure.lightsOut();
SoundEffectsManager.play("lighterLight");
},
- () => { return Trickster.trickster != null && Trickster.trickster == CachedPlayer.LocalPlayer.PlayerControl && !CachedPlayer.LocalPlayer.Data.IsDead
+ () => { return Trickster.trickster != null && Trickster.trickster == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead
&& JackInTheBox.hasJackInTheBoxLimitReached() && JackInTheBox.boxesConvertedToVents; },
- () => { return CachedPlayer.LocalPlayer.PlayerControl.CanMove && JackInTheBox.hasJackInTheBoxLimitReached() && JackInTheBox.boxesConvertedToVents; },
+ () => { return PlayerControl.LocalPlayer.CanMove && JackInTheBox.hasJackInTheBoxLimitReached() && JackInTheBox.boxesConvertedToVents; },
() => {
lightsOutButton.Timer = lightsOutButton.MaxTimer;
lightsOutButton.isEffectActive = false;
// Cleaner Clean
cleanerCleanButton = new CustomButton(
() => {
- foreach (Collider2D collider2D in Physics2D.OverlapCircleAll(CachedPlayer.LocalPlayer.PlayerControl.GetTruePosition(), CachedPlayer.LocalPlayer.PlayerControl.MaxReportDistance, Constants.PlayersOnlyMask)) {
+ 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 = CachedPlayer.LocalPlayer.PlayerControl.GetTruePosition();
+ Vector2 truePosition = PlayerControl.LocalPlayer.GetTruePosition();
Vector2 truePosition2 = component.TruePosition;
- if (Vector2.Distance(truePosition2, truePosition) <= CachedPlayer.LocalPlayer.PlayerControl.MaxReportDistance && CachedPlayer.LocalPlayer.PlayerControl.CanMove && !PhysicsHelpers.AnythingBetween(truePosition, truePosition2, Constants.ShipAndObjectsMask, false))
+ if (Vector2.Distance(truePosition2, truePosition) <= PlayerControl.LocalPlayer.MaxReportDistance && PlayerControl.LocalPlayer.CanMove && !PhysicsHelpers.AnythingBetween(truePosition, truePosition2, Constants.ShipAndObjectsMask, false))
{
NetworkedPlayerInfo playerInfo = GameData.Instance.GetPlayerById(component.ParentId);
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.CleanBody, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.CleanBody, Hazel.SendOption.Reliable, -1);
writer.Write(playerInfo.PlayerId);
writer.Write(Cleaner.cleaner.PlayerId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
}
}
},
- () => { return Cleaner.cleaner != null && Cleaner.cleaner == CachedPlayer.LocalPlayer.PlayerControl && !CachedPlayer.LocalPlayer.Data.IsDead; },
- () => { return __instance.ReportButton.graphic.color == Palette.EnabledColor && CachedPlayer.LocalPlayer.PlayerControl.CanMove; },
+ () => { return Cleaner.cleaner != null && Cleaner.cleaner == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead; },
+ () => { return __instance.ReportButton.graphic.color == Palette.EnabledColor && PlayerControl.LocalPlayer.CanMove; },
() => { cleanerCleanButton.Timer = cleanerCleanButton.MaxTimer; },
Cleaner.getButtonSprite(),
CustomButton.ButtonPositions.upperRowLeft,
SoundEffectsManager.play("warlockCurse");
// Ghost Info
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.ShareGhostInfo, Hazel.SendOption.Reliable, -1);
- writer.Write(CachedPlayer.LocalPlayer.PlayerId);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ShareGhostInfo, Hazel.SendOption.Reliable, -1);
+ writer.Write(PlayerControl.LocalPlayer.PlayerId);
writer.Write((byte)RPCProcedure.GhostInfoTypes.WarlockTarget);
writer.Write(Warlock.curseVictim.PlayerId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
// If blanked or killed
if(Warlock.rootTime > 0) {
- AntiTeleport.position = CachedPlayer.LocalPlayer.transform.position;
- CachedPlayer.LocalPlayer.PlayerControl.moveable = false;
- CachedPlayer.LocalPlayer.NetTransform.Halt(); // Stop current movement so the warlock is not just running straight into the next object
+ AntiTeleport.position = PlayerControl.LocalPlayer.transform.position;
+ PlayerControl.LocalPlayer.moveable = false;
+ PlayerControl.LocalPlayer.NetTransform.Halt(); // Stop current movement so the warlock is not just running straight into the next object
FastDestroyableSingleton<HudManager>.Instance.StartCoroutine(Effects.Lerp(Warlock.rootTime, new Action<float>((p) => { // Delayed action
if (p == 1f) {
- CachedPlayer.LocalPlayer.PlayerControl.moveable = true;
+ PlayerControl.LocalPlayer.moveable = true;
}
})));
}
warlockCurseButton.Sprite = Warlock.getCurseButtonSprite();
Warlock.warlock.killTimer = warlockCurseButton.Timer = warlockCurseButton.MaxTimer;
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.ShareGhostInfo, Hazel.SendOption.Reliable, -1);
- writer.Write(CachedPlayer.LocalPlayer.PlayerId);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ShareGhostInfo, Hazel.SendOption.Reliable, -1);
+ writer.Write(PlayerControl.LocalPlayer.PlayerId);
writer.Write((byte)RPCProcedure.GhostInfoTypes.WarlockTarget);
writer.Write(Byte.MaxValue); // This will set it to null!
AmongUsClient.Instance.FinishRpcImmediately(writer);
}
},
- () => { return Warlock.warlock != null && Warlock.warlock == CachedPlayer.LocalPlayer.PlayerControl && !CachedPlayer.LocalPlayer.Data.IsDead; },
- () => { return ((Warlock.curseVictim == null && Warlock.currentTarget != null) || (Warlock.curseVictim != null && Warlock.curseVictimTarget != null)) && CachedPlayer.LocalPlayer.PlayerControl.CanMove; },
+ () => { return Warlock.warlock != null && Warlock.warlock == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead; },
+ () => { return ((Warlock.curseVictim == null && Warlock.currentTarget != null) || (Warlock.curseVictim != null && Warlock.curseVictimTarget != null)) && PlayerControl.LocalPlayer.CanMove; },
() => {
warlockCurseButton.Timer = warlockCurseButton.MaxTimer;
warlockCurseButton.Sprite = Warlock.getCurseButtonSprite();
securityGuardButton = new CustomButton(
() => {
if (SecurityGuard.ventTarget != null) { // Seal vent
- MessageWriter writer = AmongUsClient.Instance.StartRpc(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.SealVent, Hazel.SendOption.Reliable);
+ MessageWriter writer = AmongUsClient.Instance.StartRpc(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SealVent, Hazel.SendOption.Reliable);
writer.WritePacked(SecurityGuard.ventTarget.Id);
writer.EndMessage();
RPCProcedure.sealVent(SecurityGuard.ventTarget.Id);
SecurityGuard.ventTarget = null;
} else if (!Helpers.isMira() && !Helpers.isFungle() && !SubmergedCompatibility.IsSubmerged) { // Place camera if there's no vent and it's not MiraHQ or Submerged
- var pos = CachedPlayer.LocalPlayer.transform.position;
+ 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(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.PlaceCamera, Hazel.SendOption.Reliable);
+ MessageWriter writer = AmongUsClient.Instance.StartRpc(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.PlaceCamera, Hazel.SendOption.Reliable);
writer.WriteBytesAndSize(buff);
writer.EndMessage();
RPCProcedure.placeCamera(buff);
SoundEffectsManager.play("securityGuardPlaceCam"); // Same sound used for both types (cam or vent)!
securityGuardButton.Timer = securityGuardButton.MaxTimer;
},
- () => { return SecurityGuard.securityGuard != null && SecurityGuard.securityGuard == CachedPlayer.LocalPlayer.PlayerControl && !CachedPlayer.LocalPlayer.Data.IsDead && SecurityGuard.remainingScrews >= Mathf.Min(SecurityGuard.ventPrice, SecurityGuard.camPrice); },
+ () => { return SecurityGuard.securityGuard != null && SecurityGuard.securityGuard == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead && SecurityGuard.remainingScrews >= Mathf.Min(SecurityGuard.ventPrice, SecurityGuard.camPrice); },
() => {
securityGuardButton.actionButton.graphic.sprite = (SecurityGuard.ventTarget == null && !Helpers.isMira() && !Helpers.isFungle() && !SubmergedCompatibility.IsSubmerged) ? SecurityGuard.getPlaceCameraButtonSprite() : SecurityGuard.getCloseVentButtonSprite();
if (securityGuardButtonScrewsText != null) securityGuardButtonScrewsText.text = $"{SecurityGuard.remainingScrews}/{SecurityGuard.totalScrews}";
if (SecurityGuard.ventTarget != null)
- return SecurityGuard.remainingScrews >= SecurityGuard.ventPrice && CachedPlayer.LocalPlayer.PlayerControl.CanMove;
- return !Helpers.isMira() && !Helpers.isFungle() && !SubmergedCompatibility.IsSubmerged && SecurityGuard.remainingScrews >= SecurityGuard.camPrice && CachedPlayer.LocalPlayer.PlayerControl.CanMove;
+ return SecurityGuard.remainingScrews >= SecurityGuard.ventPrice && PlayerControl.LocalPlayer.CanMove;
+ return !Helpers.isMira() && !Helpers.isFungle() && !SubmergedCompatibility.IsSubmerged && SecurityGuard.remainingScrews >= SecurityGuard.camPrice && PlayerControl.LocalPlayer.CanMove;
},
() => { securityGuardButton.Timer = securityGuardButton.MaxTimer; },
SecurityGuard.getPlaceCameraButtonSprite(),
}
SecurityGuard.charges--;
- if (SecurityGuard.cantMove) CachedPlayer.LocalPlayer.PlayerControl.moveable = false;
- CachedPlayer.LocalPlayer.NetTransform.Halt(); // Stop current movement
+ if (SecurityGuard.cantMove) PlayerControl.LocalPlayer.moveable = false;
+ PlayerControl.LocalPlayer.NetTransform.Halt(); // Stop current movement
},
() => {
- return SecurityGuard.securityGuard != null && SecurityGuard.securityGuard == CachedPlayer.LocalPlayer.PlayerControl && !CachedPlayer.LocalPlayer.Data.IsDead && SecurityGuard.remainingScrews < Mathf.Min(SecurityGuard.ventPrice, SecurityGuard.camPrice)
+ return SecurityGuard.securityGuard != null && SecurityGuard.securityGuard == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead && SecurityGuard.remainingScrews < Mathf.Min(SecurityGuard.ventPrice, SecurityGuard.camPrice)
&& !SubmergedCompatibility.IsSubmerged;
},
() => {
if (securityGuardChargesText != null) securityGuardChargesText.text = $"{SecurityGuard.charges} / {SecurityGuard.maxCharges}";
securityGuardCamButton.actionButton.graphic.sprite = Helpers.isMira() ? SecurityGuard.getLogSprite() : SecurityGuard.getCamSprite();
securityGuardCamButton.actionButton.OverrideText(Helpers.isMira() ? "DOORLOG" : "SECURITY");
- return CachedPlayer.LocalPlayer.PlayerControl.CanMove && SecurityGuard.charges > 0;
+ return PlayerControl.LocalPlayer.CanMove && SecurityGuard.charges > 0;
},
() => {
securityGuardCamButton.Timer = securityGuardCamButton.MaxTimer;
if (Minigame.Instance) {
SecurityGuard.minigame.ForceClose();
}
- CachedPlayer.LocalPlayer.PlayerControl.moveable = true;
+ PlayerControl.LocalPlayer.moveable = true;
},
false,
Helpers.isMira() ? "DOORLOG" : "SECURITY"
() => {
bool dousedEveryoneAlive = Arsonist.dousedEveryoneAlive();
if (dousedEveryoneAlive) {
- MessageWriter winWriter = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.ArsonistWin, Hazel.SendOption.Reliable, -1);
+ MessageWriter winWriter = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ArsonistWin, Hazel.SendOption.Reliable, -1);
AmongUsClient.Instance.FinishRpcImmediately(winWriter);
RPCProcedure.arsonistWin();
arsonistButton.HasEffect = false;
SoundEffectsManager.play("arsonistDouse");
}
},
- () => { return Arsonist.arsonist != null && Arsonist.arsonist == CachedPlayer.LocalPlayer.PlayerControl && !CachedPlayer.LocalPlayer.Data.IsDead; },
+ () => { return Arsonist.arsonist != null && Arsonist.arsonist == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead; },
() => {
bool dousedEveryoneAlive = Arsonist.dousedEveryoneAlive();
if (dousedEveryoneAlive) arsonistButton.actionButton.graphic.sprite = Arsonist.getIgniteSprite();
arsonistButton.isEffectActive = false;
}
- return CachedPlayer.LocalPlayer.PlayerControl.CanMove && (dousedEveryoneAlive || Arsonist.currentTarget != null);
+ return PlayerControl.LocalPlayer.CanMove && (dousedEveryoneAlive || Arsonist.currentTarget != null);
},
() => {
arsonistButton.Timer = arsonistButton.MaxTimer;
}
// Ghost Info
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.ShareGhostInfo, Hazel.SendOption.Reliable, -1);
- writer.Write(CachedPlayer.LocalPlayer.PlayerId);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ShareGhostInfo, Hazel.SendOption.Reliable, -1);
+ writer.Write(PlayerControl.LocalPlayer.PlayerId);
writer.Write((byte)RPCProcedure.GhostInfoTypes.ArsonistDouse);
writer.Write(Arsonist.douseTarget.PlayerId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
// Vulture Eat
vultureEatButton = new CustomButton(
() => {
- foreach (Collider2D collider2D in Physics2D.OverlapCircleAll(CachedPlayer.LocalPlayer.PlayerControl.GetTruePosition(), CachedPlayer.LocalPlayer.PlayerControl.MaxReportDistance, Constants.PlayersOnlyMask)) {
+ 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 = CachedPlayer.LocalPlayer.PlayerControl.GetTruePosition();
+ Vector2 truePosition = PlayerControl.LocalPlayer.GetTruePosition();
Vector2 truePosition2 = component.TruePosition;
- if (Vector2.Distance(truePosition2, truePosition) <= CachedPlayer.LocalPlayer.PlayerControl.MaxReportDistance && CachedPlayer.LocalPlayer.PlayerControl.CanMove && !PhysicsHelpers.AnythingBetween(truePosition, truePosition2, Constants.ShipAndObjectsMask, false)) {
+ if (Vector2.Distance(truePosition2, truePosition) <= PlayerControl.LocalPlayer.MaxReportDistance && PlayerControl.LocalPlayer.CanMove && !PhysicsHelpers.AnythingBetween(truePosition, truePosition2, Constants.ShipAndObjectsMask, false)) {
NetworkedPlayerInfo playerInfo = GameData.Instance.GetPlayerById(component.ParentId);
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.CleanBody, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.CleanBody, Hazel.SendOption.Reliable, -1);
writer.Write(playerInfo.PlayerId);
writer.Write(Vulture.vulture.PlayerId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
}
}
},
- () => { return Vulture.vulture != null && Vulture.vulture == CachedPlayer.LocalPlayer.PlayerControl && !CachedPlayer.LocalPlayer.Data.IsDead; },
- () => { return __instance.ReportButton.graphic.color == Palette.EnabledColor && CachedPlayer.LocalPlayer.PlayerControl.CanMove; },
+ () => { return Vulture.vulture != null && Vulture.vulture == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead; },
+ () => { return __instance.ReportButton.graphic.color == Palette.EnabledColor && PlayerControl.LocalPlayer.CanMove; },
() => { vultureEatButton.Timer = vultureEatButton.MaxTimer; },
Vulture.getButtonSprite(),
CustomButton.ButtonPositions.lowerRowCenter,
SoundEffectsManager.play("mediumAsk");
}
},
- () => { return Medium.medium != null && Medium.medium == CachedPlayer.LocalPlayer.PlayerControl && !CachedPlayer.LocalPlayer.Data.IsDead; },
+ () => { 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 && CachedPlayer.LocalPlayer.PlayerControl.CanMove;
+ return Medium.target != null && PlayerControl.LocalPlayer.CanMove;
},
() => {
mediumButton.Timer = mediumButton.MaxTimer;
() => {
mediumButton.Timer = mediumButton.MaxTimer;
if (Medium.target == null || Medium.target.player == null) return;
- string msg = Medium.getInfo(Medium.target.player, Medium.target.killerIfExisting);
- FastDestroyableSingleton<HudManager>.Instance.Chat.AddChat(CachedPlayer.LocalPlayer.PlayerControl, msg);
+ string msg = Medium.getInfo(Medium.target.player, Medium.target.killerIfExisting, Medium.target.deathReason);
+ FastDestroyableSingleton<HudManager>.Instance.Chat.AddChat(PlayerControl.LocalPlayer, msg);
// Ghost Info
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.ShareGhostInfo, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ShareGhostInfo, Hazel.SendOption.Reliable, -1);
writer.Write(Medium.target.player.PlayerId);
writer.Write((byte)RPCProcedure.GhostInfoTypes.MediumInfo);
writer.Write(msg);
}
foreach (SpriteRenderer rend in Medium.souls) {
- float distance = Vector2.Distance(rend.transform.position, CachedPlayer.LocalPlayer.PlayerControl.GetTruePosition());
+ float distance = Vector2.Distance(rend.transform.position, PlayerControl.LocalPlayer.GetTruePosition());
if (distance < closestDistance) {
closestDistance = distance;
target = rend;
pursuerButton = new CustomButton(
() => {
if (Pursuer.target != null) {
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.SetBlanked, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetBlanked, Hazel.SendOption.Reliable, -1);
writer.Write(Pursuer.target.PlayerId);
writer.Write(Byte.MaxValue);
AmongUsClient.Instance.FinishRpcImmediately(writer);
}
},
- () => { return Pursuer.pursuer != null && Pursuer.pursuer == CachedPlayer.LocalPlayer.PlayerControl && !CachedPlayer.LocalPlayer.Data.IsDead && Pursuer.blanks < Pursuer.blanksNumber; },
+ () => { return Pursuer.pursuer != null && Pursuer.pursuer == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead && Pursuer.blanks < Pursuer.blanksNumber; },
() => {
if (pursuerButtonBlanksText != null) pursuerButtonBlanksText.text = $"{Pursuer.blanksNumber - Pursuer.blanks}";
- return Pursuer.blanksNumber > Pursuer.blanks && CachedPlayer.LocalPlayer.PlayerControl.CanMove && Pursuer.target != null;
+ return Pursuer.blanksNumber > Pursuer.blanks && PlayerControl.LocalPlayer.CanMove && Pursuer.target != null;
},
() => { pursuerButton.Timer = pursuerButton.MaxTimer; },
Pursuer.getTargetSprite(),
SoundEffectsManager.play("witchSpell");
}
},
- () => { return Witch.witch != null && Witch.witch == CachedPlayer.LocalPlayer.PlayerControl && !CachedPlayer.LocalPlayer.Data.IsDead; },
+ () => { return Witch.witch != null && Witch.witch == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead; },
() => {
if (witchSpellButton.isEffectActive && Witch.spellCastingTarget != Witch.currentTarget) {
Witch.spellCastingTarget = null;
witchSpellButton.Timer = 0f;
witchSpellButton.isEffectActive = false;
}
- return CachedPlayer.LocalPlayer.PlayerControl.CanMove && Witch.currentTarget != null;
+ return PlayerControl.LocalPlayer.CanMove && Witch.currentTarget != null;
},
() => {
witchSpellButton.Timer = witchSpellButton.MaxTimer;
if (Witch.spellCastingTarget == null) return;
MurderAttemptResult attempt = Helpers.checkMuderAttempt(Witch.witch, Witch.spellCastingTarget);
if (attempt == MurderAttemptResult.PerformKill) {
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.SetFutureSpelled, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetFutureSpelled, Hazel.SendOption.Reliable, -1);
writer.Write(Witch.currentTarget.PlayerId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCProcedure.setFutureSpelled(Witch.currentTarget.PlayerId);
Patches.PlayerControlFixedUpdatePatch.miniCooldownUpdate(); // Modifies the MaxTimer if the witch is the mini
witchSpellButton.Timer = witchSpellButton.MaxTimer;
if (Witch.triggerBothCooldowns) {
- float multiplier = (Mini.mini != null && CachedPlayer.LocalPlayer.PlayerControl == Mini.mini) ? (Mini.isGrownUp() ? 0.66f : 2f) : 1f;
+ float multiplier = (Mini.mini != null && PlayerControl.LocalPlayer == Mini.mini) ? (Mini.isGrownUp() ? 0.66f : 2f) : 1f;
Witch.witch.killTimer = GameOptionsManager.Instance.currentNormalGameOptions.KillCooldown * multiplier;
}
} else {
MurderAttemptResult attempt = Helpers.checkMuderAttempt(Ninja.ninja, Ninja.ninjaMarked);
if (attempt == MurderAttemptResult.PerformKill) {
// Create first trace before killing
- var pos = CachedPlayer.LocalPlayer.transform.position;
+ 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));
- writer = AmongUsClient.Instance.StartRpc(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.PlaceNinjaTrace, Hazel.SendOption.Reliable);
+ writer = AmongUsClient.Instance.StartRpc(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.PlaceNinjaTrace, Hazel.SendOption.Reliable);
writer.WriteBytesAndSize(buff);
writer.EndMessage();
RPCProcedure.placeNinjaTrace(buff);
- MessageWriter invisibleWriter = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.SetInvisible, Hazel.SendOption.Reliable, -1);
+ MessageWriter invisibleWriter = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetInvisible, Hazel.SendOption.Reliable, -1);
invisibleWriter.Write(Ninja.ninja.PlayerId);
invisibleWriter.Write(byte.MinValue);
AmongUsClient.Instance.FinishRpcImmediately(invisibleWriter);
RPCProcedure.setInvisible(Ninja.ninja.PlayerId, byte.MinValue);
// Perform Kill
- MessageWriter writer2 = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.UncheckedMurderPlayer, Hazel.SendOption.Reliable, -1);
- writer2.Write(CachedPlayer.LocalPlayer.PlayerId);
+ 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);
if (SubmergedCompatibility.IsSubmerged) {
SubmergedCompatibility.ChangeFloor(Ninja.ninjaMarked.transform.localPosition.y > -7);
}
- RPCProcedure.uncheckedMurderPlayer(CachedPlayer.LocalPlayer.PlayerId, Ninja.ninjaMarked.PlayerId, byte.MaxValue);
+ RPCProcedure.uncheckedMurderPlayer(PlayerControl.LocalPlayer.PlayerId, Ninja.ninjaMarked.PlayerId, byte.MaxValue);
// Create Second trace after killing
pos = Ninja.ninjaMarked.transform.position;
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(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.PlaceNinjaTrace, Hazel.SendOption.Reliable);
+ MessageWriter writer3 = AmongUsClient.Instance.StartRpc(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.PlaceNinjaTrace, Hazel.SendOption.Reliable);
writer3.WriteBytesAndSize(buff);
writer3.EndMessage();
RPCProcedure.placeNinjaTrace(buff);
SoundEffectsManager.play("warlockCurse");
// Ghost Info
- writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.ShareGhostInfo, Hazel.SendOption.Reliable, -1);
- writer.Write(CachedPlayer.LocalPlayer.PlayerId);
+ writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ShareGhostInfo, Hazel.SendOption.Reliable, -1);
+ writer.Write(PlayerControl.LocalPlayer.PlayerId);
writer.Write((byte)RPCProcedure.GhostInfoTypes.NinjaMarked);
writer.Write(Ninja.ninjaMarked.PlayerId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
}
},
- () => { return Ninja.ninja != null && Ninja.ninja == CachedPlayer.LocalPlayer.PlayerControl && !CachedPlayer.LocalPlayer.Data.IsDead; },
+ () => { 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 && !TransportationToolPatches.isUsingTransportation(Ninja.ninjaMarked)) && CachedPlayer.LocalPlayer.PlayerControl.CanMove;
+ return (Ninja.currentTarget != null || Ninja.ninjaMarked != null && !TransportationToolPatches.isUsingTransportation(Ninja.ninjaMarked)) && PlayerControl.LocalPlayer.CanMove;
},
() => { // on meeting ends
ninjaButton.Timer = ninjaButton.MaxTimer;
mayorMeetingButton = new CustomButton(
() => {
- CachedPlayer.LocalPlayer.NetTransform.Halt(); // Stop current movement
+ PlayerControl.LocalPlayer.NetTransform.Halt(); // Stop current movement
Mayor.remoteMeetingsLeft--;
Helpers.handleVampireBiteOnBodyReport(); // Manually call Vampire handling, since the CmdReportDeadBody Prefix won't be called
- RPCProcedure.uncheckedCmdReportDeadBody(CachedPlayer.LocalPlayer.PlayerId, Byte.MaxValue);
+ RPCProcedure.uncheckedCmdReportDeadBody(PlayerControl.LocalPlayer.PlayerId, Byte.MaxValue);
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.UncheckedCmdReportDeadBody, Hazel.SendOption.Reliable, -1);
- writer.Write(CachedPlayer.LocalPlayer.PlayerId);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.UncheckedCmdReportDeadBody, Hazel.SendOption.Reliable, -1);
+ writer.Write(PlayerControl.LocalPlayer.PlayerId);
writer.Write(Byte.MaxValue);
AmongUsClient.Instance.FinishRpcImmediately(writer);
mayorMeetingButton.Timer = 1f;
},
- () => { return Mayor.mayor != null && Mayor.mayor == CachedPlayer.LocalPlayer.PlayerControl && !CachedPlayer.LocalPlayer.Data.IsDead && Mayor.meetingButton; },
+ () => { return Mayor.mayor != null && Mayor.mayor == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead && Mayor.meetingButton; },
() => {
mayorMeetingButton.actionButton.OverrideText("Emergency ("+ Mayor.remoteMeetingsLeft + ")");
bool sabotageActive = false;
- foreach (PlayerTask task in CachedPlayer.LocalPlayer.PlayerControl.myTasks.GetFastEnumerator())
+ foreach (PlayerTask task in PlayerControl.LocalPlayer.myTasks.GetFastEnumerator())
if (task.TaskType == TaskTypes.FixLights || task.TaskType == TaskTypes.RestoreOxy || task.TaskType == TaskTypes.ResetReactor || task.TaskType == TaskTypes.ResetSeismic || task.TaskType == TaskTypes.FixComms || task.TaskType == TaskTypes.StopCharles
|| SubmergedCompatibility.IsSubmerged && task.TaskType == SubmergedCompatibility.RetrieveOxygenMask)
sabotageActive = true;
- return !sabotageActive && CachedPlayer.LocalPlayer.PlayerControl.CanMove && (Mayor.remoteMeetingsLeft > 0);
+ return !sabotageActive && PlayerControl.LocalPlayer.CanMove && (Mayor.remoteMeetingsLeft > 0);
},
() => { mayorMeetingButton.Timer = mayorMeetingButton.MaxTimer; },
Mayor.getMeetingSprite(),
() => {
- var pos = CachedPlayer.LocalPlayer.transform.position;
+ 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(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.SetTrap, Hazel.SendOption.Reliable);
+ MessageWriter writer = AmongUsClient.Instance.StartRpc(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetTrap, Hazel.SendOption.Reliable);
writer.WriteBytesAndSize(buff);
writer.EndMessage();
RPCProcedure.setTrap(buff);
SoundEffectsManager.play("trapperTrap");
trapperButton.Timer = trapperButton.MaxTimer;
},
- () => { return Trapper.trapper != null && Trapper.trapper == CachedPlayer.LocalPlayer.PlayerControl && !CachedPlayer.LocalPlayer.Data.IsDead; },
+ () => { return Trapper.trapper != null && Trapper.trapper == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead; },
() => {
if (trapperChargesText != null) trapperChargesText.text = $"{Trapper.charges} / {Trapper.maxCharges}";
- return CachedPlayer.LocalPlayer.PlayerControl.CanMove && Trapper.charges > 0;
+ return PlayerControl.LocalPlayer.CanMove && Trapper.charges > 0;
},
() => { trapperButton.Timer = trapperButton.MaxTimer; },
Trapper.getButtonSprite(),
bomberButton = new CustomButton(
() => {
if (Helpers.checkMuderAttempt(Bomber.bomber, Bomber.bomber, ignoreMedic: true) != MurderAttemptResult.BlankKill) {
- var pos = CachedPlayer.LocalPlayer.transform.position;
+ 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(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.PlaceBomb, Hazel.SendOption.Reliable);
+ MessageWriter writer = AmongUsClient.Instance.StartRpc(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.PlaceBomb, Hazel.SendOption.Reliable);
writer.WriteBytesAndSize(buff);
writer.EndMessage();
RPCProcedure.placeBomb(buff);
bomberButton.Timer = bomberButton.MaxTimer;
Bomber.isPlanted = true;
},
- () => { return Bomber.bomber != null && Bomber.bomber == CachedPlayer.LocalPlayer.PlayerControl && !CachedPlayer.LocalPlayer.Data.IsDead; },
- () => { return CachedPlayer.LocalPlayer.PlayerControl.CanMove && !Bomber.isPlanted; },
+ () => { return Bomber.bomber != null && Bomber.bomber == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead; },
+ () => { return PlayerControl.LocalPlayer.CanMove && !Bomber.isPlanted; },
() => { bomberButton.Timer = bomberButton.MaxTimer; },
Bomber.getButtonSprite(),
CustomButton.ButtonPositions.upperRowLeft,
defuseButton.PositionOffset = new Vector3(0f, 2f, 0f);
else
defuseButton.PositionOffset = new Vector3(0f, 1f, 0f);
- return Bomber.bomb != null && Bomb.canDefuse && !CachedPlayer.LocalPlayer.Data.IsDead; },
+ return Bomber.bomb != null && Bomb.canDefuse && !PlayerControl.LocalPlayer.Data.IsDead; },
() => {
if (defuseButton.isEffectActive && !Bomb.canDefuse) {
defuseButton.Timer = 0f;
defuseButton.isEffectActive = false;
}
- return CachedPlayer.LocalPlayer.PlayerControl.CanMove;
+ return PlayerControl.LocalPlayer.CanMove;
},
() => {
defuseButton.Timer = 0f;
true,
Bomber.defuseDuration,
() => {
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.DefuseBomb, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.DefuseBomb, Hazel.SendOption.Reliable, -1);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCProcedure.defuseBomb();
if (Thief.suicideFlag) {
// Suicide
- MessageWriter writer2 = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.UncheckedMurderPlayer, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer2 = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.UncheckedMurderPlayer, Hazel.SendOption.Reliable, -1);
writer2.Write(thief.PlayerId);
writer2.Write(thief.PlayerId);
writer2.Write(0);
// Steal role if survived.
if (!Thief.thief.Data.IsDead && result == MurderAttemptResult.PerformKill) {
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.ThiefStealsRole, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ThiefStealsRole, Hazel.SendOption.Reliable, -1);
writer.Write(target.PlayerId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCProcedure.thiefStealsRole(target.PlayerId);
}
// Kill the victim (after becoming their role - so that no win is triggered for other teams)
if (result == MurderAttemptResult.PerformKill) {
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.UncheckedMurderPlayer, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.UncheckedMurderPlayer, Hazel.SendOption.Reliable, -1);
writer.Write(thief.PlayerId);
writer.Write(target.PlayerId);
writer.Write(byte.MaxValue);
RPCProcedure.uncheckedMurderPlayer(thief.PlayerId, target.PlayerId, byte.MaxValue);
}
},
- () => { return Thief.thief != null && CachedPlayer.LocalPlayer.PlayerControl == Thief.thief && !CachedPlayer.LocalPlayer.Data.IsDead; },
- () => { return Thief.currentTarget != null && CachedPlayer.LocalPlayer.PlayerControl.CanMove; },
+ () => { return Thief.thief != null && PlayerControl.LocalPlayer == Thief.thief && !PlayerControl.LocalPlayer.Data.IsDead; },
+ () => { return Thief.currentTarget != null && PlayerControl.LocalPlayer.CanMove; },
() => { thiefKillButton.Timer = thiefKillButton.MaxTimer; },
__instance.KillButton.graphic.sprite,
CustomButton.ButtonPositions.upperRowRight,
// Yoyo button
yoyoButton = new CustomButton(
() => {
- var pos = CachedPlayer.LocalPlayer.transform.position;
+ 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));
if (Yoyo.markedLocation == null) {
- MessageWriter writer = AmongUsClient.Instance.StartRpc(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.YoyoMarkLocation, Hazel.SendOption.Reliable);
+ MessageWriter writer = AmongUsClient.Instance.StartRpc(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.YoyoMarkLocation, Hazel.SendOption.Reliable);
writer.WriteBytesAndSize(buff);
writer.EndMessage();
RPCProcedure.yoyoMarkLocation(buff);
if (SubmergedCompatibility.IsSubmerged) {
SubmergedCompatibility.ChangeFloor(exit.y > -7);
}
- MessageWriter writer = AmongUsClient.Instance.StartRpc(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.YoyoBlink, Hazel.SendOption.Reliable);
+ MessageWriter writer = AmongUsClient.Instance.StartRpc(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.YoyoBlink, Hazel.SendOption.Reliable);
writer.Write(Byte.MaxValue);
writer.WriteBytesAndSize(buff);
writer.EndMessage();
SoundEffectsManager.play("morphlingMorph");
}
},
- () => { return Yoyo.yoyo != null && Yoyo.yoyo == CachedPlayer.LocalPlayer.PlayerControl && !CachedPlayer.LocalPlayer.Data.IsDead; },
- () => { return CachedPlayer.LocalPlayer.PlayerControl.CanMove; },
+ () => { return Yoyo.yoyo != null && Yoyo.yoyo == PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead; },
+ () => { return PlayerControl.LocalPlayer.CanMove; },
() => {
if (Yoyo.markStaysOverMeeting) {
yoyoButton.Timer = 10f;
}
// jump back!
- var pos = CachedPlayer.LocalPlayer.transform.position;
+ 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));
if (SubmergedCompatibility.IsSubmerged) {
SubmergedCompatibility.ChangeFloor(exit.y > -7);
}
- MessageWriter writer = AmongUsClient.Instance.StartRpc(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.YoyoBlink, Hazel.SendOption.Reliable);
+ MessageWriter writer = AmongUsClient.Instance.StartRpc(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.YoyoBlink, Hazel.SendOption.Reliable);
writer.Write((byte)0);
writer.WriteBytesAndSize(buff);
writer.EndMessage();
MapBehaviour.Instance.ShowCountOverlay(allowedToMove: true, showLivePlayerPosition: true, includeDeadBodies: true);
}
},
- () => { return Yoyo.yoyo != null && Yoyo.yoyo == CachedPlayer.LocalPlayer.PlayerControl && Yoyo.hasAdminTable && !CachedPlayer.LocalPlayer.Data.IsDead; },
+ () => { return Yoyo.yoyo != null && Yoyo.yoyo == PlayerControl.LocalPlayer && Yoyo.hasAdminTable && !PlayerControl.LocalPlayer.Data.IsDead; },
() => {
return true;
},
zoomOutButton = new CustomButton(
() => { Helpers.toggleZoom();
},
- () => { if (CachedPlayer.LocalPlayer.PlayerControl == null || !CachedPlayer.LocalPlayer.Data.IsDead || (CachedPlayer.LocalPlayer.Data.Role.IsImpostor && !CustomOptionHolder.deadImpsBlockSabotage.getBool())) return false;
- var (playerCompleted, playerTotal) = TasksHandler.taskInfo(CachedPlayer.LocalPlayer.Data);
+ () => { if (PlayerControl.LocalPlayer == null || !PlayerControl.LocalPlayer.Data.IsDead || (PlayerControl.LocalPlayer.Data.Role.IsImpostor && !CustomOptionHolder.deadImpsBlockSabotage.getBool())) return false;
+ var (playerCompleted, playerTotal) = TasksHandler.taskInfo(PlayerControl.LocalPlayer.Data);
int numberOfLeftTasks = playerTotal - playerCompleted;
return numberOfLeftTasks <= 0 || !CustomOptionHolder.finishTasksBeforeHauntingOrZoomingOut.getBool();
},
hunterLighterButton = new CustomButton(
() => {
- Hunter.lightActive.Add(CachedPlayer.LocalPlayer.PlayerId);
+ Hunter.lightActive.Add(PlayerControl.LocalPlayer.PlayerId);
SoundEffectsManager.play("lighterLight");
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.ShareTimer, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ShareTimer, Hazel.SendOption.Reliable, -1);
writer.Write(Hunter.lightPunish);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCProcedure.shareTimer(Hunter.lightPunish);
},
- () => { return HideNSeek.isHunter() && !CachedPlayer.LocalPlayer.Data.IsDead; },
+ () => { return HideNSeek.isHunter() && !PlayerControl.LocalPlayer.Data.IsDead; },
() => { return true; },
() => {
hunterLighterButton.Timer = 30f;
true,
Hunter.lightDuration,
() => {
- Hunter.lightActive.Remove(CachedPlayer.LocalPlayer.PlayerId);
+ Hunter.lightActive.Remove(PlayerControl.LocalPlayer.PlayerId);
hunterLighterButton.Timer = hunterLighterButton.MaxTimer;
SoundEffectsManager.play("lighterLight");
}
MapBehaviour.Instance.ShowCountOverlay(allowedToMove: true, showLivePlayerPosition: true, includeDeadBodies: false);
}
- CachedPlayer.LocalPlayer.NetTransform.Halt(); // Stop current movement
+ PlayerControl.LocalPlayer.NetTransform.Halt(); // Stop current movement
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.ShareTimer, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ShareTimer, Hazel.SendOption.Reliable, -1);
writer.Write(Hunter.AdminPunish);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCProcedure.shareTimer(Hunter.AdminPunish);
},
- () => { return HideNSeek.isHunter() && !CachedPlayer.LocalPlayer.Data.IsDead; },
+ () => { return HideNSeek.isHunter() && !PlayerControl.LocalPlayer.Data.IsDead; },
() => { return true; },
() => {
hunterAdminTableButton.Timer = hunterAdminTableButton.MaxTimer;
Hunter.arrowActive = true;
SoundEffectsManager.play("trackerTrackPlayer");
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.ShareTimer, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ShareTimer, Hazel.SendOption.Reliable, -1);
writer.Write(Hunter.ArrowPunish);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCProcedure.shareTimer(Hunter.ArrowPunish);
},
- () => { return HideNSeek.isHunter() && !CachedPlayer.LocalPlayer.Data.IsDead; },
+ () => { return HideNSeek.isHunter() && !PlayerControl.LocalPlayer.Data.IsDead; },
() => { return true; },
() => {
hunterArrowButton.Timer = 30f;
huntedShieldButton = new CustomButton(
() => {
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.HuntedShield, Hazel.SendOption.Reliable, -1);
- writer.Write(CachedPlayer.LocalPlayer.PlayerId);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.HuntedShield, Hazel.SendOption.Reliable, -1);
+ writer.Write(PlayerControl.LocalPlayer.PlayerId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
- RPCProcedure.huntedShield(CachedPlayer.LocalPlayer.PlayerId);
+ RPCProcedure.huntedShield(PlayerControl.LocalPlayer.PlayerId);
SoundEffectsManager.play("timemasterShield");
Hunted.shieldCount--;
},
- () => { return HideNSeek.isHunted() && !CachedPlayer.LocalPlayer.Data.IsDead; },
+ () => { return HideNSeek.isHunted() && !PlayerControl.LocalPlayer.Data.IsDead; },
() => {
if (huntedShieldCountText != null) huntedShieldCountText.text = $"{Hunted.shieldCount}";
- return CachedPlayer.LocalPlayer.PlayerControl.CanMove && Hunted.shieldCount > 0;
+ return PlayerControl.LocalPlayer.CanMove && Hunted.shieldCount > 0;
},
() => {
huntedShieldButton.Timer = huntedShieldButton.MaxTimer;
GameObject disguiseTarget = PropHunt.currentTarget;
if (disguiseTarget != null) {
player.transform.localScale = disguiseTarget.transform.lossyScale;
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.SetProp, Hazel.SendOption.Reliable, -1);
- writer.Write(CachedPlayer.LocalPlayer.PlayerId);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetProp, Hazel.SendOption.Reliable, -1);
+ writer.Write(PlayerControl.LocalPlayer.PlayerId);
writer.Write(disguiseTarget.gameObject.name);
writer.Write(disguiseTarget.gameObject.transform.position.x);
AmongUsClient.Instance.FinishRpcImmediately(writer);
- RPCProcedure.propHuntSetProp(CachedPlayer.LocalPlayer.PlayerId, disguiseTarget.gameObject.name, disguiseTarget.gameObject.transform.position.x);
+ RPCProcedure.propHuntSetProp(PlayerControl.LocalPlayer.PlayerId, disguiseTarget.gameObject.name, disguiseTarget.gameObject.transform.position.x);
SoundEffectsManager.play("morphlingMorph");
propDisguiseButton.Timer = 1f;
}
var candidates = PlayerControl.AllPlayerControls.ToArray().Where(x => !x.Data.Role.IsImpostor && !x.Data.IsDead && !PropHunt.isCurrentlyRevealed.ContainsKey(x.PlayerId)).ToList();
var rng = new System.Random();
PlayerControl selectedPlayer = candidates[rng.Next(candidates.Count)];
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.SetRevealed, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetRevealed, Hazel.SendOption.Reliable, -1);
writer.Write(selectedPlayer.PlayerId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCProcedure.propHuntSetRevealed(selectedPlayer.PlayerId);
propHuntInvisButton = new CustomButton(
() => {
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.PropHuntSetInvis, Hazel.SendOption.Reliable, -1);
- writer.Write(CachedPlayer.LocalPlayer.PlayerId);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.PropHuntSetInvis, Hazel.SendOption.Reliable, -1);
+ writer.Write(PlayerControl.LocalPlayer.PlayerId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
- RPCProcedure.propHuntSetInvis(CachedPlayer.LocalPlayer.PlayerId);
+ RPCProcedure.propHuntSetInvis(PlayerControl.LocalPlayer.PlayerId);
SoundEffectsManager.play("morphlingMorph");
},
() => { return PropHunt.isPropHuntGM && !PlayerControl.LocalPlayer.Data.IsDead && !PlayerControl.LocalPlayer.Data.Role.IsImpostor && PropHunt.enableInvis; },
propHuntSpeedboostButton = new CustomButton(
() => {
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.PropHuntSetSpeedboost, Hazel.SendOption.Reliable, -1);
- writer.Write(CachedPlayer.LocalPlayer.PlayerId);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.PropHuntSetSpeedboost, Hazel.SendOption.Reliable, -1);
+ writer.Write(PlayerControl.LocalPlayer.PlayerId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
- RPCProcedure.propHuntSetSpeedboost(CachedPlayer.LocalPlayer.PlayerId);
+ RPCProcedure.propHuntSetSpeedboost(PlayerControl.LocalPlayer.PlayerId);
SoundEffectsManager.play("timemasterShield");
},
() => { return PropHunt.isPropHuntGM && !PlayerControl.LocalPlayer.Data.IsDead && !PlayerControl.LocalPlayer.Data.Role.IsImpostor && PropHunt.enableSpeedboost; },
MapBehaviour.Instance.ShowCountOverlay(allowedToMove: true, showLivePlayerPosition: true, includeDeadBodies: false);
}
- CachedPlayer.LocalPlayer.NetTransform.Halt(); // Stop current movement
+ PlayerControl.LocalPlayer.NetTransform.Halt(); // Stop current movement
},
() => { return PropHunt.isPropHuntGM && !PlayerControl.LocalPlayer.Data.IsDead && PlayerControl.LocalPlayer.Data.Role.IsImpostor; },
() => {
using static UnityEngine.UI.Button;
using UnityEngine.Events;
using Hazel;
-using TheOtherRoles.Players;
namespace TheOtherRoles.CustomGameModes {
[HarmonyPatch]
{
TORMapOptions.gameMode = (CustomGamemodes)((int)(TORMapOptions.gameMode + 1) % Enum.GetNames(typeof(CustomGamemodes)).Length);
__instance.StartCoroutine(Effects.Lerp(0.1f, new Action<float>(p => { pButton.buttonText.text = Helpers.cs(Color.yellow, GameModeText.GetComponent<TextMeshPro>().text); })));
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.ShareGamemode, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ShareGamemode, Hazel.SendOption.Reliable, -1);
writer.Write((byte)TORMapOptions.gameMode);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCProcedure.shareGamemode((byte)TORMapOptions.gameMode);
public PlayerControl guesser = null;
public int shots = Mathf.RoundToInt(CustomOptionHolder.guesserGamemodeNumberOfShots.getFloat());
+ public int tasksToUnlock = Mathf.RoundToInt(CustomOptionHolder.guesserGamemodeCrewGuesserNumberOfTasks.getFloat());
public GuesserGM(PlayerControl player) {
guesser = player;
guessers.Add(this);
if (g == null) return;
g.guesser = null;
g.shots = Mathf.RoundToInt(CustomOptionHolder.guesserGamemodeNumberOfShots.getFloat());
+ g.tasksToUnlock = Mathf.RoundToInt(CustomOptionHolder.guesserGamemodeCrewGuesserNumberOfTasks.getFloat());
guessers.Remove(g);
}
using System;
using System.Collections.Generic;
using TheOtherRoles.Objects;
-using TheOtherRoles.Players;
using UnityEngine;
namespace TheOtherRoles.CustomGameModes {
public static float killCooldown = 10f;
public static float hunterWaitingTime = 15f;
public static bool isHunter() {
- return isHideNSeekGM && CachedPlayer.LocalPlayer != null && CachedPlayer.LocalPlayer.Data.Role.IsImpostor;
+ return isHideNSeekGM && PlayerControl.LocalPlayer != null && PlayerControl.LocalPlayer.Data.Role.IsImpostor;
}
- public static List<CachedPlayer> getHunters() {
- List<CachedPlayer> hunters = new List<CachedPlayer>(CachedPlayer.AllPlayers);
+ public static List<PlayerControl> getHunters() {
+ List<PlayerControl> hunters = new List<PlayerControl>(PlayerControl.AllPlayerControls.ToArray());
hunters.RemoveAll(x => !x.Data.Role.IsImpostor);
return hunters;
}
public static bool isHunted() {
- return isHideNSeekGM && CachedPlayer.LocalPlayer != null && !CachedPlayer.LocalPlayer.Data.Role.IsImpostor;
+ return isHideNSeekGM && PlayerControl.LocalPlayer != null && !PlayerControl.LocalPlayer.Data.Role.IsImpostor;
}
public static void clearAndReload() {
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Reflection;
using TheOtherRoles.Patches;
-using TheOtherRoles.Players;
using TheOtherRoles.Utilities;
using TMPro;
using UnityEngine;
+using UnityEngine.Video;
using static TheOtherRoles.Snitch;
using static UnityEngine.GraphicsBuffer;
float dist = 55f;
float dist2 = 15f;
float curr = float.MaxValue;
- foreach (PlayerControl playerControl in PlayerControl.AllPlayerControls.ToArray().Where(x => !x.Data.IsDead && (PlayerControl.LocalPlayer.Data.Role.IsImpostor ? !x.Data.Role.IsImpostor : x.Data.Role.IsImpostor))) {
- if (invisPlayers.ContainsKey(playerControl.PlayerId)) continue; // Dont light up for invisible players
- if (!(playerControl == null)) {
-
- float sqrMagnitude = (playerControl.transform.position - PlayerControl.LocalPlayer.transform.position).sqrMagnitude;
- if (sqrMagnitude < dist && curr > sqrMagnitude) {
- curr = sqrMagnitude;
+ try {
+ foreach (PlayerControl playerControl in PlayerControl.AllPlayerControls.ToArray().Where(x => !x.Data.IsDead && (PlayerControl.LocalPlayer.Data.Role.IsImpostor ? !x.Data.Role.IsImpostor : x.Data.Role.IsImpostor))) {
+ if (invisPlayers.ContainsKey(playerControl.PlayerId)) continue; // Dont light up for invisible players
+ if (!(playerControl == null)) {
+
+ float sqrMagnitude = (playerControl.transform.position - PlayerControl.LocalPlayer.transform.position).sqrMagnitude;
+ if (sqrMagnitude < dist && curr > sqrMagnitude) {
+ curr = sqrMagnitude;
+ }
}
}
}
+ catch { }
float dangerLevel1 = Mathf.Clamp01((dist - curr) / (dist - dist2));
float dangerLevel2 = Mathf.Clamp01((dist2 - curr) / dist2);
HudManager.Instance.DangerMeter.SetDangerValue(dangerLevel1, dangerLevel2);
Collider2D bestCollider = null;
float bestDist = 9999;
if (whitelistedObjects == null || whitelistedObjects.Count == 0 || verbose) {
- updateWhitelistedObjects(true);
+ updateWhitelistedObjects(verbose);
}
foreach (Collider2D collider in Physics2D.OverlapCircleAll(origin.transform.position, radius)) {
if (verbose) {
public static void IntroCutsceneDestroyPatch(IntroCutscene __instance) {
if (!isPropHuntGM || !PlayerControl.LocalPlayer.Data.Role.IsImpostor) return;
PlayerControl.LocalPlayer.moveable = false;
- MessageWriter writer2 = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.PropHuntStartTimer, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer2 = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.PropHuntStartTimer, Hazel.SendOption.Reliable, -1);
writer2.Write(true);
AmongUsClient.Instance.FinishRpcImmediately(writer2);
RPCProcedure.propHuntStartTimer(true);
- introObject = new GameObject("introrenderer");
- introObject.layer = HudManager.Instance.FullScreen.gameObject.layer;
- introObject.transform.SetParent(HudManager.Instance.FullScreen.transform);
- introObject.transform.localPosition = new Vector3(0, 0, -1f);
- SpriteRenderer introRenderer = introObject.AddComponent<SpriteRenderer>();
- introObject.SetActive(true);
- introRenderer.enabled = true;
- int nFrames = 25 * (int)initialBlackoutTime + 10;
- FastDestroyableSingleton<HudManager>.Instance.StartCoroutine(Effects.Lerp(initialBlackoutTime, new Action<float>((p) => {
+
+
+ // Play mp4 video in Full Screen:
+ Assembly assembly = Assembly.GetExecutingAssembly();
+ string[] resourceNames = assembly.GetManifestResourceNames();
+ var resourceBundle = assembly.GetManifestResourceStream("TheOtherRoles.Resources.IntroAnimation.intro");
+ var assetBundle = AssetBundle.LoadFromMemory(resourceBundle.ReadFully());
+ VideoClip introVid = assetBundle.LoadAsset<VideoClip>("Assets/Video/intro.webm");
+ GameObject camera = GameObject.Find("Main Camera");
+ var videoPlayer = camera.AddComponent<UnityEngine.Video.VideoPlayer>();
+ videoPlayer.playOnAwake = false;
+ videoPlayer.renderMode = UnityEngine.Video.VideoRenderMode.CameraNearPlane;
+ videoPlayer.targetCameraAlpha = 1F;
+ videoPlayer.source = VideoSource.VideoClip;
+ videoPlayer.clip = introVid;
+ videoPlayer.aspectRatio = VideoAspectRatio.FitVertically;
+ // Skip the first 100 frames.
+ videoPlayer.frame = (21 - (int)initialBlackoutTime) * 25;
+ videoPlayer.isLooping = false;
+ videoPlayer.Play();
+
+
+ FastDestroyableSingleton<HudManager>.Instance.StartCoroutine(Effects.Lerp(initialBlackoutTime + 10f/25, new Action<float>((p) => {
if (p == 1f) {
// start timer
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.PropHuntStartTimer, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.PropHuntStartTimer, Hazel.SendOption.Reliable, -1);
writer.Write(false);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCProcedure.propHuntStartTimer();
PlayerControl.LocalPlayer.moveable = true;
HudManager.Instance.FullScreen.enabled = false;
+ videoPlayer.Destroy();
+ assetBundle.Unload(false);
introObject.Destroy();
} else {
HudManager.Instance.FullScreen.enabled = true;
HudManager.Instance.FullScreen.gameObject.SetActive(true);
- HudManager.Instance.FullScreen.color = new Color(0, 0, 0, 1);
- introRenderer.sprite?.Destroy();
- introRenderer.sprite = getIntroSprite(510 - nFrames + (int)(p * nFrames));
- Resources.UnloadUnusedAssets(); // Needed so that the last sprite gets unloaded
}
- })));
+ })));
}
[HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.FixedUpdate))]
[HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.MurderPlayer))]
[HarmonyPostfix]
public static void MurderPlayerPostfix(PlayerControl __instance, [HarmonyArgument(0)] PlayerControl target) {
- if (!PropHunt.isPropHuntGM || target != CachedPlayer.LocalPlayer.PlayerControl) return;
+ if (!PropHunt.isPropHuntGM || target != PlayerControl.LocalPlayer) return;
try {
target.NetTransform.RpcSnapTo(__instance.transform.position);
} catch { }
if (__instance.currentTarget == null) {
PlayerControl.LocalPlayer.SetKillTimer(killCooldownMiss);
} else { // There is a target, execute kill!
- MurderAttemptResult res = Helpers.checkMurderAttemptAndKill(CachedPlayer.LocalPlayer.PlayerControl, __instance.currentTarget);
+ MurderAttemptResult res = Helpers.checkMurderAttemptAndKill(PlayerControl.LocalPlayer, __instance.currentTarget);
__instance.SetTarget(null);
PlayerControl.LocalPlayer.SetKillTimer(killCooldownHit);
}
public static CustomOption modifierChameleonHoldDuration;
public static CustomOption modifierChameleonFadeDuration;
public static CustomOption modifierChameleonMinVisibility;
+
+ public static CustomOption modifierArmored;
public static CustomOption modifierShifter;
public static CustomOption guesserGamemodeKillsThroughShield;
public static CustomOption guesserGamemodeEvilCanKillSpy;
public static CustomOption guesserGamemodeCantGuessSnitchIfTaksDone;
+ public static CustomOption guesserGamemodeCrewGuesserNumberOfTasks;
public static CustomOption guesserGamemodeSidekickIsAlwaysGuesser;
// Hide N Seek Gamemode
modifierChameleonFadeDuration = CustomOption.Create(1093, Types.Modifier, "Fade Duration", 1f, 0.25f, 10f, 0.25f, modifierChameleon);
modifierChameleonMinVisibility = CustomOption.Create(1094, Types.Modifier, "Minimum Visibility", new string[] { "0%", "10%", "20%", "30%", "40%", "50%" }, modifierChameleon);
+ modifierArmored = CustomOption.Create(1101, Types.Modifier, cs(Color.yellow, "Armored"), rates, null, true);
+
modifierShifter = CustomOption.Create(1100, Types.Modifier, cs(Color.yellow, "Shifter"), rates, null, true);
// Guesser Gamemode (2000 - 2999)
- guesserGamemodeCrewNumber = CustomOption.Create(2001, Types.Guesser, cs(Guesser.color, "Number of Crew Guessers"), 15f, 1f, 15f, 1f, null, true, heading: "Amount of Guessers");
- guesserGamemodeNeutralNumber = CustomOption.Create(2002, Types.Guesser, cs(Guesser.color, "Number of Neutral Guessers"), 15f, 1f, 15f, 1f, null);
- guesserGamemodeImpNumber = CustomOption.Create(2003, Types.Guesser, cs(Guesser.color, "Number of Impostor Guessers"), 15f, 1f, 15f, 1f, null);
+ guesserGamemodeCrewNumber = CustomOption.Create(2001, Types.Guesser, cs(Guesser.color, "Number of Crew Guessers"), 15f, 0f, 15f, 1f, null, true, heading: "Amount of Guessers");
+ guesserGamemodeNeutralNumber = CustomOption.Create(2002, Types.Guesser, cs(Guesser.color, "Number of Neutral Guessers"), 15f, 0f, 15f, 1f, null);
+ guesserGamemodeImpNumber = CustomOption.Create(2003, Types.Guesser, cs(Guesser.color, "Number of Impostor Guessers"), 15f, 0f, 15f, 1f, null);
guesserForceJackalGuesser = CustomOption.Create(2007, Types.Guesser, "Force Jackal Guesser", false, null, true, heading: "Force Guessers");
guesserGamemodeSidekickIsAlwaysGuesser = CustomOption.Create(2012, Types.Guesser, "Sidekick Is Always Guesser", false, null);
guesserForceThiefGuesser = CustomOption.Create(2011, Types.Guesser, "Force Thief Guesser", false, null);
guesserGamemodeHaveModifier = CustomOption.Create(2004, Types.Guesser, "Guessers Can Have A Modifier", true, null, true, heading: "General Guesser Settings");
guesserGamemodeNumberOfShots = CustomOption.Create(2005, Types.Guesser, "Guesser Number Of Shots", 3f, 1f, 15f, 1f, null);
guesserGamemodeHasMultipleShotsPerMeeting = CustomOption.Create(2006, Types.Guesser, "Guesser Can Shoot Multiple Times Per Meeting", false, null);
+ guesserGamemodeCrewGuesserNumberOfTasks = CustomOption.Create(2013, Types.Guesser, "Number Of Tasks Needed To Unlock Shooting\nFor Crew Guesser", 0f, 0f, 15f, 1f, null);
guesserGamemodeKillsThroughShield = CustomOption.Create(2008, Types.Guesser, "Guesses Ignore The Medic Shield", true, null);
guesserGamemodeEvilCanKillSpy = CustomOption.Create(2009, Types.Guesser, "Evil Guesser Can Guess The Spy", true, null);
guesserGamemodeCantGuessSnitchIfTaksDone = CustomOption.Create(2010, Types.Guesser, "Guesser Can't Guess Snitch When Tasks Completed", true, null);
- // Care: 2012 already taken!
-
// Hide N Seek Gamemode (3000 - 3999)
hideNSeekMap = CustomOption.Create(3020, Types.HideNSeekMain, cs(Color.yellow, "Map"), new string[] { "The Skeld", "Mira", "Polus", "Airship", "Fungle", "Submerged", "LI Map"}, null, true, onChange: () => { int map = hideNSeekMap.selection; if (map >= 3) map++; GameOptionsManager.Instance.currentNormalGameOptions.MapId = (byte)map; });
using TheOtherRoles.Modules;
using HarmonyLib;
using Hazel;
-using TheOtherRoles.Players;
using TheOtherRoles.Utilities;
using System.Threading.Tasks;
using TheOtherRoles.CustomGameModes;
return null;
}
+ /* This function has been removed from TOR because we switched to assetbundles for compressed audio. leaving it here for reference - Gendelo
public static AudioClip loadAudioClipFromResources(string path, string clipName = "UNNAMED_TOR_AUDIO_CLIP") {
- // must be "raw (headerless) 2-channel signed 32 bit pcm (le)" (can e.g. use Audacity® to export)
+
+ // must be "raw (headerless) 2-channel signed 32 bit pcm (le) 48kHz" (can e.g. use Audacity® to export )
try {
Assembly assembly = Assembly.GetExecutingAssembly();
Stream stream = assembly.GetManifestResourceStream(path);
}
return null;
- /* Usage example:
- AudioClip exampleClip = Helpers.loadAudioClipFromResources("TheOtherRoles.Resources.exampleClip.raw");
- if (Constants.ShouldPlaySfx()) SoundManager.Instance.PlaySound(exampleClip, false, 0.8f);
- */
- }
+ // Usage example:
+ //AudioClip exampleClip = Helpers.loadAudioClipFromResources("TheOtherRoles.Resources.exampleClip.raw");
+ //if (Constants.ShouldPlaySfx()) SoundManager.Instance.PlaySound(exampleClip, false, 0.8f);
+
+ }*/
public static string readTextFromResources(string path) {
Assembly assembly = Assembly.GetExecutingAssembly();
public static PlayerControl playerById(byte id)
{
- foreach (PlayerControl player in CachedPlayer.AllPlayers)
+ foreach (PlayerControl player in PlayerControl.AllPlayerControls)
if (player.PlayerId == id)
return player;
return null;
public static Dictionary<byte, PlayerControl> allPlayersById()
{
Dictionary<byte, PlayerControl> res = new Dictionary<byte, PlayerControl>();
- foreach (PlayerControl player in CachedPlayer.AllPlayers)
+ foreach (PlayerControl player in PlayerControl.AllPlayerControls)
res.Add(player.PlayerId, player);
return res;
}
public static void handleVampireBiteOnBodyReport() {
// Murder the bitten player and reset bitten (regardless whether the kill was successful or not)
Helpers.checkMurderAttemptAndKill(Vampire.vampire, Vampire.bitten, true, false);
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.VampireSetBitten, Hazel.SendOption.Reliable, -1);
+ 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);
}
public static bool shouldShowGhostInfo() {
- return CachedPlayer.LocalPlayer.PlayerControl != null && CachedPlayer.LocalPlayer.PlayerControl.Data.IsDead && TORMapOptions.ghostsSeeInformation || AmongUsClient.Instance.GameState == InnerNet.InnerNetClient.GameStates.Ended;
+ return PlayerControl.LocalPlayer != null && PlayerControl.LocalPlayer.Data.IsDead && TORMapOptions.ghostsSeeInformation || AmongUsClient.Instance.GameState == InnerNet.InnerNetClient.GameStates.Ended;
}
public static void clearAllTasks(this PlayerControl player) {
}
public static bool MushroomSabotageActive() {
- return CachedPlayer.LocalPlayer.PlayerControl.myTasks.ToArray().Any((x) => x.TaskType == TaskTypes.MushroomMixupSabotage);
+ return PlayerControl.LocalPlayer.myTasks.ToArray().Any((x) => x.TaskType == TaskTypes.MushroomMixupSabotage);
}
target.RawSetColor(colorId);
target.RawSetVisor(visorId, colorId);
target.RawSetHat(hatId, colorId);
- target.RawSetName(hidePlayerName(CachedPlayer.LocalPlayer.PlayerControl, target) ? "" : playerName);
+ target.RawSetName(hidePlayerName(PlayerControl.LocalPlayer, target) ? "" : playerName);
SkinViewData nextSkin = null;
else if (Thief.canUseVents && Thief.thief != null && Thief.thief == player)
roleCouldUse = true;
else if (player.Data?.Role != null && player.Data.Role.CanVent) {
- if (Janitor.janitor != null && Janitor.janitor == CachedPlayer.LocalPlayer.PlayerControl)
+ if (Janitor.janitor != null && Janitor.janitor == PlayerControl.LocalPlayer)
roleCouldUse = false;
- else if (Mafioso.mafioso != null && Mafioso.mafioso == CachedPlayer.LocalPlayer.PlayerControl && Godfather.godfather != null && !Godfather.godfather.Data.IsDead)
+ else if (Mafioso.mafioso != null && Mafioso.mafioso == PlayerControl.LocalPlayer && Godfather.godfather != null && !Godfather.godfather.Data.IsDead)
roleCouldUse = false;
else
roleCouldUse = true;
return roleCouldUse;
}
+ public static bool checkArmored(PlayerControl target, bool breakShield, bool showShield, bool additionalCondition = true) {
+ if (target != null && Armored.armored != null && Armored.armored == target && !Armored.isBrokenArmor && additionalCondition) {
+ if (breakShield) {
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.BreakArmor, Hazel.SendOption.Reliable, -1);
+ AmongUsClient.Instance.FinishRpcImmediately(writer);
+ RPCProcedure.breakArmor();
+ }
+ if (showShield) {
+ target.ShowFailedMurder();
+ }
+ return true;
+ }
+ return false;
+ }
+
public static MurderAttemptResult checkMuderAttempt(PlayerControl killer, PlayerControl target, bool blockRewind = false, bool ignoreBlank = false, bool ignoreIfKillerIsDead = false, bool ignoreMedic = false) {
var targetRole = RoleInfo.getRoleInfoForPlayer(target, false).FirstOrDefault();
-
// Modified vanilla checks
if (AmongUsClient.Instance.IsGameOver) return MurderAttemptResult.SuppressKill;
if (killer == null || killer.Data == null || (killer.Data.IsDead && !ignoreIfKillerIsDead) || killer.Data.Disconnected) return MurderAttemptResult.SuppressKill; // Allow non Impostor kills compared to vanilla code
// Handle blank shot
if (!ignoreBlank && Pursuer.blankedList.Any(x => x.PlayerId == killer.PlayerId)) {
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.SetBlanked, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetBlanked, Hazel.SendOption.Reliable, -1);
writer.Write(killer.PlayerId);
writer.Write((byte)0);
AmongUsClient.Instance.FinishRpcImmediately(writer);
// Thief if hit crew only kill if setting says so, but also kill the thief.
else if (Thief.isFailedThiefKill(target, killer, targetRole)) {
- Thief.suicideFlag = true;
+ if (!checkArmored(killer, true, true))
+ Thief.suicideFlag = true;
return MurderAttemptResult.SuppressKill;
}
+ // Block Armored with armor kill
+
+ else if (checkArmored(target, true, killer == PlayerControl.LocalPlayer, Sheriff.sheriff == null || killer.PlayerId != Sheriff.sheriff.PlayerId || isEvil(target) && Sheriff.canKillNeutrals || isKiller(target))) {
+ return MurderAttemptResult.BlankKill;
+ }
+
// Block hunted with time shield kill
else if (Hunted.timeshieldActive.Contains(target.PlayerId)) {
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(killer.NetId, (byte)CustomRPC.HuntedRewindTime, Hazel.SendOption.Reliable, -1);
}
public static void MurderPlayer(PlayerControl killer, PlayerControl target, bool showAnimation) {
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.UncheckedMurderPlayer, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.UncheckedMurderPlayer, Hazel.SendOption.Reliable, -1);
writer.Write(killer.PlayerId);
writer.Write(target.PlayerId);
writer.Write(showAnimation ? Byte.MaxValue : 0);
} else if (murder == MurderAttemptResult.DelayVampireKill) {
HudManager.Instance.StartCoroutine(Effects.Lerp(10f, new Action<float>((p) => {
if (!TransportationToolPatches.isUsingTransportation(target) && Vampire.bitten != null) {
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.VampireSetBitten, Hazel.SendOption.Reliable, -1);
+ 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);
}
public static void shareGameVersion() {
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.VersionHandshake, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.VersionHandshake, Hazel.SendOption.Reliable, -1);
writer.Write((byte)TheOtherRolesPlugin.Version.Major);
writer.Write((byte)TheOtherRolesPlugin.Version.Minor);
writer.Write((byte)TheOtherRolesPlugin.Version.Build);
public static List<PlayerControl> getKillerTeamMembers(PlayerControl player) {
List<PlayerControl> team = new List<PlayerControl>();
- foreach(PlayerControl p in CachedPlayer.AllPlayers) {
+ foreach(PlayerControl p in PlayerControl.AllPlayerControls) {
if (player.Data.Role.IsImpostor && p.Data.Role.IsImpostor && player.PlayerId != p.PlayerId && team.All(x => x.PlayerId != p.PlayerId)) team.Add(p);
else if (player == Jackal.jackal && p == Sidekick.sidekick) team.Add(p);
else if (player == Sidekick.sidekick && p == Jackal.jackal) team.Add(p);
using System;
using UnityEngine;
using TheOtherRoles.Modules;
-using TheOtherRoles.Players;
using TheOtherRoles.Utilities;
using Il2CppSystem.Security.Cryptography;
using Il2CppSystem.Text;
public class TheOtherRolesPlugin : BasePlugin
{
public const string Id = "me.eisbison.theotherroles";
- public const string VersionString = "4.6.0";
+ public const string VersionString = "4.7.0";
public static uint betaDays = 0; // amount of days for the build to be usable (0 for infinite!)
public static Version Version = Version.Parse(VersionString);
ServerManager.DefaultRegions = new Il2CppReferenceArray<IRegionInfo>(new IRegionInfo[0]);
UpdateRegions();
+ // Reactor Credits (future use?)
+ // Reactor.Utilities.ReactorCredits.Register("TheOtherRoles", VersionString, betaDays > 0, location => location == Reactor.Utilities.ReactorCredits.Location.PingTracker);
+
DebugMode = Config.Bind("Custom", "Enable Debug Mode", "false");
Harmony.PatchAll();
GameData.Instance.AddPlayer(playerControl, new InnerNet.ClientData(0));
AmongUsClient.Instance.Spawn(playerControl, -2, InnerNet.SpawnFlags.None);
- playerControl.transform.position = CachedPlayer.LocalPlayer.transform.position;
+ playerControl.transform.position = PlayerControl.LocalPlayer.transform.position;
playerControl.GetComponent<DummyBehaviour>().enabled = true;
playerControl.NetTransform.enabled = false;
playerControl.SetName(RandomString(10));
// Terminate round
if(Input.GetKeyDown(KeyCode.L)) {
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.ForceEnd, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ForceEnd, Hazel.SendOption.Reliable, -1);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCProcedure.forceEnd();
}
public class BepInExUpdater : MonoBehaviour
{
- public const string RequiredBepInExVersion = "6.0.0-be.692+851521cc126e4f9d841d2d9bfe857558f0395939";
- public const string BepInExDownloadURL = "https://builds.bepinex.dev/projects/bepinex_be/692/BepInEx-Unity.IL2CPP-win-x86-6.0.0-be.692%2B851521c.zip";
+ public const string RequiredBepInExVersion = "6.0.0-be.697+53625800b86f6c68751445248260edf0b27a71c2";
+ public const string BepInExDownloadURL = "https://builds.bepinex.dev/projects/bepinex_be/697/BepInEx-Unity.IL2CPP-win-x86-6.0.0-be.697%2B5362580.zip";
public static bool UpdateRequired => Paths.BepInExVersion.ToString() != RequiredBepInExVersion;
public void Awake()
using System;
using HarmonyLib;
using System.Linq;
-using TheOtherRoles.Players;
using TheOtherRoles.Utilities;
using Hazel;
if (AmongUsClient.Instance.GameState != InnerNet.InnerNetClient.GameStates.Started) {
if (text.ToLower().StartsWith("/kick ")) {
string playerName = text.Substring(6);
- PlayerControl target = CachedPlayer.AllPlayers.FirstOrDefault(x => x.Data.PlayerName.Equals(playerName));
+ PlayerControl target = PlayerControl.AllPlayerControls.ToArray().FirstOrDefault(x => x.Data.PlayerName.Equals(playerName));
if (target != null && AmongUsClient.Instance != null && AmongUsClient.Instance.CanBan()) {
var client = AmongUsClient.Instance.GetClient(target.OwnerId);
if (client != null) {
}
} else if (text.ToLower().StartsWith("/ban ")) {
string playerName = text.Substring(5);
- PlayerControl target = CachedPlayer.AllPlayers.FirstOrDefault(x => x.Data.PlayerName.Equals(playerName));
+ PlayerControl target = PlayerControl.AllPlayerControls.ToArray().FirstOrDefault(x => x.Data.PlayerName.Equals(playerName));
if (target != null && AmongUsClient.Instance != null && AmongUsClient.Instance.CanBan()) {
var client = AmongUsClient.Instance.GetClient(target.OwnerId);
if (client != null) {
// else its classic!
if (AmongUsClient.Instance.AmHost) {
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.ShareGamemode, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ShareGamemode, Hazel.SendOption.Reliable, -1);
writer.Write((byte)TORMapOptions.gameMode);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCProcedure.shareGamemode((byte)gameMode);
RPCProcedure.shareGamemode((byte)TORMapOptions.gameMode);
} else {
- __instance.AddChat(CachedPlayer.LocalPlayer.PlayerControl, "Nice try, but you have to be the host to use this feature");
+ __instance.AddChat(PlayerControl.LocalPlayer, "Nice try, but you have to be the host to use this feature");
}
handled = true;
}
if (AmongUsClient.Instance.NetworkMode == NetworkModes.FreePlay) {
if (text.ToLower().Equals("/murder")) {
- CachedPlayer.LocalPlayer.PlayerControl.Exiled();
- FastDestroyableSingleton<HudManager>.Instance.KillOverlay.ShowKillAnimation(CachedPlayer.LocalPlayer.Data, CachedPlayer.LocalPlayer.Data);
+ PlayerControl.LocalPlayer.Exiled();
+ FastDestroyableSingleton<HudManager>.Instance.KillOverlay.ShowKillAnimation(PlayerControl.LocalPlayer.Data, PlayerControl.LocalPlayer.Data);
handled = true;
} else if (text.ToLower().StartsWith("/color ")) {
handled = true;
int col;
if (!Int32.TryParse(text.Substring(7), out col)) {
- __instance.AddChat(CachedPlayer.LocalPlayer.PlayerControl, "Unable to parse color id\nUsage: /color {id}");
+ __instance.AddChat(PlayerControl.LocalPlayer, "Unable to parse color id\nUsage: /color {id}");
}
col = Math.Clamp(col, 0, Palette.PlayerColors.Length - 1);
- CachedPlayer.LocalPlayer.PlayerControl.SetColor(col);
- __instance.AddChat(CachedPlayer.LocalPlayer.PlayerControl, "Changed color succesfully");;
+ PlayerControl.LocalPlayer.SetColor(col);
+ __instance.AddChat(PlayerControl.LocalPlayer, "Changed color succesfully");;
}
}
- if (text.ToLower().StartsWith("/tp ") && CachedPlayer.LocalPlayer.Data.IsDead) {
+ if (text.ToLower().StartsWith("/tp ") && PlayerControl.LocalPlayer.Data.IsDead) {
string playerName = text.Substring(4).ToLower();
- PlayerControl target = CachedPlayer.AllPlayers.FirstOrDefault(x => x.Data.PlayerName.ToLower().Equals(playerName));
+ PlayerControl target = PlayerControl.AllPlayerControls.ToArray().FirstOrDefault(x => x.Data.PlayerName.ToLower().Equals(playerName));
if (target != null) {
- CachedPlayer.LocalPlayer.transform.position = target.transform.position;
+ PlayerControl.LocalPlayer.transform.position = target.transform.position;
handled = true;
}
}
if (text.ToLower().StartsWith("/role")) {
- RoleInfo localRole = RoleInfo.getRoleInfoForPlayer(CachedPlayer.LocalPlayer.PlayerControl, false).FirstOrDefault();
+ RoleInfo localRole = RoleInfo.getRoleInfoForPlayer(PlayerControl.LocalPlayer, false).FirstOrDefault();
if (localRole != RoleInfo.impostor && localRole != RoleInfo.crewmate) {
string info = RoleInfo.GetRoleDescription(localRole);
- __instance.AddChat(CachedPlayer.LocalPlayer.PlayerControl, info);
+ __instance.AddChat(PlayerControl.LocalPlayer, info);
handled = true;
}
}
[HarmonyPatch(typeof(HudManager), nameof(HudManager.Update))]
public static class EnableChat {
public static void Postfix(HudManager __instance) {
- if (!__instance.Chat.isActiveAndEnabled && (AmongUsClient.Instance.NetworkMode == NetworkModes.FreePlay || (CachedPlayer.LocalPlayer.PlayerControl.isLover() && Lovers.enableChat)))
+ if (!__instance.Chat.isActiveAndEnabled && (AmongUsClient.Instance.NetworkMode == NetworkModes.FreePlay || (PlayerControl.LocalPlayer.isLover() && Lovers.enableChat)))
__instance.Chat.SetVisible(true);
}
}
public static class SetBubbleName {
public static void Postfix(ChatBubble __instance, [HarmonyArgument(0)] string playerName) {
PlayerControl sourcePlayer = PlayerControl.AllPlayerControls.ToArray().ToList().FirstOrDefault(x => x.Data != null && x.Data.PlayerName.Equals(playerName));
- if (sourcePlayer != null && CachedPlayer.LocalPlayer != null && CachedPlayer.LocalPlayer.Data?.Role?.IsImpostor == true && (Spy.spy != null && sourcePlayer.PlayerId == Spy.spy.PlayerId || Sidekick.sidekick != null && Sidekick.wasTeamRed && sourcePlayer.PlayerId == Sidekick.sidekick.PlayerId || Jackal.jackal != null && Jackal.wasTeamRed && sourcePlayer.PlayerId == Jackal.jackal.PlayerId) && __instance != null) __instance.NameText.color = Palette.ImpostorRed;
+ if (sourcePlayer != null && PlayerControl.LocalPlayer != null && PlayerControl.LocalPlayer.Data?.Role?.IsImpostor == true && (Spy.spy != null && sourcePlayer.PlayerId == Spy.spy.PlayerId || Sidekick.sidekick != null && Sidekick.wasTeamRed && sourcePlayer.PlayerId == Sidekick.sidekick.PlayerId || Jackal.jackal != null && Jackal.wasTeamRed && sourcePlayer.PlayerId == Jackal.jackal.PlayerId) && __instance != null) __instance.NameText.color = Palette.ImpostorRed;
}
}
public static bool Prefix(ChatController __instance, [HarmonyArgument(0)] PlayerControl sourcePlayer) {
if (__instance != FastDestroyableSingleton<HudManager>.Instance.Chat)
return true;
- PlayerControl localPlayer = CachedPlayer.LocalPlayer.PlayerControl;
- return localPlayer == null || (MeetingHud.Instance != null || LobbyBehaviour.Instance != null || (localPlayer.Data.IsDead || localPlayer.isLover() && Lovers.enableChat) || (int)sourcePlayer.PlayerId == (int)CachedPlayer.LocalPlayer.PlayerId);
+ PlayerControl localPlayer = PlayerControl.LocalPlayer;
+ return localPlayer == null || (MeetingHud.Instance != null || LobbyBehaviour.Instance != null || (localPlayer.Data.IsDead || localPlayer.isLover() && Lovers.enableChat) || (int)sourcePlayer.PlayerId == (int)PlayerControl.LocalPlayer.PlayerId);
}
}
using Hazel;
using System.Reflection;
using System.Text;
-using TheOtherRoles.Players;
using TheOtherRoles.Utilities;
using static TheOtherRoles.TheOtherRoles;
using static TheOtherRoles.CustomOption;
using BepInEx;
using static ShipStatus;
using TMPro;
+using Rewired.Utils.Platforms.Windows;
+using static Il2CppSystem.Xml.Schema.FacetsChecker.FacetsCompiler;
+using TheOtherRoles;
namespace TheOtherRoles {
public class CustomOption {
public static void ShareOptionChange(uint optionId) {
var option = options.FirstOrDefault(x => x.id == optionId);
if (option == null) return;
- var writer = AmongUsClient.Instance!.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.ShareOptions, SendOption.Reliable, -1);
+ var writer = AmongUsClient.Instance!.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ShareOptions, SendOption.Reliable, -1);
writer.Write((byte)1);
writer.WritePacked((uint)option.id);
writer.WritePacked(Convert.ToUInt32(option.selection));
}
public static void ShareOptionSelections() {
- if (CachedPlayer.AllPlayers.Count <= 1 || AmongUsClient.Instance!.AmHost == false && CachedPlayer.LocalPlayer.PlayerControl == null) return;
+ if (PlayerControl.AllPlayerControls.Count <= 1 || AmongUsClient.Instance!.AmHost == false && PlayerControl.LocalPlayer == null) return;
var optionsList = new List<CustomOption>(CustomOption.options);
while (optionsList.Any())
{
byte amount = (byte) Math.Min(optionsList.Count, 200); // takes less than 3 bytes per option on average
- var writer = AmongUsClient.Instance!.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.ShareOptions, SendOption.Reliable, -1);
+ var writer = AmongUsClient.Instance!.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ShareOptions, SendOption.Reliable, -1);
writer.Write(amount);
for (int i = 0; i < amount; i++)
{
if (AmongUsClient.Instance?.AmClient == true && notifyUsers && selection != newSelection) {
DestroyableSingleton<HudManager>.Instance.Notifier.AddSettingsChangeMessage((StringNames)(this.id + 6000), selections[newSelection].ToString(), false);
try {
+ selection = newSelection;
if (GameStartManager.Instance != null && GameStartManager.Instance.LobbyInfoPane != null && GameStartManager.Instance.LobbyInfoPane.LobbyViewSettingsPane != null && GameStartManager.Instance.LobbyInfoPane.LobbyViewSettingsPane.gameObject.activeSelf) {
LobbyViewSettingsPaneChangeTabPatch.Postfix(GameStartManager.Instance.LobbyInfoPane.LobbyViewSettingsPane, GameStartManager.Instance.LobbyInfoPane.LobbyViewSettingsPane.currentTab);
}
try {
if (onChange != null) onChange();
} catch { }
+ if (AmongUsClient.Instance?.AmHost == true) {
+ var currentTab = GameOptionsMenuStartPatch.currentTabs.FirstOrDefault(x => x.active).GetComponent<GameOptionsMenu>();
+ if (currentTab != null) {
+ var optionType = options.First(x => x.optionBehaviour == currentTab.Children[0]).type;
+ GameOptionsMenuStartPatch.updateGameOptionsMenu(optionType, currentTab);
+ }
+ }
+
if (optionBehaviour != null && optionBehaviour is StringOption stringOption) {
stringOption.oldValue = stringOption.Value = selection;
stringOption.ValueText.text = selections[selection].ToString();
- if (AmongUsClient.Instance?.AmHost == true && CachedPlayer.LocalPlayer.PlayerControl) {
+ if (AmongUsClient.Instance?.AmHost == true && PlayerControl.LocalPlayer) {
if (id == 0 && selection != preset) {
switchPreset(selection); // Switch presets
ShareOptionSelections();
__instance.settingsInfo.Add(categoryHeaderMasked.gameObject);
num -= 0.85f;
i = 0;
- }
+ } else if (option.parent != null && (option.parent.selection == 0 || option.parent.parent != null && option.parent.parent.selection == 0)) continue; // Hides options, for which the parent is disabled!
+ if (option == CustomOptionHolder.crewmateRolesCountMax || option == CustomOptionHolder.neutralRolesCountMax || option == CustomOptionHolder.impostorRolesCountMax || option == CustomOptionHolder.modifiersCountMax || option == CustomOptionHolder.crewmateRolesFill)
+ continue;
ViewSettingsInfoPanel viewSettingsInfoPanel = UnityEngine.Object.Instantiate<ViewSettingsInfoPanel>(__instance.infoPanelOrigin);
viewSettingsInfoPanel.transform.SetParent(__instance.settingsContainer);
}
viewSettingsInfoPanel.transform.localPosition = new Vector3(num2, num, -2f);
int value = option.getSelection();
- viewSettingsInfoPanel.SetInfo(StringNames.ImpostorsCategory, option.selections[value].ToString(), 61);
- viewSettingsInfoPanel.titleText.text = option.name;
+ var settingTuple = handleSpecialOptionsView(option, option.name, option.selections[value].ToString());
+ viewSettingsInfoPanel.SetInfo(StringNames.ImpostorsCategory, settingTuple.Item2, 61);
+ viewSettingsInfoPanel.titleText.text = settingTuple.Item1;
if (option.isHeader && (int)optionType != 99 && option.heading == "" && (option.type == CustomOptionType.Neutral || option.type == CustomOptionType.Crewmate || option.type == CustomOptionType.Impostor || option.type == CustomOptionType.Modifier)) {
viewSettingsInfoPanel.titleText.text = "Spawn Chance";
}
}
+ private static Tuple<string, string> handleSpecialOptionsView(CustomOption option, string defaultString, string defaultVal) {
+ string name = defaultString;
+ string val = defaultVal;
+ if (option == CustomOptionHolder.crewmateRolesCountMin) {
+ val = "";
+ name = "Crewmate Roles";
+ var min = CustomOptionHolder.crewmateRolesCountMin.getSelection();
+ var max = CustomOptionHolder.crewmateRolesCountMax.getSelection();
+ if (CustomOptionHolder.crewmateRolesFill.getBool()) {
+ var crewCount = PlayerControl.AllPlayerControls.Count - GameOptionsManager.Instance.currentGameOptions.NumImpostors;
+ int minNeutral = CustomOptionHolder.neutralRolesCountMin.getSelection();
+ int maxNeutral = CustomOptionHolder.neutralRolesCountMax.getSelection();
+ if (minNeutral > maxNeutral) minNeutral = maxNeutral;
+ min = crewCount - maxNeutral;
+ max = crewCount - minNeutral;
+ if (min < 0) min = 0;
+ if (max < 0) max = 0;
+ val = "Fill: ";
+ }
+ if (min > max) min = max;
+ val += (min == max) ? $"{max}" : $"{min} - {max}";
+ }
+ if (option == CustomOptionHolder.neutralRolesCountMin) {
+ name = "Neutral Roles";
+ var min = CustomOptionHolder.neutralRolesCountMin.getSelection();
+ var max = CustomOptionHolder.neutralRolesCountMax.getSelection();
+ if (min > max) min = max;
+ val = (min == max) ? $"{max}" : $"{min} - {max}";
+ }
+ if (option == CustomOptionHolder.impostorRolesCountMin) {
+ name = "Impostor Roles";
+ var min = CustomOptionHolder.impostorRolesCountMin.getSelection();
+ var max = CustomOptionHolder.impostorRolesCountMax.getSelection();
+ if (max > GameOptionsManager.Instance.currentGameOptions.NumImpostors) max = GameOptionsManager.Instance.currentGameOptions.NumImpostors;
+ if (min > max) min = max;
+ val = (min == max) ? $"{max}" : $"{min} - {max}";
+ }
+ if (option == CustomOptionHolder.modifiersCountMin) {
+ name = "Modifiers";
+ var min = CustomOptionHolder.modifiersCountMin.getSelection();
+ var max = CustomOptionHolder.modifiersCountMax.getSelection();
+ if (min > max) min = max;
+ val = (min == max) ? $"{max}" : $"{min} - {max}";
+ }
+ return new(name, val);
+ }
+
public static void createSettingTabs(LobbyViewSettingsPane __instance) {
// Handle different gamemodes and tabs needed therein.
int next = 3;
categoryHeaderMasked.transform.localScale = Vector3.one * 0.63f;
categoryHeaderMasked.transform.localPosition = new Vector3(-0.903f, num, -2f);
num -= 0.63f;
- }
+ } else if (option.parent != null && (option.parent.selection == 0 || option.parent.parent != null && option.parent.parent.selection == 0)) continue; // Hides options, for which the parent is disabled!
OptionBehaviour optionBehaviour = UnityEngine.Object.Instantiate<StringOption>(menu.stringOptionOrigin, Vector3.zero, Quaternion.identity, menu.settingsContainer);
optionBehaviour.transform.localPosition = new Vector3(0.952f, num, -2f);
optionBehaviour.SetClickMask(menu.ButtonClickMask);
torSettingsTab.name = settingName;
var torSettingsGOM = torSettingsTab.GetComponent<GameOptionsMenu>();
+
+ updateGameOptionsMenu(optionType, torSettingsGOM);
+
+ currentTabs.Add(torSettingsTab);
+ torSettingsTab.SetActive(false);
+ }
+
+ public static void updateGameOptionsMenu(CustomOptionType optionType, GameOptionsMenu torSettingsGOM) {
foreach (var child in torSettingsGOM.Children) {
child.Destroy();
}
if (TORMapOptions.gameMode == CustomGamemodes.Guesser) // Exclude guesser options in neutral mode
relevantOptions = relevantOptions.Where(x => !(new List<int> { 310, 311, 312, 313, 314, 315, 316, 317, 318 }).Contains(x.id)).ToList();
createSettings(torSettingsGOM, relevantOptions);
-
- currentTabs.Add(torSettingsTab);
- torSettingsTab.SetActive(false);
}
private static void createSettingTabs(GameSettingMenu __instance) {
GameOptionsData.KillDistances = new(new float[] { 0.5f, 1f, 1.8f, 2.5f });
GameOptionsData.KillDistanceStrings = new(new string[] { "Very Short", "Short", "Medium", "Long" });
}
+
+ [HarmonyPatch(typeof(StringGameSetting), nameof(StringGameSetting.GetValueString))]
+ [HarmonyPrefix]
+ public static bool AjdustStringForViewPanel(StringGameSetting __instance, float value, ref string __result) {
+ if (__instance.OptionName != Int32OptionNames.KillDistance) return true;
+ __result = GameOptionsData.KillDistanceStrings[(int)value];
+ return false;
+ }
}
[HarmonyPatch(typeof(KeyboardJoystick), nameof(KeyboardJoystick.Update))]
Scroller.ContentYBounds = new FloatRange(MinY, maxY);
// Prevent scrolling when the player is interacting with a menu
- if (CachedPlayer.LocalPlayer?.PlayerControl.CanMove != true) {
+ if (PlayerControl.LocalPlayer.CanMove != true) {
GameSettings.transform.localPosition = LastPosition;
return;
toggleZoomButton.OnClick.RemoveAllListeners();
toggleZoomButton.OnClick.AddListener((Action)(() => Helpers.toggleZoom()));
}
- var (playerCompleted, playerTotal) = TasksHandler.taskInfo(CachedPlayer.LocalPlayer.Data);
+ var (playerCompleted, playerTotal) = TasksHandler.taskInfo(PlayerControl.LocalPlayer.Data);
int numberOfLeftTasks = playerTotal - playerCompleted;
- bool zoomButtonActive = !(CachedPlayer.LocalPlayer.PlayerControl == null || !CachedPlayer.LocalPlayer.Data.IsDead || (CachedPlayer.LocalPlayer.Data.Role.IsImpostor && !CustomOptionHolder.deadImpsBlockSabotage.getBool()));
+ bool zoomButtonActive = !(PlayerControl.LocalPlayer == null || !PlayerControl.LocalPlayer.Data.IsDead || (PlayerControl.LocalPlayer.Data.Role.IsImpostor && !CustomOptionHolder.deadImpsBlockSabotage.getBool()) || MeetingHud.Instance);
zoomButtonActive &= numberOfLeftTasks <= 0 || !CustomOptionHolder.finishTasksBeforeHauntingOrZoomingOut.getBool();
toggleZoomButtonObject.SetActive(zoomButtonActive);
var posOffset = Helpers.zoomOutStatus ? new Vector3(-1.27f, -7.92f, -52f) : new Vector3(0, -1.6f, -52f);
using HarmonyLib;
using Hazel;
using InnerNet;
-using TheOtherRoles.Players;
+
using TheOtherRoles.Utilities;
namespace TheOtherRoles.Modules {
if (AmongUsClient.Instance.AmHost && AmongUsClient.Instance.CanBan()) { // checking both just cause
handled = true;
if (!Int32.TryParse(text.Substring(6), out LobbyLimit)) {
- __instance.AddChat(CachedPlayer.LocalPlayer.PlayerControl, "Invalid Size\nUsage: /size {amount}");
+ __instance.AddChat(PlayerControl.LocalPlayer, "Invalid Size\nUsage: /size {amount}");
} else {
LobbyLimit = Math.Clamp(LobbyLimit, 4, 15);
if (LobbyLimit != GameOptionsManager.Instance.currentNormalGameOptions.MaxPlayers) {
GameOptionsManager.Instance.currentNormalGameOptions.MaxPlayers = LobbyLimit;
FastDestroyableSingleton<GameStartManager>.Instance.LastPlayerCount = LobbyLimit;
- CachedPlayer.LocalPlayer.PlayerControl.RpcSyncSettings(GameOptionsManager.Instance.gameOptionsFactory.ToBytes(GameOptionsManager.Instance.currentGameOptions, false)); // TODO Maybe simpler??
- __instance.AddChat(CachedPlayer.LocalPlayer.PlayerControl, $"Lobby Size changed to {LobbyLimit} players");
+ PlayerControl.LocalPlayer.RpcSyncSettings(GameOptionsManager.Instance.gameOptionsFactory.ToBytes(GameOptionsManager.Instance.currentGameOptions, false)); // TODO Maybe simpler??
+ __instance.AddChat(PlayerControl.LocalPlayer, $"Lobby Size changed to {LobbyLimit} players");
} else {
- __instance.AddChat(CachedPlayer.LocalPlayer.PlayerControl, $"Lobby Size is already {LobbyLimit}");
+ __instance.AddChat(PlayerControl.LocalPlayer, $"Lobby Size is already {LobbyLimit}");
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
-using TheOtherRoles.Players;
using TheOtherRoles.Utilities;
using UnityEngine;
bomb.SetActive(false);
background.SetActive(false);
- if (CachedPlayer.LocalPlayer.PlayerControl == Bomber.bomber) {
+ if (PlayerControl.LocalPlayer == Bomber.bomber) {
bomb.SetActive(true);
}
Bomber.bomb = this;
if (b == null) return;
if (Bomber.bomber != null) {
var position = b.bomb.transform.position;
- var distance = Vector2.Distance(position, CachedPlayer.LocalPlayer.transform.position); // every player only checks that for their own client (desynct with positions sucks)
- if (distance < Bomber.destructionRange && !CachedPlayer.LocalPlayer.Data.IsDead) {
- Helpers.checkMurderAttemptAndKill(Bomber.bomber, CachedPlayer.LocalPlayer.PlayerControl, false, false, true, true);
+ var distance = Vector2.Distance(position, PlayerControl.LocalPlayer.transform.position); // every player only checks that for their own client (desynct with positions sucks)
+ if (distance < Bomber.destructionRange && !PlayerControl.LocalPlayer.Data.IsDead) {
+ Helpers.checkMurderAttemptAndKill(Bomber.bomber, PlayerControl.LocalPlayer, false, false, true, true);
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.ShareGhostInfo, Hazel.SendOption.Reliable, -1);
- writer.Write(CachedPlayer.LocalPlayer.PlayerId);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ShareGhostInfo, Hazel.SendOption.Reliable, -1);
+ writer.Write(PlayerControl.LocalPlayer.PlayerId);
writer.Write((byte)RPCProcedure.GhostInfoTypes.DeathReasonAndKiller);
- writer.Write(CachedPlayer.LocalPlayer.PlayerId);
+ writer.Write(PlayerControl.LocalPlayer.PlayerId);
writer.Write((byte)DeadPlayer.CustomDeathReason.Bomb);
writer.Write(Bomber.bomber.PlayerId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
- GameHistory.overrideDeathReasonAndKiller(CachedPlayer.LocalPlayer, DeadPlayer.CustomDeathReason.Bomb, killer: Bomber.bomber);
+ GameHistory.overrideDeathReasonAndKiller(PlayerControl.LocalPlayer, DeadPlayer.CustomDeathReason.Bomb, killer: Bomber.bomber);
}
SoundEffectsManager.playAtPosition("bombExplosion", position, range: Bomber.hearRange) ;
}
Bomber.clearBomb();
}
- if (Vector2.Distance(CachedPlayer.LocalPlayer.PlayerControl.GetTruePosition(), Bomber.bomb.bomb.transform.position) > 1f) canDefuse = false;
+ if (Vector2.Distance(PlayerControl.LocalPlayer.GetTruePosition(), Bomber.bomb.bomb.transform.position) > 1f) canDefuse = false;
else canDefuse = true;
}
using Il2CppSystem.Runtime.ExceptionServices;
using System;
using System.Collections.Generic;
-using TheOtherRoles.Players;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
this.OnClick();
// Deputy skip onClickEvent if handcuffed
- if (Deputy.handcuffedKnows.ContainsKey(CachedPlayer.LocalPlayer.PlayerId) && Deputy.handcuffedKnows[CachedPlayer.LocalPlayer.PlayerId] > 0f) return;
+ if (Deputy.handcuffedKnows.ContainsKey(PlayerControl.LocalPlayer.PlayerId) && Deputy.handcuffedKnows[PlayerControl.LocalPlayer.PlayerId] > 0f) return;
if (this.HasEffect && !this.isEffectActive) {
this.DeputyTimer = this.EffectDuration;
public void Update()
{
- var localPlayer = CachedPlayer.LocalPlayer;
- var moveable = localPlayer.PlayerControl.moveable;
+ var localPlayer = PlayerControl.LocalPlayer;
+ var moveable = localPlayer.moveable;
if (localPlayer.Data == null || MeetingHud.Instance || ExileController.Instance || !HasButton()) {
setActive(false);
if (DeputyTimer >= 0) { // This had to be reordered, so that the handcuffs do not stop the underlying timers from running
if (HasEffect && isEffectActive)
DeputyTimer -= Time.deltaTime;
- else if (!localPlayer.PlayerControl.inVent && moveable)
+ else if (!localPlayer.inVent && moveable)
DeputyTimer -= Time.deltaTime;
}
if (Timer >= 0) {
if (HasEffect && isEffectActive)
Timer -= Time.deltaTime;
- else if (!localPlayer.PlayerControl.inVent && moveable)
+ else if (!localPlayer.inVent && moveable)
Timer -= Time.deltaTime;
}
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
-using TheOtherRoles.Players;
using TheOtherRoles.Utilities;
using UnityEngine;
using static TheOtherRoles.TheOtherRoles;
using System.Collections.Generic;
using UnityEngine;
using System.Linq;
-using TheOtherRoles.Players;
+
using TheOtherRoles.Utilities;
using Reactor.Utilities.Extensions;
gameObject = new GameObject("JackInTheBox"){layer = 11};
gameObject.AddSubmergedComponent(SubmergedCompatibility.Classes.ElevatorMover);
Vector3 position = new Vector3(p.x, p.y, p.y/1000f + 0.01f);
- position += (Vector3)CachedPlayer.LocalPlayer.PlayerControl.Collider.offset; // Add collider offset that DoMove moves the player up at a valid position
+ position += (Vector3)PlayerControl.LocalPlayer.Collider.offset; // Add collider offset that DoMove moves the player up at a valid position
// Create the marker
gameObject.transform.position = position;
boxRenderer = gameObject.AddComponent<SpriteRenderer>();
vent.name = "JackInTheBoxVent_" + vent.Id;
// Only render the box for the Trickster and for Ghosts
- var showBoxToLocalPlayer = CachedPlayer.LocalPlayer.PlayerControl == Trickster.trickster || PlayerControl.LocalPlayer.Data.IsDead;
+ var showBoxToLocalPlayer = PlayerControl.LocalPlayer == Trickster.trickster || PlayerControl.LocalPlayer.Data.IsDead;
gameObject.SetActive(showBoxToLocalPlayer);
AllJackInTheBoxes.Add(this);
public static void UpdateStates() {
if (boxesConvertedToVents == true) return;
foreach (var box in AllJackInTheBoxes) {
- var showBoxToLocalPlayer = CachedPlayer.LocalPlayer.PlayerControl == Trickster.trickster || PlayerControl.LocalPlayer.Data.IsDead;
+ var showBoxToLocalPlayer = PlayerControl.LocalPlayer == Trickster.trickster || PlayerControl.LocalPlayer.Data.IsDead;
box.gameObject.SetActive(showBoxToLocalPlayer);
}
}
public NinjaTrace(Vector2 p, float duration=1f) {
trace = new GameObject("NinjaTrace");
trace.AddSubmergedComponent(SubmergedCompatibility.Classes.ElevatorMover);
- //Vector3 position = new Vector3(p.x, p.y, CachedPlayer.LocalPlayer.transform.localPosition.z + 0.001f); // just behind player
+ //Vector3 position = new Vector3(p.x, p.y, PlayerControl.LocalPlayer.transform.localPosition.z + 0.001f); // just behind player
Vector3 position = new Vector3(p.x, p.y, p.y / 1000f + 0.01f);
trace.transform.position = position;
trace.transform.localPosition = position;
using System;
using UnityEngine;
using System.Collections.Generic;
-using TheOtherRoles.Players;
+
using TheOtherRoles.Utilities;
using static TheOtherRoles.TheOtherRoles;
public Portal(Vector2 p) {
portalGameObject = new GameObject("Portal"){ layer = 11 };
- //Vector3 position = new Vector3(p.x, p.y, CachedPlayer.LocalPlayer.transform.position.z + 1f);
+ //Vector3 position = new Vector3(p.x, p.y, PlayerControl.LocalPlayer.transform.position.z + 1f);
Vector3 position = new Vector3(p.x, p.y, p.y / 1000f + 0.01f);
// Create the portal
animationFgRenderer.material = FastDestroyableSingleton<HatManager>.Instance.PlayerMaterial;
// Only render the inactive portals for the Portalmaker
- bool playerIsPortalmaker = CachedPlayer.LocalPlayer.PlayerControl == TheOtherRoles.Portalmaker.portalmaker;
+ bool playerIsPortalmaker = PlayerControl.LocalPlayer == TheOtherRoles.Portalmaker.portalmaker;
portalGameObject.SetActive(playerIsPortalmaker);
portalFgAnimationGameObject.SetActive(true);
this.visibleForEveryOne = visibleForEveryOne;
gameObject = new GameObject("Silhouette");
gameObject.AddSubmergedComponent(SubmergedCompatibility.Classes.ElevatorMover);
- //Vector3 position = new Vector3(p.x, p.y, CachedPlayer.LocalPlayer.transform.localPosition.z + 0.001f); // just behind player
+ //Vector3 position = new Vector3(p.x, p.y, PlayerControl.LocalPlayer.transform.localPosition.z + 0.001f); // just behind player
Vector3 position = new Vector3(p.x, p.y, p.y / 1000f + 0.01f);
gameObject.transform.position = position;
gameObject.transform.localPosition = position;
using System;
using System.Collections.Generic;
using System.Linq;
-using TheOtherRoles.Players;
using TheOtherRoles.Utilities;
using UnityEngine;
var trapRenderer = trap.AddComponent<SpriteRenderer>();
trapRenderer.sprite = getTrapSprite();
trap.SetActive(false);
- if (CachedPlayer.LocalPlayer.PlayerId == Trapper.trapper.PlayerId) trap.SetActive(true);
+ if (PlayerControl.LocalPlayer.PlayerId == Trapper.trapper.PlayerId) trap.SetActive(true);
trapRenderer.color = Color.white * new Vector4(1, 1, 1, 0.5f);
this.instanceId = ++instanceCounter;
traps.Add(this);
Trap t = traps.FirstOrDefault(x => x.instanceId == (int)trapId);
PlayerControl player = Helpers.playerById(playerId);
if (Trapper.trapper == null || t == null || player == null) return;
- bool localIsTrapper = CachedPlayer.LocalPlayer.PlayerId == Trapper.trapper.PlayerId;
+ bool localIsTrapper = PlayerControl.LocalPlayer.PlayerId == Trapper.trapper.PlayerId;
if (!trapPlayerIdMap.ContainsKey(playerId)) trapPlayerIdMap.Add(playerId, t);
t.usedCount ++;
t.triggerable = false;
- if (playerId == CachedPlayer.LocalPlayer.PlayerId || playerId == Trapper.trapper.PlayerId) {
+ if (playerId == PlayerControl.LocalPlayer.PlayerId || playerId == Trapper.trapper.PlayerId) {
t.trap.SetActive(true);
SoundEffectsManager.play("trapperTrap");
}
public static void Update() {
if (Trapper.trapper == null) return;
- CachedPlayer player = CachedPlayer.LocalPlayer;
+ var player = PlayerControl.LocalPlayer;
Vent vent = MapUtilities.CachedShipStatus.AllVents[0];
float closestDistance = float.MaxValue;
Trap target = null;
foreach (Trap trap in traps) {
if (trap.arrow.arrow.active) trap.arrow.Update();
- if (trap.revealed || !trap.triggerable || trap.trappedPlayer.Contains(player.PlayerControl)) continue;
- if (player.PlayerControl.inVent || !player.PlayerControl.CanMove) continue;
- float distance = Vector2.Distance(trap.trap.transform.position, player.PlayerControl.GetTruePosition());
+ if (trap.revealed || !trap.triggerable || trap.trappedPlayer.Contains(player)) continue;
+ if (player.inVent || !player.CanMove) continue;
+ float distance = Vector2.Distance(trap.trap.transform.position, player.GetTruePosition());
if (distance <= ud && distance < closestDistance) {
closestDistance = distance;
target = trap;
}
}
if (target != null && player.PlayerId != Trapper.trapper.PlayerId && !player.Data.IsDead) {
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.TriggerTrap, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.TriggerTrap, Hazel.SendOption.Reliable, -1);
writer.Write(player.PlayerId);
writer.Write(target.instanceId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
using System.Threading.Tasks;
using TheOtherRoles;
using TheOtherRoles.CustomGameModes;
-using TheOtherRoles.Players;
using TheOtherRoles.Utilities;
using TMPro;
using UnityEngine;
using HarmonyLib;
-using TheOtherRoles.Players;
+
using UnityEngine;
namespace TheOtherRoles.Patches {
[HarmonyPrefix]
public static void Prefix(DangerMeter __instance, ref Color color) {
- if (CachedPlayer.LocalPlayer.PlayerControl != Tracker.tracker) return;
+ if (PlayerControl.LocalPlayer != Tracker.tracker) return;
if (__instance == HudManager.Instance.DangerMeter) return;
color = color.SetAlpha(0.5f);
using System.Linq;
using System;
using System.Text;
-using TheOtherRoles.Players;
+
using TheOtherRoles.Utilities;
using TheOtherRoles.CustomGameModes;
+using LibCpp2IL.Elf;
namespace TheOtherRoles.Patches {
enum CustomGameOverReason {
[HarmonyPatch(typeof(AmongUsClient), nameof(AmongUsClient.OnGameEnd))]
- public class OnGameEndPatch {
- private static GameOverReason gameOverReason;
+ public static class OnGameEndPatch {
+ public static GameOverReason gameOverReason = GameOverReason.HumansByTask;
public static void Prefix(AmongUsClient __instance, [HarmonyArgument(0)]ref EndGameResult endGameResult) {
gameOverReason = endGameResult.GameOverReason;
if ((int)endGameResult.GameOverReason >= 10) endGameResult.GameOverReason = GameOverReason.ImpostorByKill;
public static void Postfix(AmongUsClient __instance, [HarmonyArgument(0)]ref EndGameResult endGameResult) {
AdditionalTempData.clear();
- foreach(var playerControl in CachedPlayer.AllPlayers) {
+ foreach(var playerControl in PlayerControl.AllPlayerControls) {
var roles = RoleInfo.getRoleInfoForPlayer(playerControl);
var (tasksCompleted, tasksTotal) = TasksHandler.taskInfo(playerControl.Data);
bool isGuesser = HandleGuesser.isGuesserGm && HandleGuesser.isGuesser(playerControl.PlayerId);
CachedPlayerData wpd = new CachedPlayerData(Mini.mini.Data);
wpd.IsYou = false; // If "no one is the Mini", it will display the Mini, but also show defeat to everyone
EndGameResult.CachedWinners.Add(wpd);
- AdditionalTempData.winCondition = WinCondition.MiniLose;
+ AdditionalTempData.winCondition = WinCondition.MiniLose;
}
// Jester win
if (!Lovers.existingWithKiller()) {
AdditionalTempData.winCondition = WinCondition.LoversTeamWin;
EndGameResult.CachedWinners = new Il2CppSystem.Collections.Generic.List<CachedPlayerData>();
- foreach (PlayerControl p in CachedPlayer.AllPlayers) {
+ foreach (PlayerControl p in PlayerControl.AllPlayerControls) {
if (p == null) continue;
if (p == Lovers.lover1 || p == Lovers.lover2)
EndGameResult.CachedWinners.Add(new CachedPlayerData(p.Data));
EndGameResult.CachedWinners.Add(new CachedPlayerData(Lovers.lover2.Data));
}
}
-
+
// Jackal win condition (should be implemented using a proper GameOverReason in the future)
else if (teamJackalWin) {
// Jackal wins if nobody except jackal is alive
AdditionalTempData.winCondition = WinCondition.JackalWin;
EndGameResult.CachedWinners = new Il2CppSystem.Collections.Generic.List<CachedPlayerData>();
CachedPlayerData wpd = new CachedPlayerData(Jackal.jackal.Data);
- wpd.IsImpostor = false;
+ wpd.IsImpostor = false;
EndGameResult.CachedWinners.Add(wpd);
// If there is a sidekick. The sidekick also wins
if (Sidekick.sidekick != null) {
CachedPlayerData wpdSidekick = new CachedPlayerData(Sidekick.sidekick.Data);
- wpdSidekick.IsImpostor = false;
+ wpdSidekick.IsImpostor = false;
EndGameResult.CachedWinners.Add(wpdSidekick);
}
- foreach(var player in Jackal.formerJackals) {
+ foreach (var player in Jackal.formerJackals) {
CachedPlayerData wpdFormerJackal = new CachedPlayerData(player.Data);
- wpdFormerJackal.IsImpostor = false;
+ wpdFormerJackal.IsImpostor = false;
EndGameResult.CachedWinners.Add(wpdFormerJackal);
}
}
if (AdditionalTempData.winCondition == WinCondition.JesterWin) {
textRenderer.text = "Jester Wins";
textRenderer.color = Jester.color;
- }
- else if (AdditionalTempData.winCondition == WinCondition.ArsonistWin) {
+ } else if (AdditionalTempData.winCondition == WinCondition.ArsonistWin) {
textRenderer.text = "Arsonist Wins";
textRenderer.color = Arsonist.color;
- }
- else if (AdditionalTempData.winCondition == WinCondition.VultureWin) {
+ } else if (AdditionalTempData.winCondition == WinCondition.VultureWin) {
textRenderer.text = "Vulture Wins";
textRenderer.color = Vulture.color;
- }
- else if (AdditionalTempData.winCondition == WinCondition.ProsecutorWin) {
+ } else if (AdditionalTempData.winCondition == WinCondition.ProsecutorWin) {
textRenderer.text = "Prosecutor Wins";
textRenderer.color = Lawyer.color;
- }
- else if (AdditionalTempData.winCondition == WinCondition.LoversTeamWin) {
+ } else if (AdditionalTempData.winCondition == WinCondition.LoversTeamWin) {
textRenderer.text = "Lovers And Crewmates Win";
textRenderer.color = Lovers.color;
__instance.BackgroundBar.material.SetColor("_Color", Lovers.color);
- }
- else if (AdditionalTempData.winCondition == WinCondition.LoversSoloWin) {
+ } else if (AdditionalTempData.winCondition == WinCondition.LoversSoloWin) {
textRenderer.text = "Lovers Win";
textRenderer.color = Lovers.color;
__instance.BackgroundBar.material.SetColor("_Color", Lovers.color);
- }
- else if (AdditionalTempData.winCondition == WinCondition.JackalWin) {
+ } else if (AdditionalTempData.winCondition == WinCondition.JackalWin) {
textRenderer.text = "Team Jackal Wins";
textRenderer.color = Jackal.color;
- }
- else if (AdditionalTempData.winCondition == WinCondition.MiniLose) {
+ } else if (AdditionalTempData.winCondition == WinCondition.MiniLose) {
textRenderer.text = "Mini died";
textRenderer.color = Mini.color;
+ } else if (AdditionalTempData.winCondition == WinCondition.Default) {
+ switch (OnGameEndPatch.gameOverReason) {
+ case GameOverReason.ImpostorDisconnect:
+ textRenderer.text = "Last Crewmate Disconnected";
+ textRenderer.color = Color.red;
+ break;
+ case GameOverReason.ImpostorByKill:
+ textRenderer.text = "Impostors Win - By Kill";
+ textRenderer.color = Color.red;
+ break;
+ case GameOverReason.ImpostorBySabotage:
+ textRenderer.text = "Impostors Win - By Sabotage";
+ textRenderer.color = Color.red;
+ break;
+ case GameOverReason.ImpostorByVote:
+ textRenderer.text = "Impostors Win - By Vote, Guess or DC";
+ textRenderer.color = Color.red;
+ break;
+ case GameOverReason.HumansByTask:
+ textRenderer.text = "Crew Wins - Taskwin";
+ textRenderer.color = Color.white;
+ break;
+ case GameOverReason.HumansDisconnect:
+ textRenderer.text = "Crew Wins - No Evil Killers Left";
+ textRenderer.color = Color.white;
+ break;
+ case GameOverReason.HumansByVote:
+ textRenderer.text = "Crew Wins - No Evil Killers Left";
+ textRenderer.color = Color.white;
+ break;
+ }
}
foreach (WinCondition cond in AdditionalTempData.additionalWinConditions) {
using static TheOtherRoles.TheOtherRoles;
using TheOtherRoles.Objects;
using System;
-using TheOtherRoles.Players;
+
using TheOtherRoles.Utilities;
using UnityEngine;
[HarmonyPatch(typeof(ExileController), nameof(ExileController.Begin))]
[HarmonyPriority(Priority.First)]
class ExileControllerBeginPatch {
- public static NetworkedPlayerInfo lastExiled;
- public static void Prefix(ExileController __instance, [HarmonyArgument(0)]ref NetworkedPlayerInfo exiled, [HarmonyArgument(1)]bool tie) {
- lastExiled = exiled;
+ public static void Prefix(ExileController __instance, [HarmonyArgument(0)]ref NetworkedPlayerInfo exiled) {
// Medic shield
if (Medic.medic != null && AmongUsClient.Instance.AmHost && Medic.futureShielded != null && !Medic.medic.Data.IsDead) { // We need to send the RPC from the host here, to make sure that the order of shifting and setting the shield is correct(for that reason the futureShifted and futureShielded are being synced)
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.MedicSetShielded, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.MedicSetShielded, Hazel.SendOption.Reliable, -1);
writer.Write(Medic.futureShielded.PlayerId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCProcedure.medicSetShielded(Medic.futureShielded.PlayerId);
// Shifter shift
if (Shifter.shifter != null && AmongUsClient.Instance.AmHost && Shifter.futureShift != null) { // We need to send the RPC from the host here, to make sure that the order of shifting and erasing is correct (for that reason the futureShifted and futureErased are being synced)
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.ShifterShift, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ShifterShift, Hazel.SendOption.Reliable, -1);
writer.Write(Shifter.futureShift.PlayerId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCProcedure.shifterShift(Shifter.futureShift.PlayerId);
// Eraser erase
if (Eraser.eraser != null && AmongUsClient.Instance.AmHost && Eraser.futureErased != null) { // We need to send the RPC from the host here, to make sure that the order of shifting and erasing is correct (for that reason the futureShifted and futureErased are being synced)
foreach (PlayerControl target in Eraser.futureErased) {
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.ErasePlayerRoles, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ErasePlayerRoles, Hazel.SendOption.Reliable, -1);
writer.Write(target.PlayerId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCProcedure.erasePlayerRoles(target.PlayerId);
if (exiled != null && Lawyer.lawyer != null && (target == Lawyer.lawyer || target == Lovers.otherLover(Lawyer.lawyer)) && Lawyer.target != null && Lawyer.isProsecutor && Lawyer.target.PlayerId == exiled.PlayerId)
continue;
if (target == Lawyer.target && Lawyer.lawyer != null) {
- MessageWriter writer2 = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.LawyerPromotesToPursuer, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer2 = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.LawyerPromotesToPursuer, Hazel.SendOption.Reliable, -1);
AmongUsClient.Instance.FinishRpcImmediately(writer2);
RPCProcedure.lawyerPromotesToPursuer();
}
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.UncheckedExilePlayer, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.UncheckedExilePlayer, Hazel.SendOption.Reliable, -1);
writer.Write(target.PlayerId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCProcedure.uncheckedExilePlayer(target.PlayerId);
- MessageWriter writer3 = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.ShareGhostInfo, Hazel.SendOption.Reliable, -1);
- writer3.Write(CachedPlayer.LocalPlayer.PlayerId);
+ MessageWriter writer3 = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ShareGhostInfo, Hazel.SendOption.Reliable, -1);
+ writer3.Write(PlayerControl.LocalPlayer.PlayerId);
writer3.Write((byte)RPCProcedure.GhostInfoTypes.DeathReasonAndKiller);
writer3.Write(target.PlayerId);
writer3.Write((byte)DeadPlayer.CustomDeathReason.WitchExile);
[HarmonyPatch(typeof(ExileController), nameof(ExileController.WrapUp))]
class BaseExileControllerPatch {
public static void Postfix(ExileController __instance) {
- WrapUpPostfix(__instance.exiled);
+ NetworkedPlayerInfo networkedPlayer = __instance.initData.networkedPlayer;
+ WrapUpPostfix((networkedPlayer != null) ? networkedPlayer.Object : null);
}
}
[HarmonyPatch(typeof(AirshipExileController), nameof(AirshipExileController.WrapUpAndSpawn))]
class AirshipExileControllerPatch {
public static void Postfix(AirshipExileController __instance) {
- WrapUpPostfix(__instance.exiled);
+ NetworkedPlayerInfo networkedPlayer = __instance.initData.networkedPlayer;
+ WrapUpPostfix((networkedPlayer != null) ? networkedPlayer.Object : null);
}
}
// submerged
if (!SubmergedCompatibility.IsSubmerged) return;
if (obj.name.Contains("ExileCutscene")) {
- WrapUpPostfix(ExileControllerBeginPatch.lastExiled);
+ WrapUpPostfix(obj.GetComponent<ExileController>().initData.networkedPlayer?.Object);
} else if (obj.name.Contains("SpawnInMinigame")) {
AntiTeleport.setPosition();
Chameleon.lastMoved.Clear();
}
}
- static void WrapUpPostfix(NetworkedPlayerInfo exiled) {
+ static void WrapUpPostfix(PlayerControl exiled) {
// Prosecutor win condition
if (exiled != null && Lawyer.lawyer != null && Lawyer.target != null && Lawyer.isProsecutor && Lawyer.target.PlayerId == exiled.PlayerId && !Lawyer.lawyer.Data.IsDead)
Lawyer.triggerProsecutorWin = true;
CustomButton.MeetingEndedUpdate();
// Mini set adapted cooldown
- if (Mini.mini != null && CachedPlayer.LocalPlayer.PlayerControl == Mini.mini && Mini.mini.Data.Role.IsImpostor) {
+ if (Mini.mini != null && PlayerControl.LocalPlayer == Mini.mini && Mini.mini.Data.Role.IsImpostor) {
var multiplier = Mini.isGrownUp() ? 0.66f : 2f;
Mini.mini.SetKillTimer(GameOptionsManager.Instance.currentNormalGameOptions.KillCooldown * multiplier);
}
// Seer spawn souls
- if (Seer.deadBodyPositions != null && Seer.seer != null && CachedPlayer.LocalPlayer.PlayerControl == Seer.seer && (Seer.mode == 0 || Seer.mode == 2)) {
+ if (Seer.deadBodyPositions != null && Seer.seer != null && PlayerControl.LocalPlayer == Seer.seer && (Seer.mode == 0 || Seer.mode == 2)) {
foreach (Vector3 pos in Seer.deadBodyPositions) {
GameObject soul = new GameObject();
//soul.transform.position = pos;
Tracker.deadBodyPositions = new List<Vector3>();
// Arsonist deactivate dead poolable players
- if (Arsonist.arsonist != null && Arsonist.arsonist == CachedPlayer.LocalPlayer.PlayerControl) {
+ if (Arsonist.arsonist != null && Arsonist.arsonist == PlayerControl.LocalPlayer) {
int visibleCounter = 0;
Vector3 newBottomLeft = IntroCutsceneOnDestroyPatch.bottomLeft;
var BottomLeft = newBottomLeft + new Vector3(-0.25f, -0.25f, 0);
- foreach (PlayerControl p in CachedPlayer.AllPlayers) {
+ foreach (PlayerControl p in PlayerControl.AllPlayerControls) {
if (!TORMapOptions.playerIcons.ContainsKey(p.PlayerId)) continue;
if (p.Data.IsDead || p.Data.Disconnected) {
TORMapOptions.playerIcons[p.PlayerId].gameObject.SetActive(false);
}
// Force Bounty Hunter Bounty Update
- if (BountyHunter.bountyHunter != null && BountyHunter.bountyHunter == CachedPlayer.LocalPlayer.PlayerControl)
+ if (BountyHunter.bountyHunter != null && BountyHunter.bountyHunter == PlayerControl.LocalPlayer)
BountyHunter.bountyUpdateTimer = 0f;
// Medium spawn souls
- if (Medium.medium != null && CachedPlayer.LocalPlayer.PlayerControl == Medium.medium) {
+ if (Medium.medium != null && PlayerControl.LocalPlayer == Medium.medium) {
if (Medium.souls != null) {
foreach (SpriteRenderer sr in Medium.souls) UnityEngine.Object.Destroy(sr.gameObject);
Medium.souls = new List<SpriteRenderer>();
class ExileControllerMessagePatch {
static void Postfix(ref string __result, [HarmonyArgument(0)]StringNames id) {
try {
- if (ExileController.Instance != null && ExileController.Instance.exiled != null) {
- PlayerControl player = Helpers.playerById(ExileController.Instance.exiled.Object.PlayerId);
+ if (ExileController.Instance != null && ExileController.Instance.initData != null) {
+ PlayerControl player = ExileController.Instance.initData.networkedPlayer.Object;
if (player == null) return;
// Exile role text
if (id == StringNames.ExileTextPN || id == StringNames.ExileTextSN || id == StringNames.ExileTextPP || id == StringNames.ExileTextSP) {
using System.Collections.Generic;
using Hazel;
using System;
-using TheOtherRoles.Players;
+
using TheOtherRoles.Utilities;
using System.Linq;
using Reactor.Utilities.Extensions;
[HarmonyPatch(typeof(AmongUsClient), nameof(AmongUsClient.OnPlayerJoined))]
public class AmongUsClientOnPlayerJoinedPatch {
public static void Postfix(AmongUsClient __instance) {
- if (CachedPlayer.LocalPlayer != null) {
+ if (PlayerControl.LocalPlayer != null) {
Helpers.shareGameVersion();
}
GameStartManagerUpdatePatch.sendGamemode = true;
}
public static void Postfix(GameStartManager __instance) {
- // Send version as soon as CachedPlayer.LocalPlayer.PlayerControl exists
+ // Send version as soon as PlayerControl.LocalPlayer exists
if (PlayerControl.LocalPlayer != null && !versionSent) {
versionSent = true;
Helpers.shareGameVersion();
copiedStartButton?.Destroy();
// Make starting info available to clients:
if (startingTimer <= 0 && __instance.startState == GameStartManager.StartingStates.Countdown) {
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.SetGameStarting, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetGameStarting, Hazel.SendOption.Reliable, -1);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCProcedure.setGameStarting();
// Activate Stop-Button
PassiveButton startButtonPassiveButton = copiedStartButton.GetComponent<PassiveButton>();
void StopStartFunc() {
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.StopStart, Hazel.SendOption.Reliable, AmongUsClient.Instance.HostId);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.StopStart, Hazel.SendOption.Reliable, AmongUsClient.Instance.HostId);
writer.Write(PlayerControl.LocalPlayer.PlayerId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
copiedStartButton.Destroy();
if (!AmongUsClient.Instance) return;
- if (AmongUsClient.Instance.AmHost && sendGamemode && CachedPlayer.LocalPlayer != null) {
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.ShareGamemode, Hazel.SendOption.Reliable, -1);
+ if (AmongUsClient.Instance.AmHost && sendGamemode && PlayerControl.LocalPlayer != null) {
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ShareGamemode, Hazel.SendOption.Reliable, -1);
writer.Write((byte) TORMapOptions.gameMode);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCProcedure.shareGamemode((byte) TORMapOptions.gameMode);
if (TORMapOptions.gameMode == CustomGamemodes.HideNSeek) mapId = (byte)CustomOptionHolder.hideNSeekMap.getSelection();
else if (TORMapOptions.gameMode == CustomGamemodes.PropHunt) mapId = (byte)CustomOptionHolder.propHuntMap.getSelection();
if (mapId >= 3) mapId++;
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.DynamicMapOption, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.DynamicMapOption, Hazel.SendOption.Reliable, -1);
writer.Write(mapId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCProcedure.dynamicMapOption(mapId);
}
if (chosenMapId >= 3) chosenMapId++; // Skip dlekS
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.DynamicMapOption, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.DynamicMapOption, Hazel.SendOption.Reliable, -1);
writer.Write(chosenMapId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCProcedure.dynamicMapOption(chosenMapId);
using AmongUs.GameOptions;
using System.Collections.Generic;
using System.Linq;
-using TheOtherRoles.Players;
+
using System;
using TheOtherRoles.CustomGameModes;
[HarmonyPatch(typeof(HauntMenuMinigame), nameof(HauntMenuMinigame.FixedUpdate))]
public static void UpdatePostfix(HauntMenuMinigame __instance) {
if (GameOptionsManager.Instance.currentGameOptions.GameMode != GameModes.Normal) return;
- if (CachedPlayer.LocalPlayer.Data.Role.IsImpostor && Vampire.vampire != CachedPlayer.LocalPlayer.PlayerControl)
+ if (PlayerControl.LocalPlayer.Data.Role.IsImpostor && Vampire.vampire != PlayerControl.LocalPlayer)
__instance.gameObject.transform.localPosition = new UnityEngine.Vector3(-6f, -1.1f, __instance.gameObject.transform.localPosition.z);
return;
}
[HarmonyPatch(typeof(AbilityButton), nameof(AbilityButton.Update))]
public static void showOrHideAbilityButtonPostfix(AbilityButton __instance) {
bool isGameMode = GameOptionsManager.Instance.currentGameOptions.GameMode == GameModes.HideNSeek || PropHunt.isPropHuntGM || HideNSeek.isHideNSeekGM;
- if (CachedPlayer.LocalPlayer.Data.IsDead && (CustomOptionHolder.finishTasksBeforeHauntingOrZoomingOut.getBool() || isGameMode)) {
+ if (PlayerControl.LocalPlayer.Data.IsDead && (CustomOptionHolder.finishTasksBeforeHauntingOrZoomingOut.getBool() || isGameMode)) {
// player has haunt button.
- var (playerCompleted, playerTotal) = TasksHandler.taskInfo(CachedPlayer.LocalPlayer.Data);
+ var (playerCompleted, playerTotal) = TasksHandler.taskInfo(PlayerControl.LocalPlayer.Data);
int numberOfLeftTasks = playerTotal - playerCompleted;
if (numberOfLeftTasks <= 0 || isGameMode)
__instance.Show();
using System.Collections.Generic;
using System.Linq;
using Hazel;
-using TheOtherRoles.Players;
+
using TheOtherRoles.Utilities;
using TheOtherRoles.CustomGameModes;
// Generate and initialize player icons
int playerCounter = 0;
int hideNSeekCounter = 0;
- if (CachedPlayer.LocalPlayer != null && FastDestroyableSingleton<HudManager>.Instance != null) {
+ if (PlayerControl.LocalPlayer != null && FastDestroyableSingleton<HudManager>.Instance != null) {
float aspect = Camera.main.aspect;
float safeOrthographicSize = CameraSafeArea.GetSafeOrthographicSize(Camera.main);
float xpos = 1.75f - safeOrthographicSize * aspect * 1.70f;
float ypos = 0.15f - safeOrthographicSize * 1.7f;
bottomLeft = new Vector3(xpos / 2, ypos/2, -61f);
- foreach (PlayerControl p in CachedPlayer.AllPlayers) {
+ foreach (PlayerControl p in PlayerControl.AllPlayerControls) {
NetworkedPlayerInfo data = p.Data;
PoolablePlayer player = UnityEngine.Object.Instantiate<PoolablePlayer>(__instance.PlayerPrefab, FastDestroyableSingleton<HudManager>.Instance.transform);
playerPrefab = __instance.PlayerPrefab;
TORMapOptions.playerIcons[p.PlayerId] = player;
player.gameObject.SetActive(false);
- if (CachedPlayer.LocalPlayer.PlayerControl == Arsonist.arsonist && p != Arsonist.arsonist) {
+ if (PlayerControl.LocalPlayer == Arsonist.arsonist && p != Arsonist.arsonist) {
player.transform.localPosition = bottomLeft + new Vector3(-0.25f, -0.25f, 0) + Vector3.right * playerCounter++ * 0.35f;
player.transform.localScale = Vector3.one * 0.2f;
player.setSemiTransparent(true);
}
// Force Bounty Hunter to load a new Bounty when the Intro is over
- if (BountyHunter.bounty != null && CachedPlayer.LocalPlayer.PlayerControl == BountyHunter.bountyHunter) {
+ if (BountyHunter.bounty != null && PlayerControl.LocalPlayer == BountyHunter.bountyHunter) {
BountyHunter.bountyUpdateTimer = 0f;
if (FastDestroyableSingleton<HudManager>.Instance != null) {
BountyHunter.cooldownText = UnityEngine.Object.Instantiate<TMPro.TextMeshPro>(FastDestroyableSingleton<HudManager>.Instance.KillButton.cooldownTimerText, FastDestroyableSingleton<HudManager>.Instance.transform);
if (AmongUsClient.Instance.AmHost && TORMapOptions.shieldFirstKill && TORMapOptions.firstKillName != "" && !HideNSeek.isHideNSeekGM && !PropHunt.isPropHuntGM) {
PlayerControl target = PlayerControl.AllPlayerControls.ToArray().ToList().FirstOrDefault(x => x.Data.PlayerName.Equals(TORMapOptions.firstKillName));
if (target != null) {
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.SetFirstKill, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetFirstKill, Hazel.SendOption.Reliable, -1);
writer.Write(target.PlayerId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCProcedure.setFirstKill(target.PlayerId);
class IntroPatch {
public static void setupIntroTeamIcons(IntroCutscene __instance, ref Il2CppSystem.Collections.Generic.List<PlayerControl> yourTeam) {
// Intro solo teams
- if (Helpers.isNeutral(CachedPlayer.LocalPlayer.PlayerControl)) {
+ if (Helpers.isNeutral(PlayerControl.LocalPlayer)) {
var soloTeam = new Il2CppSystem.Collections.Generic.List<PlayerControl>();
- soloTeam.Add(CachedPlayer.LocalPlayer.PlayerControl);
+ soloTeam.Add(PlayerControl.LocalPlayer);
yourTeam = soloTeam;
}
// Add the Spy to the Impostor team (for the Impostors)
- if (Spy.spy != null && CachedPlayer.LocalPlayer.Data.Role.IsImpostor) {
+ if (Spy.spy != null && PlayerControl.LocalPlayer.Data.Role.IsImpostor) {
List<PlayerControl> players = PlayerControl.AllPlayerControls.ToArray().ToList().OrderBy(x => Guid.NewGuid()).ToList();
var fakeImpostorTeam = new Il2CppSystem.Collections.Generic.List<PlayerControl>(); // The local player always has to be the first one in the list (to be displayed in the center)
- fakeImpostorTeam.Add(CachedPlayer.LocalPlayer.PlayerControl);
+ fakeImpostorTeam.Add(PlayerControl.LocalPlayer);
foreach (PlayerControl p in players) {
- if (CachedPlayer.LocalPlayer.PlayerControl != p && (p == Spy.spy || p.Data.Role.IsImpostor))
+ if (PlayerControl.LocalPlayer != p && (p == Spy.spy || p.Data.Role.IsImpostor))
fakeImpostorTeam.Add(p);
}
yourTeam = fakeImpostorTeam;
}
public static void setupIntroTeam(IntroCutscene __instance, ref Il2CppSystem.Collections.Generic.List<PlayerControl> yourTeam) {
- List<RoleInfo> infos = RoleInfo.getRoleInfoForPlayer(CachedPlayer.LocalPlayer.PlayerControl);
+ List<RoleInfo> infos = RoleInfo.getRoleInfoForPlayer(PlayerControl.LocalPlayer);
RoleInfo roleInfo = infos.Where(info => !info.isModifier).FirstOrDefault();
if (roleInfo == null) return;
if (roleInfo.isNeutral) {
static int seed = 0;
static public void SetRoleTexts(IntroCutscene __instance) {
// Don't override the intro of the vanilla roles
- List<RoleInfo> infos = RoleInfo.getRoleInfoForPlayer(CachedPlayer.LocalPlayer.PlayerControl);
+ List<RoleInfo> infos = RoleInfo.getRoleInfoForPlayer(PlayerControl.LocalPlayer);
RoleInfo roleInfo = infos.Where(info => !info.isModifier).FirstOrDefault();
RoleInfo modifierInfo = infos.Where(info => info.isModifier).FirstOrDefault();
if (modifierInfo.roleId != RoleId.Lover)
__instance.RoleBlurbText.text += Helpers.cs(modifierInfo.color, $"\n{modifierInfo.introDescription}");
else {
- PlayerControl otherLover = CachedPlayer.LocalPlayer.PlayerControl == Lovers.lover1 ? Lovers.lover2 : Lovers.lover1;
+ PlayerControl otherLover = PlayerControl.LocalPlayer == Lovers.lover1 ? Lovers.lover2 : Lovers.lover1;
__instance.RoleBlurbText.text += Helpers.cs(Lovers.color, $"\n♥ You are in love with {otherLover?.Data?.PlayerName ?? ""} ♥");
}
}
--- /dev/null
+
+using AmongUs.Data;
+using HarmonyLib;
+using InnerNet;
+using System.Text.RegularExpressions;
+using UnityEngine;
+
+namespace TheOtherRoles.Patches {
+ [HarmonyPatch]
+
+ public sealed class LobbyJoinBind {
+ static int GameId;
+
+ static GameObject LobbyText;
+
+ [HarmonyPatch(typeof(InnerNetClient), nameof(InnerNetClient.JoinGame))]
+ [HarmonyPostfix]
+
+ public static void Postfix(InnerNetClient __instance) {
+ GameId = __instance.GameId;
+ }
+
+ [HarmonyPatch(typeof(MMOnlineManager), nameof(MMOnlineManager.Start))]
+ [HarmonyPostfix]
+
+ public static void Postfix() {
+ if (!LobbyText) {
+ LobbyText = new("lobbycode");
+ var comp = LobbyText.AddComponent<TMPro.TextMeshPro>();
+ comp.fontSize = 2.5f;
+ LobbyText.transform.localPosition = new(10.3f, -3.9f, 0);
+ LobbyText.SetActive(true);
+ }
+ }
+
+ [HarmonyPatch(typeof(MMOnlineManager), nameof(MMOnlineManager.Update))]
+ [HarmonyPostfix]
+
+ public static void Postfix(MMOnlineManager __instance) {
+
+ string code2 = GUIUtility.systemCopyBuffer;
+
+ if (code2.Length != 6 || !Regex.IsMatch(code2, @"^[a-zA-Z]+$"))
+ code2 = "";
+ string code2Disp = DataManager.Settings.Gameplay.StreamerMode ? "****" : code2.ToUpper();
+ if (GameId != 0 && Input.GetKeyDown(KeyCode.LeftShift)) {
+ __instance.StartCoroutine(AmongUsClient.Instance.CoJoinOnlineGameFromCode(GameId));
+ } else if (Input.GetKeyDown(KeyCode.RightShift) && code2 != "") {
+ __instance.StartCoroutine(AmongUsClient.Instance.CoJoinOnlineGameFromCode(GameCode.GameNameToInt(code2)));
+ }
+
+ if (LobbyText) {
+ LobbyText.GetComponent<TMPro.TextMeshPro>().text = "";
+ if (GameId != 0 && GameId != 32) {
+ string code = GameCode.IntToGameName(GameId);
+ if (code != "") {
+ code = DataManager.Settings.Gameplay.StreamerMode ? "****" : code;
+ LobbyText.GetComponent<TMPro.TextMeshPro>().text = $"Prev Lobby: {code} [LShift]";
+
+ }
+ }
+ if (code2 != "") {
+ LobbyText.GetComponent<TMPro.TextMeshPro>().text += $"\nClipboard: {code2Disp} [RShift]";
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
using System.Collections.Generic;
using System.Linq;
using TheOtherRoles.Objects;
-using TheOtherRoles.Players;
+
using TheOtherRoles.Utilities;
using UnityEngine;
[HarmonyPatch(typeof(MapBehaviour))]
static class MapBehaviourPatch {
- public static Dictionary<PlayerControl, SpriteRenderer> herePoints = new();
+ public static Dictionary<Byte, SpriteRenderer> herePoints = new();
public static Sprite Vent = Helpers.loadSpriteFromResources("TheOtherRoles.Resources.Vent.png", 150f);
}
__instance.HerePoint.transform.SetLocalZ(-2.1f);
- if (Trapper.trapper != null && CachedPlayer.LocalPlayer.PlayerId == Trapper.trapper.PlayerId) {
+ if (Trapper.trapper != null && PlayerControl.LocalPlayer.PlayerId == Trapper.trapper.PlayerId) {
foreach (PlayerControl player in Trapper.playersOnMap) {
- if (herePoints.ContainsKey(player)) continue;
+ if (herePoints.ContainsKey(player.PlayerId)) continue;
Vector3 v = Trap.trapPlayerIdMap[player.PlayerId].trap.transform.position;
v /= MapUtilities.CachedShipStatus.MapScale;
v.x *= Mathf.Sign(MapUtilities.CachedShipStatus.transform.localScale.x);
if (Trapper.anonymousMap) player.CurrentOutfit.ColorId = 6;
player.SetPlayerMaterialColors(herePoint);
player.CurrentOutfit.ColorId = colorId;
- herePoints.Add(player, herePoint);
+ herePoints.Add(player.PlayerId, herePoint);
}
- foreach (var s in herePoints.Where(x => !Trapper.playersOnMap.Contains(x.Key)).ToList()) {
+ foreach (var s in herePoints.Where(x => !Trapper.playersOnMap.Contains(Helpers.playerById(x.Key))).ToList()) {
UnityEngine.Object.Destroy(s.Value);
herePoints.Remove(s.Key);
}
- } else if (Snitch.snitch != null && CachedPlayer.LocalPlayer.PlayerId == Snitch.snitch.PlayerId && !Snitch.snitch.Data.IsDead && Snitch.mode != Snitch.Mode.Chat) {
+ } else if (Snitch.snitch != null && PlayerControl.LocalPlayer.PlayerId == Snitch.snitch.PlayerId && !Snitch.snitch.Data.IsDead && Snitch.mode != Snitch.Mode.Chat) {
var (playerCompleted, playerTotal) = TasksHandler.taskInfo(Snitch.snitch.Data);
int numberOfTasks = playerTotal - playerCompleted;
if (numberOfTasks == 0) {
if (MeetingHud.Instance == null) {
- foreach (PlayerControl player in CachedPlayer.AllPlayers) {
+ foreach (PlayerControl player in PlayerControl.AllPlayerControls) {
if (Snitch.targets == Snitch.Targets.EvilPlayers && !Helpers.isEvil(player)) continue;
else if (Snitch.targets == Snitch.Targets.Killers && !Helpers.isKiller(player)) continue;
if (player.Data.IsDead) continue;
v /= MapUtilities.CachedShipStatus.MapScale;
v.x *= Mathf.Sign(MapUtilities.CachedShipStatus.transform.localScale.x);
v.z = -2.1f;
- if (herePoints.ContainsKey(player)) {
- herePoints[player].transform.localPosition = v;
+ if (herePoints.ContainsKey(player.PlayerId)) {
+ herePoints[player.PlayerId].transform.localPosition = v;
continue;
}
var herePoint = UnityEngine.Object.Instantiate(__instance.HerePoint, __instance.HerePoint.transform.parent, true);
player.CurrentOutfit.ColorId = 6;
player.SetPlayerMaterialColors(herePoint);
player.CurrentOutfit.ColorId = colorId;
- herePoints.Add(player, herePoint);
+ herePoints.Add(player.PlayerId, herePoint);
}
} else {
foreach (var s in herePoints) {
// Show location of all players on the map for ghosts!
if (PlayerControl.LocalPlayer.Data.IsDead && (!PlayerControl.LocalPlayer.Data.Role.IsImpostor || CustomOptionHolder.deadImpsBlockSabotage.getBool())) {
- foreach (PlayerControl player in CachedPlayer.AllPlayers) {
+ foreach (PlayerControl player in PlayerControl.AllPlayerControls) {
if (player == PlayerControl.LocalPlayer)
continue;
var alpha = player.Data.IsDead ? 0.25f : 1f;
v /= MapUtilities.CachedShipStatus.MapScale;
v.x *= Mathf.Sign(MapUtilities.CachedShipStatus.transform.localScale.x);
v.z = -2.1f;
- if (herePoints.ContainsKey(player)) {
- herePoints[player].transform.localPosition = v;
- herePoints[player].color = herePoints[player].color.SetAlpha(alpha);
+ if (herePoints.TryGetValue(player.PlayerId, out _)) {
+ herePoints[player.PlayerId].transform.localPosition = v;
+ herePoints[player.PlayerId].color = herePoints[player.PlayerId].color.SetAlpha(alpha);
continue;
}
- var herePoint = UnityEngine.Object.Instantiate(__instance.HerePoint, __instance.HerePoint.transform.parent, true);
+
+ string pointName = $"TOR HerePoint {player.PlayerId}";
+ var doublePoint = GameObject.Find(pointName);
+ if (doublePoint != null) {
+ doublePoint.Destroy();
+ }
+
+ var herePoint = UnityEngine.Object.Instantiate(__instance.HerePoint, __instance.HerePoint.transform.parent, true);
+
+ herePoint.name = pointName;
herePoint.transform.localPosition = v;
herePoint.enabled = true;
+
+
int colorId = player.CurrentOutfit.ColorId;
player.SetPlayerMaterialColors(herePoint);
- herePoints.Add(player, herePoint);
+ herePoints.Add(player.PlayerId, herePoint);
}
}
foreach (var vent in MapUtilities.CachedShipStatus.AllVents) {
using static TheOtherRoles.TORMapOptions;
using TheOtherRoles.Objects;
using System;
-using TheOtherRoles.Players;
+
using TheOtherRoles.Utilities;
using UnityEngine;
using Innersloth.Assets;
exiled = potentialExiled.ToArray().FirstOrDefault(v => v.PlayerId == tiebreakerVote);
tie = false;
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.SetTiebreak, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetTiebreak, Hazel.SendOption.Reliable, -1);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCProcedure.setTiebreak();
}
public static bool Prefix(MeetingHud __instance, NetworkedPlayerInfo voterPlayer, int index, Transform parent) {
var spriteRenderer = UnityEngine.Object.Instantiate<SpriteRenderer>(__instance.PlayerVotePrefab);
var showVoteColors = !GameManager.Instance.LogicOptions.GetAnonymousVotes() ||
- (CachedPlayer.LocalPlayer.Data.IsDead && TORMapOptions.ghostsSeeVotes) ||
- (Mayor.mayor != null && Mayor.mayor == CachedPlayer.LocalPlayer.PlayerControl && Mayor.canSeeVoteColors && TasksHandler.taskInfo(CachedPlayer.LocalPlayer.Data).Item1 >= Mayor.tasksNeededToSeeVoteColors);
+ (PlayerControl.LocalPlayer.Data.IsDead && TORMapOptions.ghostsSeeVotes) ||
+ (Mayor.mayor != null && Mayor.mayor == PlayerControl.LocalPlayer && Mayor.canSeeVoteColors && TasksHandler.taskInfo(PlayerControl.LocalPlayer.Data).Item1 >= Mayor.tasksNeededToSeeVoteColors);
if (showVoteColors)
{
PlayerMaterial.SetColors(voterPlayer.DefaultOutfit.ColorId, spriteRenderer);
if (swapperButtonList[A] != null) swapperButtonList[A].OnClick.RemoveAllListeners(); // Swap buttons can't be clicked / changed anymore
}
if (firstPlayer != null && secondPlayer != null) {
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.SwapperSwap, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SwapperSwap, Hazel.SendOption.Reliable, -1);
writer.Write((byte)firstPlayer.TargetPlayerId);
writer.Write((byte)secondPlayer.TargetPlayerId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
// Only for the swapper: Reset all the buttons and charges value to their original state.
- if (CachedPlayer.LocalPlayer.PlayerControl != Swapper.swapper) return;
+ if (PlayerControl.LocalPlayer != Swapper.swapper) return;
// check if dying player was a selected player (but not confirmed yet)
Mayor.voteTwice = !Mayor.voteTwice;
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.MayorSetVoteTwice, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.MayorSetVoteTwice, Hazel.SendOption.Reliable, -1);
writer.Write(Mayor.voteTwice);
AmongUsClient.Instance.FinishRpcImmediately(writer);
guesserUIExitButton.OnClick.AddListener((System.Action)(() => {
__instance.playerStates.ToList().ForEach(x => {
x.gameObject.SetActive(true);
- if (CachedPlayer.LocalPlayer.Data.IsDead && x.transform.FindChild("ShootButton") != null) UnityEngine.Object.Destroy(x.transform.FindChild("ShootButton").gameObject);
+ if (PlayerControl.LocalPlayer.Data.IsDead && x.transform.FindChild("ShootButton") != null) UnityEngine.Object.Destroy(x.transform.FindChild("ShootButton").gameObject);
});
UnityEngine.Object.Destroy(container.gameObject);
}));
Transform selectedButton = null;
foreach (RoleInfo roleInfo in RoleInfo.allRoleInfos) {
- RoleId guesserRole = (Guesser.niceGuesser != null && CachedPlayer.LocalPlayer.PlayerId == Guesser.niceGuesser.PlayerId) ? RoleId.NiceGuesser : RoleId.EvilGuesser;
+ RoleId guesserRole = (Guesser.niceGuesser != null && PlayerControl.LocalPlayer.PlayerId == Guesser.niceGuesser.PlayerId) ? RoleId.NiceGuesser : RoleId.EvilGuesser;
if (roleInfo.isModifier || roleInfo.roleId == guesserRole || (!HandleGuesser.evilGuesserCanGuessSpy && guesserRole == RoleId.EvilGuesser && roleInfo.roleId == RoleId.Spy && !HandleGuesser.isGuesserGm)) continue; // Not guessable roles & modifier
if (HandleGuesser.isGuesserGm && (roleInfo.roleId == RoleId.NiceGuesser || roleInfo.roleId == RoleId.EvilGuesser)) continue; // remove Guesser for guesser game mode
- if (HandleGuesser.isGuesserGm && CachedPlayer.LocalPlayer.PlayerControl.Data.Role.IsImpostor && !HandleGuesser.evilGuesserCanGuessSpy && roleInfo.roleId == RoleId.Spy) continue;
+ if (HandleGuesser.isGuesserGm && PlayerControl.LocalPlayer.Data.Role.IsImpostor && !HandleGuesser.evilGuesserCanGuessSpy && roleInfo.roleId == RoleId.Spy) continue;
// remove all roles that cannot spawn due to the settings from the ui.
RoleManagerSelectRolesPatch.RoleAssignmentData roleData = RoleManagerSelectRolesPatch.getRoleAssignmentData();
if (roleData.neutralSettings.ContainsKey((byte)roleInfo.roleId) && roleData.neutralSettings[(byte)roleInfo.roleId] == 0) continue;
int copiedIndex = i;
button.GetComponent<PassiveButton>().OnClick.RemoveAllListeners();
- if (!CachedPlayer.LocalPlayer.Data.IsDead && !Helpers.playerById((byte)__instance.playerStates[buttonTarget].TargetPlayerId).Data.IsDead) button.GetComponent<PassiveButton>().OnClick.AddListener((System.Action)(() => {
+ if (!PlayerControl.LocalPlayer.Data.IsDead && !Helpers.playerById((byte)__instance.playerStates[buttonTarget].TargetPlayerId).Data.IsDead) button.GetComponent<PassiveButton>().OnClick.AddListener((System.Action)(() => {
if (selectedButton != button) {
selectedButton = button;
buttons.ForEach(x => x.GetComponent<SpriteRenderer>().color = x == selectedButton ? Color.red : Color.white);
} else {
PlayerControl focusedTarget = Helpers.playerById((byte)__instance.playerStates[buttonTarget].TargetPlayerId);
- if (!(__instance.state == MeetingHud.VoteStates.Voted || __instance.state == MeetingHud.VoteStates.NotVoted) || focusedTarget == null || HandleGuesser.remainingShots(CachedPlayer.LocalPlayer.PlayerId) <= 0 ) return;
+ if (!(__instance.state == MeetingHud.VoteStates.Voted || __instance.state == MeetingHud.VoteStates.NotVoted) || focusedTarget == null || HandleGuesser.remainingShots(PlayerControl.LocalPlayer.PlayerId) <= 0 ) return;
if (!HandleGuesser.killsThroughShield && focusedTarget == Medic.shielded) { // Depending on the options, shooting the shielded player will not allow the guess, notifiy everyone about the kill attempt and close the window
__instance.playerStates.ToList().ForEach(x => x.gameObject.SetActive(true));
UnityEngine.Object.Destroy(container.gameObject);
- MessageWriter murderAttemptWriter = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.ShieldedMurderAttempt, Hazel.SendOption.Reliable, -1);
+ MessageWriter murderAttemptWriter = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ShieldedMurderAttempt, Hazel.SendOption.Reliable, -1);
AmongUsClient.Instance.FinishRpcImmediately(murderAttemptWriter);
RPCProcedure.shieldedMurderAttempt();
SoundEffectsManager.play("fail");
var mainRoleInfo = RoleInfo.getRoleInfoForPlayer(focusedTarget, false).FirstOrDefault();
if (mainRoleInfo == null) return;
- PlayerControl dyingTarget = (mainRoleInfo == roleInfo) ? focusedTarget : CachedPlayer.LocalPlayer.PlayerControl;
+ PlayerControl dyingTarget = (mainRoleInfo == roleInfo) ? focusedTarget : PlayerControl.LocalPlayer;
// Reset the GUI
__instance.playerStates.ToList().ForEach(x => x.gameObject.SetActive(true));
UnityEngine.Object.Destroy(container.gameObject);
- if (HandleGuesser.hasMultipleShotsPerMeeting && HandleGuesser.remainingShots(CachedPlayer.LocalPlayer.PlayerId) > 1 && dyingTarget != CachedPlayer.LocalPlayer.PlayerControl)
+ if (HandleGuesser.hasMultipleShotsPerMeeting && HandleGuesser.remainingShots(PlayerControl.LocalPlayer.PlayerId) > 1 && dyingTarget != PlayerControl.LocalPlayer)
__instance.playerStates.ToList().ForEach(x => { if (x.TargetPlayerId == dyingTarget.PlayerId && x.transform.FindChild("ShootButton") != null) UnityEngine.Object.Destroy(x.transform.FindChild("ShootButton").gameObject); });
else
__instance.playerStates.ToList().ForEach(x => { if (x.transform.FindChild("ShootButton") != null) UnityEngine.Object.Destroy(x.transform.FindChild("ShootButton").gameObject); });
// Shoot player and send chat info if activated
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.GuesserShoot, Hazel.SendOption.Reliable, -1);
- writer.Write(CachedPlayer.LocalPlayer.PlayerId);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.GuesserShoot, Hazel.SendOption.Reliable, -1);
+ writer.Write(PlayerControl.LocalPlayer.PlayerId);
writer.Write(dyingTarget.PlayerId);
writer.Write(focusedTarget.PlayerId);
writer.Write((byte)roleInfo.roleId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
- RPCProcedure.guesserShoot(CachedPlayer.LocalPlayer.PlayerId, dyingTarget.PlayerId, focusedTarget.PlayerId, (byte)roleInfo.roleId);
+ RPCProcedure.guesserShoot(PlayerControl.LocalPlayer.PlayerId, dyingTarget.PlayerId, focusedTarget.PlayerId, (byte)roleInfo.roleId);
}
}));
[HarmonyPatch(typeof(PlayerVoteArea), nameof(PlayerVoteArea.Select))]
class PlayerVoteAreaSelectPatch {
static bool Prefix(MeetingHud __instance) {
- return !(CachedPlayer.LocalPlayer != null && HandleGuesser.isGuesser(CachedPlayer.LocalPlayer.PlayerId) && guesserUI != null);
+ return !(PlayerControl.LocalPlayer != null && HandleGuesser.isGuesser(PlayerControl.LocalPlayer.PlayerId) && guesserUI != null);
}
}
static void populateButtonsPostfix(MeetingHud __instance) {
// Add Swapper Buttons
- bool addSwapperButtons = Swapper.swapper != null && CachedPlayer.LocalPlayer.PlayerControl == Swapper.swapper && !Swapper.swapper.Data.IsDead;
- bool addMayorButton = Mayor.mayor != null && CachedPlayer.LocalPlayer.PlayerControl == Mayor.mayor && !Mayor.mayor.Data.IsDead && Mayor.mayorChooseSingleVote > 0;
+ bool addSwapperButtons = Swapper.swapper != null && PlayerControl.LocalPlayer == Swapper.swapper && !Swapper.swapper.Data.IsDead;
+ bool addMayorButton = Mayor.mayor != null && PlayerControl.LocalPlayer == Mayor.mayor && !Mayor.mayor.Data.IsDead && Mayor.mayorChooseSingleVote > 0;
if (addSwapperButtons) {
selections = new bool[__instance.playerStates.Length];
renderers = new SpriteRenderer[__instance.playerStates.Length];
checkbox.transform.SetParent(playerVoteArea.transform);
checkbox.transform.position = template.transform.position;
checkbox.transform.localPosition = new Vector3(-0.95f, 0.03f, -1.3f);
- if (HandleGuesser.isGuesserGm && HandleGuesser.isGuesser(CachedPlayer.LocalPlayer.PlayerId)) checkbox.transform.localPosition = new Vector3(-0.5f, 0.03f, -1.3f);
+ if (HandleGuesser.isGuesserGm && HandleGuesser.isGuesser(PlayerControl.LocalPlayer.PlayerId)) checkbox.transform.localPosition = new Vector3(-0.5f, 0.03f, -1.3f);
SpriteRenderer renderer = checkbox.GetComponent<SpriteRenderer>();
renderer.sprite = Swapper.getCheckSprite();
renderer.color = Color.red;
}
PassiveButton passiveButton = meetingExtraButton.GetComponent<PassiveButton>();
passiveButton.OnClick.RemoveAllListeners();
- if (!CachedPlayer.LocalPlayer.Data.IsDead) {
+ if (!PlayerControl.LocalPlayer.Data.IsDead) {
if (addSwapperButtons)
passiveButton.OnClick.AddListener((Action)(() => swapperConfirm(__instance)));
else if (addMayorButton)
}
- bool isGuesser = HandleGuesser.isGuesser(CachedPlayer.LocalPlayer.PlayerId);
+ bool isGuesser = HandleGuesser.isGuesser(PlayerControl.LocalPlayer.PlayerId);
// Add overlay for spelled players
if (Witch.witch != null && Witch.futureSpelled != null) {
rend.transform.SetParent(pva.transform);
rend.gameObject.layer = pva.Megaphone.gameObject.layer;
rend.transform.localPosition = new Vector3(-0.5f, -0.03f, -1f);
- if (CachedPlayer.LocalPlayer.PlayerControl == Swapper.swapper && isGuesser) rend.transform.localPosition = new Vector3(-0.725f, -0.15f, -1f);
+ if (PlayerControl.LocalPlayer == Swapper.swapper && isGuesser) rend.transform.localPosition = new Vector3(-0.725f, -0.15f, -1f);
rend.sprite = Witch.getSpelledOverlaySprite();
}
}
}
// Add Guesser Buttons
- int remainingShots = HandleGuesser.remainingShots(CachedPlayer.LocalPlayer.PlayerId);
+ int remainingShots = HandleGuesser.remainingShots(PlayerControl.LocalPlayer.PlayerId);
+ var (playerCompleted, playerTotal) = TasksHandler.taskInfo(PlayerControl.LocalPlayer.Data);
- if (isGuesser && !CachedPlayer.LocalPlayer.Data.IsDead && remainingShots > 0) {
+ if (isGuesser && !PlayerControl.LocalPlayer.Data.IsDead && remainingShots > 0) {
for (int i = 0; i < __instance.playerStates.Length; i++) {
PlayerVoteArea playerVoteArea = __instance.playerStates[i];
- if (playerVoteArea.AmDead || playerVoteArea.TargetPlayerId == CachedPlayer.LocalPlayer.PlayerId) continue;
- if (CachedPlayer.LocalPlayer != null && CachedPlayer.LocalPlayer.PlayerControl == Eraser.eraser && Eraser.alreadyErased.Contains(playerVoteArea.TargetPlayerId)) continue;
+ if (playerVoteArea.AmDead || playerVoteArea.TargetPlayerId == PlayerControl.LocalPlayer.PlayerId) continue;
+ if (PlayerControl.LocalPlayer != null && PlayerControl.LocalPlayer == Eraser.eraser && Eraser.alreadyErased.Contains(playerVoteArea.TargetPlayerId)) continue;
+ if (PlayerControl.LocalPlayer != null && !Helpers.isEvil(PlayerControl.LocalPlayer) && playerCompleted < HandleGuesser.tasksToUnlock) continue;
GameObject template = playerVoteArea.Buttons.transform.Find("CancelButton").gameObject;
GameObject targetBox = UnityEngine.Object.Instantiate(template, playerVoteArea.transform);
roomId = (byte)roomTracker.LastRoom?.RoomId;
}
if (Snitch.snitch != null && roomTracker != null) {
- MessageWriter roomWriter = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.ShareRoom, Hazel.SendOption.Reliable, -1);
- roomWriter.Write(CachedPlayer.LocalPlayer.PlayerId);
+ MessageWriter roomWriter = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ShareRoom, Hazel.SendOption.Reliable, -1);
+ roomWriter.Write(PlayerControl.LocalPlayer.PlayerId);
roomWriter.Write(roomId);
AmongUsClient.Instance.FinishRpcImmediately(roomWriter);
}
// Resett Bait list
Bait.active = new Dictionary<DeadPlayer, float>();
// Save AntiTeleport position, if the player is able to move (i.e. not on a ladder or a gap thingy)
- if (CachedPlayer.LocalPlayer.PlayerPhysics.enabled && (CachedPlayer.LocalPlayer.PlayerControl.moveable || CachedPlayer.LocalPlayer.PlayerControl.inVent
+ if (PlayerControl.LocalPlayer.MyPhysics.enabled && (PlayerControl.LocalPlayer.moveable || PlayerControl.LocalPlayer.inVent
|| HudManagerStartPatch.hackerVitalsButton.isEffectActive || HudManagerStartPatch.hackerAdminTableButton.isEffectActive || HudManagerStartPatch.securityGuardCamButton.isEffectActive
- || Portal.isTeleporting && Portal.teleportedPlayers.Last().playerId == CachedPlayer.LocalPlayer.PlayerId)) {
- if (!CachedPlayer.LocalPlayer.PlayerControl.inMovingPlat)
- AntiTeleport.position = CachedPlayer.LocalPlayer.transform.position;
+ || Portal.isTeleporting && Portal.teleportedPlayers.Last().playerId == PlayerControl.LocalPlayer.PlayerId)) {
+ if (!PlayerControl.LocalPlayer.inMovingPlat)
+ AntiTeleport.position = PlayerControl.LocalPlayer.transform.position;
}
// Medium meeting start time
// Add Portal info into Portalmaker Chat:
- if (Portalmaker.portalmaker != null && (CachedPlayer.LocalPlayer.PlayerControl == Portalmaker.portalmaker || Helpers.shouldShowGhostInfo()) && !Portalmaker.portalmaker.Data.IsDead) {
+ if (Portalmaker.portalmaker != null && (PlayerControl.LocalPlayer == Portalmaker.portalmaker || Helpers.shouldShowGhostInfo()) && !Portalmaker.portalmaker.Data.IsDead) {
if (Portal.teleportedPlayers.Count > 0) {
string msg = "Portal Log:\n";
foreach (var entry in Portal.teleportedPlayers) {
}
// Add trapped Info into Trapper chat
- if (Trapper.trapper != null && (CachedPlayer.LocalPlayer.PlayerControl == Trapper.trapper || Helpers.shouldShowGhostInfo()) && !Trapper.trapper.Data.IsDead) {
+ if (Trapper.trapper != null && (PlayerControl.LocalPlayer == Trapper.trapper || Helpers.shouldShowGhostInfo()) && !Trapper.trapper.Data.IsDead) {
if (Trap.traps.Any(x => x.revealed))
FastDestroyableSingleton<HudManager>.Instance.Chat.AddChat(Trapper.trapper, "Trap Logs:");
foreach (Trap trap in Trap.traps) {
// Add Snitch info
string output = "";
- if (Snitch.snitch != null && Snitch.mode != Snitch.Mode.Map && (CachedPlayer.LocalPlayer.PlayerControl == Snitch.snitch || Helpers.shouldShowGhostInfo()) && !Snitch.snitch.Data.IsDead) {
+ if (Snitch.snitch != null && Snitch.mode != Snitch.Mode.Map && (PlayerControl.LocalPlayer == Snitch.snitch || Helpers.shouldShowGhostInfo()) && !Snitch.snitch.Data.IsDead) {
var (playerCompleted, playerTotal) = TasksHandler.taskInfo(Snitch.snitch.Data);
int numberOfTasks = playerTotal - playerCompleted;
if (numberOfTasks == 0) {
output = $"Bad alive roles in game: \n \n";
FastDestroyableSingleton<HudManager>.Instance.StartCoroutine(Effects.Lerp(0.4f, new Action<float>((x) => {
if (x == 1f) {
- foreach (PlayerControl p in CachedPlayer.AllPlayers) {
+ foreach (PlayerControl p in PlayerControl.AllPlayerControls) {
if (Snitch.targets == Snitch.Targets.Killers && !Helpers.isKiller(p)) continue;
if (Snitch.targets == Snitch.Targets.EvilPlayers && !Helpers.isEvil(p)) continue;
if (!Snitch.playerRoomMap.ContainsKey(p.PlayerId)) continue;
}
}
- if (CachedPlayer.LocalPlayer.Data.IsDead && output != "") FastDestroyableSingleton<HudManager>.Instance.Chat.AddChat(CachedPlayer.LocalPlayer, $"{output}");
+ if (PlayerControl.LocalPlayer.Data.IsDead && output != "") FastDestroyableSingleton<HudManager>.Instance.Chat.AddChat(PlayerControl.LocalPlayer, $"{output}");
Trapper.playersOnMap = new List<PlayerControl>();
Snitch.playerRoomMap = new Dictionary<byte, byte>();
using static TheOtherRoles.TheOtherRoles;
using static TheOtherRoles.GameHistory;
using TheOtherRoles.Objects;
-using TheOtherRoles.Players;
+
using TheOtherRoles.Utilities;
using UnityEngine;
using TheOtherRoles.CustomGameModes;
PlayerControl result = null;
float num = AmongUs.GameOptions.GameOptionsData.KillDistances[Mathf.Clamp(GameOptionsManager.Instance.currentNormalGameOptions.KillDistance, 0, 2)];
if (!MapUtilities.CachedShipStatus) return result;
- if (targetingPlayer == null) targetingPlayer = CachedPlayer.LocalPlayer.PlayerControl;
+ if (targetingPlayer == null) targetingPlayer = PlayerControl.LocalPlayer;
if (targetingPlayer.Data.IsDead) return result;
Vector2 truePosition = targetingPlayer.GetTruePosition();
// Update functions
static void setBasePlayerOutlines() {
- foreach (PlayerControl target in CachedPlayer.AllPlayers) {
+ foreach (PlayerControl target in PlayerControl.AllPlayerControls) {
if (target == null || target.cosmetics?.currentBodySprite?.BodySprite == null) continue;
bool isMorphedMorphling = target == Morphling.morphling && Morphling.morphTarget != null && Morphling.morphTimer > 0f;
color = Color.blue;
}
+ if (PlayerControl.LocalPlayer.Data.IsDead && Armored.armored != null && target == Armored.armored && !Armored.isBrokenArmor && !hasVisibleShield) {
+ hasVisibleShield = true;
+ color = Color.yellow;
+ }
+
if (hasVisibleShield) {
target.cosmetics.currentBodySprite.BodySprite.material.SetFloat("_Outline", 1f);
target.cosmetics.currentBodySprite.BodySprite.material.SetColor("_OutlineColor", color);
}
else {
target.cosmetics.currentBodySprite.BodySprite.material.SetFloat("_Outline", 0f);
- }
+ }
}
}
static void setPetVisibility() {
- bool localalive = !CachedPlayer.LocalPlayer.Data.IsDead;
- foreach (var player in CachedPlayer.AllPlayers)
+ bool localalive = PlayerControl.LocalPlayer.Data.IsDead;
+ foreach (var player in PlayerControl.AllPlayerControls)
{
bool playeralive = !player.Data.IsDead;
- player.PlayerControl.cosmetics.SetPetVisible((localalive && playeralive) || !localalive);
+ player.cosmetics.SetPetVisible((localalive && playeralive) || !localalive);
}
}
var next = localPlayerPositions[0];
if (next.Item2 == true) {
// Exit current vent if necessary
- if (CachedPlayer.LocalPlayer.PlayerControl.inVent) {
+ if (PlayerControl.LocalPlayer.inVent) {
foreach (Vent vent in MapUtilities.CachedShipStatus.AllVents) {
bool canUse;
bool couldUse;
- vent.CanUse(CachedPlayer.LocalPlayer.Data, out canUse, out couldUse);
+ vent.CanUse(PlayerControl.LocalPlayer.Data, out canUse, out couldUse);
if (canUse) {
- CachedPlayer.LocalPlayer.PlayerPhysics.RpcExitVent(vent.Id);
+ PlayerControl.LocalPlayer.MyPhysics.RpcExitVent(vent.Id);
vent.SetButtons(false);
}
}
}
// Set position
- CachedPlayer.LocalPlayer.transform.position = next.Item1;
+ PlayerControl.LocalPlayer.transform.position = next.Item1;
}
else if (localPlayerPositions.Any(x => x.Item2 == true)) {
- CachedPlayer.LocalPlayer.transform.position = next.Item1;
+ PlayerControl.LocalPlayer.transform.position = next.Item1;
}
if (SubmergedCompatibility.IsSubmerged) {
SubmergedCompatibility.ChangeFloor(next.Item1.y > -7);
}
else {
TimeMaster.isRewinding = false;
- CachedPlayer.LocalPlayer.PlayerControl.moveable = true;
+ PlayerControl.LocalPlayer.moveable = true;
}
}
else {
while (localPlayerPositions.Count >= Mathf.Round(TimeMaster.rewindTime / Time.fixedDeltaTime)) localPlayerPositions.RemoveAt(localPlayerPositions.Count - 1);
- localPlayerPositions.Insert(0, new Tuple<Vector3, bool>(CachedPlayer.LocalPlayer.transform.position, CachedPlayer.LocalPlayer.PlayerControl.CanMove)); // CanMove = CanMove
+ localPlayerPositions.Insert(0, new Tuple<Vector3, bool>(PlayerControl.LocalPlayer.transform.position, PlayerControl.LocalPlayer.CanMove)); // CanMove = CanMove
}
}
static void medicSetTarget() {
- if (Medic.medic == null || Medic.medic != CachedPlayer.LocalPlayer.PlayerControl) return;
+ if (Medic.medic == null || Medic.medic != PlayerControl.LocalPlayer) return;
Medic.currentTarget = setTarget();
if (!Medic.usedShield) setPlayerOutline(Medic.currentTarget, Medic.shieldedColor);
}
static void shifterSetTarget() {
- if (Shifter.shifter == null || Shifter.shifter != CachedPlayer.LocalPlayer.PlayerControl) return;
+ if (Shifter.shifter == null || Shifter.shifter != PlayerControl.LocalPlayer) return;
Shifter.currentTarget = setTarget();
if (Shifter.futureShift == null) setPlayerOutline(Shifter.currentTarget, Color.yellow);
}
static void morphlingSetTarget() {
- if (Morphling.morphling == null || Morphling.morphling != CachedPlayer.LocalPlayer.PlayerControl) return;
+ if (Morphling.morphling == null || Morphling.morphling != PlayerControl.LocalPlayer) return;
Morphling.currentTarget = setTarget();
setPlayerOutline(Morphling.currentTarget, Morphling.color);
}
static void sheriffSetTarget() {
- if (Sheriff.sheriff == null || Sheriff.sheriff != CachedPlayer.LocalPlayer.PlayerControl) return;
+ if (Sheriff.sheriff == null || Sheriff.sheriff != PlayerControl.LocalPlayer) return;
Sheriff.currentTarget = setTarget();
setPlayerOutline(Sheriff.currentTarget, Sheriff.color);
}
static void deputySetTarget()
{
- if (Deputy.deputy == null || Deputy.deputy != CachedPlayer.LocalPlayer.PlayerControl) return;
+ if (Deputy.deputy == null || Deputy.deputy != PlayerControl.LocalPlayer) return;
Deputy.currentTarget = setTarget();
setPlayerOutline(Deputy.currentTarget, Deputy.color);
}
public static void deputyCheckPromotion(bool isMeeting=false)
{
// If LocalPlayer is Deputy, the Sheriff is disconnected and Deputy promotion is enabled, then trigger promotion
- if (Deputy.deputy == null || Deputy.deputy != CachedPlayer.LocalPlayer.PlayerControl) return;
+ if (Deputy.deputy == null || Deputy.deputy != PlayerControl.LocalPlayer) return;
if (Deputy.promotesToSheriff == 0 || Deputy.deputy.Data.IsDead == true || Deputy.promotesToSheriff == 2 && !isMeeting) return;
if (Sheriff.sheriff == null || Sheriff.sheriff?.Data?.Disconnected == true || Sheriff.sheriff.Data.IsDead)
{
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.DeputyPromotes, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.DeputyPromotes, Hazel.SendOption.Reliable, -1);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCProcedure.deputyPromotes();
}
}
static void trackerSetTarget() {
- if (Tracker.tracker == null || Tracker.tracker != CachedPlayer.LocalPlayer.PlayerControl) return;
+ if (Tracker.tracker == null || Tracker.tracker != PlayerControl.LocalPlayer) return;
Tracker.currentTarget = setTarget();
if (!Tracker.usedTracker) setPlayerOutline(Tracker.currentTarget, Tracker.color);
}
static void detectiveUpdateFootPrints() {
- if (Detective.detective == null || Detective.detective != CachedPlayer.LocalPlayer.PlayerControl) return;
+ if (Detective.detective == null || Detective.detective != PlayerControl.LocalPlayer) return;
Detective.timer -= Time.fixedDeltaTime;
if (Detective.timer <= 0f) {
Detective.timer = Detective.footprintIntervall;
- foreach (PlayerControl player in CachedPlayer.AllPlayers) {
- if (player != null && player != CachedPlayer.LocalPlayer.PlayerControl && !player.Data.IsDead && !player.inVent)
+ foreach (PlayerControl player in PlayerControl.AllPlayerControls) {
+ if (player != null && player != PlayerControl.LocalPlayer && !player.Data.IsDead && !player.inVent)
{
FootprintHolder.Instance.MakeFootprint(player);
}
}
static void vampireSetTarget() {
- if (Vampire.vampire == null || Vampire.vampire != CachedPlayer.LocalPlayer.PlayerControl) return;
+ if (Vampire.vampire == null || Vampire.vampire != PlayerControl.LocalPlayer) return;
PlayerControl target = null;
if (Spy.spy != null || Sidekick.wasSpy || Jackal.wasSpy) {
}
static void jackalSetTarget() {
- if (Jackal.jackal == null || Jackal.jackal != CachedPlayer.LocalPlayer.PlayerControl) return;
+ if (Jackal.jackal == null || Jackal.jackal != PlayerControl.LocalPlayer) return;
var untargetablePlayers = new List<PlayerControl>();
if (Jackal.canCreateSidekickFromImpostor) {
// Only exclude sidekick from beeing targeted if the jackal can create sidekicks from impostors
}
static void sidekickSetTarget() {
- if (Sidekick.sidekick == null || Sidekick.sidekick != CachedPlayer.LocalPlayer.PlayerControl) return;
+ if (Sidekick.sidekick == null || Sidekick.sidekick != PlayerControl.LocalPlayer) return;
var untargetablePlayers = new List<PlayerControl>();
if (Jackal.jackal != null) untargetablePlayers.Add(Jackal.jackal);
if (Mini.mini != null && !Mini.isGrownUp()) untargetablePlayers.Add(Mini.mini); // Exclude Sidekick from targeting the Mini unless it has grown up
static void sidekickCheckPromotion() {
// If LocalPlayer is Sidekick, the Jackal is disconnected and Sidekick promotion is enabled, then trigger promotion
- if (Sidekick.sidekick == null || Sidekick.sidekick != CachedPlayer.LocalPlayer.PlayerControl) return;
+ if (Sidekick.sidekick == null || Sidekick.sidekick != PlayerControl.LocalPlayer) return;
if (Sidekick.sidekick.Data.IsDead == true || !Sidekick.promotesToJackal) return;
if (Jackal.jackal == null || Jackal.jackal?.Data?.Disconnected == true) {
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.SidekickPromotes, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SidekickPromotes, Hazel.SendOption.Reliable, -1);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCProcedure.sidekickPromotes();
}
}
static void eraserSetTarget() {
- if (Eraser.eraser == null || Eraser.eraser != CachedPlayer.LocalPlayer.PlayerControl) return;
+ if (Eraser.eraser == null || Eraser.eraser != PlayerControl.LocalPlayer) return;
List<PlayerControl> untargetables = new List<PlayerControl>();
if (Spy.spy != null) untargetables.Add(Spy.spy);
static void deputyUpdate()
{
- if (CachedPlayer.LocalPlayer.PlayerControl == null || !Deputy.handcuffedKnows.ContainsKey(CachedPlayer.LocalPlayer.PlayerId)) return;
+ if (PlayerControl.LocalPlayer == null || !Deputy.handcuffedKnows.ContainsKey(PlayerControl.LocalPlayer.PlayerId)) return;
- if (Deputy.handcuffedKnows[CachedPlayer.LocalPlayer.PlayerId] <= 0)
+ if (Deputy.handcuffedKnows[PlayerControl.LocalPlayer.PlayerId] <= 0)
{
- Deputy.handcuffedKnows.Remove(CachedPlayer.LocalPlayer.PlayerId);
+ Deputy.handcuffedKnows.Remove(PlayerControl.LocalPlayer.PlayerId);
// Resets the buttons
Deputy.setHandcuffedKnows(false);
// Ghost info
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.ShareGhostInfo, Hazel.SendOption.Reliable, -1);
- writer.Write(CachedPlayer.LocalPlayer.PlayerId);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ShareGhostInfo, Hazel.SendOption.Reliable, -1);
+ writer.Write(PlayerControl.LocalPlayer.PlayerId);
writer.Write((byte)RPCProcedure.GhostInfoTypes.HandcuffOver);
AmongUsClient.Instance.FinishRpcImmediately(writer);
}
}
static void engineerUpdate() {
- bool jackalHighlight = Engineer.highlightForTeamJackal && (CachedPlayer.LocalPlayer.PlayerControl == Jackal.jackal || CachedPlayer.LocalPlayer.PlayerControl == Sidekick.sidekick);
- bool impostorHighlight = Engineer.highlightForImpostors && CachedPlayer.LocalPlayer.Data.Role.IsImpostor;
+ bool jackalHighlight = Engineer.highlightForTeamJackal && (PlayerControl.LocalPlayer == Jackal.jackal || PlayerControl.LocalPlayer == Sidekick.sidekick);
+ bool impostorHighlight = Engineer.highlightForImpostors && PlayerControl.LocalPlayer.Data.Role.IsImpostor;
if ((jackalHighlight || impostorHighlight) && MapUtilities.CachedShipStatus?.AllVents != null) {
foreach (Vent vent in MapUtilities.CachedShipStatus.AllVents) {
try {
}
static void impostorSetTarget() {
- if (!CachedPlayer.LocalPlayer.Data.Role.IsImpostor ||!CachedPlayer.LocalPlayer.PlayerControl.CanMove || CachedPlayer.LocalPlayer.Data.IsDead) { // !isImpostor || !canMove || isDead
+ if (!PlayerControl.LocalPlayer.Data.Role.IsImpostor ||!PlayerControl.LocalPlayer.CanMove || PlayerControl.LocalPlayer.Data.IsDead) { // !isImpostor || !canMove || isDead
FastDestroyableSingleton<HudManager>.Instance.KillButton.SetTarget(null);
return;
}
}
static void warlockSetTarget() {
- if (Warlock.warlock == null || Warlock.warlock != CachedPlayer.LocalPlayer.PlayerControl) return;
+ if (Warlock.warlock == null || Warlock.warlock != PlayerControl.LocalPlayer) return;
if (Warlock.curseVictim != null && (Warlock.curseVictim.Data.Disconnected || Warlock.curseVictim.Data.IsDead)) {
// If the cursed victim is disconnected or dead reset the curse so a new curse can be applied
Warlock.resetCurse();
static void ninjaUpdate()
{
- if (Ninja.isInvisble && Ninja.invisibleTimer <= 0 && Ninja.ninja == CachedPlayer.LocalPlayer.PlayerControl)
+ if (Ninja.isInvisble && Ninja.invisibleTimer <= 0 && Ninja.ninja == PlayerControl.LocalPlayer)
{
- MessageWriter invisibleWriter = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.SetInvisible, Hazel.SendOption.Reliable, -1);
+ MessageWriter invisibleWriter = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetInvisible, Hazel.SendOption.Reliable, -1);
invisibleWriter.Write(Ninja.ninja.PlayerId);
invisibleWriter.Write(byte.MaxValue);
AmongUsClient.Instance.FinishRpcImmediately(invisibleWriter);
}
if (Ninja.arrow?.arrow != null)
{
- if (Ninja.ninja == null || Ninja.ninja != CachedPlayer.LocalPlayer.PlayerControl || !Ninja.knowsTargetLocation) {
+ if (Ninja.ninja == null || Ninja.ninja != PlayerControl.LocalPlayer || !Ninja.knowsTargetLocation) {
Ninja.arrow.arrow.SetActive(false);
return;
}
- if (Ninja.ninjaMarked != null && !CachedPlayer.LocalPlayer.Data.IsDead)
+ if (Ninja.ninjaMarked != null && !PlayerControl.LocalPlayer.Data.IsDead)
{
bool trackedOnMap = !Ninja.ninjaMarked.Data.IsDead;
Vector3 position = Ninja.ninjaMarked.transform.position;
static void trackerUpdate() {
// Handle player tracking
if (Tracker.arrow?.arrow != null) {
- if (Tracker.tracker == null || CachedPlayer.LocalPlayer.PlayerControl != Tracker.tracker) {
+ if (Tracker.tracker == null || PlayerControl.LocalPlayer != Tracker.tracker) {
Tracker.arrow.arrow.SetActive(false);
if (Tracker.DangerMeterParent) Tracker.DangerMeterParent.SetActive(false);
return;
}
// Handle corpses tracking
- if (Tracker.tracker != null && Tracker.tracker == CachedPlayer.LocalPlayer.PlayerControl && Tracker.corpsesTrackingTimer >= 0f && !Tracker.tracker.Data.IsDead) {
+ if (Tracker.tracker != null && Tracker.tracker == PlayerControl.LocalPlayer && Tracker.corpsesTrackingTimer >= 0f && !Tracker.tracker.Data.IsDead) {
bool arrowsCountChanged = Tracker.localArrows.Count != Tracker.deadBodyPositions.Count();
int index = 0;
public static void updatePlayerInfo() {
Vector3 colorBlindTextMeetingInitialLocalPos = new Vector3(0.3384f, -0.16666f, -0.01f);
Vector3 colorBlindTextMeetingInitialLocalScale = new Vector3(0.9f, 1f, 1f);
- foreach (PlayerControl p in CachedPlayer.AllPlayers) {
+ foreach (PlayerControl p in PlayerControl.AllPlayerControls) {
// Colorblind Text in Meeting
PlayerVoteArea playerVoteArea = MeetingHud.Instance?.playerStates?.FirstOrDefault(x => x.TargetPlayerId == p.PlayerId);
p.cosmetics.nameText.transform.parent.SetLocalZ(-0.0001f); // This moves both the name AND the colorblindtext behind objects (if the player is behind the object), like the rock on polus
- if ((Lawyer.lawyerKnowsRole && CachedPlayer.LocalPlayer.PlayerControl == Lawyer.lawyer && p == Lawyer.target) || p == CachedPlayer.LocalPlayer.PlayerControl || CachedPlayer.LocalPlayer.Data.IsDead) {
+ if ((Lawyer.lawyerKnowsRole && PlayerControl.LocalPlayer == Lawyer.lawyer && p == Lawyer.target) || p == PlayerControl.LocalPlayer || PlayerControl.LocalPlayer.Data.IsDead) {
Transform playerInfoTransform = p.cosmetics.nameText.transform.parent.FindChild("Info");
TMPro.TextMeshPro playerInfo = playerInfoTransform != null ? playerInfoTransform.GetComponent<TMPro.TextMeshPro>() : null;
if (playerInfo == null) {
string playerInfoText = "";
string meetingInfoText = "";
- if (p == CachedPlayer.LocalPlayer.PlayerControl) {
+ if (p == PlayerControl.LocalPlayer) {
if (p.Data.IsDead) roleNames = roleText;
playerInfoText = $"{roleNames}";
if (p == Swapper.swapper) playerInfoText = $"{roleNames}" + Helpers.cs(Swapper.color, $" ({Swapper.charges})");
playerInfoText = $"{taskInfo}".Trim();
meetingInfoText = playerInfoText;
}
- else if (TORMapOptions.ghostsSeeRoles || (Lawyer.lawyerKnowsRole && CachedPlayer.LocalPlayer.PlayerControl == Lawyer.lawyer && p == Lawyer.target)) {
+ else if (TORMapOptions.ghostsSeeRoles || (Lawyer.lawyerKnowsRole && PlayerControl.LocalPlayer == Lawyer.lawyer && p == Lawyer.target)) {
playerInfoText = $"{roleText}";
meetingInfoText = playerInfoText;
}
}
public static void securityGuardSetTarget() {
- if (SecurityGuard.securityGuard == null || SecurityGuard.securityGuard != CachedPlayer.LocalPlayer.PlayerControl || MapUtilities.CachedShipStatus == null || MapUtilities.CachedShipStatus.AllVents == null) return;
+ if (SecurityGuard.securityGuard == null || SecurityGuard.securityGuard != PlayerControl.LocalPlayer || MapUtilities.CachedShipStatus == null || MapUtilities.CachedShipStatus.AllVents == null) return;
Vent target = null;
- Vector2 truePosition = CachedPlayer.LocalPlayer.PlayerControl.GetTruePosition();
+ Vector2 truePosition = PlayerControl.LocalPlayer.GetTruePosition();
float closestDistance = float.MaxValue;
for (int i = 0; i < MapUtilities.CachedShipStatus.AllVents.Length; i++) {
Vent vent = MapUtilities.CachedShipStatus.AllVents[i];
}
public static void securityGuardUpdate() {
- if (SecurityGuard.securityGuard == null || CachedPlayer.LocalPlayer.PlayerControl != SecurityGuard.securityGuard || SecurityGuard.securityGuard.Data.IsDead) return;
+ if (SecurityGuard.securityGuard == null || PlayerControl.LocalPlayer != SecurityGuard.securityGuard || SecurityGuard.securityGuard.Data.IsDead) return;
var (playerCompleted, _) = TasksHandler.taskInfo(SecurityGuard.securityGuard.Data);
if (playerCompleted == SecurityGuard.rechargedTasks) {
SecurityGuard.rechargedTasks += SecurityGuard.rechargeTasksNumber;
}
public static void arsonistSetTarget() {
- if (Arsonist.arsonist == null || Arsonist.arsonist != CachedPlayer.LocalPlayer.PlayerControl) return;
+ if (Arsonist.arsonist == null || Arsonist.arsonist != PlayerControl.LocalPlayer) return;
List<PlayerControl> untargetables;
if (Arsonist.douseTarget != null)
{
untargetables = new();
- foreach (CachedPlayer cachedPlayer in CachedPlayer.AllPlayers)
+ foreach (PlayerControl player in PlayerControl.AllPlayerControls)
{
- if (cachedPlayer.PlayerId != Arsonist.douseTarget.PlayerId)
+ if (player.PlayerId != Arsonist.douseTarget.PlayerId)
{
- untargetables.Add(cachedPlayer);
+ untargetables.Add(player);
}
}
}
var (playerCompleted, playerTotal) = TasksHandler.taskInfo(Snitch.snitch.Data);
if (playerTotal == 0) return;
- PlayerControl local = CachedPlayer.LocalPlayer.PlayerControl;
+ PlayerControl local = PlayerControl.LocalPlayer;
int numberOfTasks = playerTotal - playerCompleted;
}
static void bountyHunterUpdate() {
- if (BountyHunter.bountyHunter == null || CachedPlayer.LocalPlayer.PlayerControl != BountyHunter.bountyHunter) return;
+ if (BountyHunter.bountyHunter == null || PlayerControl.LocalPlayer != BountyHunter.bountyHunter) return;
if (BountyHunter.bountyHunter.Data.IsDead) {
if (BountyHunter.arrow != null || BountyHunter.arrow.arrow != null) UnityEngine.Object.Destroy(BountyHunter.arrow.arrow);
BountyHunter.arrowUpdateTimer = 0f; // Force arrow to update
BountyHunter.bountyUpdateTimer = BountyHunter.bountyDuration;
var possibleTargets = new List<PlayerControl>();
- foreach (PlayerControl p in CachedPlayer.AllPlayers) {
+ foreach (PlayerControl p in PlayerControl.AllPlayerControls) {
if (!p.Data.IsDead && !p.Data.Disconnected && p != p.Data.Role.IsImpostor && p != Spy.spy && (p != Sidekick.sidekick || !Sidekick.wasTeamRed) && (p != Jackal.jackal || !Jackal.wasTeamRed) && (p != Mini.mini || Mini.isGrownUp()) && (Lovers.getPartner(BountyHunter.bountyHunter) == null || p != Lovers.getPartner(BountyHunter.bountyHunter))) possibleTargets.Add(p);
}
BountyHunter.bounty = possibleTargets[TheOtherRoles.rnd.Next(0, possibleTargets.Count)];
if (BountyHunter.bounty == null) return;
// Ghost Info
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.ShareGhostInfo, Hazel.SendOption.Reliable, -1);
- writer.Write(CachedPlayer.LocalPlayer.PlayerId);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ShareGhostInfo, Hazel.SendOption.Reliable, -1);
+ writer.Write(PlayerControl.LocalPlayer.PlayerId);
writer.Write((byte)RPCProcedure.GhostInfoTypes.BountyTarget);
writer.Write(BountyHunter.bounty.PlayerId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
}
static void vultureUpdate() {
- if (Vulture.vulture == null || CachedPlayer.LocalPlayer.PlayerControl != Vulture.vulture || Vulture.localArrows == null || !Vulture.showArrows) return;
+ if (Vulture.vulture == null || PlayerControl.LocalPlayer != Vulture.vulture || Vulture.localArrows == null || !Vulture.showArrows) return;
if (Vulture.vulture.Data.IsDead) {
foreach (Arrow arrow in Vulture.localArrows) UnityEngine.Object.Destroy(arrow.arrow);
Vulture.localArrows = new List<Arrow>();
}
public static void mediumSetTarget() {
- if (Medium.medium == null || Medium.medium != CachedPlayer.LocalPlayer.PlayerControl || Medium.medium.Data.IsDead || Medium.deadBodies == null || MapUtilities.CachedShipStatus?.AllVents == null) return;
+ if (Medium.medium == null || Medium.medium != PlayerControl.LocalPlayer || Medium.medium.Data.IsDead || Medium.deadBodies == null || MapUtilities.CachedShipStatus?.AllVents == null) return;
DeadPlayer target = null;
- Vector2 truePosition = CachedPlayer.LocalPlayer.PlayerControl.GetTruePosition();
+ Vector2 truePosition = PlayerControl.LocalPlayer.GetTruePosition();
float closestDistance = float.MaxValue;
float usableDistance = MapUtilities.CachedShipStatus.AllVents.FirstOrDefault().UsableDistance;
foreach ((DeadPlayer dp, Vector3 ps) in Medium.deadBodies) {
Morphling.morphling.setLook(target.Data.PlayerName, target.Data.DefaultOutfit.ColorId, target.Data.DefaultOutfit.HatId, target.Data.DefaultOutfit.VisorId, target.Data.DefaultOutfit.SkinId, target.Data.DefaultOutfit.PetId);
}
if (Camouflager.camouflageTimer > 0) {
- foreach (PlayerControl player in CachedPlayer.AllPlayers)
+ foreach (PlayerControl player in PlayerControl.AllPlayerControls)
player.setLook("", 6, "", "", "", "");
}
}
}
public static void lawyerUpdate() {
- if (Lawyer.lawyer == null || Lawyer.lawyer != CachedPlayer.LocalPlayer.PlayerControl) return;
+ if (Lawyer.lawyer == null || Lawyer.lawyer != PlayerControl.LocalPlayer) return;
// Promote to Pursuer
if (Lawyer.target != null && Lawyer.target.Data.Disconnected && !Lawyer.lawyer.Data.IsDead) {
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.LawyerPromotesToPursuer, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.LawyerPromotesToPursuer, Hazel.SendOption.Reliable, -1);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCProcedure.lawyerPromotesToPursuer();
return;
}
public static void hackerUpdate() {
- if (Hacker.hacker == null || CachedPlayer.LocalPlayer.PlayerControl != Hacker.hacker || Hacker.hacker.Data.IsDead) return;
+ if (Hacker.hacker == null || PlayerControl.LocalPlayer != Hacker.hacker || Hacker.hacker.Data.IsDead) return;
var (playerCompleted, _) = TasksHandler.taskInfo(Hacker.hacker.Data);
if (playerCompleted == Hacker.rechargedTasks) {
Hacker.rechargedTasks += Hacker.rechargeTasksNumber;
// For swapper swap charges
public static void swapperUpdate() {
- if (Swapper.swapper == null || CachedPlayer.LocalPlayer.PlayerControl != Swapper.swapper || CachedPlayer.LocalPlayer.Data.IsDead) return;
- var (playerCompleted, _) = TasksHandler.taskInfo(CachedPlayer.LocalPlayer.Data);
+ if (Swapper.swapper == null || PlayerControl.LocalPlayer != Swapper.swapper || PlayerControl.LocalPlayer.Data.IsDead) return;
+ var (playerCompleted, _) = TasksHandler.taskInfo(PlayerControl.LocalPlayer.Data);
if (playerCompleted == Swapper.rechargedTasks) {
Swapper.rechargedTasks += Swapper.rechargeTasksNumber;
Swapper.charges++;
}
static void pursuerSetTarget() {
- if (Pursuer.pursuer == null || Pursuer.pursuer != CachedPlayer.LocalPlayer.PlayerControl) return;
+ if (Pursuer.pursuer == null || Pursuer.pursuer != PlayerControl.LocalPlayer) return;
Pursuer.target = setTarget();
setPlayerOutline(Pursuer.target, Pursuer.color);
}
static void witchSetTarget() {
- if (Witch.witch == null || Witch.witch != CachedPlayer.LocalPlayer.PlayerControl) return;
+ if (Witch.witch == null || Witch.witch != PlayerControl.LocalPlayer) return;
List<PlayerControl> untargetables;
if (Witch.spellCastingTarget != null)
untargetables = PlayerControl.AllPlayerControls.ToArray().Where(x => x.PlayerId != Witch.spellCastingTarget.PlayerId).ToList(); // Don't switch the target from the the one you're currently casting a spell on
static void ninjaSetTarget()
{
- if (Ninja.ninja == null || Ninja.ninja != CachedPlayer.LocalPlayer.PlayerControl) return;
+ if (Ninja.ninja == null || Ninja.ninja != PlayerControl.LocalPlayer) return;
List<PlayerControl> untargetables = new List<PlayerControl>();
if (Spy.spy != null && !Spy.impostorsCanKillAnyone) untargetables.Add(Spy.spy);
if (Mini.mini != null && !Mini.isGrownUp()) untargetables.Add(Mini.mini);
}
static void thiefSetTarget() {
- if (Thief.thief == null || Thief.thief != CachedPlayer.LocalPlayer.PlayerControl) return;
+ if (Thief.thief == null || Thief.thief != PlayerControl.LocalPlayer) return;
List<PlayerControl> untargetables = new List<PlayerControl>();
if (Mini.mini != null && !Mini.isGrownUp()) untargetables.Add(Mini.mini);
Thief.currentTarget = setTarget(onlyCrewmates: false, untargetablePlayers: untargetables);
Bait.active[entry.Key] = entry.Value - Time.fixedDeltaTime;
if (entry.Value <= 0) {
Bait.active.Remove(entry.Key);
- if (entry.Key.killerIfExisting != null && entry.Key.killerIfExisting.PlayerId == CachedPlayer.LocalPlayer.PlayerId) {
+ if (entry.Key.killerIfExisting != null && entry.Key.killerIfExisting.PlayerId == PlayerControl.LocalPlayer.PlayerId) {
Helpers.handleVampireBiteOnBodyReport(); // 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);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.UncheckedCmdReportDeadBody, Hazel.SendOption.Reliable, -1);
writer.Write(entry.Key.killerIfExisting.PlayerId);
writer.Write(entry.Key.player.PlayerId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
// Mini set adapted button cooldown for Vampire, Sheriff, Jackal, Sidekick, Warlock, Cleaner
public static void miniCooldownUpdate() {
- if (Mini.mini != null && CachedPlayer.LocalPlayer.PlayerControl == Mini.mini) {
+ if (Mini.mini != null && PlayerControl.LocalPlayer == Mini.mini) {
var multiplier = Mini.isGrownUp() ? 0.66f : 2f;
HudManagerStartPatch.sheriffKillButton.MaxTimer = Sheriff.cooldown * multiplier;
HudManagerStartPatch.vampireKillButton.MaxTimer = Vampire.cooldown * multiplier;
}
public static void trapperUpdate() {
- if (Trapper.trapper == null || CachedPlayer.LocalPlayer.PlayerControl != Trapper.trapper || Trapper.trapper.Data.IsDead) return;
+ if (Trapper.trapper == null || PlayerControl.LocalPlayer != Trapper.trapper || Trapper.trapper.Data.IsDead) return;
var (playerCompleted, _) = TasksHandler.taskInfo(Trapper.trapper.Data);
if (playerCompleted == Trapper.rechargedTasks) {
Trapper.rechargedTasks += Trapper.rechargeTasksNumber;
}
}
if (HideNSeek.isHunted() && !Hunted.taskPunish && !HideNSeek.isWaitingTimer) {
- var (playerCompleted, playerTotal) = TasksHandler.taskInfo(CachedPlayer.LocalPlayer.Data);
+ var (playerCompleted, playerTotal) = TasksHandler.taskInfo(PlayerControl.LocalPlayer.Data);
int numberOfTasks = playerTotal - playerCompleted;
if (numberOfTasks == 0) {
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.ShareTimer, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ShareTimer, Hazel.SendOption.Reliable, -1);
writer.Write(HideNSeek.taskPunish);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCProcedure.shareTimer(HideNSeek.taskPunish);
if (!HideNSeek.isHunter()) return;
- byte playerId = CachedPlayer.LocalPlayer.PlayerId;
+ byte playerId = PlayerControl.LocalPlayer.PlayerId;
foreach (Arrow arrow in Hunter.localArrows) arrow.arrow.SetActive(false);
if (Hunter.arrowActive) {
int arrowIndex = 0;
- foreach (PlayerControl p in CachedPlayer.AllPlayers) {
+ foreach (PlayerControl p in PlayerControl.AllPlayerControls) {
if (!p.Data.IsDead && !p.Data.Role.IsImpostor) {
if (arrowIndex >= Hunter.localArrows.Count) {
Hunter.localArrows.Add(new Arrow(Color.blue));
//pc.cosmetics.colorBlindText.gameObject.transform.localPosition = new Vector3(0, 0, -0.0001f);
}
- if (CachedPlayer.LocalPlayer.PlayerControl == __instance) {
+ if (PlayerControl.LocalPlayer == __instance) {
// Update player outlines
setBasePlayerOutlines();
}
}
- [HarmonyPatch(typeof(PlayerControl), nameof(CachedPlayer.LocalPlayer.PlayerControl.CmdReportDeadBody))]
+ [HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.LocalPlayer.CmdReportDeadBody))]
class BodyReportPatch
{
static void Postfix(PlayerControl __instance, [HarmonyArgument(0)]NetworkedPlayerInfo target)
{
// Medic or Detective report
- bool isMedicReport = Medic.medic != null && Medic.medic == CachedPlayer.LocalPlayer.PlayerControl && __instance.PlayerId == Medic.medic.PlayerId;
- bool isDetectiveReport = Detective.detective != null && Detective.detective == CachedPlayer.LocalPlayer.PlayerControl && __instance.PlayerId == Detective.detective.PlayerId;
+ bool isMedicReport = Medic.medic != null && Medic.medic == PlayerControl.LocalPlayer && __instance.PlayerId == Medic.medic.PlayerId;
+ bool isDetectiveReport = Detective.detective != null && Detective.detective == PlayerControl.LocalPlayer && __instance.PlayerId == Detective.detective.PlayerId;
if (isMedicReport || isDetectiveReport)
{
DeadPlayer deadPlayer = deadPlayers?.Where(x => x.player?.PlayerId == target?.PlayerId)?.FirstOrDefault();
{
if (AmongUsClient.Instance.AmClient && FastDestroyableSingleton<HudManager>.Instance)
{
- FastDestroyableSingleton<HudManager>.Instance.Chat.AddChat(CachedPlayer.LocalPlayer.PlayerControl, msg);
+ FastDestroyableSingleton<HudManager>.Instance.Chat.AddChat(PlayerControl.LocalPlayer, msg);
// Ghost Info
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.ShareGhostInfo, Hazel.SendOption.Reliable, -1);
- writer.Write(CachedPlayer.LocalPlayer.PlayerId);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ShareGhostInfo, Hazel.SendOption.Reliable, -1);
+ writer.Write(PlayerControl.LocalPlayer.PlayerId);
writer.Write((byte)RPCProcedure.GhostInfoTypes.DetectiveOrMedicInfo);
writer.Write(msg);
AmongUsClient.Instance.FinishRpcImmediately(writer);
}
// Sidekick promotion trigger on murder
- if (Sidekick.promotesToJackal && Sidekick.sidekick != null && !Sidekick.sidekick.Data.IsDead && target == Jackal.jackal && Jackal.jackal == CachedPlayer.LocalPlayer.PlayerControl) {
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.SidekickPromotes, Hazel.SendOption.Reliable, -1);
+ if (Sidekick.promotesToJackal && Sidekick.sidekick != null && !Sidekick.sidekick.Data.IsDead && target == Jackal.jackal && Jackal.jackal == PlayerControl.LocalPlayer) {
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SidekickPromotes, Hazel.SendOption.Reliable, -1);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCProcedure.sidekickPromotes();
}
// Pursuer promotion trigger on murder (the host sends the call such that everyone recieves the update before a possible game End)
if (target == Lawyer.target && AmongUsClient.Instance.AmHost && Lawyer.lawyer != null) {
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.LawyerPromotesToPursuer, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.LawyerPromotesToPursuer, Hazel.SendOption.Reliable, -1);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCProcedure.lawyerPromotesToPursuer();
}
// Seer show flash and add dead player position
- if (Seer.seer != null && (CachedPlayer.LocalPlayer.PlayerControl == Seer.seer || Helpers.shouldShowGhostInfo()) && !Seer.seer.Data.IsDead && Seer.seer != target && Seer.mode <= 1) {
+ if (Seer.seer != null && (PlayerControl.LocalPlayer == Seer.seer || Helpers.shouldShowGhostInfo()) && !Seer.seer.Data.IsDead && Seer.seer != target && Seer.mode <= 1) {
Helpers.showFlash(new Color(42f / 255f, 187f / 255f, 245f / 255f), message : "Seer Info: Someone Died");
}
if (Seer.deadBodyPositions != null) Seer.deadBodyPositions.Add(target.transform.position);
}
// Set bountyHunter cooldown
- if (BountyHunter.bountyHunter != null && CachedPlayer.LocalPlayer.PlayerControl == BountyHunter.bountyHunter && __instance == BountyHunter.bountyHunter) {
+ if (BountyHunter.bountyHunter != null && PlayerControl.LocalPlayer == BountyHunter.bountyHunter && __instance == BountyHunter.bountyHunter) {
if (target == BountyHunter.bounty) {
BountyHunter.bountyHunter.SetKillTimer(BountyHunter.bountyKillCooldown);
BountyHunter.bountyUpdateTimer = 0f; // Force bounty update
}
// Mini Set Impostor Mini kill timer (Due to mini being a modifier, all "SetKillTimers" must have happened before this!)
- if (Mini.mini != null && __instance == Mini.mini && __instance == CachedPlayer.LocalPlayer.PlayerControl) {
+ if (Mini.mini != null && __instance == Mini.mini && __instance == PlayerControl.LocalPlayer) {
float multiplier = 1f;
- if (Mini.mini != null && CachedPlayer.LocalPlayer.PlayerControl == Mini.mini) multiplier = Mini.isGrownUp() ? 0.66f : 2f;
+ if (Mini.mini != null && PlayerControl.LocalPlayer == Mini.mini) multiplier = Mini.isGrownUp() ? 0.66f : 2f;
Mini.mini.SetKillTimer(__instance.killTimer * multiplier);
}
// Cleaner Button Sync
- if (Cleaner.cleaner != null && CachedPlayer.LocalPlayer.PlayerControl == Cleaner.cleaner && __instance == Cleaner.cleaner && HudManagerStartPatch.cleanerCleanButton != null)
+ if (Cleaner.cleaner != null && PlayerControl.LocalPlayer == Cleaner.cleaner && __instance == Cleaner.cleaner && HudManagerStartPatch.cleanerCleanButton != null)
HudManagerStartPatch.cleanerCleanButton.Timer = Cleaner.cleaner.killTimer;
// Witch Button Sync
- if (Witch.triggerBothCooldowns && Witch.witch != null && CachedPlayer.LocalPlayer.PlayerControl == Witch.witch && __instance == Witch.witch && HudManagerStartPatch.witchSpellButton != null)
+ if (Witch.triggerBothCooldowns && Witch.witch != null && PlayerControl.LocalPlayer == Witch.witch && __instance == Witch.witch && HudManagerStartPatch.witchSpellButton != null)
HudManagerStartPatch.witchSpellButton.Timer = HudManagerStartPatch.witchSpellButton.MaxTimer;
// Warlock Button Sync
- if (Warlock.warlock != null && CachedPlayer.LocalPlayer.PlayerControl == Warlock.warlock && __instance == Warlock.warlock && HudManagerStartPatch.warlockCurseButton != null) {
+ if (Warlock.warlock != null && PlayerControl.LocalPlayer == Warlock.warlock && __instance == Warlock.warlock && HudManagerStartPatch.warlockCurseButton != null) {
if (Warlock.warlock.killTimer > HudManagerStartPatch.warlockCurseButton.Timer) {
HudManagerStartPatch.warlockCurseButton.Timer = Warlock.warlock.killTimer;
}
}
// Ninja Button Sync
- if (Ninja.ninja != null && CachedPlayer.LocalPlayer.PlayerControl == Ninja.ninja && __instance == Ninja.ninja && HudManagerStartPatch.ninjaButton != null)
+ if (Ninja.ninja != null && PlayerControl.LocalPlayer == Ninja.ninja && __instance == Ninja.ninja && HudManagerStartPatch.ninjaButton != null)
HudManagerStartPatch.ninjaButton.Timer = HudManagerStartPatch.ninjaButton.MaxTimer;
// Bait
float reportDelay = (float) rnd.Next((int)Bait.reportDelayMin, (int)Bait.reportDelayMax + 1);
Bait.active.Add(deadPlayer, reportDelay);
- if (Bait.showKillFlash && __instance == CachedPlayer.LocalPlayer.PlayerControl) Helpers.showFlash(new Color(204f / 255f, 102f / 255f, 0f / 255f));
+ if (Bait.showKillFlash && __instance == PlayerControl.LocalPlayer) Helpers.showFlash(new Color(204f / 255f, 102f / 255f, 0f / 255f));
}
// Add Bloody Modifier
if (Bloody.bloody.FindAll(x => x.PlayerId == target.PlayerId).Count > 0) {
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.Bloody, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.Bloody, Hazel.SendOption.Reliable, -1);
writer.Write(__instance.PlayerId);
writer.Write(target.PlayerId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
if (HideNSeek.isHideNSeekGM) {
int visibleCounter = 0;
Vector3 bottomLeft = IntroCutsceneOnDestroyPatch.bottomLeft + new Vector3(-0.25f, -0.25f, 0);
- foreach (PlayerControl p in CachedPlayer.AllPlayers) {
+ foreach (PlayerControl p in PlayerControl.AllPlayerControls) {
if (!TORMapOptions.playerIcons.ContainsKey(p.PlayerId) || p.Data.Role.IsImpostor) continue;
if (p.Data.IsDead || p.Data.Disconnected) {
TORMapOptions.playerIcons[p.PlayerId].gameObject.SetActive(false);
}
// Snitch
- if (Snitch.snitch != null && CachedPlayer.LocalPlayer.PlayerId == Snitch.snitch.PlayerId && MapBehaviourPatch.herePoints.Keys.Any(x => x.PlayerId == target.PlayerId)) {
- foreach (var a in MapBehaviourPatch.herePoints.Where(x => x.Key.PlayerId == target.PlayerId)) {
+ if (Snitch.snitch != null && PlayerControl.LocalPlayer.PlayerId == Snitch.snitch.PlayerId && MapBehaviourPatch.herePoints.Keys.Any(x => x == target.PlayerId)) {
+ foreach (var a in MapBehaviourPatch.herePoints.Where(x => x.Key == target.PlayerId)) {
UnityEngine.Object.Destroy(a.Value);
MapBehaviourPatch.herePoints.Remove(a.Key);
}
if (GameOptionsManager.Instance.currentNormalGameOptions.KillCooldown <= 0f) return false;
float multiplier = 1f;
float addition = 0f;
- if (Mini.mini != null && CachedPlayer.LocalPlayer.PlayerControl == Mini.mini) multiplier = Mini.isGrownUp() ? 0.66f : 2f;
- if (BountyHunter.bountyHunter != null && CachedPlayer.LocalPlayer.PlayerControl == BountyHunter.bountyHunter) addition = BountyHunter.punishmentTime;
+ if (Mini.mini != null && PlayerControl.LocalPlayer == Mini.mini) multiplier = Mini.isGrownUp() ? 0.66f : 2f;
+ if (BountyHunter.bountyHunter != null && PlayerControl.LocalPlayer == BountyHunter.bountyHunter) addition = BountyHunter.punishmentTime;
__instance.killTimer = Mathf.Clamp(time, 0f, GameOptionsManager.Instance.currentNormalGameOptions.KillCooldown * multiplier + addition);
FastDestroyableSingleton<HudManager>.Instance.KillButton.SetCoolDown(__instance.killTimer, GameOptionsManager.Instance.currentNormalGameOptions.KillCooldown * multiplier + addition);
}
// Sidekick promotion trigger on exile
- if (Sidekick.promotesToJackal && Sidekick.sidekick != null && !Sidekick.sidekick.Data.IsDead && __instance == Jackal.jackal && Jackal.jackal == CachedPlayer.LocalPlayer.PlayerControl) {
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.SidekickPromotes, Hazel.SendOption.Reliable, -1);
+ if (Sidekick.promotesToJackal && Sidekick.sidekick != null && !Sidekick.sidekick.Data.IsDead && __instance == Jackal.jackal && Jackal.jackal == PlayerControl.LocalPlayer) {
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SidekickPromotes, Hazel.SendOption.Reliable, -1);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCProcedure.sidekickPromotes();
}
if (Lawyer.lawyer != null && __instance == Lawyer.target) {
PlayerControl lawyer = Lawyer.lawyer;
if (AmongUsClient.Instance.AmHost && ((Lawyer.target != Jester.jester && !Lawyer.isProsecutor) || Lawyer.targetWasGuessed)) {
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.LawyerPromotesToPursuer, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.LawyerPromotesToPursuer, Hazel.SendOption.Reliable, -1);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCProcedure.lawyerPromotesToPursuer();
}
if (Lawyer.lawyer != null) Lawyer.lawyer.Exiled();
if (Pursuer.pursuer != null) Pursuer.pursuer.Exiled();
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.ShareGhostInfo, Hazel.SendOption.Reliable, -1);
- writer.Write(CachedPlayer.LocalPlayer.PlayerId);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ShareGhostInfo, Hazel.SendOption.Reliable, -1);
+ writer.Write(PlayerControl.LocalPlayer.PlayerId);
writer.Write((byte)RPCProcedure.GhostInfoTypes.DeathReasonAndKiller);
writer.Write(lawyer.PlayerId);
writer.Write((byte)DeadPlayer.CustomDeathReason.LawyerSuicide);
public static class PlayerPhysicsFixedUpdate {
public static void Postfix(PlayerPhysics __instance)
{
- bool shouldInvert = Invert.invert.FindAll(x => x.PlayerId == CachedPlayer.LocalPlayer.PlayerId).Count > 0 && Invert.meetings > 0;
+ bool shouldInvert = Invert.invert.FindAll(x => x.PlayerId == PlayerControl.LocalPlayer.PlayerId).Count > 0 && Invert.meetings > 0;
if (__instance.AmOwner &&
AmongUsClient.Instance &&
AmongUsClient.Instance.GameState == InnerNet.InnerNetClient.GameStates.Started &&
- !CachedPlayer.LocalPlayer.Data.IsDead &&
+ !PlayerControl.LocalPlayer.Data.IsDead &&
shouldInvert &&
GameData.Instance &&
__instance.myPlayer.CanMove)
if (GameOptionsManager.Instance.currentGameOptions.GameMode == GameModes.HideNSeek)
return true;
__result = false;
- if (!CachedPlayer.LocalPlayer.Data.IsDead && Lighter.lighter != null && Lighter.lighter.PlayerId == CachedPlayer.LocalPlayer.PlayerId) {
+ if (!PlayerControl.LocalPlayer.Data.IsDead && Lighter.lighter != null && Lighter.lighter.PlayerId == PlayerControl.LocalPlayer.PlayerId) {
__result = true;
}
[HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.AdjustLighting))]
public static class AdjustLight {
public static bool Prefix(PlayerControl __instance) {
- if (__instance == null || CachedPlayer.LocalPlayer == null || Lighter.lighter == null) return true;
+ if (__instance == null || PlayerControl.LocalPlayer == null || Lighter.lighter == null) return true;
- bool hasFlashlight = !CachedPlayer.LocalPlayer.Data.IsDead && Lighter.lighter.PlayerId == CachedPlayer.LocalPlayer.PlayerId;
+ bool hasFlashlight = !PlayerControl.LocalPlayer.Data.IsDead && Lighter.lighter.PlayerId == PlayerControl.LocalPlayer.PlayerId;
__instance.SetFlashlightInputMethod();
__instance.lightSource.SetupLightingForGameplay(hasFlashlight, Lighter.flashlightWidth, __instance.TargetFlashlight.transform);
if (serverWarning == null) {
var tmplt = __instance.ButtonPool.activeChildren[^1] ;
- serverWarning = GameObject.Instantiate(tmplt.transform.GetChild(0).gameObject, tmplt.transform);
- var comp = serverWarning.GetComponent<TMPro.TextMeshPro>();
- comp.fontSizeMin = 2;
- comp.fontSizeMax = 2;
- serverWarning.transform.localPosition = new Vector3(0f, -3f, -10f);
+ serverWarning = new GameObject("serverWarning"); // GameObject.Instantiate(tmplt.transform.GetChild(0).gameObject, tmplt.transform);
+ var comp = serverWarning.AddComponent<TMPro.TextMeshPro>(); // serverWarning.GetComponent<TMPro.TextMeshPro>();
+ //serverWarning.transform.SetParent(tmplt.transform, true);
+ comp.fontSize = 0.2f;
+ serverWarning.transform.position = new Vector3(5f, 1f, -200f);
__instance.StartCoroutine(Effects.Lerp(0.1f, new Action<float>((p) => {
comp.text = Helpers.cs(Color.red, "Vanilla Servers Are Currently Not Compatible With TOR");
+ serverWarning.transform.position = new Vector3(0f, 1f, -200f);
})));
serverWarning.SetActive(true);
}
using UnityEngine;
using System;
using AmongUs.GameOptions;
-using TheOtherRoles.Players;
+
using TheOtherRoles.Utilities;
using static TheOtherRoles.TheOtherRoles;
using TheOtherRoles.CustomGameModes;
private static List<Tuple<byte, byte>> playerRoleMap = new List<Tuple<byte, byte>>();
public static bool isGuesserGamemode { get { return TORMapOptions.gameMode == CustomGamemodes.Guesser; } }
public static void Postfix() {
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.ResetVaribles, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ResetVaribles, Hazel.SendOption.Reliable, -1);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCProcedure.resetVariables();
if (TORMapOptions.gameMode == CustomGamemodes.HideNSeek || TORMapOptions.gameMode == CustomGamemodes.PropHunt || GameOptionsManager.Instance.currentGameOptions.GameMode == GameModes.HideNSeek) return; // Don't assign Roles in Hide N Seek
int crewCountSettings = rnd.Next(crewmateMin, crewmateMax + 1);
int neutralCountSettings = rnd.Next(neutralMin, neutralMax + 1);
int impCountSettings = rnd.Next(impostorMin, impostorMax + 1);
+ // If fill crewmates is enabled, make sure crew + neutral >= crewmates s.t. everyone has a role!
+ while (crewCountSettings + neutralCountSettings < crewmates.Count && CustomOptionHolder.crewmateRolesFill.getBool())
+ crewCountSettings++;
// Potentially lower the actual maximum to the assignable players
int maxCrewmateRoles = Mathf.Min(crewmates.Count, crewCountSettings);
if (Lawyer.lawyer != null) {
var possibleTargets = new List<PlayerControl>();
if (!Lawyer.isProsecutor) { // Lawyer
- foreach (PlayerControl p in CachedPlayer.AllPlayers) {
+ foreach (PlayerControl p in PlayerControl.AllPlayerControls) {
if (!p.Data.IsDead && !p.Data.Disconnected && p != Lovers.lover1 && p != Lovers.lover2 && (p.Data.Role.IsImpostor || p == Jackal.jackal || (Lawyer.targetCanBeJester && p == Jester.jester)))
possibleTargets.Add(p);
}
} else { // Prosecutor
- foreach (PlayerControl p in CachedPlayer.AllPlayers) {
+ foreach (PlayerControl p in PlayerControl.AllPlayerControls) {
if (!p.Data.IsDead && !p.Data.Disconnected && p != Lovers.lover1 && p != Lovers.lover2 && p != Mini.mini && !p.Data.Role.IsImpostor && !Helpers.isNeutral(p) && p != Swapper.swapper)
possibleTargets.Add(p);
}
}
if (possibleTargets.Count == 0) {
- MessageWriter w = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.LawyerPromotesToPursuer, Hazel.SendOption.Reliable, -1);
+ MessageWriter w = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.LawyerPromotesToPursuer, Hazel.SendOption.Reliable, -1);
AmongUsClient.Instance.FinishRpcImmediately(w);
RPCProcedure.lawyerPromotesToPursuer();
} else {
var target = possibleTargets[TheOtherRoles.rnd.Next(0, possibleTargets.Count)];
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.LawyerSetTarget, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.LawyerSetTarget, Hazel.SendOption.Reliable, -1);
writer.Write(target.PlayerId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCProcedure.lawyerSetTarget(target.PlayerId);
RoleId.Vip,
RoleId.Invert,
RoleId.Chameleon,
+ RoleId.Armored,
RoleId.Shifter
});
byte playerId = playerList[index].PlayerId;
playerList.RemoveAt(index);
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.SetGuesserGm, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetGuesserGm, Hazel.SendOption.Reliable, -1);
writer.Write(playerId);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCProcedure.setGuesserGm(playerId);
byte playerId = playerList[index].PlayerId;
playerList.RemoveAt(index);
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.SetModifier, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetModifier, Hazel.SendOption.Reliable, -1);
writer.Write(modifierId);
writer.Write(playerId);
writer.Write(flag);
selection = CustomOptionHolder.modifierChameleon.getSelection();
if (multiplyQuantity) selection *= CustomOptionHolder.modifierChameleonQuantity.getQuantity();
break;
+ case RoleId.Armored:
+ selection = CustomOptionHolder.modifierArmored.getSelection();
+ break;
case RoleId.Shifter:
- selection = CustomOptionHolder.modifierShifter.getSelection(); break;
+ selection = CustomOptionHolder.modifierShifter.getSelection();
+ break;
}
return selection;
while (playerRoleMap.Any())
{
byte amount = (byte)Math.Min(playerRoleMap.Count, 20);
- var writer = AmongUsClient.Instance!.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.WorkaroundSetRoles, SendOption.Reliable, -1);
+ var writer = AmongUsClient.Instance!.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.WorkaroundSetRoles, SendOption.Reliable, -1);
writer.Write(amount);
for (int i = 0; i < amount; i++)
{
[HarmonyPrefix]
[HarmonyPatch(typeof(ZiplineBehaviour), nameof(ZiplineBehaviour.Use), new Type[] {typeof(PlayerControl), typeof(bool)})]
public static void prefix3(ZiplineBehaviour __instance, PlayerControl player, bool fromTop) {
- AntiTeleport.position = Players.CachedPlayer.LocalPlayer.transform.position;
+ AntiTeleport.position = PlayerControl.LocalPlayer.transform.position;
}
[HarmonyPostfix]
if (hand != null) {
if (Camouflager.camouflageTimer <= 0 && !Helpers.MushroomSabotageActive()) {
if (player == Morphling.morphling && Morphling.morphTimer > 0) {
- hand.SetPlayerColor(Morphling.morphTarget.CurrentOutfit, PlayerMaterial.MaskType.None);
+ hand.SetPlayerColor(Morphling.morphTarget.CurrentOutfit, PlayerMaterial.MaskType.None, 1f);
// Also set hat color, cause the line destroys it...
player.RawSetHat(Morphling.morphTarget.Data.DefaultOutfit.HatId, Morphling.morphTarget.Data.DefaultOutfit.ColorId);
} else {
- hand.SetPlayerColor(player.CurrentOutfit, PlayerMaterial.MaskType.None);
+ hand.SetPlayerColor(player.CurrentOutfit, PlayerMaterial.MaskType.None, 1f);
}
} else {
PlayerMaterial.SetColors(6, hand.handRenderer);
[HarmonyPrefix]
[HarmonyPatch(typeof(PlayerPhysics), nameof(PlayerPhysics.ClimbLadder))]
public static void prefix() {
- AntiTeleport.position = Players.CachedPlayer.LocalPlayer.transform.position;
+ AntiTeleport.position = PlayerControl.LocalPlayer.transform.position;
}
[HarmonyPostfix]
[HarmonyPrefix]
[HarmonyPatch(typeof(MovingPlatformBehaviour), nameof(MovingPlatformBehaviour.UsePlatform))]
public static void prefix2() {
- AntiTeleport.position = Players.CachedPlayer.LocalPlayer.transform.position;
+ AntiTeleport.position = PlayerControl.LocalPlayer.transform.position;
}
}
}
using TheOtherRoles.Objects;
using System.Collections.Generic;
using System.Linq;
-using TheOtherRoles.Players;
+
using TheOtherRoles.Utilities;
using TheOtherRoles.CustomGameModes;
using AmongUs.GameOptions;
{
private static Dictionary<byte, (string name, Color color)> TagColorDict = new();
static void resetNameTagsAndColors() {
- var localPlayer = CachedPlayer.LocalPlayer.PlayerControl;
- var myData = CachedPlayer.LocalPlayer.Data;
+ var localPlayer = PlayerControl.LocalPlayer;
+ var myData = PlayerControl.LocalPlayer.Data;
var amImpostor = myData.Role.IsImpostor;
var morphTimerNotUp = Morphling.morphTimer > 0f;
var morphTargetNotNull = Morphling.morphTarget != null;
}
static void setNameColors() {
- var localPlayer = CachedPlayer.LocalPlayer.PlayerControl;
+ var localPlayer = PlayerControl.LocalPlayer;
var localRole = RoleInfo.getRoleInfoForPlayer(localPlayer, false).FirstOrDefault();
setPlayerNameColor(localPlayer, localRole.color);
static void setNameTags() {
// Mafia
- if (CachedPlayer.LocalPlayer != null && CachedPlayer.LocalPlayer.Data.Role.IsImpostor) {
- foreach (PlayerControl player in CachedPlayer.AllPlayers)
+ if (PlayerControl.LocalPlayer != null && PlayerControl.LocalPlayer.Data.Role.IsImpostor) {
+ foreach (PlayerControl player in PlayerControl.AllPlayerControls)
if (Godfather.godfather != null && Godfather.godfather == player)
player.cosmetics.nameText.text = player.Data.PlayerName + " (G)";
else if (Mafioso.mafioso != null && Mafioso.mafioso == player)
}
// Lovers
- if (Lovers.lover1 != null && Lovers.lover2 != null && (Lovers.lover1 == CachedPlayer.LocalPlayer.PlayerControl || Lovers.lover2 == CachedPlayer.LocalPlayer.PlayerControl)) {
+ if (Lovers.lover1 != null && Lovers.lover2 != null && (Lovers.lover1 == PlayerControl.LocalPlayer || Lovers.lover2 == PlayerControl.LocalPlayer)) {
string suffix = Helpers.cs(Lovers.color, " ♥");
Lovers.lover1.cosmetics.nameText.text += suffix;
Lovers.lover2.cosmetics.nameText.text += suffix;
}
// Lawyer or Prosecutor
- if ((Lawyer.lawyer != null && Lawyer.target != null && Lawyer.lawyer == CachedPlayer.LocalPlayer.PlayerControl)) {
+ if ((Lawyer.lawyer != null && Lawyer.target != null && Lawyer.lawyer == PlayerControl.LocalPlayer)) {
Color color = Lawyer.color;
PlayerControl target = Lawyer.target;
string suffix = Helpers.cs(color, " §");
}
// Former Thief
- if (Thief.formerThief != null && (Thief.formerThief == CachedPlayer.LocalPlayer.PlayerControl || CachedPlayer.LocalPlayer.PlayerControl.Data.IsDead)) {
+ if (Thief.formerThief != null && (Thief.formerThief == PlayerControl.LocalPlayer || PlayerControl.LocalPlayer.Data.IsDead)) {
string suffix = Helpers.cs(Thief.color, " $");
Thief.formerThief.cosmetics.nameText.text += suffix;
if (MeetingHud.Instance != null)
}
// Display lighter / darker color for all alive players
- if (CachedPlayer.LocalPlayer != null && MeetingHud.Instance != null && TORMapOptions.showLighterDarker) {
+ if (PlayerControl.LocalPlayer != null && MeetingHud.Instance != null && TORMapOptions.showLighterDarker) {
foreach (PlayerVoteArea player in MeetingHud.Instance.playerStates) {
var target = Helpers.playerById(player.TargetPlayerId);
if (target != null) player.NameText.text += $" ({(Helpers.isLighterColor(target) ? "L" : "D")})";
}
static void updateImpostorKillButton(HudManager __instance) {
- if (!CachedPlayer.LocalPlayer.Data.Role.IsImpostor) return;
+ if (!PlayerControl.LocalPlayer.Data.Role.IsImpostor) return;
if (MeetingHud.Instance) {
__instance.KillButton.Hide();
return;
}
bool enabled = true;
- if (Vampire.vampire != null && Vampire.vampire == CachedPlayer.LocalPlayer.PlayerControl)
+ if (Vampire.vampire != null && Vampire.vampire == PlayerControl.LocalPlayer)
enabled = false;
- else if (Mafioso.mafioso != null && Mafioso.mafioso == CachedPlayer.LocalPlayer.PlayerControl && Godfather.godfather != null && !Godfather.godfather.Data.IsDead)
+ else if (Mafioso.mafioso != null && Mafioso.mafioso == PlayerControl.LocalPlayer && Godfather.godfather != null && !Godfather.godfather.Data.IsDead)
enabled = false;
- else if (Janitor.janitor != null && Janitor.janitor == CachedPlayer.LocalPlayer.PlayerControl)
+ else if (Janitor.janitor != null && Janitor.janitor == PlayerControl.LocalPlayer)
enabled = false;
if (enabled) __instance.KillButton.Show();
else __instance.KillButton.Hide();
- if (Deputy.handcuffedKnows.ContainsKey(CachedPlayer.LocalPlayer.PlayerId) && Deputy.handcuffedKnows[CachedPlayer.LocalPlayer.PlayerId] > 0) __instance.KillButton.Hide();
+ if (Deputy.handcuffedKnows.ContainsKey(PlayerControl.LocalPlayer.PlayerId) && Deputy.handcuffedKnows[PlayerControl.LocalPlayer.PlayerId] > 0) __instance.KillButton.Hide();
}
static void updateReportButton(HudManager __instance) {
if (GameOptionsManager.Instance.currentGameOptions.GameMode == GameModes.HideNSeek) return;
- if (Deputy.handcuffedKnows.ContainsKey(CachedPlayer.LocalPlayer.PlayerId) && Deputy.handcuffedKnows[CachedPlayer.LocalPlayer.PlayerId] > 0 || MeetingHud.Instance) __instance.ReportButton.Hide();
+ if (Deputy.handcuffedKnows.ContainsKey(PlayerControl.LocalPlayer.PlayerId) && Deputy.handcuffedKnows[PlayerControl.LocalPlayer.PlayerId] > 0 || MeetingHud.Instance) __instance.ReportButton.Hide();
else if (!__instance.ReportButton.isActiveAndEnabled) __instance.ReportButton.Show();
}
static void updateVentButton(HudManager __instance)
{
if (GameOptionsManager.Instance.currentGameOptions.GameMode == GameModes.HideNSeek) return;
- if (Deputy.handcuffedKnows.ContainsKey(CachedPlayer.LocalPlayer.PlayerId) && Deputy.handcuffedKnows[CachedPlayer.LocalPlayer.PlayerId] > 0 || MeetingHud.Instance) __instance.ImpostorVentButton.Hide();
- else if (CachedPlayer.LocalPlayer.PlayerControl.roleCanUseVents() && !__instance.ImpostorVentButton.isActiveAndEnabled) __instance.ImpostorVentButton.Show();
+ if (Deputy.handcuffedKnows.ContainsKey(PlayerControl.LocalPlayer.PlayerId) && Deputy.handcuffedKnows[PlayerControl.LocalPlayer.PlayerId] > 0 || MeetingHud.Instance) __instance.ImpostorVentButton.Hide();
+ else if (PlayerControl.LocalPlayer.roleCanUseVents() && !__instance.ImpostorVentButton.isActiveAndEnabled) __instance.ImpostorVentButton.Show();
}
}
static void updateMapButton(HudManager __instance) {
- if (Trapper.trapper == null || !(CachedPlayer.LocalPlayer.PlayerId == Trapper.trapper.PlayerId) || __instance == null || __instance.MapButton.HeldButtonSprite == null) return;
+ if (Trapper.trapper == null || !(PlayerControl.LocalPlayer.PlayerId == Trapper.trapper.PlayerId) || __instance == null || __instance.MapButton.HeldButtonSprite == null) return;
__instance.MapButton.HeldButtonSprite.color = Trapper.playersOnMap.Any() ? Trapper.color : Color.white;
}
if (!MeetingHud.Instance) __instance.AbilityButton?.Update();
// Fix dead player's pets being visible by just always updating whether the pet should be visible at all.
- foreach (PlayerControl target in CachedPlayer.AllPlayers) {
+ foreach (PlayerControl target in PlayerControl.AllPlayerControls) {
var pet = target.GetPet();
if (pet != null) {
pet.Visible = (PlayerControl.LocalPlayer.Data.IsDead && target.Data.IsDead || !target.Data.IsDead) && !target.inVent;
using static TheOtherRoles.GameHistory;
using static TheOtherRoles.TORMapOptions;
using System.Collections.Generic;
-using TheOtherRoles.Players;
+
using TheOtherRoles.Utilities;
using TheOtherRoles.Objects;
using TheOtherRoles.CustomGameModes;
}
switch (__instance.Id) {
case 9: // Cannot enter vent 9 (Engine Room Exit Only Vent)!
- if (CachedPlayer.LocalPlayer.PlayerControl.inVent) break;
+ if (PlayerControl.LocalPlayer.inVent) break;
__result = float.MaxValue;
return canUse = couldUse = false;
case 14: // Lower Central
var usableDistance = __instance.UsableDistance;
if (__instance.name.StartsWith("JackInTheBoxVent_")) {
- if(Trickster.trickster != CachedPlayer.LocalPlayer.PlayerControl) {
+ if(Trickster.trickster != PlayerControl.LocalPlayer) {
// Only the Trickster can use the Jack-In-The-Boxes!
canUse = false;
couldUse = false;
class VentButtonDoClickPatch {
static bool Prefix(VentButton __instance) {
// Manually modifying the VentButton to use Vent.Use again in order to trigger the Vent.Use prefix patch
- if (__instance.currentTarget != null && !Deputy.handcuffedKnows.ContainsKey(CachedPlayer.LocalPlayer.PlayerId)) __instance.currentTarget.Use();
+ if (__instance.currentTarget != null && !Deputy.handcuffedKnows.ContainsKey(PlayerControl.LocalPlayer.PlayerId)) __instance.currentTarget.Use();
return false;
}
}
public static bool Prefix(Vent __instance) {
if (GameOptionsManager.Instance.currentGameOptions.GameMode == GameModes.HideNSeek) return true;
// Deputy handcuff disables the vents
- if (Deputy.handcuffedPlayers.Contains(CachedPlayer.LocalPlayer.PlayerId)) {
+ if (Deputy.handcuffedPlayers.Contains(PlayerControl.LocalPlayer.PlayerId)) {
Deputy.setHandcuffedKnows();
return false;
}
- if (Trapper.playersOnMap.Contains(CachedPlayer.LocalPlayer.PlayerControl)) return false;
+ if (Trapper.playersOnMap.Contains(PlayerControl.LocalPlayer)) return false;
bool canUse;
bool couldUse;
- __instance.CanUse(CachedPlayer.LocalPlayer.Data, out canUse, out couldUse);
- bool canMoveInVents = CachedPlayer.LocalPlayer.PlayerControl != Spy.spy && !Trapper.playersOnMap.Contains(CachedPlayer.LocalPlayer.PlayerControl);
+ __instance.CanUse(PlayerControl.LocalPlayer.Data, out canUse, out couldUse);
+ bool canMoveInVents = PlayerControl.LocalPlayer != Spy.spy && !Trapper.playersOnMap.Contains(PlayerControl.LocalPlayer);
if (!canUse) return false; // No need to execute the native method as using is disallowed anyways
- bool isEnter = !CachedPlayer.LocalPlayer.PlayerControl.inVent;
+ bool isEnter = !PlayerControl.LocalPlayer.inVent;
if (__instance.name.StartsWith("JackInTheBoxVent_")) {
__instance.SetButtons(isEnter && canMoveInVents);
- MessageWriter writer = AmongUsClient.Instance.StartRpc(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.UseUncheckedVent, Hazel.SendOption.Reliable);
+ MessageWriter writer = AmongUsClient.Instance.StartRpc(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.UseUncheckedVent, Hazel.SendOption.Reliable);
writer.WritePacked(__instance.Id);
- writer.Write(CachedPlayer.LocalPlayer.PlayerId);
+ writer.Write(PlayerControl.LocalPlayer.PlayerId);
writer.Write(isEnter ? byte.MaxValue : (byte)0);
writer.EndMessage();
- RPCProcedure.useUncheckedVent(__instance.Id, CachedPlayer.LocalPlayer.PlayerId, isEnter ? byte.MaxValue : (byte)0);
+ RPCProcedure.useUncheckedVent(__instance.Id, PlayerControl.LocalPlayer.PlayerId, isEnter ? byte.MaxValue : (byte)0);
SoundEffectsManager.play("tricksterUseBoxVent");
return false;
}
if(isEnter) {
- CachedPlayer.LocalPlayer.PlayerPhysics.RpcEnterVent(__instance.Id);
+ PlayerControl.LocalPlayer.MyPhysics.RpcEnterVent(__instance.Id);
} else {
- CachedPlayer.LocalPlayer.PlayerPhysics.RpcExitVent(__instance.Id);
+ PlayerControl.LocalPlayer.MyPhysics.RpcExitVent(__instance.Id);
}
__instance.SetButtons(isEnter && canMoveInVents);
return false;
[HarmonyPatch(typeof(Vent), nameof(Vent.TryMoveToVent))]
public static class MoveToVentPatch {
public static bool Prefix(Vent otherVent) {
- return !Trapper.playersOnMap.Contains(CachedPlayer.LocalPlayer.PlayerControl);
+ return !Trapper.playersOnMap.Contains(PlayerControl.LocalPlayer);
}
}
static Sprite defaultVentSprite = null;
static void Postfix(VentButton __instance) {
// Trickster render special vent button
- if (Trickster.trickster != null && Trickster.trickster == CachedPlayer.LocalPlayer.PlayerControl) {
+ if (Trickster.trickster != null && Trickster.trickster == PlayerControl.LocalPlayer) {
if (defaultVentSprite == null) defaultVentSprite = __instance.graphic.sprite;
bool isSpecialVent = __instance.currentTarget != null && __instance.currentTarget.gameObject != null && __instance.currentTarget.gameObject.name.StartsWith("JackInTheBoxVent_");
__instance.graphic.sprite = isSpecialVent ? Trickster.getTricksterVentButtonSprite() : defaultVentSprite;
KillAnimationCoPerformKillPatch.hideNextAnimation = true; // dont jump out of bounds!
return false;
}
- if (__instance.isActiveAndEnabled && __instance.currentTarget && !__instance.isCoolingDown && !CachedPlayer.LocalPlayer.Data.IsDead && CachedPlayer.LocalPlayer.PlayerControl.CanMove) {
+ if (__instance.isActiveAndEnabled && __instance.currentTarget && !__instance.isCoolingDown && !PlayerControl.LocalPlayer.Data.IsDead && PlayerControl.LocalPlayer.CanMove) {
// Deputy handcuff update.
- if (Deputy.handcuffedPlayers.Contains(CachedPlayer.LocalPlayer.PlayerId)) {
+ if (Deputy.handcuffedPlayers.Contains(PlayerControl.LocalPlayer.PlayerId)) {
Deputy.setHandcuffedKnows();
return false;
}
// Use an unchecked kill command, to allow shorter kill cooldowns etc. without getting kicked
- MurderAttemptResult res = Helpers.checkMurderAttemptAndKill(CachedPlayer.LocalPlayer.PlayerControl, __instance.currentTarget);
+ MurderAttemptResult res = Helpers.checkMurderAttemptAndKill(PlayerControl.LocalPlayer, __instance.currentTarget);
// Handle blank kill
if (res == MurderAttemptResult.BlankKill) {
- CachedPlayer.LocalPlayer.PlayerControl.killTimer = GameOptionsManager.Instance.currentNormalGameOptions.KillCooldown;
- if (CachedPlayer.LocalPlayer.PlayerControl == Cleaner.cleaner)
+ PlayerControl.LocalPlayer.killTimer = GameOptionsManager.Instance.currentNormalGameOptions.KillCooldown;
+ if (PlayerControl.LocalPlayer == Cleaner.cleaner)
Cleaner.cleaner.killTimer = HudManagerStartPatch.cleanerCleanButton.Timer = HudManagerStartPatch.cleanerCleanButton.MaxTimer;
- else if (CachedPlayer.LocalPlayer.PlayerControl == Warlock.warlock)
+ else if (PlayerControl.LocalPlayer == Warlock.warlock)
Warlock.warlock.killTimer = HudManagerStartPatch.warlockCurseButton.Timer = HudManagerStartPatch.warlockCurseButton.MaxTimer;
- else if (CachedPlayer.LocalPlayer.PlayerControl == Mini.mini && Mini.mini.Data.Role.IsImpostor)
+ else if (PlayerControl.LocalPlayer == Mini.mini && Mini.mini.Data.Role.IsImpostor)
Mini.mini.SetKillTimer(GameOptionsManager.Instance.currentNormalGameOptions.KillCooldown * (Mini.isGrownUp() ? 0.66f : 2f));
- else if (CachedPlayer.LocalPlayer.PlayerControl == Witch.witch)
+ else if (PlayerControl.LocalPlayer == Witch.witch)
Witch.witch.killTimer = HudManagerStartPatch.witchSpellButton.Timer = HudManagerStartPatch.witchSpellButton.MaxTimer;
- else if (CachedPlayer.LocalPlayer.PlayerControl == Ninja.ninja)
+ else if (PlayerControl.LocalPlayer == Ninja.ninja)
Ninja.ninja.killTimer = HudManagerStartPatch.ninjaButton.Timer = HudManagerStartPatch.ninjaButton.MaxTimer;
}
__instance.SetTarget(null);
class SabotageButtonRefreshPatch {
static void Postfix() {
// Mafia disable sabotage button for Janitor and sometimes for Mafioso
- bool blockSabotageJanitor = (Janitor.janitor != null && Janitor.janitor == CachedPlayer.LocalPlayer.PlayerControl);
- bool blockSabotageMafioso = (Mafioso.mafioso != null && Mafioso.mafioso == CachedPlayer.LocalPlayer.PlayerControl && Godfather.godfather != null && !Godfather.godfather.Data.IsDead);
+ bool blockSabotageJanitor = (Janitor.janitor != null && Janitor.janitor == PlayerControl.LocalPlayer);
+ bool blockSabotageMafioso = (Mafioso.mafioso != null && Mafioso.mafioso == PlayerControl.LocalPlayer && Godfather.godfather != null && !Godfather.godfather.Data.IsDead);
if (blockSabotageJanitor || blockSabotageMafioso) {
FastDestroyableSingleton<HudManager>.Instance.SabotageButton.SetDisabled();
}
[HarmonyPatch(typeof(ReportButton), nameof(ReportButton.DoClick))]
class ReportButtonDoClickPatch {
public static bool Prefix(ReportButton __instance) {
- if (__instance.isActiveAndEnabled && Deputy.handcuffedPlayers.Contains(CachedPlayer.LocalPlayer.PlayerId) && __instance.graphic.color == Palette.EnabledColor) Deputy.setHandcuffedKnows();
- return !Deputy.handcuffedKnows.ContainsKey(CachedPlayer.LocalPlayer.PlayerId);
+ if (__instance.isActiveAndEnabled && Deputy.handcuffedPlayers.Contains(PlayerControl.LocalPlayer.PlayerId) && __instance.graphic.color == Palette.EnabledColor) Deputy.setHandcuffedKnows();
+ return !Deputy.handcuffedKnows.ContainsKey(PlayerControl.LocalPlayer.PlayerId);
}
}
var statusText = "";
// Deactivate emergency button for Swapper
- if (Swapper.swapper != null && Swapper.swapper == CachedPlayer.LocalPlayer.PlayerControl && !Swapper.canCallEmergency) {
+ if (Swapper.swapper != null && Swapper.swapper == PlayerControl.LocalPlayer && !Swapper.canCallEmergency) {
roleCanCallEmergency = false;
statusText = "The Swapper can't start an emergency meeting";
}
// Potentially deactivate emergency button for Jester
- if (Jester.jester != null && Jester.jester == CachedPlayer.LocalPlayer.PlayerControl && !Jester.canCallEmergency) {
+ if (Jester.jester != null && Jester.jester == PlayerControl.LocalPlayer && !Jester.canCallEmergency) {
roleCanCallEmergency = false;
statusText = "The Jester can't start an emergency meeting";
}
// Potentially deactivate emergency button for Lawyer/Prosecutor
- if (Lawyer.lawyer != null && Lawyer.lawyer == CachedPlayer.LocalPlayer.PlayerControl && !Lawyer.canCallEmergency) {
+ if (Lawyer.lawyer != null && Lawyer.lawyer == PlayerControl.LocalPlayer && !Lawyer.canCallEmergency) {
roleCanCallEmergency = false;
statusText = "The Lawyer can't start an emergency meeting";
if (Lawyer.isProsecutor) statusText = "The Prosecutor can't start an emergency meeting";
// Handle max number of meetings
if (__instance.state == 1) {
- int localRemaining = CachedPlayer.LocalPlayer.PlayerControl.RemainingEmergencies;
+ int localRemaining = PlayerControl.LocalPlayer.RemainingEmergencies;
int teamRemaining = Mathf.Max(0, maxNumberOfMeetings - meetingsCount);
- int remaining = Mathf.Min(localRemaining, (Mayor.mayor != null && Mayor.mayor == CachedPlayer.LocalPlayer.PlayerControl) ? 1 : teamRemaining);
+ int remaining = Mathf.Min(localRemaining, (Mayor.mayor != null && Mayor.mayor == PlayerControl.LocalPlayer) ? 1 : teamRemaining);
__instance.NumberText.text = $"{localRemaining.ToString()} and the ship has {teamRemaining.ToString()}";
__instance.ButtonActive = remaining > 0;
__instance.ClosedLid.gameObject.SetActive(!__instance.ButtonActive);
public static class ConsoleCanUsePatch {
public static bool Prefix(ref float __result, Console __instance, [HarmonyArgument(0)] NetworkedPlayerInfo pc, [HarmonyArgument(1)] out bool canUse, [HarmonyArgument(2)] out bool couldUse) {
canUse = couldUse = false;
- if (Swapper.swapper != null && Swapper.swapper == CachedPlayer.LocalPlayer.PlayerControl)
+ if (Swapper.swapper != null && Swapper.swapper == PlayerControl.LocalPlayer)
return !__instance.TaskTypes.Any(x => x == TaskTypes.FixLights || x == TaskTypes.FixComms);
if (__instance.AllowImpostor) return true;
if (!Helpers.hasFakeTasks(pc.Object)) return true;
class CommsMinigameBeginPatch {
static void Postfix(TuneRadioMinigame __instance) {
// Block Swapper from fixing comms. Still looking for a better way to do this, but deleting the task doesn't seem like a viable option since then the camera, admin table, ... work while comms are out
- if (Swapper.swapper != null && Swapper.swapper == CachedPlayer.LocalPlayer.PlayerControl) {
+ if (Swapper.swapper != null && Swapper.swapper == PlayerControl.LocalPlayer) {
__instance.Close();
}
}
class LightsMinigameBeginPatch {
static void Postfix(SwitchMinigame __instance) {
// Block Swapper from fixing lights. One could also just delete the PlayerTask, but I wanted to do it the same way as with coms for now.
- if (Swapper.swapper != null && Swapper.swapper == CachedPlayer.LocalPlayer.PlayerControl) {
+ if (Swapper.swapper != null && Swapper.swapper == PlayerControl.LocalPlayer) {
__instance.Close();
}
}
[HarmonyPatch(typeof(VitalsMinigame), nameof(VitalsMinigame.Begin))]
class VitalsMinigameStartPatch {
static void Postfix(VitalsMinigame __instance) {
- if (Hacker.hacker != null && CachedPlayer.LocalPlayer.PlayerControl == Hacker.hacker) {
+ if (Hacker.hacker != null && PlayerControl.LocalPlayer == Hacker.hacker) {
hackerTexts = new List<TMPro.TextMeshPro>();
foreach (VitalsPanel panel in __instance.vitals) {
TMPro.TextMeshPro text = UnityEngine.Object.Instantiate(__instance.SabText, panel.transform);
static void Postfix(VitalsMinigame __instance) {
// Hacker show time since death
- if (Hacker.hacker != null && Hacker.hacker == CachedPlayer.LocalPlayer.PlayerControl && Hacker.hackerTimer > 0) {
+ if (Hacker.hacker != null && Hacker.hacker == PlayerControl.LocalPlayer && Hacker.hackerTimer > 0) {
for (int k = 0; k < __instance.vitals.Length; k++) {
VitalsPanel vitalsPanel = __instance.vitals[k];
NetworkedPlayerInfo player = vitalsPanel.PlayerInfo;
__instance.timer = 0f;
players = new Dictionary<SystemTypes, List<Color>>();
bool commsActive = false;
- foreach (PlayerTask task in CachedPlayer.LocalPlayer.PlayerControl.myTasks.GetFastEnumerator())
+ foreach (PlayerTask task in PlayerControl.LocalPlayer.myTasks.GetFastEnumerator())
if (task.TaskType == TaskTypes.FixComms) commsActive = true;
private static Material newMat;
static void Postfix(CounterArea __instance) {
// Hacker display saved colors on the admin panel
- bool showHackerInfo = Hacker.hacker != null && Hacker.hacker == CachedPlayer.LocalPlayer.PlayerControl && Hacker.hackerTimer > 0;
+ bool showHackerInfo = Hacker.hacker != null && Hacker.hacker == PlayerControl.LocalPlayer && Hacker.hackerTimer > 0;
if (players.ContainsKey(__instance.RoomType)) {
List<Color> colors = players[__instance.RoomType];
int i = -1;
timer = 0f;
}
- if ((__instance.isStatic || update) && !PlayerTask.PlayerHasTaskOfType<IHudOverrideTask>(CachedPlayer.LocalPlayer.PlayerControl)) {
+ if ((__instance.isStatic || update) && !PlayerTask.PlayerHasTaskOfType<IHudOverrideTask>(PlayerControl.LocalPlayer)) {
__instance.isStatic = false;
for (int i = 0; i < __instance.ViewPorts.Length; i++) {
__instance.ViewPorts[i].sharedMaterial = __instance.DefaultMaterial;
else
__instance.ViewPorts[i].sharedMaterial = __instance.StaticMaterial;
}
- } else if (!__instance.isStatic && PlayerTask.PlayerHasTaskOfType<HudOverrideTask>(CachedPlayer.LocalPlayer.PlayerControl)) {
+ } else if (!__instance.isStatic && PlayerTask.PlayerHasTaskOfType<HudOverrideTask>(PlayerControl.LocalPlayer)) {
__instance.isStatic = true;
for (int j = 0; j < __instance.ViewPorts.Length; j++) {
__instance.ViewPorts[j].sharedMaterial = __instance.StaticMaterial;
}
}
- isLightsOut = CachedPlayer.LocalPlayer.PlayerControl.myTasks.ToArray().Any(x => x.name.Contains("FixLightsTask")) || Trickster.lightsOutTimer > 0;
- bool ignoreNightVision = CustomOptionHolder.camsNoNightVisionIfImpVision.getBool() && Helpers.hasImpVision(GameData.Instance.GetPlayerById(CachedPlayer.LocalPlayer.PlayerId)) || CachedPlayer.LocalPlayer.Data.IsDead;
+ isLightsOut = PlayerControl.LocalPlayer.myTasks.ToArray().Any(x => x.name.Contains("FixLightsTask")) || Trickster.lightsOutTimer > 0;
+ bool ignoreNightVision = CustomOptionHolder.camsNoNightVisionIfImpVision.getBool() && Helpers.hasImpVision(GameData.Instance.GetPlayerById(PlayerControl.LocalPlayer.PlayerId)) || PlayerControl.LocalPlayer.Data.IsDead;
bool nightVisionEnabled = CustomOptionHolder.camsNightVision.getBool();
if (isLightsOut && !nightVisionIsActive && nightVisionEnabled && !ignoreNightVision) { // only update when something changed!
- foreach (PlayerControl pc in CachedPlayer.AllPlayers) {
+ foreach (PlayerControl pc in PlayerControl.AllPlayerControls) {
if (pc == Ninja.ninja && Ninja.invisibleTimer > 0f) {
continue;
}
if (nightVisionIsActive) {
nightVisionIsActive = false;
- foreach (PlayerControl pc in CachedPlayer.AllPlayers) {
+ foreach (PlayerControl pc in PlayerControl.AllPlayerControls) {
if (Camouflager.camouflageTimer > 0) {
pc.setLook("", 6, "", "", "", "", false);
} else if (pc == Morphling.morphling && Morphling.morphTimer > 0) {
class MedScanMinigameFixedUpdatePatch {
static void Prefix(MedScanMinigame __instance) {
if (TORMapOptions.allowParallelMedBayScans) {
- __instance.medscan.CurrentUser = CachedPlayer.LocalPlayer.PlayerId;
+ __instance.medscan.CurrentUser = PlayerControl.LocalPlayer.PlayerId;
__instance.medscan.UsersList.Clear();
}
}
using System.Linq;
using UnityEngine;
using System;
-using TheOtherRoles.Players;
+
using TheOtherRoles.Utilities;
using TheOtherRoles.CustomGameModes;
using AmongUs.Data;
Vip,
Invert,
Chameleon,
+ Armored,
Shifter
}
ShareRoom,
YoyoMarkLocation,
YoyoBlink,
+ BreakArmor,
// Gamemode
SetGuesserGm,
public static void forceEnd() {
if (AmongUsClient.Instance.GameState != InnerNet.InnerNetClient.GameStates.Started) return;
- foreach (PlayerControl player in CachedPlayer.AllPlayers)
+ foreach (PlayerControl player in PlayerControl.AllPlayerControls)
{
if (!player.Data.Role.IsImpostor)
{
}
public static void setRole(byte roleId, byte playerId) {
- foreach (PlayerControl player in CachedPlayer.AllPlayers) {
+ foreach (PlayerControl player in PlayerControl.AllPlayerControls) {
if (player.PlayerId == playerId) {
switch ((RoleId)roleId) {
case RoleId.Jester:
case RoleId.Chameleon:
Chameleon.chameleon.Add(player);
break;
+ case RoleId.Armored:
+ Armored.armored = player;
+ break;
case RoleId.Shifter:
Shifter.shifter = player;
break;
public static void timeMasterRewindTime() {
TimeMaster.shieldActive = false; // Shield is no longer active when rewinding
SoundEffectsManager.stop("timemasterShield"); // Shield sound stopped when rewinding
- if(TimeMaster.timeMaster != null && TimeMaster.timeMaster == CachedPlayer.LocalPlayer.PlayerControl) {
+ if(TimeMaster.timeMaster != null && TimeMaster.timeMaster == PlayerControl.LocalPlayer) {
resetTimeMasterButton();
}
FastDestroyableSingleton<HudManager>.Instance.FullScreen.color = new Color(0f, 0.5f, 0.8f, 0.3f);
if (p == 1f) FastDestroyableSingleton<HudManager>.Instance.FullScreen.enabled = false;
})));
- if (TimeMaster.timeMaster == null || CachedPlayer.LocalPlayer.PlayerControl == TimeMaster.timeMaster) return; // Time Master himself does not rewind
+ if (TimeMaster.timeMaster == null || PlayerControl.LocalPlayer == TimeMaster.timeMaster) return; // Time Master himself does not rewind
TimeMaster.isRewinding = true;
MapBehaviour.Instance.Close();
if (Minigame.Instance)
Minigame.Instance.ForceClose();
- CachedPlayer.LocalPlayer.PlayerControl.moveable = false;
+ PlayerControl.LocalPlayer.moveable = false;
}
public static void timeMasterShield() {
public static void shieldedMurderAttempt() {
if (Medic.shielded == null || Medic.medic == null) return;
- bool isShieldedAndShow = Medic.shielded == CachedPlayer.LocalPlayer.PlayerControl && Medic.showAttemptToShielded;
+ bool isShieldedAndShow = Medic.shielded == PlayerControl.LocalPlayer && Medic.showAttemptToShielded;
isShieldedAndShow = isShieldedAndShow && (Medic.meetingAfterShielding || !Medic.showShieldAfterMeeting); // Dont show attempt, if shield is not shown yet
- bool isMedicAndShow = Medic.medic == CachedPlayer.LocalPlayer.PlayerControl && Medic.showAttemptToMedic;
+ bool isMedicAndShow = Medic.medic == PlayerControl.LocalPlayer && Medic.showAttemptToMedic;
if (isShieldedAndShow || isMedicAndShow || Helpers.shouldShowGhostInfo()) Helpers.showFlash(Palette.ImpostorRed, duration: 0.5f, "Failed Murder Attempt on Shielded Player");
}
oldShifter.Exiled();
GameHistory.overrideDeathReasonAndKiller(oldShifter, DeadPlayer.CustomDeathReason.Shift, player);
if (oldShifter == Lawyer.target && AmongUsClient.Instance.AmHost && Lawyer.lawyer != null) {
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.LawyerPromotesToPursuer, Hazel.SendOption.Reliable, -1);
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.LawyerPromotesToPursuer, Hazel.SendOption.Reliable, -1);
AmongUsClient.Instance.FinishRpcImmediately(writer);
RPCProcedure.lawyerPromotesToPursuer();
}
Shifter.shiftRole(oldShifter, player);
// Set cooldowns to max for both players
- if (CachedPlayer.LocalPlayer.PlayerControl == oldShifter || CachedPlayer.LocalPlayer.PlayerControl == player)
+ if (PlayerControl.LocalPlayer == oldShifter || PlayerControl.LocalPlayer == player)
CustomButton.ResetAllCooldowns();
}
Camouflager.camouflageTimer = Camouflager.duration;
if (Helpers.MushroomSabotageActive()) return; // Dont overwrite the fungle "camo"
- foreach (PlayerControl player in CachedPlayer.AllPlayers)
+ foreach (PlayerControl player in PlayerControl.AllPlayerControls)
player.setLook("", 6, "", "", "", "");
}
}
if (Vampire.vampire == null) return;
- foreach (PlayerControl player in CachedPlayer.AllPlayers) {
+ foreach (PlayerControl player in PlayerControl.AllPlayerControls) {
if (player.PlayerId == targetId && !player.Data.IsDead) {
Vampire.bitten = player;
}
public static void trackerUsedTracker(byte targetId) {
Tracker.usedTracker = true;
- foreach (PlayerControl player in CachedPlayer.AllPlayers)
+ foreach (PlayerControl player in PlayerControl.AllPlayerControls)
if (player.PlayerId == targetId)
Tracker.tracked = player;
}
}
erasePlayerRoles(player.PlayerId, true);
Sidekick.sidekick = player;
- if (player.PlayerId == CachedPlayer.LocalPlayer.PlayerId) CachedPlayer.LocalPlayer.PlayerControl.moveable = true;
+ if (player.PlayerId == PlayerControl.LocalPlayer.PlayerId) PlayerControl.LocalPlayer.moveable = true;
if (wasSpy || wasImpostor) Sidekick.wasTeamRed = true;
Sidekick.wasSpy = wasSpy;
Sidekick.wasImpostor = wasImpostor;
- if (player == CachedPlayer.LocalPlayer.PlayerControl) SoundEffectsManager.play("jackalSidekick");
+ if (player == PlayerControl.LocalPlayer) SoundEffectsManager.play("jackalSidekick");
if (HandleGuesser.isGuesserGm && CustomOptionHolder.guesserGamemodeSidekickIsAlwaysGuesser.getBool() && !HandleGuesser.isGuesser(targetId))
setGuesserGm(targetId);
}
if (Vip.vip.Any(x => x.PlayerId == player.PlayerId)) Vip.vip.RemoveAll(x => x.PlayerId == player.PlayerId);
if (Invert.invert.Any(x => x.PlayerId == player.PlayerId)) Invert.invert.RemoveAll(x => x.PlayerId == player.PlayerId);
if (Chameleon.chameleon.Any(x => x.PlayerId == player.PlayerId)) Chameleon.chameleon.RemoveAll(x => x.PlayerId == player.PlayerId);
+ if (player == Armored.armored) Armored.clearAndReload();
}
}
position.x = BitConverter.ToSingle(buff, 0 * sizeof(float));
position.y = BitConverter.ToSingle(buff, 1 * sizeof(float));
new NinjaTrace(position, Ninja.traceTime);
- if (CachedPlayer.LocalPlayer.PlayerControl != Ninja.ninja)
+ if (PlayerControl.LocalPlayer != Ninja.ninja)
Ninja.ninjaMarked = null;
}
target.setLook("", 6, "", "", "", "");
Color color = Color.clear;
- bool canSee = CachedPlayer.LocalPlayer.Data.Role.IsImpostor || CachedPlayer.LocalPlayer.Data.IsDead;
+ bool canSee = PlayerControl.LocalPlayer.Data.Role.IsImpostor || PlayerControl.LocalPlayer.Data.IsDead;
if (canSee) color.a = 0.1f;
target.cosmetics.currentBodySprite.BodySprite.color = color;
target.cosmetics.colorBlindText.gameObject.SetActive(false);
public static void lightsOut() {
Trickster.lightsOutTimer = Trickster.lightsOutDuration;
// If the local player is impostor indicate lights out
- if(Helpers.hasImpVision(GameData.Instance.GetPlayerById(CachedPlayer.LocalPlayer.PlayerId))) {
+ if(Helpers.hasImpVision(GameData.Instance.GetPlayerById(PlayerControl.LocalPlayer.PlayerId))) {
new CustomMessage("Lights are out", Trickster.lightsOutDuration);
}
}
}
- if (CachedPlayer.LocalPlayer.PlayerControl == SecurityGuard.securityGuard) {
+ if (PlayerControl.LocalPlayer == SecurityGuard.securityGuard) {
camera.gameObject.SetActive(true);
camera.gameObject.GetComponent<SpriteRenderer>().color = new Color(1f, 1f, 1f, 0.5f);
} else {
if (vent == null) return;
SecurityGuard.remainingScrews -= SecurityGuard.ventPrice;
- if (CachedPlayer.LocalPlayer.PlayerControl == SecurityGuard.securityGuard) {
+ if (PlayerControl.LocalPlayer == SecurityGuard.securityGuard) {
PowerTools.SpriteAnim animator = vent.GetComponent<PowerTools.SpriteAnim>();
vent.EnterVentAnim = vent.ExitVentAnim = null;
public static void arsonistWin() {
Arsonist.triggerArsonistWin = true;
- foreach (PlayerControl p in CachedPlayer.AllPlayers) {
+ foreach (PlayerControl p in PlayerControl.AllPlayerControls) {
if (p != Arsonist.arsonist && !p.Data.IsDead) {
p.Exiled();
overrideDeathReasonAndKiller(p, DeadPlayer.CustomDeathReason.Arson, Arsonist.arsonist);
Pursuer.pursuer = player;
- if (player.PlayerId == CachedPlayer.LocalPlayer.PlayerId && client != null) {
+ if (player.PlayerId == PlayerControl.LocalPlayer.PlayerId && client != null) {
Transform playerInfoTransform = client.cosmetics.nameText.transform.parent.FindChild("Info");
TMPro.TextMeshPro playerInfo = playerInfoTransform != null ? playerInfoTransform.GetComponent<TMPro.TextMeshPro>() : null;
if (playerInfo != null) playerInfo.text = "";
bool lawyerDiedAdditionally = false;
if (Lawyer.lawyer != null && !Lawyer.isProsecutor && Lawyer.lawyer.PlayerId == killerId && Lawyer.target != null && Lawyer.target.PlayerId == dyingTargetId) {
// Lawyer guessed client.
- if (CachedPlayer.LocalPlayer.PlayerControl == Lawyer.lawyer) {
+ if (PlayerControl.LocalPlayer == Lawyer.lawyer) {
FastDestroyableSingleton<HudManager>.Instance.KillOverlay.ShowKillAnimation(Lawyer.lawyer.Data, Lawyer.lawyer.Data);
if (MeetingHudPatch.guesserUI != null) MeetingHudPatch.guesserUIExitButton.OnClick.Invoke();
}
MeetingHud.Instance.CheckForEndVoting();
}
if (FastDestroyableSingleton<HudManager>.Instance != null && guesser != null)
- if (CachedPlayer.LocalPlayer.PlayerControl == dyingTarget) {
+ if (PlayerControl.LocalPlayer == dyingTarget) {
FastDestroyableSingleton<HudManager>.Instance.KillOverlay.ShowKillAnimation(guesser.Data, dyingTarget.Data);
if (MeetingHudPatch.guesserUI != null) MeetingHudPatch.guesserUIExitButton.OnClick.Invoke();
- } else if (dyingLoverPartner != null && CachedPlayer.LocalPlayer.PlayerControl == dyingLoverPartner) {
+ } else if (dyingLoverPartner != null && PlayerControl.LocalPlayer == dyingLoverPartner) {
FastDestroyableSingleton<HudManager>.Instance.KillOverlay.ShowKillAnimation(dyingLoverPartner.Data, dyingLoverPartner.Data);
if (MeetingHudPatch.guesserUI != null) MeetingHudPatch.guesserUIExitButton.OnClick.Invoke();
}
PlayerControl guessedTarget = Helpers.playerById(guessedTargetId);
- if (CachedPlayer.LocalPlayer.Data.IsDead && guessedTarget != null && guesser != null) {
+ if (PlayerControl.LocalPlayer.Data.IsDead && guessedTarget != null && guesser != null) {
RoleInfo roleInfo = RoleInfo.allRoleInfos.FirstOrDefault(x => (byte)x.roleId == guessedRoleId);
string msg = $"{guesser.Data.PlayerName} guessed the role {roleInfo?.name ?? ""} for {guessedTarget.Data.PlayerName}!";
if (AmongUsClient.Instance.AmClient && FastDestroyableSingleton<HudManager>.Instance)
public static void huntedRewindTime(byte playerId) {
Hunted.timeshieldActive.Remove(playerId); // Shield is no longer active when rewinding
SoundEffectsManager.stop("timemasterShield"); // Shield sound stopped when rewinding
- if (playerId == CachedPlayer.LocalPlayer.PlayerControl.PlayerId) {
+ if (playerId == PlayerControl.LocalPlayer.PlayerId) {
resetHuntedRewindButton();
}
FastDestroyableSingleton<HudManager>.Instance.FullScreen.color = new Color(0f, 0.5f, 0.8f, 0.3f);
if (p == 1f) FastDestroyableSingleton<HudManager>.Instance.FullScreen.enabled = false;
})));
- if (!CachedPlayer.LocalPlayer.Data.Role.IsImpostor) return; // only rewind hunter
+ if (!PlayerControl.LocalPlayer.Data.Role.IsImpostor) return; // only rewind hunter
TimeMaster.isRewinding = true;
MapBehaviour.Instance.Close();
if (Minigame.Instance)
Minigame.Instance.ForceClose();
- CachedPlayer.LocalPlayer.PlayerControl.moveable = false;
+ PlayerControl.LocalPlayer.moveable = false;
}
public static void propHuntStartTimer(bool blackout = false) {
if (Chameleon.chameleon.Any(x => x.PlayerId == Yoyo.yoyo.PlayerId)) // Make the Yoyo visible if chameleon!
Chameleon.lastMoved[Yoyo.yoyo.PlayerId] = Time.time;
}
+
+ public static void breakArmor() {
+ if (Armored.armored == null || Armored.isBrokenArmor) return;
+ Armored.isBrokenArmor = true;
+ if (PlayerControl.LocalPlayer.Data.IsDead) {
+ Armored.armored.ShowFailedMurder();
+ }
+ }
}
[HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.HandleRpc))]
case (byte)CustomRPC.YoyoBlink:
RPCProcedure.yoyoBlink(reader.ReadByte() == byte.MaxValue, reader.ReadBytesAndSize());
break;
+ case (byte)CustomRPC.BreakArmor:
+ RPCProcedure.breakArmor();
+ break;
// Game mode
case (byte)CustomRPC.SetGuesserGm:
using System.Linq;
using System;
using System.Collections.Generic;
-using TheOtherRoles.Players;
+
using static TheOtherRoles.TheOtherRoles;
using UnityEngine;
using TheOtherRoles.Utilities;
public static RoleInfo vip = new RoleInfo("VIP", Color.yellow, "You are the VIP", "Everyone is notified when you die", RoleId.Vip, false, true);
public static RoleInfo invert = new RoleInfo("Invert", Color.yellow, "Your movement is inverted", "Your movement is inverted", RoleId.Invert, false, true);
public static RoleInfo chameleon = new RoleInfo("Chameleon", Color.yellow, "You're hard to see when not moving", "You're hard to see when not moving", RoleId.Chameleon, false, true);
+ public static RoleInfo armored = new RoleInfo("Armored", Color.yellow, "You are protected from one murder attempt", "You are protected from one murder attempt", RoleId.Armored, false, true);
public static RoleInfo shifter = new RoleInfo("Shifter", Color.yellow, "Shift your role", "Shift your role", RoleId.Shifter, false, true);
vip,
invert,
chameleon,
+ armored,
shifter
};
if (p == Mini.mini) infos.Add(mini);
if (Invert.invert.Any(x => x.PlayerId == p.PlayerId)) infos.Add(invert);
if (Chameleon.chameleon.Any(x => x.PlayerId == p.PlayerId)) infos.Add(chameleon);
+ if (p == Armored.armored) infos.Add(armored);
if (p == Shifter.shifter) infos.Add(shifter);
}
public static String GetRolesString(PlayerControl p, bool useColors, bool showModifier = true, bool suppressGhostInfo = false) {
string roleName;
roleName = String.Join(" ", getRoleInfoForPlayer(p, showModifier).Select(x => useColors ? Helpers.cs(x.color, x.name) : x.name).ToArray());
- if (Lawyer.target != null && p.PlayerId == Lawyer.target.PlayerId && CachedPlayer.LocalPlayer.PlayerControl != Lawyer.target)
+ if (Lawyer.target != null && p.PlayerId == Lawyer.target.PlayerId && PlayerControl.LocalPlayer != Lawyer.target)
roleName += (useColors ? Helpers.cs(Pursuer.color, " §") : " §");
- if (HandleGuesser.isGuesserGm && HandleGuesser.isGuesser(p.PlayerId)) roleName += " (Guesser)";
+ if (HandleGuesser.isGuesserGm && HandleGuesser.isGuesser(p.PlayerId)) {
+ int remainingShots = HandleGuesser.remainingShots(p.PlayerId);
+ var (playerCompleted, playerTotal) = TasksHandler.taskInfo(p.Data);
+ if (!Helpers.isEvil(p) && playerCompleted < HandleGuesser.tasksToUnlock || remainingShots == 0)
+ roleName += Helpers.cs(Color.gray, " (Guesser)");
+ else
+ roleName += Helpers.cs(Color.white," (Guesser)");
+ }
if (!suppressGhostInfo && p != null) {
- if (p == Shifter.shifter && (CachedPlayer.LocalPlayer.PlayerControl == Shifter.shifter || Helpers.shouldShowGhostInfo()) && Shifter.futureShift != null)
+ if (p == Shifter.shifter && (PlayerControl.LocalPlayer == Shifter.shifter || Helpers.shouldShowGhostInfo()) && Shifter.futureShift != null)
roleName += Helpers.cs(Color.yellow, " ← " + Shifter.futureShift.Data.PlayerName);
- if (p == Vulture.vulture && (CachedPlayer.LocalPlayer.PlayerControl == Vulture.vulture || Helpers.shouldShowGhostInfo()))
+ if (p == Vulture.vulture && (PlayerControl.LocalPlayer == Vulture.vulture || Helpers.shouldShowGhostInfo()))
roleName = roleName + Helpers.cs(Vulture.color, $" ({Vulture.vultureNumberToWin - Vulture.eatenBodies} left)");
if (Helpers.shouldShowGhostInfo()) {
if (Eraser.futureErased.Contains(p))
if (Arsonist.dousedPlayers.Contains(p))
roleName = Helpers.cs(Arsonist.color, "♨ ") + roleName;
if (p == Arsonist.arsonist)
- roleName = roleName + Helpers.cs(Arsonist.color, $" ({CachedPlayer.AllPlayers.Count(x => { return x.PlayerControl != Arsonist.arsonist && !x.Data.IsDead && !x.Data.Disconnected && !Arsonist.dousedPlayers.Any(y => y.PlayerId == x.PlayerId); })} left)");
+ roleName = roleName + Helpers.cs(Arsonist.color, $" ({PlayerControl.AllPlayerControls.ToArray().Count(x => { return x != Arsonist.arsonist && !x.Data.IsDead && !x.Data.Disconnected && !Arsonist.dousedPlayers.Any(y => y.PlayerId == x.PlayerId); })} left)");
if (p == Jackal.fakeSidekick)
roleName = Helpers.cs(Sidekick.color, $" (fake SK)") + roleName;
using System.Text;
using UnityEngine;
using System.Linq;
+using Reactor.Utilities.Extensions;
namespace TheOtherRoles
{
soundEffects = new Dictionary<string, AudioClip>();
Assembly assembly = Assembly.GetExecutingAssembly();
string[] resourceNames = assembly.GetManifestResourceNames();
+
+ /* Old way of loading .raw files. Left here for reference -Gendelo
foreach (string resourceName in resourceNames)
{
- if (resourceName.Contains("TheOtherRoles.Resources.SoundEffects.") && resourceName.Contains(".raw"))
+ if (resourceName.Contains("TheOtherRoles.Resources.SoundEffects.") && (resourceName.Contains(".raw") || resourceName.Contains(".ogg")))
{
soundEffects.Add(resourceName, Helpers.loadAudioClipFromResources(resourceName));
}
+ }*/
+
+ var resourceBundle = assembly.GetManifestResourceStream("TheOtherRoles.Resources.SoundEffects.toraudio");
+ var assetBundle = AssetBundle.LoadFromMemory(resourceBundle.ReadFully());
+ foreach (var f in assetBundle.GetAllAssetNames()) {
+ soundEffects.Add(f, assetBundle.LoadAsset<AudioClip>(f).DontUnload());
}
+ assetBundle.Unload(false);
+
}
public static AudioClip get(string path)
{
// Convenience: As as SoundEffects are stored in the same folder, allow using just the name as well
- if (!path.Contains(".")) path = "TheOtherRoles.Resources.SoundEffects." + path + ".raw";
+ //if (!path.Contains(".")) path = "TheOtherRoles.Resources.SoundEffects." + path + ".raw";
+ path = "assets/audio/" + path.ToLower() + ".ogg";
AudioClip returnValue;
return soundEffects.TryGetValue(path, out returnValue) ? returnValue : null;
}
source.Stop();
}
float distance, volume;
- distance = Vector2.Distance(position, Players.CachedPlayer.LocalPlayer.PlayerControl.GetTruePosition());
+ distance = Vector2.Distance(position, PlayerControl.LocalPlayer.GetTruePosition());
if (distance < range)
volume = (1f - distance / range);
else
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using TheOtherRoles.Patches;
-using TheOtherRoles.Players;
+
using UnityEngine;
using Object = UnityEngine.Object;
public static void ChangeFloor(bool toUpper) {
if (!Loaded) return;
- MonoBehaviour _floorHandler = ((Component)GetFloorHandlerMethod.Invoke(null, new object[] { CachedPlayer.LocalPlayer.PlayerControl })).TryCast(FloorHandlerType) as MonoBehaviour;
+ MonoBehaviour _floorHandler = ((Component)GetFloorHandlerMethod.Invoke(null, new object[] { PlayerControl.LocalPlayer })).TryCast(FloorHandlerType) as MonoBehaviour;
RpcRequestChangeFloorMethod.Invoke(_floorHandler, new object[] { toUpper });
}
if (!Loaded) return;
try {
ShipStatus.Instance.RpcRepairSystem((SystemTypes)130, 64);
- RepairDamageMethod.Invoke(SubmarineOxygenSystemInstanceField.Invoke(null, Array.Empty<object>()), new object[] { CachedPlayer.LocalPlayer.PlayerControl, 64 });
+ RepairDamageMethod.Invoke(SubmarineOxygenSystemInstanceField.Invoke(null, Array.Empty<object>()), new object[] { PlayerControl.LocalPlayer, 64 });
}
catch (System.NullReferenceException) {
TheOtherRolesPlugin.Logger.LogMessage("null reference in engineer oxygen fix");
public static Tuple<int, int> taskInfo(NetworkedPlayerInfo playerInfo) {
int TotalTasks = 0;
int CompletedTasks = 0;
- if (!playerInfo.Disconnected && playerInfo.Tasks != null &&
+ if (playerInfo != null && !playerInfo.Disconnected && playerInfo.Tasks != null &&
playerInfo.Object &&
playerInfo.Role && playerInfo.Role.TasksCountTowardProgress &&
!playerInfo.Object.hasFakeTasks() && !playerInfo.Role.IsImpostor
using System.Collections.Generic;
using UnityEngine;
using TheOtherRoles.Objects;
-using TheOtherRoles.Players;
+
using TheOtherRoles.Utilities;
using TheOtherRoles.CustomGameModes;
using static TheOtherRoles.TheOtherRoles;
Vip.clearAndReload();
Invert.clearAndReload();
Chameleon.clearAndReload();
+ Armored.clearAndReload();
// Gamemodes
HandleGuesser.clearAndReload();
public static void setHandcuffedKnows(bool active = true, byte playerId = Byte.MaxValue)
{
if (playerId == Byte.MaxValue)
- playerId = CachedPlayer.LocalPlayer.PlayerId;
+ playerId = PlayerControl.LocalPlayer.PlayerId;
- if (active && playerId == CachedPlayer.LocalPlayer.PlayerId) {
- MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.ShareGhostInfo, Hazel.SendOption.Reliable, -1);
- writer.Write(CachedPlayer.LocalPlayer.PlayerId);
+ if (active && playerId == PlayerControl.LocalPlayer.PlayerId) {
+ MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ShareGhostInfo, Hazel.SendOption.Reliable, -1);
+ writer.Write(PlayerControl.LocalPlayer.PlayerId);
writer.Write((byte)RPCProcedure.GhostInfoTypes.HandcuffNoticed);
AmongUsClient.Instance.FinishRpcImmediately(writer);
}
handcuffedPlayers.RemoveAll(x => x == playerId);
}
- if (playerId == CachedPlayer.LocalPlayer.PlayerId) {
+ if (playerId == PlayerControl.LocalPlayer.PlayerId) {
HudManagerStartPatch.setAllButtonsHandcuffedStatus(active);
SoundEffectsManager.play("deputyHandcuff");
}
bool isMorphedMorphling = target == Morphling.morphling && Morphling.morphTarget != null && Morphling.morphTimer > 0f;
if (Medic.shielded != null && ((target == Medic.shielded && !isMorphedMorphling) || (isMorphedMorphling && Morphling.morphTarget == Medic.shielded))) {
hasVisibleShield = Medic.showShielded == 0 || Helpers.shouldShowGhostInfo() // Everyone or Ghost info
- || (Medic.showShielded == 1 && (CachedPlayer.LocalPlayer.PlayerControl == Medic.shielded || CachedPlayer.LocalPlayer.PlayerControl == Medic.medic)) // Shielded + Medic
- || (Medic.showShielded == 2 && CachedPlayer.LocalPlayer.PlayerControl == Medic.medic); // Medic only
+ || (Medic.showShielded == 1 && (PlayerControl.LocalPlayer == Medic.shielded || PlayerControl.LocalPlayer == Medic.medic)) // Shielded + Medic
+ || (Medic.showShielded == 2 && PlayerControl.LocalPlayer == Medic.medic); // Medic only
// Make shield invisible till after the next meeting if the option is set (the medic can already see the shield)
- hasVisibleShield = hasVisibleShield && (Medic.meetingAfterShielding || !Medic.showShieldAfterMeeting || CachedPlayer.LocalPlayer.PlayerControl == Medic.medic || Helpers.shouldShowGhostInfo());
+ hasVisibleShield = hasVisibleShield && (Medic.meetingAfterShielding || !Medic.showShieldAfterMeeting || PlayerControl.LocalPlayer == Medic.medic || Helpers.shouldShowGhostInfo());
}
return hasVisibleShield;
}
public static void resetCamouflage() {
camouflageTimer = 0f;
- foreach (PlayerControl p in CachedPlayer.AllPlayers) {
+ foreach (PlayerControl p in PlayerControl.AllPlayerControls) {
if (p == Ninja.ninja && Ninja.isInvisble)
continue;
p.setDefaultLook();
}
public static bool dousedEveryoneAlive() {
- return CachedPlayer.AllPlayers.All(x => { return x.PlayerControl == Arsonist.arsonist || x.Data.IsDead || x.Data.Disconnected || Arsonist.dousedPlayers.Any(y => y.PlayerId == x.PlayerId); });
+ return PlayerControl.AllPlayerControls.ToArray().All(x => { return x == Arsonist.arsonist || x.Data.IsDead || x.Data.Disconnected || Arsonist.dousedPlayers.Any(y => y.PlayerId == x.PlayerId); });
}
public static void clearAndReload() {
chanceAdditionalInfo = CustomOptionHolder.mediumChanceAdditionalInfo.getSelection() / 10f;
}
- public static string getInfo(PlayerControl target, PlayerControl killer) {
+ public static string getInfo(PlayerControl target, PlayerControl killer, DeadPlayer.CustomDeathReason deathReason) {
string msg = "";
List<SpecialMediumInfo> infos = new List<SpecialMediumInfo>();
// collect fitting death info types.
// suicides:
if (killer == target) {
- if (target == Sheriff.sheriff || target == Sheriff.formerSheriff) infos.Add(SpecialMediumInfo.SheriffSuicide);
+ if ((target == Sheriff.sheriff || target == Sheriff.formerSheriff) && deathReason != DeadPlayer.CustomDeathReason.LoverSuicide) infos.Add(SpecialMediumInfo.SheriffSuicide);
if (target == Lovers.lover1 || target == Lovers.lover2) infos.Add(SpecialMediumInfo.PassiveLoverSuicide);
- if (target == Thief.thief) infos.Add(SpecialMediumInfo.ThiefSuicide);
- if (target == Warlock.warlock) infos.Add(SpecialMediumInfo.WarlockSuicide);
+ if (target == Thief.thief && deathReason != DeadPlayer.CustomDeathReason.LoverSuicide) infos.Add(SpecialMediumInfo.ThiefSuicide);
+ if (target == Warlock.warlock && deathReason != DeadPlayer.CustomDeathReason.LoverSuicide) infos.Add(SpecialMediumInfo.WarlockSuicide);
} else {
if (target == Lovers.lover1 || target == Lovers.lover2) infos.Add(SpecialMediumInfo.ActiveLoverDies);
if (target.Data.Role.IsImpostor && killer.Data.Role.IsImpostor && Thief.formerThief != killer) infos.Add(SpecialMediumInfo.ImpostorTeamkill);
public static void setPosition() {
if (position == Vector3.zero) return; // Check if this has been set, otherwise first spawn on submerged will fail
- if (antiTeleport.FindAll(x => x.PlayerId == CachedPlayer.LocalPlayer.PlayerId).Count > 0) {
- CachedPlayer.LocalPlayer.NetTransform.RpcSnapTo(position);
+ if (antiTeleport.FindAll(x => x.PlayerId == PlayerControl.LocalPlayer.PlayerId).Count > 0) {
+ PlayerControl.LocalPlayer.NetTransform.RpcSnapTo(position);
if (SubmergedCompatibility.IsSubmerged) {
SubmergedCompatibility.ChangeFloor(position.y > -7);
}
}
}
+ public static class Armored {
+ public static PlayerControl armored;
+
+ public static bool isBrokenArmor = false;
+
+ public static void clearAndReload() {
+ armored = null;
+ isBrokenArmor = false;
+ }
+ }
+
public static class Shifter {
public static PlayerControl shifter;
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
- <Version>4.6.0</Version>
+ <Version>4.7.0</Version>
<Description>TheOtherRoles</Description>
<Authors>Eisbison</Authors>
<LangVersion>latest</LangVersion>
</ItemGroup>
<ItemGroup>
- <PackageReference Include="AmongUs.GameLibs.Steam" Version="2024.6.18" />
+ <PackageReference Include="AmongUs.GameLibs.Steam" Version="2024.10.29" />
<PackageReference Include="BepInEx.IL2CPP.MSBuild" Version="2.1.0-rc.1" />
- <PackageReference Include="BepInEx.Unity.IL2CPP" Version="6.0.0-be.692" />
- <PackageReference Include="Reactor" Version="2.2.0" />
+ <PackageReference Include="BepInEx.Unity.IL2CPP" Version="6.0.0-be.697" />
+ <PackageReference Include="Reactor" Version="2.3.1" />
</ItemGroup>
+ <ItemGroup>
+ <Folder Include="Players\" />
+ </ItemGroup>
+
<Target Name="Date" BeforeTargets="BeforeBuild"> <!--Will make the compile time available s.t. we can let betas expire-->
<WriteLinesToFile File="$(IntermediateOutputPath)gen.cs" Lines="static partial class Builtin { public static long CompileTime = $([System.DateTime]::UtcNow.Ticks) %3B }" Overwrite="true" />
<ItemGroup>
using UnityEngine;
using TheOtherRoles;
using TheOtherRoles.Patches;
-using TheOtherRoles.Players;
+
using static TheOtherRoles.TheOtherRoles;
using System.Linq;
using InnerNet;
public static bool killsThroughShield = true;
public static bool evilGuesserCanGuessSpy = true;
public static bool guesserCantGuessSnitch = false;
+ public static int tasksToUnlock = Mathf.RoundToInt(CustomOptionHolder.guesserGamemodeCrewGuesserNumberOfTasks.getFloat());
public static Sprite getTargetSprite() {
if (targetSprite) return targetSprite;
hasMultipleShotsPerMeeting = CustomOptionHolder.guesserGamemodeHasMultipleShotsPerMeeting.getBool();
killsThroughShield = CustomOptionHolder.guesserGamemodeKillsThroughShield.getBool();
evilGuesserCanGuessSpy = CustomOptionHolder.guesserGamemodeEvilCanKillSpy.getBool();
+ tasksToUnlock = Mathf.RoundToInt(CustomOptionHolder.guesserGamemodeCrewGuesserNumberOfTasks.getFloat());
} else {
guesserCantGuessSnitch = CustomOptionHolder.guesserCantGuessSnitchIfTaksDone.getBool();
hasMultipleShotsPerMeeting = CustomOptionHolder.guesserHasMultipleShotsPerMeeting.getBool();
"net6.0": {
"AmongUs.GameLibs.Steam": {
"type": "Direct",
- "requested": "[2024.6.18, )",
- "resolved": "2024.6.18",
- "contentHash": "xb+HP1xXn4/ES8AgXpk9xeoW568LFYw5NTjY6bHwd6vQjHDf2kT1xHMmQ1me5Vfee/Gp69YIMZDXUAUToG7Elg=="
+ "requested": "[2024.10.29, )",
+ "resolved": "2024.10.29",
+ "contentHash": "znuLMD9DRMTp7RMfIz3hts5KUljioPZ1TiuodgyFrH3mDEcOLZtn1sA08AU9pUzsgQA9hzikrrzP+sJIsPqZ9g=="
},
"BepInEx.IL2CPP.MSBuild": {
"type": "Direct",
},
"BepInEx.Unity.IL2CPP": {
"type": "Direct",
- "requested": "[6.0.0-be.692, )",
- "resolved": "6.0.0-be.692",
- "contentHash": "rYjnJCN2APD/04dZUKhRCbu30jhzseIKd0+pfaWWgfDJNggd8rq+whEzM/ZC0fEkkLgcIkEgbtX2LuSqsCrIgg==",
- "dependencies": {
- "BepInEx.Core": "6.0.0-be.692",
- "BepInEx.Unity.Common": "6.0.0-be.692",
- "HarmonyX": "2.10.1",
- "Iced": "1.20.0",
+ "requested": "[6.0.0-be.697, )",
+ "resolved": "6.0.0-be.697",
+ "contentHash": "+ahFT8WkKZ8m9NCdXgQI05M34/mdE1MXmLnLRKhqpjId6mqDQf9ORJ1bCPifdkbgYJjteIvey9EreCfmD9Vndw==",
+ "dependencies": {
+ "BepInEx.Core": "6.0.0-be.697",
+ "BepInEx.Unity.Common": "6.0.0-be.697",
+ "HarmonyX": "2.10.2",
+ "Iced": "1.21.0",
"Il2CppInterop.Generator": "1.4.6-ci.426",
"Il2CppInterop.HarmonySupport": "1.4.6-ci.426",
"Il2CppInterop.Runtime": "1.4.6-ci.426",
},
"Reactor": {
"type": "Direct",
- "requested": "[2.2.0, )",
- "resolved": "2.2.0",
- "contentHash": "foMHya01tmr//3tw+kO7FmY1ojnR0m+ShMU6sxogbnWeO85lmX3QM8aSIsYeAhtJSThf6Ben6iTM4O0KgVcmqw==",
+ "requested": "[2.3.1, )",
+ "resolved": "2.3.1",
+ "contentHash": "CsFs84aM3PA6+74TzHEAUayXOosYBJEJKf1Ebs3CpL10RMLrj+WRAWrpgFoNd9qS+pIzQflW76Q5Pgg/aOQ40w==",
"dependencies": {
- "BepInEx.Unity.IL2CPP": "6.0.0-be.670"
+ "BepInEx.Unity.IL2CPP": "6.0.0-be.679"
}
},
"AsmResolver": {
},
"AssetRipper.Primitives": {
"type": "Transitive",
- "resolved": "3.1.1",
- "contentHash": "GhFAVMWpG8MyZscQxwYCd1HSS36UhIQeW0Gn9iPYiininZWlo8RTV9tGYv0CNNXw5bODYJtXf4qiqo6sQOVAEg=="
+ "resolved": "3.1.3",
+ "contentHash": "djZbN/+EXmI+Oia9Pm0LyjZVCPLf60TPSL5rGb7mBEYM5F4CN3nPFXvl2yA5LanPZoHS1Yq7PghGUmkP7Pv9RQ=="
},
"BepInEx.Core": {
"type": "Transitive",
- "resolved": "6.0.0-be.692",
- "contentHash": "I/JuhVhOXUFRrSxy7MqMHpygKoYNt39XY5V8e7PTLbq+nfCBGYzOhszcPx90Wj5xGPx6IFuABJocWAbFDHUddA==",
+ "resolved": "6.0.0-be.697",
+ "contentHash": "6p/zLtBja8BEA5+FwFwH1lUg8avO725mZKRw0P1JbuXj/XUZL8Qy5n0c7COiq/dJ58nCyW5J/ldeYUHM0c4vRA==",
"dependencies": {
- "HarmonyX": "2.10.1",
+ "HarmonyX": "2.10.2",
"MonoMod.Utils": "22.5.1.1",
"SemanticVersioning": "2.0.2"
}
},
"BepInEx.Unity.Common": {
"type": "Transitive",
- "resolved": "6.0.0-be.692",
- "contentHash": "QYsp8Sf4kQwmx4qwFLhS7SW+Dp67iBibb0zo5IdMQXGmS0KY2WH7/SZ+fFmG6ce06BT+E58wsxk0rU6NW0qWbg==",
+ "resolved": "6.0.0-be.697",
+ "contentHash": "6eTjN4vBy7veWUwCVWqfvL05fQ4MskpjD4wIsD0FF8g0kF/1lKjsK0Fmyb4N78vSrvm/tV1quhHChCh2SQU0GQ==",
"dependencies": {
- "AssetRipper.Primitives": "3.1.1",
+ "AssetRipper.Primitives": "3.1.3",
"MonoMod.Utils": "22.5.1.1"
}
},
},
"HarmonyX": {
"type": "Transitive",
- "resolved": "2.10.1",
- "contentHash": "9LodMC9Y0u1TW96eKJoWrFJFpmzbgojEO38/Q+e7c1mFPhmHt8xcR8qhI06iF1rf0Dnsk+hqENFVSgbtwl/bEw==",
+ "resolved": "2.10.2",
+ "contentHash": "/5WwkxXX8mPsRuigQt957rJGx1f0dDQxk+bvk4yYITKFjXas9Em+O71zEP8X0ym8OFQQ2XH/2SxS4NC7vEC+Xg==",
"dependencies": {
"MonoMod.RuntimeDetour": "22.3.23.4",
"System.Reflection.Emit": "4.7.0"
},
"Iced": {
"type": "Transitive",
- "resolved": "1.20.0",
- "contentHash": "cjk+vNDIatLI5vQ22tOCAzsgowZ32Ob1Fy4ljQSfqfzMe5ATKXU+dMPRE6+cIUUFetoyyWkUJArJoxe3QwDXAA=="
+ "resolved": "1.21.0",
+ "contentHash": "dv5+81Q1TBQvVMSOOOmRcjJmvWcX3BZPZsIq31+RLc5cNft0IHAyNlkdb7ZarOWG913PyBoFDsDXoCIlKmLclg=="
},
"Il2CppInterop.Common": {
"type": "Transitive",