1
0
mirror of https://github.com/veden/Rampant.git synced 2025-03-17 20:58:35 +02:00

finished adaptive behavior

This commit is contained in:
Aaron Veden 2021-07-24 18:20:13 -07:00
parent 5450359cfe
commit 16986e5f09
No known key found for this signature in database
GPG Key ID: FF5990B1C6DD3F84
8 changed files with 95 additions and 39 deletions

View File

@ -1,9 +1,12 @@
# Rampant Tactics
Factorio Mod - Improves the enemies tactics by using potential fields/pheromones allowing probing of defenses, retreats, reinforcements, counterattacking, breaching, raids, rallying death cry, and player hunting. Uses nonhoming blockable biter projectiles. Adds new Enemies (disabled by default). Difficulty setting in mod options menu.
# Forum Post
# Site
https://mod.factorio.com/veden/Rampant
# Forum Post
https://forums.factorio.com/viewtopic.php?f=94&t=31445
# Notes

View File

@ -1,3 +1,11 @@
---------------------------------------------------------------------------------------------------
Version: 1.1.2
Date: 24. 07. 2021
Features:
- Rampant new enemies now adapt to the damage type they are killed with
Tweaks:
- Reduced default max number of active squads to 25 and active builders to 10
---------------------------------------------------------------------------------------------------
Version: 1.1.1
Date: 02. 05. 2021

View File

@ -480,10 +480,11 @@ local function onDeath(event)
if group then
local damageType = event.damage_type
local squad = map.groupNumberToSquad[group.group_number]
if squad then
if damageType and squad then
local base = squad.base
if base then
base.damagedBy[damageType] = (base.damagedBy[damageType] or 0) + 0.01
local damageTypeName = damageType.name
base.damagedBy[damageTypeName] = (base.damagedBy[damageTypeName] or 0) + 0.01
base.deathEvents = base.deathEvents + 1
end
end

View File

@ -6,5 +6,5 @@
"author" : "Veden",
"homepage" : "https://forums.factorio.com/viewtopic.php?f=94&t=31445",
"description" : "Improves the enemies tactics by using potential fields (pheromones) allowing probing of defenses, retreats, reinforcements, counterattacking, breaching, raids, rallying death cry, and player hunting. Uses blockable biter projectiles. Adds new Enemies (disabled by default). Difficulty setting in mod options menu.",
"dependencies" : ["base >= 1.1.0", "? bobenemies", "? Natural_Evolution_Enemies >= 0.17.0", "? Clockwork", "? Orbital Ion Cannon", "? ArmouredBiters", "? Krastorio2"]
"dependencies" : ["base >= 1.1.36", "? bobenemies", "? Natural_Evolution_Enemies >= 0.17.0", "? Clockwork", "? Kux-OrbitalIonCannon", "? Orbital Ion Cannon", "? ArmouredBiters", "? Krastorio2"]
}

View File

