diff --git a/GameMode/FFAManager.cs b/GameMode/FFAManager.cs index 53b76e115..111ca90ca 100644 --- a/GameMode/FFAManager.cs +++ b/GameMode/FFAManager.cs @@ -1,8 +1,8 @@ -using HarmonyLib; -using Hazel; -using System; +using System; using System.Collections.Generic; using System.Linq; +using HarmonyLib; +using Hazel; using TOHE.Modules; using UnityEngine; using static TOHE.Translator; diff --git a/GameMode/HotPotatoManager.cs b/GameMode/HotPotatoManager.cs index b43c5ea2f..63e8cd674 100644 --- a/GameMode/HotPotatoManager.cs +++ b/GameMode/HotPotatoManager.cs @@ -1,7 +1,7 @@ -using HarmonyLib; -using System; +using System; using System.Collections.Generic; using System.Linq; +using HarmonyLib; using UnityEngine; namespace TOHE diff --git a/GameMode/MoveAndStopManager.cs b/GameMode/MoveAndStopManager.cs index bd5fbd950..5ddef50b8 100644 --- a/GameMode/MoveAndStopManager.cs +++ b/GameMode/MoveAndStopManager.cs @@ -1,7 +1,7 @@ -using HarmonyLib; -using System; +using System; using System.Collections.Generic; using System.Linq; +using HarmonyLib; using TOHE.Roles.AddOns.Common; using UnityEngine; using static TOHE.Translator; diff --git a/GameMode/SoloKombatManager.cs b/GameMode/SoloKombatManager.cs index ba2dab5e5..07465028f 100644 --- a/GameMode/SoloKombatManager.cs +++ b/GameMode/SoloKombatManager.cs @@ -1,8 +1,8 @@ -using HarmonyLib; -using Hazel; -using System; +using System; using System.Collections.Generic; using System.Linq; +using HarmonyLib; +using Hazel; using TOHE.Modules; using TOHE.Roles.Neutral; using UnityEngine; diff --git a/Modules/AntiBlackout.cs b/Modules/AntiBlackout.cs index 9407fc9c4..8a03dbc42 100644 --- a/Modules/AntiBlackout.cs +++ b/Modules/AntiBlackout.cs @@ -1,8 +1,8 @@ -using AmongUs.GameOptions; -using Hazel; using System.Collections.Generic; using System.Linq; using System.Runtime.CompilerServices; +using AmongUs.GameOptions; +using Hazel; using TOHE.Modules; namespace TOHE; @@ -118,33 +118,33 @@ public static class AntiBlackout SendGameData(); } - /* - /// - ///Run the code with IsDead temporarily restored to its original value - ///Execution details - /// - public static void TempRestore(Action action) +/* + /// + ///Run the code with IsDead temporarily restored to its original value + ///Execution details + /// + public static void TempRestore(Action action) + { + Logger.Info("==Temp Restore=="); + //Whether TempRestore was executed with IsDead overwritten + bool before_IsCached = IsCached; + try { - Logger.Info("==Temp Restore=="); - //Whether TempRestore was executed with IsDead overwritten - bool before_IsCached = IsCached; - try - { - if (before_IsCached) RestoreIsDead(doSend: false); - action(); - } - catch (Exception ex) - { - Logger.Warn("An exception occurred within AntiBlackout.TempRestore"); - Logger.Exception(ex); - } - finally - { - if (before_IsCached) SetIsDead(doSend: false); - Logger.Info("==/Temp Restore=="); - } + if (before_IsCached) RestoreIsDead(doSend: false); + action(); } - */ + catch (Exception ex) + { + Logger.Warn("An exception occurred within AntiBlackout.TempRestore"); + Logger.Exception(ex); + } + finally + { + if (before_IsCached) SetIsDead(doSend: false); + Logger.Info("==/Temp Restore=="); + } + } +*/ public static void Reset() { diff --git a/Modules/BanManager.cs b/Modules/BanManager.cs index 477c11b8c..c4399ca07 100644 --- a/Modules/BanManager.cs +++ b/Modules/BanManager.cs @@ -1,5 +1,3 @@ -using HarmonyLib; -using InnerNet; using System; using System.Collections.Generic; using System.IO; @@ -8,6 +6,8 @@ using System.Reflection; using System.Security.Cryptography; using System.Text; using System.Text.RegularExpressions; +using HarmonyLib; +using InnerNet; using static TOHE.Translator; namespace TOHE; diff --git a/Modules/Camouflague.cs b/Modules/Camouflague.cs index bd0ab2e6e..0d05e79fc 100644 --- a/Modules/Camouflague.cs +++ b/Modules/Camouflague.cs @@ -1,5 +1,6 @@ -using AmongUs.Data; using System.Collections.Generic; +using System.Linq; +using AmongUs.Data; using TOHE.Roles.Impostor; using TOHE.Roles.Neutral; diff --git a/Modules/ClientOptionItem.cs b/Modules/ClientOptionItem.cs index ea3ed40b8..f747f993a 100644 --- a/Modules/ClientOptionItem.cs +++ b/Modules/ClientOptionItem.cs @@ -1,5 +1,5 @@ -using BepInEx.Configuration; -using System; +using System; +using BepInEx.Configuration; using UnityEngine; using Object = UnityEngine.Object; diff --git a/Modules/Cloud.cs b/Modules/Cloud.cs index f0bcf53fe..cb4be4ef4 100644 --- a/Modules/Cloud.cs +++ b/Modules/Cloud.cs @@ -1,9 +1,9 @@ -using HarmonyLib; -using System; +using System; using System.IO; using System.Net.Sockets; using System.Reflection; using System.Text; +using HarmonyLib; namespace TOHE; diff --git a/Modules/CustomRoleSelector.cs b/Modules/CustomRoleSelector.cs index 2fec64ce6..5d9ba3c9d 100644 --- a/Modules/CustomRoleSelector.cs +++ b/Modules/CustomRoleSelector.cs @@ -1,7 +1,7 @@ -using AmongUs.GameOptions; -using HarmonyLib; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; +using AmongUs.GameOptions; +using HarmonyLib; using TOHE.Roles.Impostor; namespace TOHE.Modules; diff --git a/Modules/CustomRolesHelper.cs b/Modules/CustomRolesHelper.cs index 176332c12..45307b14e 100644 --- a/Modules/CustomRolesHelper.cs +++ b/Modules/CustomRolesHelper.cs @@ -1,9 +1,8 @@ -using AmongUs.GameOptions; using System.Linq; +using AmongUs.GameOptions; using TOHE.Roles.Crewmate; using TOHE.Roles.Impostor; using TOHE.Roles.Neutral; -using UnityEngine; namespace TOHE; @@ -1356,42 +1355,7 @@ internal static class CustomRolesHelper _ => role.Is(Team.Impostor) ? CountTypes.Impostor : CountTypes.Crew }; - public static RoleOptionType GetRoleOptionType(this CustomRoles role) - { - if (role.IsImpostor()) return RoleOptionType.Impostor; - if (role.IsCrewmate()) return role.GetDYRole() == RoleTypes.Impostor ? RoleOptionType.Crewmate_ImpostorBased : RoleOptionType.Crewmate_Normal; - if (role.IsNeutral()) return role.IsNK() ? RoleOptionType.Neutral_Killing : RoleOptionType.Neutral_NonKilling; - return RoleOptionType.Crewmate_Normal; - } - - public static Color GetRoleOptionTypeColor(this RoleOptionType type) => type switch - { - RoleOptionType.Impostor => Palette.ImpostorRed, - RoleOptionType.Crewmate_Normal => Palette.CrewmateBlue, - RoleOptionType.Crewmate_ImpostorBased => Utils.GetRoleColor(CustomRoles.Sheriff), - RoleOptionType.Neutral_NonKilling => Utils.GetRoleColor(CustomRoles.Sprayer), - RoleOptionType.Neutral_Killing => Utils.GetRoleColor(CustomRoles.Traitor), - _ => Utils.GetRoleColor(CustomRoles.SwordsMan) - }; - - public static TabGroup GetTabFromOptionType(this RoleOptionType type) => type switch - { - RoleOptionType.Impostor => TabGroup.ImpostorRoles, - RoleOptionType.Crewmate_Normal => TabGroup.CrewmateRoles, - RoleOptionType.Crewmate_ImpostorBased => TabGroup.CrewmateRoles, - RoleOptionType.Neutral_NonKilling => TabGroup.NeutralRoles, - RoleOptionType.Neutral_Killing => TabGroup.NeutralRoles, - _ => TabGroup.OtherRoles - }; -} - -public enum RoleOptionType -{ - Impostor, - Crewmate_Normal, - Crewmate_ImpostorBased, - Neutral_NonKilling, - Neutral_Killing + public static bool HasSubRole(this PlayerControl pc) => Main.PlayerStates[pc.PlayerId].SubRoles.Count > 0; } public enum CustomRoleTypes diff --git a/Modules/CustomRpcSender.cs b/Modules/CustomRpcSender.cs index d57f5c3ba..bd365f295 100644 --- a/Modules/CustomRpcSender.cs +++ b/Modules/CustomRpcSender.cs @@ -1,9 +1,9 @@ +using System; +using System.Diagnostics.CodeAnalysis; using AmongUs.GameOptions; using Hazel; using Il2CppInterop.Runtime.InteropTypes.Arrays; using InnerNet; -using System; -using System.Diagnostics.CodeAnalysis; namespace TOHE; diff --git a/Modules/CustomSounds.cs b/Modules/CustomSounds.cs index 7641396af..a8f5794e4 100644 --- a/Modules/CustomSounds.cs +++ b/Modules/CustomSounds.cs @@ -1,8 +1,8 @@ -using Hazel; -using System; +using System; using System.IO; using System.Reflection; using System.Runtime.InteropServices; +using Hazel; namespace TOHE.Modules; diff --git a/Modules/CustomWinnerHolder.cs b/Modules/CustomWinnerHolder.cs index 06229fa9a..81822326d 100644 --- a/Modules/CustomWinnerHolder.cs +++ b/Modules/CustomWinnerHolder.cs @@ -1,5 +1,5 @@ -using Hazel; using System.Collections.Generic; +using Hazel; namespace TOHE; diff --git a/Modules/DisableDevice.cs b/Modules/DisableDevice.cs index 6444bfe85..c724a4e15 100644 --- a/Modules/DisableDevice.cs +++ b/Modules/DisableDevice.cs @@ -1,6 +1,6 @@ -using HarmonyLib; using System; using System.Collections.Generic; +using HarmonyLib; using UnityEngine; using Object = UnityEngine.Object; diff --git a/Modules/EAC.cs b/Modules/EAC.cs index 34164c9bb..57df892c4 100644 --- a/Modules/EAC.cs +++ b/Modules/EAC.cs @@ -1,10 +1,10 @@ -using AmongUs.GameOptions; -using Hazel; -using InnerNet; -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; +using AmongUs.GameOptions; +using Hazel; +using InnerNet; using TOHE.Modules; using static TOHE.Translator; diff --git a/Modules/ErrorText.cs b/Modules/ErrorText.cs index 58535402e..fd49ee2c6 100644 --- a/Modules/ErrorText.cs +++ b/Modules/ErrorText.cs @@ -79,10 +79,11 @@ public class ErrorText : MonoBehaviour { var error = new ErrorData(code); if (0 < error.ErrorLevel) - Logger.Error($"Error: {error}: {error.Message}", "ErrorText"); + Logger.Error($"エラー発生: {error}: {error.Message}", "ErrorText"); - if (AllErrors.All(e => e.Code != code)) + if (!AllErrors.Any(e => e.Code == code)) { + //まだ出ていないエラー AllErrors.Add(error); } diff --git a/Modules/ExtendedPlayerControl.cs b/Modules/ExtendedPlayerControl.cs index f17a2fd20..4b53b51c3 100644 --- a/Modules/ExtendedPlayerControl.cs +++ b/Modules/ExtendedPlayerControl.cs @@ -1,12 +1,12 @@ -using AmongUs.GameOptions; -using HarmonyLib; -using Hazel; -using InnerNet; using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Text; +using AmongUs.GameOptions; +using HarmonyLib; +using Hazel; +using InnerNet; using TOHE.Modules; using TOHE.Patches; using TOHE.Roles.AddOns.Crewmate; @@ -661,8 +661,6 @@ static class ExtendedPlayerControl } public static bool IsShifted(this PlayerControl pc) => Main.CheckShapeshift.TryGetValue(pc.PlayerId, out var shifted) && shifted; public static bool IsPlayerShifted(this byte id) => Main.CheckShapeshift.TryGetValue(id, out var shifted) && shifted; - public static bool HasSubRole(this PlayerControl pc) => Main.PlayerStates[pc.PlayerId].SubRoles.Count > 0; - public static void ResetKillCooldown(this PlayerControl player) { Main.PlayerStates[player.PlayerId].Role.SetKillCooldown(player.PlayerId); @@ -832,8 +830,8 @@ static class ExtendedPlayerControl public static bool KnowDeathReason(this PlayerControl seer, PlayerControl target) => ((seer.Is(CustomRoles.Doctor) || seer.Is(CustomRoles.Autopsy) - || (seer.Data.IsDead && Options.GhostCanSeeDeathReason.GetBool())) - && target.Data.IsDead) || (target.Is(CustomRoles.Gravestone) && target.Data.IsDead); + || (seer.Data.IsDead && Options.GhostCanSeeDeathReason.GetBool())) + && target.Data.IsDead) || (target.Is(CustomRoles.Gravestone) && target.Data.IsDead); public static string GetRoleInfo(this PlayerControl player, bool InfoLong = false) { diff --git a/Modules/GameOptionsSender/GameOptionsSender.cs b/Modules/GameOptionsSender/GameOptionsSender.cs index 3d637bcc9..9cbb16a54 100644 --- a/Modules/GameOptionsSender/GameOptionsSender.cs +++ b/Modules/GameOptionsSender/GameOptionsSender.cs @@ -1,9 +1,9 @@ +using System; +using System.Collections.Generic; using AmongUs.GameOptions; using Hazel; using Il2CppInterop.Runtime.InteropTypes.Arrays; using InnerNet; -using System; -using System.Collections.Generic; using Array = Il2CppSystem.Array; using Buffer = Il2CppSystem.Buffer; diff --git a/Modules/GameOptionsSender/NormalGameOptionsSender.cs b/Modules/GameOptionsSender/NormalGameOptionsSender.cs index e08388f55..8e7f1964d 100644 --- a/Modules/GameOptionsSender/NormalGameOptionsSender.cs +++ b/Modules/GameOptionsSender/NormalGameOptionsSender.cs @@ -1,5 +1,5 @@ -using AmongUs.GameOptions; using System; +using AmongUs.GameOptions; namespace TOHE.Modules; diff --git a/Modules/GameOptionsSender/PlayerGameOptionsSender.cs b/Modules/GameOptionsSender/PlayerGameOptionsSender.cs index b9edee0fa..fba8b5711 100644 --- a/Modules/GameOptionsSender/PlayerGameOptionsSender.cs +++ b/Modules/GameOptionsSender/PlayerGameOptionsSender.cs @@ -1,9 +1,9 @@ -using AmongUs.GameOptions; +using System; +using System.Linq; +using AmongUs.GameOptions; using Hazel; using Il2CppInterop.Runtime.InteropTypes.Arrays; using InnerNet; -using System; -using System.Linq; using TOHE.Roles.Crewmate; using TOHE.Roles.Impostor; using TOHE.Roles.Neutral; @@ -268,14 +268,21 @@ public class PlayerGameOptionsSender(PlayerControl player) : GameOptionsSender Main.AllPlayerSpeed[player.PlayerId] = Options.MareSpeedDuringLightsOut.GetFloat(); break; case CustomRoles.Torch: + if (!Utils.IsActive(SystemTypes.Electrical)) + { opt.SetVision(true); - opt.SetFloat(FloatOptionNames.CrewLightMod, Options.TorchVision.GetFloat()); - opt.SetFloat(FloatOptionNames.ImpostorLightMod, Options.TorchVision.GetFloat()); - if (Utils.IsActive(SystemTypes.Electrical) && !Options.TorchAffectedByLights.GetBool()) + opt.SetFloat(FloatOptionNames.CrewLightMod, Options.TorchVision.GetFloat()); + opt.SetFloat(FloatOptionNames.ImpostorLightMod, Options.TorchVision.GetFloat()); + } + + else if (!Options.TorchAffectedByLights.GetBool()) + { opt.SetVision(true); - opt.SetFloat(FloatOptionNames.CrewLightMod, Options.TorchVision.GetFloat() * 5); - opt.SetFloat(FloatOptionNames.ImpostorLightMod, Options.TorchVision.GetFloat() * 5); + opt.SetFloat(FloatOptionNames.CrewLightMod, Options.TorchVision.GetFloat() * 5); + opt.SetFloat(FloatOptionNames.ImpostorLightMod, Options.TorchVision.GetFloat() * 5); + } + break; case CustomRoles.Bewilder: opt.SetVision(false); @@ -311,7 +318,14 @@ public class PlayerGameOptionsSender(PlayerControl player) : GameOptionsSender opt.SetFloat(FloatOptionNames.ImpostorLightMod, 0.01f); } - // ������������ȴΪ0ʱ�޷�������ʾͼ�� + if (Changeling.ChangedRole.TryGetValue(player.PlayerId, out var changed) && changed && player.GetCustomRole().GetRoleTypes() != RoleTypes.Shapeshifter) + { + AURoleOptions.ShapeshifterCooldown = 300f; + AURoleOptions.ShapeshifterDuration = 1f; + } + + // =================================================================================================================== + AURoleOptions.EngineerCooldown = Mathf.Max(0.01f, AURoleOptions.EngineerCooldown); if (Main.AllPlayerKillCooldown.TryGetValue(player.PlayerId, out var killCooldown)) diff --git a/Modules/GameState.cs b/Modules/GameState.cs index b888b0084..9c3243e1e 100644 --- a/Modules/GameState.cs +++ b/Modules/GameState.cs @@ -1,9 +1,9 @@ -using AmongUs.GameOptions; -using HarmonyLib; -using InnerNet; using System; using System.Collections.Generic; using System.Linq; +using AmongUs.GameOptions; +using HarmonyLib; +using InnerNet; using TOHE.Modules; using TOHE.Roles.AddOns.Crewmate; using TOHE.Roles.Crewmate; @@ -46,7 +46,6 @@ public class PlayerState(byte playerId) _ => CustomRoles.Crewmate, }; } - public void SetMainRole(CustomRoles role) { countTypes = role switch @@ -190,7 +189,6 @@ public class PlayerState(byte playerId) break; } } - public void RemoveSubRole(CustomRoles role) { if (SubRoles.Contains(role)) @@ -205,7 +203,6 @@ public class PlayerState(byte playerId) RPC.SendDeathReason(PlayerId, deathReason); } } - public bool IsSuicide => deathReason == DeathReason.Suicide; public TaskState TaskState => taskState; public void InitTask(PlayerControl player) => taskState.Init(player); @@ -249,11 +246,9 @@ public class PlayerState(byte playerId) etc = -1, } - public byte GetRealKiller() => IsDead && RealKiller.TIMESTAMP != DateTime.MinValue ? RealKiller.ID : byte.MaxValue; public int GetKillCount(bool ExcludeSelfKill = false) => Main.PlayerStates.Values.Where(state => !(ExcludeSelfKill && state.PlayerId == PlayerId) && state.GetRealKiller() == PlayerId).ToArray().Length; } - public class TaskState { public static int InitialTotalTasks; @@ -272,12 +267,10 @@ public class TaskState AllTasksCount = 0; return; } - hasTasks = true; AllTasksCount = player.Data.Tasks.Count; Logger.Info($"{player.GetNameWithRole().RemoveHtmlTags().RemoveHtmlTags()}: TaskCounts = {CompletedTasksCount}/{AllTasksCount}", "TaskState.Init"); } - public void Update(PlayerControl player) { Logger.Info($"{player.GetNameWithRole().RemoveHtmlTags().RemoveHtmlTags()}: UpdateTask", "TaskState.Update"); @@ -382,33 +375,22 @@ public class TaskState Logger.Info($"{player.GetNameWithRole().RemoveHtmlTags()}: TaskCounts = {CompletedTasksCount}/{AllTasksCount}", "TaskState.Update"); } } - public class PlayerVersion(Version ver, string tag_str, string forkId) { public readonly Version version = ver; public readonly string tag = tag_str; public readonly string forkId = forkId; #pragma warning disable CA1041 // Provide ObsoleteAttribute message - [Obsolete] - public PlayerVersion(string ver, string tag_str) : this(Version.Parse(ver), tag_str, string.Empty) - { - } - - [Obsolete] - public PlayerVersion(Version ver, string tag_str) : this(ver, tag_str, string.Empty) - { - } + [Obsolete] public PlayerVersion(string ver, string tag_str) : this(Version.Parse(ver), tag_str, string.Empty) { } + [Obsolete] public PlayerVersion(Version ver, string tag_str) : this(ver, tag_str, string.Empty) { } #pragma warning restore CA1041 // Provide ObsoleteAttribute message - public PlayerVersion(string ver, string tag_str, string forkId) : this(Version.Parse(ver), tag_str, forkId) - { - } + public PlayerVersion(string ver, string tag_str, string forkId) : this(Version.Parse(ver), tag_str, forkId) { } public bool IsEqual(PlayerVersion pv) { return pv.version == version && pv.tag == tag; } } - public static class GameStates { public static bool InGame; @@ -424,15 +406,12 @@ public static class GameStates public static bool IsInTask => InGame && !MeetingHud.Instance; public static bool IsMeeting => InGame && MeetingHud.Instance; public static bool IsVoting => IsMeeting && MeetingHud.Instance.state is MeetingHud.VoteStates.Voted or MeetingHud.VoteStates.NotVoted; - public static bool IsCountDown => GameStartManager.InstanceExists && GameStartManager.Instance.startState == GameStartManager.StartingStates.Countdown; - /**********TOP ZOOM.cs***********/ public static bool IsShip => ShipStatus.Instance != null; public static bool IsCanMove => PlayerControl.LocalPlayer?.CanMove is true; public static bool IsDead => PlayerControl.LocalPlayer?.Data?.IsDead is true; } - public static class MeetingStates { public static DeadBody[] DeadBodies; diff --git a/Modules/GuessManager.cs b/Modules/GuessManager.cs index 63ec36065..b57f6b6d7 100644 --- a/Modules/GuessManager.cs +++ b/Modules/GuessManager.cs @@ -1,10 +1,10 @@ -using HarmonyLib; -using Hazel; -using System; +using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; +using HarmonyLib; +using Hazel; using TMPro; using TOHE.Modules; using TOHE.Roles.AddOns.Common; @@ -969,7 +969,7 @@ public static class GuessManager { CustomRoleTypes.Crewmate => new(140, 255, 255, byte.MaxValue), CustomRoleTypes.Impostor => new(255, 25, 25, byte.MaxValue), - CustomRoleTypes.Neutral => new(127, 140, 141, byte.MaxValue), + CustomRoleTypes.Neutral => new(255, 171, 27, byte.MaxValue), // CustomRoleTypes.Madmate => new Color32(255, 25, 25, byte.MaxValue), CustomRoleTypes.Addon => new Color32(255, 154, 206, byte.MaxValue), _ => throw new NotImplementedException(), diff --git a/Modules/LoadingScreen.cs b/Modules/LoadingScreen.cs index 7576f4bd0..009fea6f3 100644 --- a/Modules/LoadingScreen.cs +++ b/Modules/LoadingScreen.cs @@ -1,5 +1,5 @@ -using Rewired.Utils; -using System; +using System; +using Rewired.Utils; using TOHE.Patches; using UnityEngine; using Object = UnityEngine.Object; diff --git a/Modules/MeetingTimeManager.cs b/Modules/MeetingTimeManager.cs index ac967ce2c..65017f56e 100644 --- a/Modules/MeetingTimeManager.cs +++ b/Modules/MeetingTimeManager.cs @@ -1,5 +1,5 @@ -using AmongUs.GameOptions; using System; +using AmongUs.GameOptions; using TOHE.Roles.Crewmate; using TOHE.Roles.Impostor; @@ -62,19 +62,21 @@ public class MeetingTimeManager } int TotalMeetingTime = DiscussionTime + VotingTime; - //時間の下限、上限で刈り込み + if (TimeManager.playerIdList.Count > 0) BonusMeetingTime = Math.Clamp(TotalMeetingTime + BonusMeetingTime, MeetingTimeMinTimeManager, MeetingTimeMax) - TotalMeetingTime; if (TimeThief.playerIdList.Count > 0) BonusMeetingTime = Math.Clamp(TotalMeetingTime + BonusMeetingTime, MeetingTimeMinTimeThief, MeetingTimeMax) - TotalMeetingTime; if (TimeManager.playerIdList.Count == 0 && TimeThief.playerIdList.Count == 0) BonusMeetingTime = Math.Clamp(TotalMeetingTime + BonusMeetingTime, MeetingTimeMinTimeThief, MeetingTimeMax) - TotalMeetingTime; if (BonusMeetingTime >= 0) - VotingTime += BonusMeetingTime; //投票時間を延長 + { + VotingTime += BonusMeetingTime; + } else { - DiscussionTime += BonusMeetingTime; //会議時間を優先的に短縮 - if (DiscussionTime < 0) //会議時間だけでは賄えない場合 + DiscussionTime += BonusMeetingTime; + if (DiscussionTime < 0) { - VotingTime += DiscussionTime; //足りない分投票時間を短縮 + VotingTime += DiscussionTime; DiscussionTime = 0; } } diff --git a/Modules/ModUpdater.cs b/Modules/ModUpdater.cs index 607d00b4a..0a1c6ae71 100644 --- a/Modules/ModUpdater.cs +++ b/Modules/ModUpdater.cs @@ -1,11 +1,11 @@ -using HarmonyLib; -using Newtonsoft.Json.Linq; -using System; +using System; using System.IO; using System.IO.Compression; using System.Net.Http; using System.Reflection; using System.Threading.Tasks; +using HarmonyLib; +using Newtonsoft.Json.Linq; using Twitch; using UnityEngine; using static TOHE.Translator; diff --git a/Modules/NameNotifyManager.cs b/Modules/NameNotifyManager.cs index 4248d296b..7dc5cc106 100644 --- a/Modules/NameNotifyManager.cs +++ b/Modules/NameNotifyManager.cs @@ -1,5 +1,5 @@ -using Hazel; -using System.Collections.Generic; +using System.Collections.Generic; +using Hazel; using TOHE.Modules; using UnityEngine; diff --git a/Modules/OptionBackup/OptionBackupData.cs b/Modules/OptionBackup/OptionBackupData.cs index 0acfbb6b2..2555eb729 100644 --- a/Modules/OptionBackup/OptionBackupData.cs +++ b/Modules/OptionBackup/OptionBackupData.cs @@ -1,8 +1,8 @@ -using AmongUs.GameOptions; using System; using System.Collections; using System.Collections.Generic; using System.Linq; +using AmongUs.GameOptions; namespace TOHE; diff --git a/Modules/OptionBackup/OptionBackupValue.cs b/Modules/OptionBackup/OptionBackupValue.cs index d24b0a1cf..89fd94afc 100644 --- a/Modules/OptionBackup/OptionBackupValue.cs +++ b/Modules/OptionBackup/OptionBackupValue.cs @@ -1,5 +1,5 @@ -using AmongUs.GameOptions; using System; +using AmongUs.GameOptions; namespace TOHE; diff --git a/Modules/OptionHolder.cs b/Modules/OptionHolder.cs index d9747445e..a3882f41f 100644 --- a/Modules/OptionHolder.cs +++ b/Modules/OptionHolder.cs @@ -1,8 +1,8 @@ -using HarmonyLib; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using HarmonyLib; using TOHE.Modules; using TOHE.Roles.AddOns.Crewmate; using TOHE.Roles.AddOns.Impostor; @@ -1080,13 +1080,140 @@ public static class Options NoLimitAddonsNumMax = IntegerOptionItem.Create(211, "NoLimitAddonsNumMax", new(1, 90, 1), 1, TabGroup.Addons, false) .SetGameMode(CustomGameMode.Standard); + //==================================================================================================================================// - // Add-Ons ===================================================================================================================== + MainLoadingText = "Building role settings"; + RoleLoadingText = "Vanilla roles\nImpostor"; + + + // Impostor + + SetupRoleOptions(300, TabGroup.ImpostorRoles, CustomRoles.ImpostorTOHE); + RoleLoadingText = "Vanilla roles\nShapeshifter"; + SetupRoleOptions(400, TabGroup.ImpostorRoles, CustomRoles.ShapeshifterTOHE); + ShapeshiftCD = FloatOptionItem.Create(402, "ShapeshiftCooldown", new(1f, 180f, 1f), 30f, TabGroup.ImpostorRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.ShapeshifterTOHE]) + .SetValueFormat(OptionFormat.Seconds); + ShapeshiftDur = FloatOptionItem.Create(403, "ShapeshiftDuration", new(1f, 60f, 1f), 10f, TabGroup.ImpostorRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.ShapeshifterTOHE]) + .SetValueFormat(OptionFormat.Seconds); + + RoleLoadingText = "Impostor roles\nEvil Guesser"; + SetupRoleOptions(1200, TabGroup.ImpostorRoles, CustomRoles.EvilGuesser); + EGCanGuessTime = IntegerOptionItem.Create(1205, "GuesserCanGuessTimes", new(1, 15, 1), 15, TabGroup.ImpostorRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.EvilGuesser]) + .SetValueFormat(OptionFormat.Times); + EGCanGuessImp = BooleanOptionItem.Create(1206, "EGCanGuessImp", true, TabGroup.ImpostorRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.EvilGuesser]); + EGCanGuessAdt = BooleanOptionItem.Create(1207, "EGCanGuessAdt", false, TabGroup.ImpostorRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.EvilGuesser]); + EGCanGuessTaskDoneSnitch = BooleanOptionItem.Create(1208, "EGCanGuessTaskDoneSnitch", true, TabGroup.ImpostorRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.EvilGuesser]); + EGTryHideMsg = BooleanOptionItem.Create(1209, "GuesserTryHideMsg", true, TabGroup.ImpostorRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.EvilGuesser]) + .SetColor(Color.green); + + RoleLoadingText = "Impostor roles\nVindicator"; + SetupRoleOptions(3400, TabGroup.ImpostorRoles, CustomRoles.Vindicator); + VindicatorAdditionalVote = IntegerOptionItem.Create(3410, "MayorAdditionalVote", new(1, 30, 1), 1, TabGroup.ImpostorRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Vindicator]) + .SetValueFormat(OptionFormat.Votes); + VindicatorHideVote = BooleanOptionItem.Create(3411, "MayorHideVote", false, TabGroup.ImpostorRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Vindicator]); + RoleLoadingText = "Impostor roles\nVisionary"; + + SetupRoleOptions(16150, TabGroup.ImpostorRoles, CustomRoles.Visionary); + + RoleLoadingText = "Impostor roles\nTrickster"; + SetupRoleOptions(4300, TabGroup.ImpostorRoles, CustomRoles.Trickster); + + + // Crewmates ===================================================================================================================== + + + RoleLoadingText = "Vanilla roles\nCrewmate"; + + SetupRoleOptions(5050, TabGroup.CrewmateRoles, CustomRoles.CrewmateTOHE); + RoleLoadingText = "Vanilla roles\nEngineer"; + SetupRoleOptions(5000, TabGroup.CrewmateRoles, CustomRoles.EngineerTOHE); + RoleLoadingText = "Vanilla roles\nScientist"; + SetupRoleOptions(5100, TabGroup.CrewmateRoles, CustomRoles.ScientistTOHE); + ScientistCD = FloatOptionItem.Create(5110, "VitalsCooldown", new(1f, 250f, 1f), 3f, TabGroup.CrewmateRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.ScientistTOHE]) + .SetValueFormat(OptionFormat.Seconds); + ScientistDur = FloatOptionItem.Create(5111, "VitalsDuration", new(1f, 250f, 1f), 15f, TabGroup.CrewmateRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.ScientistTOHE]) + .SetValueFormat(OptionFormat.Seconds); + + RoleLoadingText = "Crewmate roles\nCelebrity"; + + SetupRoleOptions(5300, TabGroup.CrewmateRoles, CustomRoles.CyberStar); + ImpKnowCyberStarDead = BooleanOptionItem.Create(5400, "ImpKnowCyberStarDead", false, TabGroup.CrewmateRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.CyberStar]); + NeutralKnowCyberStarDead = BooleanOptionItem.Create(5500, "NeutralKnowCyberStarDead", false, TabGroup.CrewmateRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.CyberStar]); + RoleLoadingText = "Crewmate roles\nDemolitionist"; + SetupSingleRoleOptions(5550, TabGroup.CrewmateRoles, CustomRoles.Demolitionist, 1); + DemolitionistVentTime = FloatOptionItem.Create(5552, "DemolitionistVentTime", new(0f, 90f, 1f), 5f, TabGroup.CrewmateRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Demolitionist]) + .SetValueFormat(OptionFormat.Seconds); + DemolitionistKillerDiesOnMeetingCall = BooleanOptionItem.Create(5553, "DemolitionistKillerDiesOnMeetingCall", false, TabGroup.CrewmateRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Demolitionist]); + RoleLoadingText = "Crewmate roles\nShiftguard"; + SetupRoleOptions(5594, TabGroup.CrewmateRoles, CustomRoles.Shiftguard); + RoleLoadingText = "Crewmate roles\nDetour"; + SetupRoleOptions(5590, TabGroup.CrewmateRoles, CustomRoles.Detour); + RoleLoadingText = "Crewmate roles\nLazy Guy"; + SetupRoleOptions(5700, TabGroup.CrewmateRoles, CustomRoles.Needy); + + RoleLoadingText = "Crewmate roles\nDetective"; + SetupRoleOptions(6600, TabGroup.CrewmateRoles, CustomRoles.Detective); + DetectiveCanknowKiller = BooleanOptionItem.Create(6610, "DetectiveCanknowKiller", true, TabGroup.CrewmateRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Detective]); + + RoleLoadingText = "Crewmate roles\nObserver"; + SetupRoleOptions(7500, TabGroup.CrewmateRoles, CustomRoles.Observer); + + RoleLoadingText = "Crewmate roles\nNice Guesser"; + SetupRoleOptions(8600, TabGroup.CrewmateRoles, CustomRoles.NiceGuesser); + GGCanGuessTime = IntegerOptionItem.Create(8610, "GuesserCanGuessTimes", new(0, 15, 1), 15, TabGroup.CrewmateRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.NiceGuesser]) + .SetValueFormat(OptionFormat.Times); + GGCanGuessCrew = BooleanOptionItem.Create(8611, "GGCanGuessCrew", true, TabGroup.CrewmateRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.NiceGuesser]); + GGCanGuessAdt = BooleanOptionItem.Create(8612, "GGCanGuessAdt", false, TabGroup.CrewmateRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.NiceGuesser]); + GGTryHideMsg = BooleanOptionItem.Create(8613, "GuesserTryHideMsg", true, TabGroup.CrewmateRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.NiceGuesser]) + .SetColor(Color.green); + + RoleLoadingText = "Crewmate roles\nDictator"; + SetupRoleOptions(9100, TabGroup.CrewmateRoles, CustomRoles.Dictator); + + RoleLoadingText = "Neutral roles\nPhantom"; + SetupRoleOptions(11400, TabGroup.NeutralRoles, CustomRoles.Phantom); + PhantomCanVent = BooleanOptionItem.Create(11410, "CanVent", false, TabGroup.NeutralRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Phantom]); + PhantomSnatchesWin = BooleanOptionItem.Create(11411, "SnatchesWin", false, TabGroup.NeutralRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Phantom]); + PhantomCanGuess = BooleanOptionItem.Create(11412, "CanGuess", false, TabGroup.NeutralRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Phantom]); + PhantomTasks = OverrideTasksData.Create(11413, TabGroup.NeutralRoles, CustomRoles.Phantom); + RoleLoadingText = "Neutral roles\nTerrorist"; + SetupRoleOptions(11500, TabGroup.NeutralRoles, CustomRoles.Terrorist); + CanTerroristSuicideWin = BooleanOptionItem.Create(11510, "CanTerroristSuicideWin", false, TabGroup.NeutralRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Terrorist]); + TerroristCanGuess = BooleanOptionItem.Create(11511, "CanGuess", true, TabGroup.NeutralRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Terrorist]); + TerroristTasks = OverrideTasksData.Create(11512, TabGroup.NeutralRoles, CustomRoles.Terrorist); RoleLoadingText = "Add-ons\n."; + // Add-Ons ===================================================================================================================== + + AddBracketsToAddons = BooleanOptionItem.Create(13500, "BracketAddons", false, TabGroup.Addons, false) .SetGameMode(CustomGameMode.Standard) .SetHeader(true); @@ -1530,41 +1657,17 @@ public static class Options try { - var roleClassesDict = Main.AllRoleClasses + var roleClassesDict = Utils.GetEnumerableOfType() .Where(x => x.GetType().Name != "VanillaRole") - .GroupBy(x => ((CustomRoles)Enum.Parse(typeof(CustomRoles), ignoreCase: true, value: x.GetType().Name)).GetRoleOptionType()) + .GroupBy(x => ((CustomRoles)Enum.Parse(typeof(CustomRoles), ignoreCase: true, value: x.GetType().Name)).GetCustomRoleTypes()) .ToDictionary(x => x.Key, x => x.ToArray()); - int titleId = 100000; - foreach (var roleClasses in roleClassesDict) { MainLoadingText = $"Building Role Settings: {roleClasses.Key} Roles"; int allRoles = roleClasses.Value.Length; int index = 0; - switch (roleClasses.Key) - { - case RoleOptionType.Impostor: - SetupBasicImpostorRoleSettings(ref titleId); - break; - case RoleOptionType.Crewmate_Normal: - SetupBasicNonKillingCrewmateRoleSettings(ref titleId); - break; - case RoleOptionType.Neutral_NonKilling: - SetupBasicNonKillingNeutralRoleSettings(ref titleId); - break; - case RoleOptionType.Neutral_Killing: - SetupBasicKillingNeutralRoleSettings(ref titleId); - break; - } - - TextOptionItem.Create(titleId, $"ROT.{roleClasses.Key}", roleClasses.Key.GetTabFromOptionType()) - .SetHeader(true) - .SetGameMode(CustomGameMode.Standard) - .SetColor(roleClasses.Key.GetRoleOptionTypeColor()); - titleId += 10; - foreach (var roleClass in roleClasses.Value) { index++; @@ -1578,6 +1681,44 @@ public static class Options { Logger.Exception(e, $"{MainLoadingText} - {RoleLoadingText}"); } + + if (roleClasses.Key != CustomRoleTypes.Impostor) continue; + + switch (roleClass) + { + case Assassin: + Undertaker.SetupCustomOption(); + break; + case Swooper: + Chameleon.SetupCustomOption(); + Wraith.SetupCustomOption(); + break; + case Wildling: + BloodKnight.SetupCustomOption(); + break; + case Witch: + HexMaster.SetupCustomOption(); + break; + case Greedier: + Imitator.SetupCustomOption(); + break; + case CursedWolf: + Jinx.SetupCustomOption(); + break; + case Sans: + Juggernaut.SetupCustomOption(); + Reckless.SetupCustomOption(); + break; + case Cleaner: + Medusa.SetupCustomOption(); + break; + case Vampire: + Poisoner.SetupCustomOption(); + break; + case EvilDiviner: + Ritualist.SetupCustomOption(); + break; + } } } } @@ -2534,89 +2675,6 @@ public static class Options OptionSaver.Load(); IsLoaded = true; - return; - - static void SetupBasicNonKillingCrewmateRoleSettings(ref int titleId) - { - TextOptionItem.Create(titleId, "ROT.Vanilla", TabGroup.CrewmateRoles) - .SetGameMode(CustomGameMode.Standard) - .SetColor(Color.white) - .SetHeader(true); - titleId += 10; - - CrewmateVanillaRoles.SetupCustomOption(); - - TextOptionItem.Create(titleId, "ROT.Basic", TabGroup.CrewmateRoles) - .SetGameMode(CustomGameMode.Standard) - .SetColor(Color.gray) - .SetHeader(true); - titleId += 10; - - CyberStar.SetupCustomOption(); // Celebrity - Chameleon.SetupCustomOption(); - Demolitionist.SetupCustomOption(); - Detective.SetupCustomOption(); - SetupRoleOptions(5590, TabGroup.CrewmateRoles, CustomRoles.Detour); - SetupRoleOptions(9100, TabGroup.CrewmateRoles, CustomRoles.Dictator); - SetupRoleOptions(5700, TabGroup.CrewmateRoles, CustomRoles.Needy); // Lazy guy - SetupRoleOptions(7500, TabGroup.CrewmateRoles, CustomRoles.Observer); - NiceGuesser.SetupCustomOption(); - SetupRoleOptions(5594, TabGroup.CrewmateRoles, CustomRoles.Shiftguard); - } - - static void SetupBasicImpostorRoleSettings(ref int titleId) - { - TextOptionItem.Create(titleId, "ROT.Vanilla", TabGroup.ImpostorRoles) - .SetGameMode(CustomGameMode.Standard) - .SetColor(Color.white) - .SetHeader(true); - titleId += 10; - - ImpostorVanillaRoles.SetupCustomOption(); - - TextOptionItem.Create(100030, "ROT.Basic", TabGroup.ImpostorRoles) - .SetGameMode(CustomGameMode.Standard) - .SetColor(Color.gray) - .SetHeader(true); - titleId += 10; - - EvilGuesser.SetupCustomOption(); - Vindicator.SetupCustomOption(); - SetupRoleOptions(16150, TabGroup.ImpostorRoles, CustomRoles.Visionary); - SetupRoleOptions(4300, TabGroup.ImpostorRoles, CustomRoles.Trickster); - } - - static void SetupBasicNonKillingNeutralRoleSettings(ref int titleId) - { - TextOptionItem.Create(100030, "ROT.BasicNNK", TabGroup.NeutralRoles) - .SetGameMode(CustomGameMode.Standard) - .SetColor(Color.gray) - .SetHeader(true); - titleId += 10; - - Phantom.SetupCustomOption(); - Terrorist.SetupCustomOption(); - } - - static void SetupBasicKillingNeutralRoleSettings(ref int titleId) - { - TextOptionItem.Create(100030, "ROT.BasicNK", TabGroup.NeutralRoles) - .SetGameMode(CustomGameMode.Standard) - .SetColor(Color.gray) - .SetHeader(true); - titleId += 10; - - BloodKnight.SetupCustomOption(); - HexMaster.SetupCustomOption(); - Imitator.SetupCustomOption(); - Jinx.SetupCustomOption(); - Juggernaut.SetupCustomOption(); - Medusa.SetupCustomOption(); - Poisoner.SetupCustomOption(); - Reckless.SetupCustomOption(); - Ritualist.SetupCustomOption(); - Wraith.SetupCustomOption(); - } } public static void SetupRoleOptions(int id, TabGroup tab, CustomRoles role, CustomGameMode customGameMode = CustomGameMode.Standard, bool zeroOne = false) diff --git a/Modules/OptionShower.cs b/Modules/OptionShower.cs index e8eabfee1..07be9119d 100644 --- a/Modules/OptionShower.cs +++ b/Modules/OptionShower.cs @@ -10,17 +10,15 @@ public static class OptionShower { public static int currentPage; public static List pages = []; - static OptionShower() { - } + } public static string GetTextNoFresh() { if (pages.Count < 3) GetText(); return $"{pages[currentPage]}{GetString("PressTabToNextPage")}({currentPage + 1}/{pages.Count})"; } - public static string GetText() { //初期化 @@ -52,7 +50,6 @@ public static class OptionShower pages.Add(sb + "\n\n"); sb.Clear(); } - //有効な役職と詳細設定一覧 pages.Add(""); sb.Append($"{Utils.GetRoleName(CustomRoles.GM)}: {(Main.GM.Value ? GetString("RoleRate") : GetString("RoleOff"))}\n\n"); @@ -74,24 +71,21 @@ public static class OptionShower } //1ページにつき35行までにする処理 - List tmp = [.. sb.ToString().Split("\n\n")]; + List tmp = [..sb.ToString().Split("\n\n")]; foreach (var str in tmp) { if (pages[^1].Count(c => c == '\n') + 1 + str.Count(c => c == '\n') + 1 > 35) pages.Add(str + "\n\n"); else pages[^1] += str + "\n\n"; } - if (currentPage >= pages.Count) currentPage = pages.Count - 1; //現在のページが最大ページ数を超えていれば最後のページに修正 return $"{pages[currentPage]}{GetString("PressTabToNextPage")}({currentPage + 1}/{pages.Count})"; } - public static void Next() { currentPage++; if (currentPage >= pages.Count) currentPage = 0; //現在のページが最大ページを超えていれば最初のページに } - private static void ShowChildren(OptionItem option, ref StringBuilder sb, Color color, int deep = 0) { foreach (var opt in option.Children.Select((v, i) => new { Value = v, Index = i + 1 })) diff --git a/Modules/RPC.cs b/Modules/RPC.cs index 2d50e5f77..aa133fdc6 100644 --- a/Modules/RPC.cs +++ b/Modules/RPC.cs @@ -1,11 +1,11 @@ -using AmongUs.GameOptions; -using HarmonyLib; -using Hazel; -using InnerNet; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using AmongUs.GameOptions; +using HarmonyLib; +using Hazel; +using InnerNet; using TOHE.Roles.AddOns.Crewmate; using TOHE.Roles.AddOns.Impostor; using TOHE.Roles.Crewmate; diff --git a/Modules/ServerAddManager.cs b/Modules/ServerAddManager.cs index b45c912a6..c47085e02 100644 --- a/Modules/ServerAddManager.cs +++ b/Modules/ServerAddManager.cs @@ -1,10 +1,10 @@ -using HarmonyLib; -using Il2CppInterop.Runtime.InteropTypes; -using System; +using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Linq.Expressions; +using HarmonyLib; +using Il2CppInterop.Runtime.InteropTypes; namespace TOHE; diff --git a/Modules/TemplateManager.cs b/Modules/TemplateManager.cs index 20f6c322f..4c8868f15 100644 --- a/Modules/TemplateManager.cs +++ b/Modules/TemplateManager.cs @@ -1,6 +1,3 @@ -using AmongUs.Data; -using HarmonyLib; -using InnerNet; using System; using System.Collections.Generic; using System.Globalization; @@ -9,6 +6,9 @@ using System.Linq; using System.Reflection; using System.Text; using System.Text.RegularExpressions; +using AmongUs.Data; +using HarmonyLib; +using InnerNet; using UnityEngine; using static TOHE.Translator; diff --git a/Modules/Translator.cs b/Modules/Translator.cs index d888bb657..6e27b4473 100644 --- a/Modules/Translator.cs +++ b/Modules/Translator.cs @@ -1,5 +1,3 @@ -using HarmonyLib; -using Il2CppInterop.Runtime.InteropTypes.Arrays; using System; using System.Collections.Generic; using System.Globalization; @@ -9,6 +7,8 @@ using System.Reflection; using System.Text; using System.Text.Json; using System.Text.RegularExpressions; +using HarmonyLib; +using Il2CppInterop.Runtime.InteropTypes.Arrays; using Object = Il2CppSystem.Object; namespace TOHE; diff --git a/Modules/Utils.cs b/Modules/Utils.cs index c2ab640ed..9b9a37e9b 100644 --- a/Modules/Utils.cs +++ b/Modules/Utils.cs @@ -1,8 +1,3 @@ -using AmongUs.Data; -using AmongUs.GameOptions; -using Hazel; -using Il2CppInterop.Runtime.InteropTypes; -using InnerNet; using System; using System.Collections.Generic; using System.Diagnostics; @@ -12,6 +7,11 @@ using System.Reflection; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; +using AmongUs.Data; +using AmongUs.GameOptions; +using Hazel; +using Il2CppInterop.Runtime.InteropTypes; +using InnerNet; using TOHE.Modules; using TOHE.Patches; using TOHE.Roles.AddOns.Common; @@ -265,9 +265,6 @@ public static class Utils public static void TargetDies(PlayerControl killer, PlayerControl target) { if (!target.Data.IsDead || GameStates.IsMeeting) return; - - var targetRole = target.GetCustomRole(); - foreach (PlayerControl seer in Main.AllPlayerControls) { if (KillFlashCheck(killer, target, seer)) @@ -276,7 +273,7 @@ public static class Utils continue; } - if (targetRole == CustomRoles.CyberStar) + if (target.Is(CustomRoles.CyberStar)) { if (!Options.ImpKnowCyberStarDead.GetBool() && seer.GetCustomRole().IsImpostor()) continue; if (!Options.NeutralKnowCyberStarDead.GetBool() && seer.GetCustomRole().IsNeutral()) continue; @@ -285,14 +282,29 @@ public static class Utils } } - switch (targetRole) + if (target.Is(CustomRoles.CyberStar) && !Main.CyberStarDead.Contains(target.PlayerId)) Main.CyberStarDead.Add(target.PlayerId); + if (target.Is(CustomRoles.Demolitionist) && !Main.DemolitionistDead.Contains(target.PlayerId)) Main.DemolitionistDead.Add(target.PlayerId); + if (target.Is(CustomRoles.Demolitionist)) { - case CustomRoles.CyberStar when !Main.CyberStarDead.Contains(target.PlayerId): - Main.CyberStarDead.Add(target.PlayerId); - break; - case CustomRoles.Demolitionist: - Demolitionist.OnDeath(killer, target); - break; + killer.Notify(ColorString(GetRoleColor(CustomRoles.Demolitionist), GetString("OnDemolitionistDead"))); + killer.KillFlash(); + _ = new LateTask(() => + { + if (!killer.inVent && (killer.PlayerId != target.PlayerId)) + { + if ((Options.DemolitionistKillerDiesOnMeetingCall.GetBool() || GameStates.IsInTask) && killer.IsAlive()) + { + killer.Suicide(PlayerState.DeathReason.Demolished, target); + RPC.PlaySoundRPC(killer.PlayerId, Sounds.KillSound); + } + } + else + { + if (killer.IsModClient()) RPC.PlaySoundRPC(killer.PlayerId, Sounds.TaskComplete); + else killer.RpcGuardAndKill(killer); + killer.SetKillCooldown(Main.AllPlayerKillCooldown[killer.PlayerId] - Options.DemolitionistVentTime.GetFloat()); + } + }, Options.DemolitionistVentTime.GetFloat() + 0.5f); } } @@ -1116,7 +1128,7 @@ public static class Utils sb.Append("<#ffffff>Role Summary:"); - List cloneRoles = [.. Main.PlayerStates.Keys]; + List cloneRoles = [..Main.PlayerStates.Keys]; foreach (byte id in Main.winnerList.ToArray()) { if (EndGamePatch.SummaryText[id].Contains("")) continue; @@ -2330,7 +2342,7 @@ public static class Utils CustomRoles.Druid => Druid.VentCooldown.GetInt(), CustomRoles.Sniper => Options.DefaultShapeshiftCooldown.GetInt(), CustomRoles.Assassin => Assassin.AssassinateCooldownOpt.GetInt(), - CustomRoles.Undertaker => Assassin.UndertakerAssassinateCooldown.GetInt(), + CustomRoles.Undertaker => Undertaker.AssassinateCooldown.GetInt(), CustomRoles.Bomber => Options.BombCooldown.GetInt(), CustomRoles.Nuker => Options.NukeCooldown.GetInt(), CustomRoles.Sapper => Sapper.ShapeshiftCooldown.GetInt(), @@ -2836,6 +2848,27 @@ public static class Utils return casted != null; } + public static IEnumerable GetEnumerableOfType(params object[] constructorArgs) where T : class, IComparable + { + List objects = []; + try + { + var assembly = Assembly.GetAssembly(typeof(T)); + if (assembly == null) return objects; + objects.AddRange(assembly + .GetTypes() + .Where(myType => myType.IsClass && !myType.IsAbstract && myType.IsSubclassOf(typeof(T))) + .Select(type => (T)Activator.CreateInstance(type, constructorArgs))); + objects.Sort(); + } + catch (Exception e) + { + ThrowException(e); + } + + return objects; + } + public static int AllPlayersCount => Main.PlayerStates.Values.Count(state => state.countTypes != CountTypes.OutOfGame); public static int AllAlivePlayersCount => Main.AllAlivePlayerControls.Count(pc => !pc.Is(CountTypes.OutOfGame)); public static bool IsAllAlive => Main.PlayerStates.Values.All(state => state.countTypes == CountTypes.OutOfGame || !state.IsDead); diff --git a/Modules/Zoom.cs b/Modules/Zoom.cs index f82e3b96d..64693e805 100644 --- a/Modules/Zoom.cs +++ b/Modules/Zoom.cs @@ -1,6 +1,6 @@ -using HarmonyLib; -using System; +using System; using System.Collections.Generic; +using HarmonyLib; using UnityEngine; namespace TOHE; diff --git a/Patches/AirShipElectricalDoors.cs b/Patches/AirShipElectricalDoors.cs index 3891ca091..7f8843815 100644 --- a/Patches/AirShipElectricalDoors.cs +++ b/Patches/AirShipElectricalDoors.cs @@ -1,5 +1,5 @@ -using HarmonyLib; using System.Collections.Generic; +using HarmonyLib; namespace TOHE; diff --git a/Patches/AnnouncementPatch.cs b/Patches/AnnouncementPatch.cs index cd725d132..18ec79ab1 100644 --- a/Patches/AnnouncementPatch.cs +++ b/Patches/AnnouncementPatch.cs @@ -1,11 +1,11 @@ -using AmongUs.Data; +using System; +using System.Collections.Generic; +using System.Linq; +using AmongUs.Data; using AmongUs.Data.Player; using Assets.InnerNet; using HarmonyLib; using Il2CppInterop.Runtime.InteropTypes.Arrays; -using System; -using System.Collections.Generic; -using System.Linq; namespace TOHE; diff --git a/Patches/ChatCommandPatch.cs b/Patches/ChatCommandPatch.cs index 02200cf37..337c67f58 100644 --- a/Patches/ChatCommandPatch.cs +++ b/Patches/ChatCommandPatch.cs @@ -597,7 +597,7 @@ internal class ChatCommands case "/id": canceled = true; string msgText = GetString("PlayerIdList"); - msgText = Main.AllPlayerControls.Aggregate(msgText, (current, pc) => current + ("\n" + pc.PlayerId + " → " + Main.AllPlayerNames[pc.PlayerId])); + msgText = Main.AllPlayerControls.Aggregate(msgText, (current, pc) => current + "\n" + pc.PlayerId + " → " + Main.AllPlayerNames[pc.PlayerId]); Utils.SendMessage(msgText, localPlayerId); break; @@ -1209,7 +1209,7 @@ internal class ChatCommands // break; case "/id": string msgText = GetString("PlayerIdList"); - msgText = Main.AllPlayerControls.Aggregate(msgText, (current, pc) => current + ("\n" + pc.PlayerId + " → " + Main.AllPlayerNames[pc.PlayerId])); + msgText = Main.AllPlayerControls.Aggregate(msgText, (current, pc) => current + "\n" + pc.PlayerId + " → " + Main.AllPlayerNames[pc.PlayerId]); Utils.SendMessage(msgText, player.PlayerId); break; diff --git a/Patches/ChatControlPatch.cs b/Patches/ChatControlPatch.cs index 79f437bda..a152fce27 100644 --- a/Patches/ChatControlPatch.cs +++ b/Patches/ChatControlPatch.cs @@ -1,9 +1,9 @@ -using AmongUs.Data; -using HarmonyLib; -using InnerNet; using System; using System.Collections.Generic; using System.Linq; +using AmongUs.Data; +using HarmonyLib; +using InnerNet; using TOHE.Roles.Impostor; using UnityEngine; diff --git a/Patches/CheckGameEndPatch.cs b/Patches/CheckGameEndPatch.cs index dc0ce1cbb..8204cf45c 100644 --- a/Patches/CheckGameEndPatch.cs +++ b/Patches/CheckGameEndPatch.cs @@ -1,11 +1,11 @@ +using System.Collections; +using System.Collections.Generic; +using System.Linq; using AmongUs.GameOptions; using BepInEx.Unity.IL2CPP.Utils.Collections; using HarmonyLib; using Hazel; using InnerNet; -using System.Collections; -using System.Collections.Generic; -using System.Linq; using TOHE.Modules; using TOHE.Roles.Impostor; using TOHE.Roles.Neutral; diff --git a/Patches/ControlPatch.cs b/Patches/ControlPatch.cs index aec7232de..f5e9cc769 100644 --- a/Patches/ControlPatch.cs +++ b/Patches/ControlPatch.cs @@ -1,9 +1,9 @@ -using HarmonyLib; -using Rewired; using System; using System.Collections.Generic; using System.Linq; using System.Text; +using HarmonyLib; +using Rewired; using TOHE.Modules; using UnityEngine; using static TOHE.Translator; diff --git a/Patches/CredentialsPatch.cs b/Patches/CredentialsPatch.cs index adb1c189d..eb3b6239f 100644 --- a/Patches/CredentialsPatch.cs +++ b/Patches/CredentialsPatch.cs @@ -1,7 +1,7 @@ -using HarmonyLib; using System; using System.Linq; using System.Text; +using HarmonyLib; using TMPro; using TOHE.Modules; using UnityEngine; diff --git a/Patches/DiscordPatch.cs b/Patches/DiscordPatch.cs index 52b38035d..29bc175b1 100644 --- a/Patches/DiscordPatch.cs +++ b/Patches/DiscordPatch.cs @@ -1,7 +1,7 @@ +using System; using AmongUs.Data; using Discord; using HarmonyLib; -using System; namespace TOHE.Patches { @@ -14,6 +14,8 @@ namespace TOHE.Patches public static void Prefix([HarmonyArgument(0)] Activity activity) { + if (activity == null) return; + var details = $"TOHE+ v{Main.PluginDisplayVersion}"; activity.Details = details; @@ -62,4 +64,4 @@ namespace TOHE.Patches } } } -} \ No newline at end of file +} diff --git a/Patches/ExilePatch.cs b/Patches/ExilePatch.cs index 96109f63d..0094efc8b 100644 --- a/Patches/ExilePatch.cs +++ b/Patches/ExilePatch.cs @@ -1,7 +1,7 @@ +using System.Linq; using AmongUs.Data; using AmongUs.GameOptions; using HarmonyLib; -using System.Linq; using TOHE.Roles.AddOns.Crewmate; using TOHE.Roles.AddOns.Impostor; using TOHE.Roles.Crewmate; diff --git a/Patches/GameOptionsMenuPatch.cs b/Patches/GameOptionsMenuPatch.cs index 8b1394267..2b4d448dc 100644 --- a/Patches/GameOptionsMenuPatch.cs +++ b/Patches/GameOptionsMenuPatch.cs @@ -1,10 +1,10 @@ +using System; +using System.Collections; +using System.Linq; using AmongUs.GameOptions; using HarmonyLib; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSystem.Collections.Generic; -using System; -using System.Collections; -using System.Linq; using TMPro; using UnityEngine; using static TOHE.Translator; diff --git a/Patches/GameStartManagerPatch.cs b/Patches/GameStartManagerPatch.cs index c2a15c377..6e1ce4ab4 100644 --- a/Patches/GameStartManagerPatch.cs +++ b/Patches/GameStartManagerPatch.cs @@ -1,10 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Linq; using AmongUs.Data; using AmongUs.GameOptions; using HarmonyLib; using InnerNet; -using System; -using System.Collections.Generic; -using System.Linq; using TMPro; using TOHE.Roles.Neutral; using UnityEngine; @@ -308,7 +308,7 @@ public class GameStartRandomMap Main.LastShapeshifterCooldown.Value = AURoleOptions.ShapeshifterCooldown; AURoleOptions.ShapeshifterCooldown = 0f; - PlayerControl.LocalPlayer.RpcSyncSettings(GameOptionsManager.Instance.gameOptionsFactory.ToBytes(opt)); + PlayerControl.LocalPlayer.RpcSyncSettings(GameOptionsManager.Instance.gameOptionsFactory.ToBytes(opt, AprilFoolsMode.IsAprilFoolsModeToggledOn)); __instance.ReallyBegin(false); return false; @@ -371,7 +371,7 @@ class ResetStartStatePatch if (GameStates.IsCountDown) { Main.NormalOptions.KillCooldown = Options.DefaultKillCooldown; - PlayerControl.LocalPlayer.RpcSyncSettings(GameOptionsManager.Instance.gameOptionsFactory.ToBytes(GameOptionsManager.Instance.CurrentGameOptions)); + PlayerControl.LocalPlayer.RpcSyncSettings(GameOptionsManager.Instance.gameOptionsFactory.ToBytes(GameOptionsManager.Instance.CurrentGameOptions, AprilFoolsMode.IsAprilFoolsModeToggledOn)); } } } @@ -384,4 +384,4 @@ class UnrestrictedNumImpostorsPatch __result = Main.NormalOptions.NumImpostors; return false; } -} \ No newline at end of file +} diff --git a/Patches/HudPatch.cs b/Patches/HudPatch.cs index ea4b108e4..ea729f5ec 100644 --- a/Patches/HudPatch.cs +++ b/Patches/HudPatch.cs @@ -1,8 +1,8 @@ -using HarmonyLib; -using Il2CppSystem.Text; using System; using System.Collections.Generic; using System.Linq; +using HarmonyLib; +using Il2CppSystem.Text; using TMPro; using TOHE.Modules; using TOHE.Roles.AddOns.Common; @@ -93,7 +93,7 @@ class HudManagerPatch { var pc = Utils.GetPlayerById(item.Key); string prefix = first ? string.Empty : "\n"; - string text = $"{prefix}{(item.Key == 0 ? "Host" : $"{(pc == null ? $"ID {item.Key}" : $"{pc.GetRealName()}")}")} - {GetString(item.Value.ToString())}"; + string text = $"{prefix}{(item.Key == 0 ? "Host" : $"{(pc == null ? $"ID {item.Key}" : $"{pc.GetRealName()}")}")} - {GetString(item.Value.ToString())}"; resultText[item.Key] = text; first = false; } @@ -106,13 +106,13 @@ class HudManagerPatch var pc = Utils.GetPlayerById(item.Key); if (resultText.ContainsKey(item.Key)) { - string text = $" <#ffffff>({GetString(role.ToString())}<#ffffff>)"; + string text = $" <#ffffff>({GetString(role.ToString())}<#ffffff>)"; resultText[item.Key] += text; } else { string prefix = first ? string.Empty : "\n"; - string text = $"{prefix}{(item.Key == 0 ? "Host" : $"{(pc == null ? $"ID {item.Key}" : $"{pc.GetRealName()}")}")} - <#ffffff>({GetString(role.ToString())}<#ffffff>)"; + string text = $"{prefix}{(item.Key == 0 ? "Host" : $"{(pc == null ? $"ID {item.Key}" : $"{pc.GetRealName()}")}")} - <#ffffff>({GetString(role.ToString())}<#ffffff>)"; resultText[item.Key] = text; first = false; } @@ -161,11 +161,16 @@ class HudManagerPatch { if (player.IsAlive() || Options.CurrentGameMode is CustomGameMode.FFA or CustomGameMode.MoveAndStop or CustomGameMode.HotPotato) { + bool usesPetInsteadOfKill = false; if (player.GetCustomRole().UsesPetInsteadOfKill()) { - __instance.PetButton?.OverrideText("KillButtonText"); + __instance.PetButton?.OverrideText(GetString("KillButtonText")); + usesPetInsteadOfKill = true; } + ActionButton usedButton = __instance.KillButton; + if (usesPetInsteadOfKill) usedButton = __instance.PetButton; + Main.PlayerStates[player.PlayerId].Role.SetButtonTexts(__instance, player.PlayerId); switch (player.GetCustomRole()) @@ -173,9 +178,6 @@ class HudManagerPatch case CustomRoles.FireWorks: __instance.AbilityButton?.OverrideText((Main.PlayerStates[player.PlayerId].Role as FireWorks).nowFireWorksCount == 0 ? GetString("FireWorksExplosionButtonText") : GetString("FireWorksInstallAtionButtonText")); break; - //case CustomRoles.SerialKiller: - // SerialKiller.GetAbilityButtonText(__instance, player); - // break; case CustomRoles.Pestilence: __instance.KillButton?.OverrideText(GetString("KillButtonText")); break; @@ -191,25 +193,16 @@ class HudManagerPatch __instance.ImpostorVentButton.buttonLabelText.text = GetString("ArsonistVentButtonText"); break; case CustomRoles.Farseer: - __instance.KillButton?.OverrideText(GetString("FarseerKillButtonText")); + usedButton?.OverrideText(GetString("FarseerKillButtonText")); break; - //case CustomRoles.NWitch: - // __instance.KillButton.OverrideText($"{GetString("WitchControlButtonText")}"); - // break; - //case CustomRoles.BountyHunter: - // BountyHunter.SetAbilityButtonText(__instance); - // break; case CustomRoles.Capitalism: __instance.KillButton?.OverrideText(GetString("CapitalismButtonText")); break; case CustomRoles.Pelican: __instance.KillButton?.OverrideText(GetString("PelicanButtonText")); break; - //case CustomRoles.Counterfeiter: - // __instance.KillButton.OverrideText(GetString("CounterfeiterButtonText")); - // break; case CustomRoles.Analyzer: - __instance.KillButton?.OverrideText(GetString("AnalyzerKillButtonText")); + usedButton?.OverrideText(GetString("AnalyzerKillButtonText")); break; case CustomRoles.Pursuer: __instance.KillButton?.OverrideText(GetString("PursuerButtonText")); @@ -227,12 +220,12 @@ class HudManagerPatch __instance.KillButton?.OverrideText(GetString("FFFButtonText")); break; case CustomRoles.Gaulois: - __instance.KillButton?.OverrideText(GetString("GauloisKillButtonText")); + usedButton?.OverrideText(GetString("GauloisKillButtonText")); break; case CustomRoles.Aid: case CustomRoles.DonutDelivery: case CustomRoles.Medic: - __instance.KillButton?.OverrideText(GetString("MedicalerButtonText")); + usedButton?.OverrideText(GetString("MedicalerButtonText")); break; case CustomRoles.Gamer: __instance.KillButton?.OverrideText(GetString("GamerButtonText")); @@ -298,10 +291,10 @@ class HudManagerPatch break; case CustomRoles.Sheriff: - __instance.KillButton?.OverrideText(GetString("SheriffKillButtonText")); + usedButton?.OverrideText(GetString("SheriffKillButtonText")); break; case CustomRoles.Crusader: - __instance.KillButton?.OverrideText(GetString("CrusaderKillButtonText")); + usedButton?.OverrideText(GetString("CrusaderKillButtonText")); break; case CustomRoles.Totocalcio: __instance.KillButton?.OverrideText(GetString("TotocalcioKillButtonText")); @@ -323,10 +316,10 @@ class HudManagerPatch __instance.KillButton?.OverrideText(GetString("RememberButtonText")); break; case CustomRoles.Monarch: - __instance.KillButton?.OverrideText(GetString("MonarchKillButtonText")); + usedButton?.OverrideText(GetString("MonarchKillButtonText")); break; case CustomRoles.Deputy: - __instance.KillButton?.OverrideText(GetString("DeputyHandcuffText")); + usedButton?.OverrideText(GetString("DeputyHandcuffText")); break; case CustomRoles.Hangman: if (shapeshifting) __instance.KillButton?.OverrideText(GetString("HangmanKillButtonTextDuringSS")); @@ -395,6 +388,7 @@ class HudManagerPatch CustomRoles.YinYanger => YinYanger.ModeText(player), CustomRoles.WeaponMaster => WeaponMaster.GetHudAndProgressText(player.PlayerId), CustomRoles.Postman => Postman.GetHudText(player), + CustomRoles.Predator => Predator.GetSuffixAndHudText(player), CustomRoles.SoulHunter => SoulHunter.HUDText(player.PlayerId), CustomRoles.Chronomancer => Chronomancer.GetHudText(player.PlayerId), CustomRoles.Mafioso => Mafioso.GetHUDText(player), @@ -722,7 +716,7 @@ class TaskPanelBehaviourPatch List<(int, byte)> list = []; foreach (var id in Main.PlayerStates.Keys) list.Add((SoloKombatManager.GetRankOfScore(id), id)); list.Sort(); - AllText = list.Where(x => SummaryText.ContainsKey(x.Item2)).Aggregate(AllText, (current, id) => current + ("\r\n" + SummaryText[id.Item2])); + AllText = list.Where(x => SummaryText.ContainsKey(x.Item2)).Aggregate(AllText, (current, id) => current + "\r\n" + SummaryText[id.Item2]); AllText = $"{AllText}"; @@ -742,7 +736,7 @@ class TaskPanelBehaviourPatch List<(int, byte)> list2 = []; foreach (var id in Main.PlayerStates.Keys) list2.Add((FFAManager.GetRankOfScore(id), id)); list2.Sort(); - AllText = list2.Where(x => SummaryText2.ContainsKey(x.Item2)).Aggregate(AllText, (current, id) => current + ("\r\n" + SummaryText2[id.Item2])); + AllText = list2.Where(x => SummaryText2.ContainsKey(x.Item2)).Aggregate(AllText, (current, id) => current + "\r\n" + SummaryText2[id.Item2]); AllText = $"{AllText}"; @@ -779,7 +773,7 @@ class TaskPanelBehaviourPatch List<(int, byte)> list3 = []; foreach (var id in Main.PlayerStates.Keys) list3.Add((MoveAndStopManager.GetRankOfScore(id), id)); list3.Sort(); - list3 = [.. list3.OrderBy(x => (Utils.GetPlayerById(x.Item2).IsAlive()))]; + list3 = [.. list3.OrderBy(x => Utils.GetPlayerById(x.Item2).IsAlive())]; foreach (var id in list3.Where(x => SummaryText3.ContainsKey(x.Item2)).ToArray()) { bool alive = Utils.GetPlayerById(id.Item2).IsAlive(); diff --git a/Patches/IntroPatch.cs b/Patches/IntroPatch.cs index 7edec42dd..83704699b 100644 --- a/Patches/IntroPatch.cs +++ b/Patches/IntroPatch.cs @@ -1,9 +1,9 @@ -using AmongUs.GameOptions; -using HarmonyLib; -using Il2CppSystem.Collections.Generic; using System; using System.Linq; using System.Threading.Tasks; +using AmongUs.GameOptions; +using HarmonyLib; +using Il2CppSystem.Collections.Generic; using UnityEngine; using static TOHE.Translator; diff --git a/Patches/JoinGameButtonPatch.cs b/Patches/JoinGameButtonPatch.cs index a3896aace..b5915ac29 100644 --- a/Patches/JoinGameButtonPatch.cs +++ b/Patches/JoinGameButtonPatch.cs @@ -1,5 +1,5 @@ -using HarmonyLib; using System.Text.RegularExpressions; +using HarmonyLib; using UnityEngine; namespace TOHE; diff --git a/Patches/LadderPatch.cs b/Patches/LadderPatch.cs index 4734a806a..e9dc5f05c 100644 --- a/Patches/LadderPatch.cs +++ b/Patches/LadderPatch.cs @@ -1,6 +1,6 @@ -using HarmonyLib; +using System.Collections.Generic; +using HarmonyLib; using Hazel; -using System.Collections.Generic; using UnityEngine; namespace TOHE; diff --git a/Patches/LobbyListPatch.cs b/Patches/LobbyListPatch.cs index a5ce45588..d689fc92b 100644 --- a/Patches/LobbyListPatch.cs +++ b/Patches/LobbyListPatch.cs @@ -1,7 +1,7 @@ -using HarmonyLib; -using InnerNet; -using System; +using System; using System.Collections.Generic; +using HarmonyLib; +using InnerNet; using UnityEngine; namespace TOHE; diff --git a/Patches/LogoAndStampPatch.cs b/Patches/LogoAndStampPatch.cs index ad81d1e96..ca949dc87 100644 --- a/Patches/LogoAndStampPatch.cs +++ b/Patches/LogoAndStampPatch.cs @@ -1,6 +1,6 @@ -using BepInEx.Unity.IL2CPP.Utils; +using System.Collections; +using BepInEx.Unity.IL2CPP.Utils; using HarmonyLib; -using System.Collections; using TMPro; using UnityEngine; using static TOHE.Translator; diff --git a/Patches/MainMenuManagerPatch.cs b/Patches/MainMenuManagerPatch.cs index cffa546d5..c9e4c4549 100644 --- a/Patches/MainMenuManagerPatch.cs +++ b/Patches/MainMenuManagerPatch.cs @@ -1,5 +1,5 @@ -using HarmonyLib; using System; +using HarmonyLib; using TMPro; using TOHE.Modules; using UnityEngine; @@ -112,29 +112,18 @@ public class MainMenuManagerPatch var bottomTemplate = GameObject.Find("InventoryButton"); if (bottomTemplate == null) return; - - var HorseButton = Object.Instantiate(bottomTemplate, bottomTemplate.transform.parent); - var passiveHorseButton = HorseButton.GetComponent(); - var spriteHorseButton = HorseButton.GetComponent(); - if (HorseModePatch.isHorseMode) spriteHorseButton.transform.localScale *= -1; - - spriteHorseButton.sprite = Utils.LoadSprite("TOHE.Resources.Images.HorseButton.png", 75f); - passiveHorseButton.OnClick = new(); - passiveHorseButton.OnClick.AddListener((Action)(() => { RunLoginPatch.ClickCount++; if (RunLoginPatch.ClickCount == 10) PlayerControl.LocalPlayer.RPCPlayCustomSound("Gunload", true); if (RunLoginPatch.ClickCount == 20) PlayerControl.LocalPlayer.RPCPlayCustomSound("AWP", true); - spriteHorseButton.transform.localScale *= -1; - HorseModePatch.isHorseMode = !HorseModePatch.isHorseMode; var particles = Object.FindObjectOfType(); if (particles != null) { particles.pool.ReclaimAll(); particles.Start(); } - })); + } //var DleksButton = Object.Instantiate(bottomTemplate, bottomTemplate.transform.parent); //var passiveDleksButton = DleksButton.GetComponent(); //var spriteDleksButton = DleksButton.GetComponent(); diff --git a/Patches/MeetingHudPatch.cs b/Patches/MeetingHudPatch.cs index a45779ac2..9577d4218 100644 --- a/Patches/MeetingHudPatch.cs +++ b/Patches/MeetingHudPatch.cs @@ -1,8 +1,8 @@ -using HarmonyLib; using System; using System.Collections.Generic; using System.Linq; using System.Text; +using HarmonyLib; using TOHE.Roles.Crewmate; using TOHE.Roles.Impostor; using TOHE.Roles.Neutral; @@ -715,6 +715,7 @@ class MeetingHudStartPatch } Main.CyberStarDead.Clear(); + Main.DemolitionistDead.Clear(); Express.SpeedNormal.Clear(); Express.SpeedUp.Clear(); Main.DetectiveNotify.Clear(); diff --git a/Patches/OutroPatch.cs b/Patches/OutroPatch.cs index 1bc159ae5..c67b3c9fa 100644 --- a/Patches/OutroPatch.cs +++ b/Patches/OutroPatch.cs @@ -1,8 +1,8 @@ -using HarmonyLib; using System; using System.Collections.Generic; using System.Linq; using System.Text; +using HarmonyLib; using TMPro; using TOHE.Modules; using TOHE.Roles.Neutral; @@ -171,8 +171,8 @@ class SetEverythingUpPatch { byte id = Main.winnerList[i1]; if (Main.winnerNameList[i1].RemoveHtmlTags() != winningPlayerData2.PlayerName.RemoveHtmlTags()) continue; - var role = Main.PlayerStates[id].MainRole; + var role = Main.PlayerStates[id].MainRole; var color = Main.roleColors[role]; var rolename = Utils.GetRoleName(role); @@ -261,7 +261,6 @@ class SetEverythingUpPatch switch (CustomWinnerHolder.WinnerTeam) { - //通常勝利 case CustomWinner.Crewmate: CustomWinnerColor = Utils.GetRoleColorCode(CustomRoles.Engineer); __instance.BackgroundBar.material.color = Utils.GetRoleColor(CustomRoles.Engineer); @@ -278,14 +277,12 @@ class SetEverythingUpPatch CustomWinnerColor = Utils.GetRoleColorCode(CustomRoles.Egoist); __instance.BackgroundBar.material.color = Utils.GetRoleColor(CustomRoles.Egoist); break; - //特殊勝利 case CustomWinner.Terrorist: __instance.BackgroundBar.material.color = Utils.GetRoleColor(CustomRoles.Terrorist); break; case CustomWinner.Lovers: __instance.BackgroundBar.material.color = Utils.GetRoleColor(CustomRoles.Lovers); break; - //引き分け処理 case CustomWinner.Draw: __instance.WinText.text = GetString("ForceEnd"); __instance.WinText.color = Color.white; @@ -300,7 +297,6 @@ class SetEverythingUpPatch WinnerText.text = GetString("NeutralsLeftText"); WinnerText.color = Utils.GetRoleColor(CustomRoles.Executioner); break; - //全滅 case CustomWinner.None: __instance.WinText.text = string.Empty; __instance.WinText.color = Color.black; @@ -345,7 +341,7 @@ class SetEverythingUpPatch RoleSummaryObject.transform.localScale = new(1f, 1f, 1f); StringBuilder sb = new($"{GetString("RoleSummaryText")}\n"); - List cloneRoles = [.. Main.PlayerStates.Keys]; + List cloneRoles = [..Main.PlayerStates.Keys]; foreach (byte id in Main.winnerList.ToArray()) { if (EndGamePatch.SummaryText[id].Contains("")) continue; @@ -423,12 +419,10 @@ class SetEverythingUpPatch return name; } - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //Utils.ApplySuffix(); static string GetWinnerRoleName(CustomRoles role) { var name = GetString($"WinnerRoleText.{Enum.GetName(typeof(CustomRoles), role)}"); - if (name == string.Empty || name.StartsWith("*") || name.StartsWith(" { NotifyRoles(NoCache: true); }, - 1.2f, "ShapeShiftNotify"); + _ = new LateTask(() => { NotifyRoles(NoCache: true); }, 1.2f, "ShapeShiftNotify"); } if ((!shapeshifting || !isSSneeded) && !Swapster.FirstSwapTarget.ContainsKey(shapeshifter.PlayerId)) @@ -1236,7 +1246,6 @@ class FixedUpdatePatch if (target.AmOwner && GameStates.IsInTask) { - //targetが自分自身 if (target.Is(CustomRoles.Arsonist) && target.IsDouseDone()) RealName = ColorString(GetRoleColor(CustomRoles.Arsonist), GetString("EnterVentToWin")); else if (target.Is(CustomRoles.Revolutionist) && target.IsDrawDone()) @@ -1263,19 +1272,19 @@ class FixedUpdatePatch // Name Color Manager RealName = RealName.ApplyNameColorData(seer, target, false); - if (seer.GetCustomRole().IsCrewmate() && seer.Is(CustomRoles.Madmate) && Marshall.MadmateCanFindMarshall) //seerがインポスター + if (seer.GetCustomRole().IsCrewmate() && seer.Is(CustomRoles.Madmate) && Marshall.MadmateCanFindMarshall) { - if (target.Is(CustomRoles.Marshall) && target.GetTaskState().IsTaskFinished) //targetがタスクを終わらせたマッドスニッチ - Mark.Append(ColorString(GetRoleColor(CustomRoles.Marshall), "★")); //targetにマーク付与 + if (target.Is(CustomRoles.Marshall) && target.GetTaskState().IsTaskFinished) + Mark.Append(ColorString(GetRoleColor(CustomRoles.Marshall), "★")); } - switch (target.GetCustomRole()) //seerがインポスター + switch (target.GetCustomRole()) { case CustomRoles.Snitch when seer.GetCustomRole().IsImpostor() && target.Is(CustomRoles.Madmate) && target.GetTaskState().IsTaskFinished: - Mark.Append(ColorString(GetRoleColor(CustomRoles.Impostor), "★")); //targetにマーク付与 + Mark.Append(ColorString(GetRoleColor(CustomRoles.Impostor), "★")); break; case CustomRoles.Marshall when seer.GetCustomRole().IsCrewmate() && target.GetTaskState().IsTaskFinished: - Mark.Append(ColorString(GetRoleColor(CustomRoles.Marshall), "★")); //targetにマーク付与 + Mark.Append(ColorString(GetRoleColor(CustomRoles.Marshall), "★")); break; case CustomRoles.SuperStar when Options.EveryOneKnowSuperStar.GetBool(): Mark.Append(ColorString(GetRoleColor(CustomRoles.SuperStar), "★")); @@ -1412,6 +1421,9 @@ class FixedUpdatePatch case CustomRoles.Tiger when target.PlayerId == seer.PlayerId: Suffix.Append(Tiger.GetSuffix(seer)); break; + case CustomRoles.Predator when seer.PlayerId == target.PlayerId: + Suffix.Append(Predator.GetSuffixAndHudText(seer)); + break; } Mark.Append(Totocalcio.TargetMark(seer, target)); @@ -1491,11 +1503,7 @@ class FixedUpdatePatch if (Options.CurrentGameMode == CustomGameMode.SoloKombat) Suffix.Append(SoloKombatManager.GetDisplayHealth(target)); - /*if(main.AmDebugger.Value && main.BlockKilling.TryGetValue(target.PlayerId, out var isBlocked)) { - Mark = isBlocked ? "(true)" : "(false)"; - }*/ - - //Devourer + // Devourer if (Devourer.HideNameOfConsumedPlayer.GetBool() && Devourer.playerIdList.Any(x => Main.PlayerStates[x].Role is Devourer { IsEnable: true } dv && dv.PlayerSkinsCosumed.Contains(seer.PlayerId))) RealName = GetString("DevouredName"); @@ -1504,7 +1512,6 @@ class FixedUpdatePatch RealName = $"{RealName} "; string DeathReason = seer.Data.IsDead && seer.KnowDeathReason(target) ? $"\n({ColorString(GetRoleColor(CustomRoles.Doctor), GetVitalText(target.PlayerId))})" : string.Empty; - //Mark・Suffixの適用 var currentText = target.cosmetics.nameText.text; var changeTo = $"{RealName}{DeathReason}{Mark}\r\n{Suffix}"; diff --git a/Patches/PlayerJoinAndLeftPatch.cs b/Patches/PlayerJoinAndLeftPatch.cs index 5076ced92..811daaa96 100644 --- a/Patches/PlayerJoinAndLeftPatch.cs +++ b/Patches/PlayerJoinAndLeftPatch.cs @@ -1,10 +1,10 @@ +using System; +using System.Text.RegularExpressions; +using System.Threading.Tasks; using AmongUs.Data; using AmongUs.GameOptions; using HarmonyLib; using InnerNet; -using System; -using System.Text.RegularExpressions; -using System.Threading.Tasks; using TOHE.Modules; using TOHE.Roles.Crewmate; using TOHE.Roles.Neutral; @@ -143,17 +143,27 @@ class OnPlayerLeftPatch Main.PlayerStates[lovers.PlayerId].RemoveSubRole(CustomRoles.Lovers); } } - - if (data.Character.Is(CustomRoles.Executioner) && Executioner.Target.ContainsKey(data.Character.PlayerId)) - Executioner.ChangeRole(data.Character); + + switch (data.Character.GetCustomRole()) + { + case CustomRoles.Executioner when Executioner.Target.ContainsKey(data.Character.PlayerId): + Executioner.ChangeRole(data.Character); + break; + case CustomRoles.Lawyer when Lawyer.Target.ContainsKey(data.Character.PlayerId): + Lawyer.ChangeRole(data.Character); + break; + case CustomRoles.Pelican: + Pelican.OnPelicanDied(data.Character.PlayerId); + break; + case CustomRoles.Markseeker: + Markseeker.OnDeath(data.Character); + break; + } + if (Executioner.Target.ContainsValue(data.Character.PlayerId)) Executioner.ChangeRoleByTarget(data.Character); - if (data.Character.Is(CustomRoles.Lawyer) && Lawyer.Target.ContainsKey(data.Character.PlayerId)) - Lawyer.ChangeRole(data.Character); if (Lawyer.Target.ContainsValue(data.Character.PlayerId)) Lawyer.ChangeRoleByTarget(data.Character); - if (data.Character.Is(CustomRoles.Pelican)) - Pelican.OnPelicanDied(data.Character.PlayerId); if (Spiritualist.SpiritualistTarget == data.Character.PlayerId) Spiritualist.RemoveTarget(); Postman.CheckAndResetTargets(data.Character); diff --git a/Patches/RandomSpawnPatch.cs b/Patches/RandomSpawnPatch.cs index 2208e08eb..d0387b3f9 100644 --- a/Patches/RandomSpawnPatch.cs +++ b/Patches/RandomSpawnPatch.cs @@ -1,7 +1,7 @@ -using HarmonyLib; using System; using System.Collections.Generic; using System.Linq; +using HarmonyLib; using TOHE.Roles.Impostor; using UnityEngine; diff --git a/Patches/SabotageSystemPatch.cs b/Patches/SabotageSystemPatch.cs index 8d1f3e99d..9afa66b2b 100644 --- a/Patches/SabotageSystemPatch.cs +++ b/Patches/SabotageSystemPatch.cs @@ -1,6 +1,7 @@ +using System.Linq; using HarmonyLib; using Hazel; -using System.Linq; +using TOHE.Roles.Neutral; namespace TOHE; @@ -248,6 +249,29 @@ public static class SabotageSystemTypeRepairDamagePatch modifiedCooldownSec = Options.SabotageCooldown.GetFloat(); } + public static bool Prefix([HarmonyArgument(0)] PlayerControl player) + { + if (Options.DisableSabotage.GetBool() || Options.CurrentGameMode is CustomGameMode.SoloKombat or CustomGameMode.FFA or CustomGameMode.MoveAndStop or CustomGameMode.HotPotato) return false; + if (Main.BlockSabo.Count > 0) return false; + if (Glitch.hackedIdList.ContainsKey(player.PlayerId)) + { + player.Notify(string.Format(Translator.GetString("HackedByGlitch"), "Sabotage")); + return false; + } + + if (player.Is(CustomRoleTypes.Impostor) && !player.IsAlive() && Options.DeadImpCantSabotage.GetBool()) return false; + if (player.Is(CustomRoleTypes.Impostor) && (player.IsAlive() || !Options.DeadImpCantSabotage.GetBool()) && !player.Is(CustomRoles.Minimalism) && !player.Is(CustomRoles.Mafioso)) return true; + return player.GetCustomRole() switch + { + CustomRoles.Jackal when Jackal.CanSabotage.GetBool() => true, + CustomRoles.Sidekick when Jackal.CanSabotageSK.GetBool() => true, + CustomRoles.Traitor when Traitor.CanSabotage.GetBool() => true, + CustomRoles.Parasite when player.IsAlive() => true, + CustomRoles.Refugee when player.IsAlive() => true, + _ => Main.PlayerStates[player.PlayerId].Role.OnSabotage(player) && Main.PlayerStates[player.PlayerId].Role.CanUseSabotage(player) + }; + } + public static void Postfix(SabotageSystemType __instance) { if (!isCooldownModificationEnabled || !AmongUsClient.Instance.AmHost) diff --git a/Patches/ShipStatusPatch.cs b/Patches/ShipStatusPatch.cs index dfeacdb85..0ad693b79 100644 --- a/Patches/ShipStatusPatch.cs +++ b/Patches/ShipStatusPatch.cs @@ -1,8 +1,8 @@ +using System.Collections.Generic; +using System.Linq; using BepInEx; using HarmonyLib; using Hazel; -using System.Collections.Generic; -using System.Linq; using TOHE.Patches; using TOHE.Roles.AddOns.Crewmate; using TOHE.Roles.AddOns.Impostor; @@ -134,7 +134,7 @@ class RepairSystemPatch CustomRoles.Traitor when Traitor.CanSabotage.GetBool() => true, CustomRoles.Parasite when player.IsAlive() => true, CustomRoles.Refugee when player.IsAlive() => true, - _ => Main.PlayerStates[player.PlayerId].Role.OnSabotage(player) && Main.PlayerStates[player.PlayerId].Role.CanUseSabotage(player) + _ => Main.PlayerStates[player.PlayerId].Role.CanUseSabotage(player) }; case SystemTypes.Security when amount == 1: var camerasDisabled = (MapNames)Main.NormalOptions.MapId switch @@ -280,7 +280,7 @@ class BeginPatch { Logger.CurrentMethod(); - //Should I initialize the host role here? + //Should I initialize the host role here? - no } } @@ -289,7 +289,7 @@ class CheckTaskCompletionPatch { public static bool Prefix(ref bool __result) { - if (Options.DisableTaskWin.GetBool() || Options.NoGameEnd.GetBool() || TaskState.InitialTotalTasks == 0 || Options.CurrentGameMode is CustomGameMode.SoloKombat or CustomGameMode.FFA or CustomGameMode.MoveAndStop or CustomGameMode.HotPotato) + if (Options.DisableTaskWin.GetBool() || Options.NoGameEnd.GetBool() || TaskState.InitialTotalTasks == 0 || (Options.DisableTaskWinIfAllCrewsAreDead.GetBool() && !Main.AllAlivePlayerControls.Any(x => x.Is(CustomRoleTypes.Crewmate))) || Options.CurrentGameMode is CustomGameMode.SoloKombat or CustomGameMode.FFA or CustomGameMode.MoveAndStop or CustomGameMode.HotPotato) { __result = false; return false; diff --git a/Patches/TaskAdderPatch.cs b/Patches/TaskAdderPatch.cs index 61baec521..11e57f276 100644 --- a/Patches/TaskAdderPatch.cs +++ b/Patches/TaskAdderPatch.cs @@ -1,8 +1,8 @@ -using AmongUs.GameOptions; -using HarmonyLib; using System; using System.Collections; using System.Linq; +using AmongUs.GameOptions; +using HarmonyLib; using UnityEngine; using Object = UnityEngine.Object; diff --git a/Patches/onGameStartedPatch.cs b/Patches/onGameStartedPatch.cs index 0d88d301a..64f8f3a8f 100644 --- a/Patches/onGameStartedPatch.cs +++ b/Patches/onGameStartedPatch.cs @@ -1,9 +1,9 @@ -using AmongUs.GameOptions; -using HarmonyLib; -using Hazel; using System; using System.Collections.Generic; using System.Linq; +using AmongUs.GameOptions; +using HarmonyLib; +using Hazel; using TOHE.Modules; using TOHE.Roles.AddOns.Common; using TOHE.Roles.AddOns.Crewmate; @@ -74,6 +74,7 @@ internal class ChangeRoleSettings Main.ForCrusade = []; Main.KillGhoul = []; Main.CyberStarDead = []; + Main.DemolitionistDead = []; Main.KilledDiseased = []; Main.KilledAntidote = []; Main.WorkaholicAlive = []; diff --git a/Resources/Lang/en_US.json b/Resources/Lang/en_US.json index 1840b2c00..becd3372e 100644 --- a/Resources/Lang/en_US.json +++ b/Resources/Lang/en_US.json @@ -63,15 +63,6 @@ "CrewOnlyAddonSettings": "Can guess Crewmate add-ons", "NeutralAddonSettings": "Can guess Neutral add-ons", "BasicAddonSettings": "Can guess global add-ons", - "ROT.Impostor": "★ Impostor Roles", - "ROT.Crewmate_Normal": "★ Non-Killing Crewmate Roles", - "ROT.Crewmate_ImpostorBased": "★ Killing Crewmate Roles", - "ROT.Neutral_NonKilling": "★ Non-Killing Neutral Roles", - "ROT.Neutral_Killing": "★ Killing Neutral Roles", - "ROT.Vanilla": "★ Vanilla Roles", - "ROT.Basic": "★ Basic Roles", - "ROT.BasicNK": "★ Basic Neutral Killing Roles", - "ROT.BasicNNK": "★ Basic Non-Killing Neutral Roles", "GM": "Game Master", "Sunnyboy": "Sunnyboy", "Bard": "Bard", diff --git a/Roles/AddOns/Crewmate/Stressed.cs b/Roles/AddOns/Crewmate/Stressed.cs index 9462c7601..166cb9ca8 100644 --- a/Roles/AddOns/Crewmate/Stressed.cs +++ b/Roles/AddOns/Crewmate/Stressed.cs @@ -1,6 +1,6 @@ -using Hazel; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; +using Hazel; using TOHE.Modules; using static TOHE.Options; using static TOHE.Translator; diff --git a/Roles/AddOns/Impostor/Damocles.cs b/Roles/AddOns/Impostor/Damocles.cs index 9a40c14ca..4697d6963 100644 --- a/Roles/AddOns/Impostor/Damocles.cs +++ b/Roles/AddOns/Impostor/Damocles.cs @@ -1,7 +1,7 @@ -using Hazel; -using System; +using System; using System.Collections.Generic; using System.Linq; +using Hazel; using TOHE.Modules; using static TOHE.Options; using static TOHE.Translator; diff --git a/Roles/Crewmate/Addict.cs b/Roles/Crewmate/Addict.cs index 015e92376..39033c666 100644 --- a/Roles/Crewmate/Addict.cs +++ b/Roles/Crewmate/Addict.cs @@ -1,6 +1,6 @@ -using AmongUs.GameOptions; using System; using System.Collections.Generic; +using AmongUs.GameOptions; using UnityEngine; namespace TOHE.Roles.Crewmate diff --git a/Roles/Crewmate/Aid.cs b/Roles/Crewmate/Aid.cs index ef27f44c2..32530d24f 100644 --- a/Roles/Crewmate/Aid.cs +++ b/Roles/Crewmate/Aid.cs @@ -1,5 +1,6 @@ -using AmongUs.GameOptions; using System.Collections.Generic; +using System.Text; +using AmongUs.GameOptions; namespace TOHE.Roles.Crewmate { diff --git a/Roles/Crewmate/Alchemist.cs b/Roles/Crewmate/Alchemist.cs index 035b45b6c..a647f411e 100644 --- a/Roles/Crewmate/Alchemist.cs +++ b/Roles/Crewmate/Alchemist.cs @@ -1,8 +1,8 @@ -using AmongUs.GameOptions; -using Hazel; using System.Collections.Generic; using System.Linq; using System.Text; +using AmongUs.GameOptions; +using Hazel; using TOHE.Modules; using TOHE.Roles.Neutral; @@ -340,17 +340,12 @@ namespace TOHE.Roles.Crewmate if (am.FixNextSabo) str.Append($"\n{GetString("QuickFixPotionWaitForUse")}"); } - if (UsePets.GetBool() && Main.AbilityCD.TryGetValue(pc.PlayerId, out var CD)) - { - str.Append($"\n{GetString("CD")}: {CD.TOTALCD - (Utils.TimeStamp - CD.START_TIMESTAMP) + 1}s"); - } - return str.ToString(); } public override string GetProgressText(byte playerId, bool comms) { - if (Utils.GetPlayerById(playerId) == null || !GameStates.IsInTask || !PlayerControl.LocalPlayer.IsAlive() || Utils.GetPlayerById(playerId).IsModClient()) return string.Empty; + if (Utils.GetPlayerById(playerId) == null || !GameStates.IsInTask || Utils.GetPlayerById(playerId).IsModClient()) return string.Empty; var str = new StringBuilder(); switch (PotionID) { diff --git a/Roles/Crewmate/Analyzer.cs b/Roles/Crewmate/Analyzer.cs index a2877c003..a4806dfa0 100644 --- a/Roles/Crewmate/Analyzer.cs +++ b/Roles/Crewmate/Analyzer.cs @@ -1,6 +1,6 @@ -using AmongUs.GameOptions; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; +using AmongUs.GameOptions; using UnityEngine; using static TOHE.Options; using static TOHE.Translator; diff --git a/Roles/Crewmate/Benefactor.cs b/Roles/Crewmate/Benefactor.cs index f82607921..6858d56c6 100644 --- a/Roles/Crewmate/Benefactor.cs +++ b/Roles/Crewmate/Benefactor.cs @@ -1,7 +1,7 @@ -using Hazel; -using System; +using System; using System.Collections.Generic; using System.Linq; +using Hazel; using TOHE.Modules; using static TOHE.Translator; @@ -62,7 +62,6 @@ namespace TOHE.Roles.Crewmate if (!isShield) writer.Write(TaskMarkPerRound[benefactorId]); AmongUsClient.Instance.FinishRpcImmediately(writer); } - public static void ReceiveRPC(MessageReader reader) { byte benefactorID = reader.ReadByte(); @@ -87,18 +86,15 @@ namespace TOHE.Roles.Crewmate { if (taskIndex.ContainsKey(benefactorID)) taskIndex[benefactorID].Remove(taskInd); } - if (clearAll && taskIndex.ContainsKey(benefactorID)) taskIndex[benefactorID].Clear(); if (IsShield) { shieldedPlayers.TryAdd(shieldedId, Utils.TimeStamp); } - if (shieldExpire) { shieldedPlayers.Remove(shieldedId); } - if (clearAll && shieldedPlayers.Count > 0) shieldedPlayers.Clear(); } @@ -147,7 +143,6 @@ namespace TOHE.Roles.Crewmate Logger.Info($"Max task per round ({TaskMarkPerRound[playerId]}) reached for {player.GetNameWithRole()}", "Benefactor"); return; } - TaskMarkPerRound[playerId]++; if (!taskIndex.ContainsKey(playerId)) taskIndex[playerId] = []; taskIndex[playerId].Add(task.Index); @@ -172,4 +167,4 @@ namespace TOHE.Roles.Crewmate } } } -} \ No newline at end of file +} diff --git a/Roles/Crewmate/Bloodhound.cs b/Roles/Crewmate/Bloodhound.cs index 1a9101120..0f73b660d 100644 --- a/Roles/Crewmate/Bloodhound.cs +++ b/Roles/Crewmate/Bloodhound.cs @@ -1,6 +1,6 @@ -using Hazel; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; +using Hazel; using TOHE.Modules; using UnityEngine; diff --git a/Roles/Crewmate/CameraMan.cs b/Roles/Crewmate/CameraMan.cs index b3214a068..f664daeea 100644 --- a/Roles/Crewmate/CameraMan.cs +++ b/Roles/Crewmate/CameraMan.cs @@ -1,6 +1,6 @@ -using AmongUs.GameOptions; using System; using System.Collections.Generic; +using AmongUs.GameOptions; using UnityEngine; namespace TOHE.Roles.Crewmate diff --git a/Roles/Crewmate/CandleLighter.cs b/Roles/Crewmate/CandleLighter.cs index 10cf6fcaf..d20499a90 100644 --- a/Roles/Crewmate/CandleLighter.cs +++ b/Roles/Crewmate/CandleLighter.cs @@ -1,6 +1,6 @@ -using AmongUs.GameOptions; -using System; +using System; using System.Collections.Generic; +using AmongUs.GameOptions; using UnityEngine; namespace TOHE.Roles.Crewmate diff --git a/Roles/Crewmate/Cleanser.cs b/Roles/Crewmate/Cleanser.cs index c2825384a..172caf2b5 100644 --- a/Roles/Crewmate/Cleanser.cs +++ b/Roles/Crewmate/Cleanser.cs @@ -1,5 +1,5 @@ -using Hazel; -using System.Collections.Generic; +using System.Collections.Generic; +using Hazel; using TOHE.Modules; using UnityEngine; using static TOHE.Options; diff --git a/Roles/Crewmate/CopyCat.cs b/Roles/Crewmate/CopyCat.cs index ee1d4bd26..09e4f98a8 100644 --- a/Roles/Crewmate/CopyCat.cs +++ b/Roles/Crewmate/CopyCat.cs @@ -50,6 +50,11 @@ public class CopyCat : RoleBase public override bool IsEnable => playerIdList.Count > 0; public override void SetKillCooldown(byte id) => Main.AllPlayerKillCooldown[id] = Utils.GetPlayerById(id).IsAlive() ? CurrentKillCooldown : 0f; + public override bool CanUseKillButton(PlayerControl pc) + { + return pc.IsAlive(); + } + public static void ResetRole() { foreach (var player in playerIdList) diff --git a/Roles/Crewmate/CrewmateVanillaRoles.cs b/Roles/Crewmate/CrewmateVanillaRoles.cs deleted file mode 100644 index e554f9c33..000000000 --- a/Roles/Crewmate/CrewmateVanillaRoles.cs +++ /dev/null @@ -1,20 +0,0 @@ -using static TOHE.Options; - -namespace TOHE.Roles.Crewmate -{ - internal static class CrewmateVanillaRoles - { - public static void SetupCustomOption() - { - SetupRoleOptions(5050, TabGroup.CrewmateRoles, CustomRoles.CrewmateTOHE); - SetupRoleOptions(5000, TabGroup.CrewmateRoles, CustomRoles.EngineerTOHE); - SetupRoleOptions(5100, TabGroup.CrewmateRoles, CustomRoles.ScientistTOHE); - ScientistCD = FloatOptionItem.Create(5110, "VitalsCooldown", new(1f, 250f, 1f), 3f, TabGroup.CrewmateRoles, false) - .SetParent(CustomRoleSpawnChances[CustomRoles.ScientistTOHE]) - .SetValueFormat(OptionFormat.Seconds); - ScientistDur = FloatOptionItem.Create(5111, "VitalsDuration", new(1f, 250f, 1f), 15f, TabGroup.CrewmateRoles, false) - .SetParent(CustomRoleSpawnChances[CustomRoles.ScientistTOHE]) - .SetValueFormat(OptionFormat.Seconds); - } - } -} diff --git a/Roles/Crewmate/Crusader.cs b/Roles/Crewmate/Crusader.cs index 1557a7a5a..80a8de680 100644 --- a/Roles/Crewmate/Crusader.cs +++ b/Roles/Crewmate/Crusader.cs @@ -1,5 +1,5 @@ -using AmongUs.GameOptions; using System.Collections.Generic; +using AmongUs.GameOptions; namespace TOHE.Roles.Crewmate; diff --git a/Roles/Crewmate/CyberStar.cs b/Roles/Crewmate/CyberStar.cs deleted file mode 100644 index e0852375e..000000000 --- a/Roles/Crewmate/CyberStar.cs +++ /dev/null @@ -1,20 +0,0 @@ -using static TOHE.Options; - -namespace TOHE.Roles.Crewmate -{ - internal static class CyberStar - { - public static void SetupCustomOption() - { - SetupRoleOptions(5300, TabGroup.CrewmateRoles, CustomRoles.CyberStar); - ImpKnowCyberStarDead = BooleanOptionItem.Create(5400, "ImpKnowCyberStarDead", false, TabGroup.CrewmateRoles, false) - .SetParent(CustomRoleSpawnChances[CustomRoles.CyberStar]); - NeutralKnowCyberStarDead = BooleanOptionItem.Create(5500, "NeutralKnowCyberStarDead", false, TabGroup.CrewmateRoles, false) - .SetParent(CustomRoleSpawnChances[CustomRoles.CyberStar]); - } - - public static void OnDeath(PlayerControl seer) - { - } - } -} diff --git a/Roles/Crewmate/Demolitionist.cs b/Roles/Crewmate/Demolitionist.cs deleted file mode 100644 index 4571944ca..000000000 --- a/Roles/Crewmate/Demolitionist.cs +++ /dev/null @@ -1,41 +0,0 @@ -using TOHE.Modules; -using static TOHE.Options; - -namespace TOHE.Roles.Crewmate -{ - internal static class Demolitionist - { - public static void SetupCustomOption() - { - SetupSingleRoleOptions(5550, TabGroup.CrewmateRoles, CustomRoles.Demolitionist, 1); - DemolitionistVentTime = FloatOptionItem.Create(5552, "DemolitionistVentTime", new(0f, 90f, 1f), 5f, TabGroup.CrewmateRoles, false) - .SetParent(CustomRoleSpawnChances[CustomRoles.Demolitionist]) - .SetValueFormat(OptionFormat.Seconds); - DemolitionistKillerDiesOnMeetingCall = BooleanOptionItem.Create(5553, "DemolitionistKillerDiesOnMeetingCall", false, TabGroup.CrewmateRoles, false) - .SetParent(CustomRoleSpawnChances[CustomRoles.Demolitionist]); - } - - public static void OnDeath(PlayerControl killer, PlayerControl target) - { - killer.Notify(Utils.ColorString(Utils.GetRoleColor(CustomRoles.Demolitionist), Translator.GetString("OnDemolitionistDead"))); - killer.KillFlash(); - _ = new LateTask(() => - { - if (!killer.inVent && (killer.PlayerId != target.PlayerId)) - { - if ((DemolitionistKillerDiesOnMeetingCall.GetBool() || GameStates.IsInTask) && killer.IsAlive()) - { - killer.Suicide(PlayerState.DeathReason.Demolished, target); - RPC.PlaySoundRPC(killer.PlayerId, Sounds.KillSound); - } - } - else - { - if (killer.IsModClient()) RPC.PlaySoundRPC(killer.PlayerId, Sounds.TaskComplete); - else killer.RpcGuardAndKill(killer); - killer.SetKillCooldown(Main.AllPlayerKillCooldown[killer.PlayerId] - (DemolitionistVentTime.GetFloat() + 0.5f)); - } - }, DemolitionistVentTime.GetFloat() + 0.5f); - } - } -} diff --git a/Roles/Crewmate/Deputy.cs b/Roles/Crewmate/Deputy.cs index ad9765a51..c2f55f886 100644 --- a/Roles/Crewmate/Deputy.cs +++ b/Roles/Crewmate/Deputy.cs @@ -1,5 +1,5 @@ -using AmongUs.GameOptions; -using System.Collections.Generic; +using System.Collections.Generic; +using AmongUs.GameOptions; using static TOHE.Options; using static TOHE.Translator; diff --git a/Roles/Crewmate/Detective.cs b/Roles/Crewmate/Detective.cs index fd8a4b446..2a31ff19d 100644 --- a/Roles/Crewmate/Detective.cs +++ b/Roles/Crewmate/Detective.cs @@ -2,13 +2,6 @@ { internal static class Detective { - public static void SetupCustomOption() - { - Options.SetupRoleOptions(6600, TabGroup.CrewmateRoles, CustomRoles.Detective); - Options.DetectiveCanknowKiller = BooleanOptionItem.Create(6610, "DetectiveCanknowKiller", true, TabGroup.CrewmateRoles, false) - .SetParent(Options.CustomRoleSpawnChances[CustomRoles.Detective]); - } - public static void OnReportDeadBody(PlayerControl player, PlayerControl tpc) { string msg = string.Format(Translator.GetString("DetectiveNoticeVictim"), tpc.GetRealName(), tpc.GetDisplayRoleName()); diff --git a/Roles/Crewmate/DonutDelivery.cs b/Roles/Crewmate/DonutDelivery.cs index b3f8fbd49..08cb9d1e6 100644 --- a/Roles/Crewmate/DonutDelivery.cs +++ b/Roles/Crewmate/DonutDelivery.cs @@ -1,5 +1,5 @@ -using AmongUs.GameOptions; -using System.Collections.Generic; +using System.Collections.Generic; +using AmongUs.GameOptions; using static TOHE.Options; using static TOHE.Translator; diff --git a/Roles/Crewmate/Doormaster.cs b/Roles/Crewmate/Doormaster.cs index 5ed35a9b4..2c701b555 100644 --- a/Roles/Crewmate/Doormaster.cs +++ b/Roles/Crewmate/Doormaster.cs @@ -1,5 +1,5 @@ -using AmongUs.GameOptions; using System.Collections.Generic; +using AmongUs.GameOptions; using TOHE.Modules; namespace TOHE.Roles.Crewmate diff --git a/Roles/Crewmate/DovesOfNeace.cs b/Roles/Crewmate/DovesOfNeace.cs index ccab7e9cd..1a9f853d7 100644 --- a/Roles/Crewmate/DovesOfNeace.cs +++ b/Roles/Crewmate/DovesOfNeace.cs @@ -1,8 +1,9 @@ -using AmongUs.GameOptions; +using System.Linq; +using AmongUs.GameOptions; using HarmonyLib; -using System.Linq; using TOHE.Modules; using TOHE.Roles.Impostor; +using static TOHE.Options; namespace TOHE.Roles.Crewmate { @@ -11,10 +12,27 @@ namespace TOHE.Roles.Crewmate public static bool On; public override bool IsEnable => On; + public static void SetupCustomOption() + { + SetupRoleOptions(7700, TabGroup.CrewmateRoles, CustomRoles.DovesOfNeace); + DovesOfNeaceCooldown = FloatOptionItem.Create(7710, "DovesOfNeaceCooldown", new(0f, 180f, 1f), 7f, TabGroup.CrewmateRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.DovesOfNeace]) + .SetValueFormat(OptionFormat.Seconds); + DovesOfNeaceMaxOfUseage = IntegerOptionItem.Create(7711, "DovesOfNeaceMaxOfUseage", new(0, 180, 1), 0, TabGroup.CrewmateRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.DovesOfNeace]) + .SetValueFormat(OptionFormat.Times); + DovesOfNeaceAbilityUseGainWithEachTaskCompleted = FloatOptionItem.Create(7712, "AbilityUseGainWithEachTaskCompleted", new(0f, 5f, 0.1f), 0.2f, TabGroup.CrewmateRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.DovesOfNeace]) + .SetValueFormat(OptionFormat.Times); + DovesOfNeaceAbilityChargesWhenFinishedTasks = FloatOptionItem.Create(7713, "AbilityChargesWhenFinishedTasks", new(0f, 5f, 0.1f), 0.2f, TabGroup.CrewmateRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.DovesOfNeace]) + .SetValueFormat(OptionFormat.Times); + } + public override void Add(byte playerId) { On = true; - playerId.SetAbilityUseLimit(Options.DovesOfNeaceMaxOfUseage.GetInt()); + playerId.SetAbilityUseLimit(DovesOfNeaceMaxOfUseage.GetInt()); } public override void Init() @@ -24,14 +42,14 @@ namespace TOHE.Roles.Crewmate public override void ApplyGameOptions(IGameOptions opt, byte playerId) { - if (Options.UsePets.GetBool()) return; - AURoleOptions.EngineerCooldown = Options.DovesOfNeaceCooldown.GetFloat(); + if (UsePets.GetBool()) return; + AURoleOptions.EngineerCooldown = DovesOfNeaceCooldown.GetFloat(); AURoleOptions.EngineerInVentMaxTime = 1f; } public override void SetButtonTexts(HudManager hud, byte id) { - if (Options.UsePets.GetBool()) + if (UsePets.GetBool()) hud.PetButton.buttonLabelText.text = Translator.GetString("DovesOfNeaceVentButtonText"); else hud.AbilityButton.buttonLabelText.text = Translator.GetString("DovesOfNeaceVentButtonText"); diff --git a/Roles/Crewmate/Drainer.cs b/Roles/Crewmate/Drainer.cs index a98a7a950..476cd425e 100644 --- a/Roles/Crewmate/Drainer.cs +++ b/Roles/Crewmate/Drainer.cs @@ -1,7 +1,7 @@ -using AmongUs.GameOptions; -using HarmonyLib; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; +using AmongUs.GameOptions; +using HarmonyLib; using static TOHE.Options; namespace TOHE.Roles.Crewmate diff --git a/Roles/Crewmate/Druid.cs b/Roles/Crewmate/Druid.cs index 1d7c79283..2b62e654e 100644 --- a/Roles/Crewmate/Druid.cs +++ b/Roles/Crewmate/Druid.cs @@ -1,8 +1,8 @@ -using AmongUs.GameOptions; -using Hazel; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using System.Text; +using AmongUs.GameOptions; +using Hazel; using TOHE.Modules; using UnityEngine; using static TOHE.Options; diff --git a/Roles/Crewmate/Escort.cs b/Roles/Crewmate/Escort.cs index eeba511df..34edd6f67 100644 --- a/Roles/Crewmate/Escort.cs +++ b/Roles/Crewmate/Escort.cs @@ -1,5 +1,5 @@ -using AmongUs.GameOptions; -using System.Collections.Generic; +using System.Collections.Generic; +using AmongUs.GameOptions; using TOHE.Roles.Neutral; using static TOHE.Translator; diff --git a/Roles/Crewmate/Farseer.cs b/Roles/Crewmate/Farseer.cs index b3b617f0d..690471c16 100644 --- a/Roles/Crewmate/Farseer.cs +++ b/Roles/Crewmate/Farseer.cs @@ -1,6 +1,6 @@ -using AmongUs.GameOptions; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; +using AmongUs.GameOptions; using TOHE.Modules; using TOHE.Roles.Impostor; using TOHE.Roles.Neutral; @@ -76,6 +76,11 @@ namespace TOHE.Roles.Crewmate public override void SetKillCooldown(byte id) => Main.AllPlayerKillCooldown[id] = FarseerCooldown.GetFloat(); + public override bool CanUseKillButton(PlayerControl pc) + { + return pc.IsAlive(); + } + public override bool OnCheckMurder(PlayerControl killer, PlayerControl target) { killer.SetKillCooldown(FarseerRevealTime.GetFloat()); diff --git a/Roles/Crewmate/Gaulois.cs b/Roles/Crewmate/Gaulois.cs index ee937a54d..b1264dd3e 100644 --- a/Roles/Crewmate/Gaulois.cs +++ b/Roles/Crewmate/Gaulois.cs @@ -1,5 +1,5 @@ -using AmongUs.GameOptions; -using System.Collections.Generic; +using System.Collections.Generic; +using AmongUs.GameOptions; using static TOHE.Options; namespace TOHE.Roles.Crewmate @@ -10,7 +10,7 @@ namespace TOHE.Roles.Crewmate private static List playerIdList = []; private static OptionItem CD; - private static OptionItem AdditionalSpeed; + public static OptionItem AdditionalSpeed; private static OptionItem UseLimitOpt; public static OptionItem UsePet; @@ -68,6 +68,8 @@ namespace TOHE.Roles.Crewmate killer.RpcRemoveAbilityUse(); killer.SetKillCooldown(); + target.MarkDirtySettings(); + return false; } } diff --git a/Roles/Crewmate/Grenadier.cs b/Roles/Crewmate/Grenadier.cs index 5561ce989..902c2e016 100644 --- a/Roles/Crewmate/Grenadier.cs +++ b/Roles/Crewmate/Grenadier.cs @@ -1,9 +1,10 @@ -using AmongUs.GameOptions; -using HarmonyLib; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using System.Text; +using AmongUs.GameOptions; +using HarmonyLib; using TOHE.Modules; +using static TOHE.Options; namespace TOHE.Roles.Crewmate { @@ -15,10 +16,35 @@ namespace TOHE.Roles.Crewmate public static bool On; public override bool IsEnable => On; + public static void SetupCustomOption() + { + SetupRoleOptions(6800, TabGroup.CrewmateRoles, CustomRoles.Grenadier); + GrenadierSkillCooldown = FloatOptionItem.Create(6810, "GrenadierSkillCooldown", new(0f, 180f, 1f), 25f, TabGroup.CrewmateRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Grenadier]) + .SetValueFormat(OptionFormat.Seconds); + GrenadierSkillDuration = FloatOptionItem.Create(6811, "GrenadierSkillDuration", new(0f, 180f, 1f), 10f, TabGroup.CrewmateRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Grenadier]) + .SetValueFormat(OptionFormat.Seconds); + GrenadierCauseVision = FloatOptionItem.Create(6812, "GrenadierCauseVision", new(0f, 5f, 0.05f), 0.3f, TabGroup.CrewmateRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Grenadier]) + .SetValueFormat(OptionFormat.Multiplier); + GrenadierCanAffectNeutral = BooleanOptionItem.Create(6813, "GrenadierCanAffectNeutral", false, TabGroup.CrewmateRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Grenadier]); + GrenadierSkillMaxOfUseage = IntegerOptionItem.Create(6814, "GrenadierSkillMaxOfUseage", new(0, 180, 1), 2, TabGroup.CrewmateRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Grenadier]) + .SetValueFormat(OptionFormat.Times); + GrenadierAbilityUseGainWithEachTaskCompleted = FloatOptionItem.Create(6815, "AbilityUseGainWithEachTaskCompleted", new(0f, 5f, 0.1f), 0.5f, TabGroup.CrewmateRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Grenadier]) + .SetValueFormat(OptionFormat.Times); + GrenadierAbilityChargesWhenFinishedTasks = FloatOptionItem.Create(6816, "AbilityChargesWhenFinishedTasks", new(0f, 5f, 0.1f), 0.2f, TabGroup.CrewmateRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Grenadier]) + .SetValueFormat(OptionFormat.Times); + } + public override void Add(byte playerId) { On = true; - playerId.SetAbilityUseLimit(Options.GrenadierSkillMaxOfUseage.GetInt()); + playerId.SetAbilityUseLimit(GrenadierSkillMaxOfUseage.GetInt()); } public override void Init() @@ -28,8 +54,8 @@ namespace TOHE.Roles.Crewmate public override void ApplyGameOptions(IGameOptions opt, byte playerId) { - if (Options.UsePets.GetBool()) return; - AURoleOptions.EngineerCooldown = Options.GrenadierSkillCooldown.GetFloat(); + if (UsePets.GetBool()) return; + AURoleOptions.EngineerCooldown = GrenadierSkillCooldown.GetFloat(); AURoleOptions.EngineerInVentMaxTime = 1; } @@ -45,7 +71,7 @@ namespace TOHE.Roles.Crewmate public override void SetButtonTexts(HudManager hud, byte id) { - if (Options.UsePets.GetBool()) + if (UsePets.GetBool()) hud.PetButton.buttonLabelText.text = Translator.GetString("GrenadierVentButtonText"); else hud.AbilityButton.buttonLabelText.text = Translator.GetString("GrenadierVentButtonText"); @@ -68,7 +94,7 @@ namespace TOHE.Roles.Crewmate var playerId = player.PlayerId; var now = Utils.TimeStamp; - if (GrenadierBlinding.TryGetValue(playerId, out var gtime) && gtime + Options.GrenadierSkillDuration.GetInt() < now) + if (GrenadierBlinding.TryGetValue(playerId, out var gtime) && gtime + GrenadierSkillDuration.GetInt() < now) { GrenadierBlinding.Remove(playerId); player.RpcResetAbilityCooldown(); @@ -76,7 +102,7 @@ namespace TOHE.Roles.Crewmate Utils.MarkEveryoneDirtySettingsV3(); } - if (MadGrenadierBlinding.TryGetValue(playerId, out var mgtime) && mgtime + Options.GrenadierSkillDuration.GetInt() < now) + if (MadGrenadierBlinding.TryGetValue(playerId, out var mgtime) && mgtime + GrenadierSkillDuration.GetInt() < now) { MadGrenadierBlinding.Remove(playerId); player.RpcResetAbilityCooldown(); @@ -100,11 +126,11 @@ namespace TOHE.Roles.Crewmate { GrenadierBlinding.Remove(pc.PlayerId); GrenadierBlinding.Add(pc.PlayerId, Utils.TimeStamp); - Main.AllPlayerControls.Where(x => x.IsModClient()).Where(x => x.GetCustomRole().IsImpostor() || (x.GetCustomRole().IsNeutral() && Options.GrenadierCanAffectNeutral.GetBool())).Do(x => x.RPCPlayCustomSound("FlashBang")); + Main.AllPlayerControls.Where(x => x.IsModClient()).Where(x => x.GetCustomRole().IsImpostor() || (x.GetCustomRole().IsNeutral() && GrenadierCanAffectNeutral.GetBool())).Do(x => x.RPCPlayCustomSound("FlashBang")); } pc.RPCPlayCustomSound("FlashBang"); - pc.Notify(Translator.GetString("GrenadierSkillInUse"), Options.GrenadierSkillDuration.GetFloat()); + pc.Notify(Translator.GetString("GrenadierSkillInUse"), GrenadierSkillDuration.GetFloat()); pc.RpcRemoveAbilityUse(); Utils.MarkEveryoneDirtySettingsV3(); } diff --git a/Roles/Crewmate/Jailer.cs b/Roles/Crewmate/Jailer.cs index f85e8dcaf..91f0bfe15 100644 --- a/Roles/Crewmate/Jailer.cs +++ b/Roles/Crewmate/Jailer.cs @@ -1,6 +1,6 @@ +using System.Collections.Generic; using AmongUs.GameOptions; using Hazel; -using System.Collections.Generic; using TOHE.Modules; using static TOHE.Options; using static TOHE.Translator; diff --git a/Roles/Crewmate/Judge.cs b/Roles/Crewmate/Judge.cs index 86b4be15e..aa4e41cb6 100644 --- a/Roles/Crewmate/Judge.cs +++ b/Roles/Crewmate/Judge.cs @@ -1,9 +1,9 @@ -using HarmonyLib; -using Hazel; -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; +using HarmonyLib; +using Hazel; using TOHE.Modules; using UnityEngine; using static TOHE.Translator; diff --git a/Roles/Crewmate/Lighter.cs b/Roles/Crewmate/Lighter.cs index ad046a7f2..4025b6e66 100644 --- a/Roles/Crewmate/Lighter.cs +++ b/Roles/Crewmate/Lighter.cs @@ -1,5 +1,6 @@ -using AmongUs.GameOptions; -using System.Text; +using System.Text; +using AmongUs.GameOptions; +using static TOHE.Options; namespace TOHE.Roles.Crewmate { @@ -11,10 +12,36 @@ namespace TOHE.Roles.Crewmate public static bool On; public override bool IsEnable => On; + public static void SetupCustomOption() + { + SetupSingleRoleOptions(6850, TabGroup.CrewmateRoles, CustomRoles.Lighter, 1); + LighterSkillCooldown = FloatOptionItem.Create(6852, "LighterSkillCooldown", new(0f, 180f, 1f), 25f, TabGroup.CrewmateRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Lighter]) + .SetValueFormat(OptionFormat.Seconds); + LighterSkillDuration = FloatOptionItem.Create(6853, "LighterSkillDuration", new(0f, 180f, 1f), 10f, TabGroup.CrewmateRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Lighter]) + .SetValueFormat(OptionFormat.Seconds); + LighterVisionNormal = FloatOptionItem.Create(6854, "LighterVisionNormal", new(0f, 5f, 0.05f), 0.9f, TabGroup.CrewmateRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Lighter]) + .SetValueFormat(OptionFormat.Multiplier); + LighterVisionOnLightsOut = FloatOptionItem.Create(6855, "LighterVisionOnLightsOut", new(0f, 5f, 0.05f), 0.35f, TabGroup.CrewmateRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Lighter]) + .SetValueFormat(OptionFormat.Multiplier); + LighterSkillMaxOfUseage = IntegerOptionItem.Create(6856, "AbilityUseLimit", new(0, 180, 1), 2, TabGroup.CrewmateRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Lighter]) + .SetValueFormat(OptionFormat.Times); + LighterAbilityUseGainWithEachTaskCompleted = FloatOptionItem.Create(6857, "AbilityUseGainWithEachTaskCompleted", new(0f, 5f, 0.1f), 1.5f, TabGroup.CrewmateRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Lighter]) + .SetValueFormat(OptionFormat.Times); + LighterAbilityChargesWhenFinishedTasks = FloatOptionItem.Create(6858, "AbilityChargesWhenFinishedTasks", new(0f, 5f, 0.1f), 0.2f, TabGroup.CrewmateRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Lighter]) + .SetValueFormat(OptionFormat.Times); + } + public override void Add(byte playerId) { On = true; - playerId.SetAbilityUseLimit(Options.LighterSkillMaxOfUseage.GetInt()); + playerId.SetAbilityUseLimit(LighterSkillMaxOfUseage.GetInt()); IsAbilityActive = false; ActivateTimeStamp = 0; } @@ -28,17 +55,17 @@ namespace TOHE.Roles.Crewmate public override void ApplyGameOptions(IGameOptions opt, byte playerId) { - if (!Options.UsePets.GetBool()) + if (!UsePets.GetBool()) { AURoleOptions.EngineerInVentMaxTime = 1; - AURoleOptions.EngineerCooldown = Options.LighterSkillCooldown.GetFloat(); + AURoleOptions.EngineerCooldown = LighterSkillCooldown.GetFloat(); } if (IsAbilityActive) { opt.SetVision(false); - if (Utils.IsActive(SystemTypes.Electrical)) opt.SetFloat(FloatOptionNames.CrewLightMod, Options.LighterVisionOnLightsOut.GetFloat() * 5); - else opt.SetFloat(FloatOptionNames.CrewLightMod, Options.LighterVisionNormal.GetFloat()); + if (Utils.IsActive(SystemTypes.Electrical)) opt.SetFloat(FloatOptionNames.CrewLightMod, LighterVisionOnLightsOut.GetFloat() * 5); + else opt.SetFloat(FloatOptionNames.CrewLightMod, LighterVisionNormal.GetFloat()); } } @@ -54,7 +81,7 @@ namespace TOHE.Roles.Crewmate public override void SetButtonTexts(HudManager hud, byte id) { - if (Options.UsePets.GetBool()) + if (UsePets.GetBool()) hud.PetButton.buttonLabelText.text = Translator.GetString("LighterVentButtonText"); else hud.AbilityButton.buttonLabelText.text = Translator.GetString("LighterVentButtonText"); @@ -78,7 +105,7 @@ namespace TOHE.Roles.Crewmate IsAbilityActive = true; ActivateTimeStamp = Utils.TimeStamp; - pc.Notify(Translator.GetString("LighterSkillInUse"), Options.LighterSkillDuration.GetFloat()); + pc.Notify(Translator.GetString("LighterSkillInUse"), LighterSkillDuration.GetFloat()); pc.RpcRemoveAbilityUse(); pc.MarkDirtySettings(); } @@ -99,7 +126,7 @@ namespace TOHE.Roles.Crewmate { if (!GameStates.IsInTask) return; - if (IsAbilityActive && ActivateTimeStamp + Options.LighterSkillDuration.GetInt() < Utils.TimeStamp) + if (IsAbilityActive && ActivateTimeStamp + LighterSkillDuration.GetInt() < Utils.TimeStamp) { IsAbilityActive = false; player.RpcResetAbilityCooldown(); diff --git a/Roles/Crewmate/Medic.cs b/Roles/Crewmate/Medic.cs index a92567af3..53e3271e5 100644 --- a/Roles/Crewmate/Medic.cs +++ b/Roles/Crewmate/Medic.cs @@ -1,8 +1,8 @@ -using AmongUs.GameOptions; +using System.Collections.Generic; +using System.Linq; +using AmongUs.GameOptions; using HarmonyLib; using Hazel; -using System.Collections.Generic; -using System.Linq; using TOHE.Modules; namespace TOHE.Roles.Crewmate; @@ -101,7 +101,6 @@ public class Medic : RoleBase writer.Write(x); AmongUsClient.Instance.FinishRpcImmediately(writer); } - public static void ReceiveRPCForProtectList(MessageReader reader) { int count = reader.ReadInt32(); @@ -184,7 +183,6 @@ public class Medic : RoleBase return true; } - public static void OnCheckMark() { if (!ShieldDeactivatesWhenMedicDies.GetBool()) return; @@ -201,7 +199,6 @@ public class Medic : RoleBase } } } - public static void IsDead(PlayerControl target) { if (!target.Is(CustomRoles.Medic)) return; @@ -213,7 +210,6 @@ public class Medic : RoleBase { Utils.NotifyRoles(SpecifySeer: Utils.GetPlayerById(pc), SpecifyTarget: target); } - Utils.NotifyRoles(SpecifySeer: target); ProtectList.Clear(); diff --git a/Roles/Crewmate/Mole.cs b/Roles/Crewmate/Mole.cs index 9138ad607..da416efc2 100644 --- a/Roles/Crewmate/Mole.cs +++ b/Roles/Crewmate/Mole.cs @@ -1,4 +1,5 @@ using AmongUs.GameOptions; +using UnityEngine; using static TOHE.Options; namespace TOHE.Roles.Crewmate @@ -32,4 +33,4 @@ namespace TOHE.Roles.Crewmate _ = new LateTask(() => { pc.TPtoRndVent(); }, 0.5f, "Mole TP"); } } -} \ No newline at end of file +} diff --git a/Roles/Crewmate/Monarch.cs b/Roles/Crewmate/Monarch.cs index fd6b16455..61eae9a7f 100644 --- a/Roles/Crewmate/Monarch.cs +++ b/Roles/Crewmate/Monarch.cs @@ -1,5 +1,5 @@ -using AmongUs.GameOptions; -using System.Collections.Generic; +using System.Collections.Generic; +using AmongUs.GameOptions; using static TOHE.Options; using static TOHE.Translator; diff --git a/Roles/Crewmate/Mortician.cs b/Roles/Crewmate/Mortician.cs index db185e805..ba051efc7 100644 --- a/Roles/Crewmate/Mortician.cs +++ b/Roles/Crewmate/Mortician.cs @@ -1,5 +1,5 @@ -using Hazel; -using System.Collections.Generic; +using System.Collections.Generic; +using Hazel; using TOHE.Modules; using UnityEngine; using static TOHE.Options; diff --git a/Roles/Crewmate/NiceGuesser.cs b/Roles/Crewmate/NiceGuesser.cs deleted file mode 100644 index 3ce9bdb00..000000000 --- a/Roles/Crewmate/NiceGuesser.cs +++ /dev/null @@ -1,23 +0,0 @@ -using UnityEngine; -using static TOHE.Options; - -namespace TOHE.Roles.Crewmate -{ - internal static class NiceGuesser - { - public static void SetupCustomOption() - { - SetupRoleOptions(8600, TabGroup.CrewmateRoles, CustomRoles.NiceGuesser); - GGCanGuessTime = IntegerOptionItem.Create(8610, "GuesserCanGuessTimes", new(0, 15, 1), 15, TabGroup.CrewmateRoles, false) - .SetParent(CustomRoleSpawnChances[CustomRoles.NiceGuesser]) - .SetValueFormat(OptionFormat.Times); - GGCanGuessCrew = BooleanOptionItem.Create(8611, "GGCanGuessCrew", true, TabGroup.CrewmateRoles, false) - .SetParent(CustomRoleSpawnChances[CustomRoles.NiceGuesser]); - GGCanGuessAdt = BooleanOptionItem.Create(8612, "GGCanGuessAdt", false, TabGroup.CrewmateRoles, false) - .SetParent(CustomRoleSpawnChances[CustomRoles.NiceGuesser]); - GGTryHideMsg = BooleanOptionItem.Create(8613, "GuesserTryHideMsg", true, TabGroup.CrewmateRoles, false) - .SetParent(CustomRoleSpawnChances[CustomRoles.NiceGuesser]) - .SetColor(Color.green); - } - } -} diff --git a/Roles/Crewmate/NiceHacker.cs b/Roles/Crewmate/NiceHacker.cs index c18f008d3..17761cd20 100644 --- a/Roles/Crewmate/NiceHacker.cs +++ b/Roles/Crewmate/NiceHacker.cs @@ -1,8 +1,8 @@ -using AmongUs.GameOptions; -using Hazel; -using System; +using System; using System.Collections.Generic; using System.Text; +using AmongUs.GameOptions; +using Hazel; using TOHE.Modules; using UnityEngine; diff --git a/Roles/Crewmate/NiceSwapper.cs b/Roles/Crewmate/NiceSwapper.cs index ad603a67c..12ecc3f33 100644 --- a/Roles/Crewmate/NiceSwapper.cs +++ b/Roles/Crewmate/NiceSwapper.cs @@ -1,8 +1,8 @@ -using HarmonyLib; -using Hazel; -using System; +using System; using System.Linq; using System.Text.RegularExpressions; +using HarmonyLib; +using Hazel; using TOHE.Modules; using UnityEngine; using static TOHE.Translator; diff --git a/Roles/Crewmate/ParityCop.cs b/Roles/Crewmate/ParityCop.cs index c2d69da80..ec8f69d19 100644 --- a/Roles/Crewmate/ParityCop.cs +++ b/Roles/Crewmate/ParityCop.cs @@ -1,7 +1,7 @@ -using HarmonyLib; using System; using System.Collections.Generic; using System.Linq; +using HarmonyLib; using TOHE.Modules; using UnityEngine; using static TOHE.Options; diff --git a/Roles/Crewmate/Perceiver.cs b/Roles/Crewmate/Perceiver.cs index e5906cf9a..37d8ab573 100644 --- a/Roles/Crewmate/Perceiver.cs +++ b/Roles/Crewmate/Perceiver.cs @@ -1,5 +1,5 @@ -using AmongUs.GameOptions; -using System.Linq; +using System.Linq; +using AmongUs.GameOptions; using UnityEngine; namespace TOHE.Roles.Crewmate diff --git a/Roles/Crewmate/Psychic.cs b/Roles/Crewmate/Psychic.cs index 81ab4336b..19999defd 100644 --- a/Roles/Crewmate/Psychic.cs +++ b/Roles/Crewmate/Psychic.cs @@ -1,9 +1,9 @@ -using AmongUs.GameOptions; -using HarmonyLib; -using Hazel; using System; using System.Collections.Generic; using System.Linq; +using AmongUs.GameOptions; +using HarmonyLib; +using Hazel; using TOHE.Modules; using static TOHE.Options; diff --git a/Roles/Crewmate/Rabbit.cs b/Roles/Crewmate/Rabbit.cs index 8f5b87e07..196a07b9d 100644 --- a/Roles/Crewmate/Rabbit.cs +++ b/Roles/Crewmate/Rabbit.cs @@ -1,6 +1,6 @@ -using Hazel; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; +using Hazel; using TOHE.Modules; namespace TOHE.Roles.Crewmate @@ -19,9 +19,10 @@ namespace TOHE.Roles.Crewmate if (!Player.IsAlive() || (MyTaskState.CompletedTasksCount < TaskTrigger && !MyTaskState.IsTaskFinished)) return; var Impostors = Main.AllAlivePlayerControls.Where(pc => pc.Is(CustomRoleTypes.Impostor)).ToArray(); + if (Impostors.Length == 0) return; var target = Impostors[IRandom.Instance.Next(Impostors.Length)]; - TargetArrow.Add(Player.PlayerId, target.PlayerId, update: false); + LocateArrow.Add(Player.PlayerId, target.Pos()); Arrow = (true, target.PlayerId); SendRPC(); Utils.NotifyRoles(SpecifySeer: Player, SpecifyTarget: Player); @@ -29,7 +30,7 @@ namespace TOHE.Roles.Crewmate _ = new LateTask(() => { - TargetArrow.Remove(Player.PlayerId, target.PlayerId); + LocateArrow.Remove(Player.PlayerId, target.Pos()); Arrow = (false, byte.MaxValue); SendRPC(); Utils.NotifyRoles(SpecifySeer: Player, SpecifyTarget: Player); @@ -53,7 +54,7 @@ namespace TOHE.Roles.Crewmate public string Suffix => !GameStates.IsInTask || !Arrow.HasArrow ? string.Empty - : Utils.ColorString(Utils.GetRoleColor(CustomRoles.Rabbit), TargetArrow.GetArrows(Player, Arrow.Target)); + : Utils.ColorString(Utils.GetRoleColor(CustomRoles.Rabbit), LocateArrow.GetArrows(Player)); } private static int Id => 643330; diff --git a/Roles/Crewmate/Randomizer.cs b/Roles/Crewmate/Randomizer.cs index e5350e314..03229772a 100644 --- a/Roles/Crewmate/Randomizer.cs +++ b/Roles/Crewmate/Randomizer.cs @@ -1,7 +1,7 @@ -using HarmonyLib; -using System; +using System; using System.Collections.Generic; using System.Linq; +using HarmonyLib; using TOHE.Modules; using TOHE.Roles.Impostor; using TOHE.Roles.Neutral; diff --git a/Roles/Crewmate/Ricochet.cs b/Roles/Crewmate/Ricochet.cs index c6cdbe9cf..e799cfdeb 100644 --- a/Roles/Crewmate/Ricochet.cs +++ b/Roles/Crewmate/Ricochet.cs @@ -1,5 +1,5 @@ -using Hazel; using System.Collections.Generic; +using Hazel; using TOHE.Modules; namespace TOHE.Roles.Crewmate @@ -58,7 +58,6 @@ namespace TOHE.Roles.Crewmate writer.Write(targetId); AmongUsClient.Instance.FinishRpcImmediately(writer); } - public static void ReceiveRPCSyncTarget(MessageReader reader) { byte id = reader.ReadByte(); @@ -80,7 +79,6 @@ namespace TOHE.Roles.Crewmate return true; } - public static bool OnVote(PlayerControl pc, PlayerControl target) { if (target == null || pc == null || pc.PlayerId == target.PlayerId || Main.PlayerStates[pc.PlayerId].Role is not Ricochet rc || Main.DontCancelVoteList.Contains(pc.PlayerId)) return false; @@ -93,7 +91,6 @@ namespace TOHE.Roles.Crewmate Main.DontCancelVoteList.Add(pc.PlayerId); return true; } - return false; } diff --git a/Roles/Crewmate/SabotageMaster.cs b/Roles/Crewmate/SabotageMaster.cs index 76fbb04f9..fc36c5c85 100644 --- a/Roles/Crewmate/SabotageMaster.cs +++ b/Roles/Crewmate/SabotageMaster.cs @@ -1,6 +1,6 @@ +using System.Collections.Generic; using AmongUs.GameOptions; using Hazel; -using System.Collections.Generic; using TOHE.Modules; namespace TOHE.Roles.Crewmate; diff --git a/Roles/Crewmate/SecurityGuard.cs b/Roles/Crewmate/SecurityGuard.cs index 8dbaad597..3b7f27c02 100644 --- a/Roles/Crewmate/SecurityGuard.cs +++ b/Roles/Crewmate/SecurityGuard.cs @@ -1,5 +1,6 @@ -using AmongUs.GameOptions; -using System.Text; +using System.Text; +using AmongUs.GameOptions; +using static TOHE.Options; namespace TOHE.Roles.Crewmate { @@ -8,10 +9,30 @@ namespace TOHE.Roles.Crewmate public static bool On; public override bool IsEnable => On; + public static void SetupCustomOption() + { + SetupRoleOptions(6860, TabGroup.CrewmateRoles, CustomRoles.SecurityGuard); + SecurityGuardSkillCooldown = FloatOptionItem.Create(6862, "SecurityGuardSkillCooldown", new(0f, 180f, 1f), 15f, TabGroup.CrewmateRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.SecurityGuard]) + .SetValueFormat(OptionFormat.Seconds); + SecurityGuardSkillDuration = FloatOptionItem.Create(6863, "SecurityGuardSkillDuration", new(0f, 180f, 1f), 10f, TabGroup.CrewmateRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.SecurityGuard]) + .SetValueFormat(OptionFormat.Seconds); + SecurityGuardSkillMaxOfUseage = IntegerOptionItem.Create(6866, "AbilityUseLimit", new(0, 180, 1), 1, TabGroup.CrewmateRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.SecurityGuard]) + .SetValueFormat(OptionFormat.Times); + SecurityGuardAbilityUseGainWithEachTaskCompleted = FloatOptionItem.Create(6867, "AbilityUseGainWithEachTaskCompleted", new(0f, 5f, 0.1f), 0.4f, TabGroup.CrewmateRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.SecurityGuard]) + .SetValueFormat(OptionFormat.Times); + SecurityGuardAbilityChargesWhenFinishedTasks = FloatOptionItem.Create(6868, "AbilityChargesWhenFinishedTasks", new(0f, 5f, 0.1f), 0.2f, TabGroup.CrewmateRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.SecurityGuard]) + .SetValueFormat(OptionFormat.Times); + } + public override void Add(byte playerId) { On = true; - playerId.SetAbilityUseLimit(Options.SecurityGuardSkillMaxOfUseage.GetInt()); + playerId.SetAbilityUseLimit(SecurityGuardSkillMaxOfUseage.GetInt()); } public override void Init() @@ -21,9 +42,9 @@ namespace TOHE.Roles.Crewmate public override void ApplyGameOptions(IGameOptions opt, byte playerId) { - if (Options.UsePets.GetBool()) return; + if (UsePets.GetBool()) return; AURoleOptions.EngineerInVentMaxTime = 1; - AURoleOptions.EngineerCooldown = Options.SecurityGuardSkillCooldown.GetFloat(); + AURoleOptions.EngineerCooldown = SecurityGuardSkillCooldown.GetFloat(); } public override string GetProgressText(byte playerId, bool comms) @@ -38,7 +59,7 @@ namespace TOHE.Roles.Crewmate public override void SetButtonTexts(HudManager hud, byte id) { - if (Options.UsePets.GetBool()) + if (UsePets.GetBool()) hud.PetButton.buttonLabelText.text = Translator.GetString("SecurityGuardVentButtonText"); else hud.AbilityButton.buttonLabelText.text = Translator.GetString("SecurityGuardVentButtonText"); @@ -56,7 +77,7 @@ namespace TOHE.Roles.Crewmate { Main.BlockSabo.Remove(pc.PlayerId); Main.BlockSabo.Add(pc.PlayerId, Utils.TimeStamp); - pc.Notify(Translator.GetString("SecurityGuardSkillInUse"), Options.SecurityGuardSkillDuration.GetFloat()); + pc.Notify(Translator.GetString("SecurityGuardSkillInUse"), SecurityGuardSkillDuration.GetFloat()); pc.RpcRemoveAbilityUse(); } else @@ -69,7 +90,7 @@ namespace TOHE.Roles.Crewmate public override void OnFixedUpdate(PlayerControl player) { var playerId = player.PlayerId; - if (Main.BlockSabo.TryGetValue(playerId, out var stime) && stime + Options.SecurityGuardSkillDuration.GetInt() < Utils.TimeStamp) + if (Main.BlockSabo.TryGetValue(playerId, out var stime) && stime + SecurityGuardSkillDuration.GetInt() < Utils.TimeStamp) { Main.BlockSabo.Remove(playerId); player.RpcResetAbilityCooldown(); @@ -77,4 +98,4 @@ namespace TOHE.Roles.Crewmate } } } -} \ No newline at end of file +} diff --git a/Roles/Crewmate/Sentinel.cs b/Roles/Crewmate/Sentinel.cs index 90f1e3ed5..1e94618d3 100644 --- a/Roles/Crewmate/Sentinel.cs +++ b/Roles/Crewmate/Sentinel.cs @@ -1,6 +1,6 @@ -using AmongUs.GameOptions; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; +using AmongUs.GameOptions; using UnityEngine; using static TOHE.Options; using static TOHE.Translator; @@ -10,47 +10,13 @@ namespace TOHE.Roles.Crewmate { public class PatrollingState(byte sentinelId, int patrolDuration, float patrolRadius, PlayerControl sentinel = null, bool isPatrolling = false, Vector2? startingPosition = null, long patrolStartTimeStamp = 0) { - public byte SentinelId - { - get => sentinelId; - set => sentinelId = value; - } - - public PlayerControl Sentinel - { - get => sentinel; - set => sentinel = value; - } - - public bool IsPatrolling - { - get => isPatrolling; - set => isPatrolling = value; - } - - public Vector2 StartingPosition - { - get => startingPosition ?? Vector2.zero; - set => startingPosition = value; - } - - public long PatrolStartTimeStamp - { - get => patrolStartTimeStamp; - set => patrolStartTimeStamp = value; - } - - public int PatrolDuration - { - get => patrolDuration; - set => patrolDuration = value; - } - - public float PatrolRadius - { - get => patrolRadius; - set => patrolRadius = value; - } + public byte SentinelId { get => sentinelId; set => sentinelId = value; } + public PlayerControl Sentinel { get => sentinel; set => sentinel = value; } + public bool IsPatrolling { get => isPatrolling; set => isPatrolling = value; } + public Vector2 StartingPosition { get => startingPosition ?? Vector2.zero; set => startingPosition = value; } + public long PatrolStartTimeStamp { get => patrolStartTimeStamp; set => patrolStartTimeStamp = value; } + public int PatrolDuration { get => patrolDuration; set => patrolDuration = value; } + public float PatrolRadius { get => patrolRadius; set => patrolRadius = value; } public PlayerControl[] NearbyKillers => GetPlayersInRadius(PatrolRadius, StartingPosition).Where(x => !x.Is(Team.Crewmate) && SentinelId != x.PlayerId).ToArray(); private readonly List LastNearbyKillers = []; @@ -100,7 +66,6 @@ namespace TOHE.Roles.Crewmate pc.Notify(GetString("KillerEscapedFromSentinel")); LastNearbyKillers.Remove(pc.PlayerId); } - if (nowInRange) { pc.Notify(string.Format(GetString("KillerNotifyPatrol"), PatrolDuration - (TimeStamp - PatrolStartTimeStamp))); @@ -116,7 +81,6 @@ namespace TOHE.Roles.Crewmate { pc.Suicide(realKiller: Sentinel); } - Sentinel.MarkDirtySettings(); } } @@ -177,7 +141,6 @@ namespace TOHE.Roles.Crewmate return false; } } - return true; } @@ -220,4 +183,4 @@ namespace TOHE.Roles.Crewmate }, 0.1f); } } -} \ No newline at end of file +} diff --git a/Roles/Crewmate/Sheriff.cs b/Roles/Crewmate/Sheriff.cs index 3c80d5e87..808d7f349 100644 --- a/Roles/Crewmate/Sheriff.cs +++ b/Roles/Crewmate/Sheriff.cs @@ -1,7 +1,7 @@ -using AmongUs.GameOptions; using System; using System.Collections.Generic; using System.Linq; +using AmongUs.GameOptions; namespace TOHE.Roles.Crewmate; diff --git a/Roles/Crewmate/Spy.cs b/Roles/Crewmate/Spy.cs index da57e9574..d58a00adb 100644 --- a/Roles/Crewmate/Spy.cs +++ b/Roles/Crewmate/Spy.cs @@ -1,5 +1,5 @@ -using Hazel; using System.Collections.Generic; +using Hazel; using TOHE.Modules; namespace TOHE.Roles.Crewmate @@ -68,10 +68,8 @@ namespace TOHE.Roles.Crewmate writer.Write(changeColor); break; } - AmongUsClient.Instance.FinishRpcImmediately(writer); } - public static void ReceiveRPC(MessageReader reader) { int operate = reader.ReadInt32(); @@ -115,10 +113,7 @@ namespace TOHE.Roles.Crewmate } } - if (change && GameStates.IsInTask) - { - NotifyRoles(SpecifySeer: pc); - } + if (change && GameStates.IsInTask) { NotifyRoles(SpecifySeer: pc); } } } } \ No newline at end of file diff --git a/Roles/Crewmate/SwordsMan.cs b/Roles/Crewmate/SwordsMan.cs index bc78b05d5..a38dd4d0c 100644 --- a/Roles/Crewmate/SwordsMan.cs +++ b/Roles/Crewmate/SwordsMan.cs @@ -1,6 +1,6 @@ -using AmongUs.GameOptions; +using System.Collections.Generic; +using AmongUs.GameOptions; using Hazel; -using System.Collections.Generic; using TOHE.Modules; using UnityEngine; diff --git a/Roles/Crewmate/Tether.cs b/Roles/Crewmate/Tether.cs index 6e1b4980b..f8c9800c0 100644 --- a/Roles/Crewmate/Tether.cs +++ b/Roles/Crewmate/Tether.cs @@ -1,7 +1,7 @@ -using AmongUs.GameOptions; -using Hazel; using System.Collections.Generic; using System.Text; +using AmongUs.GameOptions; +using Hazel; using TOHE.Modules; namespace TOHE.Roles.Crewmate diff --git a/Roles/Crewmate/TimeMaster.cs b/Roles/Crewmate/TimeMaster.cs index 6e0616042..f3b4fca3f 100644 --- a/Roles/Crewmate/TimeMaster.cs +++ b/Roles/Crewmate/TimeMaster.cs @@ -1,5 +1,6 @@ -using AmongUs.GameOptions; -using System.Text; +using System.Text; +using AmongUs.GameOptions; +using static TOHE.Options; namespace TOHE.Roles.Crewmate { @@ -8,11 +9,31 @@ namespace TOHE.Roles.Crewmate public static bool On; public override bool IsEnable => On; + public static void SetupCustomOption() + { + SetupRoleOptions(8950, TabGroup.CrewmateRoles, CustomRoles.TimeMaster); + TimeMasterSkillCooldown = FloatOptionItem.Create(8960, "TimeMasterSkillCooldown", new(0f, 180f, 1f), 20f, TabGroup.CrewmateRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.TimeMaster]) + .SetValueFormat(OptionFormat.Seconds); + TimeMasterSkillDuration = FloatOptionItem.Create(8961, "TimeMasterSkillDuration", new(0f, 180f, 1f), 10f, TabGroup.CrewmateRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.TimeMaster]) + .SetValueFormat(OptionFormat.Seconds); + TimeMasterMaxUses = IntegerOptionItem.Create(8962, "TimeMasterMaxUses", new(0, 180, 1), 1, TabGroup.CrewmateRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.TimeMaster]) + .SetValueFormat(OptionFormat.Times); + TimeMasterAbilityUseGainWithEachTaskCompleted = FloatOptionItem.Create(8963, "AbilityUseGainWithEachTaskCompleted", new(0f, 5f, 0.1f), 0.4f, TabGroup.CrewmateRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.TimeMaster]) + .SetValueFormat(OptionFormat.Times); + TimeMasterAbilityChargesWhenFinishedTasks = FloatOptionItem.Create(8964, "AbilityChargesWhenFinishedTasks", new(0f, 5f, 0.1f), 0.2f, TabGroup.CrewmateRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.TimeMaster]) + .SetValueFormat(OptionFormat.Times); + } + public override void Add(byte playerId) { On = true; Main.TimeMasterNum[playerId] = 0; - playerId.SetAbilityUseLimit(Options.TimeMasterMaxUses.GetInt()); + playerId.SetAbilityUseLimit(TimeMasterMaxUses.GetInt()); } public override void Init() @@ -22,8 +43,8 @@ namespace TOHE.Roles.Crewmate public override void ApplyGameOptions(IGameOptions opt, byte playerId) { - if (Options.UsePets.GetBool()) return; - AURoleOptions.EngineerCooldown = Options.TimeMasterSkillCooldown.GetFloat(); + if (UsePets.GetBool()) return; + AURoleOptions.EngineerCooldown = TimeMasterSkillCooldown.GetFloat(); AURoleOptions.EngineerInVentMaxTime = 1f; } @@ -39,7 +60,7 @@ namespace TOHE.Roles.Crewmate public override void SetButtonTexts(HudManager hud, byte id) { - if (Options.UsePets.GetBool()) + if (UsePets.GetBool()) hud.PetButton.buttonLabelText.text = Translator.GetString("TimeMasterVentButtonText"); else hud.AbilityButton.buttonLabelText.text = Translator.GetString("TimeMasterVentButtonText"); @@ -64,7 +85,7 @@ namespace TOHE.Roles.Crewmate pc.RpcRemoveAbilityUse(); Main.TimeMasterInProtect.Remove(pc.PlayerId); Main.TimeMasterInProtect.Add(pc.PlayerId, Utils.TimeStamp); - pc.Notify(Translator.GetString("TimeMasterOnGuard"), Options.TimeMasterSkillDuration.GetFloat()); + pc.Notify(Translator.GetString("TimeMasterOnGuard"), TimeMasterSkillDuration.GetFloat()); foreach (PlayerControl player in Main.AllPlayerControls) { if (Main.TimeMasterBackTrack.TryGetValue(player.PlayerId, out var position)) @@ -95,7 +116,7 @@ namespace TOHE.Roles.Crewmate public override bool OnCheckMurderAsTarget(PlayerControl killer, PlayerControl target) { - if (killer.PlayerId != target.PlayerId && Main.TimeMasterInProtect.TryGetValue(target.PlayerId, out var ts) && ts + Options.TimeMasterSkillDuration.GetInt() >= Utils.TimeStamp) + if (killer.PlayerId != target.PlayerId && Main.TimeMasterInProtect.TryGetValue(target.PlayerId, out var ts) && ts + TimeMasterSkillDuration.GetInt() >= Utils.TimeStamp) { foreach (var player in Main.AllPlayerControls) { @@ -115,7 +136,7 @@ namespace TOHE.Roles.Crewmate public override void OnFixedUpdate(PlayerControl player) { var playerId = player.PlayerId; - if (Main.TimeMasterInProtect.TryGetValue(playerId, out var ttime) && ttime + Options.TimeMasterSkillDuration.GetInt() < Utils.TimeStamp) + if (Main.TimeMasterInProtect.TryGetValue(playerId, out var ttime) && ttime + TimeMasterSkillDuration.GetInt() < Utils.TimeStamp) { Main.TimeMasterInProtect.Remove(playerId); player.RpcResetAbilityCooldown(); @@ -123,4 +144,4 @@ namespace TOHE.Roles.Crewmate } } } -} \ No newline at end of file +} diff --git a/Roles/Crewmate/Tornado.cs b/Roles/Crewmate/Tornado.cs index a0fa3d282..618842cce 100644 --- a/Roles/Crewmate/Tornado.cs +++ b/Roles/Crewmate/Tornado.cs @@ -1,7 +1,7 @@ -using Hazel; -using System; +using System; using System.Collections.Generic; using System.Linq; +using Hazel; using TOHE.Modules; using UnityEngine; using static TOHE.Options; diff --git a/Roles/Crewmate/Tracefinder.cs b/Roles/Crewmate/Tracefinder.cs index ade5bd67b..9afb29365 100644 --- a/Roles/Crewmate/Tracefinder.cs +++ b/Roles/Crewmate/Tracefinder.cs @@ -1,7 +1,7 @@ -using AmongUs.GameOptions; -using Hazel; using System; using System.Collections.Generic; +using AmongUs.GameOptions; +using Hazel; using TOHE.Modules; using UnityEngine; using static TOHE.Options; @@ -17,6 +17,8 @@ public class Tracefinder : RoleBase private static OptionItem ArrowDelayMin; private static OptionItem ArrowDelayMax; + public static bool On; + public static void SetupCustomOption() { SetupRoleOptions(Id, TabGroup.CrewmateRoles, CustomRoles.Tracefinder); @@ -37,11 +39,13 @@ public class Tracefinder : RoleBase public override void Init() { playerIdList = []; + On = false; } public override void Add(byte playerId) { playerIdList.Add(playerId); + On = true; } public override bool IsEnable => playerIdList.Count > 0; @@ -89,6 +93,8 @@ public class Tracefinder : RoleBase public static void OnPlayerDead(PlayerControl target) { + if (!On || !GameStates.IsInTask || target == null) return; + var pos = target.Pos(); float minDis = float.MaxValue; foreach (PlayerControl pc in Main.AllAlivePlayerControls) @@ -111,7 +117,7 @@ public class Tracefinder : RoleBase { if (GameStates.IsInTask) { - foreach (byte id in playerIdList.ToArray()) + foreach (byte id in playerIdList) { PlayerControl pc = Utils.GetPlayerById(id); if (pc == null || !pc.IsAlive()) diff --git a/Roles/Crewmate/Tracker.cs b/Roles/Crewmate/Tracker.cs index c765b032a..aa3b49f7b 100644 --- a/Roles/Crewmate/Tracker.cs +++ b/Roles/Crewmate/Tracker.cs @@ -1,5 +1,5 @@ -using Hazel; -using System.Collections.Generic; +using System.Collections.Generic; +using Hazel; using TOHE.Modules; using UnityEngine; using static TOHE.Options; diff --git a/Roles/Crewmate/Veteran.cs b/Roles/Crewmate/Veteran.cs index deb976aff..b666e2628 100644 --- a/Roles/Crewmate/Veteran.cs +++ b/Roles/Crewmate/Veteran.cs @@ -1,6 +1,7 @@ -using AmongUs.GameOptions; -using System.Text; +using System.Text; +using AmongUs.GameOptions; using TOHE.Modules; +using static TOHE.Options; namespace TOHE.Roles.Crewmate { @@ -12,7 +13,7 @@ namespace TOHE.Roles.Crewmate public override void Add(byte playerId) { On = true; - playerId.SetAbilityUseLimit(Options.VeteranSkillMaxOfUseage.GetInt()); + playerId.SetAbilityUseLimit(VeteranSkillMaxOfUseage.GetInt()); } public override void Init() @@ -20,10 +21,30 @@ namespace TOHE.Roles.Crewmate On = false; } + public static void SetupCustomOption() + { + SetupRoleOptions(8908, TabGroup.CrewmateRoles, CustomRoles.Veteran); + VeteranSkillCooldown = FloatOptionItem.Create(8910, "VeteranSkillCooldown", new(0f, 180f, 1f), 20f, TabGroup.CrewmateRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Veteran]) + .SetValueFormat(OptionFormat.Seconds); + VeteranSkillDuration = FloatOptionItem.Create(8911, "VeteranSkillDuration", new(0f, 180f, 1f), 10f, TabGroup.CrewmateRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Veteran]) + .SetValueFormat(OptionFormat.Seconds); + VeteranSkillMaxOfUseage = IntegerOptionItem.Create(8912, "VeteranSkillMaxOfUseage", new(0, 180, 1), 1, TabGroup.CrewmateRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Veteran]) + .SetValueFormat(OptionFormat.Times); + VeteranAbilityUseGainWithEachTaskCompleted = FloatOptionItem.Create(8913, "AbilityUseGainWithEachTaskCompleted", new(0f, 5f, 0.1f), 0.3f, TabGroup.CrewmateRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Veteran]) + .SetValueFormat(OptionFormat.Times); + VeteranAbilityChargesWhenFinishedTasks = FloatOptionItem.Create(8914, "AbilityChargesWhenFinishedTasks", new(0f, 5f, 0.1f), 0.2f, TabGroup.CrewmateRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Veteran]) + .SetValueFormat(OptionFormat.Times); + } + public override void ApplyGameOptions(IGameOptions opt, byte playerId) { - if (Options.UsePets.GetBool()) return; - AURoleOptions.EngineerCooldown = Options.VeteranSkillCooldown.GetFloat(); + if (UsePets.GetBool()) return; + AURoleOptions.EngineerCooldown = VeteranSkillCooldown.GetFloat(); AURoleOptions.EngineerInVentMaxTime = 1; } @@ -39,7 +60,7 @@ namespace TOHE.Roles.Crewmate public override void SetButtonTexts(HudManager hud, byte id) { - if (Options.UsePets.GetBool()) + if (UsePets.GetBool()) hud.PetButton.buttonLabelText.text = Translator.GetString("VeteranVentButtonText"); else hud.AbilityButton.buttonLabelText.text = Translator.GetString("VeteranVentButtonText"); @@ -63,7 +84,7 @@ namespace TOHE.Roles.Crewmate Main.VeteranInProtect[pc.PlayerId] = Utils.TimeStamp; pc.RpcRemoveAbilityUse(); pc.RPCPlayCustomSound("Gunload"); - pc.Notify(Translator.GetString("VeteranOnGuard"), Options.VeteranSkillDuration.GetFloat()); + pc.Notify(Translator.GetString("VeteranOnGuard"), VeteranSkillDuration.GetFloat()); pc.MarkDirtySettings(); } else @@ -76,7 +97,7 @@ namespace TOHE.Roles.Crewmate { if (Main.VeteranInProtect.ContainsKey(target.PlayerId) && killer.PlayerId != target.PlayerId - && Main.VeteranInProtect[target.PlayerId] + Options.VeteranSkillDuration.GetInt() >= Utils.TimeStamp) + && Main.VeteranInProtect[target.PlayerId] + VeteranSkillDuration.GetInt() >= Utils.TimeStamp) { if (!killer.Is(CustomRoles.Pestilence)) { @@ -98,7 +119,7 @@ namespace TOHE.Roles.Crewmate public override void OnFixedUpdate(PlayerControl player) { var playerId = player.PlayerId; - if (Main.VeteranInProtect.TryGetValue(playerId, out var vtime) && vtime + Options.VeteranSkillDuration.GetInt() < Utils.TimeStamp) + if (Main.VeteranInProtect.TryGetValue(playerId, out var vtime) && vtime + VeteranSkillDuration.GetInt() < Utils.TimeStamp) { Main.VeteranInProtect.Remove(playerId); player.RpcResetAbilityCooldown(); diff --git a/Roles/Crewmate/Witness.cs b/Roles/Crewmate/Witness.cs index 41c9a3f8a..5eb67f478 100644 --- a/Roles/Crewmate/Witness.cs +++ b/Roles/Crewmate/Witness.cs @@ -1,5 +1,6 @@ -using AmongUs.GameOptions; -using System.Collections.Generic; +using System.Collections.Generic; +using AmongUs.GameOptions; +using static TOHE.Options; namespace TOHE.Roles.Crewmate { @@ -20,9 +21,21 @@ namespace TOHE.Roles.Crewmate On = false; } + public static void SetupCustomOption() + { + SetupSingleRoleOptions(8550, TabGroup.CrewmateRoles, CustomRoles.Witness, 1); + WitnessCD = FloatOptionItem.Create(8552, "AbilityCD", new(0f, 60f, 2.5f), 15f, TabGroup.CrewmateRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Witness]) + .SetValueFormat(OptionFormat.Seconds); + WitnessTime = IntegerOptionItem.Create(8553, "WitnessTime", new(0, 90, 1), 10, TabGroup.CrewmateRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Witness]) + .SetValueFormat(OptionFormat.Seconds); + WitnessUsePet = CreatePetUseSetting(8554, CustomRoles.Witness); + } + public override void SetKillCooldown(byte id) { - Main.AllPlayerKillCooldown[id] = Options.WitnessCD.GetFloat(); + Main.AllPlayerKillCooldown[id] = WitnessCD.GetFloat(); } public override void ApplyGameOptions(IGameOptions opt, byte playerId) diff --git a/Roles/Impostor/AntiAdminer.cs b/Roles/Impostor/AntiAdminer.cs index 7b73442ac..a6e216db8 100644 --- a/Roles/Impostor/AntiAdminer.cs +++ b/Roles/Impostor/AntiAdminer.cs @@ -1,6 +1,6 @@ -using AmongUs.GameOptions; -using System; +using System; using System.Collections.Generic; +using AmongUs.GameOptions; using TOHE.Roles.Crewmate; using TOHE.Roles.Neutral; using UnityEngine; @@ -58,9 +58,7 @@ internal class AntiAdminer : RoleBase { if (!IsEnable) return; - Count--; - if (Count > 0) return; - Count = 5; + Count--; if (Count > 0) return; Count = 5; bool Admin = false, Camera = false, DoorLog = false, Vital = false; foreach (PlayerControl pc in Main.AllAlivePlayerControls) @@ -90,7 +88,6 @@ internal class AntiAdminer : RoleBase Admin |= Vector2.Distance(PlayerPos, DisableDevice.DevicePos["PolusLeftAdmin"]) <= DisableDevice.UsableDistance(); Admin |= Vector2.Distance(PlayerPos, DisableDevice.DevicePos["PolusRightAdmin"]) <= DisableDevice.UsableDistance(); } - if (!Options.DisablePolusCamera.GetBool()) Camera |= Vector2.Distance(PlayerPos, DisableDevice.DevicePos["PolusCamera"]) <= DisableDevice.UsableDistance(); if (!Options.DisablePolusVital.GetBool()) diff --git a/Roles/Impostor/Assassin.cs b/Roles/Impostor/Assassin.cs index d596ebe99..7bd3a988b 100644 --- a/Roles/Impostor/Assassin.cs +++ b/Roles/Impostor/Assassin.cs @@ -1,6 +1,6 @@ -using AmongUs.GameOptions; +using System.Collections.Generic; +using AmongUs.GameOptions; using Hazel; -using System.Collections.Generic; using TOHE.Modules; using TOHE.Roles.Crewmate; using TOHE.Roles.Neutral; @@ -17,9 +17,6 @@ internal class Assassin : RoleBase private static OptionItem MarkCooldownOpt; public static OptionItem AssassinateCooldownOpt; private static OptionItem CanKillAfterAssassinateOpt; - public static OptionItem UndertakerMarkCooldown; - public static OptionItem UndertakerAssassinateCooldown; - public static OptionItem UndertakerCanKillAfterAssassinate; private float MarkCooldown; private float AssassinateCooldown; @@ -31,24 +28,11 @@ internal class Assassin : RoleBase public static void SetupCustomOption() { SetupRoleOptions(Id, TabGroup.ImpostorRoles, CustomRoles.Assassin); - MarkCooldownOpt = FloatOptionItem.Create(Id + 10, "AssassinMarkCooldown", new(0f, 180f, 0.5f), 1f, TabGroup.ImpostorRoles, false) - .SetParent(CustomRoleSpawnChances[CustomRoles.Assassin]) + MarkCooldownOpt = FloatOptionItem.Create(Id + 10, "AssassinMarkCooldown", new(0f, 180f, 0.5f), 1f, TabGroup.ImpostorRoles, false).SetParent(CustomRoleSpawnChances[CustomRoles.Assassin]) .SetValueFormat(OptionFormat.Seconds); - AssassinateCooldownOpt = FloatOptionItem.Create(Id + 11, "AssassinAssassinateCooldown", new(0f, 180f, 0.5f), 18.5f, TabGroup.ImpostorRoles, false) - .SetParent(CustomRoleSpawnChances[CustomRoles.Assassin]) + AssassinateCooldownOpt = FloatOptionItem.Create(Id + 11, "AssassinAssassinateCooldown", new(0f, 180f, 0.5f), 18.5f, TabGroup.ImpostorRoles, false).SetParent(CustomRoleSpawnChances[CustomRoles.Assassin]) .SetValueFormat(OptionFormat.Seconds); - CanKillAfterAssassinateOpt = BooleanOptionItem.Create(Id + 12, "AssassinCanKillAfterAssassinate", true, TabGroup.ImpostorRoles, false) - .SetParent(CustomRoleSpawnChances[CustomRoles.Assassin]); - - SetupRoleOptions(Id + 20, TabGroup.ImpostorRoles, CustomRoles.Undertaker); - UndertakerMarkCooldown = FloatOptionItem.Create(Id + 30, "UndertakerMarkCooldown", new(0f, 180f, 0.5f), 1f, TabGroup.ImpostorRoles, false) - .SetParent(CustomRoleSpawnChances[CustomRoles.Undertaker]) - .SetValueFormat(OptionFormat.Seconds); - UndertakerAssassinateCooldown = FloatOptionItem.Create(Id + 31, "UndertakerAssassinateCooldown", new(0f, 180f, 0.5f), 18.5f, TabGroup.ImpostorRoles, false) - .SetParent(CustomRoleSpawnChances[CustomRoles.Undertaker]) - .SetValueFormat(OptionFormat.Seconds); - UndertakerCanKillAfterAssassinate = BooleanOptionItem.Create(Id + 32, "UndertakerCanKillAfterAssassinate", true, TabGroup.ImpostorRoles, false) - .SetParent(CustomRoleSpawnChances[CustomRoles.Undertaker]); + CanKillAfterAssassinateOpt = BooleanOptionItem.Create(Id + 12, "AssassinCanKillAfterAssassinate", true, TabGroup.ImpostorRoles, false).SetParent(CustomRoleSpawnChances[CustomRoles.Assassin]); } public override void Init() @@ -66,9 +50,9 @@ internal class Assassin : RoleBase if (IsUndertaker) { - MarkCooldown = UndertakerMarkCooldown.GetFloat(); - AssassinateCooldown = UndertakerAssassinateCooldown.GetFloat(); - CanKillAfterAssassinate = UndertakerCanKillAfterAssassinate.GetBool(); + MarkCooldown = Undertaker.MarkCooldown.GetFloat(); + AssassinateCooldown = Undertaker.AssassinateCooldown.GetFloat(); + CanKillAfterAssassinate = Undertaker.CanKillAfterAssassinate.GetBool(); } else { diff --git a/Roles/Impostor/BallLightning.cs b/Roles/Impostor/BallLightning.cs index 0d2d6e029..db073dd09 100644 --- a/Roles/Impostor/BallLightning.cs +++ b/Roles/Impostor/BallLightning.cs @@ -1,5 +1,5 @@ -using Hazel; -using System.Collections.Generic; +using System.Collections.Generic; +using Hazel; using TOHE.Modules; using TOHE.Patches; using TOHE.Roles.Crewmate; diff --git a/Roles/Impostor/Blackmailer.cs b/Roles/Impostor/Blackmailer.cs index b5ec4b84e..d2117b615 100644 --- a/Roles/Impostor/Blackmailer.cs +++ b/Roles/Impostor/Blackmailer.cs @@ -1,5 +1,5 @@ -using AmongUs.GameOptions; -using System.Collections.Generic; +using System.Collections.Generic; +using AmongUs.GameOptions; using static TOHE.Options; namespace TOHE.Roles.Impostor; diff --git a/Roles/Impostor/BountyHunter.cs b/Roles/Impostor/BountyHunter.cs index 243c51b43..23cfd6751 100644 --- a/Roles/Impostor/BountyHunter.cs +++ b/Roles/Impostor/BountyHunter.cs @@ -1,6 +1,6 @@ -using Hazel; using System.Collections.Generic; using System.Linq; +using Hazel; using TOHE.Modules; using UnityEngine; using static TOHE.Translator; diff --git a/Roles/Impostor/Chronomancer.cs b/Roles/Impostor/Chronomancer.cs index 38ee4eb76..b9dbe18e6 100644 --- a/Roles/Impostor/Chronomancer.cs +++ b/Roles/Impostor/Chronomancer.cs @@ -1,5 +1,5 @@ -using Hazel; -using System.Collections.Generic; +using System.Collections.Generic; +using Hazel; using TOHE.Modules; using static TOHE.Options; diff --git a/Roles/Impostor/Councillor.cs b/Roles/Impostor/Councillor.cs index ec744d60d..adbd62dd0 100644 --- a/Roles/Impostor/Councillor.cs +++ b/Roles/Impostor/Councillor.cs @@ -1,9 +1,9 @@ -using HarmonyLib; -using Hazel; -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; +using HarmonyLib; +using Hazel; using TOHE.Modules; using TOHE.Roles.Crewmate; using UnityEngine; diff --git a/Roles/Impostor/Crewpostor.cs b/Roles/Impostor/Crewpostor.cs index d3e7b01b2..5a6cb6ebb 100644 --- a/Roles/Impostor/Crewpostor.cs +++ b/Roles/Impostor/Crewpostor.cs @@ -1,9 +1,10 @@ -using AmongUs.GameOptions; -using Hazel; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; +using AmongUs.GameOptions; +using Hazel; using TOHE.Modules; using UnityEngine; +using static TOHE.Options; namespace TOHE.Roles.Impostor { @@ -14,6 +15,22 @@ namespace TOHE.Roles.Impostor public static bool On; public override bool IsEnable => On; + public static void SetupCustomOption() + { + SetupRoleOptions(4800, TabGroup.ImpostorRoles, CustomRoles.Crewpostor); + CrewpostorCanKillAllies = BooleanOptionItem.Create(4810, "CanKillAllies", true, TabGroup.ImpostorRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Crewpostor]); + CrewpostorKnowsAllies = BooleanOptionItem.Create(4811, "CrewpostorKnowsAllies", true, TabGroup.ImpostorRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Crewpostor]); + AlliesKnowCrewpostor = BooleanOptionItem.Create(4812, "AlliesKnowCrewpostor", true, TabGroup.ImpostorRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Crewpostor]); + CrewpostorLungeKill = BooleanOptionItem.Create(4813, "CrewpostorLungeKill", true, TabGroup.ImpostorRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Crewpostor]); + CrewpostorKillAfterTask = IntegerOptionItem.Create(4814, "CrewpostorKillAfterTask", new(1, 50, 1), 1, TabGroup.ImpostorRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Crewpostor]); + CrewpostorTasks = OverrideTasksData.Create(4815, TabGroup.ImpostorRoles, CustomRoles.Crewpostor); + } + public override void ApplyGameOptions(IGameOptions opt, byte playerId) { AURoleOptions.EngineerCooldown = 0f; @@ -26,14 +43,14 @@ namespace TOHE.Roles.Impostor SendRPC(player.PlayerId, TasksDone[player.PlayerId]); - PlayerControl[] list = Main.AllAlivePlayerControls.Where(x => x.PlayerId != player.PlayerId && (Options.CrewpostorCanKillAllies.GetBool() || !x.GetCustomRole().IsImpostorTeam())).ToArray(); + PlayerControl[] list = Main.AllAlivePlayerControls.Where(x => x.PlayerId != player.PlayerId && (CrewpostorCanKillAllies.GetBool() || !x.GetCustomRole().IsImpostorTeam())).ToArray(); if (list.Length == 0) { Logger.Info("No target to kill", "Crewpostor"); } - else if (TasksDone[player.PlayerId] % Options.CrewpostorKillAfterTask.GetInt() != 0 && TasksDone[player.PlayerId] != 0) + else if (TasksDone[player.PlayerId] % CrewpostorKillAfterTask.GetInt() != 0 && TasksDone[player.PlayerId] != 0) { - Logger.Info($"Crewpostor task done but kill skipped, {TasksDone[player.PlayerId]} tasks completed, but it kills after {Options.CrewpostorKillAfterTask.GetInt()} tasks", "Crewpostor"); + Logger.Info($"Crewpostor task done but kill skipped, {TasksDone[player.PlayerId]} tasks completed, but it kills after {CrewpostorKillAfterTask.GetInt()} tasks", "Crewpostor"); } else { @@ -41,7 +58,7 @@ namespace TOHE.Roles.Impostor var target = list[0]; if (!target.Is(CustomRoles.Pestilence)) { - if (!Options.CrewpostorLungeKill.GetBool()) + if (!CrewpostorLungeKill.GetBool()) { target.SetRealKiller(player); if (player.RpcCheckAndMurder(target, true)) diff --git a/Roles/Impostor/Dazzler.cs b/Roles/Impostor/Dazzler.cs index a99de98e6..1e83ce52d 100644 --- a/Roles/Impostor/Dazzler.cs +++ b/Roles/Impostor/Dazzler.cs @@ -1,5 +1,5 @@ -using AmongUs.GameOptions; using System.Collections.Generic; +using AmongUs.GameOptions; using TOHE.Roles.Neutral; using static TOHE.Options; using static TOHE.Translator; diff --git a/Roles/Impostor/Deathpact.cs b/Roles/Impostor/Deathpact.cs index 406df3168..ad1d6c92e 100644 --- a/Roles/Impostor/Deathpact.cs +++ b/Roles/Impostor/Deathpact.cs @@ -1,6 +1,6 @@ -using AmongUs.GameOptions; using System.Collections.Generic; using System.Linq; +using AmongUs.GameOptions; using TOHE.Roles.Crewmate; using TOHE.Roles.Neutral; using UnityEngine; @@ -251,7 +251,7 @@ namespace TOHE.Roles.Impostor { if (!ActiveDeathpacts.Contains(dp.DeathPactId) || dp.PlayersInDeathpact.All(b => b.PlayerId != player.PlayerId)) continue; - string otherPlayerNames = dp.PlayersInDeathpact.Where(a => a.PlayerId != player.PlayerId).Aggregate(string.Empty, (current, otherPlayerInPact) => current + (otherPlayerInPact.name.ToUpper() + ",")); + string otherPlayerNames = dp.PlayersInDeathpact.Where(a => a.PlayerId != player.PlayerId).Aggregate(string.Empty, (current, otherPlayerInPact) => current + otherPlayerInPact.name.ToUpper() + ","); otherPlayerNames = otherPlayerNames.Remove(otherPlayerNames.Length - 1); int countdown = (int)(dp.DeathpactTime - TimeStamp); diff --git a/Roles/Impostor/Devourer.cs b/Roles/Impostor/Devourer.cs index 8545274b1..0d9d08b4d 100644 --- a/Roles/Impostor/Devourer.cs +++ b/Roles/Impostor/Devourer.cs @@ -1,6 +1,6 @@ -using AmongUs.GameOptions; using System.Collections.Generic; using System.Linq; +using AmongUs.GameOptions; using TOHE.Roles.Neutral; using static TOHE.Options; using static TOHE.Translator; diff --git a/Roles/Impostor/Duellist.cs b/Roles/Impostor/Duellist.cs index 669f5abb2..546ca4b67 100644 --- a/Roles/Impostor/Duellist.cs +++ b/Roles/Impostor/Duellist.cs @@ -1,5 +1,5 @@ -using AmongUs.GameOptions; -using System.Collections.Generic; +using System.Collections.Generic; +using AmongUs.GameOptions; using TOHE.Roles.Crewmate; using TOHE.Roles.Neutral; using static TOHE.Options; diff --git a/Roles/Impostor/EvilDiviner.cs b/Roles/Impostor/EvilDiviner.cs index 94eb0f83f..4f79f3c7e 100644 --- a/Roles/Impostor/EvilDiviner.cs +++ b/Roles/Impostor/EvilDiviner.cs @@ -1,6 +1,6 @@ +using System.Collections.Generic; using AmongUs.GameOptions; using Hazel; -using System.Collections.Generic; using TOHE.Modules; using TOHE.Roles.Neutral; using static TOHE.Options; @@ -119,7 +119,6 @@ namespace TOHE.Roles.Impostor killer.SetKillCooldown(); } } - public static bool IsShowTargetRole(PlayerControl seer, PlayerControl target) { return Main.PlayerStates[seer.PlayerId].Role is EvilDiviner ed && ed.DivinationTarget.Contains(target.PlayerId); diff --git a/Roles/Impostor/EvilGuesser.cs b/Roles/Impostor/EvilGuesser.cs deleted file mode 100644 index 033f1e5c7..000000000 --- a/Roles/Impostor/EvilGuesser.cs +++ /dev/null @@ -1,25 +0,0 @@ -using UnityEngine; -using static TOHE.Options; - -namespace TOHE.Roles.Impostor -{ - internal static class EvilGuesser - { - public static void SetupCustomOption() - { - SetupRoleOptions(1200, TabGroup.ImpostorRoles, CustomRoles.EvilGuesser); - EGCanGuessTime = IntegerOptionItem.Create(1205, "GuesserCanGuessTimes", new(1, 15, 1), 15, TabGroup.ImpostorRoles, false) - .SetParent(CustomRoleSpawnChances[CustomRoles.EvilGuesser]) - .SetValueFormat(OptionFormat.Times); - EGCanGuessImp = BooleanOptionItem.Create(1206, "EGCanGuessImp", true, TabGroup.ImpostorRoles, false) - .SetParent(CustomRoleSpawnChances[CustomRoles.EvilGuesser]); - EGCanGuessAdt = BooleanOptionItem.Create(1207, "EGCanGuessAdt", false, TabGroup.ImpostorRoles, false) - .SetParent(CustomRoleSpawnChances[CustomRoles.EvilGuesser]); - EGCanGuessTaskDoneSnitch = BooleanOptionItem.Create(1208, "EGCanGuessTaskDoneSnitch", true, TabGroup.ImpostorRoles, false) - .SetParent(CustomRoleSpawnChances[CustomRoles.EvilGuesser]); - EGTryHideMsg = BooleanOptionItem.Create(1209, "GuesserTryHideMsg", true, TabGroup.ImpostorRoles, false) - .SetParent(CustomRoleSpawnChances[CustomRoles.EvilGuesser]) - .SetColor(Color.green); - } - } -} diff --git a/Roles/Impostor/EvilTracker.cs b/Roles/Impostor/EvilTracker.cs index cefcb1306..4ea42793a 100644 --- a/Roles/Impostor/EvilTracker.cs +++ b/Roles/Impostor/EvilTracker.cs @@ -1,9 +1,9 @@ -using AmongUs.GameOptions; -using Hazel; -using Il2CppSystem.Text; using System; using System.Collections.Generic; using System.Linq; +using AmongUs.GameOptions; +using Hazel; +using Il2CppSystem.Text; using TOHE.Modules; using UnityEngine; using static TOHE.Options; @@ -68,15 +68,23 @@ public class EvilTracker : RoleBase public override void Add(byte playerId) { + CanSeeKillFlash = OptionCanSeeKillFlash.GetBool(); + CurrentTargetMode = (TargetMode)OptionTargetMode.GetValue(); + RoleTypes = CurrentTargetMode == TargetMode.Never ? RoleTypes.Impostor : RoleTypes.Shapeshifter; + CanSeeLastRoomInMeeting = OptionCanSeeLastRoomInMeeting.GetBool(); + playerIdList.Add(playerId); Target = byte.MaxValue; CanSetTarget = CurrentTargetMode != TargetMode.Never; EvilTrackerId = playerId; - CanSeeKillFlash = OptionCanSeeKillFlash.GetBool(); - CurrentTargetMode = (TargetMode)OptionTargetMode.GetValue(); - RoleTypes = CurrentTargetMode == TargetMode.Never ? RoleTypes.Impostor : RoleTypes.Shapeshifter; - CanSeeLastRoomInMeeting = OptionCanSeeLastRoomInMeeting.GetBool(); + _ = new LateTask(() => + { + foreach (var id in ImpostorsId) + { + TargetArrow.Add(playerId, id); + } + }, 3f, "Add Evil Tracker Arrows"); } public override bool IsEnable => playerIdList.Count > 0; @@ -149,11 +157,6 @@ public class EvilTracker : RoleBase } } - /// - ///引数が両方空:再設定可能に, - ///trackerIdのみ:該当IDのターゲット削除, - ///trackerIdとtargetId両方あり:該当IDのプレイヤーをターゲットに設定 - /// public void SetTarget(byte trackerId = byte.MaxValue, byte targetId = byte.MaxValue) { if (trackerId == byte.MaxValue) CanSetTarget = true; @@ -172,7 +175,6 @@ public class EvilTracker : RoleBase writer.Write(targetId); AmongUsClient.Instance.FinishRpcImmediately(writer); } - public static void ReceiveRPC(MessageReader reader) { byte trackerId = reader.ReadByte(); @@ -210,10 +212,8 @@ public class EvilTracker : RoleBase { sb.Append(Utils.ColorString(Color.white, TargetArrow.GetArrows(target, targetId))); } - return sb.ToString(); } - public static string GetArrowAndLastRoom(PlayerControl seer, PlayerControl target) { string text = Utils.ColorString(Palette.ImpostorRed, TargetArrow.GetArrows(seer, target.PlayerId)); diff --git a/Roles/Impostor/FireWorks.cs b/Roles/Impostor/FireWorks.cs index 7f4f7ce65..07b3213ef 100644 --- a/Roles/Impostor/FireWorks.cs +++ b/Roles/Impostor/FireWorks.cs @@ -1,6 +1,6 @@ -using Hazel; using System; using System.Collections.Generic; +using Hazel; using TOHE.Modules; using TOHE.Roles.Crewmate; using TOHE.Roles.Neutral; diff --git a/Roles/Impostor/Gambler.cs b/Roles/Impostor/Gambler.cs index ab5ebb971..6abafabf8 100644 --- a/Roles/Impostor/Gambler.cs +++ b/Roles/Impostor/Gambler.cs @@ -1,7 +1,7 @@ -using AmongUs.GameOptions; -using System; +using System; using System.Collections.Generic; using System.Linq; +using AmongUs.GameOptions; using TOHE.Roles.Crewmate; using TOHE.Roles.Neutral; using static TOHE.Options; diff --git a/Roles/Impostor/Greedier.cs b/Roles/Impostor/Greedier.cs index 4bc6631b1..92ca1a1d5 100644 --- a/Roles/Impostor/Greedier.cs +++ b/Roles/Impostor/Greedier.cs @@ -1,7 +1,7 @@ -using AmongUs.GameOptions; -using Hazel; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; +using AmongUs.GameOptions; +using Hazel; using TOHE.Modules; using TOHE.Roles.Neutral; diff --git a/Roles/Impostor/Hacker.cs b/Roles/Impostor/Hacker.cs index 914d3f173..4c7989302 100644 --- a/Roles/Impostor/Hacker.cs +++ b/Roles/Impostor/Hacker.cs @@ -1,5 +1,5 @@ -using AmongUs.GameOptions; -using System.Collections.Generic; +using System.Collections.Generic; +using AmongUs.GameOptions; using static TOHE.Options; using static TOHE.Translator; diff --git a/Roles/Impostor/Hangman.cs b/Roles/Impostor/Hangman.cs index 04f50aacc..b62babe5b 100644 --- a/Roles/Impostor/Hangman.cs +++ b/Roles/Impostor/Hangman.cs @@ -1,5 +1,5 @@ -using AmongUs.GameOptions; -using System.Collections.Generic; +using System.Collections.Generic; +using AmongUs.GameOptions; using TOHE.Roles.Crewmate; using static TOHE.Options; diff --git a/Roles/Impostor/Hitman.cs b/Roles/Impostor/Hitman.cs index 25cc90279..66caee434 100644 --- a/Roles/Impostor/Hitman.cs +++ b/Roles/Impostor/Hitman.cs @@ -1,6 +1,6 @@ -using AmongUs.GameOptions; +using System.Collections.Generic; +using AmongUs.GameOptions; using Hazel; -using System.Collections.Generic; using TOHE.Modules; using static TOHE.Options; using static TOHE.Utils; @@ -124,4 +124,4 @@ namespace TOHE.Roles.Impostor return id == byte.MaxValue ? string.Empty : $"Target: {GetPlayerById(id).GetRealName().RemoveHtmlTags()}"; } } -} \ No newline at end of file +} diff --git a/Roles/Impostor/ImpostorVanillaRoles.cs b/Roles/Impostor/ImpostorVanillaRoles.cs deleted file mode 100644 index 55beed5dd..000000000 --- a/Roles/Impostor/ImpostorVanillaRoles.cs +++ /dev/null @@ -1,19 +0,0 @@ -using static TOHE.Options; - -namespace TOHE.Roles.Impostor -{ - internal static class ImpostorVanillaRoles - { - public static void SetupCustomOption() - { - SetupRoleOptions(300, TabGroup.ImpostorRoles, CustomRoles.ImpostorTOHE); - SetupRoleOptions(400, TabGroup.ImpostorRoles, CustomRoles.ShapeshifterTOHE); - ShapeshiftCD = FloatOptionItem.Create(402, "ShapeshiftCooldown", new(1f, 180f, 1f), 30f, TabGroup.ImpostorRoles, false) - .SetParent(CustomRoleSpawnChances[CustomRoles.ShapeshifterTOHE]) - .SetValueFormat(OptionFormat.Seconds); - ShapeshiftDur = FloatOptionItem.Create(403, "ShapeshiftDuration", new(1f, 60f, 1f), 10f, TabGroup.ImpostorRoles, false) - .SetParent(CustomRoleSpawnChances[CustomRoles.ShapeshifterTOHE]) - .SetValueFormat(OptionFormat.Seconds); - } - } -} diff --git a/Roles/Impostor/Librarian.cs b/Roles/Impostor/Librarian.cs index 5d6fe48a2..b0e57ae02 100644 --- a/Roles/Impostor/Librarian.cs +++ b/Roles/Impostor/Librarian.cs @@ -1,6 +1,6 @@ -using AmongUs.GameOptions; +using System.Collections.Generic; +using AmongUs.GameOptions; using Hazel; -using System.Collections.Generic; using TOHE.Modules; using UnityEngine; using static TOHE.Options; diff --git a/Roles/Impostor/Mafia.cs b/Roles/Impostor/Mafia.cs index 6f6e29fea..941312a43 100644 --- a/Roles/Impostor/Mafia.cs +++ b/Roles/Impostor/Mafia.cs @@ -5,6 +5,7 @@ using System; using System.Linq; using TOHE.Modules; using UnityEngine; +using static TOHE.Options; using static TOHE.Translator; using Object = UnityEngine.Object; @@ -15,6 +16,22 @@ namespace TOHE.Roles.Impostor public static bool On; public override bool IsEnable => On; + public static void SetupCustomOption() + { + SetupRoleOptions(3100, TabGroup.ImpostorRoles, CustomRoles.Mafia); + MafiaCanKillNum = IntegerOptionItem.Create(3200, "MafiaCanKillNum", new(0, 15, 1), 1, TabGroup.ImpostorRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Mafia]) + .SetValueFormat(OptionFormat.Players); + LegacyMafia = BooleanOptionItem.Create(3210, "LegacyMafia", false, TabGroup.ImpostorRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Mafia]); + MafiaShapeshiftCD = FloatOptionItem.Create(3211, "ShapeshiftCooldown", new(1f, 180f, 1f), 15f, TabGroup.ImpostorRoles, false) + .SetParent(LegacyMafia) + .SetValueFormat(OptionFormat.Seconds); + MafiaShapeshiftDur = FloatOptionItem.Create(3212, "ShapeshiftDuration", new(1f, 180f, 1f), 30f, TabGroup.ImpostorRoles, false) + .SetParent(LegacyMafia) + .SetValueFormat(OptionFormat.Seconds); + } + public override void Add(byte playerId) { On = true; @@ -32,8 +49,8 @@ namespace TOHE.Roles.Impostor public override void ApplyGameOptions(IGameOptions opt, byte playerId) { - AURoleOptions.ShapeshifterCooldown = Options.MafiaShapeshiftCD.GetFloat(); - AURoleOptions.ShapeshifterDuration = Options.MafiaShapeshiftDur.GetFloat(); + AURoleOptions.ShapeshifterCooldown = MafiaShapeshiftCD.GetFloat(); + AURoleOptions.ShapeshifterDuration = MafiaShapeshiftDur.GetFloat(); } public static bool MafiaMsgCheck(PlayerControl pc, string msg, bool isUI = false) @@ -43,7 +60,7 @@ namespace TOHE.Roles.Impostor if (!pc.Is(CustomRoles.Mafia)) return false; msg = msg.Trim().ToLower(); if (msg.Length < 3 || msg[..3] != "/rv") return false; - if (Options.MafiaCanKillNum.GetInt() < 1) + if (MafiaCanKillNum.GetInt() < 1) { if (!isUI) Utils.SendMessage(GetString("MafiaKillDisable"), pc.PlayerId); else pc.ShowPopUp(GetString("MafiaKillDisable")); @@ -59,7 +76,7 @@ namespace TOHE.Roles.Impostor if (msg == "/rv") { string text = GetString("PlayerIdList"); - text = Main.AllAlivePlayerControls.Aggregate(text, (current, npc) => current + ("\n" + npc.PlayerId + " → (" + npc.GetDisplayRoleName() + ") " + npc.GetRealName())); + text = Main.AllAlivePlayerControls.Aggregate(text, (current, npc) => current + "\n" + npc.PlayerId + " → (" + npc.GetDisplayRoleName() + ") " + npc.GetRealName()); Utils.SendMessage(text, pc.PlayerId); return true; @@ -67,7 +84,7 @@ namespace TOHE.Roles.Impostor if (!Main.MafiaRevenged.TryAdd(pc.PlayerId, 0)) { - if (Main.MafiaRevenged[pc.PlayerId] >= Options.MafiaCanKillNum.GetInt()) + if (Main.MafiaRevenged[pc.PlayerId] >= MafiaCanKillNum.GetInt()) { if (!isUI) Utils.SendMessage(GetString("MafiaKillMax"), pc.PlayerId); else pc.ShowPopUp(GetString("MafiaKillMax")); diff --git a/Roles/Impostor/Mafioso.cs b/Roles/Impostor/Mafioso.cs index 6626b73d2..4d380b99f 100644 --- a/Roles/Impostor/Mafioso.cs +++ b/Roles/Impostor/Mafioso.cs @@ -1,7 +1,7 @@ -using AmongUs.GameOptions; -using Hazel; -using System; +using System; using System.Collections.Generic; +using AmongUs.GameOptions; +using Hazel; using TOHE.Modules; using static TOHE.Options; using static TOHE.Translator; diff --git a/Roles/Impostor/Morphling.cs b/Roles/Impostor/Morphling.cs index 96d4a091c..13d9e58e2 100644 --- a/Roles/Impostor/Morphling.cs +++ b/Roles/Impostor/Morphling.cs @@ -1,5 +1,5 @@ -using AmongUs.GameOptions; using System.Collections.Generic; +using AmongUs.GameOptions; using static TOHE.Options; namespace TOHE.Roles.Impostor; @@ -28,6 +28,7 @@ public class Morphling : RoleBase public override void Init() { playerIdList = []; + } public override void Add(byte playerId) diff --git a/Roles/Impostor/OverKiller.cs b/Roles/Impostor/OverKiller.cs index 3ac142777..2e0e4b8a4 100644 --- a/Roles/Impostor/OverKiller.cs +++ b/Roles/Impostor/OverKiller.cs @@ -1,6 +1,6 @@ -using Hazel; +using System.Linq; +using Hazel; using InnerNet; -using System.Linq; using TOHE.Roles.Crewmate; using TOHE.Roles.Neutral; using UnityEngine; @@ -86,4 +86,4 @@ namespace TOHE.Roles.Impostor return base.OnCheckMurder(killer, target); } } -} \ No newline at end of file +} diff --git a/Roles/Impostor/Puppeteer.cs b/Roles/Impostor/Puppeteer.cs index e62f57cdd..a0cca6980 100644 --- a/Roles/Impostor/Puppeteer.cs +++ b/Roles/Impostor/Puppeteer.cs @@ -1,11 +1,12 @@ -using AmongUs.GameOptions; -using HarmonyLib; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; +using AmongUs.GameOptions; +using HarmonyLib; using TOHE.Modules; using TOHE.Roles.Crewmate; using TOHE.Roles.Neutral; using UnityEngine; +using static TOHE.Options; namespace TOHE.Roles.Impostor { @@ -19,6 +20,43 @@ namespace TOHE.Roles.Impostor public static bool On; public override bool IsEnable => On; + public static void SetupCustomOption() + { + SetupRoleOptions(3900, TabGroup.ImpostorRoles, CustomRoles.Puppeteer); + PuppeteerCD = FloatOptionItem.Create(3911, "PuppeteerCD", new(2.5f, 60f, 2.5f), 22.5f, TabGroup.ImpostorRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Puppeteer]) + .SetValueFormat(OptionFormat.Seconds); + PuppeteerCanKillNormally = BooleanOptionItem.Create(3917, "PuppeteerCanKillNormally", true, TabGroup.ImpostorRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Puppeteer]); + PuppeteerKCD = FloatOptionItem.Create(3912, "PuppeteerKCD", new(2.5f, 60f, 2.5f), 25f, TabGroup.ImpostorRoles, false) + .SetParent(PuppeteerCanKillNormally) + .SetValueFormat(OptionFormat.Seconds); + PuppeteerMinDelay = IntegerOptionItem.Create(3913, "PuppeteerMinDelay", new(0, 90, 1), 3, TabGroup.ImpostorRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Puppeteer]) + .SetValueFormat(OptionFormat.Seconds); + PuppeteerMaxDelay = IntegerOptionItem.Create(3914, "PuppeteerMaxDelay", new(0, 90, 1), 7, TabGroup.ImpostorRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Puppeteer]) + .SetValueFormat(OptionFormat.Seconds); + PuppeteerManipulationEndsAfterFixedTime = BooleanOptionItem.Create(3915, "PuppeteerManipulationEndsAfterFixedTime", false, TabGroup.ImpostorRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Puppeteer]); + PuppeteerManipulationEndsAfterTime = IntegerOptionItem.Create(3916, "PuppeteerManipulationEndsAfterTime", new(0, 90, 1), 30, TabGroup.ImpostorRoles, false) + .SetParent(PuppeteerManipulationEndsAfterFixedTime) + .SetValueFormat(OptionFormat.Seconds); + PuppeteerManipulationBypassesLazy = BooleanOptionItem.Create(3918, "PuppeteerManipulationBypassesLazy", false, TabGroup.ImpostorRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Puppeteer]); + PuppeteerManipulationBypassesLazyGuy = BooleanOptionItem.Create(3922, "PuppeteerManipulationBypassesLazyGuy", false, TabGroup.ImpostorRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Puppeteer]); + PuppeteerPuppetCanKillImpostors = BooleanOptionItem.Create(3919, "PuppeteerPuppetCanKillImpostors", false, TabGroup.ImpostorRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Puppeteer]); + PuppeteerPuppetCanKillPuppeteer = BooleanOptionItem.Create(3920, "PuppeteerPuppetCanKillPuppeteer", false, TabGroup.ImpostorRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Puppeteer]); + Options.PuppeteerMaxPuppets = IntegerOptionItem.Create(3921, "PuppeteerMaxPuppets", new(0, 30, 1), 5, TabGroup.ImpostorRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Puppeteer]) + .SetValueFormat(OptionFormat.Times); + PuppeteerDiesAfterMaxPuppets = BooleanOptionItem.Create(3923, "PuppeteerDiesAfterMaxPuppets", false, TabGroup.ImpostorRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Puppeteer]); + } + public override void Add(byte playerId) { On = true; @@ -35,7 +73,7 @@ namespace TOHE.Roles.Impostor public override void SetKillCooldown(byte id) { - Main.AllPlayerKillCooldown[id] = Options.PuppeteerCanKillNormally.GetBool() ? Options.PuppeteerKCD.GetFloat() : Options.PuppeteerCD.GetFloat(); + Main.AllPlayerKillCooldown[id] = PuppeteerCanKillNormally.GetBool() ? PuppeteerKCD.GetFloat() : PuppeteerCD.GetFloat(); } public override void SetButtonTexts(HudManager hud, byte id) @@ -45,8 +83,8 @@ namespace TOHE.Roles.Impostor public override bool OnCheckMurder(PlayerControl killer, PlayerControl target) { - if (target.Is(CustomRoles.Needy) && Options.PuppeteerManipulationBypassesLazyGuy.GetBool()) return false; - if (target.Is(CustomRoles.Lazy) && Options.PuppeteerManipulationBypassesLazy.GetBool()) return false; + if (target.Is(CustomRoles.Needy) && PuppeteerManipulationBypassesLazyGuy.GetBool()) return false; + if (target.Is(CustomRoles.Lazy) && PuppeteerManipulationBypassesLazy.GetBool()) return false; if (Medic.ProtectList.Contains(target.PlayerId)) return false; if (!PuppeteerMaxPuppets.TryGetValue(killer.PlayerId, out var usesLeft)) @@ -55,14 +93,14 @@ namespace TOHE.Roles.Impostor PuppeteerMaxPuppets.Add(killer.PlayerId, usesLeft); } - if (Options.PuppeteerCanKillNormally.GetBool()) + if (PuppeteerCanKillNormally.GetBool()) { return killer.CheckDoubleTrigger(target, () => { PuppeteerList[target.PlayerId] = killer.PlayerId; PuppeteerDelayList[target.PlayerId] = Utils.TimeStamp; - PuppeteerDelay[target.PlayerId] = IRandom.Instance.Next(Options.PuppeteerMinDelay.GetInt(), Options.PuppeteerMaxDelay.GetInt()); - killer.SetKillCooldown(time: Options.PuppeteerCD.GetFloat()); + PuppeteerDelay[target.PlayerId] = IRandom.Instance.Next(PuppeteerMinDelay.GetInt(), PuppeteerMaxDelay.GetInt()); + killer.SetKillCooldown(time: PuppeteerCD.GetFloat()); if (usesLeft <= 1) { _ = new LateTask(() => { killer.Suicide(); }, 1.5f, "Puppeteer Max Uses Reached => Suicide"); @@ -77,7 +115,7 @@ namespace TOHE.Roles.Impostor PuppeteerList[target.PlayerId] = killer.PlayerId; PuppeteerDelayList[target.PlayerId] = Utils.TimeStamp; - PuppeteerDelay[target.PlayerId] = IRandom.Instance.Next(Options.PuppeteerMinDelay.GetInt(), Options.PuppeteerMaxDelay.GetInt()); + PuppeteerDelay[target.PlayerId] = IRandom.Instance.Next(PuppeteerMinDelay.GetInt(), PuppeteerMaxDelay.GetInt()); killer.SetKillCooldown(); if (usesLeft <= 1) { @@ -106,7 +144,7 @@ namespace TOHE.Roles.Impostor PuppeteerDelayList.Remove(playerId); PuppeteerDelay.Remove(playerId); } - else if (PuppeteerDelayList[playerId] + Options.PuppeteerManipulationEndsAfterTime.GetInt() < now && Options.PuppeteerManipulationEndsAfterFixedTime.GetBool()) + else if (PuppeteerDelayList[playerId] + PuppeteerManipulationEndsAfterTime.GetInt() < now && PuppeteerManipulationEndsAfterFixedTime.GetBool()) { PuppeteerList.Remove(playerId); PuppeteerDelayList.Remove(playerId); @@ -120,8 +158,8 @@ namespace TOHE.Roles.Impostor foreach (PlayerControl target in Main.AllAlivePlayerControls) { if (target.PlayerId == playerId || target.Is(CustomRoles.Pestilence)) continue; - if (target.Is(CustomRoles.Puppeteer) && !Options.PuppeteerPuppetCanKillPuppeteer.GetBool()) continue; - if (target.Is(CustomRoleTypes.Impostor) && !Options.PuppeteerPuppetCanKillImpostors.GetBool()) continue; + if (target.Is(CustomRoles.Puppeteer) && !PuppeteerPuppetCanKillPuppeteer.GetBool()) continue; + if (target.Is(CustomRoleTypes.Impostor) && !PuppeteerPuppetCanKillImpostors.GetBool()) continue; float dis = Vector2.Distance(puppeteerPos, target.transform.position); targetDistance.Add(target.PlayerId, dis); diff --git a/Roles/Impostor/QuickShooter.cs b/Roles/Impostor/QuickShooter.cs index bce6d74e8..cbe1ffe52 100644 --- a/Roles/Impostor/QuickShooter.cs +++ b/Roles/Impostor/QuickShooter.cs @@ -1,7 +1,7 @@ -using AmongUs.GameOptions; -using Hazel; -using System; +using System; using System.Collections.Generic; +using AmongUs.GameOptions; +using Hazel; using TOHE.Modules; using UnityEngine; diff --git a/Roles/Impostor/RiftMaker.cs b/Roles/Impostor/RiftMaker.cs index e6f919759..973315fd0 100644 --- a/Roles/Impostor/RiftMaker.cs +++ b/Roles/Impostor/RiftMaker.cs @@ -1,5 +1,5 @@ -using AmongUs.GameOptions; -using System.Collections.Generic; +using System.Collections.Generic; +using AmongUs.GameOptions; using TOHE.Roles.Neutral; using UnityEngine; using static TOHE.Options; diff --git a/Roles/Impostor/Sans.cs b/Roles/Impostor/Sans.cs index db0651de6..e0105cdff 100644 --- a/Roles/Impostor/Sans.cs +++ b/Roles/Impostor/Sans.cs @@ -1,6 +1,6 @@ -using AmongUs.GameOptions; -using System; +using System; using System.Collections.Generic; +using AmongUs.GameOptions; using TOHE.Roles.Neutral; using static TOHE.Options; diff --git a/Roles/Impostor/Sapper.cs b/Roles/Impostor/Sapper.cs index fd783daa0..6f5aa0304 100644 --- a/Roles/Impostor/Sapper.cs +++ b/Roles/Impostor/Sapper.cs @@ -1,7 +1,7 @@ -using AmongUs.GameOptions; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using System.Text; +using AmongUs.GameOptions; using TOHE.Roles.Neutral; using UnityEngine; using static TOHE.Options; diff --git a/Roles/Impostor/Sniper.cs b/Roles/Impostor/Sniper.cs index 066ec04ee..08535ffb4 100644 --- a/Roles/Impostor/Sniper.cs +++ b/Roles/Impostor/Sniper.cs @@ -1,7 +1,7 @@ -using AmongUs.GameOptions; -using Hazel; using System.Collections.Generic; using System.Linq; +using AmongUs.GameOptions; +using Hazel; using TOHE.Modules; using TOHE.Roles.Crewmate; using TOHE.Roles.Neutral; diff --git a/Roles/Impostor/Stealth.cs b/Roles/Impostor/Stealth.cs index 0aafab345..79b7158c0 100644 --- a/Roles/Impostor/Stealth.cs +++ b/Roles/Impostor/Stealth.cs @@ -1,6 +1,6 @@ -using Hazel; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; +using Hazel; using TOHE.Modules; using UnityEngine; diff --git a/Roles/Impostor/Swapster.cs b/Roles/Impostor/Swapster.cs index 4c1daa781..4ae3f3914 100644 --- a/Roles/Impostor/Swapster.cs +++ b/Roles/Impostor/Swapster.cs @@ -1,5 +1,5 @@ -using AmongUs.GameOptions; -using System.Collections.Generic; +using System.Collections.Generic; +using AmongUs.GameOptions; namespace TOHE.Roles.Impostor { @@ -52,4 +52,4 @@ namespace TOHE.Roles.Impostor return false; } } -} \ No newline at end of file +} diff --git a/Roles/Impostor/Swooper.cs b/Roles/Impostor/Swooper.cs index 514065277..f8ee01740 100644 --- a/Roles/Impostor/Swooper.cs +++ b/Roles/Impostor/Swooper.cs @@ -1,8 +1,8 @@ -using AmongUs.GameOptions; -using Hazel; -using System; +using System; using System.Collections.Generic; using System.Text; +using AmongUs.GameOptions; +using Hazel; using TOHE.Modules; using TOHE.Roles.Crewmate; using TOHE.Roles.Neutral; diff --git a/Roles/Impostor/Twister.cs b/Roles/Impostor/Twister.cs index 7c4473329..379a44ed7 100644 --- a/Roles/Impostor/Twister.cs +++ b/Roles/Impostor/Twister.cs @@ -1,6 +1,6 @@ -using AmongUs.GameOptions; using System.Collections.Generic; using System.Linq; +using AmongUs.GameOptions; using TOHE.Modules; using TOHE.Roles.Neutral; using static TOHE.Options; diff --git a/Roles/Impostor/Undertaker.cs b/Roles/Impostor/Undertaker.cs new file mode 100644 index 000000000..b483e4822 --- /dev/null +++ b/Roles/Impostor/Undertaker.cs @@ -0,0 +1,22 @@ +using static TOHE.Options; + +namespace TOHE.Roles.Impostor; + +internal static class Undertaker +{ + private const int Id = 750; + + public static OptionItem MarkCooldown; + public static OptionItem AssassinateCooldown; + public static OptionItem CanKillAfterAssassinate; + + public static void SetupCustomOption() + { + SetupRoleOptions(Id, TabGroup.ImpostorRoles, CustomRoles.Undertaker); + MarkCooldown = FloatOptionItem.Create(Id + 10, "UndertakerMarkCooldown", new(0f, 180f, 0.5f), 1f, TabGroup.ImpostorRoles, false).SetParent(CustomRoleSpawnChances[CustomRoles.Undertaker]) + .SetValueFormat(OptionFormat.Seconds); + AssassinateCooldown = FloatOptionItem.Create(Id + 11, "UndertakerAssassinateCooldown", new(0f, 180f, 0.5f), 18.5f, TabGroup.ImpostorRoles, false).SetParent(CustomRoleSpawnChances[CustomRoles.Undertaker]) + .SetValueFormat(OptionFormat.Seconds); + CanKillAfterAssassinate = BooleanOptionItem.Create(Id + 12, "UndertakerCanKillAfterAssassinate", true, TabGroup.ImpostorRoles, false).SetParent(CustomRoleSpawnChances[CustomRoles.Undertaker]); + } +} \ No newline at end of file diff --git a/Roles/Impostor/Vindicator.cs b/Roles/Impostor/Vindicator.cs deleted file mode 100644 index 556b73765..000000000 --- a/Roles/Impostor/Vindicator.cs +++ /dev/null @@ -1,17 +0,0 @@ -using static TOHE.Options; - -namespace TOHE.Roles.Impostor -{ - internal static class Vindicator - { - public static void SetupCustomOption() - { - SetupRoleOptions(3400, TabGroup.ImpostorRoles, CustomRoles.Vindicator); - VindicatorAdditionalVote = IntegerOptionItem.Create(3410, "MayorAdditionalVote", new(1, 30, 1), 1, TabGroup.ImpostorRoles, false) - .SetParent(CustomRoleSpawnChances[CustomRoles.Vindicator]) - .SetValueFormat(OptionFormat.Votes); - VindicatorHideVote = BooleanOptionItem.Create(3411, "MayorHideVote", false, TabGroup.ImpostorRoles, false) - .SetParent(CustomRoleSpawnChances[CustomRoles.Vindicator]); - } - } -} diff --git a/Roles/Impostor/Warlock.cs b/Roles/Impostor/Warlock.cs index be356b656..38b9de983 100644 --- a/Roles/Impostor/Warlock.cs +++ b/Roles/Impostor/Warlock.cs @@ -1,10 +1,11 @@ -using AmongUs.GameOptions; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; +using AmongUs.GameOptions; using TOHE.Modules; using TOHE.Roles.Crewmate; using TOHE.Roles.Neutral; using UnityEngine; +using static TOHE.Options; namespace TOHE.Roles.Impostor { @@ -13,6 +14,18 @@ namespace TOHE.Roles.Impostor public static bool On; public override bool IsEnable => On; + public static void SetupCustomOption() + { + SetupRoleOptions(4600, TabGroup.ImpostorRoles, CustomRoles.Warlock); + WarlockCanKillAllies = BooleanOptionItem.Create(4610, "CanKillAllies", true, TabGroup.ImpostorRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Warlock]); + WarlockCanKillSelf = BooleanOptionItem.Create(4611, "CanKillSelf", false, TabGroup.ImpostorRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Warlock]); + WarlockShiftDuration = FloatOptionItem.Create(4612, "ShapeshiftDuration", new(0, 180, 1), 1, TabGroup.ImpostorRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Warlock]) + .SetValueFormat(OptionFormat.Seconds); + } + public override void Add(byte playerId) { On = true; @@ -27,11 +40,11 @@ namespace TOHE.Roles.Impostor public override void ApplyGameOptions(IGameOptions opt, byte playerId) { - if (Options.UsePets.GetBool()) return; + if (UsePets.GetBool()) return; try { - AURoleOptions.ShapeshifterCooldown = Main.isCursed ? 1f : Options.DefaultKillCooldown; - AURoleOptions.ShapeshifterDuration = Options.WarlockShiftDuration.GetFloat(); + AURoleOptions.ShapeshifterCooldown = Main.isCursed ? 1f : DefaultKillCooldown; + AURoleOptions.ShapeshifterDuration = WarlockShiftDuration.GetFloat(); } catch { @@ -98,8 +111,8 @@ namespace TOHE.Roles.Impostor foreach (PlayerControl p in Main.AllAlivePlayerControls) { if (p.PlayerId == cp.PlayerId) continue; - if (!Options.WarlockCanKillSelf.GetBool() && p.PlayerId == pc.PlayerId) continue; - if (!Options.WarlockCanKillAllies.GetBool() && p.GetCustomRole().IsImpostor()) continue; + if (!WarlockCanKillSelf.GetBool() && p.PlayerId == pc.PlayerId) continue; + if (!WarlockCanKillAllies.GetBool() && p.GetCustomRole().IsImpostor()) continue; if (p.Is(CustomRoles.Pestilence)) continue; if (Pelican.IsEaten(p.PlayerId) || Medic.ProtectList.Contains(p.PlayerId)) continue; float dis = Vector2.Distance(cppos, p.Pos()); diff --git a/Roles/Impostor/Wildling.cs b/Roles/Impostor/Wildling.cs index 91fa78ec4..0ca0ecfb2 100644 --- a/Roles/Impostor/Wildling.cs +++ b/Roles/Impostor/Wildling.cs @@ -1,8 +1,8 @@ -using AmongUs.GameOptions; -using Hazel; using System; using System.Collections.Generic; using System.Text; +using AmongUs.GameOptions; +using Hazel; using TOHE.Modules; using TOHE.Roles.Neutral; using static TOHE.Options; @@ -109,7 +109,6 @@ public class Wildling : RoleBase writer.Write(TimeStamp.ToString()); AmongUsClient.Instance.FinishRpcImmediately(writer); } - public static void ReceiveRPC(MessageReader reader) { byte PlayerId = reader.ReadByte(); @@ -150,7 +149,6 @@ public class Wildling : RoleBase pc.Notify(Translator.GetString("BKProtectOut")); } } - public static string GetHudText(PlayerControl pc) { if (pc == null || !GameStates.IsInTask || !PlayerControl.LocalPlayer.IsAlive()) return string.Empty; @@ -166,7 +164,6 @@ public class Wildling : RoleBase { str.Append(Translator.GetString("BKSkillNotice")); } - return str.ToString(); } } \ No newline at end of file diff --git a/Roles/Impostor/Witch.cs b/Roles/Impostor/Witch.cs index 80cccbe40..0a59f2936 100644 --- a/Roles/Impostor/Witch.cs +++ b/Roles/Impostor/Witch.cs @@ -1,6 +1,6 @@ -using Hazel; using System.Collections.Generic; using System.Text; +using Hazel; using TOHE.Modules; using TOHE.Patches; using TOHE.Roles.Crewmate; @@ -83,6 +83,7 @@ public class Witch : RoleBase writer.Write(witchId); writer.Write(spellMode); AmongUsClient.Instance.FinishRpcImmediately(writer); + } } @@ -139,7 +140,6 @@ public class Witch : RoleBase Utils.NotifyRoles(SpecifySeer: killer, SpecifyTarget: target, ForceLoop: true); } } - public static void RemoveSpelledPlayer() { foreach (byte witch in playerIdList) @@ -164,14 +164,12 @@ public class Witch : RoleBase SwitchSpellMode(killer.PlayerId, true); return true; } - SetSpelled(killer, target); SwitchSpellMode(killer.PlayerId, true); return false; } - public static void OnCheckForEndVoting(PlayerState.DeathReason deathReason, params byte[] exileIds) { if (deathReason != PlayerState.DeathReason.Vote) return; @@ -183,7 +181,6 @@ public class Witch : RoleBase wc.SpelledPlayer.Clear(); } } - var spelledIdList = new List(); foreach (PlayerControl pc in Main.AllAlivePlayerControls) { @@ -208,7 +205,6 @@ public class Witch : RoleBase CheckForEndVotingPatch.TryAddAfterMeetingDeathPlayers(PlayerState.DeathReason.Spell, [.. spelledIdList]); RemoveSpelledPlayer(); } - public static string GetSpelledMark(byte target, bool isMeeting) { if (!isMeeting) return string.Empty; @@ -219,10 +215,8 @@ public class Witch : RoleBase return Utils.ColorString(Palette.ImpostorRed, "†"); } } - return string.Empty; } - public static string GetSpellModeText(PlayerControl witch, bool hud, bool isMeeting = false) { if (witch == null || isMeeting) return string.Empty; @@ -236,7 +230,6 @@ public class Witch : RoleBase { str.Append($"{GetString("Mode")}: "); } - if (NowSwitchTrigger == SwitchTrigger.DoubleTrigger) { str.Append(GetString("WitchModeDouble")); @@ -245,10 +238,8 @@ public class Witch : RoleBase { str.Append(IsSpellMode(witch.PlayerId) ? GetString("WitchModeSpell") : GetString("WitchModeKill")); } - return str.ToString(); } - public static void GetAbilityButtonText(HudManager hud) { if (IsSpellMode(PlayerControl.LocalPlayer.PlayerId) && NowSwitchTrigger != SwitchTrigger.DoubleTrigger) diff --git a/Roles/Impostor/YinYanger.cs b/Roles/Impostor/YinYanger.cs index 237c65946..4cabcd6c9 100644 --- a/Roles/Impostor/YinYanger.cs +++ b/Roles/Impostor/YinYanger.cs @@ -1,5 +1,5 @@ -using Hazel; -using System.Collections.Generic; +using System.Collections.Generic; +using Hazel; using TOHE.Modules; using UnityEngine; using static TOHE.Options; diff --git a/Roles/Impostor/Zombie.cs b/Roles/Impostor/Zombie.cs index 230662204..bf47fd474 100644 --- a/Roles/Impostor/Zombie.cs +++ b/Roles/Impostor/Zombie.cs @@ -1,5 +1,6 @@ -using AmongUs.GameOptions; -using System; +using System; +using AmongUs.GameOptions; +using static TOHE.Options; namespace TOHE.Roles.Impostor { @@ -8,6 +9,17 @@ namespace TOHE.Roles.Impostor public static bool On; public override bool IsEnable => On; + public static void SetupCustomOption() + { + SetupRoleOptions(16400, TabGroup.OtherRoles, CustomRoles.Zombie); + ZombieKillCooldown = FloatOptionItem.Create(16410, "KillCooldown", new(0f, 180f, 2.5f), 5f, TabGroup.OtherRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Zombie]) + .SetValueFormat(OptionFormat.Seconds); + ZombieSpeedReduce = FloatOptionItem.Create(16411, "ZombieSpeedReduce", new(0.0f, 1.0f, 0.1f), 0.1f, TabGroup.OtherRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Zombie]) + .SetValueFormat(OptionFormat.Multiplier); + } + public override void Add(byte playerId) { On = true; @@ -20,8 +32,8 @@ namespace TOHE.Roles.Impostor public override void SetKillCooldown(byte id) { - Main.AllPlayerKillCooldown[id] = Options.ZombieKillCooldown.GetFloat(); - Main.AllPlayerSpeed[id] = Math.Clamp(Main.AllPlayerSpeed[id] - Options.ZombieSpeedReduce.GetFloat(), 0.1f, 3f); + Main.AllPlayerKillCooldown[id] = ZombieKillCooldown.GetFloat(); + Main.AllPlayerSpeed[id] = Math.Clamp(Main.AllPlayerSpeed[id] - ZombieSpeedReduce.GetFloat(), 0.1f, 3f); } public override void ApplyGameOptions(IGameOptions opt, byte playerId) diff --git a/Roles/Neutral/Agitater.cs b/Roles/Neutral/Agitater.cs index 9f0075efa..0d1f83cd1 100644 --- a/Roles/Neutral/Agitater.cs +++ b/Roles/Neutral/Agitater.cs @@ -1,7 +1,7 @@ -using AmongUs.GameOptions; -using Hazel; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; +using AmongUs.GameOptions; +using Hazel; using TOHE.Modules; using TOHE.Roles.Crewmate; using UnityEngine; diff --git a/Roles/Neutral/Amnesiac.cs b/Roles/Neutral/Amnesiac.cs index 405801116..1fa99d0eb 100644 --- a/Roles/Neutral/Amnesiac.cs +++ b/Roles/Neutral/Amnesiac.cs @@ -1,6 +1,6 @@ -using AmongUs.GameOptions; using System; using System.Collections.Generic; +using AmongUs.GameOptions; using static TOHE.Options; using static TOHE.Translator; diff --git a/Roles/Neutral/Arsonist.cs b/Roles/Neutral/Arsonist.cs index 5bc11af7d..8d67de39e 100644 --- a/Roles/Neutral/Arsonist.cs +++ b/Roles/Neutral/Arsonist.cs @@ -1,7 +1,8 @@ -using AmongUs.GameOptions; -using System.Linq; +using System.Linq; +using AmongUs.GameOptions; using TOHE.Modules; using UnityEngine; +using static TOHE.Options; namespace TOHE.Roles.Neutral { @@ -10,6 +11,25 @@ namespace TOHE.Roles.Neutral public static bool On; public override bool IsEnable => On; + public static void SetupCustomOption() + { + SetupRoleOptions(10400, TabGroup.NeutralRoles, CustomRoles.Arsonist); + ArsonistDouseTime = FloatOptionItem.Create(10410, "ArsonistDouseTime", new(0f, 90f, 1f), 3f, TabGroup.NeutralRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Arsonist]) + .SetValueFormat(OptionFormat.Seconds); + ArsonistCooldown = FloatOptionItem.Create(10411, "Cooldown", new(0f, 60f, 1f), 10f, TabGroup.NeutralRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Arsonist]) + .SetValueFormat(OptionFormat.Seconds); + ArsonistCanIgniteAnytime = BooleanOptionItem.Create(10413, "ArsonistCanIgniteAnytime", false, TabGroup.NeutralRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Arsonist]); + ArsonistMinPlayersToIgnite = IntegerOptionItem.Create(10414, "ArsonistMinPlayersToIgnite", new(1, 14, 1), 1, TabGroup.NeutralRoles, false) + .SetParent(ArsonistCanIgniteAnytime); + ArsonistMaxPlayersToIgnite = IntegerOptionItem.Create(10415, "ArsonistMaxPlayersToIgnite", new(1, 14, 1), 3, TabGroup.NeutralRoles, false) + .SetParent(ArsonistCanIgniteAnytime); + ArsonistKeepsGameGoing = BooleanOptionItem.Create(10412, "ArsonistKeepsGameGoing", false, TabGroup.NeutralRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Arsonist]); + } + public override void Add(byte playerId) { On = true; @@ -26,17 +46,17 @@ namespace TOHE.Roles.Neutral public override bool CanUseKillButton(PlayerControl pc) { - return Options.ArsonistCanIgniteAnytime.GetBool() ? Utils.GetDousedPlayerCount(pc.PlayerId).Item1 < Options.ArsonistMaxPlayersToIgnite.GetInt() : !pc.IsDouseDone(); + return ArsonistCanIgniteAnytime.GetBool() ? Utils.GetDousedPlayerCount(pc.PlayerId).Item1 < ArsonistMaxPlayersToIgnite.GetInt() : !pc.IsDouseDone(); } public override bool CanUseImpostorVentButton(PlayerControl pc) { - return pc.IsDouseDone() || (Options.ArsonistCanIgniteAnytime.GetBool() && (Utils.GetDousedPlayerCount(pc.PlayerId).Item1 >= Options.ArsonistMinPlayersToIgnite.GetInt() || pc.inVent)); + return pc.IsDouseDone() || (ArsonistCanIgniteAnytime.GetBool() && (Utils.GetDousedPlayerCount(pc.PlayerId).Item1 >= ArsonistMinPlayersToIgnite.GetInt() || pc.inVent)); } public override void SetKillCooldown(byte id) { - Main.AllPlayerKillCooldown[id] = Options.ArsonistCooldown.GetFloat(); + Main.AllPlayerKillCooldown[id] = ArsonistCooldown.GetFloat(); } public override void ApplyGameOptions(IGameOptions opt, byte playerId) @@ -47,12 +67,12 @@ namespace TOHE.Roles.Neutral public override string GetProgressText(byte playerId, bool comms) { var doused = Utils.GetDousedPlayerCount(playerId); - return Utils.ColorString(Utils.GetRoleColor(CustomRoles.Arsonist).ShadeColor(0.25f), !Options.ArsonistCanIgniteAnytime.GetBool() ? $"- {doused.Item1}/{doused.Item2}" : $"- {doused.Item1}/{Options.ArsonistMaxPlayersToIgnite.GetInt()}"); + return Utils.ColorString(Utils.GetRoleColor(CustomRoles.Arsonist).ShadeColor(0.25f), !ArsonistCanIgniteAnytime.GetBool() ? $"- {doused.Item1}/{doused.Item2}" : $"- {doused.Item1}/{ArsonistMaxPlayersToIgnite.GetInt()}"); } public override bool OnCheckMurder(PlayerControl killer, PlayerControl target) { - killer.SetKillCooldown(Options.ArsonistDouseTime.GetFloat()); + killer.SetKillCooldown(ArsonistDouseTime.GetFloat()); if (!Main.isDoused[(killer.PlayerId, target.PlayerId)] && !Main.ArsonistTimer.ContainsKey(killer.PlayerId)) { Main.ArsonistTimer.Add(killer.PlayerId, (target, 0f)); @@ -99,16 +119,15 @@ namespace TOHE.Roles.Neutral return; } - if (Options.ArsonistCanIgniteAnytime.GetBool()) + if (ArsonistCanIgniteAnytime.GetBool()) { var douseCount = Utils.GetDousedPlayerCount(physics.myPlayer.PlayerId).Item1; - if (douseCount >= Options.ArsonistMinPlayersToIgnite.GetInt()) // Don't check for max, since the player would not be able to ignite at all if they somehow get more players doused than the max + if (douseCount >= ArsonistMinPlayersToIgnite.GetInt()) // Don't check for max, since the player would not be able to ignite at all if they somehow get more players doused than the max { - if (douseCount > Options.ArsonistMaxPlayersToIgnite.GetInt()) Logger.Warn("Arsonist Ignited with more players doused than the maximum amount in the settings", "Arsonist Ignite"); + if (douseCount > ArsonistMaxPlayersToIgnite.GetInt()) Logger.Warn("Arsonist Ignited with more players doused than the maximum amount in the settings", "Arsonist Ignite"); foreach (PlayerControl pc in Main.AllAlivePlayerControls) { - if (!physics.myPlayer.IsDousedPlayer(pc)) - continue; + if (!physics.myPlayer.IsDousedPlayer(pc)) continue; pc.KillFlash(); pc.Suicide(PlayerState.DeathReason.Torched, physics.myPlayer); } @@ -120,19 +139,14 @@ namespace TOHE.Roles.Neutral CustomWinnerHolder.ShiftWinnerAndSetWinner(CustomWinner.Arsonist); CustomWinnerHolder.WinnerIds.Add(physics.myPlayer.PlayerId); break; - case 2: - { - foreach (var x in Main.AllAlivePlayerControls.Where(p => p.PlayerId != physics.myPlayer.PlayerId).ToArray()) + default: + if (Main.AllAlivePlayerControls.Where(x => x.PlayerId != physics.myPlayer.PlayerId).All(x => x.GetCountTypes() == CountTypes.Crew)) { - if (!x.GetCustomRole().IsImpostor() && !x.GetCustomRole().IsNeutralKilling()) - { - CustomWinnerHolder.ShiftWinnerAndSetWinner(CustomWinner.Arsonist); - CustomWinnerHolder.WinnerIds.Add(physics.myPlayer.PlayerId); - } + CustomWinnerHolder.ShiftWinnerAndSetWinner(CustomWinner.Arsonist); + CustomWinnerHolder.WinnerIds.Add(physics.myPlayer.PlayerId); } break; - } } } } @@ -158,7 +172,7 @@ namespace TOHE.Roles.Neutral { Main.ArsonistTimer.Remove(playerId); } - else if (ar_time >= Options.ArsonistDouseTime.GetFloat()) + else if (ar_time >= ArsonistDouseTime.GetFloat()) { player.SetKillCooldown(); Main.ArsonistTimer.Remove(playerId); diff --git a/Roles/Neutral/Bandit.cs b/Roles/Neutral/Bandit.cs index 37b109e79..97da77322 100644 --- a/Roles/Neutral/Bandit.cs +++ b/Roles/Neutral/Bandit.cs @@ -1,6 +1,6 @@ -using AmongUs.GameOptions; +using System.Collections.Generic; +using AmongUs.GameOptions; using Hazel; -using System.Collections.Generic; using TOHE.Modules; using UnityEngine; using static TOHE.Options; diff --git a/Roles/Neutral/Bubble.cs b/Roles/Neutral/Bubble.cs index 6c934c90f..ec24ecfaa 100644 --- a/Roles/Neutral/Bubble.cs +++ b/Roles/Neutral/Bubble.cs @@ -1,8 +1,8 @@ -using AmongUs.GameOptions; +using System.Collections.Generic; +using System.Linq; +using AmongUs.GameOptions; using HarmonyLib; using Hazel; -using System.Collections.Generic; -using System.Linq; using TOHE.Modules; using UnityEngine; using static TOHE.Options; @@ -26,6 +26,7 @@ namespace TOHE.Roles.Neutral private static OptionItem ExplosionRadius; public static readonly Dictionary EncasedPlayers = []; + private static readonly Dictionary LastUpdates = []; public static void SetupCustomOption() { @@ -54,6 +55,7 @@ namespace TOHE.Roles.Neutral { BubbleId = byte.MaxValue; EncasedPlayers.Clear(); + LastUpdates.Clear(); } public override void Add(byte playerId) @@ -142,7 +144,11 @@ namespace TOHE.Roles.Neutral if (ts + NotifyDelay.GetInt() < now) { - Main.AllAlivePlayerControls.Where(x => Vector2.Distance(x.Pos(), encasedPc.Pos()) < 5f).Do(x => NotifyRoles(SpecifySeer: x, SpecifyTarget: encasedPc)); + Main.AllAlivePlayerControls.Where(x => (!LastUpdates.TryGetValue(x.PlayerId, out var la) || la != now) && Vector2.Distance(x.Pos(), encasedPc.Pos()) < 5f).Do(x => + { + NotifyRoles(SpecifySeer: x, SpecifyTarget: encasedPc); + LastUpdates[x.PlayerId] = now; + }); } } diff --git a/Roles/Neutral/Collector.cs b/Roles/Neutral/Collector.cs index b152eb1fa..9e5884b7d 100644 --- a/Roles/Neutral/Collector.cs +++ b/Roles/Neutral/Collector.cs @@ -1,6 +1,6 @@ -using Hazel; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; +using Hazel; using TOHE.Modules; using TOHE.Patches; diff --git a/Roles/Neutral/DarkHide.cs b/Roles/Neutral/DarkHide.cs index 0d6f2833f..856339570 100644 --- a/Roles/Neutral/DarkHide.cs +++ b/Roles/Neutral/DarkHide.cs @@ -1,7 +1,7 @@ -using AmongUs.GameOptions; +using System.Collections.Generic; +using AmongUs.GameOptions; using Hazel; using InnerNet; -using System.Collections.Generic; using TOHE.Modules; namespace TOHE.Roles.Neutral; diff --git a/Roles/Neutral/Doomsayer.cs b/Roles/Neutral/Doomsayer.cs index 4c10d5f0d..7b2fb3076 100644 --- a/Roles/Neutral/Doomsayer.cs +++ b/Roles/Neutral/Doomsayer.cs @@ -1,5 +1,5 @@ -using Hazel; -using System.Collections.Generic; +using System.Collections.Generic; +using Hazel; using TOHE.Modules; using UnityEngine; diff --git a/Roles/Neutral/Doppelganger.cs b/Roles/Neutral/Doppelganger.cs index 5d3294449..4486e8482 100644 --- a/Roles/Neutral/Doppelganger.cs +++ b/Roles/Neutral/Doppelganger.cs @@ -1,6 +1,6 @@ -using Hazel; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; +using Hazel; using TOHE.Modules; using TOHE.Roles.Impostor; using UnityEngine; @@ -35,12 +35,12 @@ public class Doppelganger : RoleBase public static void SetupCustomOption() { - SetupSingleRoleOptions(Id, TabGroup.NeutralRoles, CustomRoles.Doppelganger, 1, zeroOne: false); - MaxSteals = IntegerOptionItem.Create(Id + 10, "DoppelMaxSteals", new(1, 14, 1), 9, TabGroup.NeutralRoles, false).SetParent(CustomRoleSpawnChances[CustomRoles.Doppelganger]); - KillCooldown = FloatOptionItem.Create(Id + 11, "KillCooldown", new(0f, 180f, 2.5f), 20f, TabGroup.NeutralRoles, false).SetParent(CustomRoleSpawnChances[CustomRoles.Doppelganger]) + SetupSingleRoleOptions(Id, TabGroup.OtherRoles, CustomRoles.Doppelganger, 1, zeroOne: false); + MaxSteals = IntegerOptionItem.Create(Id + 10, "DoppelMaxSteals", new(1, 14, 1), 9, TabGroup.OtherRoles, false).SetParent(CustomRoleSpawnChances[CustomRoles.Doppelganger]); + KillCooldown = FloatOptionItem.Create(Id + 11, "KillCooldown", new(0f, 180f, 2.5f), 20f, TabGroup.OtherRoles, false).SetParent(CustomRoleSpawnChances[CustomRoles.Doppelganger]) .SetValueFormat(OptionFormat.Seconds); - ResetMode = StringOptionItem.Create(Id + 12, "DGResetMode", ResetModes, 0, TabGroup.NeutralRoles, false).SetParent(CustomRoleSpawnChances[CustomRoles.Doppelganger]); - ResetTimer = FloatOptionItem.Create(Id + 13, "DGResetTimer", new(0f, 60f, 1f), 30f, TabGroup.NeutralRoles, false).SetParent(CustomRoleSpawnChances[CustomRoles.Doppelganger]) + ResetMode = StringOptionItem.Create(Id + 12, "DGResetMode", ResetModes, 0, TabGroup.OtherRoles, false).SetParent(CustomRoleSpawnChances[CustomRoles.Doppelganger]); + ResetTimer = FloatOptionItem.Create(Id + 13, "DGResetTimer", new(0f, 60f, 1f), 30f, TabGroup.OtherRoles, false).SetParent(CustomRoleSpawnChances[CustomRoles.Doppelganger]) .SetValueFormat(OptionFormat.Seconds); } @@ -106,16 +106,15 @@ public class Doppelganger : RoleBase return instance; } - void RpcChangeSkin(PlayerControl pc, GameData.PlayerOutfit newOutfit) + static void RpcChangeSkin(PlayerControl pc, GameData.PlayerOutfit newOutfit) { - if (!IsEnable) return; var sender = CustomRpcSender.Create(name: $"Doppelganger.RpcChangeSkin({pc.Data.PlayerName})"); - //if (pc.PlayerId == PlayerControl.LocalPlayer.PlayerId) Main.nickName = newOutfit.PlayerName; + pc.SetName(newOutfit.PlayerName); sender.AutoStartRpc(pc.NetId, (byte)RpcCalls.SetName) .Write(newOutfit.PlayerName) .EndRpc(); - //pc.RpcSetName(newOutfit.PlayerName); + Main.AllPlayerNames[pc.PlayerId] = newOutfit.PlayerName; pc.SetColor(newOutfit.ColorId); @@ -152,9 +151,9 @@ public class Doppelganger : RoleBase DoppelPresentSkin[pc.PlayerId] = newOutfit; } - public override bool OnCheckMurder(PlayerControl killer, PlayerControl target) + public static bool OnCheckMurderEnd(PlayerControl killer, PlayerControl target) { - if (killer == null || target == null || !IsEnable || Camouflage.IsCamouflage || Camouflager.IsActive) return true; + if (killer == null || target == null || Camouflage.IsCamouflage || Camouflager.IsActive || Main.PlayerStates[killer.PlayerId].Role is not Doppelganger { IsEnable: true } dg) return true; if (target.IsShifted()) { Logger.Info("Target was shapeshifting", "Doppelganger"); @@ -169,7 +168,7 @@ public class Doppelganger : RoleBase TotalSteals[killer.PlayerId]++; - StealTimeStamp = Utils.TimeStamp; + dg.StealTimeStamp = Utils.TimeStamp; string kname; if (killer.PlayerId == PlayerControl.LocalPlayer.PlayerId && Main.nickName.Length != 0) kname = Main.nickName; @@ -184,13 +183,12 @@ public class Doppelganger : RoleBase DoppelVictim[target.PlayerId] = tname; - RpcChangeSkin(target, killerSkin); Logger.Info("Changed target skin", "Doppelganger"); RpcChangeSkin(killer, targetSkin); Logger.Info("Changed killer skin", "Doppelganger"); - SendRPC(killer.PlayerId); + dg.SendRPC(killer.PlayerId); Utils.NotifyRoles(); killer.ResetKillCooldown(); killer.SetKillCooldown(); @@ -208,6 +206,7 @@ public class Doppelganger : RoleBase { RpcChangeSkin(currentTarget, DoppelPresentSkin[currentTarget.PlayerId]); RpcChangeSkin(pc, DoppelDefaultSkin[pc.PlayerId]); + DoppelVictim[pc.PlayerId] = string.Empty; } } } @@ -222,11 +221,10 @@ public class Doppelganger : RoleBase RpcChangeSkin(currentTarget, DoppelPresentSkin[currentTarget.PlayerId]); RpcChangeSkin(pc, DoppelDefaultSkin[pc.PlayerId]); DoppelVictim[pc.PlayerId] = string.Empty; - } - - if (GameStates.IsInTask) - { - Utils.NotifyRoles(); + if (GameStates.IsInTask) + { + Utils.NotifyRoles(); + } } } } diff --git a/Roles/Neutral/Eclipse.cs b/Roles/Neutral/Eclipse.cs index 16999cff0..b59bdaf03 100644 --- a/Roles/Neutral/Eclipse.cs +++ b/Roles/Neutral/Eclipse.cs @@ -1,6 +1,6 @@ -using AmongUs.GameOptions; using System; using System.Collections.Generic; +using AmongUs.GameOptions; using static TOHE.Options; namespace TOHE.Roles.Neutral; diff --git a/Roles/Neutral/Executioner.cs b/Roles/Neutral/Executioner.cs index 3d598f9c0..9d25ce0e5 100644 --- a/Roles/Neutral/Executioner.cs +++ b/Roles/Neutral/Executioner.cs @@ -1,8 +1,8 @@ -using HarmonyLib; -using Hazel; using System; using System.Collections.Generic; using System.Linq; +using HarmonyLib; +using Hazel; using TOHE.Modules; using static TOHE.Options; diff --git a/Roles/Neutral/FFF.cs b/Roles/Neutral/FFF.cs index 94c7de084..8e8979254 100644 --- a/Roles/Neutral/FFF.cs +++ b/Roles/Neutral/FFF.cs @@ -1,6 +1,6 @@ -using AmongUs.GameOptions; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; +using AmongUs.GameOptions; using static TOHE.Options; namespace TOHE.Roles.Neutral diff --git a/Roles/Neutral/Gamer.cs b/Roles/Neutral/Gamer.cs index be95da0fc..a257d4389 100644 --- a/Roles/Neutral/Gamer.cs +++ b/Roles/Neutral/Gamer.cs @@ -1,6 +1,6 @@ -using AmongUs.GameOptions; +using System.Collections.Generic; +using AmongUs.GameOptions; using Hazel; -using System.Collections.Generic; using TOHE.Modules; using UnityEngine; using static TOHE.Options; diff --git a/Roles/Neutral/Glitch.cs b/Roles/Neutral/Glitch.cs index 69021a6ac..d393f5094 100644 --- a/Roles/Neutral/Glitch.cs +++ b/Roles/Neutral/Glitch.cs @@ -1,9 +1,9 @@ -using AmongUs.GameOptions; -using Hazel; using System; using System.Collections.Generic; using System.Linq; using System.Text; +using AmongUs.GameOptions; +using Hazel; using TOHE.Modules; using static TOHE.Options; diff --git a/Roles/Neutral/HeadHunter.cs b/Roles/Neutral/HeadHunter.cs index c109f74bd..83d96cd5b 100644 --- a/Roles/Neutral/HeadHunter.cs +++ b/Roles/Neutral/HeadHunter.cs @@ -1,8 +1,8 @@ -using AmongUs.GameOptions; -using Hazel; using System; using System.Collections.Generic; using System.Linq; +using AmongUs.GameOptions; +using Hazel; using TOHE.Modules; using static TOHE.Options; diff --git a/Roles/Neutral/Jackal.cs b/Roles/Neutral/Jackal.cs index 3531f79f2..7cabce8fa 100644 --- a/Roles/Neutral/Jackal.cs +++ b/Roles/Neutral/Jackal.cs @@ -1,7 +1,7 @@ -using AmongUs.GameOptions; -using HarmonyLib; using System.Collections.Generic; using System.Linq; +using AmongUs.GameOptions; +using HarmonyLib; using static TOHE.Options; using static TOHE.Translator; @@ -53,7 +53,7 @@ public class Jackal : RoleBase CanRecruitSidekick = BooleanOptionItem.Create(Id + 17, "JackalCanRecruitSidekick", false, TabGroup.NeutralRoles, false).SetParent(CustomRoleSpawnChances[CustomRoles.Jackal]); SidekickAssignMode = StringOptionItem.Create(Id + 29, "SidekickAssignMode", SidekickAssignModeStrings, 0, TabGroup.NeutralRoles, false).SetParent(CanRecruitSidekick); SidekickRecruitLimitOpt = IntegerOptionItem.Create(Id + 18, "JackalSidekickRecruitLimit", new(0, 15, 1), 0, TabGroup.NeutralRoles, false).SetParent(CanRecruitSidekick) - .SetValueFormat(OptionFormat.Times); + .SetValueFormat(OptionFormat.Times); KillCooldownSK = FloatOptionItem.Create(Id + 20, "KillCooldown", new(0f, 180f, 2.5f), 20f, TabGroup.NeutralRoles, false).SetParent(CanRecruitSidekick) .SetValueFormat(OptionFormat.Seconds); CanVentSK = BooleanOptionItem.Create(Id + 21, "CanVent", true, TabGroup.NeutralRoles, false).SetParent(CanRecruitSidekick); @@ -135,7 +135,6 @@ public class Jackal : RoleBase return true; } } - if (SidekickAssignMode.GetValue() != 1) { if (!CanBeSidekick(target) && !target.Is(CustomRoles.Sidekick) && !target.Is(CustomRoles.Recruit) && !target.Is(CustomRoles.Loyal)) diff --git a/Roles/Neutral/Lawyer.cs b/Roles/Neutral/Lawyer.cs index 791b65a29..007d0fbb1 100644 --- a/Roles/Neutral/Lawyer.cs +++ b/Roles/Neutral/Lawyer.cs @@ -1,8 +1,8 @@ -using HarmonyLib; -using Hazel; using System; using System.Collections.Generic; using System.Linq; +using HarmonyLib; +using Hazel; using TOHE.Modules; using static TOHE.Options; diff --git a/Roles/Neutral/Magician.cs b/Roles/Neutral/Magician.cs index c75afa0ee..265885774 100644 --- a/Roles/Neutral/Magician.cs +++ b/Roles/Neutral/Magician.cs @@ -1,7 +1,7 @@ -using AmongUs.GameOptions; using System.Collections.Generic; using System.Linq; using System.Text; +using AmongUs.GameOptions; using TOHE.Modules; using TOHE.Roles.Crewmate; using UnityEngine; diff --git a/Roles/Neutral/Mario.cs b/Roles/Neutral/Mario.cs index a5118dfb3..87e3c8d49 100644 --- a/Roles/Neutral/Mario.cs +++ b/Roles/Neutral/Mario.cs @@ -1,6 +1,7 @@ -using AmongUs.GameOptions; -using System.Collections.Generic; +using System.Collections.Generic; +using AmongUs.GameOptions; using UnityEngine; +using static TOHE.Options; namespace TOHE.Roles.Neutral { @@ -9,6 +10,17 @@ namespace TOHE.Roles.Neutral public static bool On; public override bool IsEnable => On; + public static void SetupCustomOption() + { + SetupRoleOptions(18300, TabGroup.OtherRoles, CustomRoles.Mario); + MarioVentNumWin = IntegerOptionItem.Create(18310, "MarioVentNumWin", new(0, 900, 5), 40, TabGroup.OtherRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Mario]) + .SetValueFormat(OptionFormat.Times); + MarioVentCD = FloatOptionItem.Create(18311, "VentCooldown", new(0f, 180f, 1f), 15f, TabGroup.OtherRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Mario]) + .SetValueFormat(OptionFormat.Seconds); + } + public override void Add(byte playerId) { On = true; @@ -22,27 +34,27 @@ namespace TOHE.Roles.Neutral public override void ApplyGameOptions(IGameOptions opt, byte playerId) { - AURoleOptions.EngineerCooldown = Options.MarioVentCD.GetFloat(); + AURoleOptions.EngineerCooldown = MarioVentCD.GetFloat(); AURoleOptions.EngineerInVentMaxTime = 1f; } public override string GetProgressText(byte playerId, bool comms) { - return Utils.ColorString(Color.white, $"- {Main.MarioVentCount.GetValueOrDefault(playerId, 0)}/{Options.MarioVentNumWin.GetInt()}"); + return Utils.ColorString(Color.white, $"- {Main.MarioVentCount.GetValueOrDefault(playerId, 0)}/{MarioVentNumWin.GetInt()}"); } public override void SetButtonTexts(HudManager hud, byte id) { hud.AbilityButton.buttonLabelText.text = Translator.GetString("MarioVentButtonText"); - hud.AbilityButton?.SetUsesRemaining(Options.MarioVentNumWin.GetInt() - (Main.MarioVentCount.GetValueOrDefault(id, 0))); + hud.AbilityButton?.SetUsesRemaining(MarioVentNumWin.GetInt() - Main.MarioVentCount.GetValueOrDefault(id, 0)); } public override void OnFixedUpdate(PlayerControl pc) { var playerId = pc.PlayerId; - if (Main.MarioVentCount[playerId] > Options.MarioVentNumWin.GetInt() && GameStates.IsInTask) + if (Main.MarioVentCount[playerId] > MarioVentNumWin.GetInt() && GameStates.IsInTask) { - Main.MarioVentCount[playerId] = Options.MarioVentNumWin.GetInt(); + Main.MarioVentCount[playerId] = MarioVentNumWin.GetInt(); CustomWinnerHolder.ResetAndSetWinner(CustomWinner.Mario); CustomWinnerHolder.WinnerIds.Add(playerId); } @@ -54,7 +66,7 @@ namespace TOHE.Roles.Neutral Main.MarioVentCount[pc.PlayerId]++; Utils.NotifyRoles(SpecifySeer: pc, SpecifyTarget: pc); - if (AmongUsClient.Instance.AmHost && Main.MarioVentCount[pc.PlayerId] >= Options.MarioVentNumWin.GetInt()) + if (AmongUsClient.Instance.AmHost && Main.MarioVentCount[pc.PlayerId] >= MarioVentNumWin.GetInt()) { CustomWinnerHolder.ResetAndSetWinner(CustomWinner.Mario); //马里奥这个多动症赢了 CustomWinnerHolder.WinnerIds.Add(pc.PlayerId); diff --git a/Roles/Neutral/Mycologist.cs b/Roles/Neutral/Mycologist.cs index c0e4621f1..301dd0a67 100644 --- a/Roles/Neutral/Mycologist.cs +++ b/Roles/Neutral/Mycologist.cs @@ -1,7 +1,7 @@ -using AmongUs.GameOptions; -using Hazel; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; +using AmongUs.GameOptions; +using Hazel; using TOHE.Modules; using static TOHE.Options; using static TOHE.Translator; diff --git a/Roles/Neutral/NSerialKiller.cs b/Roles/Neutral/NSerialKiller.cs index 074440370..97e76fdba 100644 --- a/Roles/Neutral/NSerialKiller.cs +++ b/Roles/Neutral/NSerialKiller.cs @@ -1,5 +1,5 @@ -using AmongUs.GameOptions; using System.Collections.Generic; +using AmongUs.GameOptions; using static TOHE.Options; namespace TOHE.Roles.Neutral; diff --git a/Roles/Neutral/Necromancer.cs b/Roles/Neutral/Necromancer.cs index 8091d5716..168c81115 100644 --- a/Roles/Neutral/Necromancer.cs +++ b/Roles/Neutral/Necromancer.cs @@ -1,5 +1,5 @@ -using AmongUs.GameOptions; -using System.Collections.Generic; +using System.Collections.Generic; +using AmongUs.GameOptions; using static TOHE.Options; using static TOHE.Translator; @@ -193,4 +193,4 @@ namespace TOHE.Roles.Neutral return false; } } -} \ No newline at end of file +} diff --git a/Roles/Neutral/Pelican.cs b/Roles/Neutral/Pelican.cs index 1cabd7bf5..ea625a7ea 100644 --- a/Roles/Neutral/Pelican.cs +++ b/Roles/Neutral/Pelican.cs @@ -1,7 +1,7 @@ -using AmongUs.GameOptions; -using Hazel; -using System; +using System; using System.Collections.Generic; +using AmongUs.GameOptions; +using Hazel; using TOHE.Modules; using TOHE.Roles.Crewmate; using UnityEngine; @@ -16,7 +16,6 @@ public class Pelican : RoleBase private static readonly Dictionary OriginalSpeed = []; public static OptionItem KillCooldown; public static OptionItem CanVent; - public static void SetupCustomOption() { Options.SetupRoleOptions(Id, TabGroup.NeutralRoles, CustomRoles.Pelican); @@ -49,13 +48,12 @@ public class Pelican : RoleBase Main.AllPlayerKillCooldown[id] = KillCooldown.GetFloat(); } - private static void SyncEatenList( /*byte playerId*/) + private static void SyncEatenList(/*byte playerId*/) { SendRPC(byte.MaxValue); foreach (var el in eatenList) SendRPC(el.Key); } - private static void SendRPC(byte playerId) { if (!Utils.DoRPC) return; @@ -69,10 +67,8 @@ public class Pelican : RoleBase writer.Write(el); } } - AmongUsClient.Instance.FinishRpcImmediately(writer); } - public static void ReceiveRPC(MessageReader reader) { byte playerId = reader.ReadByte(); @@ -90,9 +86,7 @@ public class Pelican : RoleBase eatenList.Add(playerId, list); } } - public static bool IsEaten(PlayerControl pc, byte id) => eatenList.ContainsKey(pc.PlayerId) && eatenList[pc.PlayerId].Contains(id); - public static bool IsEaten(byte id) { foreach (var el in eatenList) @@ -100,14 +94,12 @@ public class Pelican : RoleBase return true; return false; } - public static bool CanEat(PlayerControl pc, byte id) { if (!pc.Is(CustomRoles.Pelican) || GameStates.IsMeeting) return false; var target = Utils.GetPlayerById(id); return target != null && target.IsAlive() && !target.inVent && !Medic.ProtectList.Contains(target.PlayerId) && !target.Is(CustomRoles.GM) && !IsEaten(pc, id) && !IsEaten(id); } - public static Vector2 GetBlackRoomPS() { return Main.NormalOptions.MapId switch @@ -131,14 +123,13 @@ public class Pelican : RoleBase eatenNum = value.Count; return Utils.ColorString(eatenNum < 1 ? Color.gray : Utils.GetRoleColor(CustomRoles.Pelican), $"({eatenNum})"); } - public static void EatPlayer(PlayerControl pc, PlayerControl target) { if (pc == null || target == null || !CanEat(pc, target.PlayerId)) return; if (!eatenList.ContainsKey(pc.PlayerId)) eatenList.Add(pc.PlayerId, []); eatenList[pc.PlayerId].Add(target.PlayerId); - SyncEatenList( /*pc.PlayerId*/); + SyncEatenList(/*pc.PlayerId*/); OriginalSpeed.Remove(target.PlayerId); OriginalSpeed.Add(target.PlayerId, Main.AllPlayerSpeed[target.PlayerId]); @@ -172,9 +163,8 @@ public class Pelican : RoleBase Logger.Info($"{killer.GetRealName()} 消化了 {target.GetRealName()}", "Pelican"); } } - eatenList.Clear(); - SyncEatenList( /*byte.MaxValue*/); + SyncEatenList(/*byte.MaxValue*/); } public static void OnPelicanDied(byte pc) @@ -194,9 +184,8 @@ public class Pelican : RoleBase Utils.NotifyRoles(SpecifySeer: target, SpecifyTarget: player); Logger.Info($"{Utils.GetPlayerById(pc).GetRealName()} 吐出了 {target.GetRealName()}", "Pelican"); } - eatenList.Remove(pc); - SyncEatenList( /*pc*/); + SyncEatenList(/*pc*/); } private int Count; @@ -208,9 +197,8 @@ public class Pelican : RoleBase if (eatenList.Count > 0) { eatenList.Clear(); - SyncEatenList( /*byte.MaxValue*/); + SyncEatenList(/*byte.MaxValue*/); } - return; } diff --git a/Roles/Neutral/Phantom.cs b/Roles/Neutral/Phantom.cs deleted file mode 100644 index 863e00765..000000000 --- a/Roles/Neutral/Phantom.cs +++ /dev/null @@ -1,19 +0,0 @@ -using static TOHE.Options; - -namespace TOHE.Roles.Neutral -{ - internal static class Phantom - { - public static void SetupCustomOption() - { - SetupRoleOptions(11400, TabGroup.NeutralRoles, CustomRoles.Phantom); - PhantomCanVent = BooleanOptionItem.Create(11410, "CanVent", false, TabGroup.NeutralRoles, false) - .SetParent(CustomRoleSpawnChances[CustomRoles.Phantom]); - PhantomSnatchesWin = BooleanOptionItem.Create(11411, "SnatchesWin", false, TabGroup.NeutralRoles, false) - .SetParent(CustomRoleSpawnChances[CustomRoles.Phantom]); - PhantomCanGuess = BooleanOptionItem.Create(11412, "CanGuess", false, TabGroup.NeutralRoles, false) - .SetParent(CustomRoleSpawnChances[CustomRoles.Phantom]); - PhantomTasks = OverrideTasksData.Create(11413, TabGroup.NeutralRoles, CustomRoles.Phantom); - } - } -} diff --git a/Roles/Neutral/Pickpocket.cs b/Roles/Neutral/Pickpocket.cs index e357d5bfc..afad06f48 100644 --- a/Roles/Neutral/Pickpocket.cs +++ b/Roles/Neutral/Pickpocket.cs @@ -1,5 +1,5 @@ -using AmongUs.GameOptions; using System.Collections.Generic; +using AmongUs.GameOptions; using static TOHE.Options; namespace TOHE.Roles.Neutral; diff --git a/Roles/Neutral/PlagueBearer.cs b/Roles/Neutral/PlagueBearer.cs index 976c1b927..478584461 100644 --- a/Roles/Neutral/PlagueBearer.cs +++ b/Roles/Neutral/PlagueBearer.cs @@ -1,6 +1,6 @@ -using AmongUs.GameOptions; +using System.Collections.Generic; +using AmongUs.GameOptions; using Hazel; -using System.Collections.Generic; using TOHE.Modules; using static TOHE.Options; using static TOHE.Translator; @@ -25,9 +25,9 @@ public class PlagueBearer : RoleBase { SetupRoleOptions(Id, TabGroup.NeutralRoles, CustomRoles.PlagueBearer); PlagueBearerCDOpt = FloatOptionItem.Create(Id + 10, "PlagueBearerCD", new(0f, 180f, 2.5f), 17.5f, TabGroup.NeutralRoles, false).SetParent(CustomRoleSpawnChances[CustomRoles.PlagueBearer]) - .SetValueFormat(OptionFormat.Seconds); + .SetValueFormat(OptionFormat.Seconds); PestilenceCDOpt = FloatOptionItem.Create(Id + 11, "PestilenceCD", new(0f, 180f, 2.5f), 22.5f, TabGroup.NeutralRoles, false).SetParent(CustomRoleSpawnChances[CustomRoles.PlagueBearer]) - .SetValueFormat(OptionFormat.Seconds); + .SetValueFormat(OptionFormat.Seconds); PestilenceCanVent = BooleanOptionItem.Create(Id + 12, "PestilenceCanVent", true, TabGroup.NeutralRoles, false) .SetParent(CustomRoleSpawnChances[CustomRoles.PlagueBearer]); PestilenceHasImpostorVision = BooleanOptionItem.Create(Id + 13, "PestilenceHasImpostorVision", true, TabGroup.NeutralRoles, false) @@ -59,7 +59,6 @@ public class PlagueBearer : RoleBase public override bool CanUseImpostorVentButton(PlayerControl pc) => false; public static bool IsPlagued(byte pc, byte target) => PlaguedList.TryGetValue(pc, out var x) && x.Contains(target); - public static void SendRPC(PlayerControl player, PlayerControl target) { if (!Utils.DoRPC) return; @@ -68,7 +67,6 @@ public class PlagueBearer : RoleBase writer.Write(target.PlayerId); AmongUsClient.Instance.FinishRpcImmediately(writer); } - public static void ReceiveRPC(MessageReader reader) { byte PlagueBearerId = reader.ReadByte(); @@ -87,7 +85,6 @@ public class PlagueBearer : RoleBase if (IsPlagued(playerId, pc.PlayerId)) plagued++; } - return (plagued, all); } @@ -105,7 +102,6 @@ public class PlagueBearer : RoleBase killer.Notify(GetString("PlagueBearerAlreadyPlagued")); return false; } - PlaguedList[killer.PlayerId].Add(target.PlayerId); Utils.NotifyRoles(SpecifySeer: killer, SpecifyTarget: target); killer.ResetKillCooldown(); diff --git a/Roles/Neutral/PlagueDoctor.cs b/Roles/Neutral/PlagueDoctor.cs index 039a34fb7..64f8ce004 100644 --- a/Roles/Neutral/PlagueDoctor.cs +++ b/Roles/Neutral/PlagueDoctor.cs @@ -1,9 +1,9 @@ -using AmongUs.GameOptions; -using Hazel; -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; +using AmongUs.GameOptions; +using Hazel; using TOHE.Modules; using UnityEngine; @@ -311,4 +311,4 @@ namespace TOHE.Roles.Neutral } } } -} \ No newline at end of file +} diff --git a/Roles/Neutral/Postman.cs b/Roles/Neutral/Postman.cs index a7b3d15d0..ed548971f 100644 --- a/Roles/Neutral/Postman.cs +++ b/Roles/Neutral/Postman.cs @@ -1,6 +1,6 @@ -using AmongUs.GameOptions; -using System.Collections.Generic; +using System.Collections.Generic; using System.Text; +using AmongUs.GameOptions; using static TOHE.Options; using static TOHE.Translator; diff --git a/Roles/Neutral/Pyromaniac.cs b/Roles/Neutral/Pyromaniac.cs index 510025b22..91afe30e0 100644 --- a/Roles/Neutral/Pyromaniac.cs +++ b/Roles/Neutral/Pyromaniac.cs @@ -1,5 +1,5 @@ -using AmongUs.GameOptions; using System.Collections.Generic; +using AmongUs.GameOptions; using static TOHE.Options; namespace TOHE.Roles.Neutral; diff --git a/Roles/Neutral/Revolutionist.cs b/Roles/Neutral/Revolutionist.cs index 62b91d7e6..59c79edc0 100644 --- a/Roles/Neutral/Revolutionist.cs +++ b/Roles/Neutral/Revolutionist.cs @@ -1,7 +1,8 @@ -using AmongUs.GameOptions; -using System.Linq; +using System.Linq; +using AmongUs.GameOptions; using TOHE.Modules; using UnityEngine; +using static TOHE.Options; namespace TOHE.Roles.Neutral { @@ -10,6 +11,26 @@ namespace TOHE.Roles.Neutral public static bool On; public override bool IsEnable => On; + public static void SetupCustomOption() + { + SetupRoleOptions(18400, TabGroup.NeutralRoles, CustomRoles.Revolutionist); + RevolutionistDrawTime = FloatOptionItem.Create(18410, "RevolutionistDrawTime", new(0f, 90f, 1f), 3f, TabGroup.NeutralRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Revolutionist]) + .SetValueFormat(OptionFormat.Seconds); + RevolutionistCooldown = FloatOptionItem.Create(18411, "RevolutionistCooldown", new(0f, 100f, 1f), 10f, TabGroup.NeutralRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Revolutionist]) + .SetValueFormat(OptionFormat.Seconds); + RevolutionistDrawCount = IntegerOptionItem.Create(18412, "RevolutionistDrawCount", new(0, 14, 1), 6, TabGroup.NeutralRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Revolutionist]) + .SetValueFormat(OptionFormat.Players); + RevolutionistKillProbability = IntegerOptionItem.Create(18413, "RevolutionistKillProbability", new(0, 100, 5), 15, TabGroup.NeutralRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Revolutionist]) + .SetValueFormat(OptionFormat.Percent); + RevolutionistVentCountDown = FloatOptionItem.Create(18414, "RevolutionistVentCountDown", new(0f, 180f, 1f), 15f, TabGroup.NeutralRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Revolutionist]) + .SetValueFormat(OptionFormat.Seconds); + } + public override void Add(byte playerId) { On = true; @@ -41,7 +62,7 @@ namespace TOHE.Roles.Neutral public override void SetKillCooldown(byte id) { - Main.AllPlayerKillCooldown[id] = Options.RevolutionistCooldown.GetFloat(); + Main.AllPlayerKillCooldown[id] = RevolutionistCooldown.GetFloat(); } public override void ApplyGameOptions(IGameOptions opt, byte playerId) @@ -67,7 +88,7 @@ namespace TOHE.Roles.Neutral public override bool OnCheckMurder(PlayerControl killer, PlayerControl target) { - killer.SetKillCooldown(Options.RevolutionistDrawTime.GetFloat()); + killer.SetKillCooldown(RevolutionistDrawTime.GetFloat()); if (!Main.isDraw[(killer.PlayerId, target.PlayerId)] && !Main.RevolutionistTimer.ContainsKey(killer.PlayerId)) { Main.RevolutionistTimer.TryAdd(killer.PlayerId, (target, 0f)); @@ -116,7 +137,7 @@ namespace TOHE.Roles.Neutral { Main.RevolutionistTimer.Remove(playerId); } - else if (rv_time >= Options.RevolutionistDrawTime.GetFloat()) + else if (rv_time >= RevolutionistDrawTime.GetFloat()) { player.SetKillCooldown(); Main.RevolutionistTimer.Remove(playerId); @@ -124,7 +145,7 @@ namespace TOHE.Roles.Neutral player.RpcSetDrawPlayer(rv_target, true); Utils.NotifyRoles(SpecifySeer: player, SpecifyTarget: rv_target, ForceLoop: true); RPC.ResetCurrentDrawTarget(playerId); - if (IRandom.Instance.Next(1, 100) <= Options.RevolutionistKillProbability.GetInt()) + if (IRandom.Instance.Next(1, 100) <= RevolutionistKillProbability.GetInt()) { rv_target.SetRealKiller(player); Main.PlayerStates[rv_target.PlayerId].deathReason = PlayerState.DeathReason.Sacrifice; @@ -162,7 +183,7 @@ namespace TOHE.Roles.Neutral long nowtime = Utils.TimeStamp; Main.RevolutionistLastTime[playerId] = nowtime; int time = (int)(Main.RevolutionistLastTime[playerId] - Main.RevolutionistStart[playerId]); - int countdown = Options.RevolutionistVentCountDown.GetInt() - time; + int countdown = RevolutionistVentCountDown.GetInt() - time; Main.RevolutionistCountdown.Clear(); if (countdown <= 0) { diff --git a/Roles/Neutral/Romantic.cs b/Roles/Neutral/Romantic.cs index 7a228aef9..69c0fe4ea 100644 --- a/Roles/Neutral/Romantic.cs +++ b/Roles/Neutral/Romantic.cs @@ -1,6 +1,6 @@ -using Hazel; using System; using System.Collections.Generic; +using Hazel; using TOHE.Modules; using UnityEngine; using static TOHE.Options; diff --git a/Roles/Neutral/Sidekick.cs b/Roles/Neutral/Sidekick.cs index 2ee354cde..d39aecadf 100644 --- a/Roles/Neutral/Sidekick.cs +++ b/Roles/Neutral/Sidekick.cs @@ -1,5 +1,5 @@ -using AmongUs.GameOptions; using System.Collections.Generic; +using AmongUs.GameOptions; namespace TOHE.Roles.Neutral; diff --git a/Roles/Neutral/SoulHunter.cs b/Roles/Neutral/SoulHunter.cs index 9c7e1e1f5..c0aab914f 100644 --- a/Roles/Neutral/SoulHunter.cs +++ b/Roles/Neutral/SoulHunter.cs @@ -1,7 +1,7 @@ -using AmongUs.GameOptions; -using Hazel; -using System; +using System; using System.Linq; +using AmongUs.GameOptions; +using Hazel; using TOHE.Modules; using static TOHE.Options; using static TOHE.Translator; diff --git a/Roles/Neutral/Spiritcaller.cs b/Roles/Neutral/Spiritcaller.cs index 2723b2faf..fa254b88f 100644 --- a/Roles/Neutral/Spiritcaller.cs +++ b/Roles/Neutral/Spiritcaller.cs @@ -1,5 +1,5 @@ -using AmongUs.GameOptions; -using System.Collections.Generic; +using System.Collections.Generic; +using AmongUs.GameOptions; using TOHE.Modules; using static TOHE.Options; using static TOHE.Translator; diff --git a/Roles/Neutral/Sprayer.cs b/Roles/Neutral/Sprayer.cs index 304df5c29..662ea14be 100644 --- a/Roles/Neutral/Sprayer.cs +++ b/Roles/Neutral/Sprayer.cs @@ -1,6 +1,6 @@ -using AmongUs.GameOptions; -using System; +using System; using System.Collections.Generic; +using AmongUs.GameOptions; using UnityEngine; using static TOHE.Options; using static TOHE.Translator; diff --git a/Roles/Neutral/Succubus.cs b/Roles/Neutral/Succubus.cs index 54508ded1..b4a3004a3 100644 --- a/Roles/Neutral/Succubus.cs +++ b/Roles/Neutral/Succubus.cs @@ -1,6 +1,6 @@ -using AmongUs.GameOptions; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; +using AmongUs.GameOptions; using UnityEngine; using static TOHE.Options; using static TOHE.Translator; diff --git a/Roles/Neutral/Terrorist.cs b/Roles/Neutral/Terrorist.cs deleted file mode 100644 index 7041483db..000000000 --- a/Roles/Neutral/Terrorist.cs +++ /dev/null @@ -1,17 +0,0 @@ -using static TOHE.Options; - -namespace TOHE.Roles.Neutral -{ - internal static class Terrorist - { - public static void SetupCustomOption() - { - SetupRoleOptions(11500, TabGroup.NeutralRoles, CustomRoles.Terrorist); - CanTerroristSuicideWin = BooleanOptionItem.Create(11510, "CanTerroristSuicideWin", false, TabGroup.NeutralRoles, false) - .SetParent(CustomRoleSpawnChances[CustomRoles.Terrorist]); - TerroristCanGuess = BooleanOptionItem.Create(11511, "CanGuess", true, TabGroup.NeutralRoles, false) - .SetParent(CustomRoleSpawnChances[CustomRoles.Terrorist]); - TerroristTasks = OverrideTasksData.Create(11512, TabGroup.NeutralRoles, CustomRoles.Terrorist); - } - } -} diff --git a/Roles/Neutral/Totocalcio.cs b/Roles/Neutral/Totocalcio.cs index bb5ecb71e..4988605d5 100644 --- a/Roles/Neutral/Totocalcio.cs +++ b/Roles/Neutral/Totocalcio.cs @@ -1,7 +1,7 @@ -using Hazel; -using Il2CppSystem; using System.Collections.Generic; using System.Linq; +using Hazel; +using Il2CppSystem; using TOHE.Modules; using UnityEngine; using static TOHE.Options; @@ -68,7 +68,6 @@ public class Totocalcio : RoleBase writer.Write(BetPlayer); AmongUsClient.Instance.FinishRpcImmediately(writer); } - public static void ReceiveRPC(MessageReader reader) { byte PlayerId = reader.ReadByte(); @@ -90,13 +89,11 @@ public class Totocalcio : RoleBase Main.AllPlayerKillCooldown[id] = 300f; return; } - float cd = BetCooldown.GetFloat(); cd += Main.AllPlayerControls.Count(x => !x.IsAlive()) * BetCooldownIncrese.GetFloat(); cd = Math.Min(cd, MaxBetCooldown.GetFloat()); Main.AllPlayerKillCooldown[id] = cd; } - public static bool KnowRole(PlayerControl player, PlayerControl target) { if (!KnowTargetRole.GetBool()) return false; @@ -131,7 +128,6 @@ public class Totocalcio : RoleBase Logger.Info($"Target selected:{killer.GetNameWithRole().RemoveHtmlTags()} => {target.GetNameWithRole().RemoveHtmlTags()}", "Totocalcio"); return false; } - public static string TargetMark(PlayerControl seer, PlayerControl target) { if (!seer.Is(CustomRoles.Totocalcio)) diff --git a/Roles/Neutral/Traitor.cs b/Roles/Neutral/Traitor.cs index 8d60360ed..c53a629a5 100644 --- a/Roles/Neutral/Traitor.cs +++ b/Roles/Neutral/Traitor.cs @@ -1,5 +1,5 @@ -using AmongUs.GameOptions; using System.Collections.Generic; +using AmongUs.GameOptions; using static TOHE.Options; namespace TOHE.Roles.Neutral; diff --git a/Roles/Neutral/Vengeance.cs b/Roles/Neutral/Vengeance.cs index 8600e22fe..7e7573cdc 100644 --- a/Roles/Neutral/Vengeance.cs +++ b/Roles/Neutral/Vengeance.cs @@ -1,5 +1,5 @@ -using AmongUs.GameOptions; using System.Collections.Generic; +using AmongUs.GameOptions; using static TOHE.Options; using static TOHE.Translator; diff --git a/Roles/Neutral/Virus.cs b/Roles/Neutral/Virus.cs index 99af7dc59..a06e4a922 100644 --- a/Roles/Neutral/Virus.cs +++ b/Roles/Neutral/Virus.cs @@ -1,7 +1,7 @@ -using AmongUs.GameOptions; -using Hazel; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; +using AmongUs.GameOptions; +using Hazel; using TOHE.Modules; using TOHE.Patches; using static TOHE.Options; diff --git a/Roles/Neutral/Vulture.cs b/Roles/Neutral/Vulture.cs index a97a847cd..0966cdc18 100644 --- a/Roles/Neutral/Vulture.cs +++ b/Roles/Neutral/Vulture.cs @@ -1,6 +1,6 @@ +using System.Collections.Generic; using AmongUs.GameOptions; using Hazel; -using System.Collections.Generic; using TOHE.Modules; using UnityEngine; using static TOHE.Options; diff --git a/Roles/Neutral/WeaponMaster.cs b/Roles/Neutral/WeaponMaster.cs index bb9bc1e2b..f95aece99 100644 --- a/Roles/Neutral/WeaponMaster.cs +++ b/Roles/Neutral/WeaponMaster.cs @@ -1,6 +1,6 @@ +using System.Collections.Generic; using AmongUs.GameOptions; using Hazel; -using System.Collections.Generic; using TOHE.Modules; using UnityEngine; using static TOHE.Options; @@ -75,7 +75,6 @@ public class WeaponMaster : RoleBase writer.Write(shieldUsed); AmongUsClient.Instance.FinishRpcImmediately(writer); } - public static void ReceiveRPC(MessageReader reader) { var id = reader.ReadByte(); @@ -157,7 +156,6 @@ public class WeaponMaster : RoleBase player.Suicide(PlayerState.DeathReason.Kill, killer); } } - killer.SetKillCooldown(time: HighKCD.GetFloat()); }, 0.1f, "Weapon Master Axe Kill"); return true; @@ -167,7 +165,6 @@ public class WeaponMaster : RoleBase target.Suicide(PlayerState.DeathReason.Kill, killer); killer.SetKillCooldown(); } - return false; case 3: return false; @@ -206,7 +203,6 @@ public class WeaponMaster : RoleBase { return Main.PlayerStates[id].Role is not WeaponMaster { IsEnable: true } wm ? string.Empty : string.Format(GetString("WMMode"), ModeToText(wm.Mode)); } - public static string ModeToText(byte mode) { return mode switch @@ -218,4 +214,4 @@ public class WeaponMaster : RoleBase _ => string.Empty, }; } -} \ No newline at end of file +} diff --git a/Roles/Neutral/Werewolf.cs b/Roles/Neutral/Werewolf.cs index 5e1c2860c..9e90841a7 100644 --- a/Roles/Neutral/Werewolf.cs +++ b/Roles/Neutral/Werewolf.cs @@ -1,7 +1,7 @@ -using AmongUs.GameOptions; -using Hazel; using System.Collections.Generic; using System.Text; +using AmongUs.GameOptions; +using Hazel; using TOHE.Modules; using TOHE.Roles.Crewmate; using static TOHE.Options; @@ -152,7 +152,6 @@ public class Werewolf : RoleBase } }, 0.5f, "Werewolf Vent"); } - public static string GetHudText(PlayerControl pc) { if (pc == null || !GameStates.IsInTask || !PlayerControl.LocalPlayer.IsAlive() || Main.PlayerStates[pc.PlayerId].Role is not Werewolf { IsEnable: true } ww) return string.Empty; @@ -171,7 +170,6 @@ public class Werewolf : RoleBase { str.Append(GetString("WWCanRampage")); } - return str.ToString(); } @@ -179,4 +177,4 @@ public class Werewolf : RoleBase { return !Medic.ProtectList.Contains(target.PlayerId) && IsRampaging; } -} \ No newline at end of file +} diff --git a/Roles/Neutral/Workaholic.cs b/Roles/Neutral/Workaholic.cs index 6a16e4689..f9cbb32c1 100644 --- a/Roles/Neutral/Workaholic.cs +++ b/Roles/Neutral/Workaholic.cs @@ -1,6 +1,7 @@ -using AmongUs.GameOptions; -using System.Linq; +using System.Linq; +using AmongUs.GameOptions; using TOHE.Modules; +using static TOHE.Options; namespace TOHE.Roles.Neutral { @@ -9,6 +10,23 @@ namespace TOHE.Roles.Neutral public static bool On; public override bool IsEnable => On; + public static void SetupCustomOption() + { + SetupRoleOptions(11700, TabGroup.NeutralRoles, CustomRoles.Workaholic); //TOH_Y + WorkaholicCannotWinAtDeath = BooleanOptionItem.Create(11710, "WorkaholicCannotWinAtDeath", true, TabGroup.NeutralRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Workaholic]); + WorkaholicVentCooldown = FloatOptionItem.Create(11711, "VentCooldown", new(0f, 180f, 2.5f), 30f, TabGroup.NeutralRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Workaholic]) + .SetValueFormat(OptionFormat.Seconds); + WorkaholicVisibleToEveryone = BooleanOptionItem.Create(11712, "WorkaholicVisibleToEveryone", false, TabGroup.NeutralRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Workaholic]); + WorkaholicGiveAdviceAlive = BooleanOptionItem.Create(11713, "WorkaholicGiveAdviceAlive", false, TabGroup.NeutralRoles, false) + .SetParent(WorkaholicVisibleToEveryone); + WorkaholicTasks = OverrideTasksData.Create(11714, TabGroup.NeutralRoles, CustomRoles.Workaholic); + WorkaholicCanGuess = BooleanOptionItem.Create(11725, "CanGuess", true, TabGroup.NeutralRoles, false) + .SetParent(CustomRoleSpawnChances[CustomRoles.Workaholic]); + } + public override void Add(byte playerId) { On = true; @@ -21,14 +39,14 @@ namespace TOHE.Roles.Neutral public override void ApplyGameOptions(IGameOptions opt, byte playerId) { - AURoleOptions.EngineerCooldown = Options.WorkaholicVentCooldown.GetFloat(); + AURoleOptions.EngineerCooldown = WorkaholicVentCooldown.GetFloat(); AURoleOptions.EngineerInVentMaxTime = 0f; } public override void OnTaskComplete(PlayerControl player, int CompletedTasksCount, int AllTasksCount) { var alive = player.IsAlive(); - if ((CompletedTasksCount + 1) >= AllTasksCount && !(Options.WorkaholicCannotWinAtDeath.GetBool() && !alive)) + if ((CompletedTasksCount + 1) >= AllTasksCount && !(WorkaholicCannotWinAtDeath.GetBool() && !alive)) { Logger.Info("Workaholic Tasks Finished", "Workaholic"); RPC.PlaySoundRPC(player.PlayerId, Sounds.KillSound); diff --git a/Roles/RoleBase.cs b/Roles/RoleBase.cs index cbb933f3e..5615eb7ab 100644 --- a/Roles/RoleBase.cs +++ b/Roles/RoleBase.cs @@ -1,10 +1,30 @@ -using AmongUs.GameOptions; +using System; using System.Text; +using AmongUs.GameOptions; namespace TOHE { - public abstract class RoleBase + public abstract class RoleBase : IComparable { + public int CompareTo(RoleBase other) + { + var thisName = GetType().Name; + var translatedName = Translator.GetString(thisName); + if (translatedName != string.Empty && !translatedName.StartsWith("*") && !translatedName.StartsWith("TOHE+ Gurge44 preview - D:\Epic Games\AmongUs + E:\Program Files\AmongUs true True $(MSBuildProjectName)+ diff --git a/main.cs b/main.cs index f8382aba7..53e548ba4 100644 --- a/main.cs +++ b/main.cs @@ -1,3 +1,7 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; using AmongUs.GameOptions; using BepInEx; using BepInEx.Configuration; @@ -5,10 +9,6 @@ using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using HarmonyLib; using Il2CppInterop.Runtime.Injection; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; using TOHE; using TOHE.Roles.Neutral; using UnityEngine; @@ -92,7 +92,6 @@ public class Main : BasePlugin public static Dictionary> SetAddOns = []; public static Dictionary AlwaysSpawnTogetherCombos = []; public static Dictionary NeverSpawnTogetherCombos = []; - public static List AllRoleClasses; public static bool IsFixedCooldown => CustomRoles.Vampire.IsEnable() || CustomRoles.Poisoner.IsEnable(); public static float RefixCooldownDelay; public static bool ProcessShapeshifts = true; @@ -126,6 +125,7 @@ public class Main : BasePlugin //public static Dictionary FlashbangInProtect = new(); public static List CyberStarDead = []; + public static List DemolitionistDead = []; public static List BlockedVents = []; public static List WorkaholicAlive = []; public static List SpeedrunnerAlive = []; @@ -197,38 +197,12 @@ public class Main : BasePlugin public static Dictionary DevRole = []; - public static PlayerControl[] AllPlayerControls - { - get - { - List result = []; - foreach (var pc in PlayerControl.AllPlayerControls) - { - if (pc == null) continue; - result.Add(pc); - } - - return [.. result]; - } - } - - public static PlayerControl[] AllAlivePlayerControls - { - get - { - List result = []; - foreach (var pc in PlayerControl.AllPlayerControls) - { - if (pc == null || !pc.IsAlive() || pc.Data.Disconnected || Pelican.IsEaten(pc.PlayerId)) continue; - result.Add(pc); - } - - return [.. result]; - } - } + public static PlayerControl[] AllPlayerControls => PlayerControl.AllPlayerControls.ToArray().Where(p => p != null).ToArray(); + public static PlayerControl[] AllAlivePlayerControls => PlayerControl.AllPlayerControls.ToArray().Where(p => p != null && p.IsAlive() && !p.Data.Disconnected && !Pelican.IsEaten(p.PlayerId)).ToArray(); public static Main Instance; + //一些很新的东东 public static string OverrideWelcomeMsg = string.Empty; public static int HostClientId; @@ -457,6 +431,7 @@ public class Main : BasePlugin { CustomRoles.Provocateur, "#74ba43" }, { CustomRoles.Sunnyboy, "#ff9902" }, { CustomRoles.Poisoner, "#e70052" }, + //{CustomRoles.NWitch, "#BF5FFF"}, { CustomRoles.Totocalcio, "#ff9409" }, { CustomRoles.Romantic, "#FF1493" }, { CustomRoles.VengefulRomantic, "#8B0000" }, @@ -617,20 +592,6 @@ public class Main : BasePlugin DevManager.Init(); Cloud.Init(); - AllRoleClasses = []; - try - { - AllRoleClasses.AddRange(Assembly.GetAssembly(typeof(RoleBase))! - .GetTypes() - .Where(myType => myType.IsClass && !myType.IsAbstract && myType.IsSubclassOf(typeof(RoleBase))) - .Select(type => (RoleBase)Activator.CreateInstance(type, null))); - AllRoleClasses.Sort(); - } - catch (Exception e) - { - Utils.ThrowException(e); - } - IRandom.SetInstance(new NetRandomWrapper()); TOHE.Logger.Info($"{Application.version}", "AmongUs Version"); @@ -650,7 +611,7 @@ public class Main : BasePlugin if (!DebugModeManager.AmDebugger) ConsoleManager.DetachConsole(); else ConsoleManager.CreateConsole(); - TOHE.Logger.Msg("========= TOHE+ loaded! =========", "Plugin Load"); + TOHE.Logger.Msg("========= TOHE loaded! =========", "Plugin Load"); } }