Skip to content

Commit

Permalink
Merge pull request #2 from Vretu-Dev/beta
Browse files Browse the repository at this point in the history
1.7.3
  • Loading branch information
Vretu-Dev authored Oct 20, 2024
2 parents b530b2e + 73adf8e commit 87b772d
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 17 deletions.
10 changes: 7 additions & 3 deletions UsefulHints/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,19 @@ 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;
public string Scp268TimeLeftMessage { get; set; } = "Remaining: {0}s";
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; } = "<color=yellow>\u26A0</color> You are already affected by <color=#A60C0E>SCP-207</color>";
Expand All @@ -31,6 +32,9 @@ public class Config : IConfig
public string FriendlyFireWarning { get; set; } = "<size=27><color=yellow>\u26A0 Do not hurt your teammate</color></size>";
public string DamageTakenWarning { get; set; } = "<size=27><color=red>{0}</color> <color=yellow>(teammate) hit you</color></size>";
public bool ClassDAreTeammates { get; set; } = true;
public bool EnableCuffedWarning { get; set; } = false;
public string CuffedAttackerWarning { get; set; } = "<size=27><color=yellow>\u26A0 Player is cuffed</color></size>";
public string CuffedPlayerWarning { get; set; } = "<size=27><color=red>{0}</color> <color=yellow>hit you when you were cuffed</color></size>";
[Description("Kill Counter:")]
public bool EnableKillCounter { get; set; } = true;
public string KillCountMessage { get; set; } = "{0} kills";
Expand Down
103 changes: 92 additions & 11 deletions UsefulHints/EventHandlers/Items/Hints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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($"<color=red>{new string('\n', 10)}{string.Format(UsefulHints.Instance.Config.MicroHidLowEnergyMessage)}</color>", 4);
}
else
{
ev.Player.ShowHint($"<color=#4169E1>{new string('\n', 10)}{string.Format(UsefulHints.Instance.Config.MicroHidEnergyMessage, roundedEnergyPercentage)}</color>", 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($"<color=red>{string.Format(UsefulHints.Instance.Config.MicroLowEnergyMessage)}</color>", 4);
ev.Player.ShowHint($"<color=red>{new string('\n', 10)}{string.Format(UsefulHints.Instance.Config.MicroHidLowEnergyMessage)}</color>", 2);
}
else
{
ev.Player.ShowHint($"<color=#4169E1>{string.Format(UsefulHints.Instance.Config.MicroEnergyMessage, roundedEnergyPercentage)}</color>", 4);
ev.Player.ShowHint($"<color=#4169E1>{new string('\n', 10)}{string.Format(UsefulHints.Instance.Config.MicroHidEnergyMessage, roundedEnergyPercentage)}</color>", 2);
}
}
}
Expand All @@ -73,7 +102,7 @@ private static void OnPickingUpSCP207(PickingUpItemEventArgs ev)

if (scp207Effect != null)
{
ev.Player.ShowHint($"<color=#A60C0E>{string.Format(UsefulHints.Instance.Config.Scp207HintMessage, scp207Effect.Intensity)}</color>", 4);
ev.Player.ShowHint($"<color=#A60C0E>{new string('\n', 10)}{string.Format(UsefulHints.Instance.Config.Scp207HintMessage, scp207Effect.Intensity)}</color>", 4);
}
}
if (ev.Pickup.Type == ItemType.AntiSCP207)
Expand All @@ -82,7 +111,35 @@ private static void OnPickingUpSCP207(PickingUpItemEventArgs ev)

if (antiscp207Effect != null)
{
ev.Player.ShowHint($"<color=#2969AD>{string.Format(UsefulHints.Instance.Config.AntiScp207HintMessage, antiscp207Effect.Intensity)}</color>", 4);
ev.Player.ShowHint($"<color=#C53892>{new string('\n', 10)}{string.Format(UsefulHints.Instance.Config.AntiScp207HintMessage, antiscp207Effect.Intensity)}</color>", 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($"<color=#A60C0E>{new string('\n', 10)}{string.Format(UsefulHints.Instance.Config.Scp207HintMessage, scp207Effect.Intensity)}</color>", 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($"<color=#C53892>{new string('\n', 10)}{string.Format(UsefulHints.Instance.Config.AntiScp207HintMessage, antiscp207Effect.Intensity)}</color>", 2);
}
}
}
}
Expand Down Expand Up @@ -221,11 +278,35 @@ private static void OnPickingUpJailbird(PickingUpItemEventArgs ev)
int remainingCharges = maxCharges - jailbirdPickup.TotalCharges;
if (remainingCharges > 1)
{
ev.Player.ShowHint($"<color=#00B7EB>{string.Format(UsefulHints.Instance.Config.JailbirdUseMessage, remainingCharges)}</color>", 4);
ev.Player.ShowHint($"<color=#00B7EB>{new string('\n', 10)}{string.Format(UsefulHints.Instance.Config.JailbirdUseMessage, remainingCharges)}</color>", 4);
}
else
{
ev.Player.ShowHint($"<color=#C73804>{string.Format(UsefulHints.Instance.Config.JailbirdUseMessage, remainingCharges)}</color>", 4);
ev.Player.ShowHint($"<color=#C73804>{new string('\n', 10)}{string.Format(UsefulHints.Instance.Config.JailbirdUseMessage, remainingCharges)}</color>", 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($"<color=#00B7EB>{new string('\n', 10)}{string.Format(UsefulHints.Instance.Config.JailbirdUseMessage, remainingCharges)}</color>", 2);
}
else
{
ev.Player.ShowHint($"<color=#C73804>{new string('\n', 10)}{string.Format(UsefulHints.Instance.Config.JailbirdUseMessage, remainingCharges)}</color>", 2);
}
}
}
}
Expand Down
8 changes: 6 additions & 2 deletions UsefulHints/EventHandlers/Modules/FFWarning.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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);
}
}
}

}
}
2 changes: 1 addition & 1 deletion UsefulHints/UsefulHints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class UsefulHints : Plugin<Config>
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; }
Expand Down

0 comments on commit 87b772d

Please sign in to comment.