1
0
mirror of https://github.com/veden/Rampant.git synced 2025-01-26 03:20:07 +02:00

see changelog

This commit is contained in:
Aaron Veden 2019-05-15 22:11:43 -07:00
parent 70da8b9682
commit aa0bbf7839
13 changed files with 156 additions and 86 deletions

View File

@ -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

View File

@ -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

View File

@ -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
@ -203,7 +206,7 @@ local function rebuildMap()
map.chunkToRetreats = {}
map.chunkToRallys = {}
map.chunkToSpawner = {}
-- map.chunkToSpawner = {}
map.chunkToSettler = {}
map.chunkToPassable = {}
@ -538,12 +541,18 @@ 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
@ -551,7 +560,11 @@ 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
@ -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

View File

@ -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",

View File

@ -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
@ -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 map[x] and map[x][y] then
mapScanChunk(map[x][y], surface, map)
else
if map[x] == nil then
map[x] = {}
end
if (chunk ~= SENTINEL_IMPASSABLE_CHUNK) then
local chunkX = chunk.x
local chunk = createChunk(x, y)
chunk = initialScan(chunk, natives, surface, map, tick, evolutionFactor, rebuilding)
if map[chunkX] == nil then
map[chunkX] = {}
end
map[chunkX][chunk.y] = chunk
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

View File

@ -23,7 +23,7 @@ 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
@ -31,7 +31,7 @@ function chunkPropertyUtils.setWormCount(map, chunk, count)
end
function chunkPropertyUtils.setNestCount(map, chunk, count)
if (count == 0) then
if (count <= 0) then
map.chunkToNests[chunk] = nil
else
map.chunkToNests[chunk] = count
@ -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
@ -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
@ -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

View File

@ -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)
@ -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
@ -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

View File

@ -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
@ -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
@ -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
@ -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
@ -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
@ -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 = {}

View File

