diff --git a/UsefulHints/Config.cs b/UsefulHints/Config.cs index 80ef429..8bda09c 100644 --- a/UsefulHints/Config.cs +++ b/UsefulHints/Config.cs @@ -9,7 +9,7 @@ public class Config : IConfig { public bool IsEnabled { get; set; } = true; public bool Debug { get; set; } = false; - [Description("Hints Settings:")] + [Description("Hint Settings:")] public bool EnableHints { get; set; } = true; public string Scp096LookMessage { get; set; } = "You looked at SCP-096!"; public float Scp268Duration { get; set; } = 15f; @@ -17,10 +17,11 @@ public class Config : IConfig public string Scp2176TimeLeftMessage { get; set; } = "Remaining: {0}s"; public string Scp1576TimeLeftMessage { get; set; } = "Remaining: {0}s"; public string JailbirdUseMessage { get; set; } = "Remaining charges: {0}"; - public string MicroEnergyMessage { get; set; } = "Remaining energy: {0}%"; - public string MicroLowEnergyMessage { get; set; } = "Low Energy"; + public string MicroHidEnergyMessage { get; set; } = "Remaining energy: {0}%"; + public string MicroHidLowEnergyMessage { get; set; } = "Low Energy"; public string Scp207HintMessage { get; set; } = "You have {0} doses of SCP-207"; public string AntiScp207HintMessage { get; set; } = "You have {0} doses of Anti SCP-207"; + public bool ShowHintOnEquipItem { get; set; } = false; [Description("Item Warnings:")] public bool EnableWarnings { get; set; } = true; public string Scp207Warning { get; set; } = "\u26A0 You are already affected by SCP-207"; @@ -31,6 +32,9 @@ public class Config : IConfig public string FriendlyFireWarning { get; set; } = "\u26A0 Do not hurt your teammate"; public string DamageTakenWarning { get; set; } = "{0} (teammate) hit you"; public bool ClassDAreTeammates { get; set; } = true; + public bool EnableCuffedWarning { get; set; } = false; + public string CuffedAttackerWarning { get; set; } = "\u26A0 Player is cuffed"; + public string CuffedPlayerWarning { get; set; } = "{0} hit you when you were cuffed"; [Description("Kill Counter:")] public bool EnableKillCounter { get; set; } = true; public string KillCountMessage { get; set; } = "{0} kills"; diff --git a/UsefulHints/EventHandlers/Items/Hints.cs b/UsefulHints/EventHandlers/Items/Hints.cs index bf83770..e852fd3 100644 --- a/UsefulHints/EventHandlers/Items/Hints.cs +++ b/UsefulHints/EventHandlers/Items/Hints.cs @@ -3,11 +3,13 @@ using System.Collections.Generic; using Exiled.API.Enums; using Exiled.API.Extensions; -using Exiled.API.Features.Pickups; +using JailbirdPickup = Exiled.API.Features.Pickups.JailbirdPickup; using Player = Exiled.API.Features.Player; using Exiled.Events.EventArgs.Map; using Exiled.Events.EventArgs.Player; using InventorySystem.Items.ThrowableProjectiles; +using InventorySystem.Items.Jailbird; +using InventorySystem.Items.MicroHID; using MEC; namespace UsefulHints.EventHandlers.Items @@ -19,7 +21,9 @@ public static class Hints public static void RegisterEvents() { Exiled.Events.Handlers.Player.PickingUpItem += OnPickingUpMicroHid; + Exiled.Events.Handlers.Player.ChangingItem += OnEquipMicroHid; Exiled.Events.Handlers.Player.PickingUpItem += OnPickingUpSCP207; + Exiled.Events.Handlers.Player.ChangingItem += OnEquipSCP207; Exiled.Events.Handlers.Player.UsedItem += OnSCP1576Used; Exiled.Events.Handlers.Player.ChangedItem += OnSCP1576ChangedItem; Exiled.Events.Handlers.Player.UsedItem += OnSCP268Used; @@ -28,11 +32,14 @@ public static void RegisterEvents() Exiled.Events.Handlers.Map.ExplodingGrenade += OnSCP2176Grenade; Exiled.Events.Handlers.Server.WaitingForPlayers += OnWaitingForPlayers; Exiled.Events.Handlers.Player.PickingUpItem += OnPickingUpJailbird; + Exiled.Events.Handlers.Player.ChangingItem += OnEquipJailbird; } public static void UnregisterEvents() { Exiled.Events.Handlers.Player.PickingUpItem -= OnPickingUpMicroHid; + Exiled.Events.Handlers.Player.ChangingItem -= OnEquipMicroHid; Exiled.Events.Handlers.Player.PickingUpItem -= OnPickingUpSCP207; + Exiled.Events.Handlers.Player.ChangingItem -= OnEquipSCP207; Exiled.Events.Handlers.Player.UsedItem -= OnSCP1576Used; Exiled.Events.Handlers.Player.ChangedItem -= OnSCP1576ChangedItem; Exiled.Events.Handlers.Player.UsedItem -= OnSCP268Used; @@ -41,25 +48,47 @@ public static void UnregisterEvents() Exiled.Events.Handlers.Map.ExplodingGrenade -= OnSCP2176Grenade; Exiled.Events.Handlers.Server.WaitingForPlayers -= OnWaitingForPlayers; Exiled.Events.Handlers.Player.PickingUpItem -= OnPickingUpJailbird; + Exiled.Events.Handlers.Player.ChangingItem -= OnEquipJailbird; } + // MicroHid Handler private static void OnPickingUpMicroHid(PickingUpItemEventArgs ev) { - if (ev.Pickup.Type == ItemType.MicroHID) + if (ev.Pickup.Base is MicroHIDPickup microHidPickup) { - var microHidPickup = ev.Pickup.Base as InventorySystem.Items.MicroHID.MicroHIDPickup; + float energyPercentage = microHidPickup.Energy * 100; + float roundedEnergyPercentage = (float)Math.Round(energyPercentage, 1); - if (microHidPickup != null) + if (roundedEnergyPercentage < 5) { - float energyPercentage = microHidPickup.Energy * 100; + ev.Player.ShowHint($"{new string('\n', 10)}{string.Format(UsefulHints.Instance.Config.MicroHidLowEnergyMessage)}", 4); + } + else + { + ev.Player.ShowHint($"{new string('\n', 10)}{string.Format(UsefulHints.Instance.Config.MicroHidEnergyMessage, roundedEnergyPercentage)}", 4); + } + } + } + public static void OnEquipMicroHid(ChangingItemEventArgs ev) + { + if (UsefulHints.Instance.Config.ShowHintOnEquipItem) + { + if (ev.Item == null) + { + return; + } + if (ev.Item.Base is MicroHIDItem microHidItem) + { + + float energyPercentage = microHidItem.RemainingEnergy * 100; float roundedEnergyPercentage = (float)Math.Round(energyPercentage, 1); if (roundedEnergyPercentage < 5) { - ev.Player.ShowHint($"{string.Format(UsefulHints.Instance.Config.MicroLowEnergyMessage)}", 4); + ev.Player.ShowHint($"{new string('\n', 10)}{string.Format(UsefulHints.Instance.Config.MicroHidLowEnergyMessage)}", 2); } else { - ev.Player.ShowHint($"{string.Format(UsefulHints.Instance.Config.MicroEnergyMessage, roundedEnergyPercentage)}", 4); + ev.Player.ShowHint($"{new string('\n', 10)}{string.Format(UsefulHints.Instance.Config.MicroHidEnergyMessage, roundedEnergyPercentage)}", 2); } } } @@ -73,7 +102,7 @@ private static void OnPickingUpSCP207(PickingUpItemEventArgs ev) if (scp207Effect != null) { - ev.Player.ShowHint($"{string.Format(UsefulHints.Instance.Config.Scp207HintMessage, scp207Effect.Intensity)}", 4); + ev.Player.ShowHint($"{new string('\n', 10)}{string.Format(UsefulHints.Instance.Config.Scp207HintMessage, scp207Effect.Intensity)}", 4); } } if (ev.Pickup.Type == ItemType.AntiSCP207) @@ -82,7 +111,35 @@ private static void OnPickingUpSCP207(PickingUpItemEventArgs ev) if (antiscp207Effect != null) { - ev.Player.ShowHint($"{string.Format(UsefulHints.Instance.Config.AntiScp207HintMessage, antiscp207Effect.Intensity)}", 4); + ev.Player.ShowHint($"{new string('\n', 10)}{string.Format(UsefulHints.Instance.Config.AntiScp207HintMessage, antiscp207Effect.Intensity)}", 4); + } + } + } + private static void OnEquipSCP207(ChangingItemEventArgs ev) + { + if (UsefulHints.Instance.Config.ShowHintOnEquipItem) + { + if (ev.Item == null) + { + return; + } + if (ev.Item.Type == ItemType.SCP207) + { + CustomPlayerEffects.StatusEffectBase scp207Effect = ev.Player.ActiveEffects.FirstOrDefault(effect => effect.GetEffectType() == EffectType.Scp207); + + if (scp207Effect != null) + { + ev.Player.ShowHint($"{new string('\n', 10)}{string.Format(UsefulHints.Instance.Config.Scp207HintMessage, scp207Effect.Intensity)}", 2); + } + } + if (ev.Item.Type == ItemType.AntiSCP207) + { + CustomPlayerEffects.StatusEffectBase antiscp207Effect = ev.Player.ActiveEffects.FirstOrDefault(effect => effect.GetEffectType() == EffectType.AntiScp207); + + if (antiscp207Effect != null) + { + ev.Player.ShowHint($"{new string('\n', 10)}{string.Format(UsefulHints.Instance.Config.AntiScp207HintMessage, antiscp207Effect.Intensity)}", 2); + } } } } @@ -221,11 +278,35 @@ private static void OnPickingUpJailbird(PickingUpItemEventArgs ev) int remainingCharges = maxCharges - jailbirdPickup.TotalCharges; if (remainingCharges > 1) { - ev.Player.ShowHint($"{string.Format(UsefulHints.Instance.Config.JailbirdUseMessage, remainingCharges)}", 4); + ev.Player.ShowHint($"{new string('\n', 10)}{string.Format(UsefulHints.Instance.Config.JailbirdUseMessage, remainingCharges)}", 4); } else { - ev.Player.ShowHint($"{string.Format(UsefulHints.Instance.Config.JailbirdUseMessage, remainingCharges)}", 4); + ev.Player.ShowHint($"{new string('\n', 10)}{string.Format(UsefulHints.Instance.Config.JailbirdUseMessage, remainingCharges)}", 4); + } + } + } + public static void OnEquipJailbird(ChangingItemEventArgs ev) + { + if (UsefulHints.Instance.Config.ShowHintOnEquipItem) + { + if (ev.Item == null) + { + return; + } + if (ev.Item.Base is JailbirdItem jailbirdItem) + { + int maxCharges = 5; + int remainingCharges = maxCharges - jailbirdItem.TotalChargesPerformed; + + if (remainingCharges > 1) + { + ev.Player.ShowHint($"{new string('\n', 10)}{string.Format(UsefulHints.Instance.Config.JailbirdUseMessage, remainingCharges)}", 2); + } + else + { + ev.Player.ShowHint($"{new string('\n', 10)}{string.Format(UsefulHints.Instance.Config.JailbirdUseMessage, remainingCharges)}", 2); + } } } } diff --git a/UsefulHints/EventHandlers/Modules/FFWarning.cs b/UsefulHints/EventHandlers/Modules/FFWarning.cs index df86a4e..d8caf47 100644 --- a/UsefulHints/EventHandlers/Modules/FFWarning.cs +++ b/UsefulHints/EventHandlers/Modules/FFWarning.cs @@ -15,7 +15,7 @@ public static void UnregisterEvents() } private static void OnHurting(HurtingEventArgs ev) { - if (ev.Attacker != null && ev.Player != null && ev.Attacker.Role != null && ev.Player.Role != null) + if (ev.Attacker != null && ev.Player != null && ev.Attacker.Role != null && ev.Player.Role != null && ev.Attacker.Role.Team != Team.SCPs && ev.Player.Role.Team != Team.SCPs) { if (ev.Attacker.Role.Side == ev.Player.Role.Side && ev.Attacker != ev.Player) { @@ -33,8 +33,12 @@ private static void OnHurting(HurtingEventArgs ev) ev.Player.ShowHint(string.Format(UsefulHints.Instance.Config.DamageTakenWarning, ev.Attacker.Nickname), 2); } } + if (UsefulHints.Instance.Config.EnableCuffedWarning && ev.Player.IsCuffed && ev.Attacker != ev.Player) + { + ev.Attacker.ShowHint(string.Format(UsefulHints.Instance.Config.CuffedAttackerWarning), 2); + ev.Player.ShowHint(string.Format(UsefulHints.Instance.Config.CuffedPlayerWarning, ev.Attacker.Nickname), 2); + } } } - } } \ No newline at end of file diff --git a/UsefulHints/UsefulHints.cs b/UsefulHints/UsefulHints.cs index 6c5cb42..975f5a1 100644 --- a/UsefulHints/UsefulHints.cs +++ b/UsefulHints/UsefulHints.cs @@ -9,7 +9,7 @@ public class UsefulHints : Plugin public override string Name => "Useful Hints"; public override string Author => "Vretu"; public override string Prefix { get; } = "UH"; - public override Version Version => new Version(1, 7, 2); + public override Version Version => new Version(1, 7, 3); public override Version RequiredExiledVersion { get; } = new Version(8, 9, 8); public override PluginPriority Priority { get; } = PluginPriority.Low; public static UsefulHints Instance { get; private set; }