Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
8 changes: 4 additions & 4 deletions source/Patches/CrewmateRoles/DetectiveMod/PerformKill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,23 @@ public static bool Prefix(KillButton __instance)
PlayerControl.LocalPlayer.GetTruePosition()) > maxDistance) return false;
if (role.ClosestPlayer == null) return false;
var interact = Utils.Interact(PlayerControl.LocalPlayer, role.ClosestPlayer);
if (interact[4] == true)
if (interact.AbilityUsed)
{
if (role.DetectedKillers.Contains(role.ClosestPlayer.PlayerId) || (CustomGameOptions.CanDetectLastKiller && role.LastKiller == role.ClosestPlayer)) Coroutines.Start(Utils.FlashCoroutine(Color.red));
else Coroutines.Start(Utils.FlashCoroutine(Color.green));
}
if (interact[0] == true)
if (interact.FullCooldownReset)
{
role.LastExamined = DateTime.UtcNow;
return false;
}
else if (interact[1] == true)
else if (interact.GaReset)
{
role.LastExamined = DateTime.UtcNow;
role.LastExamined = role.LastExamined.AddSeconds(CustomGameOptions.ProtectKCReset - CustomGameOptions.ExamineCd);
return false;
}
else if (interact[3] == true) return false;
else if (interact.ZeroSecReset) return false;
return false;
}
else
Expand Down
2 changes: 1 addition & 1 deletion source/Patches/CrewmateRoles/MedicMod/Protect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static bool Prefix(KillButton __instance)
if (role.StartTimer() > 0) return false;

var interact = Utils.Interact(PlayerControl.LocalPlayer, role.ClosestPlayer);
if (interact[4] == true)
if (interact.AbilityUsed)
{
Utils.Rpc(CustomRPC.Protect, PlayerControl.LocalPlayer.PlayerId, role.ClosestPlayer.PlayerId);

Expand Down
8 changes: 4 additions & 4 deletions source/Patches/CrewmateRoles/OracleMod/PerformKill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static bool Prefix(KillButton __instance)
if (role.ClosestPlayer == null) return false;

var interact = Utils.Interact(PlayerControl.LocalPlayer, role.ClosestPlayer);
if (interact[4] == true)
if (interact.AbilityUsed)
{
role.Confessor = role.ClosestPlayer;
bool showsCorrectFaction = true;
Expand Down Expand Up @@ -55,18 +55,18 @@ public static bool Prefix(KillButton __instance)
else role.RevealedFaction = Faction.Impostors;
Utils.Rpc(CustomRPC.Confess, PlayerControl.LocalPlayer.PlayerId, role.Confessor.PlayerId, faction);
}
if (interact[0] == true)
if (interact.FullCooldownReset)
{
role.LastConfessed = DateTime.UtcNow;
return false;
}
else if (interact[1] == true)
else if (interact.GaReset)
{
role.LastConfessed = DateTime.UtcNow;
role.LastConfessed = role.LastConfessed.AddSeconds(CustomGameOptions.ProtectKCReset - CustomGameOptions.ConfessCd);
return false;
}
else if (interact[3] == true) return false;
else if (interact.ZeroSecReset) return false;
return false;
}
}
Expand Down
8 changes: 4 additions & 4 deletions source/Patches/CrewmateRoles/SeerMod/PerformKill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,22 @@ public static bool Prefix(KillButton __instance)
if (role.ClosestPlayer == null) return false;

var interact = Utils.Interact(PlayerControl.LocalPlayer, role.ClosestPlayer);
if (interact[4] == true)
if (interact.AbilityUsed)
{
role.Investigated.Add(role.ClosestPlayer.PlayerId);
}
if (interact[0] == true)
if (interact.FullCooldownReset)
{
role.LastInvestigated = DateTime.UtcNow;
return false;
}
else if (interact[1] == true)
else if (interact.GaReset)
{
role.LastInvestigated = DateTime.UtcNow;
role.LastInvestigated = role.LastInvestigated.AddSeconds(CustomGameOptions.ProtectKCReset - CustomGameOptions.SeerCd);
return false;
}
else if (interact[3] == true) return false;
else if (interact.ZeroSecReset) return false;
return false;
}
}
Expand Down
8 changes: 4 additions & 4 deletions source/Patches/CrewmateRoles/TrackerMod/PerformKill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static bool Prefix(KillButton __instance)
if (!role.ButtonUsable) return false;

