Skip to content

Commit

Permalink
see changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
veden committed May 16, 2019
1 parent 70da8b9 commit aa0bbf7
Show file tree
Hide file tree
Showing 13 changed files with 156 additions and 86 deletions.
6 changes: 3 additions & 3 deletions Upgrade.lua
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,10 @@ function upgrade.attempt(natives)
game.surfaces[natives.activeSurface].print("Rampant - Version 0.17.22")
global.version = 89
end
if (global.version < 91) then
if (global.version < 92) then

game.surfaces[natives.activeSurface].print("Rampant - Version 0.17.25")
global.version = 91
game.surfaces[natives.activeSurface].print("Rampant - Version 0.17.26")
global.version = 92
end

return starting ~= global.version, natives
Expand Down
22 changes: 22 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
---------------------------------------------------------------------------------------------------
Version: 0.17.26
Date: 5. 14. 2019
Contributions:
- Choumiko - Added event hooks for script_built and script_destroyed events
Optimizations:
- Disabled full map scan by default in favor of script_built and script_destroyed events. If a mod does not use these events and creates or destroys entities through scripts, you may need to re-enable this feature in the mod map settings under Compatibility: enable full map scan.
Improvements:
- Added a check for script created resources in the script_built and script_destroyed events
- When a squad is destroyed its last few chunk moves now receive a portion of the death generator pheromone from the chunk they died on
Tweaks:
- Removed unused mapping tables
- Chunk properties now use <= instead of == when checking for minimum allowed values
- Increased death pheromone generator amount to 1300
- Increased retreat levels by 30%
- Increased raiding base activition threshold to 550
- Decreased minimum cooldown time for attack waves in aggressive state to 30 seconds
- Reduced all player generator values by half
Bugfixes:
- Memory leak with settlers last tick map
- Multiple version of chunks where in the processing queue causing double processing issues with a duplicate context

---------------------------------------------------------------------------------------------------
Version: 0.17.25
Date: 5. 8. 2019
Expand Down
31 changes: 22 additions & 9 deletions control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ local unregisterEnemyBaseStructure = chunkUtils.unregisterEnemyBaseStructure
local registerEnemyBaseStructure = chunkUtils.registerEnemyBaseStructure
local makeImmortalEntity = chunkUtils.makeImmortalEntity

local registerResource = chunkUtils.registerResource
local unregisterResource = chunkUtils.unregisterResource

local upgradeEntity = baseUtils.upgradeEntity
local rebuildNativeTables = baseUtils.rebuildNativeTables

Expand Down Expand Up @@ -203,7 +206,7 @@ local function rebuildMap()

map.chunkToRetreats = {}
map.chunkToRallys = {}
map.chunkToSpawner = {}
-- map.chunkToSpawner = {}
map.chunkToSettler = {}

map.chunkToPassable = {}
Expand Down Expand Up @@ -538,20 +541,30 @@ end)
local function onBuild(event)
local entity = event.created_entity or event.entity
if (entity.surface.index == natives.activeSurface) then
accountPlayerEntity(map, entity, natives, true, false)
if natives.safeBuildings then
if natives.safeEntities[entity.type] or natives.safeEntityName[entity.name] then
entity.destructible = false
end
end
if (entity.type == "resource") and (entity.force.name == "neutral") then
-- print("registering resource", entity.name)
registerResource(entity, map)
else
-- print("registering entity", entity.name)
accountPlayerEntity(map, entity, natives, true, false)
if natives.safeBuildings then
if natives.safeEntities[entity.type] or natives.safeEntityName[entity.name] then
entity.destructible = false
end
end
end
end
end

local function onMine(event)
local entity = event.entity
local surface = entity.surface
if (surface.index == natives.activeSurface) then
accountPlayerEntity(map, entity, natives, false, false)
if (entity.type == "resource") and (entity.force.name == "neutral") then
unregisterResource(entity, map)
else
accountPlayerEntity(map, entity, natives, false, false)
end
end
end

Expand Down Expand Up @@ -779,7 +792,7 @@ end
local function onResourceDepleted(event)
local entity = event.entity
if (entity.surface.index == natives.activeSurface) then
chunkUtils.unregisterResource(entity, map)
unregisterResource(entity, map)
end
end

Expand Down
2 changes: 1 addition & 1 deletion info.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name" : "Rampant",
"factorio_version" : "0.17",
"version" : "0.17.25",
"version" : "0.17.26",
"title" : "Rampant",
"author" : "Veden",
"homepage" : "https://forums.factorio.com/viewtopic.php?f=94&t=31445",
Expand Down
26 changes: 15 additions & 11 deletions libs/ChunkProcessor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ local MAX_TICKS_BEFORE_SORT_CHUNKS = constants.MAX_TICKS_BEFORE_SORT_CHUNKS
-- imported functions

