mirror of
https://github.com/veden/Rampant.git
synced 2025-03-17 20:58:35 +02:00
FACTO-127: Readded enemy static pheromone to chunks
This commit is contained in:
parent
267a4730e7
commit
989f4b3a46
16
Upgrade.lua
16
Upgrade.lua
@ -43,6 +43,9 @@ local DEFINES_DISTRACTION_BY_ANYTHING = defines.distraction.by_anything
|
||||
local CHUNK_SIZE = constants.CHUNK_SIZE
|
||||
local TRIPLE_CHUNK_SIZE = constants.TRIPLE_CHUNK_SIZE
|
||||
|
||||
local ENEMY_PHEROMONE = constants.ENEMY_PHEROMONE
|
||||
local CHUNK_TICK = constants.CHUNK_TICK
|
||||
|
||||
-- imported functions
|
||||
|
||||
local sFind = string.find
|
||||
@ -611,8 +614,19 @@ function upgrade.attempt(universe)
|
||||
global.version = 303
|
||||
|
||||
universe.entitySkipCountLookup = {}
|
||||
end
|
||||
if global.version < 304 then
|
||||
global.version = 304
|
||||
|
||||
game.print("Rampant - Version 3.0.3")
|
||||
for _,map in pairs(universe.maps) do
|
||||
local processQueue = map.processQueue
|
||||
for i=1,#processQueue do
|
||||
local chunk = processQueue[i]
|
||||
chunk[CHUNK_TICK] = chunk[ENEMY_PHEROMONE]
|
||||
end
|
||||
end
|
||||
|
||||
game.print("Rampant - Version 3.1.0")
|
||||
end
|
||||
|
||||
return (starting ~= global.version) and global.version
|
||||
|
@ -1,3 +1,8 @@
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Version: 3.1.0
|
||||
Improvements:
|
||||
- Readded enemy pheromone for pathfinding incorporating enemy bases
|
||||
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Version: 3.0.3
|
||||
Bugfixes:
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name" : "Rampant",
|
||||
"factorio_version" : "1.1",
|
||||
"version" : "3.0.3",
|
||||
"version" : "3.1.0",
|
||||
"title" : "Rampant",
|
||||
"author" : "Veden",
|
||||
"homepage" : "https://forums.factorio.com/viewtopic.php?f=94&t=31445",
|
||||
|
@ -42,6 +42,7 @@ local BASE_AI_STATE_ONSLAUGHT = constants.BASE_AI_STATE_ONSLAUGHT
|
||||
local BASE_PHEROMONE = constants.BASE_PHEROMONE
|
||||
local PLAYER_PHEROMONE = constants.PLAYER_PHEROMONE
|
||||
local RESOURCE_PHEROMONE = constants.RESOURCE_PHEROMONE
|
||||
local ENEMY_PHEROMONE = constants.ENEMY_PHEROMONE
|
||||
local BUILDING_PHEROMONES = constants.BUILDING_PHEROMONES
|
||||
|
||||
local CHUNK_SIZE = constants.CHUNK_SIZE
|
||||
@ -440,6 +441,7 @@ function chunkUtils.createChunk(map, topX, topY)
|
||||
chunk[BASE_PHEROMONE] = 0
|
||||
chunk[PLAYER_PHEROMONE] = 0
|
||||
chunk[RESOURCE_PHEROMONE] = 0
|
||||
chunk[ENEMY_PHEROMONE] = 0
|
||||
chunk[CHUNK_TICK] = 0
|
||||
|
||||
return chunk
|
||||
|
@ -214,10 +214,8 @@ constants.MOVEMENT_GENERATOR_PERSISTANCE = 0.92
|
||||
constants.BASE_PHEROMONE = 1
|
||||
constants.PLAYER_PHEROMONE = 2
|
||||
constants.RESOURCE_PHEROMONE = 3
|
||||
|
||||
-- constants.PASSABLE = 5
|
||||
|
||||
constants.CHUNK_TICK = 4
|
||||
constants.ENEMY_PHEROMONE = 4
|
||||
constants.CHUNK_TICK = 5
|
||||
|
||||
-- constants.PATH_RATING = 7
|
||||
|
||||
|
@ -39,6 +39,7 @@ local CHUNK_EAST_WEST = constants.CHUNK_EAST_WEST
|
||||
local BASE_PHEROMONE = constants.BASE_PHEROMONE
|
||||
local PLAYER_PHEROMONE = constants.PLAYER_PHEROMONE
|
||||
local RESOURCE_PHEROMONE = constants.RESOURCE_PHEROMONE
|
||||
local ENEMY_PHEROMONE = constants.ENEMY_PHEROMONE
|
||||
|
||||
local VICTORY_SCENT = constants.VICTORY_SCENT
|
||||
|
||||
@ -58,6 +59,8 @@ local getNeighborChunks = mapUtils.getNeighborChunks
|
||||
local getChunkById = mapUtils.getChunkById
|
||||
|
||||
local getEnemyStructureCount = chunkPropertyUtils.getEnemyStructureCount
|
||||
local getNestCount = chunkPropertyUtils.getNestCount
|
||||
local getHiveCount = chunkPropertyUtils.getHiveCount
|
||||
local getPathRating = chunkPropertyUtils.getPathRating
|
||||
local getPassable = chunkPropertyUtils.getPassable
|
||||
local getPlayerBaseGenerator = chunkPropertyUtils.getPlayerBaseGenerator
|
||||
@ -122,6 +125,7 @@ end
|
||||
function pheromoneUtils.processStaticPheromone(map, chunk)
|
||||
local chunkBase = -MAGIC_MAXIMUM_NUMBER
|
||||
local chunkResource = -MAGIC_MAXIMUM_NUMBER
|
||||
local chunkEnemy = -MAGIC_MAXIMUM_NUMBER
|
||||
local chunkPathRating = getPathRating(map, chunk)
|
||||
|
||||
local clear = getEnemyStructureCount(map, chunk)
|
||||
@ -142,6 +146,10 @@ function pheromoneUtils.processStaticPheromone(map, chunk)
|
||||
if chunkBase < pheromone then
|
||||
chunkBase = pheromone
|
||||
end
|
||||
pheromone = neighbor[ENEMY_PHEROMONE]
|
||||
if chunkEnemy < pheromone then
|
||||
chunkEnemy = pheromone
|
||||
end
|
||||
pheromone = neighbor[RESOURCE_PHEROMONE]
|
||||
if chunkResource < pheromone then
|
||||
chunkResource = pheromone
|
||||
@ -157,6 +165,10 @@ function pheromoneUtils.processStaticPheromone(map, chunk)
|
||||
if chunkBase < pheromone then
|
||||
chunkBase = pheromone
|
||||
end
|
||||
pheromone = neighbor[ENEMY_PHEROMONE]
|
||||
if chunkEnemy < pheromone then
|
||||
chunkEnemy = pheromone
|
||||
end
|
||||
pheromone = neighbor[RESOURCE_PHEROMONE]
|
||||
if chunkResource < pheromone then
|
||||
chunkResource = pheromone
|
||||
@ -172,6 +184,10 @@ function pheromoneUtils.processStaticPheromone(map, chunk)
|
||||
if chunkBase < pheromone then
|
||||
chunkBase = pheromone
|
||||
end
|
||||
pheromone = neighbor[ENEMY_PHEROMONE]
|
||||
if chunkEnemy < pheromone then
|
||||
chunkEnemy = pheromone
|
||||
end
|
||||
pheromone = neighbor[RESOURCE_PHEROMONE]
|
||||
if chunkResource < pheromone then
|
||||
chunkResource = pheromone
|
||||
@ -187,6 +203,10 @@ function pheromoneUtils.processStaticPheromone(map, chunk)
|
||||
if chunkBase < pheromone then
|
||||
chunkBase = pheromone
|
||||
end
|
||||
pheromone = neighbor[ENEMY_PHEROMONE]
|
||||
if chunkEnemy < pheromone then
|
||||
chunkEnemy = pheromone
|
||||
end
|
||||
pheromone = neighbor[RESOURCE_PHEROMONE]
|
||||
if chunkResource < pheromone then
|
||||
chunkResource = pheromone
|
||||
@ -202,6 +222,10 @@ function pheromoneUtils.processStaticPheromone(map, chunk)
|
||||
if chunkBase < pheromone then
|
||||
chunkBase = pheromone
|
||||
end
|
||||
pheromone = neighbor[ENEMY_PHEROMONE]
|
||||
if chunkEnemy < pheromone then
|
||||
chunkEnemy = pheromone
|
||||
end
|
||||
pheromone = neighbor[RESOURCE_PHEROMONE]
|
||||
if chunkResource < pheromone then
|
||||
chunkResource = pheromone
|
||||
@ -217,6 +241,10 @@ function pheromoneUtils.processStaticPheromone(map, chunk)
|
||||
if chunkBase < pheromone then
|
||||
chunkBase = pheromone
|
||||
end
|
||||
pheromone = neighbor[ENEMY_PHEROMONE]
|
||||
if chunkEnemy < pheromone then
|
||||
chunkEnemy = pheromone
|
||||
end
|
||||
pheromone = neighbor[RESOURCE_PHEROMONE]
|
||||
if chunkResource < pheromone then
|
||||
chunkResource = pheromone
|
||||
@ -232,6 +260,10 @@ function pheromoneUtils.processStaticPheromone(map, chunk)
|
||||
if chunkBase < pheromone then
|
||||
chunkBase = pheromone
|
||||
end
|
||||
pheromone = neighbor[ENEMY_PHEROMONE]
|
||||
if chunkEnemy < pheromone then
|
||||
chunkEnemy = pheromone
|
||||
end
|
||||
pheromone = neighbor[RESOURCE_PHEROMONE]
|
||||
if chunkResource < pheromone then
|
||||
chunkResource = pheromone
|
||||
@ -247,6 +279,10 @@ function pheromoneUtils.processStaticPheromone(map, chunk)
|
||||
if chunkBase < pheromone then
|
||||
chunkBase = pheromone
|
||||
end
|
||||
pheromone = neighbor[ENEMY_PHEROMONE]
|
||||
if chunkEnemy < pheromone then
|
||||
chunkEnemy = pheromone
|
||||
end
|
||||
pheromone = neighbor[RESOURCE_PHEROMONE]
|
||||
if chunkResource < pheromone then
|
||||
chunkResource = pheromone
|
||||
@ -263,6 +299,10 @@ function pheromoneUtils.processStaticPheromone(map, chunk)
|
||||
if chunkBase < pheromone then
|
||||
chunkBase = pheromone
|
||||
end
|
||||
pheromone = neighbor[ENEMY_PHEROMONE]
|
||||
if chunkEnemy < pheromone then
|
||||
chunkEnemy = pheromone
|
||||
end
|
||||
pheromone = neighbor[RESOURCE_PHEROMONE]
|
||||
if chunkResource < pheromone then
|
||||
chunkResource = pheromone
|
||||
@ -278,6 +318,10 @@ function pheromoneUtils.processStaticPheromone(map, chunk)
|
||||
if chunkBase < pheromone then
|
||||
chunkBase = pheromone
|
||||
end
|
||||
pheromone = neighbor[ENEMY_PHEROMONE]
|
||||
if chunkEnemy < pheromone then
|
||||
chunkEnemy = pheromone
|
||||
end
|
||||
pheromone = neighbor[RESOURCE_PHEROMONE]
|
||||
if chunkResource < pheromone then
|
||||
chunkResource = pheromone
|
||||
@ -294,6 +338,10 @@ function pheromoneUtils.processStaticPheromone(map, chunk)
|
||||
if chunkBase < pheromone then
|
||||
chunkBase = pheromone
|
||||
end
|
||||
pheromone = neighbor[ENEMY_PHEROMONE]
|
||||
if chunkEnemy < pheromone then
|
||||
chunkEnemy = pheromone
|
||||
end
|
||||
pheromone = neighbor[RESOURCE_PHEROMONE]
|
||||
if chunkResource < pheromone then
|
||||
chunkResource = pheromone
|
||||
@ -309,6 +357,10 @@ function pheromoneUtils.processStaticPheromone(map, chunk)
|
||||
if chunkBase < pheromone then
|
||||
chunkBase = pheromone
|
||||
end
|
||||
pheromone = neighbor[ENEMY_PHEROMONE]
|
||||
if chunkEnemy < pheromone then
|
||||
chunkEnemy = pheromone
|
||||
end
|
||||
pheromone = neighbor[RESOURCE_PHEROMONE]
|
||||
if chunkResource < pheromone then
|
||||
chunkResource = pheromone
|
||||
@ -325,6 +377,13 @@ function pheromoneUtils.processStaticPheromone(map, chunk)
|
||||
chunk[BASE_PHEROMONE] = chunkBase * chunkPathRating
|
||||
end
|
||||
|
||||
pheromone = getNestCount(map, chunk) + getHiveCount(map, chunk)
|
||||
if chunkEnemy < pheromone then
|
||||
chunk[ENEMY_PHEROMONE] = pheromone * chunkPathRating
|
||||
else
|
||||
chunk[ENEMY_PHEROMONE] = chunkEnemy * chunkPathRating
|
||||
end
|
||||
|
||||
chunkResource = chunkResource * 0.9
|
||||
pheromone = getResourceGenerator(map, chunk)
|
||||
if (pheromone > 0) and clear then
|
||||
|
Loading…
x
Reference in New Issue
Block a user