From 94fc883ce78d206e70b2dc407baa0598d8c631cc Mon Sep 17 00:00:00 2001 From: TheKittehJesus <29379890+TheKittehJesus@users.noreply.github.com> Date: Wed, 17 Sep 2025 05:58:12 -0500 Subject: [PATCH] Human tone elf skin fix (#1787) * Patch saving for human skin tone elves * Formatting clean up --- .../Humanoid/CP14ElfTonedSkinColoration.cs | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/Content.Shared/_CP14/Humanoid/CP14ElfTonedSkinColoration.cs b/Content.Shared/_CP14/Humanoid/CP14ElfTonedSkinColoration.cs index 1b0d6ef9ab..5eac31d0ea 100644 --- a/Content.Shared/_CP14/Humanoid/CP14ElfTonedSkinColoration.cs +++ b/Content.Shared/_CP14/Humanoid/CP14ElfTonedSkinColoration.cs @@ -26,7 +26,7 @@ public sealed partial class CP14ElfTonedSkinColoration : ISkinColorationStrategy if (hue < 20f || hue > 270f) return false; - if (sat < 5f || sat > 35f) + if (sat < 5f || sat > 50f) return false; if (val < 20f || val > 100f) @@ -83,13 +83,31 @@ public sealed partial class CP14ElfTonedSkinColoration : ISkinColorationStrategy public float ToUnary(Color color) { var hsv = Color.ToHsv(color); - var hue = hsv.X * 360f; var sat = hsv.Y * 100f; var val = hsv.Z * 100f; + if (hue > 255) + { + var progressVal = (100f - val) / (100f - 25f); + return Math.Clamp(progressVal * 100f, 0f, 100f); + } + else + { + // check for hue/value first, if hue is lower than this percentage + // and value is 1.0 + // then it'll be hue + if (Math.Clamp(hsv.X, 25f / 360f, 1) > 25f / 360f + && hsv.Z == 1.0) + { + return Math.Abs(45 - hsv.X * 360); + } + // otherwise it'll directly be the saturation + else + { + return hsv.Y * 100; + } + } - var progressVal = (100f - val) / (100f - 25f); - return Math.Clamp(progressVal * 100f, 0f, 100f); } }