@ -285,13 +285,15 @@ function mapProcessor.scanMap(map, surface, natives, tick)
local retreats = map.chunkToRetreats
local rallys = map.chunkToRallys
local spawners = map.chunkToSpawner
-- local spawners = map.chunkToSpawner
local settlers = map.chunkToSettler
local drained = map.chunkToDrained
local processQueue = map.processQueue
local endIndex = mMin(index + SCAN_QUEUE_SIZE, #processQueue)
local isFullMapScan = settings.global["rampant-enableFullMapScan"].value
for x=index,endIndex do
local chunk = processQueue[x]
@ -311,12 +313,12 @@ function mapProcessor.scanMap(map, surface, natives, tick)
rallys[chunk] = nil
end
local spawnerTick = spawners[chunk]
if spawnerTick and ((tick - spawnerTick) > INTERVAL_SPAWNER) then
spawners[chunk] = nil
end
-- local spawnerTick = spawners[chunk]
-- if spawnerTick and ((tick - spawnerTick) > INTERVAL_SPAWNER) then
-- spawners[chunk] = nil
-- end
local settlerTick = spawners[chunk]
local settlerTick = settlers[chunk]
if settlerTick and ((tick - settlerTick) > 0) then
settlers[chunk] = nil
end
@ -336,7 +338,9 @@ function mapProcessor.scanMap(map, surface, natives, tick)
end
end
mapScanChunk(chunk, surface, map)
if isFullMapScan then
mapScanChunk(chunk, surface, map)
end
local nests = getNestCount(map, chunk)
if (nests > 0) then

View File

@ -21,6 +21,8 @@ local RESOURCE_PHEROMONE = constants.RESOURCE_PHEROMONE
local ATTACK_SCORE_KAMIKAZE = constants.ATTACK_SCORE_KAMIKAZE
local DIVISOR_DEATH_TRAIL_TABLE = constants.DIVISOR_DEATH_TRAIL_TABLE
local BASE_CLEAN_DISTANCE = constants.BASE_CLEAN_DISTANCE
local SQUAD_BUILDING = constants.SQUAD_BUILDING
@ -48,6 +50,7 @@ local SENTINEL_IMPASSABLE_CHUNK = constants.SENTINEL_IMPASSABLE_CHUNK
-- imported functions
local mRandom = math.random
local mMin = math.min
local tRemove = table.remove
local euclideanDistancePoints = mathUtils.euclideanDistancePoints
@ -55,6 +58,8 @@ local euclideanDistancePoints = mathUtils.euclideanDistancePoints
local findMovementPosition = movementUtils.findMovementPosition
local removeSquadFromChunk = chunkPropertyUtils.removeSquadFromChunk
local addDeathGenerator = chunkPropertyUtils.addDeathGenerator
local getDeathGenerator = chunkPropertyUtils.getDeathGenerator
local getNestCount = chunkPropertyUtils.getNestCount
@ -295,6 +300,13 @@ function squadAttack.squadsDispatch(map, surface, natives)
if (memberCount == 0) then
tRemove(squads, i)
removeSquadFromChunk(map, squad)
local deathGen = getDeathGenerator(map, squad.chunk)
local penalties = squad.penalties
for x=1,mMin(#squad.penalties,5) do
addDeathGenerator(map,
penalties[x].c,
deathGen * DIVISOR_DEATH_TRAIL_TABLE[x])
end
group.destroy()
elseif (memberCount > AI_MAX_BITER_GROUP_SIZE) then
local members = group.members

View File

@ -12502,6 +12502,7 @@ rampant-energyThiefEnemy=World: Energy Thief Biter Faction
rampant-poisonEnemy=World: Poison Biter Faction
rampant-disableCollidingProjectiles=Projectiles: Non biter force colliding projectiles
rampant-enableFullMapScan=Compatibility: Enable full map scanning
[mod-setting-description]
rampant-unitSpawnerBreath=Now unit spawners breath air so they are affected by things like poison capsules
@ -12589,4 +12590,5 @@ rampant-energyThiefEnemy=Energy Thief Biter Faction, Major resistance to Electri
rampant-poisonEnemy=Poison Biter Faction, Only Biters. On death creates a cloud that heals biters and hurts player objects. Major resistance to Poison, Minor weakness to Electric, Minor weakness to Explosive, Minor weakness to Laser, Minor resistance to Fire.
rampant-disableCollidingProjectiles=Biter projectiles no longer collide with other biters, worms or nests. Everything else still collides with biter projectiles.
rampant-liteMode=AI is still fully functional but the map scanning and processing is slowed, which will cause pheromones to remain longer, reduce the number of attacks spawned, and pheromones will spread slower.
rampant-liteMode=AI is still fully functional but the map scanning and processing is slowed, which will cause pheromones to remain longer, reduce the number of attacks spawned, and pheromones will spread slower.
rampant-enableFullMapScan=This setting causes the game map to slowly be scanned for entities created or destroyed outside of the factorio event system. (If a mod isn't using script_raised_built or script_raised_destroyed this will cause Rampant to still eventually be consistent with the game map)

View File

@ -17,7 +17,7 @@ data:extend({
default_value = true,
order = "b[modifier]-b[trigger]",
per_user = false
},
},
{
type = "bool-setting",
@ -539,6 +539,15 @@ data:extend({
per_user = false
},
{
type = "bool-setting",
name = "rampant-enableFullMapScan",
setting_type = "runtime-global",
default_value = false,
order = "n[modifier]-a[optimize]",
per_user = false
},
{
type = "bool-setting",
name = "rampant-unkillableLogisticRobots",

View File

@ -30,7 +30,7 @@ function tests.pheromoneLevels(size)
for i=1,#chunk do
str = str .. " " .. tostring(i) .. "/" .. tostring(chunk[i])
end
str = str .. " " .. "p/" .. game.surfaces[global.natives.activeSurface].get_pollution(chunk) .. " " .. "n/" .. chunkPropertyUtils.getNestCount(global.map, chunk) .. " " .. "w/" .. chunkPropertyUtils.getWormCount(global.map, chunk)
str = str .. " " .. "p/" .. game.surfaces[global.natives.activeSurface].get_pollution(chunk) .. " " .. "n/" .. chunkPropertyUtils.getNestCount(global.map, chunk) .. " " .. "w/" .. chunkPropertyUtils.getWormCount(global.map, chunk) .. " pg/" .. chunkPropertyUtils.getPlayerBaseGenerator(global.map, chunk)
if (chunk.x == playerChunkX) and (chunk.y == playerChunkY) then
print("=============")
print(chunk.x, chunk.y, str)