-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1.4.0 | Code Refactor & More Configurable
- Completely code refactor - More option in config
- Loading branch information
Showing
12 changed files
with
786 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using CustomPlayerEffects; | ||
using Exiled.API.Enums; | ||
using Exiled.API.Interfaces; | ||
using System.ComponentModel; | ||
|
||
namespace UsefulHints | ||
{ | ||
public class Config : IConfig | ||
{ | ||
public bool IsEnabled { get; set; } = true; | ||
public bool Debug { get; set; } = false; | ||
[Description("[Module] Hints:")] | ||
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 JailbirdUseMessage { get; set; } = "Jailbird has been used {0}/5 times"; | ||
public string Scp207HintMessage { get; set; } = "You are on {0} SCP-207"; | ||
[Description("[Module] Kill Counter:")] | ||
public bool EnableKillCounter { get; set; } = true; | ||
public string KillCountMessage { get; set; } = "{0} kills"; | ||
[Description("[Module] Round Summary:")] | ||
public bool EnableRoundSummary { get; set; } = true; | ||
public ushort RoundSummaryMessageDuration { get; set; } = 10; | ||
public string HumanKillMessage { get; set; } = "<size=27><color=#70EE9C>{0}</color> had the most kills as <color=green>Human</color>: <color=yellow>{1}</color></size>"; | ||
public string ScpKillMessage { get; set; } = "<size=27><color=#70EE9C>{0}</color> had the most kills as <color=red>SCP</color>: <color=yellow>{1}</color></size>"; | ||
public string TopDamageMessage { get; set; } = "<size=27><color=#70EE9C>{0}</color> did the most damage: <color=yellow>{1}</color></size>"; | ||
public string FirstScpKillerMessage { get; set; } = "<size=27><color=#70EE9C>{0}</color> was the first to kill <color=red>SCP</color></size>"; | ||
public string EscaperMessage { get; set; } = "<size=27><color=#70EE9C>{0}</color> escaped first from the facility: <color=yellow>{1}:{2}</color></size>"; | ||
[Description("[Module] Teammates:")] | ||
public bool EnableTeammates { get; set; } = true; | ||
public float TeammateHintDelay { get; set; } = 4f; | ||
public string TeammateHintMessage { get; set; } = "<align=left><size=28><color=#70EE9C>Your Teammates</color></size> \n<size=25><color=yellow>{0}</color></size></align>"; | ||
public float TeammateMessageDuration { get; set; } = 8f; | ||
public string AloneHintMessage { get; set; } = "<align=left><color=red>You are playing Solo</color></align>"; | ||
public float AloneMessageDuration { get; set; } = 4f; | ||
[Description("[Module] Last Human Broadcast:")] | ||
public bool EnableLastHumanBroadcast { get; set; } = true; | ||
public string BroadcastForHuman { get; set; } = "<color=red>You are the last human alive!</color>"; | ||
public string BroadcastForScp { get; set; } = "<color=#70EE9C>{0}</color> is the last human alive playing as {1} in <color=yellow>{2}</color>"; | ||
[Description("[Module] Jailbird Custom Settings:")] | ||
public bool EnableCustomJailbirdSettings { get; set; } = false; | ||
public EffectType JailbirdEffect { get; set; } = EffectType.Flashed; | ||
public float JailbirdEffectDuration { get; set; } = 4f; | ||
public byte JailbirdEffectIntensity { get; set; } = 1; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using Exiled.Events.EventArgs.Scp096; | ||
|
||
namespace UsefulHints.EventHandlers.Entities | ||
{ | ||
public static class SCP096 | ||
{ | ||
public static void RegisterEvents() | ||
{ | ||
Exiled.Events.Handlers.Scp096.AddingTarget += OnScp096AddingTarget; | ||
} | ||
public static void UnregisterEvents() | ||
{ | ||
Exiled.Events.Handlers.Scp096.AddingTarget -= OnScp096AddingTarget; | ||
} | ||
private static void OnScp096AddingTarget(AddingTargetEventArgs ev) | ||
{ | ||
ev.Target.ShowHint(UsefulHints.Instance.Config.Scp096LookMessage, 5); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
using System.Linq; | ||
using System.Collections.Generic; | ||
using Exiled.API.Enums; | ||
using Exiled.API.Extensions; | ||
using Exiled.API.Features.Pickups; | ||
using Player = Exiled.API.Features.Player; | ||
using Exiled.Events.EventArgs.Map; | ||
using Exiled.Events.EventArgs.Player; | ||
using InventorySystem.Items.ThrowableProjectiles; | ||
using MEC; | ||
|
||
namespace UsefulHints.EventHandlers.Items | ||
{ | ||
public static class Hints | ||
{ | ||
private static readonly Dictionary<Player, CoroutineHandle> activeCoroutines = new Dictionary<Player, CoroutineHandle>(); | ||
private static Dictionary<Player, ItemType> activeItems = new Dictionary<Player, ItemType>(); | ||
public static void RegisterEvents() | ||
{ | ||
Exiled.Events.Handlers.Player.PickingUpItem += OnPickingUpSCP207; | ||
Exiled.Events.Handlers.Player.UsedItem += OnSCP268Used; | ||
Exiled.Events.Handlers.Player.InteractingDoor += OnSCP268Interacting; | ||
Exiled.Events.Handlers.Player.ChangedItem += OnSCP268ChangedItem; | ||
Exiled.Events.Handlers.Map.ExplodingGrenade += OnSCP2176Grenade; | ||
Exiled.Events.Handlers.Server.WaitingForPlayers += OnWaitingForPlayers; | ||
Exiled.Events.Handlers.Player.PickingUpItem += OnPickingUpJailbird; | ||
} | ||
public static void UnregisterEvents() | ||
{ | ||
Exiled.Events.Handlers.Player.PickingUpItem -= OnPickingUpSCP207; | ||
Exiled.Events.Handlers.Player.UsedItem -= OnSCP268Used; | ||
Exiled.Events.Handlers.Player.InteractingDoor -= OnSCP268Interacting; | ||
Exiled.Events.Handlers.Player.ChangedItem -= OnSCP268ChangedItem; | ||
Exiled.Events.Handlers.Map.ExplodingGrenade -= OnSCP2176Grenade; | ||
Exiled.Events.Handlers.Server.WaitingForPlayers -= OnWaitingForPlayers; | ||
Exiled.Events.Handlers.Player.PickingUpItem -= OnPickingUpJailbird; | ||
} | ||
// SCP 207 Handler | ||
private static void OnPickingUpSCP207(PickingUpItemEventArgs ev) | ||
{ | ||
if (ev.Pickup.Type == ItemType.SCP207) | ||
{ | ||
CustomPlayerEffects.StatusEffectBase scp207Effect = ev.Player.ActiveEffects.FirstOrDefault(effect => effect.GetEffectType() == EffectType.Scp207); | ||
|
||
if (scp207Effect != null) | ||
{ | ||
ev.Player.ShowHint($"<color=#A60C0E>{string.Format(UsefulHints.Instance.Config.Scp207HintMessage, scp207Effect.Intensity)}</color>", 4); | ||
} | ||
} | ||
} | ||
// SCP 268 Handler | ||
private static void OnSCP268Used(UsedItemEventArgs ev) | ||
{ | ||
if (ev.Item.Type == ItemType.SCP268) | ||
{ | ||
if (activeCoroutines.ContainsKey(ev.Player)) | ||
{ | ||
Timing.KillCoroutines(activeCoroutines[ev.Player]); | ||
activeCoroutines.Remove(ev.Player); | ||
} | ||
|
||
var coroutine = Timing.RunCoroutine(Scp268Timer(ev.Player)); | ||
activeCoroutines.Add(ev.Player, coroutine); | ||
activeItems.Add(ev.Player, ev.Item.Type); | ||
} | ||
} | ||
private static void OnSCP268Interacting(InteractingDoorEventArgs ev) | ||
{ | ||
if (activeCoroutines.ContainsKey(ev.Player) && activeItems.ContainsKey(ev.Player) && activeItems[ev.Player] == ItemType.SCP268) | ||
{ | ||
Timing.KillCoroutines(activeCoroutines[ev.Player]); | ||
activeCoroutines.Remove(ev.Player); | ||
activeItems.Remove(ev.Player); | ||
} | ||
} | ||
private static void OnSCP268ChangedItem(ChangedItemEventArgs ev) | ||
{ | ||
if (activeCoroutines.ContainsKey(ev.Player) && activeItems.ContainsKey(ev.Player) && activeItems[ev.Player] == ItemType.SCP268) | ||
{ | ||
Timing.KillCoroutines(activeCoroutines[ev.Player]); | ||
activeCoroutines.Remove(ev.Player); | ||
activeItems.Remove(ev.Player); | ||
} | ||
} | ||
private static IEnumerator<float> Scp268Timer(Player player) | ||
{ | ||
float duration = UsefulHints.Instance.Config.Scp268Duration; | ||
|
||
while (duration > 0) | ||
{ | ||
player.ShowHint($"<color=purple>{new string('\n', 10)}{string.Format(UsefulHints.Instance.Config.Scp268TimeLeftMessage, (int)duration)}</color>", 1.15f); | ||
yield return Timing.WaitForSeconds(1f); | ||
duration -= 1f; | ||
} | ||
activeCoroutines.Remove(player); | ||
} | ||
// SCP 2176 Handler | ||
private static void OnSCP2176Grenade(ExplodingGrenadeEventArgs ev) | ||
{ | ||
if (ev.Projectile.Base is Scp2176Projectile) | ||
{ | ||
if (ev.Player != null) | ||
{ | ||
if (activeCoroutines.ContainsKey(ev.Player)) | ||
{ | ||
Timing.KillCoroutines(activeCoroutines[ev.Player]); | ||
activeCoroutines.Remove(ev.Player); | ||
} | ||
|
||
var coroutine = Timing.RunCoroutine(Scp2176Timer(ev.Player)); | ||
activeCoroutines.Add(ev.Player, coroutine); | ||
} | ||
} | ||
} | ||
private static IEnumerator<float> Scp2176Timer(Player player) | ||
{ | ||
float duration = 13f; | ||
|
||
while (duration > 0) | ||
{ | ||
player.ShowHint($"<color=#1CAA21>{new string('\n', 10)}{string.Format(UsefulHints.Instance.Config.Scp2176TimeLeftMessage, (int)duration)}</color>", 1.15f); | ||
yield return Timing.WaitForSeconds(1f); | ||
duration -= 1f; | ||
} | ||
activeCoroutines.Remove(player); | ||
} | ||
// Reset Coroutines | ||
private static void OnWaitingForPlayers() | ||
{ | ||
activeCoroutines.Clear(); | ||
} | ||
// Jailbird Handler | ||
private static void OnPickingUpJailbird(PickingUpItemEventArgs ev) | ||
{ | ||
if (ev.Pickup is JailbirdPickup jailbirdPickup) | ||
{ | ||
int remainingCharges = jailbirdPickup.TotalCharges; | ||
if (remainingCharges < 4) | ||
{ | ||
ev.Player.ShowHint($"<color=#00B7EB>{string.Format(UsefulHints.Instance.Config.JailbirdUseMessage, remainingCharges)}</color>", 4); | ||
} | ||
else | ||
{ | ||
ev.Player.ShowHint($"<color=#C73804>{string.Format(UsefulHints.Instance.Config.JailbirdUseMessage, remainingCharges)}</color>", 4); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using HarmonyLib; | ||
using System; | ||
|
||
namespace UsefulHints.EventHandlers.Modules | ||
{ | ||
public static class JailbirdPatchHandler | ||
{ | ||
public static Harmony Harmony { get; private set; } | ||
public static string HarmonyName { get; private set; } | ||
public static void RegisterEvents() | ||
{ | ||
if (UsefulHints.Instance.Config.EnableCustomJailbirdSettings) | ||
{ | ||
HarmonyName = $"com-vretu.uh-{DateTime.UtcNow.Ticks}"; | ||
Harmony = new Harmony(HarmonyName); | ||
Harmony.PatchAll(); | ||
} | ||
} | ||
public static void UnregisterEvents() | ||
{ | ||
if (UsefulHints.Instance.Config.EnableCustomJailbirdSettings) | ||
{ | ||
Harmony.UnpatchAll(HarmonyName); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using System.Collections.Generic; | ||
using Player = Exiled.API.Features.Player; | ||
using Exiled.Events.EventArgs.Player; | ||
|
||
namespace UsefulHints.EventHandlers.Modules | ||
{ | ||
public static class KillCounter | ||
{ | ||
private static readonly Dictionary<Player, int> playerKills = new Dictionary<Player, int>(); | ||
public static void RegisterEvents() | ||
{ | ||
Exiled.Events.Handlers.Player.Died += OnPlayerDied; | ||
} | ||
public static void UnregisterEvents() | ||
{ | ||
Exiled.Events.Handlers.Player.Died -= OnPlayerDied; | ||
} | ||
private static void OnPlayerDied(DiedEventArgs ev) | ||
{ | ||
if (UsefulHints.Instance.Config.EnableKillCounter) | ||
{ | ||
if (ev.Attacker != null && ev.Attacker != ev.Player) | ||
{ | ||
Player killer = ev.Attacker; | ||
|
||
if (playerKills.ContainsKey(killer)) | ||
{ | ||
playerKills[killer]++; | ||
} | ||
else | ||
{ | ||
playerKills[killer] = 1; | ||
} | ||
killer.ShowHint(string.Format(UsefulHints.Instance.Config.KillCountMessage, playerKills[killer]), 4); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
using System.Linq; | ||
using Exiled.API.Enums; | ||
using Exiled.API.Features; | ||
using Exiled.Events.EventArgs.Player; | ||
using PlayerRoles; | ||
|
||
namespace UsefulHints.EventHandlers.Modules | ||
{ | ||
public static class LastHumanBroadcast | ||
{ | ||
public static void RegisterEvents() | ||
{ | ||
Exiled.Events.Handlers.Player.Died += OnPlayerDied; | ||
} | ||
public static void UnregisterEvents() | ||
{ | ||
Exiled.Events.Handlers.Player.Died -= OnPlayerDied; | ||
} | ||
private static void OnPlayerDied(DiedEventArgs ev) | ||
{ | ||
if (UsefulHints.Instance.Config.EnableLastHumanBroadcast) | ||
{ | ||
var aliveHumans = Player.List.Where(p => p.IsAlive && IsHuman(p)); | ||
|
||
if (aliveHumans.Count() == 1) | ||
{ | ||
Player lastAlive = aliveHumans.First(); | ||
|
||
lastAlive.Broadcast(10, UsefulHints.Instance.Config.BroadcastForHuman); | ||
|
||
var zone = GetZoneName(lastAlive); | ||
var teamName = GetRoleTeamName(lastAlive); | ||
|
||
string message = string.Format(UsefulHints.Instance.Config.BroadcastForScp, lastAlive.Nickname, teamName, zone); | ||
|
||
foreach (var scp in Player.List.Where(p => p.Role.Team == Team.SCPs)) | ||
{ | ||
scp.Broadcast(10, message); | ||
} | ||
} | ||
} | ||
} | ||
private static bool IsHuman(Player player) | ||
{ | ||
return player.Role.Team == Team.FoundationForces || player.Role.Team == Team.ClassD || player.Role.Team == Team.Scientists || player.Role.Team == Team.ChaosInsurgency; | ||
} | ||
private static string GetZoneName(Player player) | ||
{ | ||
ZoneType zone = player.CurrentRoom.Zone; | ||
|
||
switch (zone) | ||
{ | ||
case ZoneType.LightContainment: | ||
return "Light Containment"; | ||
case ZoneType.HeavyContainment: | ||
return "Heavy Containment"; | ||
case ZoneType.Entrance: | ||
return "Entrance Zone"; | ||
case ZoneType.Surface: | ||
return "Surface"; | ||
default: | ||
return "Unknown Zone"; | ||
} | ||
} | ||
private static string GetRoleTeamName(Player player) | ||
{ | ||
Team team = player.Role.Team; | ||
|
||
switch (team) | ||
{ | ||
case Team.FoundationForces: | ||
return "<color=#0096FF>Mobile Task Force</color>"; | ||
case Team.ClassD: | ||
return "<color=#FF8E00>Class D</color>"; | ||
case Team.Scientists: | ||
return "<color=#FFFF7C>Scientist</color>"; | ||
case Team.ChaosInsurgency: | ||
return "<color=#15853D>Chaos Insurgency</color>"; | ||
default: | ||
return "Unknown Team"; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.