-
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.
UPDATE 1.0.1 | Make effect more smoothly
- Loading branch information
Showing
2 changed files
with
40 additions
and
6 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 |
---|---|---|
@@ -1,35 +1,62 @@ | ||
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<Config> | ||
{ | ||
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() | ||
{ | ||
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<float> 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<PlayerEffects.MovementBoost>(); | ||
|
||
// Smooth increase intensity | ||
while (currentIntensity < Config.BoostIntensity) | ||
{ | ||
currentIntensity += increment; | ||
movementBoost.Intensity = (byte)currentIntensity; | ||
yield return Timing.WaitForSeconds(stepDuration); | ||
} | ||
// Maximum intensity | ||
movementBoost.Intensity = Config.BoostIntensity; | ||
} | ||
|
||
} | ||
} |
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 |
---|---|---|
@@ -1,12 +1,19 @@ | ||
using Exiled.API.Interfaces; | ||
using System.ComponentModel; | ||
|
||
namespace AdrenalinRush | ||
{ | ||
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; | ||
} | ||
} |