var interact = Utils.Interact(PlayerControl.LocalPlayer, role.ClosestPlayer);
if (interact[4] == true)
if (interact.AbilityUsed)
{
var gameObj = new GameObject();
var arrow = gameObj.AddComponent<ArrowBehaviour>();
Expand All @@ -53,18 +53,18 @@ public static bool Prefix(KillButton __instance)
role.TrackerArrows.Add(target.PlayerId, arrow);
role.UsesLeft--;
}
if (interact[0] == true)
if (interact.FullCooldownReset)
{
role.LastTracked = DateTime.UtcNow;
return false;
}
else if (interact[1] == true)
else if (interact.GaReset)
{
role.LastTracked = DateTime.UtcNow;
role.LastTracked = role.LastTracked.AddSeconds(CustomGameOptions.ProtectKCReset - CustomGameOptions.TrackCd);
return false;
}
else if (interact[3] == true) return false;
else if (interact.ZeroSecReset) return false;
return false;
}
}
Expand Down
14 changes: 7 additions & 7 deletions source/Patches/CrewmateRoles/VampireHunterMod/PerformKill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,39 +27,39 @@ public static bool Prefix(KillButton __instance)
if (!role.ClosestPlayer.Is(RoleEnum.Vampire))
{
var interact = Utils.Interact(PlayerControl.LocalPlayer, role.ClosestPlayer);
if (interact[0] == true)
if (interact.FullCooldownReset)
{
role.LastStaked = DateTime.UtcNow;
role.UsesLeft--;
if (role.UsesLeft == 0 && role.CorrectKills == 0 && CustomGameOptions.SelfKillAfterFinalStake)
Utils.RpcMurderPlayer(PlayerControl.LocalPlayer, PlayerControl.LocalPlayer);
return false;
}
else if (interact[1] == true)
else if (interact.GaReset)
{
role.LastStaked = DateTime.UtcNow;
role.LastStaked = role.LastStaked.AddSeconds(CustomGameOptions.ProtectKCReset - CustomGameOptions.StakeCd);
return false;
}
else if (interact[3] == true) return false;
else if (interact.ZeroSecReset) return false;
return false;
}
else
{
var interact = Utils.Interact(PlayerControl.LocalPlayer, role.ClosestPlayer, true);
if (interact[4] == true) return false;
else if (interact[0] == true)
if (interact.AbilityUsed) return false;
else if (interact.FullCooldownReset)
{
role.LastStaked = DateTime.UtcNow;
return false;
}
else if (interact[1] == true)
else if (interact.GaReset)
{
role.LastStaked = DateTime.UtcNow;
role.LastStaked = role.LastStaked.AddSeconds(CustomGameOptions.ProtectKCReset - CustomGameOptions.StakeCd);
return false;
}
else if (interact[3] == true) return false;
else if (interact.ZeroSecReset) return false;
return false;
}
}
Expand Down
17 changes: 8 additions & 9 deletions source/Patches/CultistRoles/WhispererMod/PerformKill.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using HarmonyLib;
using Hazel;
using TownOfUs.Roles;
using TownOfUs.Roles.Cultist;
using UnityEngine;
Expand Down Expand Up @@ -31,16 +30,16 @@ public static bool Prefix(KillButton __instance)
var closestPlayers = Utils.GetClosestPlayers(truePosition, CustomGameOptions.WhisperRadius, false);
if (role.PlayerConversion.Count == 0) role.PlayerConversion = role.GetPlayers();
var oldStats = role.PlayerConversion;
role.PlayerConversion = new List<(PlayerControl, int)>();
role.PlayerConversion = new();
foreach (var conversionRate in oldStats)
{
var player = conversionRate.Item1;
var stats = conversionRate.Item2;
var player = conversionRate.Player;
var stats = conversionRate.UnconvertableChance;
if (closestPlayers.Contains(player))
{
stats -= role.WhisperConversion;
}
if (!player.Data.IsDead) role.PlayerConversion.Add((player, stats));
if (!player.Data.IsDead) role.PlayerConversion.Add(new(player, stats));
}
role.WhisperCount += 1;
role.LastWhispered = DateTime.UtcNow;
Expand All @@ -52,17 +51,17 @@ public static bool Prefix(KillButton __instance)

