Skip to content

Commit c146508

Browse files
authored
Force Simple Teamcolors in Huge Games (#4223)
- Simple Teamcolors will be force enabled when the teams sizes grow above available palette of colors - Added a modoption to force enable or force disable this behaviour regardless of team sizes
1 parent 1c4c060 commit c146508

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

luarules/gadgets/game_autocolors.lua

+13-3
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,9 @@ if gadgetHandler:IsSyncedCode() then
432432
Spring.SetTeamRulesParam(teamID, "AutoTeamColorBlue", hex2RGB(gaiaGrayColor)[3])
433433
elseif isSurvival then
434434
if not survivalColors[survivalColorNum] then -- If we have no color for this team anymore
435+
if Spring.GetModOptions().teamcolors_forcesimple == "bigteamsonly" then
436+
Spring.SetGameRulesParam("ForcedSimpleColors", 1)
437+
end
435438
survivalColorNum = 1 -- Starting from the first color again..
436439
survivalColorVariation = survivalColorVariation + colorVariationDelta -- ..but adding random color variations with increasing amplitude with every cycle
437440
end
@@ -458,6 +461,9 @@ if gadgetHandler:IsSyncedCode() then
458461
survivalColorNum = survivalColorNum + 1 -- Will start from the next color next time
459462
elseif useFFAColors then
460463
if not ffaColors[ffaColorNum] then -- If we have no color for this team anymore
464+
if Spring.GetModOptions().teamcolors_forcesimple == "bigteamsonly" then
465+
Spring.SetGameRulesParam("ForcedSimpleColors", 1)
466+
end
461467
ffaColorNum = 1 -- Starting from the first color again..
462468
ffaColorVariation = ffaColorVariation + colorVariationDelta -- ..but adding random color variations with increasing amplitude with every cycle
463469
end
@@ -489,6 +495,9 @@ if gadgetHandler:IsSyncedCode() then
489495
and teamColors[allyTeamCount][teamSizes[allyTeamID][1]]
490496
then -- And this team number exists in the color set
491497
if not teamColors[allyTeamCount][teamSizes[allyTeamID][1]][teamSizes[allyTeamID][2]] then -- If we have no color for this player anymore
498+
if Spring.GetModOptions().teamcolors_forcesimple == "bigteamsonly" then
499+
Spring.SetGameRulesParam("ForcedSimpleColors", 1)
500+
end
492501
teamSizes[allyTeamID][2] = 1 -- Starting from the first color again..
493502
teamSizes[allyTeamID][3] = teamSizes[allyTeamID][3] + colorVariationDelta -- ..but adding random color variations with increasing amplitude with every cycle
494503
end
@@ -545,6 +554,7 @@ else -- UNSYNCED
545554
local myPlayerID = Spring.GetLocalPlayerID()
546555
local mySpecState = Spring.GetSpectatingState()
547556
local teamColorsTable = {}
557+
ForcedSimpleColors = Spring.GetModOptions().teamcolors_forcesimple == "alwaysenabled" or (Spring.GetGameRulesParam("ForcedSimpleColors") and Spring.GetGameRulesParam("ForcedSimpleColors") == 1)
548558

549559
local function setUpLocalTeamColor(teamID, allyTeamID, isAI)
550560
if anonymousMode ~= "disabled" and anonymousMode ~= "global" then
@@ -732,7 +742,7 @@ else -- UNSYNCED
732742
hex2RGB(iconDevModeColor)[3] / 255
733743
)
734744
elseif
735-
Spring.GetConfigInt("SimpleTeamColors", 0) == 1 or (anonymousMode == "allred" and not mySpecState)
745+
Spring.GetConfigInt("SimpleTeamColors", 0) == 1 or (anonymousMode == "allred" and not mySpecState) or ForcedSimpleColors == true
736746
then
737747
local allyTeamID = select(6, Spring.GetTeamInfo(teamID))
738748
if teamID == myTeamID then
@@ -749,7 +759,7 @@ else -- UNSYNCED
749759
next_team_brightness_offset * Spring.GetConfigInt("SimpleTeamColorsAllyG", 255) / 255,
750760
next_team_brightness_offset * Spring.GetConfigInt("SimpleTeamColorsAllyB", 0) / 255
751761
)
752-
if Spring.GetConfigInt("SimpleTeamColorsUseGradient", 0) == 1 and anonymousMode ~= "allred" then
762+
if (Spring.GetConfigInt("SimpleTeamColorsUseGradient", 0) == 1 or ForcedSimpleColors == true) and anonymousMode ~= "allred" then
753763
next_team_brightness_offset = dimming_factor * next_team_brightness_offset
754764
end
755765
elseif allyTeamID ~= myAllyTeamID and teamID ~= gaiaTeamID then
@@ -759,7 +769,7 @@ else -- UNSYNCED
759769
next_opponent_brightness_offset * Spring.GetConfigInt("SimpleTeamColorsEnemyG", 16) / 255,
760770
next_opponent_brightness_offset * Spring.GetConfigInt("SimpleTeamColorsEnemyB", 5) / 255
761771
)
762-
if Spring.GetConfigInt("SimpleTeamColorsUseGradient", 0) == 1 and anonymousMode ~= "allred" then
772+
if (Spring.GetConfigInt("SimpleTeamColorsUseGradient", 0) == 1 or ForcedSimpleColors == true) and anonymousMode ~= "allred" then
763773
next_opponent_brightness_offset = dimming_factor * next_opponent_brightness_offset
764774
end
765775
else

modoptions.lua

+14
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,20 @@ local options = {
161161
},
162162
},
163163

164+
{
165+
key = "teamcolors_forcesimple",
166+
name = "Force Simple Teamcolors",
167+
desc = "Forces Simple Teamcolors for everyone in the match, to make it easier to tell who is in which team in bigger than normal matches.",
168+
type = "list",
169+
section = "options_main",
170+
def = "bigteamsonly",
171+
items = {
172+
{ key = "disabled", name = "Always Disabled" },
173+
{ key = "alwaysenabled", name = "Always Enabled"},
174+
{ key = "bigteamsonly", name = "Enabled in Huge Matches", desc = "Only Enabled when there's not enough colors in the palette" },
175+
},
176+
},
177+
164178
{
165179
key = "transportenemy",
166180
name = "Enemy Transporting",

0 commit comments

Comments
 (0)