Skip to content

Commit 585de17

Browse files
authored
autocolors: readded simplecolors gradient (#4237)
autocolors: readded simplecolors gradient + in big teamgames your own teamcolor gets lighter
1 parent 6411223 commit 585de17

File tree

1 file changed

+56
-38
lines changed

1 file changed

+56
-38
lines changed

luarules/gadgets/game_autocolors.lua

+56-38
Original file line numberDiff line numberDiff line change
@@ -736,57 +736,75 @@ else -- UNSYNCED
736736
)
737737

738738
elseif
739-
not teamColors[allyTeamCount] or not teamColors[allyTeamCount][1][#Spring.GetTeamList(allyTeamCount-1)] --or #Spring.GetTeamList() > 30
739+
Spring.GetConfigInt("SimpleTeamColors", 0) == 1 or (anonymousMode == "allred" and not mySpecState)
740740
then
741+
local brightnessVariation = 0
742+
local maxColorVariation = 0
743+
local numEnemies = #Spring.GetTeamList()-1 - #Spring.GetTeamList(myAllyTeamID)
744+
if Spring.GetConfigInt("SimpleTeamColorsUseGradient", 0) == 1 then
745+
local totalEnemyDimmingCount = 0
746+
for allyTeamID, count in pairs(dimmingCount) do
747+
if allyTeamID ~= myAllyTeamID then
748+
totalEnemyDimmingCount = totalEnemyDimmingCount + count
749+
end
750+
end
751+
brightnessVariation = (0.7 - ((1.1 / numEnemies) * totalEnemyDimmingCount)) * 255
752+
maxColorVariation = math.floor(11 + (90 / (allyTeamCount)))
753+
end
741754
local color = hex2RGB(ffaColors[allyTeamID+1] or '#333333')
742755
if teamID == gaiaTeamID then
756+
brightnessVariation = 0
757+
maxColorVariation = 0
743758
color = hex2RGB(gaiaGrayColor)
744-
else
745-
local brightnessVariation = (0.55 - ((1 / #Spring.GetTeamList(allyTeamID)) * (dimmingCount[allyTeamID]))) * 255
746-
local maxColorVariation = math.floor(10 + (70 / (allyTeamCount)))
747-
color[1] = math.min(color[1] + brightnessVariation, 255) + math.random(-maxColorVariation, maxColorVariation)
748-
color[2] = math.min(color[2] + brightnessVariation, 255) + math.random(-maxColorVariation, maxColorVariation)
749-
color[3] = math.min(color[3] + brightnessVariation, 255) + math.random(-maxColorVariation, maxColorVariation)
759+
elseif teamID == myTeamID then
760+
brightnessVariation = 0
761+
maxColorVariation = 0
762+
color = {Spring.GetConfigInt("SimpleTeamColorsPlayerR", 0), Spring.GetConfigInt("SimpleTeamColorsPlayerG", 77), Spring.GetConfigInt("SimpleTeamColorsPlayerB", 255)}
763+
elseif allyTeamID == myAllyTeamID then
764+
color = {Spring.GetConfigInt("SimpleTeamColorsAllyR", 0), Spring.GetConfigInt("SimpleTeamColorsAllyG", 255), Spring.GetConfigInt("SimpleTeamColorsAllyB", 0)}
765+
elseif allyTeamID ~= myAllyTeamID then
766+
color = {Spring.GetConfigInt("SimpleTeamColorsEnemyR", 255), Spring.GetConfigInt("SimpleTeamColorsEnemyG", 16), Spring.GetConfigInt("SimpleTeamColorsEnemyB", 5)}
750767
end
768+
color[1] = math.min(color[1] + brightnessVariation, 255) + math.random(-maxColorVariation, maxColorVariation)
769+
color[2] = math.min(color[2] + brightnessVariation, 255) + math.random(-maxColorVariation, maxColorVariation)
770+
color[3] = math.min(color[3] + brightnessVariation, 255) + math.random(-maxColorVariation, maxColorVariation)
751771
Spring.SetTeamColor(
752772
teamID,
753-
(color[1] + (teamID == myTeamID and 0.3 or 0)) / 255,
754-
(color[2] + (teamID == myTeamID and 0.3 or 0)) / 255,
755-
(color[3] + (teamID == myTeamID and 0.3 or 0)) / 255
773+
color[1] / 255,
774+
color[2] / 255,
775+
color[3] / 255
756776
)
757777

778+
-- auto ffa gradient colored for huge player games
758779
elseif
759-
Spring.GetConfigInt("SimpleTeamColors", 0) == 1 or (anonymousMode == "allred" and not mySpecState)
780+
not teamColors[allyTeamCount] or not teamColors[allyTeamCount][1][#Spring.GetTeamList(allyTeamCount-1)] --or #Spring.GetTeamList() > 30
760781
then
761-
if teamID == myTeamID then
762-
Spring.SetTeamColor(
763-
teamID,
764-
Spring.GetConfigInt("SimpleTeamColorsPlayerR", 0) / 255,
765-
Spring.GetConfigInt("SimpleTeamColorsPlayerG", 77) / 255,
766-
Spring.GetConfigInt("SimpleTeamColorsPlayerB", 255) / 255
767-
)
782+
local brightnessVariation = (0.7 - ((1.1 / #Spring.GetTeamList(allyTeamID)) * dimmingCount[allyTeamID])) * 255
783+
local maxColorVariation = math.floor(11 + (90 / (allyTeamCount)))
784+
local color = hex2RGB(ffaColors[allyTeamID+1] or '#333333')
785+
if teamID == gaiaTeamID then
786+
brightnessVariation = 0
787+
maxColorVariation = 0
788+
color = hex2RGB(gaiaGrayColor)
789+
elseif teamID == myTeamID then
790+
brightnessVariation = 0
791+
maxColorVariation = 0
792+
color[1] = color[1] + 210
793+
color[2] = color[2] + 210
794+
color[3] = color[3] + 210
768795
elseif allyTeamID == myAllyTeamID then
769-
Spring.SetTeamColor(
770-
teamID,
771-
Spring.GetConfigInt("SimpleTeamColorsAllyR", 0) / 255,
772-
Spring.GetConfigInt("SimpleTeamColorsAllyG", 255) / 255,
773-
Spring.GetConfigInt("SimpleTeamColorsAllyB", 0) / 255
774-
)
775-
elseif allyTeamID ~= myAllyTeamID and teamID ~= gaiaTeamID then
776-
Spring.SetTeamColor(
777-
teamID,
778-
Spring.GetConfigInt("SimpleTeamColorsEnemyR", 255) / 255,
779-
Spring.GetConfigInt("SimpleTeamColorsEnemyG", 16) / 255,
780-
Spring.GetConfigInt("SimpleTeamColorsEnemyB", 5) / 255
781-
)
782-
else
783-
Spring.SetTeamColor(
784-
teamID,
785-
hex2RGB(gaiaGrayColor)[1] / 255,
786-
hex2RGB(gaiaGrayColor)[2] / 255,
787-
hex2RGB(gaiaGrayColor)[3] / 255
788-
)
796+
brightnessVariation = brightnessVariation - 40
797+
maxColorVariation = math.ceil(maxColorVariation * 1.2)
789798
end
799+
color[1] = math.min(color[1] + brightnessVariation, 255) + math.random(-maxColorVariation, maxColorVariation)
800+
color[2] = math.min(color[2] + brightnessVariation, 255) + math.random(-maxColorVariation, maxColorVariation)
801+
color[3] = math.min(color[3] + brightnessVariation, 255) + math.random(-maxColorVariation, maxColorVariation)
802+
Spring.SetTeamColor(
803+
teamID,
804+
color[1] / 255,
805+
color[2] / 255,
806+
color[3] / 255
807+
)
790808

791809
else
792810
Spring.SetTeamColor(teamID, r, g, b)

0 commit comments

Comments
 (0)