1
0
mirror of https://github.com/veden/Rampant.git synced 2024-12-26 20:54:12 +02:00

f78b307: Bases remember mutation history with mod setting

This commit is contained in:
Aaron Veden 2023-01-16 12:28:40 -08:00
parent 6ac7083773
commit e3bf7f0efe
No known key found for this signature in database
GPG Key ID: FF5990B1C6DD3F84
7 changed files with 74 additions and 40 deletions

View File

@ -639,6 +639,7 @@ function upgrade.attempt(universe)
base.maxExpansionGroups = 0
base.sentExpansionGroups = 0
base.resetExpensionGroupsTick = 0
base.alignmentHistory = {}
end
for _,map in pairs(universe.maps) do

View File

@ -14,6 +14,7 @@ Version: 3.2.0
- Added long term death pheromone that overtime will cause chunks saturated in death to be avoided more frequently and settled less
- Added a mod setting to toggle the purple settler cloud
- When enemies die there body parts can fill in water tiles. Can be disabled in mod settings.
- Added base mutation history to prevent mutations to previously mutated factions. Configurable amount of history in Mod Settings.
Compatibility:
- Added interface for adding and removing excluded surfaces
Tweaks:
@ -47,6 +48,7 @@ Version: 3.2.0
- When the last player structure is destroyed on a chunk, the base pheromone is set to 0
- Fixed crash when walls or gates didn't have a resistence property with the add acid resistance to walls mod settings
- Fixed projectiles not being able to collide with spawner eggs and wasps
- Fixed bases being able to mutate to the same factions
Optimizations:
- Moved most constants out of global
- Removed new enemy variations setting

View File

@ -288,6 +288,8 @@ local function onModSettingsChange(event)
universe["AI_MAX_VANILLA_BUILDER_COUNT"] = universe["AI_MAX_BUILDER_COUNT"] * 0.65
universe["MAX_BASE_MUTATIONS"] = settings.global["rampant--max-base-mutations"].value
universe["MAX_BASE_ALIGNMENT_HISTORY"] = settings.global["rampant--maxBaseAlignmentHistory"].value
universe["initialPeaceTime"] = settings.global["rampant--initialPeaceTime"].value * TICKS_A_MINUTE
universe["printAwakenMessage"] = settings.global["rampant--printAwakenMessage"].value

View File

@ -204,8 +204,9 @@ local function processBase(universe, base, tick)
deathThreshold = universe.adaptationModifier * deathThreshold
if ((base.deathEvents > deathThreshold) and (universe.random() > 0.95)) then
if (base.mutations < universe.MAX_BASE_MUTATIONS) then
base.mutations = base.mutations + 1
upgradeBaseBasedOnDamage(universe, base)
if upgradeBaseBasedOnDamage(universe, base) then
base.mutations = base.mutations + 1
end
elseif (base.mutations == universe.MAX_BASE_MUTATIONS) then
local roll = universe.random()
if (roll < 0.001) then

View File