@ -310,27 +310,27 @@ function baseUtils.upgradeEntity(entity, baseAlignment, map, disPos, evolve)
return entity
end
local function upgradeBase(map, base)
local baseAlignment = base.alignment
-- local function upgradeBase(map, base)
-- local baseAlignment = base.alignment
local roll = mRandom()
if baseAlignment[2] then
if (roll < 0.05) then
baseAlignment[2] = nil
baseAlignment[1] = findBaseMutation(map)
elseif (roll < 0.25) then
baseAlignment[1] = findBaseMutation(map)
else
baseAlignment[2] = findBaseMutation(map)
end
else
if (roll < 0.85) then
base.alignment[1] = findBaseMutation(map)
else
base.alignment[2] = findBaseMutation(map)
end
end
end
-- local roll = mRandom()
-- if baseAlignment[2] then
-- if (roll < 0.05) then
-- baseAlignment[2] = nil
-- baseAlignment[1] = findBaseMutation(map)
-- elseif (roll < 0.25) then
-- baseAlignment[1] = findBaseMutation(map)
-- else
-- baseAlignment[2] = findBaseMutation(map)
-- end
-- else
-- if (roll < 0.85) then
-- base.alignment[1] = findBaseMutation(map)
-- else
-- base.alignment[2] = findBaseMutation(map)
-- end
-- end
-- end
local function pickMutationFromDamageType(map, damageType, roll, base)
local baseAlignment = base.alignment
@ -381,13 +381,16 @@ local function upgradeBaseBasedOnDamage(map, base)
for _,amount in pairs(base.damagedBy) do
total = total + amount
end
local mutationAmount = total * 0.15
local mutationAmount = total * 0.176471
base.damagedBy["mutation"] = mutationAmount
total = total + mutationAmount
local pickedDamage
local roll = mRandom()
for damageTypeName,amount in pairs(base.damagedBy) do
base.damagedBy[damageTypeName] = amount / total
end
for damageType,amount in pairs(base.damagedBy) do
if (roll - (amount / total) < 0) then
if (roll - (amount / total) <= 0) then
pickedDamage = damageType
break
end
@ -425,7 +428,18 @@ function baseUtils.processBase(chunk, map, tick, base)
end
end
if ((upgradeRoll > 0.95) and (base.deathEvents > 3000)) then
local deathThreshold
if (map.evolutionLevel < 0.5) then
deathThreshold = 1
elseif (map.evolutionLevel < 0.7) then
deathThreshold = 4500
elseif (map.evolutionLevel < 0.9) then
deathThreshold = 6000
else
deathThreshold = 7500
end
if ((base.deathEvents > deathThreshold) and (upgradeRoll > 0.95)) then
upgradeBaseBasedOnDamage(map, base)
base.damagedBy = {}
base.deathEvents = 0
@ -490,6 +504,7 @@ function baseUtils.createBase(map, chunk, tick, rebuilding)
alignment = alignment,
state = BASE_AI_STATE_ACTIVE,
damagedBy = {},
deathEvents = 0,
stateTick = 0,
createdTick = tick,
points = 0,

View File

@ -516,8 +516,9 @@ function chunkUtils.unregisterEnemyBaseStructure(map, entity, damageType)
local count = getFunc(map, chunk)
if count then
local base = getChunkBase(map, chunk)
if base then
base.damagedBy[damageType] = (base.damagedBy[damageType] or 0) + 1
if damageType and base then
local damageTypeName = damageType.name
base.damagedBy[damageTypeName] = (base.damagedBy[damageTypeName] or 0) + 3
base.deathEvents = base.deathEvents + 3
end
if (count <= 1) then

View File

@ -474,28 +474,56 @@ end
constants.FACTIONS_BY_DAMAGE_TYPE = {
["physical"] = {
"physical",
"troll",
"acid",
"fast",
"spawner"
},
["impact"] = {
"nuclear",
"suicide",
"spawner",
"physical",
"troll"
},
["poison"] = {
"poison",
"suicide",
"nuclear",
"acid"
},
["explosion"] = {
"fast",
"troll",
"physical",
"acid"
},
["fire"] = {
"fire",
"inferno",
"poison",
"fast"
},
["laser"] = {
"laser",
"energy-thief",
"electric",
"wasp",
"spawner"
},
["acid"] = {
"acid",
"inferno",
"fire",
"poison"
},
["electric"] = {
"laser",
"energy-thief",
"electric",
"wasp",
"spawner"
}
}

View File

@ -54,7 +54,7 @@ data:extend({
setting_type = "runtime-global",
minimum_value = 1,
maximum_value = 300,
default_value = 50,
default_value = 25,
order = "b[modifier]-f[wave]",
per_user = false
},
@ -65,7 +65,7 @@ data:extend({
setting_type = "runtime-global",
minimum_value = 1,
maximum_value = 120,
default_value = 35,
default_value = 10,
order = "b[modifier]-f[wave]",
per_user = false
},