150 lines
5.0 KiB
C#
150 lines
5.0 KiB
C#
using CustomPlayerEffects;
|
|
using InventorySystem.Items.Usables.Scp330;
|
|
using LabApi.Events.Handlers;
|
|
using LabApi.Features.Wrappers;
|
|
using MEC;
|
|
using PlayerRoles.FirstPersonControl;
|
|
using PlayerRoles.PlayableScps.Scp939;
|
|
using static LabApi.Features.Wrappers.Server;
|
|
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
|
|
{
|
|
public static bool IsBloodFueled(Player player)
|
|
{
|
|
try
|
|
{
|
|
return player.CustomInfo.Contains("Blood Fueled");
|
|
}
|
|
catch
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public BloodFueledManager()
|
|
{
|
|
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;
|
|
|
|
var isAffectedByBloodCloud = Scp939AmnesticCloudInstance.ActiveInstances.Where(x=>x.Owner && x.Owner == ev.Attacker?.ReferenceHub).Any(x=>x.AffectedPlayers.Contains(ev.Player.ReferenceHub));
|
|
|
|
if (isAffectedByBloodCloud)
|
|
{
|
|
attacker.Heal(10);
|
|
attacker.StaminaRemaining += 0.1f;
|
|
}
|
|
|
|
if (ev.Player.Health <= 0)
|
|
{
|
|
attacker.Heal(25);
|
|
attacker.StaminaRemaining += 0.2f;
|
|
return;
|
|
}
|
|
|
|
attacker.Heal(15);
|
|
attacker.StaminaRemaining += 0.1f;
|
|
};
|
|
|
|
Timing.RunCoroutine(DrainBlood());
|
|
|
|
PlayerEvents.EnteringHazard += ev =>
|
|
{
|
|
if (ev.Hazard is not AmnesticCloudHazard amnesticCloud) return;
|
|
if (amnesticCloud.Owner == null || !IsBloodFueled(amnesticCloud.Owner)) return;
|
|
|
|
ev.Player.EnableEffect<Invigorated>(1, float.PositiveInfinity);
|
|
};
|
|
|
|
PlayerEvents.StayingInHazard += ev =>
|
|
{
|
|
if (ev.Hazard is not AmnesticCloudHazard amnesticCloud) return;
|
|
if (amnesticCloud.Owner == null || !IsBloodFueled(amnesticCloud.Owner)) return;
|
|
|
|
foreach (var affectedPlayer in ev.AffectedPlayers)
|
|
{
|
|
// ReSharper disable once PossibleLossOfFraction
|
|
affectedPlayer.Heal(10 / MaxTps);
|
|
}
|
|
};
|
|
|
|
PlayerEvents.LeavingHazard += ev =>
|
|
{
|
|
if (ev.Hazard is not AmnesticCloudHazard amnesticCloud) return;
|
|
if (amnesticCloud.Owner == null || !IsBloodFueled(amnesticCloud.Owner)) return;
|
|
|
|
ev.Player.DisableEffect<Invigorated>();
|
|
};
|
|
}
|
|
|
|
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.MaxHumeShield = 0;
|
|
player.HumeShield = 0;
|
|
player.MaxHealth = 3500;
|
|
player.Health = 3500;
|
|
|
|
player.EnableEffect<DisableStaminaRegenEffect>(1, float.PositiveInfinity);
|
|
player.EnableEffect<BloodFueledStaminaEffect>(1, float.PositiveInfinity);
|
|
}
|
|
|
|
public override void SendSpawnMessage(Player player, CustomClassConfig config)
|
|
{
|
|
player.SendBroadcast("You are SCP-939-<color=#C50000>Blood Fueled</color> \n Your stamina bar has been replaced by a <color=#C50000>blood meter</color>. \n You refill it by <color=#C50000>damaging</color> or <color=#C50000>killing</color> Humans. \n <color=#C50000><b>Don't let it run out.</color></b>", CustomClasses.BroadcastDuration);
|
|
}
|
|
} |