From db543bce91e016eb09fa0c36c2aaf23a3ccc081a Mon Sep 17 00:00:00 2001 From: Vretu <82831707+Vretu-Dev@users.noreply.github.com> Date: Tue, 10 Sep 2024 13:55:36 +0200 Subject: [PATCH] UPDATE 1.0.1 | Make effect more smoothly --- AdrenalinRush/AdrenalinRush.cs | 37 +++++++++++++++++++++++++++++----- AdrenalinRush/config.cs | 9 ++++++++- 2 files changed, 40 insertions(+), 6 deletions(-) diff --git a/AdrenalinRush/AdrenalinRush.cs b/AdrenalinRush/AdrenalinRush.cs index 447d6ec..3242978 100644 --- a/AdrenalinRush/AdrenalinRush.cs +++ b/AdrenalinRush/AdrenalinRush.cs @@ -1,15 +1,19 @@ using System; +using System.Collections.Generic; using Exiled.API.Enums; using Exiled.API.Features; using Exiled.Events.EventArgs.Player; +using MEC; +using PlayerEffects = CustomPlayerEffects; -namespace AdrenalinRush { +namespace AdrenalinRush +{ public class AdrenalinRush : Plugin { public override string Name => "Adrenalin Rush"; public override string Author => "Vretu"; public override string Prefix { get; } = "AR"; - public override Version Version => new Version(1, 0, 0); + public override Version Version => new Version(1, 0, 1); public override Version RequiredExiledVersion { get; } = new Version(8, 9, 8); public override void OnEnabled() @@ -17,19 +21,42 @@ public override void OnEnabled() Exiled.Events.Handlers.Player.UsedItem += OnUsedItem; base.OnEnabled(); } - public override void OnDisabled() { Exiled.Events.Handlers.Player.UsedItem -= OnUsedItem; base.OnDisabled(); } - + // Handler for Using Adrenaline private void OnUsedItem(UsedItemEventArgs ev) { if (ev.Item.Type == ItemType.Adrenaline) { - ev.Player.EnableEffect(EffectType.MovementBoost, Config.BoostIntensity, Config.BoostDuration); + Timing.RunCoroutine(ApplySmoothBoost(ev.Player)); + } + } + private IEnumerator ApplySmoothBoost(Player player) + { + float currentIntensity = 0f; + float increment = Config.BoostIntensity / Config.SpeedIncrease; // Adjust how fast the boost grows + float duration = Config.BoostDuration; + float stepDuration = duration / Config.Steps; // Number of steps after speed is refreshed in the duration + + // Enable movement boost effect for full duration setting in config + player.EnableEffect(EffectType.MovementBoost, duration); + + // Retrieve active movement boost effect + var movementBoost = player.ReferenceHub.playerEffectsController.GetEffect(); + + // Smooth increase intensity + while (currentIntensity < Config.BoostIntensity) + { + currentIntensity += increment; + movementBoost.Intensity = (byte)currentIntensity; + yield return Timing.WaitForSeconds(stepDuration); } + // Maximum intensity + movementBoost.Intensity = Config.BoostIntensity; } + } } \ No newline at end of file diff --git a/AdrenalinRush/config.cs b/AdrenalinRush/config.cs index 836a0b8..e165856 100644 --- a/AdrenalinRush/config.cs +++ b/AdrenalinRush/config.cs @@ -1,4 +1,5 @@ using Exiled.API.Interfaces; +using System.ComponentModel; namespace AdrenalinRush { @@ -6,7 +7,13 @@ public class Config : IConfig { public bool IsEnabled { get; set; } = true; public bool Debug { get; set; } = false; - public int BoostDuration { get; set; } = 3; + [Description("Duration time of effect in seconds.")] + public int BoostDuration { get; set; } = 4; + [Description("It's effect Intensity. Same as Remote Admin.")] public byte BoostIntensity { get; set; } = 30; + [Description("Adjust how fast the boost grows. It's BoostIntensity / SpeedIncrease. For example [30 Intensity / 4s Duration = 7,5 IntensityBoost per second].")] + public int SpeedIncrease { get; set; } = 4; + [Description("Number of steps after speed is refreshed. Higher value = refreshing more frequently.")] + public int Steps { get; set; } = 5; } }