1
0
mirror of https://github.com/veden/Rampant.git synced 2024-12-26 20:54:12 +02:00

63676ad: When the last player structure on a chunk is lost base score should be zeroed

This commit is contained in:
Aaron Veden 2023-01-07 22:17:46 -08:00
parent 97d19407ac
commit b7c30a37f0
No known key found for this signature in database
GPG Key ID: FF5990B1C6DD3F84
6 changed files with 17 additions and 8 deletions

View File

@ -35,6 +35,7 @@ Version: 3.2.0
- Fixed death pheromone spread being initialized to 0 instead of max negative number causing victory scent to spread incorrectly
- Fixed chunk scanning have a false negative for impassable chunks
- Fixed non-settler unit groups being created when player or base pheromone is effectively zero
- When the last player structure is destroyed on a chunk, the base pheromone is set to 0
Optimizations:
- Moved most constants out of global
- Removed new enemy variations setting

View File

@ -103,8 +103,6 @@ local positionToChunkXY = mapUtils.positionToChunkXY
local processVengence = mapProcessor.processVengence
local processAttackWaves = mapProcessor.processAttackWaves
local processStaticMap = mapProcessor.processStaticMap
local disperseVictoryScent = pheromoneUtils.disperseVictoryScent
local getChunkByPosition = mapUtils.getChunkByPosition

View File

@ -606,13 +606,22 @@ end
function chunkPropertyUtils.setPlayerBaseGenerator(map, chunk, playerGenerator)
if (playerGenerator <= 0) then
map.chunkToPlayerBase[chunk.id] = nil
return 0
else
map.chunkToPlayerBase[chunk.id] = playerGenerator
return playerGenerator
end
end
function chunkPropertyUtils.addPlayerBaseGenerator(map, chunk, playerGenerator)
map.chunkToPlayerBase[chunk.id] = (map.chunkToPlayerBase[chunk.id] or 0) + playerGenerator
local amount = (map.chunkToPlayerBase[chunk.id] or 0) + playerGenerator
if amount <= 0 then
map.chunkToPlayerBase[chunk.id] = nil
return 0
else
map.chunkToPlayerBase[chunk.id] = amount
return amount
end
end
function chunkPropertyUtils.findNearbyBase(map, chunk)

View File

@ -37,8 +37,6 @@ local HIVE_BUILDINGS_TYPES = constants.HIVE_BUILDINGS_TYPES
local DEFINES_WIRE_TYPE_RED = defines.wire_type.red
local DEFINES_WIRE_TYPE_GREEN = defines.wire_type.green
local CHUNK_PASS_THRESHOLD = constants.CHUNK_PASS_THRESHOLD
local BASE_AI_STATE_ONSLAUGHT = constants.BASE_AI_STATE_ONSLAUGHT
local BASE_PHEROMONE = constants.BASE_PHEROMONE
@ -599,7 +597,10 @@ function chunkUtils.accountPlayerEntity(entity, map, addObject, base)
for i=1,#overlapArray do
local chunk = overlapArray[i]
if (chunk ~= -1) then
addPlayerBaseGenerator(map, chunk, entityValue)
local amount = addPlayerBaseGenerator(map, chunk, entityValue)
if (amount == 0) then
chunk[BASE_PHEROMONE] = 0
end
end
end
end

View File

@ -43,6 +43,7 @@ local VICTORY_SCENT = constants.VICTORY_SCENT
local PLAYER_PHEROMONE_GENERATOR_AMOUNT = constants.PLAYER_PHEROMONE_GENERATOR_AMOUNT
local DEATH_PHEROMONE_GENERATOR_AMOUNT = constants.DEATH_PHEROMONE_GENERATOR_AMOUNT
local TEN_DEATH_PHEROMONE_GENERATOR_AMOUNT = constants.TEN_DEATH_PHEROMONE_GENERATOR_AMOUNT
-- imported functions
@ -122,7 +123,7 @@ end
function pheromoneUtils.deathScent(map, chunk, structure)
local amount = -DEATH_PHEROMONE_GENERATOR_AMOUNT
if structure then
amount = amount * 7.5
amount = -TEN_DEATH_PHEROMONE_GENERATOR_AMOUNT
end
addDeathGenerator(map, chunk, amount)
addPermanentDeathGenerator(map, chunk, amount)

View File

@ -64,7 +64,6 @@ local findMovementPosition = movementUtils.findMovementPosition
local removeSquadFromChunk = chunkPropertyUtils.removeSquadFromChunk
local addDeathGenerator = chunkPropertyUtils.addDeathGenerator
local getCombinedDeathGeneratorRating = chunkPropertyUtils.getCombinedDeathGeneratorRating
local getPlayersOnChunk = chunkPropertyUtils.getPlayersOnChunk
local getHiveCount = chunkPropertyUtils.getHiveCount