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

see changelog

This commit is contained in:
Aaron Veden 2020-10-18 20:33:01 -07:00
parent d32a50005b
commit 1ab917e416
No known key found for this signature in database
GPG Key ID: FF5990B1C6DD3F84
12 changed files with 204 additions and 138 deletions

View File

@ -1,9 +1,23 @@
---------------------------------------------------------------------------------------------------
Version: 1.0.0
Date: 06. 09. 2020
Date: 18. 10. 2020
Improvements:
- Added spawner creep from vanilla to Rampant spawners and worms
- Added nuclear biters atomic shockwave
- Added corpse expiration time setting in mod settings
Tweaks:
- Increased active raid nest contribution to AI temperament to 0.0075
- Reduced destroyed player buildings effect on AI temperament to 5
- Reduced destroyed enemy buildings effect on AI temperament to 5
- Increased minimum logic cycle contribution change to AI temperament to 10%
- Increased units to spawn around new enemy spawners by 6 and units owned by 2
- Added caching to goto_location command
Bugfixes:
- Missing EN locale for acid pool on vanilla worm and spitter attack
- Temporary unit group size check on build command to prevent infinite loop until factorio 1.1 is released
- Fixed mod settings ordering for hive settings
Optimizations:
- Removed ai command completed event as cost was too high
---------------------------------------------------------------------------------------------------
Version: 0.18.17

View File

