mirror of
https://github.com/veden/Rampant.git
synced 2025-03-17 20:58:35 +02:00
attack waves are processing outside active map
This commit is contained in:
parent
71e40a9c46
commit
d978d3fdd4
12
Upgrade.lua
12
Upgrade.lua
@ -428,8 +428,8 @@ function upgrade.attempt(universe)
|
||||
|
||||
universe.maxPoints = 0
|
||||
end
|
||||
if global.version < 200 then
|
||||
global.version = 200
|
||||
if global.version < 201 then
|
||||
global.version = 201
|
||||
|
||||
addCommandSet(universe)
|
||||
universe.eventId = 0
|
||||
@ -457,6 +457,11 @@ function upgrade.attempt(universe)
|
||||
universe.builderCount = 0
|
||||
universe.squadCount = 0
|
||||
universe.chunkToNests = {}
|
||||
universe.processActiveSpawnerIterator = nil
|
||||
universe.processActiveRaidSpawnerIterator = nil
|
||||
universe.processMigrationIterator = nil
|
||||
universe.chunkToActiveNest = {}
|
||||
universe.chunkToActiveRaidNest = {}
|
||||
|
||||
game.print("Rampant - Version 2.0.0")
|
||||
end
|
||||
@ -535,9 +540,6 @@ function upgrade.prepMap(universe, surface)
|
||||
|
||||
map.chunkToPassScanIterator = nil
|
||||
map.recycleBaseIterator = nil
|
||||
map.processActiveSpawnerIterator = nil
|
||||
map.processActiveRaidSpawnerIterator = nil
|
||||
map.processMigrationIterator = nil
|
||||
|
||||
map.chunkScanCounts = {}
|
||||
|
||||
|
@ -27,6 +27,7 @@ Date: 23. 11. 2021
|
||||
- Pheromone map processing only does upto 5% of generated chunks on a surface before switching to the next surface
|
||||
- AI Planning will now happen on upto 15 surface per cycle
|
||||
- Spawners not covered by pollution are now processed regardless of current active surface
|
||||
- Attack waves are 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
|
||||
|
@ -1022,7 +1022,7 @@ script.on_event(defines.events.on_tick,
|
||||
scanResourceMap(map, tick)
|
||||
scanEnemyMap(map, tick)
|
||||
elseif (pick == 5) then
|
||||
processAttackWaves(map)
|
||||
processAttackWaves(universe)
|
||||
scanEnemyMap(map, tick)
|
||||
elseif (pick == 6) then
|
||||
scanPlayerMap(map, tick)
|
||||
|
@ -149,8 +149,8 @@ function chunkPropertyUtils.removeNestCount(map, chunk, unitNumber)
|
||||
if cToN[chunkId].v == 0 then
|
||||
map.chunkToNestIds[chunkId] = nil
|
||||
cToN[chunkId] = nil
|
||||
if (map.processMigrationIterator == chunkId) then
|
||||
map.processMigrationIterator = nil
|
||||
if (map.universe.processMigrationIterator == chunkId) then
|
||||
map.universe.processMigrationIterator = nil
|
||||
end
|
||||
if (map.universe.processNestIterator == chunkId) then
|
||||
map.universe.processNestIterator = nil
|
||||
@ -237,44 +237,62 @@ end
|
||||
|
||||
|
||||
function chunkPropertyUtils.getRaidNestActiveness(map, chunk)
|
||||
return map.chunkToActiveRaidNest[chunk.id] or 0
|
||||
local activeness = map.universe.chunkToActiveRaidNest[chunk.id]
|
||||
if not activeness then
|
||||
return 0
|
||||
end
|
||||
return activeness.v or 0
|
||||
end
|
||||
|
||||
function chunkPropertyUtils.setRaidNestActiveness(map, chunk, value)
|
||||
local universe = map.universe
|
||||
if (value <= 0) then
|
||||
if map.chunkToActiveRaidNest[chunk.id] then
|
||||
if universe.chunkToActiveRaidNest[chunk.id] then
|
||||
map.activeRaidNests = map.activeRaidNests - 1
|
||||
end
|
||||
if (map.processActiveRaidSpawnerIterator == chunk.id) then
|
||||
map.processActiveRaidSpawnerIterator = nil
|
||||
if (universe.processActiveRaidSpawnerIterator == chunk.id) then
|
||||
universe.processActiveRaidSpawnerIterator = nil
|
||||
end
|
||||
map.chunkToActiveRaidNest[chunk.id] = nil
|
||||
universe.chunkToActiveRaidNest[chunk.id] = nil
|
||||
else
|
||||
if not map.chunkToActiveRaidNest[chunk.id] then
|
||||
if not universe.chunkToActiveRaidNest[chunk.id] then
|
||||
map.activeRaidNests = map.activeRaidNests + 1
|
||||
universe.chunkToActiveRaidNest[chunk.id] = {
|
||||
map = map,
|
||||
v = 0
|
||||
}
|
||||
end
|
||||
map.chunkToActiveRaidNest[chunk.id] = value
|
||||
universe.chunkToActiveRaidNest[chunk.id].v = value
|
||||
end
|
||||
end
|
||||
|
||||
function chunkPropertyUtils.getNestActiveness(map, chunk)
|
||||
return map.chunkToActiveNest[chunk.id] or 0
|
||||
local activeness = map.universe.chunkToActiveNest[chunk.id]
|
||||
if not activeness then
|
||||
return 0
|
||||
end
|
||||
return activeness.v or 0
|
||||
end
|
||||
|
||||
function chunkPropertyUtils.setNestActiveness(map, chunk, value)
|
||||
local universe = map.universe
|
||||
if (value <= 0) then
|
||||
if map.chunkToActiveNest[chunk.id] then
|
||||
if universe.chunkToActiveNest[chunk.id] then
|
||||
map.activeNests = map.activeNests - 1
|
||||
end
|
||||
if (map.processActiveSpawnerIterator == chunk.id) then
|
||||
map.processActiveSpawnerIterator = nil
|
||||
if (universe.processActiveSpawnerIterator == chunk.id) then
|
||||
universe.processActiveSpawnerIterator = nil
|
||||
end
|
||||
map.chunkToActiveNest[chunk.id] = nil
|
||||
universe.chunkToActiveNest[chunk.id] = nil
|
||||
else
|
||||
if not map.chunkToActiveNest[chunk.id] then
|
||||
if not universe.chunkToActiveNest[chunk.id] then
|
||||
map.activeNests = map.activeNests + 1
|
||||
universe.chunkToActiveNest[chunk.id] = {
|
||||
map = map,
|
||||
v = 0
|
||||
}
|
||||
end
|
||||
map.chunkToActiveNest[chunk.id] = value
|
||||
universe.chunkToActiveNest[chunk.id].v = value
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -17,6 +17,9 @@ local baseUtils = require("BaseUtils")
|
||||
|
||||
-- constants
|
||||
|
||||
local AI_STATE_ONSLAUGHT = constants.AI_STATE_ONSLAUGHT
|
||||
local AI_STATE_RAIDING = constants.AI_STATE_RAIDING
|
||||
|
||||
local DURATION_ACTIVE_NEST = constants.DURATION_ACTIVE_NEST
|
||||
|
||||
local PROCESS_QUEUE_SIZE = constants.PROCESS_QUEUE_SIZE
|
||||
@ -38,7 +41,6 @@ local AI_STATE_AGGRESSIVE = constants.AI_STATE_AGGRESSIVE
|
||||
|
||||
local AI_STATE_PEACEFUL = constants.AI_STATE_PEACEFUL
|
||||
local AI_STATE_MIGRATING = constants.AI_STATE_MIGRATING
|
||||
local AI_STATE_SIEGE = constants.AI_STATE_SIEGE
|
||||
|
||||
local COOLDOWN_RALLY = constants.COOLDOWN_RALLY
|
||||
local COOLDOWN_RETREAT = constants.COOLDOWN_RETREAT
|
||||
@ -477,10 +479,29 @@ function mapProcessor.processNests(universe, tick)
|
||||
end
|
||||
end
|
||||
|
||||
local function processSpawnersBody(map, iterator, chunks)
|
||||
local chunkId = next(chunks, map[iterator])
|
||||
map[iterator] = chunkId
|
||||
local function processSpawnersBody(universe, iterator, chunks)
|
||||
local chunkId, chunkPack = next(chunks, universe[iterator])
|
||||
universe[iterator] = chunkId
|
||||
if chunkId then
|
||||
local map = chunkPack.map
|
||||
local state = chunkPack.map.state
|
||||
if state == AI_STATE_PEACEFUL then
|
||||
return
|
||||
end
|
||||
if iterator == "processMigrationIterator" then
|
||||
if (state == AI_STATE_AGGRESSIVE) or (state == AI_STATE_ONSLAUGHT) or (state == AI_STATE_RAIDING) then
|
||||
return
|
||||
end
|
||||
elseif iterator == "processActiveRaidSpawnerIterator" then
|
||||
if (state == AI_STATE_AGGRESSIVE) or (state == AI_STATE_MIGRATING) then
|
||||
return
|
||||
end
|
||||
elseif iterator == "processActiveSpawnerIterator" then
|
||||
if (state == AI_STATE_MIGRATING) then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local chunk = getChunkById(map, chunkId)
|
||||
local migrate = canMigrate(map)
|
||||
local attack = canAttack(map)
|
||||
@ -492,36 +513,16 @@ local function processSpawnersBody(map, iterator, chunks)
|
||||
end
|
||||
end
|
||||
|
||||
function mapProcessor.processAttackWaves(map)
|
||||
|
||||
if (map.state ~= AI_STATE_PEACEFUL) then
|
||||
if (map.state == AI_STATE_MIGRATING) then
|
||||
processSpawnersBody(map,
|
||||
"processMigrationIterator",
|
||||
map.chunkToNests)
|
||||
elseif (map.state == AI_STATE_AGGRESSIVE) then
|
||||
processSpawnersBody(map,
|
||||
"processActiveSpawnerIterator",
|
||||
map.chunkToActiveNest)
|
||||
elseif (map.state == AI_STATE_SIEGE) then
|
||||
processSpawnersBody(map,
|
||||
"processActiveSpawnerIterator",
|
||||
map.chunkToActiveNest)
|
||||
processSpawnersBody(map,
|
||||
"processActiveRaidSpawnerIterator",
|
||||
map.chunkToActiveRaidNest)
|
||||
processSpawnersBody(map,
|
||||
"processMigrationIterator",
|
||||
map.chunkToNests)
|
||||
else
|
||||
processSpawnersBody(map,
|
||||
"processActiveSpawnerIterator",
|
||||
map.chunkToActiveNest)
|
||||
processSpawnersBody(map,
|
||||
"processActiveRaidSpawnerIterator",
|
||||
map.chunkToActiveRaidNest)
|
||||
end
|
||||
end
|
||||
function mapProcessor.processAttackWaves(universe)
|
||||
processSpawnersBody(universe,
|
||||
"processActiveSpawnerIterator",
|
||||
universe.chunkToActiveNest)
|
||||
processSpawnersBody(universe,
|
||||
"processActiveRaidSpawnerIterator",
|
||||
universe.chunkToActiveRaidNest)
|
||||
processSpawnersBody(universe,
|
||||
"processMigrationIterator",
|
||||
universe.chunkToNests)
|
||||
end
|
||||
|
||||
mapProcessorG = mapProcessor
|
||||
|
Loading…
x
Reference in New Issue
Block a user