diff --git a/Upgrade.lua b/Upgrade.lua index 86f79f8..bbe1ca2 100644 --- a/Upgrade.lua +++ b/Upgrade.lua @@ -441,11 +441,13 @@ function upgrade.attempt(universe) universe.chunkIdToChunk = {} universe.groupNumberToSquad = {} universe.pendingUpgrades = {} + universe.chunkToVictory = {} universe.pendingChunks = {} universe.processActiveNest = {} universe.processActiveNestIterator = nil universe.deployVengenceIterator = nil universe.pendingUpgradeIterator = nil + universe.victoryScentIterator = nil universe.squadIterator = nil universe.vengenceQueue = {} universe.activeMap = nil @@ -526,7 +528,6 @@ function upgrade.prepMap(universe, surface) map.chunkToPathRating = {} map.chunkToDeathGenerator = {} map.chunkToDrained = {} - map.chunkToVictory = {} map.chunkToActiveNest = {} map.chunkToActiveRaidNest = {} @@ -536,7 +537,6 @@ function upgrade.prepMap(universe, surface) map.processActiveRaidSpawnerIterator = nil map.processMigrationIterator = nil map.processNestIterator = nil - map.victoryScentIterator = nil map.chunkScanCounts = {} diff --git a/changelog.txt b/changelog.txt index 6e3c995..3741f9b 100644 --- a/changelog.txt +++ b/changelog.txt @@ -23,6 +23,7 @@ Date: 23. 11. 2021 - Newly generated chunks are now processed regardless of current active surface - Neutral death events that aren't cliffs are no longer processed - Added support for AbandonedRuins mod + - Victory scent is now processed regardless of current active surface 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/control.lua b/control.lua index b3d991b..273a8fc 100644 --- a/control.lua +++ b/control.lua @@ -1015,7 +1015,7 @@ script.on_event(defines.events.on_tick, processMap(map, tick) elseif (pick == 3) then processStaticMap(map) - disperseVictoryScent(map) + disperseVictoryScent(universe) processVengence(universe) elseif (pick == 4) then scanResourceMap(map, tick) diff --git a/libs/ChunkPropertyUtils.lua b/libs/ChunkPropertyUtils.lua index 53d1062..9f694ab 100644 --- a/libs/ChunkPropertyUtils.lua +++ b/libs/ChunkPropertyUtils.lua @@ -287,7 +287,15 @@ function chunkPropertyUtils.addDeathGenerator(map, chunk, value) end function chunkPropertyUtils.addVictoryGenerator(map, chunk, value) - map.chunkToVictory[chunk.id] = (map.chunkToVictory[chunk.id] or 0) + value + local cToV = map.universe.chunkToVictory + local chunkId = chunk.id + if not cToV[chunkId] then + cToV[chunkId] = { + map = map, + v = 0 + } + end + cToV[chunkId].v = cToV[chunkId].v + value end function chunkPropertyUtils.decayDeathGenerator(map, chunk) diff --git a/libs/PheromoneUtils.lua b/libs/PheromoneUtils.lua index ccf3a12..08114ca 100644 --- a/libs/PheromoneUtils.lua +++ b/libs/PheromoneUtils.lua @@ -63,18 +63,19 @@ function pheromoneUtils.victoryScent(map, chunk, entityType) end end -function pheromoneUtils.disperseVictoryScent(map) - local chunkId = map.victoryScentIterator - local chunkToVictory = map.chunkToVictory - local pheromone +function pheromoneUtils.disperseVictoryScent(universe) + local chunkId = universe.victoryScentIterator + local chunkToVictory = universe.chunkToVictory + local pheromonePack if not chunkId then - chunkId, pheromone = next(chunkToVictory, nil) + chunkId, pheromonePack = next(chunkToVictory, nil) else - pheromone = chunkToVictory[chunkId] + pheromonePack = chunkToVictory[chunkId] end if not chunkId then - map.victoryScentIterator = nil + universe.victoryScentIterator = nil else + local map = pheromonePack.map map.victoryScentIterator = next(chunkToVictory, chunkId) chunkToVictory[chunkId] = nil local chunk = getChunkById(map, chunkId) @@ -85,7 +86,7 @@ function pheromoneUtils.disperseVictoryScent(map) for y = chunkY - VICTORY_SCENT_BOUND, chunkY + VICTORY_SCENT_BOUND,32 do local c = getChunkByXY(map, x, y) if (c ~= -1) then - addDeathGenerator(map, c, -pheromone * VICTORY_SCENT_MULTIPLER[i] * getPathRating(map, c)) + addDeathGenerator(map, c, -pheromonePack.v * VICTORY_SCENT_MULTIPLER[i] * getPathRating(map, c)) end i = i + 1 end