diff --git a/changelog.txt b/changelog.txt index bf19034..ba6e8bf 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,7 @@ --------------------------------------------------------------------------------------------------- Version: 3.0.0 + Contributions: + - Added custom colors from ErdwurmJim Notes: - Will reset maps of in progress games. This means that all enemy units will be removed and new enemy faction mutations will be reset. Improvement: @@ -7,6 +9,7 @@ Version: 3.0.0 - AI is now per regional base - Regional bases now have there own aggressive and siege squad counter and cleanup process - Added beltlayer, pipelayer, and blueprint-sandboxes mod surfaces to surface exclusion list + - Added mod settings to customize factions colors Tweaks: - Added surface minime_dummy_dungeon and minime-preview-character to exclusion list - Increased unit spawner cooldown by 2x diff --git a/libs/Constants.lua b/libs/Constants.lua index fb8157e..0eced20 100644 --- a/libs/Constants.lua +++ b/libs/Constants.lua @@ -438,6 +438,37 @@ for tier=1, 10 do end end +local function hexToRGBA(hex) + local index = 1 + local a = {"r","g","b","a"} + local tint = {} + string.gsub( + hex, + "..", + function(cc) + tint[a[index]] = tonumber(cc, 16) / 255 + index = index+1 + end + ) + return tint +end + +local function convertHexPairs(hexPairString) + if #hexPairString ~= 17 then + error( + "Invalid rgba hex value for Rampant new enemy color, each color needs to have `rrggbbaa rrggbbaa`:" .. hexPairString + ) + end + local index = 1 + local a = {"tint", "tint2"} + local tints = {} + for hex in string.gmatch(hexPairString, "%x%x%x%x%x%x%x%x") do + tints[a[index]] = hexToRGBA(hex) + index = index + 1 + end + return tints +end + constants.FACTIONS_BY_DAMAGE_TYPE = { ["physical"] = { -- "physical", @@ -495,10 +526,11 @@ constants.FACTIONS_BY_DAMAGE_TYPE = { constants.FACTION_SET = {} +local neutralTints = convertHexPairs(settings.startup["rampant--neutralTints"].value) constants.FACTION_SET[#constants.FACTION_SET+1] = { type = "neutral", - tint = {r=0.9, g=0.9, b=0.9, a=1}, - tint2 = {r=1, g=1, b=1, a=1}, + tint = neutralTints.tint, + tint2 = neutralTints.tint2, acceptRate = {1, 7, 0.3, 0.1}, evo = 0, units = { @@ -579,10 +611,11 @@ if settings.startup["rampant--acidEnemy"].value then constants.FACTIONS_BY_DAMAGE_TYPE["poison"][#constants.FACTIONS_BY_DAMAGE_TYPE["poison"]+1] = "acid" constants.FACTIONS_BY_DAMAGE_TYPE["explosion"][#constants.FACTIONS_BY_DAMAGE_TYPE["explosion"]+1] = "acid" constants.FACTIONS_BY_DAMAGE_TYPE["acid"][#constants.FACTIONS_BY_DAMAGE_TYPE["acid"]+1] = "acid" + local acidTints = convertHexPairs(settings.startup["rampant--acidTints"].value) constants.FACTION_SET[#constants.FACTION_SET+1] = { type = "acid", - tint = {r=1, g=1, b=1, a=1}, - tint2 = {r=0.4, g=0.9, b=0.4, a=1}, + tint = acidTints.tint, + tint2 = acidTints.tint2, acceptRate = {1, 10, 0.1, 0.2}, evo = 0, units = { @@ -662,10 +695,11 @@ end if settings.startup["rampant--laserEnemy"].value then constants.FACTIONS_BY_DAMAGE_TYPE["laser"][#constants.FACTIONS_BY_DAMAGE_TYPE["laser"]+1] = "laser" constants.FACTIONS_BY_DAMAGE_TYPE["electric"][#constants.FACTIONS_BY_DAMAGE_TYPE["electric"]+1] = "laser" + local laserTints = convertHexPairs(settings.startup["rampant--laserTints"].value) constants.FACTION_SET[#constants.FACTION_SET+1] = { type = "laser", - tint = {r=0.3, g=0.3, b=0.42, a=1}, - tint2 = {r=0, g=1, b=1, a=1}, + tint = laserTints.tint, + tint2 = laserTints.tint2, acceptRate = {2, 10, 0.1, 0.15}, evo = 0.10, units = { @@ -739,10 +773,11 @@ end if settings.startup["rampant--fireEnemy"].value then constants.FACTIONS_BY_DAMAGE_TYPE["fire"][#constants.FACTIONS_BY_DAMAGE_TYPE["fire"]+1] = "fire" constants.FACTIONS_BY_DAMAGE_TYPE["acid"][#constants.FACTIONS_BY_DAMAGE_TYPE["acid"]+1] = "fire" + local fireTints = convertHexPairs(settings.startup["rampant--fireTints"].value) constants.FACTION_SET[#constants.FACTION_SET+1] = { type = "fire", - tint = {r=1, g=1, b=1, a=1}, - tint2 = {r=0.9, g=0.2, b=0.2, a=1}, + tint = fireTints.tint, + tint2 = fireTints.tint2, acceptRate = {2, 10, 0.1, 0.15}, evo = 0.12, units = { @@ -822,10 +857,11 @@ end if settings.startup["rampant--infernoEnemy"].value then constants.FACTIONS_BY_DAMAGE_TYPE["fire"][#constants.FACTIONS_BY_DAMAGE_TYPE["fire"]+1] = "inferno" constants.FACTIONS_BY_DAMAGE_TYPE["acid"][#constants.FACTIONS_BY_DAMAGE_TYPE["acid"]+1] = "inferno" + local infernoTints = convertHexPairs(settings.startup["rampant--infernoTints"].value) constants.FACTION_SET[#constants.FACTION_SET+1] = { type = "inferno", - tint = {r=0.5, g=0.1, b=0.1, a=1}, - tint2 = {r=0.9, g=0.1, b=0.1, a=1}, + tint = infernoTints.tint, + tint2 = infernoTints.tint2, acceptRate = {3, 10, 0.1, 0.125}, evo = 0.2, units = { @@ -883,10 +919,11 @@ end if settings.startup["rampant--waspEnemy"].value then constants.FACTIONS_BY_DAMAGE_TYPE["laser"][#constants.FACTIONS_BY_DAMAGE_TYPE["laser"]+1] = "wasp" constants.FACTIONS_BY_DAMAGE_TYPE["electric"][#constants.FACTIONS_BY_DAMAGE_TYPE["electric"]+1] = "wasp" + local waspTints = convertHexPairs(settings.startup["rampant--waspTints"].value) constants.FACTION_SET[#constants.FACTION_SET+1] = { type = "wasp", - tint = {r=1, g=1, b=0, a=1}, - tint2 = {r=0, g=0, b=0, a=1}, + tint = waspTints.tint, + tint2 = waspTints.tint2, acceptRate = {3, 10, 0.1, 0.125}, evo = 0.2, units = { @@ -952,10 +989,11 @@ if settings.startup["rampant--spawnerEnemy"].value then constants.FACTIONS_BY_DAMAGE_TYPE["electric"][#constants.FACTIONS_BY_DAMAGE_TYPE["electric"]+1] = "spawner" constants.FACTIONS_BY_DAMAGE_TYPE["impact"][#constants.FACTIONS_BY_DAMAGE_TYPE["impact"]+1] = "spawner" constants.FACTIONS_BY_DAMAGE_TYPE["physical"][#constants.FACTIONS_BY_DAMAGE_TYPE["physical"]+1] = "spawner" + local spawnerTints = convertHexPairs(settings.startup["rampant--spawnerTints"].value) constants.FACTION_SET[#constants.FACTION_SET+1] = { type = "spawner", - tint = {r=0.7, g=0.1, b=0.7, a=1}, - tint2 = {r=1, g=0.4, b=1, a=1}, + tint = spawnerTints.tint, + tint2 = spawnerTints.tint2, acceptRate = {3, 10, 0.1, 0.125}, evo = 0.2, units = { @@ -1026,10 +1064,11 @@ end if settings.startup["rampant--electricEnemy"].value then constants.FACTIONS_BY_DAMAGE_TYPE["laser"][#constants.FACTIONS_BY_DAMAGE_TYPE["laser"]+1] = "electric" constants.FACTIONS_BY_DAMAGE_TYPE["electric"][#constants.FACTIONS_BY_DAMAGE_TYPE["electric"]+1] = "electric" + local electricTints = convertHexPairs(settings.startup["rampant--electricTints"].value) constants.FACTION_SET[#constants.FACTION_SET+1] = { type = "electric", - tint = {r=0.7, g=0.7, b=1.0, a=1}, - tint2 = {r=0.2, g=0.2, b=1, a=1}, + tint = electricTints.tint, + tint2 = electricTints.tint2, acceptRate = {2, 10, 0.1, 0.15}, evo = 0.1, units = { @@ -1088,10 +1127,11 @@ if settings.startup["rampant--physicalEnemy"].value then constants.FACTIONS_BY_DAMAGE_TYPE["physical"][#constants.FACTIONS_BY_DAMAGE_TYPE["physical"]+1] = "physical" constants.FACTIONS_BY_DAMAGE_TYPE["impact"][#constants.FACTIONS_BY_DAMAGE_TYPE["impact"]+1] = "physical" constants.FACTIONS_BY_DAMAGE_TYPE["explosion"][#constants.FACTIONS_BY_DAMAGE_TYPE["explosion"]+1] = "physical" + local physicalTints = convertHexPairs(settings.startup["rampant--physicalTints"].value) constants.FACTION_SET[#constants.FACTION_SET+1] = { type = "physical", - tint = {r=0.9, g=0.9, b=0.9, a=1}, - tint2 = {r=0.8, g=0.8, b=0.8, a=1}, + tint = physicalTints.tint, + tint2 = physicalTints.tint2, acceptRate = {2, 10, 0.1, 0.15}, evo = 0.12, units = { @@ -1150,10 +1190,11 @@ if settings.startup["rampant--trollEnemy"].value then constants.FACTIONS_BY_DAMAGE_TYPE["physical"][#constants.FACTIONS_BY_DAMAGE_TYPE["physical"]+1] = "troll" constants.FACTIONS_BY_DAMAGE_TYPE["impact"][#constants.FACTIONS_BY_DAMAGE_TYPE["impact"]+1] = "troll" constants.FACTIONS_BY_DAMAGE_TYPE["explosion"][#constants.FACTIONS_BY_DAMAGE_TYPE["explosion"]+1] = "troll" + local trollTints = convertHexPairs(settings.startup["rampant--trollTints"].value) constants.FACTION_SET[#constants.FACTION_SET+1] = { type = "troll", - tint = {r=0.4, g=0.4, b=0.4, a=1}, - tint2 = {r=1, g=0.2, b=0.2, a=1}, + tint = trollTints.tint, + tint2 = trollTints.tint2, acceptRate = {3, 10, 0.1, 0.125}, evo = 0.17, units = { @@ -1213,10 +1254,11 @@ if settings.startup["rampant--poisonEnemy"].value then constants.FACTIONS_BY_DAMAGE_TYPE["fire"][#constants.FACTIONS_BY_DAMAGE_TYPE["fire"]+1] = "poison" constants.FACTIONS_BY_DAMAGE_TYPE["acid"][#constants.FACTIONS_BY_DAMAGE_TYPE["acid"]+1] = "poison" constants.FACTIONS_BY_DAMAGE_TYPE["poison"][#constants.FACTIONS_BY_DAMAGE_TYPE["poison"]+1] = "poison" + local poisonTints = convertHexPairs(settings.startup["rampant--poisonTints"].value) constants.FACTION_SET[#constants.FACTION_SET+1] = { type = "poison", - tint = {r=0.4, g=0.6, b=0.5, a=1}, - tint2 = {r=0, g=0.7, b=0, a=1}, + tint = poisonTints.tint, + tint2 = poisonTints.tint2, acceptRate = {2, 10, 0.1, 0.15}, evo = 0.17, units = { @@ -1278,10 +1320,11 @@ end if settings.startup["rampant--suicideEnemy"].value then constants.FACTIONS_BY_DAMAGE_TYPE["impact"][#constants.FACTIONS_BY_DAMAGE_TYPE["impact"]+1] = "suicide" constants.FACTIONS_BY_DAMAGE_TYPE["poison"][#constants.FACTIONS_BY_DAMAGE_TYPE["poison"]+1] = "suicide" + local suicideTints = convertHexPairs(settings.startup["rampant--suicideTints"].value) constants.FACTION_SET[#constants.FACTION_SET+1] = { type = "suicide", - tint = {r=0.8, g=0.8, b=0.8, a=1}, - tint2 = {r=1, g=0.5, b=0, a=1}, + tint = suicideTints.tint, + tint2 = suicideTints.tint2, acceptRate = {2, 10, 0.05, 0.15}, evo = 0.35, units = { @@ -1339,10 +1382,11 @@ end if settings.startup["rampant--nuclearEnemy"].value then constants.FACTIONS_BY_DAMAGE_TYPE["impact"][#constants.FACTIONS_BY_DAMAGE_TYPE["impact"]+1] = "nuclear" constants.FACTIONS_BY_DAMAGE_TYPE["poison"][#constants.FACTIONS_BY_DAMAGE_TYPE["poison"]+1] = "nuclear" + local nuclearTints = convertHexPairs(settings.startup["rampant--nuclearTints"].value) constants.FACTION_SET[#constants.FACTION_SET+1] = { type = "nuclear", - tint = {r=0.1, g=0.95, b=0.1, a=1}, - tint2 = {r=1, g=0.5, b=0, a=1}, + tint = nuclearTints.tint, + tint2 = nuclearTints.tint2, acceptRate = {4, 10, 0.1, 0.125}, evo = 0.45, units = { @@ -1399,10 +1443,11 @@ end if settings.startup["rampant--energyThiefEnemy"].value then constants.FACTIONS_BY_DAMAGE_TYPE["laser"][#constants.FACTIONS_BY_DAMAGE_TYPE["laser"]+1] = "energy-thief" constants.FACTIONS_BY_DAMAGE_TYPE["electric"][#constants.FACTIONS_BY_DAMAGE_TYPE["electric"]+1] = "energy-thief" + local energyThiefTints = convertHexPairs(settings.startup["rampant--energyThiefTints"].value) constants.FACTION_SET[#constants.FACTION_SET+1] = { type = "energy-thief", - tint = {r=0.2, g=0.2, b=0.4, a=1}, - tint2 = {r=0.1, g=0.1, b=0.1, a=1}, + tint = energyThiefTints.tint, + tint2 = energyThiefTints.tint2, acceptRate = {3, 10, 0.1, 0.125}, evo = 0.2, units = { @@ -1460,10 +1505,11 @@ if settings.startup["rampant--fastEnemy"].value then constants.FACTIONS_BY_DAMAGE_TYPE["physical"][#constants.FACTIONS_BY_DAMAGE_TYPE["physical"]+1] = "fast" constants.FACTIONS_BY_DAMAGE_TYPE["explosion"][#constants.FACTIONS_BY_DAMAGE_TYPE["explosion"]+1] = "fast" constants.FACTIONS_BY_DAMAGE_TYPE["fire"][#constants.FACTIONS_BY_DAMAGE_TYPE["fire"]+1] = "fast" + local fastTints = convertHexPairs(settings.startup["rampant--fastTints"].value) constants.FACTION_SET[#constants.FACTION_SET+1] = { type = "fast", - tint = {r=0.9, g=0.9, b=0.9, a=1}, - tint2 = {r=1, g=1, b=0.1, a=1}, + tint = fastTints.tint, + tint2 = fastTints.tint2, acceptRate = {2, 10, 0.1, 0.15}, evo = 0.12, units = { diff --git a/locale/en/locale.cfg b/locale/en/locale.cfg index d90f597..d5c1b1e 100644 --- a/locale/en/locale.cfg +++ b/locale/en/locale.cfg @@ -18891,6 +18891,22 @@ rampant--acidEnemy=World: Acidic Biter Faction rampant--energyThiefEnemy=World: Sapper Biter Faction rampant--poisonEnemy=World: Poison Biter Faction +rampant--neutralTints=World: Neutral Biter Faction Colors +rampant--laserTints=World: Laser Biter Faction Colors +rampant--waspTints=World: Wasp Biter Faction Colors +rampant--spawnerTints=World: Spawner Biter Faction Colors +rampant--trollTints=World: Regenerative Biter Faction Colors +rampant--fastTints=World: Fast Biter Faction Colors +rampant--infernoTints=World: Inferno Biter Faction Colors +rampant--nuclearTints=World: Nuclear Biter Faction Colors +rampant--electricTints=World: Electric Biter Faction Colors +rampant--fireTints=World: Fire Biter Faction Colors +rampant--suicideTints=World: Suicide Biter Faction Colors +rampant--physicalTints=World: Brutal Biter Faction Colors +rampant--acidTints=World: Acidic Biter Faction Colors +rampant--energyThiefTints=World: Sapper Biter Faction Colors +rampant--poisonTints=World: Poison Biter Faction Colors + rampant--disableCollidingProjectiles=Projectiles: Non biter force colliding projectiles rampant--enableFullMapScan=Compatibility: Enable full map scanning rampant--unitAndSpawnerFadeTime=Biter, Spitter, Worm, Nest, and Hive Corpse Fade Time @@ -18995,6 +19011,22 @@ rampant--acidEnemy=Acid Biter Faction, Major resistance to Acid, Minor resistanc rampant--energyThiefEnemy=Sapper Biter Faction, Major resistance to Electric, Minor resistance to Laser. Destroying powered structures creates draining crystals. rampant--poisonEnemy=Poison Biter Faction, Only Biters. On death creates a cloud that heals biters and hurts player objects. Major resistance to Poison, Minor weakness to Electric, Minor weakness to Explosive, Minor weakness to Laser, Minor resistance to Fire. +rampant--neutralTints=Both colors should have 8 hex characters rrggbbaa +rampant--laserTints=Both colors should have 8 hex characters rrggbbaa +rampant--waspTints=Both colors should have 8 hex characters rrggbbaa +rampant--spawnerTints=Both colors should have 8 hex characters rrggbbaa +rampant--trollTints=Both colors should have 8 hex characters rrggbbaa +rampant--fastTints=Both colors should have 8 hex characters rrggbbaa +rampant--infernoTints=Both colors should have 8 hex characters rrggbbaa +rampant--nuclearTints=Both colors should have 8 hex characters rrggbbaa +rampant--electricTints=Both colors should have 8 hex characters rrggbbaa +rampant--fireTints=Both colors should have 8 hex characters rrggbbaa +rampant--suicideTints=Both colors should have 8 hex characters rrggbbaa +rampant--physicalTints=Both colors should have 8 hex characters rrggbbaa +rampant--acidTints=Both colors should have 8 hex characters rrggbbaa +rampant--energyThiefTints=Both colors should have 8 hex characters rrggbbaa +rampant--poisonTints=Both colors should have 8 hex characters rrggbbaa + rampant--disableCollidingProjectiles=Biter projectiles no longer collide with other biters, worms or nests. Everything else still collides with biter projectiles. rampant--enableFullMapScan=This setting causes the game map to slowly be scanned for entities created or destroyed outside of the factorio event system. (If a mod isnt using script_raised_built or script_raised_destroyed this will cause Rampant to still eventually be consistent with the game map) diff --git a/settings.lua b/settings.lua index 1f568e6..e423125 100644 --- a/settings.lua +++ b/settings.lua @@ -13,7 +13,6 @@ -- You should have received a copy of the GNU General Public License -- along with this program. If not, see . - data:extend({ { @@ -943,7 +942,6 @@ data:extend({ per_user = false }, - { type = "double-setting", name = "rampant--unitHiveRespawnScaler", @@ -1001,3 +999,140 @@ data:extend({ } }) + +-- Converts the RGBA struct to Hexadecimal discarding the alpha value. +-- Since the RGBA struct stores values as percent (0-1) and not actual RGB (0-255) there might be precision errors when converting. +local function rgbaToHex(rgba) + local r = string.format("%x", rgba.r * 255) + local g = string.format("%x", rgba.g * 255) + local b = string.format("%x", rgba.b * 255) + local a = string.format("%x", rgba.a * 255) + if #r == 1 then + r = "0"..r + end + if #g == 1 then + g = "0"..g + end + if #b == 1 then + b = "0"..b + end + if #a == 1 then + a = "0"..a + end + return r..g..b..a +end + +-- Sets the default value of the faction tint settings. +-- Change this function if the formating of the tint settings changes. +local function setDefaultValue(tint, tint2) + return rgbaToHex(tint) .. " " .. rgbaToHex(tint2) +end + +local FACTIONS = { + { + -- Neutral faction + type = "neutral", + tint = {r = 0.90, g = 0.90, b = 0.90, a = 1}, + tint2 = {r = 1, g = 1, b = 1, a = 1} + }, + { + -- Acidic faction + type = "acid", + tint = {r = 1, g = 1, b = 1, a = 1}, + tint2 = {r = 0.40, g = 0.90, b = 0.40, a = 1} + }, + { + -- Laser faction + type = "laser", + tint = {r = 0.60, g = 0.60, b = 0.84, a = 1}, + tint2 = {r = 0.60, g = 0.60, b = 0.84, a = 1} + }, + { + -- Fire faction + type = "fire", + tint = {r = 1, g = 1, b = 1, a = 1}, + tint2 = {r = 0.90, g = 0.20, b = 0.20, a = 1} + }, + { + -- Inferno faction + type = "inferno", + tint = {r = 0.90, g = 0.75, b = 0.75, a = 1}, + tint2 = {r = 0.70, g = 0.30, b = 0.30, a = 1} + }, + { + -- Wasp faction + type = "wasp", + tint = {r = 1, g = 1, b = 0.70, a = 1}, + tint2 = {r = 0.50, g = 0.50, b = 0, a = 1} + }, + { + -- Spawner faction + type = "spawner", + tint = {r = 1, g = 0.80, b = 1, a = 1}, + tint2 = {r = 0.90, g = 0.30, b = 0.90, a = 1} + }, + { + -- Electric faction + type = "electric", + tint = {r = 0.80, g = 0.80, b = 1, a = 1}, + tint2 = {r = 0.30, g = 0.30, b = 1, a = 1} + }, + { + -- Brutal faction + type = "physical", + tint = {r = 0.90, g = 0.90, b = 0.90, a = 1}, + tint2 = {r = 0.80, g = 0.80, b = 0.80, a = 1} + }, + { + -- Regenerative faction + type = "troll", + tint = {r = 0.55, g = 0.55, b = 0.55, a = 1}, + tint2 = {r = 1, g = 0.30, b = 0.30, a = 1} + }, + { + -- Poison faction + type = "poison", + tint = {r = 0.50, g = 0.70, b = 0.60, a = 1}, + tint2 = {r = 0.30, g = 0.90, b = 0.30, a = 1} + }, + { + -- Suicide faction + type = "suicide", + tint = {r = 0.80, g = 0.80, b = 0.80, a = 1}, + tint2 = {r = 1, g = 0.50, b = 0, a = 1} + }, + { + -- Nuclear faction + type = "nuclear", + tint = {r = 0.10, g = 0.95, b = 0.10, a = 1}, + tint2 = {r = 1, g = 0.50, b = 0, a = 1} + }, + { + -- Sapper faction + type = "energyThief", + tint = {r = 0.50, g = 0.50, b = 0.70, a = 1}, + tint2 = {r = 0.40, g = 0.40, b = 0.40, a = 1} + }, + { + -- Fast faction + type = "fast", + tint = {r = 0.90, g = 0.90, b = 0.90, a = 1}, + tint2 = {r = 1, g = 1, b = 0.10, a = 1} + } +} + +for i = 1, #FACTIONS do + local entry = FACTIONS[i] + local setting = "rampant--" .. entry.type .. "Tints" + + data:extend({ + { + type = "string-setting", + name = setting, + description = setting, + setting_type = "startup", + default_value = setDefaultValue(entry.tint, entry.tint2), + order = "p[modifier]-r[zzunit]", + }, + }) +end