That should do it, up to you to check more thoroughly to see if using SetStatusBarColor on nameplates doesn't taint anything in a bad way though (and to check whether it doesn't leave random other nameplates colored wrong, but it shouldn't.)
lua Code:
hooksecurefunc("CompactUnitFrame_UpdateHealth", function(frame)
if frame.optionTable.colorNameBySelection and not frame:IsForbidden() then
local healthPercentage = ceil((UnitHealth(frame.displayedUnit) / UnitHealthMax(frame.displayedUnit) * 100))
if C_NamePlate.GetNamePlateForUnit(frame.unit) == C_NamePlate.GetNamePlateForUnit("player") then
if healthPercentage == 100 then
frame.healthBar:SetStatusBarColor(0, 1, 0)
elseif healthPercentage < 100 and healthPercentage >= 75 then
frame.healthBar:SetStatusBarColor(0.6, 0.8, 0.19)
elseif healthPercentage < 75 and healthPercentage >= 50 then
frame.healthBar:SetStatusBarColor(1, 1, 0)
elseif healthPercentage < 50 and healthPercentage >= 25 then
frame.healthBar:SetStatusBarColor(1, 0.64, 0)
elseif healthPercentage < 25 then
frame.healthBar:SetStatusBarColor(1, 0, 0)
end
end
end
end)
Hacky, but eh. Not like that other script was any better.