Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ChaosTokens/Buttons/TokenKillButton.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using AmongUs.GameOptions;
using ChaosTokens.Modifiers.Effects;
using ChaosTokens.Modifiers.Effects;
using MiraAPI.GameOptions;
using MiraAPI.Hud;
using MiraAPI.Modifiers;
Expand Down Expand Up @@ -53,6 +52,7 @@ public override bool Enabled(RoleBehaviour role)

protected override void FixedUpdate(PlayerControl playerControl)
{
if (!Button) return;
Button.graphic.sprite = HudManager.Instance?.KillButton?.graphic?.sprite ?? MiraAssets.Empty.LoadAsset();
Button.graphic.color = ChaosTokensPlugin.MainColor;
}
Expand Down
2 changes: 1 addition & 1 deletion ChaosTokens/ChaosTokens.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<DebugType>embedded</DebugType>

<Authors>Chipseq</Authors>
<Version>1.1.1</Version>
<Version>1.1.2</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
18 changes: 14 additions & 4 deletions ChaosTokens/ChaosTokensRpc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,11 @@
Reroll();
break;
}
if (player.HasModifier<TokenInvisible>())
{
Reroll();
break;
}

player.RpcAddModifier<TokenTransparent>(Random.RandomRange(0f, 0.8f));
break;
Expand Down Expand Up @@ -256,6 +261,11 @@
Reroll();
break;
}
if (player.HasModifier<TokenTransparent>())
{
Reroll();
break;
}

player.RpcAddModifier<TokenInvisible>();
break;
Expand Down Expand Up @@ -310,9 +320,6 @@
player.RpcAddModifier<TokenDrunk>();
break;
case ChaosEffects.FakeRevealSelf:
// The player will reveal as ANY role
// disabled, vanilla, ghost roles included
// why? because it's funny
if (player.HasModifier<TokenReveal>())
{
Reroll();
Expand All @@ -325,7 +332,10 @@
break;
}

player.RpcAddModifier<TokenReveal>(RoleManager.Instance.AllRoles.Random().Role, player.Data.PlayerId);
var validRoles = CustomRoleManager.CustomMiraRoles
.Where(r => r.Team != player.GetTownOfUsRole()?.Team)
.Select(r => (r as RoleBehaviour).Role);
player.RpcAddModifier<TokenReveal>(validRoles.Random(), player.Data.PlayerId);
break;
case ChaosEffects.Hyperactive:
if (player.HasModifier<TokenHyperactive>())
Expand All @@ -340,7 +350,7 @@
Reroll();
break;

if (player.HasModifier<TokenColorblind>() || player.HasModifier<TokenNausea>())

Check warning on line 353 in ChaosTokens/ChaosTokensRpc.cs

View workflow job for this annotation

GitHub Actions / build

Unreachable code detected

Check warning on line 353 in ChaosTokens/ChaosTokensRpc.cs

View workflow job for this annotation

GitHub Actions / build

Unreachable code detected

Check warning on line 353 in ChaosTokens/ChaosTokensRpc.cs

View workflow job for this annotation

GitHub Actions / build

Unreachable code detected

Check warning on line 353 in ChaosTokens/ChaosTokensRpc.cs

View workflow job for this annotation

GitHub Actions / build

Unreachable code detected
{
Reroll();
break;
Expand Down
16 changes: 15 additions & 1 deletion ChaosTokens/DebugMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,25 @@ public void WindowFunction(int windowID)
GUILayout.Space(5f);
GUILayout.Label("Effects");

var player = PlayerControl.LocalPlayer;
foreach (var modifier in ModifierManager.Modifiers.OfType<TokenEffect>())
{
if (GUILayout.Button(modifier.ModifierName.Replace("Token ", string.Empty)))
{
ChaosTokensRpc.ApplyEffect(PlayerControl.LocalPlayer, modifier.Effect);
ChaosTokensRpc.ApplyEffect(player, modifier.Effect);
}

if (modifier.ModifierName == "Token Reveal")
{
if (GUILayout.Button("Fake Reveal") && !player.HasModifier<TokenReveal>())
{
ChaosTokensRpc.ApplyEffect(player, ChaosEffects.FakeRevealSelf);
}

if (GUILayout.Button("Random Person Reveal"))
{
ChaosTokensRpc.ApplyEffect(player, ChaosEffects.RevealRandom);
}
}
}

Expand Down
21 changes: 12 additions & 9 deletions ChaosTokens/Modifiers/Effects/TokenHyperactive.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,21 @@ public override void FixedUpdate()
{
EffectActive = !EffectActive;
}
foreach (var ability in CustomButtonManager.Buttons)

if (Player.AmOwner)
{
random = Random.RandomRangeInt(1, 100);
if (random == 1)
foreach (var ability in CustomButtonManager.Buttons)
{
if (!ability.Button.isActiveAndEnabled) continue;
if (ability.Location == ButtonLocation.BottomLeft) continue; // not the best solution, but stops modifier buttons from being pressed
if (!ability.CanClick()) continue;
if (ability.EffectActive) continue;
random = Random.RandomRangeInt(1, 100);
if (random == 1)
{
if (!ability.Button?.isActiveAndEnabled ?? false) continue;
if (ability.Location == ButtonLocation.BottomLeft) continue; // not the best solution, but stops modifier buttons from being pressed
if (!ability.CanClick()) continue;
if (ability.EffectActive) continue;

ability.ClickHandler();
ability.ClickHandler();
}
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions ChaosTokens/Modifiers/Effects/TokenInvisible.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using Reactor.Utilities;
using TownOfUs.Modifiers.Game.Universal;
using TownOfUs.Roles.Impostor;
using TownOfUs.Utilities;
Expand All @@ -11,7 +10,7 @@ public sealed class TokenInvisible : TokenEffect
{
public override ChaosEffects Effect => ChaosEffects.Invisible;
public override string ModifierName => "Token Invisible";
public override string Notification => "You have now become... invisible?";
public override string Notification => "You have now become... invisible?"; // no one got the reference :cry:
public override bool Negative => false;

private const float InvisDelay = 1f;
Expand Down
25 changes: 24 additions & 1 deletion ChaosTokens/Modifiers/Effects/TokenMedium.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
using System.Linq;
using System.Collections;
using System.Linq;
using HarmonyLib;
using MiraAPI.Modifiers;
using Reactor.Utilities;
using Reactor.Utilities.Extensions;
using TownOfUs;
using TownOfUs.Utilities;
using UnityEngine;

namespace ChaosTokens.Modifiers.Effects;

Expand All @@ -23,6 +29,12 @@ public override void OnActivate()
.Where(x => !x.HasModifier<VisibleGhost>())
.Do(x => x.AddModifier<VisibleGhost>());
}

if (PlayerControl.LocalPlayer.HasDied())
{
Coroutines.Start(MiscUtils.CoFlash(ChaosTokensPlugin.MainColor, 2));
Coroutines.Start(CoArrow(Player));
}
}

public override void OnDeactivate()
Expand All @@ -36,4 +48,15 @@ public override void OnDeactivate()
.Do(x => x.RemoveModifier<VisibleGhost>());
}
}