@ -162,7 +162,7 @@ local makeImmortalEntity = chunkUtils.makeImmortalEntity
local registerResource = chunkUtils.registerResource
local unregisterResource = chunkUtils.unregisterResource
local cleanSquads = unitGroupUtils.cleanSquads
local cleanSquads = squadAttack.cleanSquads
local upgradeEntity = baseUtils.upgradeEntity
local rebuildNativeTables = baseUtils.rebuildNativeTables
@ -449,7 +449,7 @@ local function rebuildMap()
map.moveCommand = {
type = DEFINES_COMMAND_GO_TO_LOCATION,
destination = map.position,
pathfind_flags = { cache = false },
pathfind_flags = { cache = true },
distraction = DEFINES_DISTRACTION_BY_ENEMY
}
@ -463,15 +463,15 @@ local function rebuildMap()
map.wonderCommand = {
type = DEFINES_COMMAND_WANDER,
wander_in_group = false,
radius = TRIPLE_CHUNK_SIZE,
ticks_to_wait = 3600
radius = TRIPLE_CHUNK_SIZE*2,
ticks_to_wait = 36000
}
map.wonder2Command = {
type = DEFINES_COMMAND_WANDER,
wander_in_group = false,
radius = TRIPLE_CHUNK_SIZE,
ticks_to_wait = 360
ticks_to_wait = 36000
}
map.wonder3Command = {
@ -479,7 +479,7 @@ local function rebuildMap()
wander_in_group = true,
radius = TRIPLE_CHUNK_SIZE,
distraction = DEFINES_DISTRACTION_BY_ANYTHING,
ticks_to_wait = 60 * 30
ticks_to_wait = 36000
}
map.stopCommand = {
@ -557,9 +557,10 @@ end
local function onModSettingsChange(event)
if event and ((string.sub(event.setting, 1, 7) ~= "rampant") or
(string.sub(event.setting, 1, 15) == "rampant-arsenal") or
(string.sub(event.setting, 1, 17) == "rampant-resources") or
(string.sub(event.setting, 1, 17) == "rampant-evolution"))
(string.sub(event.setting, 1, 15) == "rampant-arsenal") or
(string.sub(event.setting, 1, 17) == "rampant-resources") or
(string.sub(event.setting, 1, 17) == "rampant-evolution") or
(string.sub(event.setting, 1, 19) == "rampant-maintenance"))
then
return false
end
@ -1080,25 +1081,24 @@ local function onUnitGroupCreated(event)
end
end
local function onCommandComplete(event)
local unitNumber = event.unit_number
local squad = natives.groupNumberToSquad[unitNumber]
if squad then
local group = squad.group
if group and group.valid and (group.surface.name == natives.activeSurface) then
if (event.result == DEFINES_BEHAVIOR_RESULT_FAIL) then
if (#group.members == 0) then
group.destroy()
else
squadDispatch(map, group.surface, squad, unitNumber)
end
else
squadDispatch(map, group.surface, squad, unitNumber)
end
end
end
end
-- local function onCommandComplete(event)
-- local unitNumber = event.unit_number
-- local squad = natives.groupNumberToSquad[unitNumber]
-- if squad then
-- local group = squad.group
-- if group and group.valid and (group.surface.name == natives.activeSurface) then
-- -- if (event.result == DEFINES_BEHAVIOR_RESULT_FAIL) then
-- -- if (#group.members == 0) then
-- -- group.destroy()
-- -- else
-- -- squadDispatch(map, group.surface, squad, unitNumber)
-- -- end
-- -- else
-- squadDispatch(map, group.surface, squad, unitNumber)
-- -- end
-- end
-- end
-- end
local function onGroupFinishedGathering(event)
local group = event.group
@ -1293,6 +1293,8 @@ script.on_event(defines.events.on_tick,
local pick = tick % 7
local surface = gameRef.get_surface(natives.activeSurface)
-- local profiler = game.create_profiler()
if (pick == 0) then
processPendingChunks(map,
surface,
@ -1313,6 +1315,8 @@ script.on_event(defines.events.on_tick,
cleanSquads(natives, map.squadIterator)
processActiveNests(map, surface, tick)
-- game.print({"", "--dispatch4 ", profiler, ", ", game.tick, " ", mRandom()})
end)
script.on_event(defines.events.on_surface_cleared, onSurfaceCleared)
@ -1344,7 +1348,7 @@ script.on_event({defines.events.on_built_entity,
defines.events.script_raised_built,
defines.events.script_raised_revive}, onBuild)
script.on_event(defines.events.on_ai_command_completed, onCommandComplete)
-- script.on_event(defines.events.on_ai_command_completed, onCommandComplete)
script.on_event(defines.events.on_land_mine_armed, onEntitySpawned)
script.on_event(defines.events.on_rocket_launched, onRocketLaunch)
@ -1355,6 +1359,7 @@ script.on_event(defines.events.on_unit_group_created, onUnitGroupCreated)
script.on_event(defines.events.on_force_created, onForceCreated)
script.on_event(defines.events.on_forces_merged, onForceMerged)
script.on_event(defines.events.on_unit_group_finished_gathering, onGroupFinishedGathering)
-- script.on_event(defines.events.on_unit_removed_from_group, onUnitRemovedFromGroup)
script.on_event(defines.events.on_build_base_arrived, onBuilderArrived)

View File

@ -77,6 +77,15 @@ if settings.startup["rampant-enableShrinkNestsAndWorms"].value then
end
for k, corpse in pairs(data.raw["corpse"]) do
corpse.time_before_removed = (string.find(k, "biter") or
string.find(k, "spitter") or
string.find(k, "hive") or
string.find(k, "worm")) and
settings.startup["rampant-unitAndSpawnerFadeTime"].value * 60
end
if settings.startup["rampant-addWallResistanceAcid"].value then
vanillaBuildings.addWallAcidResistance()
end

View File

@ -274,7 +274,7 @@ function aiPlanning.temperamentPlanner(natives)
delta = delta + val
if destroyPlayerBuildings > 0 then
delta = delta - (200 * destroyPlayerBuildings)
delta = delta - (5 * destroyPlayerBuildings)
end
else
@ -282,15 +282,15 @@ function aiPlanning.temperamentPlanner(natives)
if destroyPlayerBuildings > 0 then
if (currentTemperament > 0) then
delta = delta - (200 * destroyPlayerBuildings)
delta = delta - (5 * destroyPlayerBuildings)
else
delta = delta + (200 * destroyPlayerBuildings)
delta = delta + (5 * destroyPlayerBuildings)
end
end
end
if activeRaidNests > 0 then
local val = (0.002 * activeRaidNests)
local val = (0.0075 * activeRaidNests)
delta = delta - val
else
delta = delta - 0.5
@ -306,7 +306,7 @@ function aiPlanning.temperamentPlanner(natives)
end
if lostEnemyBuilding > 0 then
delta = delta + (20 * lostEnemyBuilding)
delta = delta + (5 * lostEnemyBuilding)
end
if (builtEnemyBuilding > 0) then
@ -347,7 +347,7 @@ function aiPlanning.temperamentPlanner(natives)
natives.ionCannonBlasts = 0
natives.artilleryBlasts = 0
natives.temperamentScore = mMin(10000, mMax(-10000, currentTemperament + (natives.evolutionLevel * delta)))
natives.temperamentScore = mMin(10000, mMax(-10000, currentTemperament + (mMin(natives.evolutionLevel, 0.1) * delta)))
natives.temperament = ((natives.temperamentScore + 10000) * 0.00005)
-- print(natives.temperament, natives.temperamentScore)
-- print("--")

View File

@ -132,7 +132,7 @@ function mapProcessor.processMap(map, surface, tick)
for x=index,endIndex,step do
local chunk = processQueue[x]
if (chunk[CHUNK_TICK] ~= tick) then
if chunk and (chunk[CHUNK_TICK] ~= tick) then
chunk[CHUNK_TICK] = tick
processPheromone(map, chunk)
end

View File

@ -96,7 +96,7 @@ end
local function scoreSiegeLocationKamikaze(map, squad, neighborChunk)
local settle = neighborChunk[BASE_PHEROMONE] +
neighborChunk[RESOURCE_PHEROMONE] + (neighborChunk[PLAYER_PHEROMONE] * PLAYER_PHEROMONE_MULTIPLER)
return settle
end
@ -108,7 +108,7 @@ end
local function scoreSiegeLocation(map, squad, neighborChunk)
local settle = -getDeathGenerator(map, neighborChunk) + neighborChunk[BASE_PHEROMONE] +
neighborChunk[RESOURCE_PHEROMONE] + (neighborChunk[PLAYER_PHEROMONE] * PLAYER_PHEROMONE_MULTIPLER)
return settle
end
@ -146,7 +146,7 @@ local function settleMove(map, squad, surface)
end
addDeathGenerator(map, chunk, TEN_DEATH_PHEROMONE_GENERATOR_AMOUNT)
addSquadToChunk(map, chunk, squad)
addMovementPenalty(map, squad, chunk)
addMovementPenalty(map, squad, chunk)
local distance = euclideanDistancePoints(groupPosition.x,
groupPosition.y,
squad.originPosition.x,
@ -175,6 +175,13 @@ local function settleMove(map, squad, surface)
squad.status = SQUAD_BUILDING
-- remove in 1.1
if (#group.members == 0) then
-- print("killing")
group.destroy()
return
end
group.set_command(cmd)
else
local attackChunk, attackDirection, nextAttackChunk, nextAttackDirection = scoreNeighborsForSettling(map,
@ -244,8 +251,14 @@ local function settleMove(map, squad, surface)
cmd.distraction = DEFINES_DISTRACTION_BY_ENEMY
end
squad.status = SQUAD_BUILDING
-- remove in 1.1
if (#group.members == 0) then
-- print("killing")
group.destroy()
return
end
squad.status = SQUAD_BUILDING
end
group.set_command(cmd)
@ -342,8 +355,41 @@ local function buildMove(map, squad, surface)
group.set_command(map.compoundSettleCommand)
end
function squadAttack.cleanSquads(natives, iterator)
local squads = natives.groupNumberToSquad
local map = natives.map
local k, squad = next(squads, iterator)
if not k then
if (table_size(squads) == 0) then
-- this is needed as the next command remembers the max length a table has been
natives.groupNumberToSquad = {}
end
else
local group = squad.group
if not group.valid then
addDeathGenerator(map, squad.chunk, TEN_DEATH_PHEROMONE_GENERATOR_AMOUNT)
removeSquadFromChunk(map, squad)
if (map.regroupIterator == k) then
map.regroupIterator = nil
end
if squad.settlers then
natives.builderCount = natives.builderCount - 1
else
natives.squadCount = natives.squadCount - 1
end
local nextK
nextK,squad = next(squads, k)
squads[k] = nil
k = nextK
elseif (group.state == 4) then
squadAttack.squadDispatch(map, group.surface, squad, squad.groupNumber)
end
end
map.squadIterator = k
end
function squadAttack.squadDispatch(map, surface, squad)
-- local profiler = game.create_profiler()
local group = squad.group
if group and group.valid then
local status = squad.status
@ -370,9 +416,8 @@ function squadAttack.squadDispatch(map, surface, squad)
squad.status = SQUAD_RAIDING
attackMove(map, squad, surface)
end
end
end
end
-- game.print({"", "--dispatch4 ", profiler})
end
squadAttackG = squadAttack

View File

@ -90,18 +90,18 @@ function aiDefense.retreatUnits(chunk, cause, map, surface, tick, radius)
else
return
end
local newSquad = findNearbyRetreatingSquad(map, exitPath)
local created = false
local natives = map.natives
if not newSquad then
if (natives.squadCount < natives.AI_MAX_SQUAD_COUNT) then
created = true
newSquad = createSquad(position, surface)
newSquad = createSquad(position, surface)
else
return
end
end
end
map.fleeCommand.from = cause
@ -110,7 +110,7 @@ function aiDefense.retreatUnits(chunk, cause, map, surface, tick, radius)
map.formRetreatCommand.unit_search_distance = radius
local foundUnits = surface.set_multi_command(map.formRetreatCommand)
if (foundUnits == 0) then
if created then
newSquad.group.destroy()
@ -118,7 +118,7 @@ function aiDefense.retreatUnits(chunk, cause, map, surface, tick, radius)
return
end
if created then
if created then
natives.groupNumberToSquad[newSquad.groupNumber] = newSquad
natives.squadCount = natives.squadCount + 1
end

View File

@ -133,38 +133,6 @@ function unitGroupUtils.createSquad(position, surface, group, settlers)
return squad
end
function unitGroupUtils.cleanSquads(natives, iterator)
local squads = natives.groupNumberToSquad
local map = natives.map
local k, squad = next(squads, iterator)
if not k then
if (table_size(squads) == 0) then
-- this is needed as the next command remembers the max length a table has been
natives.groupNumberToSquad = {}
end
else
local group = squad.group
if not group.valid then
addDeathGenerator(map, squad.chunk, TEN_DEATH_PHEROMONE_GENERATOR_AMOUNT)
removeSquadFromChunk(map, squad)
if (map.regroupIterator == k) then
map.regroupIterator = nil
end
if squad.settlers then
natives.builderCount = natives.builderCount - 1
else
natives.squadCount = natives.squadCount - 1
end
local nextK
nextK,squad = next(squads, k)
squads[k] = nil
k = nextK
end
end
map.squadIterator = k
end
function unitGroupUtils.calculateKamikazeThreshold(memberCount, natives)
local threshold = (memberCount / natives.attackWaveMaxSize) * 0.2 + (natives.evolutionLevel * 0.2)
return threshold

View File

@ -12,6 +12,15 @@ crystal-v10-drain-rampant=Power Draining Crystal
crystal-drain-pole-rampant=Crystal Pylon
pylon-target-rampant=Crystal Pylon
acid-ball-acid-fire-rampant=Acid Pool
acid-ball-1-acid-fire-rampant=Acid Pool
acid-ball-2-acid-fire-rampant=Acid Pool
acid-ball-2-direction-acid-fire-rampant=Acid Pool
acid-ball-3-acid-fire-rampant=Acid Pool
acid-ball-3-direction-acid-fire-rampant=Acid Pool
acid-ball-4-acid-fire-rampant=Acid Pool
acid-ball-5-acid-fire-rampant=Acid Pool
spawner-proxy-1-rampant=Spawner Proxy
spawner-proxy-2-rampant=Spawner Proxy
spawner-proxy-3-rampant=Spawner Proxy
@ -18777,8 +18786,10 @@ rampant-poisonEnemy=World: Poison Biter Faction
rampant-disableCollidingProjectiles=Projectiles: Non biter force colliding projectiles
rampant-enableFullMapScan=Compatibility: Enable full map scanning
rampant-unitAndSpawnerFadeTime=Biter Corpse Fade Time
[mod-setting-description]
rampant-unitAndSpawnerFadeTime=The time in seconds for how long biter corpses stay around
rampant-unitsAffectedByTiles=(Can cause Desyncs) Units are affected by tile movement modifiers
rampant-oldRedEnemyMapColor=Reverts the enemy map color to the vanilla enemy map color
rampant-unitSpawnerBreath=Now unit spawners breath air so they are affected by things like poison capsules

View File

@ -231,9 +231,9 @@ local unitSpawnerAttributeNumeric = {
["healing"] = { 0.02, 0.02, 0.022, 0.024, 0.026, 0.028, 0.03, 0.032, 0.034, 0.036 },
["spawningCooldownStart"] = { 1080, 1075, 1070, 1065, 1060, 1055, 1050, 1045, 1040, 1035 },
["spawningCooldownEnd"] = { 350, 345, 340, 335, 330, 325, 320, 315, 310, 305 },
["unitsToSpawn"] = { 5, 5, 6, 6, 7, 7, 8, 8, 9, 9 },
["unitsToSpawn"] = { 11, 11, 12, 12, 13, 13, 14, 14, 15, 15 },
["scale"] = { 0.5, 0.6, 0.7, 0.8, 0.9, 1, 1.2, 1.4, 1.6, 1.8 },
["unitsOwned"] = { 7, 7, 8, 8, 9, 9, 10, 10, 11, 11 },
["unitsOwned"] = { 9, 9, 10, 10, 11, 11, 12, 12, 13, 13 },
["physicalDecrease"] = { 1, 2, 3, 4, 6, 6, 8, 10, 12, 14 },
["physicalPercent"] = { 15, 15, 17, 17, 18, 18, 19, 19, 20, 20 },
["explosionDecrease"] = { 5, 5, 6, 6, 7, 7, 8, 8, 9, 9 },

View File

@ -70,6 +70,17 @@ data:extend({
per_user = false
},
{
type = "int-setting",
name = "rampant-unitAndSpawnerFadeTime",
setting_type = "startup",
minimum_value = 1,
maximum_value = 300 * 60,
default_value = 5 * 60,
order = "b[modifier]-f[wave]",
per_user = false
},
{
type = "bool-setting",
name = "rampant-permanentNocturnal",
@ -787,7 +798,7 @@ data:extend({
default_value = 1.0,
minimum_value = 0.0001,
maximum_value = 100000.0,
order = "p[modifier]-r[unit]",
order = "p[modifier]-r[zunit]",
per_user = false
},
@ -799,7 +810,7 @@ data:extend({
default_value = 1.0,
minimum_value = 0.0001,
maximum_value = 100000.0,
order = "p[modifier]-r[unit]",
order = "p[modifier]-r[zunit]",
per_user = false
},
@ -811,7 +822,7 @@ data:extend({
default_value = 1.0,
minimum_value = 0.0001,
maximum_value = 100000.0,
order = "p[modifier]-r[unit]",
order = "p[modifier]-r[zunit]",
per_user = false
},

105
tests.lua
View File

@ -63,10 +63,12 @@ end
function tests.activeSquads()
print("-----")
print("Squads", global.natives.squads.len)
for i=1, global.natives.squads.len do
print(defines.group_state.gathering .. " is equal to gathering")
print(defines.group_state.finished .. " is equal to finished")
-- print("Squads", global.natives.groupNumberToSquad)
for un, squad in pairs(global.natives.groupNumberToSquad) do
print("-")
local squad = global.natives.squads[i]
-- local squad = global.natives.squads[i]
local squadHealth = 0
local squadMakeup = {}
if squad.group.valid then
@ -86,53 +88,54 @@ function tests.activeSquads()
-- print(serpent.dump(squad))
end
end
print("---")
print("pending", global.natives.pendingAttack.len)
for i=1, global.natives.pendingAttack.len do
print("-")
local squad = global.natives.pendingAttack[i]
local squadHealth = 0
local squadMakeup = {}
if squad.group.valid then
-- for x=1,#squad.group.members do
-- local member = squad.group.members[x].prototype
-- if not squadMakeup[member.name] then
-- squadMakeup[member.name] = 0
-- end
-- print("---")
-- print("pending", global.natives.pendingAttack.len)
-- for i=1, global.natives.pendingAttack.len do
-- print("-")
-- local squad = global.natives.pendingAttack[i]
-- local squadHealth = 0
-- local squadMakeup = {}
-- if squad.group.valid then
-- -- for x=1,#squad.group.members do
-- -- local member = squad.group.members[x].prototype
-- -- if not squadMakeup[member.name] then
-- -- squadMakeup[member.name] = 0
-- -- end
-- squadHealth = squadHealth + member.max_health
-- squadMakeup[member.name] = squadMakeup[member.name] + 1
-- end
print(math.floor(squad.group.position.x * 0.03125), math.floor(squad.group.position.y * 0.03125), squad.status, squad.group.state, #squad.group.members, squad.cycles, -- squadHealth,
squad.group.group_number)
-- print(serpent.dump(squadResistances))
-- print(serpent.dump(squadMakeup))
-- print(serpent.dump(squad))
end
end
print("---")
print("building", #global.natives.building)
for i=1, #global.natives.building do
print("-")
local squad = global.natives.building[i]
local squadHealth = 0
local squadMakeup = {}
if squad.group.valid then
-- for x=1,#squad.group.members do
-- local member = squad.group.members[x].prototype
-- if not squadMakeup[member.name] then
-- squadMakeup[member.name] = 0
-- end
-- -- squadHealth = squadHealth + member.max_health
-- -- squadMakeup[member.name] = squadMakeup[member.name] + 1
-- -- end
-- print(math.floor(squad.group.position.x * 0.03125), math.floor(squad.group.position.y * 0.03125), squad.status, squad.group.state, #squad.group.members, squad.cycles, -- squadHealth,
-- squad.group.group_number)
-- -- print(serpent.dump(squadResistances))
-- -- print(serpent.dump(squadMakeup))
-- -- print(serpent.dump(squad))
-- end
-- end
-- print("---")
-- print("building", #global.natives.building)
-- for i=1, #global.natives.building do
-- print("-")
-- local squad = global.natives.building[i]
-- local squadHealth = 0
-- local squadMakeup = {}
-- if squad.group.valid then
-- -- for x=1,#squad.group.members do
-- -- local member = squad.group.members[x].prototype
-- -- if not squadMakeup[member.name] then
-- -- squadMakeup[member.name] = 0
-- -- end
-- -- squadHealth = squadHealth + member.max_health
-- -- squadMakeup[member.name] = squadMakeup[member.name] + 1
-- -- end
-- print(math.floor(squad.group.position.x * 0.03125), math.floor(squad.group.position.y * 0.03125), squad.status, squad.group.state, #squad.group.members, squad.cycles, squad.group.group_number, squadHealth)
-- -- print(serpent.dump(squadResistances))
-- -- print(serpent.dump(squadMakeup))
-- -- print(serpent.dump(squad))
-- end
-- end
-- squadHealth = squadHealth + member.max_health
-- squadMakeup[member.name] = squadMakeup[member.name] + 1
-- end
print(math.floor(squad.group.position.x * 0.03125), math.floor(squad.group.position.y * 0.03125), squad.status, squad.group.state, #squad.group.members, squad.cycles, squad.group.group_number, squadHealth)
-- print(serpent.dump(squadResistances))
-- print(serpent.dump(squadMakeup))
-- print(serpent.dump(squad))
end
end
end
function tests.entitiesOnPlayerChunk()
@ -261,7 +264,7 @@ function tests.baseStats()
local base = natives.bases[i]
print(base.x,
base.y,
base.distanceThreshold,
base.distanceThreshold,
base.tick,
base.points,
base.temperament,
@ -404,14 +407,14 @@ function tests.exportAiState()
local base = chunkPropertyUtils.getChunkBase(global.map, chunk)
local alignmentCount = 0
if base then
if base then
if (#base.alignment == 2) then
alignmentCount = (math.abs(base.x) * 10000) + (math.abs(base.y) * 10000) + (lookupIndexFaction(base.alignment[1]) * 100) + lookupIndexFaction(base.alignment[2])
else
alignmentCount = (math.abs(base.x) * 10000) + (math.abs(base.y) * 10000) + lookupIndexFaction(base.alignment[1])
end
end
s = s .. table.concat({0,
chunk[constants.BASE_PHEROMONE],
chunk[constants.PLAYER_PHEROMONE],