2019-02-16 06:17:30 +02:00
|
|
|
if pheromoneUtilsG then
|
|
|
|
return pheromoneUtilsG
|
|
|
|
end
|
2016-08-05 06:47:51 +02:00
|
|
|
local pheromoneUtils = {}
|
|
|
|
|
2016-08-20 04:52:27 +02:00
|
|
|
-- imports
|
2018-02-14 10:28:42 +02:00
|
|
|
local mathUtils = require("MathUtils")
|
2016-08-05 06:47:51 +02:00
|
|
|
local mapUtils = require("MapUtils")
|
|
|
|
local constants = require("Constants")
|
2018-01-15 09:41:55 +02:00
|
|
|
local chunkPropertyUtils = require("ChunkPropertyUtils")
|
2016-08-20 04:52:27 +02:00
|
|
|
|
|
|
|
-- constants
|
|
|
|
|
2020-05-25 01:41:12 +02:00
|
|
|
local VICTORY_SCENT_MULTIPLER = constants.VICTORY_SCENT_MULTIPLER
|
|
|
|
local VICTORY_SCENT_BOUND = constants.VICTORY_SCENT_BOUND
|
|
|
|
|
2020-05-22 08:57:03 +02:00
|
|
|
local MAGIC_MAXIMUM_NUMBER = constants.MAGIC_MAXIMUM_NUMBER
|
|
|
|
|
2019-10-19 21:13:48 +02:00
|
|
|
local CHUNK_ALL_DIRECTIONS = constants.CHUNK_ALL_DIRECTIONS
|
|
|
|
local CHUNK_NORTH_SOUTH = constants.CHUNK_NORTH_SOUTH
|
|
|
|
local CHUNK_EAST_WEST = constants.CHUNK_EAST_WEST
|
|
|
|
|
2016-10-15 02:00:18 +02:00
|
|
|
local BASE_PHEROMONE = constants.BASE_PHEROMONE
|
2016-08-20 04:52:27 +02:00
|
|
|
local PLAYER_PHEROMONE = constants.PLAYER_PHEROMONE
|
2017-06-08 02:57:24 +02:00
|
|
|
local RESOURCE_PHEROMONE = constants.RESOURCE_PHEROMONE
|
2016-08-20 04:52:27 +02:00
|
|
|
|
2019-10-19 23:04:38 +02:00
|
|
|
local VICTORY_SCENT = constants.VICTORY_SCENT
|
2017-04-22 01:14:04 +02:00
|
|
|
|
2016-08-20 04:52:27 +02:00
|
|
|
local PLAYER_PHEROMONE_GENERATOR_AMOUNT = constants.PLAYER_PHEROMONE_GENERATOR_AMOUNT
|
|
|
|
|
2018-09-26 07:14:13 +02:00
|
|
|
local DEATH_PHEROMONE_GENERATOR_AMOUNT = constants.DEATH_PHEROMONE_GENERATOR_AMOUNT
|
|
|
|
|
2016-08-20 04:52:27 +02:00
|
|
|
-- imported functions
|
|
|
|
|
2020-05-25 01:41:12 +02:00
|
|
|
local addVictoryGenerator = chunkPropertyUtils.addVictoryGenerator
|
|
|
|
|
2020-05-22 08:57:03 +02:00
|
|
|
local getPlayersOnChunk = chunkPropertyUtils.getPlayersOnChunk
|
|
|
|
|
2018-09-26 07:14:13 +02:00
|
|
|
local getNeighborChunks = mapUtils.getNeighborChunks
|
2016-08-20 04:52:27 +02:00
|
|
|
|
2018-01-15 09:41:55 +02:00
|
|
|
local getEnemyStructureCount = chunkPropertyUtils.getEnemyStructureCount
|
2018-09-24 06:56:45 +02:00
|
|
|
local getPathRating = chunkPropertyUtils.getPathRating
|
2019-10-19 21:13:48 +02:00
|
|
|
local getPassable = chunkPropertyUtils.getPassable
|
2018-01-15 09:41:55 +02:00
|
|
|
local getPlayerBaseGenerator = chunkPropertyUtils.getPlayerBaseGenerator
|
|
|
|
local getResourceGenerator = chunkPropertyUtils.getResourceGenerator
|
2018-09-24 06:56:45 +02:00
|
|
|
local addDeathGenerator = chunkPropertyUtils.addDeathGenerator
|
|
|
|
|
|
|
|
local decayDeathGenerator = chunkPropertyUtils.decayDeathGenerator
|
2017-08-08 10:19:51 +02:00
|
|
|
|
2019-02-11 08:14:17 +02:00
|
|
|
local linearInterpolation = mathUtils.linearInterpolation
|
2018-02-14 10:28:42 +02:00
|
|
|
|
2020-05-25 01:41:12 +02:00
|
|
|
local getChunkByXY = mapUtils.getChunkByXY
|
|
|
|
|
|
|
|
local next = next
|
|
|
|
|
2016-08-20 04:52:27 +02:00
|
|
|
-- module code
|
2017-01-20 07:58:36 +02:00
|
|
|
|
2018-09-26 07:14:13 +02:00
|
|
|
function pheromoneUtils.victoryScent(map, chunk, entityType)
|
2019-10-19 23:04:38 +02:00
|
|
|
local value = VICTORY_SCENT[entityType]
|
2017-11-21 09:27:03 +02:00
|
|
|
if value then
|
2020-05-25 01:41:12 +02:00
|
|
|
addVictoryGenerator(map, chunk, value)
|
2017-04-22 01:14:04 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-05-25 01:41:12 +02:00
|
|
|
function pheromoneUtils.disperseVictoryScent(map)
|
2021-11-25 20:20:33 +02:00
|
|
|
local chunk = map.victoryScentIterator
|
2020-05-25 01:41:12 +02:00
|
|
|
local chunkToVictory = map.chunkToVictory
|
2021-11-25 20:20:33 +02:00
|
|
|
local pheromone
|
|
|
|
if not chunk then
|
|
|
|
chunk, pheromone = next(chunkToVictory, nil)
|
|
|
|
else
|
|
|
|
pheromone = chunkToVictory[chunk]
|
|
|
|
end
|
|
|
|
if not chunk then
|
|
|
|
map.victoryScentIterator = nil
|
|
|
|
else
|
|
|
|
map.victoryScentIterator = next(chunkToVictory, chunk)
|
2020-05-25 01:41:12 +02:00
|
|
|
local chunkX = chunk.x
|
|
|
|
local chunkY = chunk.y
|
|
|
|
local i = 1
|
2020-05-25 05:25:21 +02:00
|
|
|
for x=chunkX - VICTORY_SCENT_BOUND, chunkX + VICTORY_SCENT_BOUND,32 do
|
|
|
|
for y = chunkY - VICTORY_SCENT_BOUND, chunkY + VICTORY_SCENT_BOUND,32 do
|
2020-05-25 01:41:12 +02:00
|
|
|
local c = getChunkByXY(map, x, y)
|
|
|
|
if (c ~= -1) then
|
2020-05-25 05:25:21 +02:00
|
|
|
addDeathGenerator(map, c, -pheromone * VICTORY_SCENT_MULTIPLER[i] * getPathRating(map, c))
|
2020-05-25 01:41:12 +02:00
|
|
|
end
|
2020-05-25 05:25:21 +02:00
|
|
|
i = i + 1
|
2020-05-25 01:41:12 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
chunkToVictory[chunk] = nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-09-24 06:56:45 +02:00
|
|
|
function pheromoneUtils.deathScent(map, chunk)
|
2020-05-23 23:29:56 +02:00
|
|
|
addDeathGenerator(map, chunk, DEATH_PHEROMONE_GENERATOR_AMOUNT)
|
2016-08-05 06:47:51 +02:00
|
|
|
end
|
|
|
|
|
2020-05-22 20:45:05 +02:00
|
|
|
function pheromoneUtils.processStaticPheromone(map, chunk)
|
|
|
|
local chunkBase = -MAGIC_MAXIMUM_NUMBER
|
|
|
|
local chunkResource = -MAGIC_MAXIMUM_NUMBER
|
|
|
|
local chunkPathRating = getPathRating(map, chunk)
|
2019-02-11 08:14:17 +02:00
|
|
|
|
2020-05-22 20:45:05 +02:00
|
|
|
local clear = getEnemyStructureCount(map, chunk)
|
2019-03-06 08:18:03 +02:00
|
|
|
|
2020-05-22 20:45:05 +02:00
|
|
|
local tempNeighbors = getNeighborChunks(map, chunk.x, chunk.y)
|
|
|
|
|
|
|
|
local neighbor
|
|
|
|
local neighborPass
|
|
|
|
|
|
|
|
local chunkPass = getPassable(map, chunk)
|
|
|
|
local pheromone
|
|
|
|
if (chunkPass == CHUNK_ALL_DIRECTIONS) then
|
|
|
|
neighbor = tempNeighbors[2]
|
|
|
|
if (neighbor ~= -1) then
|
|
|
|
neighborPass = getPassable(map, neighbor)
|
|
|
|
if ((neighborPass == CHUNK_ALL_DIRECTIONS) or (neighborPass == CHUNK_NORTH_SOUTH)) then
|
|
|
|
pheromone = neighbor[BASE_PHEROMONE]
|
|
|
|
if chunkBase < pheromone then
|
|
|
|
chunkBase = pheromone
|
|
|
|
end
|
|
|
|
pheromone = neighbor[RESOURCE_PHEROMONE]
|
|
|
|
if chunkResource < pheromone then
|
|
|
|
chunkResource = pheromone
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
neighbor = tempNeighbors[7]
|
|
|
|
if (neighbor ~= -1) then
|
|
|
|
neighborPass = getPassable(map, neighbor)
|
|
|
|
if ((neighborPass == CHUNK_ALL_DIRECTIONS) or (neighborPass == CHUNK_NORTH_SOUTH)) then
|
|
|
|
pheromone = neighbor[BASE_PHEROMONE]
|
|
|
|
if chunkBase < pheromone then
|
|
|
|
chunkBase = pheromone
|
|
|
|
end
|
|
|
|
pheromone = neighbor[RESOURCE_PHEROMONE]
|
|
|
|
if chunkResource < pheromone then
|
|
|
|
chunkResource = pheromone
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
neighbor = tempNeighbors[4]
|
|
|
|
if (neighbor ~= -1) then
|
|
|
|
neighborPass = getPassable(map, neighbor)
|
|
|
|
if ((neighborPass == CHUNK_ALL_DIRECTIONS) or (neighborPass == CHUNK_EAST_WEST)) then
|
|
|
|
pheromone = neighbor[BASE_PHEROMONE]
|
|
|
|
if chunkBase < pheromone then
|
|
|
|
chunkBase = pheromone
|
|
|
|
end
|
|
|
|
pheromone = neighbor[RESOURCE_PHEROMONE]
|
|
|
|
if chunkResource < pheromone then
|
|
|
|
chunkResource = pheromone
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
neighbor = tempNeighbors[5]
|
|
|
|
if (neighbor ~= -1) then
|
|
|
|
neighborPass = getPassable(map, neighbor)
|
|
|
|
if ((neighborPass == CHUNK_ALL_DIRECTIONS) or (neighborPass == CHUNK_EAST_WEST)) then
|
|
|
|
pheromone = neighbor[BASE_PHEROMONE]
|
|
|
|
if chunkBase < pheromone then
|
|
|
|
chunkBase = pheromone
|
|
|
|
end
|
|
|
|
pheromone = neighbor[RESOURCE_PHEROMONE]
|
|
|
|
if chunkResource < pheromone then
|
|
|
|
chunkResource = pheromone
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
neighbor = tempNeighbors[1]
|
|
|
|
if (neighbor ~= -1) then
|
|
|
|
neighborPass = getPassable(map, neighbor)
|
|
|
|
if (neighborPass == CHUNK_ALL_DIRECTIONS) then
|
|
|
|
pheromone = neighbor[BASE_PHEROMONE]
|
|
|
|
if chunkBase < pheromone then
|
|
|
|
chunkBase = pheromone
|
|
|
|
end
|
|
|
|
pheromone = neighbor[RESOURCE_PHEROMONE]
|
|
|
|
if chunkResource < pheromone then
|
|
|
|
chunkResource = pheromone
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
neighbor = tempNeighbors[3]
|
|
|
|
if (neighbor ~= -1) then
|
|
|
|
neighborPass = getPassable(map, neighbor)
|
|
|
|
if (neighborPass == CHUNK_ALL_DIRECTIONS) then
|
|
|
|
pheromone = neighbor[BASE_PHEROMONE]
|
|
|
|
if chunkBase < pheromone then
|
|
|
|
chunkBase = pheromone
|
|
|
|
end
|
|
|
|
pheromone = neighbor[RESOURCE_PHEROMONE]
|
|
|
|
if chunkResource < pheromone then
|
|
|
|
chunkResource = pheromone
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
neighbor = tempNeighbors[6]
|
|
|
|
if (neighbor ~= -1) then
|
|
|
|
neighborPass = getPassable(map, neighbor)
|
|
|
|
if (neighborPass == CHUNK_ALL_DIRECTIONS) then
|
|
|
|
pheromone = neighbor[BASE_PHEROMONE]
|
|
|
|
if chunkBase < pheromone then
|
|
|
|
chunkBase = pheromone
|
|
|
|
end
|
|
|
|
pheromone = neighbor[RESOURCE_PHEROMONE]
|
|
|
|
if chunkResource < pheromone then
|
|
|
|
chunkResource = pheromone
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
neighbor = tempNeighbors[8]
|
|
|
|
if (neighbor ~= -1) then
|
|
|
|
neighborPass = getPassable(map, neighbor)
|
|
|
|
if (neighborPass == CHUNK_ALL_DIRECTIONS) then
|
|
|
|
pheromone = neighbor[BASE_PHEROMONE]
|
|
|
|
if chunkBase < pheromone then
|
|
|
|
chunkBase = pheromone
|
|
|
|
end
|
|
|
|
pheromone = neighbor[RESOURCE_PHEROMONE]
|
|
|
|
if chunkResource < pheromone then
|
|
|
|
chunkResource = pheromone
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
elseif (chunkPass == CHUNK_EAST_WEST) then
|
|
|
|
|
|
|
|
neighbor = tempNeighbors[4]
|
|
|
|
if (neighbor ~= -1) then
|
|
|
|
neighborPass = getPassable(map, neighbor)
|
|
|
|
if ((neighborPass == CHUNK_ALL_DIRECTIONS) or (neighborPass == CHUNK_EAST_WEST)) then
|
|
|
|
pheromone = neighbor[BASE_PHEROMONE]
|
|
|
|
if chunkBase < pheromone then
|
|
|
|
chunkBase = pheromone
|
|
|
|
end
|
|
|
|
pheromone = neighbor[RESOURCE_PHEROMONE]
|
|
|
|
if chunkResource < pheromone then
|
|
|
|
chunkResource = pheromone
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2019-10-19 23:04:38 +02:00
|
|
|
|
2020-05-22 20:45:05 +02:00
|
|
|
neighbor = tempNeighbors[5]
|
|
|
|
if (neighbor ~= -1) then
|
|
|
|
neighborPass = getPassable(map, neighbor)
|
|
|
|
if ((neighborPass == CHUNK_ALL_DIRECTIONS) or (neighborPass == CHUNK_EAST_WEST)) then
|
|
|
|
pheromone = neighbor[BASE_PHEROMONE]
|
|
|
|
if chunkBase < pheromone then
|
|
|
|
chunkBase = pheromone
|
|
|
|
end
|
|
|
|
pheromone = neighbor[RESOURCE_PHEROMONE]
|
|
|
|
if chunkResource < pheromone then
|
|
|
|
chunkResource = pheromone
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
elseif (chunkPass == CHUNK_NORTH_SOUTH) then
|
|
|
|
|
|
|
|
neighbor = tempNeighbors[2]
|
|
|
|
if (neighbor ~= -1) then
|
|
|
|
neighborPass = getPassable(map, neighbor)
|
|
|
|
if ((neighborPass == CHUNK_ALL_DIRECTIONS) or (neighborPass == CHUNK_NORTH_SOUTH)) then
|
|
|
|
pheromone = neighbor[BASE_PHEROMONE]
|
|
|
|
if chunkBase < pheromone then
|
|
|
|
chunkBase = pheromone
|
|
|
|
end
|
|
|
|
pheromone = neighbor[RESOURCE_PHEROMONE]
|
|
|
|
if chunkResource < pheromone then
|
|
|
|
chunkResource = pheromone
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
neighbor = tempNeighbors[7]
|
|
|
|
if (neighbor ~= -1) then
|
|
|
|
neighborPass = getPassable(map, neighbor)
|
|
|
|
if ((neighborPass == CHUNK_ALL_DIRECTIONS) or (neighborPass == CHUNK_NORTH_SOUTH)) then
|
|
|
|
pheromone = neighbor[BASE_PHEROMONE]
|
|
|
|
if chunkBase < pheromone then
|
|
|
|
chunkBase = pheromone
|
|
|
|
end
|
|
|
|
pheromone = neighbor[RESOURCE_PHEROMONE]
|
|
|
|
if chunkResource < pheromone then
|
|
|
|
chunkResource = pheromone
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
chunkBase = chunkBase * 0.9
|
2021-02-14 06:49:54 +02:00
|
|
|
pheromone = getPlayerBaseGenerator(map, chunk)
|
2020-05-22 20:45:05 +02:00
|
|
|
if chunkBase < pheromone then
|
|
|
|
chunk[BASE_PHEROMONE] = pheromone * chunkPathRating
|
|
|
|
else
|
|
|
|
chunk[BASE_PHEROMONE] = chunkBase * chunkPathRating
|
|
|
|
end
|
|
|
|
|
|
|
|
chunkResource = chunkResource * 0.9
|
2021-02-14 06:49:54 +02:00
|
|
|
pheromone = getResourceGenerator(map, chunk)
|
2020-05-23 23:29:56 +02:00
|
|
|
if (pheromone > 0) and clear then
|
|
|
|
pheromone = linearInterpolation(pheromone, 15000, 20000)
|
|
|
|
end
|
2020-05-22 20:45:05 +02:00
|
|
|
if chunkResource < pheromone then
|
2020-05-23 06:22:40 +02:00
|
|
|
if clear then
|
2020-05-22 20:45:05 +02:00
|
|
|
chunk[RESOURCE_PHEROMONE] = pheromone * chunkPathRating
|
|
|
|
else
|
|
|
|
chunk[RESOURCE_PHEROMONE] = pheromone * chunkPathRating * 0.1
|
2020-05-23 06:22:40 +02:00
|
|
|
end
|
2020-05-22 20:45:05 +02:00
|
|
|
else
|
|
|
|
if clear then
|
|
|
|
chunk[RESOURCE_PHEROMONE] = chunkResource * chunkPathRating
|
|
|
|
else
|
|
|
|
chunk[RESOURCE_PHEROMONE] = chunkResource * chunkPathRating * 0.1
|
2020-05-23 06:22:40 +02:00
|
|
|
end
|
2020-05-22 20:45:05 +02:00
|
|
|
end
|
2018-10-20 07:17:37 +02:00
|
|
|
end
|
|
|
|
|
2020-05-24 05:47:14 +02:00
|
|
|
function pheromoneUtils.processPheromone(map, chunk, player)
|
2020-05-22 08:57:03 +02:00
|
|
|
local chunkPlayer = -MAGIC_MAXIMUM_NUMBER
|
2018-09-24 06:56:45 +02:00
|
|
|
local chunkPathRating = getPathRating(map, chunk)
|
2018-02-13 09:10:17 +02:00
|
|
|
|
2018-10-20 07:17:37 +02:00
|
|
|
local tempNeighbors = getNeighborChunks(map, chunk.x, chunk.y)
|
2017-11-21 09:27:03 +02:00
|
|
|
|
2019-10-19 23:04:38 +02:00
|
|
|
local neighbor
|
|
|
|
local neighborPass
|
|
|
|
|
2019-10-19 21:13:48 +02:00
|
|
|
local chunkPass = getPassable(map, chunk)
|
2020-05-22 08:57:03 +02:00
|
|
|
local pheromone
|
2019-10-19 21:13:48 +02:00
|
|
|
if (chunkPass == CHUNK_ALL_DIRECTIONS) then
|
2020-05-22 08:57:03 +02:00
|
|
|
neighbor = tempNeighbors[2]
|
2020-05-20 04:37:16 +02:00
|
|
|
if (neighbor ~= -1) then
|
|
|
|
neighborPass = getPassable(map, neighbor)
|
|
|
|
if ((neighborPass == CHUNK_ALL_DIRECTIONS) or (neighborPass == CHUNK_NORTH_SOUTH)) then
|
2020-05-22 08:57:03 +02:00
|
|
|
pheromone = neighbor[PLAYER_PHEROMONE]
|
|
|
|
if chunkPlayer < pheromone then
|
|
|
|
chunkPlayer = pheromone
|
|
|
|
end
|
2020-05-20 04:37:16 +02:00
|
|
|
end
|
2019-10-19 21:13:48 +02:00
|
|
|
end
|
|
|
|
|
2019-10-19 23:04:38 +02:00
|
|
|
neighbor = tempNeighbors[7]
|
2020-05-22 08:57:03 +02:00
|
|
|
if (neighbor ~= -1) then
|
2020-05-20 04:37:16 +02:00
|
|
|
neighborPass = getPassable(map, neighbor)
|
|
|
|
if ((neighborPass == CHUNK_ALL_DIRECTIONS) or (neighborPass == CHUNK_NORTH_SOUTH)) then
|
2020-05-22 08:57:03 +02:00
|
|
|
pheromone = neighbor[PLAYER_PHEROMONE]
|
|
|
|
if chunkPlayer < pheromone then
|
|
|
|
chunkPlayer = pheromone
|
|
|
|
end
|
2020-05-20 04:37:16 +02:00
|
|
|
end
|
2019-10-19 21:13:48 +02:00
|
|
|
end
|
|
|
|
|
2019-10-19 23:04:38 +02:00
|
|
|
neighbor = tempNeighbors[4]
|
2020-05-22 08:57:03 +02:00
|
|
|
if (neighbor ~= -1) then
|
2020-05-20 04:37:16 +02:00
|
|
|
neighborPass = getPassable(map, neighbor)
|
|
|
|
if ((neighborPass == CHUNK_ALL_DIRECTIONS) or (neighborPass == CHUNK_EAST_WEST)) then
|
2020-05-22 08:57:03 +02:00
|
|
|
pheromone = neighbor[PLAYER_PHEROMONE]
|
|
|
|
if chunkPlayer < pheromone then
|
|
|
|
chunkPlayer = pheromone
|
|
|
|
end
|
2020-05-20 04:37:16 +02:00
|
|
|
end
|
2019-10-19 21:13:48 +02:00
|
|
|
end
|
|
|
|
|
2019-10-19 23:04:38 +02:00
|
|
|
neighbor = tempNeighbors[5]
|
2020-05-20 04:37:16 +02:00
|
|
|
if (neighbor ~= -1) then
|
|
|
|
neighborPass = getPassable(map, neighbor)
|
|
|
|
if ((neighborPass == CHUNK_ALL_DIRECTIONS) or (neighborPass == CHUNK_EAST_WEST)) then
|
2020-05-22 08:57:03 +02:00
|
|
|
pheromone = neighbor[PLAYER_PHEROMONE]
|
|
|
|
if chunkPlayer < pheromone then
|
|
|
|
chunkPlayer = pheromone
|
|
|
|
end
|
2020-05-20 04:37:16 +02:00
|
|
|
end
|
2019-10-19 21:13:48 +02:00
|
|
|
end
|
|
|
|
|
2019-10-19 23:04:38 +02:00
|
|
|
neighbor = tempNeighbors[1]
|
2020-05-22 08:57:03 +02:00
|
|
|
if (neighbor ~= -1) then
|
2020-05-20 04:37:16 +02:00
|
|
|
neighborPass = getPassable(map, neighbor)
|
|
|
|
if (neighborPass == CHUNK_ALL_DIRECTIONS) then
|
2020-05-22 08:57:03 +02:00
|
|
|
pheromone = neighbor[PLAYER_PHEROMONE]
|
|
|
|
if chunkPlayer < pheromone then
|
|
|
|
chunkPlayer = pheromone
|
|
|
|
end
|
2020-05-20 04:37:16 +02:00
|
|
|
end
|
2019-10-19 21:13:48 +02:00
|
|
|
end
|
|
|
|
|
2019-10-19 23:04:38 +02:00
|
|
|
neighbor = tempNeighbors[3]
|
2020-05-22 08:57:03 +02:00
|
|
|
if (neighbor ~= -1) then
|
2020-05-20 04:37:16 +02:00
|
|
|
neighborPass = getPassable(map, neighbor)
|
|
|
|
if (neighborPass == CHUNK_ALL_DIRECTIONS) then
|
2020-05-22 08:57:03 +02:00
|
|
|
pheromone = neighbor[PLAYER_PHEROMONE]
|
|
|
|
if chunkPlayer < pheromone then
|
|
|
|
chunkPlayer = pheromone
|
|
|
|
end
|
2020-05-20 04:37:16 +02:00
|
|
|
end
|
2019-10-19 21:13:48 +02:00
|
|
|
end
|
|
|
|
|
2019-10-19 23:04:38 +02:00
|
|
|
neighbor = tempNeighbors[6]
|
2020-05-22 08:57:03 +02:00
|
|
|
if (neighbor ~= -1) then
|
2020-05-20 04:37:16 +02:00
|
|
|
neighborPass = getPassable(map, neighbor)
|
|
|
|
if (neighborPass == CHUNK_ALL_DIRECTIONS) then
|
2020-05-22 08:57:03 +02:00
|
|
|
pheromone = neighbor[PLAYER_PHEROMONE]
|
|
|
|
if chunkPlayer < pheromone then
|
|
|
|
chunkPlayer = pheromone
|
|
|
|
end
|
2020-05-20 04:37:16 +02:00
|
|
|
end
|
2019-10-19 21:13:48 +02:00
|
|
|
end
|
|
|
|
|
2019-10-19 23:04:38 +02:00
|
|
|
neighbor = tempNeighbors[8]
|
2020-05-20 04:37:16 +02:00
|
|
|
if (neighbor ~= -1) then
|
|
|
|
neighborPass = getPassable(map, neighbor)
|
|
|
|
if (neighborPass == CHUNK_ALL_DIRECTIONS) then
|
2020-05-22 08:57:03 +02:00
|
|
|
pheromone = neighbor[PLAYER_PHEROMONE]
|
|
|
|
if chunkPlayer < pheromone then
|
|
|
|
chunkPlayer = pheromone
|
|
|
|
end
|
2020-05-20 04:37:16 +02:00
|
|
|
end
|
2019-10-19 21:13:48 +02:00
|
|
|
end
|
|
|
|
elseif (chunkPass == CHUNK_EAST_WEST) then
|
|
|
|
|
2019-10-19 23:04:38 +02:00
|
|
|
neighbor = tempNeighbors[4]
|
2020-05-22 08:57:03 +02:00
|
|
|
if (neighbor ~= -1) then
|
2020-05-20 04:37:16 +02:00
|
|
|
neighborPass = getPassable(map, neighbor)
|
|
|
|
if ((neighborPass == CHUNK_ALL_DIRECTIONS) or (neighborPass == CHUNK_EAST_WEST)) then
|
2020-05-22 08:57:03 +02:00
|
|
|
pheromone = neighbor[PLAYER_PHEROMONE]
|
|
|
|
if chunkPlayer < pheromone then
|
|
|
|
chunkPlayer = pheromone
|
|
|
|
end
|
2020-05-20 04:37:16 +02:00
|
|
|
end
|
2019-10-19 21:13:48 +02:00
|
|
|
end
|
|
|
|
|
2019-10-19 23:04:38 +02:00
|
|
|
neighbor = tempNeighbors[5]
|
2020-05-22 08:57:03 +02:00
|
|
|
if (neighbor ~= -1) then
|
2020-05-20 04:37:16 +02:00
|
|
|
neighborPass = getPassable(map, neighbor)
|
|
|
|
if ((neighborPass == CHUNK_ALL_DIRECTIONS) or (neighborPass == CHUNK_EAST_WEST)) then
|
2020-05-22 08:57:03 +02:00
|
|
|
pheromone = neighbor[PLAYER_PHEROMONE]
|
|
|
|
if chunkPlayer < pheromone then
|
|
|
|
chunkPlayer = pheromone
|
|
|
|
end
|
2020-05-20 04:37:16 +02:00
|
|
|
end
|
2019-10-19 21:13:48 +02:00
|
|
|
end
|
|
|
|
elseif (chunkPass == CHUNK_NORTH_SOUTH) then
|
2019-10-19 23:04:38 +02:00
|
|
|
|
|
|
|
neighbor = tempNeighbors[2]
|
2020-05-22 08:57:03 +02:00
|
|
|
if (neighbor ~= -1) then
|
2020-05-20 04:37:16 +02:00
|
|
|
neighborPass = getPassable(map, neighbor)
|
|
|
|
if ((neighborPass == CHUNK_ALL_DIRECTIONS) or (neighborPass == CHUNK_NORTH_SOUTH)) then
|
2020-05-22 08:57:03 +02:00
|
|
|
pheromone = neighbor[PLAYER_PHEROMONE]
|
|
|
|
if chunkPlayer < pheromone then
|
|
|
|
chunkPlayer = pheromone
|
|
|
|
end
|
2020-05-20 04:37:16 +02:00
|
|
|
end
|
2019-10-19 21:13:48 +02:00
|
|
|
end
|
|
|
|
|
2019-10-19 23:04:38 +02:00
|
|
|
neighbor = tempNeighbors[7]
|
2020-05-22 08:57:03 +02:00
|
|
|
if (neighbor ~= -1) then
|
2020-05-20 04:37:16 +02:00
|
|
|
neighborPass = getPassable(map, neighbor)
|
|
|
|
if ((neighborPass == CHUNK_ALL_DIRECTIONS) or (neighborPass == CHUNK_NORTH_SOUTH)) then
|
2020-05-22 08:57:03 +02:00
|
|
|
pheromone = neighbor[PLAYER_PHEROMONE]
|
|
|
|
if chunkPlayer < pheromone then
|
|
|
|
chunkPlayer = pheromone
|
|
|
|
end
|
2020-05-20 04:37:16 +02:00
|
|
|
end
|
2019-10-19 21:13:48 +02:00
|
|
|
end
|
2018-10-20 07:17:37 +02:00
|
|
|
end
|
2019-02-11 08:14:17 +02:00
|
|
|
|
2020-05-24 05:47:14 +02:00
|
|
|
if not player then
|
|
|
|
decayDeathGenerator(map, chunk)
|
|
|
|
end
|
2019-02-11 08:14:17 +02:00
|
|
|
|
2020-05-23 06:22:40 +02:00
|
|
|
chunkPlayer = chunkPlayer * 0.45
|
2021-02-14 06:49:54 +02:00
|
|
|
pheromone = getPlayersOnChunk(map, chunk) * PLAYER_PHEROMONE_GENERATOR_AMOUNT
|
2020-05-22 08:57:03 +02:00
|
|
|
if chunkPlayer < pheromone then
|
|
|
|
chunk[PLAYER_PHEROMONE] = pheromone * chunkPathRating
|
2018-02-13 09:10:17 +02:00
|
|
|
else
|
2020-05-22 08:57:03 +02:00
|
|
|
chunk[PLAYER_PHEROMONE] = chunkPlayer * chunkPathRating
|
2018-02-13 09:10:17 +02:00
|
|
|
end
|
2016-08-05 06:47:51 +02:00
|
|
|
end
|
|
|
|
|
2019-02-16 06:17:30 +02:00
|
|
|
pheromoneUtilsG = pheromoneUtils
|
2016-09-13 01:23:26 +02:00
|
|
|
return pheromoneUtils
|