private static IEnumerator CoArrow(PlayerControl player)
{
var arrow = MiscUtils.CreateArrow(player.transform, TownOfUsColors.Medium);
for (float time = 0; time <= 2; time += Time.deltaTime)
{
arrow.target = player.GetTruePosition();
yield return new WaitForEndOfFrame();
}
arrow.gameObject.Destroy();
}
}
13 changes: 10 additions & 3 deletions ChaosTokens/Modifiers/Effects/TokenOneTimeKill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,19 @@ public class TokenOneTimeKill : TokenEffect
public override void OnActivate()
{
base.OnActivate();
CustomButtonSingleton<TokenKillButton>.Instance.SetTimer(10f);
CustomButtonSingleton<TokenKillButton>.Instance.Button.gameObject.SetActive(true);

if (Player.AmOwner)
{
CustomButtonSingleton<TokenKillButton>.Instance.SetTimer(10f);
CustomButtonSingleton<TokenKillButton>.Instance.Button.gameObject.SetActive(true);
}
}

public override void OnDeactivate()
{
CustomButtonSingleton<TokenKillButton>.Instance.Button.gameObject.SetActive(false);
if (Player.AmOwner)
{
CustomButtonSingleton<TokenKillButton>.Instance.Button.gameObject.SetActive(false);
}
}
}
14 changes: 11 additions & 3 deletions ChaosTokens/Modifiers/Effects/TokenReveal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class TokenReveal(RoleTypes role, byte source) : TokenEffect<RoleReveal>(
public override bool LinkToAditional => true;

public bool FakeReveal { get; protected set; }
private bool _ghostInfoUpdated = false;

public override void OnActivate()
{
Expand All @@ -24,17 +25,17 @@ public override void OnActivate()
if (Player.AmOwner && FakeReveal)
{
Utils.Notification("<b>You have been revealed to everyone as a random role!</b>");

AdditionalModifier.ExtraRoleText = " <i><color=red>(fake)</color></i>";
AdditionalModifier.ExtraRoleText = " <size=50%><i><color=red>(fake)</color></i></size>";
return;
}

if (Player.AmOwner)
{
Utils.Notification("<b>Your role has been revealed to everyone!</b>");
AdditionalModifier.ExtraRoleText = " <size=50%><i><color=red>(revealed)</color></i></size>";
return;
}

if (AdditionalModifier?.RevealSource?.AmOwner ?? false)
{
Utils.Notification("<b>You revealed the role of a random person!</b>");
Expand All @@ -47,5 +48,12 @@ public override void Update()
{
MeetingMenu.Instances.Do(x => x.HideSingle(Player.PlayerId));
}

if (!_ghostInfoUpdated && FakeReveal && PlayerControl.LocalPlayer.HasDied())
{
_ghostInfoUpdated = true;
AdditionalModifier.ExtraRoleText = $" <size=50%><i><color=red>(revealed as {AdditionalModifier.ShownRole?.NiceName})</color></i></size>";
AdditionalModifier.ShownRole = Player.GetRoleWhenAlive();
}
}
}
7 changes: 6 additions & 1 deletion ChaosTokens/Modifiers/VisibleGhost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public sealed class VisibleGhost : BaseModifier
{
public override string ModifierName => "Visible Ghost";
public override bool HideOnUi => true;

public override void FixedUpdate()
{
if (!Player.Data.IsDead)
Expand All @@ -17,4 +17,9 @@ public override void FixedUpdate()

Player.Visible = true;
}

public override void OnDeactivate()
{
Player.Visible = false;
}
}