diff --git a/changelog.txt b/changelog.txt index dc24947..498aaa5 100644 --- a/changelog.txt +++ b/changelog.txt @@ -35,6 +35,7 @@ Date: 23. 11. 2021 - Siege AI state now sends roughly 1 raid group every 2 settler groups if raiding is enabled - Siege groups now try to settle just outside player structures as opposed to attacking - Added Raid AI state to lower temperament scores @ 20% at 0 temperament and 15% at (0.2, 0.4) + - Vengence squads now have a 7.5% chance to be a settler group if migration is enabled Tweaks: - Increase chance to upgrade an enemy structure from 5% to 30% - New enemy regional bases that have two factions now do 75% on one faction and 25% on the faction for building and upgrading enemy structures diff --git a/libs/AIAttackWave.lua b/libs/AIAttackWave.lua index 149791d..087a8b5 100644 --- a/libs/AIAttackWave.lua +++ b/libs/AIAttackWave.lua @@ -315,6 +315,55 @@ function aiAttackWave.formVengenceSquad(map, chunk) end end +function aiAttackWave.formVengenceSettler(map, chunk) + local universe = map.universe + if (universe.builderCount < universe.AI_MAX_BUILDER_COUNT) and + (map.random() < universe.formSquadThreshold) and + ((map.points - AI_VENGENCE_SQUAD_COST) > 0) + then + local surface = map.surface + local squadPath, squadDirection = scoreNeighborsForFormation(getNeighborChunks(map, chunk.x, chunk.y), + validUnitGroupLocation, + scoreUnitGroupLocation, + map) + if (squadPath ~= -1) then + local squadPosition = surface.find_non_colliding_position("chunk-scanner-squad-rampant", + positionFromDirectionAndChunk(squadDirection, + chunk, + 0.98), + CHUNK_SIZE, + 4, + true) + if squadPosition then + local squad = createSquad(squadPosition, map, nil, true) + + squad.rabid = map.random() < 0.03 + + local scaledWaveSize = settlerWaveScaling(universe) + universe.formGroupCommand.group = squad.group + universe.formCommand.unit_count = scaledWaveSize + local foundUnits = surface.set_multi_command(universe.formCommand) + if (foundUnits > 0) then + if universe.NEW_ENEMIES then + squad.base = findNearbyBase(map, chunk) + end + squad.kamikaze = map.random() < calculateKamikazeSettlerThreshold(foundUnits, universe) + universe.groupNumberToSquad[squad.groupNumber] = squad + universe.builderCount = universe.builderCount + 1 + map.points = map.points - AI_VENGENCE_SQUAD_COST + if universe.aiPointsPrintSpendingToChat then + game.print(map.surface.name .. ": Points: -" .. AI_VENGENCE_SQUAD_COST .. ". [Vengence Settlers] Total: " .. string.format("%.2f", map.points) .. " [gps=" .. squadPosition.x .. "," .. squadPosition.y .. "]") + end + else + if (squad.group.valid) then + squad.group.destroy() + end + end + end + end + end +end + function aiAttackWave.formSquads(map, chunk) local universe = map.universe if (universe.squadCount < universe.AI_MAX_SQUAD_COUNT) and diff --git a/libs/MapProcessor.lua b/libs/MapProcessor.lua index 8a147a5..a12356d 100644 --- a/libs/MapProcessor.lua +++ b/libs/MapProcessor.lua @@ -57,6 +57,7 @@ local getChunkBase = chunkPropertyUtils.getChunkBase local formSquads = aiAttackWave.formSquads local formVengenceSquad = aiAttackWave.formVengenceSquad +local formVengenceSettler = aiAttackWave.formVengenceSettler local formSettlers = aiAttackWave.formSettlers local getChunkByPosition = mapUtils.getChunkByPosition @@ -430,7 +431,11 @@ function mapProcessor.processVengence(universe) vengenceQueue[chunkId] = nil return end - formVengenceSquad(map, getChunkById(vengencePack.map, chunkId)) + if universe.enabledMigration and (universe.random() < 0.075) then + formVengenceSettler(map, getChunkById(vengencePack.map, chunkId)) + else + formVengenceSquad(map, getChunkById(vengencePack.map, chunkId)) + end vengenceQueue[chunkId] = nil end end