public static void CheckConversion(Whisperer role)
{
var removals = new List<(PlayerControl, int)>();
var removals = new List<ConversionData>();
foreach (var playerConversion in role.PlayerConversion)
{
if (playerConversion.Item2 <= 0)
if (playerConversion.UnconvertableChance <= 0)
{
Utils.Convert(playerConversion.Item1);
Utils.Convert(playerConversion.Player);
role.ConversionCount += 1;
role.WhisperConversion -= CustomGameOptions.DecreasedPercentagePerConversion;
if (role.WhisperConversion < 5) role.WhisperConversion = 5;

Utils.Rpc(CustomRPC.Convert, playerConversion.Item1.PlayerId);
Utils.Rpc(CustomRPC.Convert, playerConversion.Player.PlayerId);
removals.Add(playerConversion);
}
}
Expand Down
11 changes: 5 additions & 6 deletions source/Patches/CultistRoles/WhispererMod/TargetColor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using TownOfUs.Roles;
using TownOfUs.Roles.Cultist;
using UnityEngine;
using static UnityEngine.ParticleSystem.PlaybackState;

namespace TownOfUs.CultistRoles.WhispererMod
{
Expand Down Expand Up @@ -31,8 +30,8 @@ private static void UpdateMeeting(MeetingHud __instance)
{
foreach (var state in __instance.playerStates)
{
if (stats.Item1.PlayerId != state.TargetPlayerId) continue;
float color = stats.Item2 / 100f;
if (stats.Player.PlayerId != state.TargetPlayerId) continue;
float color = stats.UnconvertableChance / 100f;
if (color <= 0) state.NameText.color = Patches.Colors.Impostor;
else state.NameText.color = new Color(1f, 1f, color, 1f);
}
Expand Down Expand Up @@ -61,9 +60,9 @@ private static void Postfix(HudManager __instance)

foreach (var stats in role.PlayerConversion)
{
float color = stats.Item2/100f;
if (color <= 0) stats.Item1.nameText().color = Patches.Colors.Impostor;
else stats.Item1.nameText().color = new Color(1f, 1f, color, 1f);
float color = stats.UnconvertableChance/100f;
if (color <= 0) stats.Player.nameText().color = Patches.Colors.Impostor;
else stats.Player.nameText().color = new Color(1f, 1f, color, 1f);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion source/Patches/ImpostorRoles/BlackmailerMod/PerformKill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static bool Prefix(KillButton __instance)
if (role.BlackmailTimer() != 0) return false;

var interact = Utils.Interact(PlayerControl.LocalPlayer, target);
if (interact[4] == true)
if (interact.AbilityUsed)
{
role.Blackmailed?.myRend().material.SetFloat("_Outline", 0f);
if (role.Blackmailed != null && role.Blackmailed.Data.IsImpostor())
Expand Down
4 changes: 1 addition & 3 deletions source/Patches/ImpostorRoles/MinerMod/PerformKill.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
using System;
using System.Linq;
using HarmonyLib;
using Hazel;
using TownOfUs.Patches;
using TownOfUs.Roles;
using UnityEngine;
using Object = UnityEngine.Object;
using Reactor.Networking.Extensions;

namespace TownOfUs.ImpostorRoles.MinerMod
{
Expand All @@ -26,7 +24,7 @@ public static bool Prefix(KillButton __instance)
if (!__instance.isActiveAndEnabled) return false;
if (!role.CanPlace) return false;
if (role.MineTimer() != 0) return false;
if (SubmergedCompatibility.GetPlayerElevator(PlayerControl.LocalPlayer).Item1) return false;
if (SubmergedCompatibility.GetPlayerElevator(PlayerControl.LocalPlayer).AtTopFloor) return false;
var position = PlayerControl.LocalPlayer.transform.position;
var id = GetAvailableId();
Utils.Rpc(CustomRPC.Mine, id, PlayerControl.LocalPlayer.PlayerId, position, position.z + 0.001f);
Expand Down
16 changes: 8 additions & 8 deletions source/Patches/NeutralRoles/ArsonistMod/PerformKill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ public static bool Prefix(KillButton __instance)
if (!role.DousedPlayers.Contains(role.ClosestPlayerIgnite.PlayerId)) return false;

var interact2 = Utils.Interact(PlayerControl.LocalPlayer, role.ClosestPlayerIgnite);
if (interact2[4] == true) role.Ignite();
if (interact2[0] == true)
if (interact2.AbilityUsed) role.Ignite();
if (interact2.FullCooldownReset)
{
role.LastDoused = DateTime.UtcNow;
return false;
}
else if (interact2[1] == true)
else if (interact2.GaReset)
{
role.LastDoused = DateTime.UtcNow;
role.LastDoused.AddSeconds(CustomGameOptions.ProtectKCReset - CustomGameOptions.DouseCd);
return false;
}
else if (interact2[3] == true) return false;
else if (interact2.ZeroSecReset) return false;
return false;
}
else return false;
Expand All @@ -57,19 +57,19 @@ public static bool Prefix(KillButton __instance)
if (!flag2) return false;
if (role.DousedPlayers.Contains(role.ClosestPlayerDouse.PlayerId)) return false;
var interact = Utils.Interact(PlayerControl.LocalPlayer, role.ClosestPlayerDouse);
if (interact[4] == true) role.DousedPlayers.Add(role.ClosestPlayerDouse.PlayerId);
if (interact[0] == true)
if (interact.AbilityUsed) role.DousedPlayers.Add(role.ClosestPlayerDouse.PlayerId);
if (interact.FullCooldownReset)
{
role.LastDoused = DateTime.UtcNow;
return false;
}
else if (interact[1] == true)
else if (interact.GaReset)
{
role.LastDoused = DateTime.UtcNow;
role.LastDoused.AddSeconds(CustomGameOptions.ProtectKCReset - CustomGameOptions.DouseCd);
return false;
}
else if (interact[3] == true) return false;
else if (interact.ZeroSecReset) return false;
return false;
}
}
Expand Down
8 changes: 4 additions & 4 deletions source/Patches/NeutralRoles/DoomsayerMod/PerformKill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,22 @@ public static bool Prefix(KillButton __instance)
GameOptionsData.KillDistances[GameOptionsManager.Instance.currentNormalGameOptions.KillDistance];
if (!flag3) return false;
var interact = Utils.Interact(PlayerControl.LocalPlayer, role.ClosestPlayer);
if (interact[4] == true)
if (interact.AbilityUsed)
{
role.LastObservedPlayer = role.ClosestPlayer;
}
if (interact[0] == true)
if (interact.FullCooldownReset)
{
role.LastObserved = DateTime.UtcNow;
return false;
}
else if (interact[1] == true)
else if (interact.GaReset)
{
role.LastObserved = DateTime.UtcNow;
role.LastObserved = role.LastObserved.AddSeconds(CustomGameOptions.ProtectKCReset - CustomGameOptions.ObserveCooldown);
return false;
}
else if (interact[3] == true) return false;
else if (interact.ZeroSecReset) return false;
return false;
}
}
Expand Down
10 changes: 5 additions & 5 deletions source/Patches/NeutralRoles/JuggernautMod/PerformKill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,25 @@ public static bool Prefix(KillButton __instance)
GameOptionsData.KillDistances[GameOptionsManager.Instance.currentNormalGameOptions.KillDistance];
if (!flag3) return false;
var interact = Utils.Interact(PlayerControl.LocalPlayer, role.ClosestPlayer, true);
if (interact[4] == true) return false;
else if (interact[0] == true)
if (interact.AbilityUsed) return false;
else if (interact.FullCooldownReset)
{
role.LastKill = DateTime.UtcNow;
return false;
}
else if (interact[1] == true)
else if (interact.GaReset)
{
role.LastKill = DateTime.UtcNow;
role.LastKill = role.LastKill.AddSeconds(-(CustomGameOptions.JuggKCd - CustomGameOptions.ReducedKCdPerKill * role.JuggKills) + CustomGameOptions.ProtectKCReset);
return false;
}
else if (interact[2] == true)
else if (interact.SurvReset)
{
role.LastKill = DateTime.UtcNow;
role.LastKill = role.LastKill.AddSeconds(-(CustomGameOptions.JuggKCd - CustomGameOptions.ReducedKCdPerKill * role.JuggKills) + CustomGameOptions.VestKCReset);
return false;
}
else if (interact[3] == true) return false;
else if (interact.ZeroSecReset) return false;
return false;
}
}
Expand Down
Loading