diff --git a/EXILED/Exiled.API/Features/CustomHealthStat.cs b/EXILED/Exiled.API/Features/CustomHealthStat.cs index dbe99a948b..062c1cebf7 100644 --- a/EXILED/Exiled.API/Features/CustomHealthStat.cs +++ b/EXILED/Exiled.API/Features/CustomHealthStat.cs @@ -7,6 +7,7 @@ namespace Exiled.API.Features { + using PlayerRoles; using PlayerStatsSystem; /// @@ -17,7 +18,7 @@ public class CustomHealthStat : HealthStat private float customMaxValue; /// - public override float MaxValue => CustomMaxValue == default ? base.MaxValue : CustomMaxValue; + public override float MaxValue => customMaxValue == default ? base.MaxValue : CustomMaxValue; /// /// Gets or sets the maximum amount of health the player will have. @@ -27,7 +28,7 @@ public float CustomMaxValue get { if (Hub.playerStats.TryGetModule(out MaxHealthStat maxHealthStat)) - return maxHealthStat.CurValue; + return maxHealthStat.CurValue + HumanRole.DefaultMaxHealth; return customMaxValue; } @@ -35,7 +36,7 @@ public float CustomMaxValue { customMaxValue = value; if (Hub.playerStats.TryGetModule(out MaxHealthStat maxHealthStat)) - maxHealthStat.CurValue = value; + maxHealthStat.CurValue = value - HumanRole.DefaultMaxHealth; } } } diff --git a/EXILED/Exiled.Events/Patches/Fixes/HumanMaxHealth.cs b/EXILED/Exiled.Events/Patches/Fixes/HumanMaxHealth.cs deleted file mode 100644 index 521e7d6221..0000000000 --- a/EXILED/Exiled.Events/Patches/Fixes/HumanMaxHealth.cs +++ /dev/null @@ -1,36 +0,0 @@ -// ----------------------------------------------------------------------- -// -// Copyright (c) Exiled Team. All rights reserved. -// Licensed under the CC BY-SA 3.0 license. -// -// ----------------------------------------------------------------------- - -namespace Exiled.Events.Patches.Fixes -{ -#pragma warning disable SA1313 - using Exiled.API.Features; - using HarmonyLib; - using Mirror; - using PlayerStatsSystem; - using UnityEngine; - - /// - /// Fix health bar for custom max hp. - /// - [HarmonyPatch(typeof(MaxHealthStat), nameof(MaxHealthStat.WriteValue))] - public class HumanMaxHealth - { -#pragma warning disable SA1313 - private static bool Prefix(MaxHealthStat __instance, NetworkWriter writer) - { - float value = __instance.CurValue; - - if (Player.Get(__instance.Hub).MaxHealth != default) - value -= 100; - - int num = Mathf.Clamp(Mathf.CeilToInt(value), 0, ushort.MaxValue); - writer.WriteUShort((ushort)num); - return false; - } - } -} \ No newline at end of file