@ -73,6 +73,7 @@ local gaussianRandomRangeRG = mathUtils.gaussianRandomRangeRG
local mFloor = math.floor
local tableRemove = table.remove
local mMin = math.min
local mMax = math.max
@ -321,50 +322,58 @@ local function pickMutationFromDamageType(universe, damageType, roll, base)
if damageFactions and (#damageFactions > 0) then
mutation = damageFactions[universe.random(#damageFactions)]
if baseAlignment[2] then
if (baseAlignment[1] ~= mutation) and (baseAlignment[2] ~= mutation) then
if not isMember(mutation, base.alignmentHistory) then
if baseAlignment[2] then
if (baseAlignment[1] ~= mutation) and (baseAlignment[2] ~= mutation) then
mutated = true
if (roll < 0.05) then
base.alignmentHistory[#base.alignmentHistory+1] = baseAlignment[1]
base.alignmentHistory[#base.alignmentHistory+1] = baseAlignment[2]
baseAlignment[1] = mutation
baseAlignment[2] = nil
elseif (roll < 0.75) then
base.alignmentHistory[#base.alignmentHistory+1] = baseAlignment[1]
baseAlignment[1] = mutation
else
baseAlignment[2] = mutation
end
end
elseif (baseAlignment[1] ~= mutation) then
mutated = true
end
if (roll < 0.05) then
baseAlignment[1] = mutation
baseAlignment[2] = nil
elseif (roll < 0.25) then
baseAlignment[1] = mutation
else
baseAlignment[2] = mutation
end
else
if (baseAlignment[1] ~= mutation) then
mutated = true
end
if (roll < 0.85) then
baseAlignment[1] = mutation
else
baseAlignment[2] = mutation
if (roll < 0.85) then
base.alignmentHistory[#base.alignmentHistory+1] = baseAlignment[1]
baseAlignment[1] = mutation
else
baseAlignment[2] = mutation
end
end
end
else
mutation = findBaseMutation(universe)
if baseAlignment[2] then
if (baseAlignment[1] ~= mutation) and (baseAlignment[2] ~= mutation) then
if not isMember(mutation, base.alignmentHistory) then
if baseAlignment[2] then
if (baseAlignment[1] ~= mutation) and (baseAlignment[2] ~= mutation) then
mutated = true
if (roll < 0.05) then
base.alignmentHistory[#base.alignmentHistory+1] = baseAlignment[1]
base.alignmentHistory[#base.alignmentHistory+1] = baseAlignment[2]
baseAlignment[1] = mutation
baseAlignment[2] = nil
elseif (roll < 0.75) then
base.alignmentHistory[#base.alignmentHistory+1] = baseAlignment[1]
baseAlignment[1] = mutation
else
baseAlignment[2] = mutation
end
end
elseif (baseAlignment[1] ~= mutation) then
mutated = true
end
if (roll < 0.05) then
baseAlignment[2] = nil
baseAlignment[1] = mutation
elseif (roll < 0.25) then
baseAlignment[1] = mutation
else
baseAlignment[2] = mutation
end
else
if (baseAlignment[1] ~= mutation) then
mutated = true
end
if (roll < 0.85) then
base.alignment[1] = mutation
else
base.alignment[2] = mutation
if (roll < 0.85) then
base.alignmentHistory[#base.alignmentHistory+1] = baseAlignment[1]
base.alignment[1] = mutation
else
base.alignment[2] = mutation
end
end
end
end
@ -392,6 +401,11 @@ local function pickMutationFromDamageType(universe, damageType, roll, base)
universe.MAX_BASE_MUTATIONS})
end
end
local alignmentCount = table_size(base.alignmentHistory)
while (alignmentCount > universe.MAX_BASE_ALIGNMENT_HISTORY) do
tableRemove(base.alignmentHistory, 1)
alignmentCount = alignmentCount - 1
end
return mutated
end
@ -482,6 +496,7 @@ function baseUtils.createBase(map, chunk, tick)
distanceThreshold = distanceThreshold * universe.baseDistanceModifier,
tick = tick,
alignment = alignment,
alignmentHistory = {},
damagedBy = {},
deathEvents = 0,
mutations = 0,

View File

@ -78,6 +78,7 @@ spawner-proxy-3-rampant=Spawner Proxy
[entity-description]
[mod-setting-name]
rampant--maxBaseAlignmentHistory=World: Max Base Mutation History
rampant--enabledPurpleSettlerCloud=World: Enable Purple Cloud
rampant--minimumAdaptationEvolution=AI: Minimum Adaptation Evolution
rampant--printBaseSettling=AI: Print when settlers start building
@ -207,6 +208,7 @@ rampant--temperamentRateModifier=AI: Temperament Rate Modifier
rampant--enableLandfillOnDeath=World: Enemies fill water on death
[mod-setting-description]
rampant--maxBaseAlignmentHistory=The number of mutations that a base will remember. Remembered mutations cannot be mutated to again.
rampant--enableLandfillOnDeath=The body parts that are thrown off when dying will landfill water tiles. If Remove blood particles is enabled then this setting will not work.
rampant--enabledPurpleSettlerCloud=Toggle the purple cloud that spawns when a settler group starts building a nest.
rampant--minimumAdaptationEvolution=The minimum evolution that must be reached before bases will be begin to mutate. Only has an effect when Rampant New Enemies are enabled.

View File

@ -249,6 +249,17 @@ data:extend({
per_user = false
},
{
type = "int-setting",
name = "rampant--maxBaseAlignmentHistory",
setting_type = "runtime-global",
minimum_value = 0,
maximum_value = 16,
default_value = 16,
order = "d[modifier]-a[ai]",
per_user = false
},
{
type = "int-setting",
name = "rampant--initialPeaceTime",