Skip to content

Commit

Permalink
Version 2.9.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Eisbison committed Nov 6, 2021
1 parent 14f185f commit f60d070
Show file tree
Hide file tree
Showing 10 changed files with 108 additions and 136 deletions.
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ The [Role Assignment](#role-assignment) sections explains how the roles are bein
# Releases
| Among Us - Version| Mod Version | Link |
|----------|-------------|-----------------|
| 2021.6.30s| v2.9.1| [Download](https://github.com/Eisbison/TheOtherRoles/releases/download/v2.9.1/TheOtherRoles.zip)
| 2021.6.30s| v2.9.0| [Download](https://github.com/Eisbison/TheOtherRoles/releases/download/v2.9.0/TheOtherRoles.zip)
| 2021.6.30s| v2.8.1| [Download](https://github.com/Eisbison/TheOtherRoles/releases/download/v2.8.1/TheOtherRoles.zip)
| 2021.6.30s| v2.8.0| [Download](https://github.com/Eisbison/TheOtherRoles/releases/download/v2.8.0/TheOtherRoles.zip)
Expand Down Expand Up @@ -77,6 +78,14 @@ The [Role Assignment](#role-assignment) sections explains how the roles are bein
<details>
<summary>Click to show the Changelog</summary>

**Version 2.9.1**
- Fixed a bug where [Camouflager](#camouflager) & [Morphling](#morphling) caused performance issues
- Fixed a bug where [Medium](#medium) did not exlude the Evil [Mini](#mini)
- [Vulture](#vulture) "Number Of Corpses Needed To Be Eaten" max value extended to 10
- Added Vulture Option: "Show Arrows Pointing Towards The Corpes"
- Removed Medium Question: "What is your name?" (name of the soul is added after each question)


**Version 2.9.0**
- **New Role:** [Medium](#medium)
- **New Role:** [Vulture](#vulture)
Expand Down Expand Up @@ -418,6 +427,7 @@ docker run -d -p 22023:22023/udp --env IMPOSTOR_AntiCheat__Enabled=false --env I
[TownOfUs](https://github.com/slushiegoose/Town-Of-Us) - Idea for the Swapper, Shifter, Arsonist and a similar Mayor role come from **Slushiegoose**\
[Ottomated](https://twitter.com/ottomated_) - Idea for the Morphling, Snitch and Camouflager role come from **Ottomated**\
[Crowded-Mod](https://github.com/CrowdedMods/CrowdedMod) - Our implementation for 10+ player lobbies is inspired by the one from the **Crowded Mod Team**\
[Goose-Goose-Duck](https://store.steampowered.com/app/1568590/Goose_Goose_Duck) - Idea for the Vulture role come from **Slushygoose**

# Settings
The mod adds a few new settings to Among Us (in addition to the role settings):
Expand Down Expand Up @@ -1155,7 +1165,7 @@ Created by [Mallöris](https://github.com/Mallaris)\
\
The medium is a crewmate who can ask the souls of dead players for information. Like the Seer, it sees the places where the players have died (after the next meeting) and can question them. It then gets random information about the soul or the killer in the chat. The souls only stay for one round, i.e. until the next meeting. Depending on the options, the souls can only be questioned once and then disappear.

Questions: What is your name?
Questions:
What is your Role?
What is your killer's color type?
When did you die?
Expand All @@ -1164,7 +1174,7 @@ What is your killers role? (mini exluded)
### Game Options
| Name | Description
|----------|:-------------:|
| Bait Spawn Chance | -
| Medium Spawn Chance | -
| Medium Cooldown | -
| Medium Duration | The time it takes to question a soul
| Medium Each Soul Can Only Be Questioned Once | If set to true, souls can only be questioned once and then disappear
Expand All @@ -1177,7 +1187,7 @@ Created by [Mallöris](https://github.com/Mallaris)\
\
The Vulture does not have any tasks, he has to win the game as a solo.\
The Vulture is a neutral role that must eat a specified number of corpses (depending on the options) in order to win.\
When a player dies, the Vulture gets an arrow pointing to the corpse.
Depending on the options, when a player dies, the Vulture gets an arrow pointing to the corpse.

### Game Options
| Name | Description |
Expand All @@ -1186,6 +1196,7 @@ When a player dies, the Vulture gets an arrow pointing to the corpse.
| Vulture Countdown | -
| Number Of Corpses Needed To Be Eaten | Corpes needed to be eaten to win the game
| Vulture Can Use Vents | -
| Show Arrows Pointing Towards The Corpes | -
-----------------------

# Source code
Expand Down
15 changes: 8 additions & 7 deletions TheOtherRoles/Buttons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -859,15 +859,16 @@ public static void Postfix(HudManager __instance)
if (Medium.target == null || Medium.target.player == null) return;
string msg = "";

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

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


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

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

Expand Down
4 changes: 3 additions & 1 deletion TheOtherRoles/CustomOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ public class CustomOptionHolder {
public static CustomOption vultureCooldown;
public static CustomOption vultureNumberToWin;
public static CustomOption vultureCanUseVents;
public static CustomOption vultureShowArrows;

public static CustomOption mediumSpawnRate;
public static CustomOption mediumCooldown;
Expand Down Expand Up @@ -283,8 +284,9 @@ public static void Load() {

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

shifterSpawnRate = CustomOption.Create(70, cs(Shifter.color, "Shifter"), rates, null, true);
shifterShiftsModifiers = CustomOption.Create(71, "Shifter Shifts Modifiers", false, shifterSpawnRate);
Expand Down
69 changes: 46 additions & 23 deletions TheOtherRoles/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,29 +78,6 @@ public static Dictionary<byte, PlayerControl> allPlayersById()
return res;
}

public static void setSkinWithAnim(PlayerPhysics playerPhysics, uint SkinId) {
SkinData nextSkin = DestroyableSingleton<HatManager>.Instance.AllSkins[(int)SkinId];
AnimationClip clip = null;
var spriteAnim = playerPhysics.Skin.animator;
var anim = spriteAnim.m_animator;
var skinLayer = playerPhysics.Skin;

var currentPhysicsAnim = playerPhysics.Animator.GetCurrentAnimation();
if (currentPhysicsAnim == playerPhysics.RunAnim) clip = nextSkin.RunAnim;
else if (currentPhysicsAnim == playerPhysics.SpawnAnim) clip = nextSkin.SpawnAnim;
else if (currentPhysicsAnim == playerPhysics.EnterVentAnim) clip = nextSkin.EnterVentAnim;
else if (currentPhysicsAnim == playerPhysics.ExitVentAnim) clip = nextSkin.ExitVentAnim;
else if (currentPhysicsAnim == playerPhysics.IdleAnim) clip = nextSkin.IdleAnim;
else clip = nextSkin.IdleAnim;

float progress = playerPhysics.Animator.m_animator.GetCurrentAnimatorStateInfo(0).normalizedTime;
skinLayer.skin = nextSkin;

spriteAnim.Play(clip, 1f);
anim.Play("a", 0, progress % 1);
anim.Update(0f);
}

public static bool handleMurderAttempt(PlayerControl target, bool isMeetingStart = false) {
// Block impostor shielded kill
if (Medic.shielded != null && Medic.shielded == target) {
Expand Down Expand Up @@ -248,5 +225,51 @@ public static KeyValuePair<byte, int> MaxPair(this Dictionary<byte, int> self, o
}
return result;
}

public static bool hidePlayerName(PlayerControl source, PlayerControl target) {
if (!MapOptions.hidePlayerNames) return false; // All names are visible
else if (source == null || target == null) return true;
else if (source == target) return false; // Player sees his own name
else if (source.Data.IsImpostor && (target.Data.IsImpostor || target == Spy.spy)) return false; // Members of team Impostors see the names of Impostors/Spies
else if ((source == Lovers.lover1 || source == Lovers.lover2) && (target == Lovers.lover1 || target == Lovers.lover2)) return false; // Members of team Lovers see the names of each other
else if ((source == Jackal.jackal || source == Sidekick.sidekick) && (target == Jackal.jackal || target == Sidekick.sidekick || target == Jackal.fakeSidekick)) return false; // Members of team Jackal see the names of each other
return true;
}

public static void setDefaultLook(this PlayerControl target) {
target.setLook(target.Data.PlayerName, target.Data.ColorId, target.Data.HatId, target.Data.SkinId, target.Data.PetId);
}

public static void setLook(this PlayerControl target, String playerName, int colorId, uint hatId, uint skinId, uint petId) {
target.nameText.text = hidePlayerName(PlayerControl.LocalPlayer, target) ? "" : playerName;
target.myRend.material.SetColor("_BackColor", Palette.ShadowColors[colorId]);
target.myRend.material.SetColor("_BodyColor", Palette.PlayerColors[colorId]);
target.HatRenderer.SetHat(hatId, colorId);
target.nameText.transform.localPosition = new Vector3(0f, ((hatId == 0U) ? 0.7f : 1.05f) * 2f, -0.5f);

SkinData nextSkin = DestroyableSingleton<HatManager>.Instance.AllSkins[(int)skinId];
PlayerPhysics playerPhysics = target.MyPhysics;
AnimationClip clip = null;
var spriteAnim = playerPhysics.Skin.animator;
var currentPhysicsAnim = playerPhysics.Animator.GetCurrentAnimation();
if (currentPhysicsAnim == playerPhysics.RunAnim) clip = nextSkin.RunAnim;
else if (currentPhysicsAnim == playerPhysics.SpawnAnim) clip = nextSkin.SpawnAnim;
else if (currentPhysicsAnim == playerPhysics.EnterVentAnim) clip = nextSkin.EnterVentAnim;
else if (currentPhysicsAnim == playerPhysics.ExitVentAnim) clip = nextSkin.ExitVentAnim;
else if (currentPhysicsAnim == playerPhysics.IdleAnim) clip = nextSkin.IdleAnim;
else clip = nextSkin.IdleAnim;
float progress = playerPhysics.Animator.m_animator.GetCurrentAnimatorStateInfo(0).normalizedTime;
playerPhysics.Skin.skin = nextSkin;
spriteAnim.Play(clip, 1f);
spriteAnim.m_animator.Play("a", 0, progress % 1);
spriteAnim.m_animator.Update(0f);

if (target.CurrentPet) UnityEngine.Object.Destroy(target.CurrentPet.gameObject);
target.CurrentPet = UnityEngine.Object.Instantiate<PetBehaviour>(DestroyableSingleton<HatManager>.Instance.AllPets[(int)petId]);
target.CurrentPet.transform.position = target.transform.position;
target.CurrentPet.Source = target;
target.CurrentPet.Visible = target.Visible;
PlayerControl.SetPlayerMaterialColors(colorId, target.CurrentPet.rend);
}
}
}
2 changes: 1 addition & 1 deletion TheOtherRoles/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace TheOtherRoles
public class TheOtherRolesPlugin : BasePlugin
{
public const string Id = "me.eisbison.theotherroles";
public const string VersionString = "2.9.0";
public const string VersionString = "2.9.1";
public static System.Version Version = System.Version.Parse(VersionString);

public Harmony Harmony { get; } = new Harmony(Id);
Expand Down
25 changes: 24 additions & 1 deletion TheOtherRoles/Patches/PlayerControlPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ static void baitUpdate() {
}
}
static void vultureUpdate() {
if (Vulture.vulture == null || PlayerControl.LocalPlayer != Vulture.vulture || Vulture.localArrows == null) 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>();
Expand Down Expand Up @@ -602,6 +602,27 @@ public static void mediumSetTarget() {
Medium.target = target;
}

static void morphlingAndCamouflagerUpdate() {
float oldCamouflageTimer = Camouflager.camouflageTimer;
float oldMorphTimer = Morphling.morphTimer;
Camouflager.camouflageTimer = Mathf.Max(0f, Camouflager.camouflageTimer - Time.fixedDeltaTime);
Morphling.morphTimer = Mathf.Max(0f, Morphling.morphTimer - Time.fixedDeltaTime);


// Camouflage reset and set Morphling look if necessary
if (oldCamouflageTimer > 0f && Camouflager.camouflageTimer <= 0f) {
Camouflager.resetCamouflage();
if (Morphling.morphTimer > 0f && Morphling.morphling != null && Morphling.morphTarget != null) {
PlayerControl target = Morphling.morphTarget;
Morphling.morphling.setLook(target.Data.PlayerName, target.Data.ColorId, target.Data.HatId, target.Data.SkinId, target.Data.PetId);
}
}

// Morphling reset (only if camouflage is inactive)
if (Camouflager.camouflageTimer <= 0f && oldMorphTimer > 0f && Morphling.morphTimer <= 0f && Morphling.morphling != null)
Morphling.resetMorph();
}

public static void Postfix(PlayerControl __instance) {
if (AmongUsClient.Instance.GameState != InnerNet.InnerNetClient.GameStates.Started) return;

Expand Down Expand Up @@ -665,6 +686,8 @@ public static void Postfix(PlayerControl __instance) {
vultureUpdate();
// Medium
mediumSetTarget();
// Morphling and Camouflager
morphlingAndCamouflagerUpdate();
}
}
}
Expand Down
Loading

0 comments on commit f60d070

Please sign in to comment.