local createChunk = chunkUtils.createChunk
local mapScanChunk = chunkUtils.mapScanChunk
local initialScan = chunkUtils.initialScan
local chunkPassScan = chunkUtils.chunkPassScan

Expand Down Expand Up @@ -63,25 +64,28 @@ function chunkProcessor.processPendingChunks(natives, map, surface, pendingStack
local topLeft = event.area.left_top
local x = topLeft.x
local y = topLeft.y
local chunk = createChunk(x, y)

topOffset[1] = x
topOffset[2] = y
bottomOffset[1] = x + CHUNK_SIZE
bottomOffset[2] = y + CHUNK_SIZE

chunk = initialScan(chunk, natives, surface, map, tick, evolutionFactor, rebuilding)

if (chunk ~= SENTINEL_IMPASSABLE_CHUNK) then
local chunkX = chunk.x
if map[x] and map[x][y] then
mapScanChunk(map[x][y], surface, map)
else
if map[x] == nil then
map[x] = {}
end

if map[chunkX] == nil then
map[chunkX] = {}
end
map[chunkX][chunk.y] = chunk
local chunk = createChunk(x, y)

chunk = initialScan(chunk, natives, surface, map, tick, evolutionFactor, rebuilding)

processQueue[#processQueue+1] = chunk
end
if (chunk ~= SENTINEL_IMPASSABLE_CHUNK) then
map[x][y] = chunk
processQueue[#processQueue+1] = chunk
end
end
end

if (#processQueue > natives.nextChunkSort) or
Expand Down
18 changes: 5 additions & 13 deletions libs/ChunkPropertyUtils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ function chunkPropertyUtils.getWormCount(map, chunk)
end

function chunkPropertyUtils.setWormCount(map, chunk, count)
if (count == 0) then
if (count <= 0) then
map.chunkToWorms[chunk] = nil
else
map.chunkToWorms[chunk] = count
end
end

function chunkPropertyUtils.setNestCount(map, chunk, count)
if (count == 0) then
if (count <= 0) then
map.chunkToNests[chunk] = nil
else
map.chunkToNests[chunk] = count
Expand All @@ -43,7 +43,7 @@ function chunkPropertyUtils.getChunkSettlerTick(map, chunk)
end

function chunkPropertyUtils.setChunkSettlerTick(map, chunk, tick)
if (tick == 0) then
if (tick <= 0) then
map.chunkToSettler[chunk] = nil
else
map.chunkToSettler[chunk] = tick
Expand Down Expand Up @@ -87,21 +87,13 @@ function chunkPropertyUtils.setRetreatTick(map, chunk, tick)
end

function chunkPropertyUtils.setResourceGenerator(map, chunk, resourceGenerator)
if (resourceGenerator == 0) then
if (resourceGenerator <= 0) then
map.chunkToResource[chunk] = nil
else
map.chunkToResource[chunk] = resourceGenerator
end
end

function chunkPropertyUtils.setChunkSpawnerEggTick(map, chunk, tick)
map.chunkToSpawner[chunk] = tick
end

function chunkPropertyUtils.getChunkSpawnerEggTick(map, chunk)
return map.chunkToSpawner[chunk] or 0
end

function chunkPropertyUtils.getResourceGenerator(map, chunk)
return map.chunkToResource[chunk] or 0
end
Expand Down Expand Up @@ -223,7 +215,7 @@ function chunkPropertyUtils.getSquadsOnChunk(map, chunk)
end

function chunkPropertyUtils.setPlayerBaseGenerator(map, chunk, playerGenerator)
if (playerGenerator == 0) then
if (playerGenerator <= 0) then
map.chunkToPlayerBase[chunk] = nil
else
map.chunkToPlayerBase[chunk] = playerGenerator
Expand Down
28 changes: 19 additions & 9 deletions libs/ChunkUtils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,12 @@ local function scanPaths(chunk, surface, map)
end

local function scorePlayerBuildings(surface, map)
return (surface.count_entities_filtered(map.filteredEntitiesPlayerQuery50) * 50) +
(surface.count_entities_filtered(map.filteredEntitiesPlayerQuery200) * 200) +
(surface.count_entities_filtered(map.filteredEntitiesPlayerQuery1000) * 1000) +
(surface.count_entities_filtered(map.filteredEntitiesPlayerQuery2000) * 2000) +
(surface.count_entities_filtered(map.filteredEntitiesPlayerQuery3500) * 3500) +
(surface.count_entities_filtered(map.filteredEntitiesPlayerQuery12000) * 12000)
return (surface.count_entities_filtered(map.filteredEntitiesPlayerQuery50) * 25) +
(surface.count_entities_filtered(map.filteredEntitiesPlayerQuery200) * 100) +
(surface.count_entities_filtered(map.filteredEntitiesPlayerQuery1000) * 500) +
(surface.count_entities_filtered(map.filteredEntitiesPlayerQuery2000) * 1000) +
(surface.count_entities_filtered(map.filteredEntitiesPlayerQuery3500) * 1750) +
(surface.count_entities_filtered(map.filteredEntitiesPlayerQuery12000) * 6000)
end

function chunkUtils.initialScan(chunk, natives, surface, map, tick, evolutionFactor, rebuilding)
Expand Down Expand Up @@ -399,11 +399,11 @@ function chunkUtils.unregisterEnemyBaseStructure(map, entity)
end

function chunkUtils.accountPlayerEntity(map, entity, natives, addObject, creditNatives)

if (BUILDING_PHEROMONES[entity.type] ~= nil) and (entity.force.name ~= "enemy") then
local entityValue = BUILDING_PHEROMONES[entity.type]

local overlapArray = getEntityOverlapChunks(map, entity)
local overlapArray = getEntityOverlapChunks(map, entity)
if not addObject then
if creditNatives then
if (natives.state == AI_STATE_ONSLAUGHT) then
Expand Down Expand Up @@ -439,6 +439,16 @@ function chunkUtils.unregisterResource(entity, map)
end
end

function chunkUtils.registerResource(entity, map)
local overlapArray = getEntityOverlapChunks(map, entity)

for i=1,#overlapArray do
local chunk = overlapArray[i]
if (chunk ~= SENTINEL_IMPASSABLE_CHUNK) then
addResourceGenerator(map, chunk, RESOURCE_NORMALIZER)
end
end
end

function chunkUtils.makeImmortalEntity(surface, entity)
local repairPosition = entity.position
Expand Down
62 changes: 32 additions & 30 deletions libs/Constants.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ constants.VERSION_88 = 88

constants.MAGIC_MAXIMUM_NUMBER = 1e99 -- used in loops trying to find the lowest/highest score
constants.MAGIC_MAXIMUM_BASE_NUMBER = 100000000
constants.RETREAT_MOVEMENT_PHEROMONE_LEVEL_MIN = 10000
constants.RETREAT_MOVEMENT_PHEROMONE_LEVEL_MAX = 170000
constants.RETREAT_MOVEMENT_PHEROMONE_LEVEL_MIN = 13000
constants.RETREAT_MOVEMENT_PHEROMONE_LEVEL_MAX = 221000

constants.PROCESS_QUEUE_SIZE = 85
constants.SCAN_QUEUE_SIZE = 10
Expand Down Expand Up @@ -90,6 +90,8 @@ constants.CHUNK_ALL_DIRECTIONS = 3
constants.BASE_SEARCH_RADIUS = 4 * constants.CHUNK_SIZE
constants.EVOLUTION_INCREMENTS = 0.05

constants.DIVISOR_DEATH_TRAIL_TABLE = { 0.75, 0.65, 0.55, 0.45, 0.35 }

-- ai

constants.MAX_TICKS_BEFORE_SORT_CHUNKS = 60 * 60 * 30 -- 1 tick = 1/60 sec * 60 = 1 second
Expand All @@ -107,7 +109,7 @@ constants.AI_TUNNEL_COST = 100
constants.AI_MAX_POINTS = 12500
constants.AI_MAX_OVERFLOW_POINTS = constants.AI_MAX_POINTS * 3

constants.RAIDING_MINIMUM_BASE_THRESHOLD = 250
constants.RAIDING_MINIMUM_BASE_THRESHOLD = 550

constants.AI_UNIT_REFUND = 3

Expand All @@ -132,7 +134,7 @@ constants.BASE_AI_STATE_OVERDRIVE = 4
constants.BASE_AI_STATE_MUTATE = 5


constants.AGGRESSIVE_CAN_ATTACK_WAIT_MIN_DURATION = 1
constants.AGGRESSIVE_CAN_ATTACK_WAIT_MIN_DURATION = 0.5
constants.AGGRESSIVE_CAN_ATTACK_WAIT_MAX_DURATION = 3

constants.AI_MIN_STATE_DURATION = 7
Expand Down Expand Up @@ -380,7 +382,7 @@ constants.NO_RETREAT_SQUAD_SIZE_BONUS_MAX = 0.40
-- pheromone amounts

constants.MOVEMENT_PENALTY_AMOUNT = 300000
constants.DEATH_PHEROMONE_GENERATOR_AMOUNT = 750
constants.DEATH_PHEROMONE_GENERATOR_AMOUNT = 1300
constants.PLAYER_PHEROMONE_GENERATOR_AMOUNT = 300

constants.IMPASSABLE_TERRAIN_GENERATOR_AMOUNT = 0
Expand Down Expand Up @@ -436,31 +438,31 @@ constants.MAX_PENALTY_BEFORE_PURGE = 36000
-- player building pheromones

constants.BUILDING_PHEROMONES = {}
constants.BUILDING_PHEROMONES["wall"] = 50
constants.BUILDING_PHEROMONES["transport-belt"] = 50 -- 1
constants.BUILDING_PHEROMONES["splitter"] = 200
constants.BUILDING_PHEROMONES["pump"] = 200
constants.BUILDING_PHEROMONES["offshore-pump"] = 200 -- 2
constants.BUILDING_PHEROMONES["lamp"] = 1000
constants.BUILDING_PHEROMONES["generator"] = 1000
constants.BUILDING_PHEROMONES["solar-panel"] = 1000
constants.BUILDING_PHEROMONES["programmable-speaker"] = 1000
constants.BUILDING_PHEROMONES["accumulator"] = 1000
constants.BUILDING_PHEROMONES["assembling-machine"] = 1000
constants.BUILDING_PHEROMONES["turret"] = 1000
constants.BUILDING_PHEROMONES["roboport"] = 1000
constants.BUILDING_PHEROMONES["beacon"] = 1000
constants.BUILDING_PHEROMONES["ammo-turret"] = 1000 -- 3
constants.BUILDING_PHEROMONES["boiler"] = 2000
constants.BUILDING_PHEROMONES["furnace"] = 2000
constants.BUILDING_PHEROMONES["lab"] = 2000
constants.BUILDING_PHEROMONES["reactor"] = 2000
constants.BUILDING_PHEROMONES["radar"] = 2000
constants.BUILDING_PHEROMONES["electric-turret"] = 2000 -- 4
constants.BUILDING_PHEROMONES["fluid-turret"] = 3500
constants.BUILDING_PHEROMONES["mining-drill"] = 3500 -- 5
constants.BUILDING_PHEROMONES["artillery-turret"] = 12000
constants.BUILDING_PHEROMONES["rocket-silo"] = 12000 -- 6
constants.BUILDING_PHEROMONES["wall"] = 25
constants.BUILDING_PHEROMONES["transport-belt"] = 25 -- 1
constants.BUILDING_PHEROMONES["splitter"] = 100
constants.BUILDING_PHEROMONES["pump"] = 100
constants.BUILDING_PHEROMONES["offshore-pump"] = 100 -- 2
constants.BUILDING_PHEROMONES["lamp"] = 500
constants.BUILDING_PHEROMONES["generator"] = 500
constants.BUILDING_PHEROMONES["solar-panel"] = 500
constants.BUILDING_PHEROMONES["programmable-speaker"] = 500
constants.BUILDING_PHEROMONES["accumulator"] = 500
constants.BUILDING_PHEROMONES["assembling-machine"] = 500
constants.BUILDING_PHEROMONES["turret"] = 500
constants.BUILDING_PHEROMONES["roboport"] = 500
constants.BUILDING_PHEROMONES["beacon"] = 500
constants.BUILDING_PHEROMONES["ammo-turret"] = 500 -- 3
constants.BUILDING_PHEROMONES["boiler"] = 500
constants.BUILDING_PHEROMONES["furnace"] = 500
constants.BUILDING_PHEROMONES["lab"] = 500
constants.BUILDING_PHEROMONES["reactor"] = 500
constants.BUILDING_PHEROMONES["radar"] = 500
constants.BUILDING_PHEROMONES["electric-turret"] = 500 -- 4
constants.BUILDING_PHEROMONES["fluid-turret"] = 1750
constants.BUILDING_PHEROMONES["mining-drill"] = 1750 -- 5
constants.BUILDING_PHEROMONES["artillery-turret"] = 6000
constants.BUILDING_PHEROMONES["rocket-silo"] = 6000 -- 6


-- constants.RETREAT_FILTER = {}
Expand Down
Loading

0 comments on commit aa0bbf7

Please sign in to comment.