122 lines
3.6 KiB
C#
122 lines
3.6 KiB
C#
using LabApi.Events.Handlers;
|
|
using LabApi.Features.Wrappers;
|
|
using MEC;
|
|
using PlayerRoles.FirstPersonControl;
|
|
using PlayerRoles.PlayableScps.Scp939;
|
|
using Logger = LabApi.Features.Console.Logger;
|
|
using Random = System.Random;
|
|
|
|
namespace CustomClasses;
|
|
|
|
public class DisableStaminaRegenEffect : CustomPlayerEffect, IStaminaModifier
|
|
{
|
|
public bool StaminaModifierActive => IsEnabled;
|
|
public float StaminaUsageMultiplier => 1;
|
|
|
|
public float StaminaRegenMultiplier => 0;
|
|
public bool SprintingDisabled => false;
|
|
|
|
public override EffectClassification Classification => EffectClassification.Negative;
|
|
}
|
|
|
|
public class BloodFueledStaminaEffect : CustomPlayerEffect, IStaminaModifier
|
|
{
|
|
public bool StaminaModifierActive => IsEnabled;
|
|
public float StaminaUsageMultiplier => 0.2f;
|
|
|
|
public float StaminaRegenMultiplier => 1;
|
|
public bool SprintingDisabled => false;
|
|
|
|
public override EffectClassification Classification => EffectClassification.Positive;
|
|
}
|
|
|
|
public class BloodFueledManager
|
|
{
|
|
private readonly CustomClasses _plugin;
|
|
|
|
public static bool IsBloodFueled(Player player)
|
|
{
|
|
try
|
|
{
|
|
return player.CustomInfo.Contains("Blood Fueled");
|
|
}
|
|
catch
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public BloodFueledManager(CustomClasses plugin)
|
|
{
|
|
_plugin = plugin;
|
|
PlayerEvents.Hurt += ev =>
|
|
{
|
|
if (ev.DamageHandler is not Scp939DamageHandler damageHandler) return;
|
|
var attacker = Player.Get(damageHandler.Attacker.Hub);
|
|
if (attacker == null) return;
|
|
if (!IsBloodFueled(attacker)) return;
|
|
|
|
|
|
if (ev.Player.Health <= 0)
|
|
{
|
|
attacker.Heal(25);
|
|
attacker.StaminaRemaining += 0.2f;
|
|
return;
|
|
}
|
|
|
|
attacker.Heal(15);
|
|
attacker.StaminaRemaining += 0.1f;
|
|
};
|
|
|
|
Timing.RunCoroutine(DrainBlood());
|
|
}
|
|
|
|
public static IEnumerator<float> DrainBlood()
|
|
{
|
|
while (true)
|
|
{
|
|
yield return Timing.WaitForSeconds(1);
|
|
foreach (var player in Player.ReadyList.Where(IsBloodFueled))
|
|
{
|
|
if (player.StaminaRemaining <= 0f)
|
|
{
|
|
player.Health = Math.Min(Math.Max(player.Health - 50, 500), player.Health);
|
|
continue;
|
|
}
|
|
|
|
player.StaminaRemaining -= 0.005f;
|
|
|
|
if (player.MaxHealth <= player.Health) continue;
|
|
player.Heal(5);
|
|
player.StaminaRemaining -= 0.001f;
|
|
}
|
|
}
|
|
// ReSharper disable once IteratorNeverReturns
|
|
}
|
|
}
|
|
|
|
public class BloodFueledHandler : CustomClassHandler
|
|
{
|
|
public override void HandleSpawn(Player player, CustomClassConfig config, Random random)
|
|
{
|
|
player.SendBroadcast("You are the <color=#6e2e99>Blood Fueled</color>!", CustomClasses.BroadcastDuration);
|
|
const string customInfo = "<color=#A0A0A0>Blood Fueled</color>";
|
|
if (!Player.ValidateCustomInfo(customInfo, out var reason))
|
|
{
|
|
Logger.Error($"Invalid custom info for Blood Fueled: {reason}");
|
|
}
|
|
else
|
|
{
|
|
player.CustomInfo = customInfo;
|
|
player.InfoArea |= PlayerInfoArea.CustomInfo;
|
|
}
|
|
|
|
player.MaxHumeShield = 0;
|
|
player.HumeShield = 0;
|
|
player.MaxHealth = 3500;
|
|
player.Health = 3500;
|
|
|
|
player.EnableEffect<DisableStaminaRegenEffect>(1, float.PositiveInfinity);
|
|
player.EnableEffect<BloodFueledStaminaEffect>(1, float.PositiveInfinity);
|
|
}
|
|
} |