From 8e76817a196b575f8e66ceb9ccdd6684dc720f16 Mon Sep 17 00:00:00 2001 From: Aaron Veden Date: Sun, 14 Jan 2018 23:41:55 -0800 Subject: [PATCH] added base detection, creation, and removal. needs base location on register --- UnitClasses.lua | 3 +- control.lua | 74 ++++++++++++++++++- libs/AIAttackWave.lua | 8 +- libs/BaseProcessor.lua | 8 +- libs/BaseUtils.lua | 86 ++++++++++++++-------- libs/ChunkProcessor.lua | 4 +- libs/ChunkProperties.lua | 136 ++++++++++++++++++++++++++++++++++ libs/ChunkUtils.lua | 153 ++++++++------------------------------- libs/Constants.lua | 2 + libs/MapProcessor.lua | 5 +- libs/PheromoneUtils.lua | 8 +- libs/SquadAttack.lua | 6 +- libs/SquadDefense.lua | 12 +-- libs/UnitGroupUtils.lua | 6 +- 14 files changed, 325 insertions(+), 186 deletions(-) create mode 100755 libs/ChunkProperties.lua diff --git a/UnitClasses.lua b/UnitClasses.lua index 06cab57..4aeb9ed 100755 --- a/UnitClasses.lua +++ b/UnitClasses.lua @@ -63,7 +63,7 @@ buildUnitSpawner( }, unitSpawner = { - name = "rampant-suicide-nest", + name = "rampant-suicide-biter-nest", attributes = { health = 30, healing = 0.01, @@ -73,6 +73,7 @@ buildUnitSpawner( spawingCooldownStop = 150, }, + resistances = { explosion = { decrease = 0, diff --git a/control.lua b/control.lua index bbe5404..b71df75 100755 --- a/control.lua +++ b/control.lua @@ -276,12 +276,78 @@ local function onModSettingsChange(event) end local function rebuildNativeTables() + local position = { x=0, y=0 } for v=1,SUICIDE_NEST_VARIATIONS do - local entity = surface.create_entity() - natives. - entity.die() + for t=1,SUICIDE_NEST_TIERS do + local entity = surface.create_entity({ + name="rampant-suicide-biter-nest-v" .. v .. "-t" .. t, + position=position + }) + local evoRequirement = entity.prototype.build_base_evolution_requirement + natives.evolutionTable[#natives.evolutionTable[evoRequirement]+1] = entity.name + entity.die() + end end - for v=1,ACID_NEST_VARIATIONS do + -- for v=1,ACID_NEST_VARIATIONS do + -- for t=1,ACID_NEST_TIERS do + + -- end + -- end + -- for v=1,FIRE_NEST_VARIATIONS do + -- for t=1,FIRE_NEST_TIERS do + + -- end + -- end + -- for v=1,PHYSICAL_NEST_VARIATIONS do + -- for t=1,PHYSICAL_NEST_TIERS do + + -- end + -- end + -- for v=1,LASER_NEST_VARIATIONS do + -- for t=1,LASER_NEST_TIERS do + + -- end + -- end + -- for v=1,INFERNO_NEST_VARIATIONS do + -- for t=1,INFERNO_NEST_TIERS do + + -- end + -- end + -- for v=1,POSION_NEST_VARIATIONS do + -- for t=1,POSION_NEST_TIERS do + + -- end + -- end + -- for v=1,INFESTER_NEST_VARIATIONS do + -- for t=1,INFESTER_NEST_TIERS do + + -- end + -- end + -- for v=1,TROLL_NEST_VARIATIONS do + -- for t=1,TROLL_NEST_TIERS do + + -- end + -- end + -- for v=1,FAST_NEST_VARIATIONS do + -- for t=1,FAST_NEST_TIERS do + + -- end + -- end + -- for v=1,WEB_NEST_VARIATIONS do + -- for t=1,WEB_NEST_TIERS do + + -- end + -- end + -- for v=1,DECAYING_NEST_VARIATIONS do + -- for t=1,DECAYING_NEST_TIERS do + + -- end + -- end + -- for v=1,UNDYING_NEST_VARIATIONS do + -- for t=1,UNDYING_NEST_TIERS do + + -- end + -- end end local function onConfigChanged() diff --git a/libs/AIAttackWave.lua b/libs/AIAttackWave.lua index 322c682..5b4016d 100755 --- a/libs/AIAttackWave.lua +++ b/libs/AIAttackWave.lua @@ -4,7 +4,7 @@ local aiAttackWave = {} local constants = require("Constants") local mapUtils = require("MapUtils") -local chunkUtils = require("ChunkUtils") +local chunkPropetyUtils = require("ChunkPropertyUtils") local unitGroupUtils = require("UnitGroupUtils") local movementUtils = require("MovementUtils") package.path = "../?.lua;" .. package.path @@ -41,9 +41,9 @@ local mRandom = math.random local positionFromDirectionAndChunk = mapUtils.positionFromDirectionAndChunk -local getNestCount = chunkUtils.getNestCount -local getRallyTick = chunkUtils.getRallyTick -local setRallyTick = chunkUtils.setRallyTick +local getNestCount = chunkPropetyUtils.getNestCount +local getRallyTick = chunkPropetyUtils.getRallyTick +local setRallyTick = chunkPropetyUtils.setRallyTick local getNeighborChunks = mapUtils.getNeighborChunks local getChunkByXY = mapUtils.getChunkByXY diff --git a/libs/BaseProcessor.lua b/libs/BaseProcessor.lua index 2f2745e..15783ce 100755 --- a/libs/BaseProcessor.lua +++ b/libs/BaseProcessor.lua @@ -2,8 +2,8 @@ local baseProcessor = {} -- imports -local nestUtils = require("NestUtils") -local tendrilUtils = require("TendrilUtils") +-- local nestUtils = require("NestUtils") +-- local tendrilUtils = require("TendrilUtils") local constants = require("Constants") -- constants @@ -14,8 +14,8 @@ local BASE_QUEUE_SIZE = constants.BASE_QUEUE_SIZE local mMin = math.min -local buildOrder = nestUtils.buildOrder -local advanceTendrils = tendrilUtils.advanceTendrils +-- local buildOrder = nestUtils.buildOrder +-- local advanceTendrils = tendrilUtils.advanceTendrils -- module code diff --git a/libs/BaseUtils.lua b/libs/BaseUtils.lua index e72f294..ced12b3 100755 --- a/libs/BaseUtils.lua +++ b/libs/BaseUtils.lua @@ -5,6 +5,8 @@ local baseUtils = {} local stringUtils = require("StringUtils") local mathUtils = require("MathUtils") local constants = require("Constants") +local mapUtils = require("MapUtils") +local chunkPropertyUtils = require("ChunkPropertyUtils") -- constants @@ -12,6 +14,8 @@ local BASE_DISTANCE_THRESHOLD = constants.BASE_DISTANCE_THRESHOLD local BASE_ALIGNMENT_NEUTRAL = constants.BASE_ALIGNMENT_NEUTRAL +local CHUNK_SIZE = constants.CHUNK_SIZE + local MAGIC_MAXIMUM_NUMBER = constants.MAGIC_MAXIMUM_NUMBER local MAGIC_MAXIMUM_BASE_NUMBER = constants.MAGIC_MAXIMUM_BASE_NUMBER @@ -23,62 +27,82 @@ local isRampant = stringUtils.isRampant local mFloor = math.floor --- local buildTendril = tendrilUtils.buildTendril +local positionToChunkXY = mapUtils.positionToChunkXY +local getChunkBase = chunkPropertyUtils.getChunkBase +local setChunkBase = chunkPropertyUtils.setChunkBase local mRandom = math.random -- module code -function baseUtils.findNearbyBase(natives, position) - local bases = natives.bases - local foundBase +function baseUtils.findNearbyBase(map, chunk, chunkRadius) + local x = chunk.x + local y = chunk.y + + local foundBase = getChunkBase(map, chunk) + if foundBase then + return foundBase + end + local closest = MAGIC_MAXIMUM_NUMBER - for i=1,#bases do - local base = bases[i] - local distance = euclideanDistancePoints(base.x, base.y, position.x, position.y) - if (distance <= (BASE_DISTANCE_THRESHOLD + (base.level * 100))) and (distance < closest) then - closest = distance - foundBase = base + for xi = x-chunkRadius, x+chunkRadius, CHUNK_SIZE do + for yi = y-chunkRadius, y+chunkRadius, CHUNK_SIZE do + if (xi ~= x) and (yi ~= y) then + local base = getChunkBase(map, positionToChunkXY(map, xi, yi)) + if base then + local distance = euclideanDistancePoints(base.x, base.y, x, y) + if (distance <= (BASE_DISTANCE_THRESHOLD + (base.level * 100))) and (distance < closest) then + closest = distance + foundBase = base + end + end + end end end + return foundBase end -function baseUtils.upgradeEntity(map, entity, surface, natives) +function baseUtils.upgradeEntity(map, entity, surface, natives, evolutionFactor, tick) if not isRampant(entity.name) then local position = entity.position - -- build_base_evolution_requirement entity.die() - entity = surface.create_entity({name = "rampant-suicide-nest-v" .. mRandom(5) .. "-t1", - position = position}) + local chunk = positionToChunkXY(map, position) + local base = getChunkBase(map, chunk) + + if not base then + baseUtils.createBase(map, natives, evolutionFactor, chunk, surface, tick) + end + + entity = surface.creaate_entity({name = "rampant-suicide-nest-v" .. mRandom(5) .. "-t1", + position = position}) + end return entity end -function baseUtils.createBase(map, natives, position, surface, tick) - local bases = natives.bases - local distance = euclideanDistancePoints(position.x, position.y, 0, 0) +function baseUtils.createBase(map, natives, evolutionFactor, chunk, surface, tick) + local x = chunk.x + local y = chunk.y + local distance = euclideanDistancePoints(x, y, 0, 0) local base = { - x = position.x, - y = position.y, + x = x, + y = y, created = tick, alignment = { BASE_ALIGNMENT_NEUTRAL }, - hives = {}, - tendrils = {}, - nests = {}, - worms = {}, - eggs = {}, - upgradePoints = 0, - growth = tick, pattern = mRandom(MAGIC_MAXIMUM_BASE_NUMBER), level = mFloor(distance / 200) } - if not buildHive(map, base, surface) then - return nil - end - -- buildTendril(map, natives, base, surface, tick) - bases[#bases+1] = base + + setChunkBase(map, chunk, base) + + -- if not buildHive(map, base, surface) then + -- return nil + -- end + + natives.bases[natives.bases+1] = base + return base end diff --git a/libs/ChunkProcessor.lua b/libs/ChunkProcessor.lua index 70c04bb..4387515 100755 --- a/libs/ChunkProcessor.lua +++ b/libs/ChunkProcessor.lua @@ -19,7 +19,7 @@ local chunkPassScan = chunkUtils.chunkPassScan -- module code -function chunkProcessor.processPendingChunks(natives, map, surface, pendingStack) +function chunkProcessor.processPendingChunks(natives, map, surface, pendingStack, tick) local processQueue = map.processQueue local area = map.area @@ -41,7 +41,7 @@ function chunkProcessor.processPendingChunks(natives, map, surface, pendingStack bottomOffset[1] = x + CHUNK_SIZE bottomOffset[2] = y + CHUNK_SIZE - chunk = initialScan(chunk, natives, surface, map) + chunk = initialScan(chunk, natives, surface, map, tick) if (chunk ~= SENTINEL_IMPASSABLE_CHUNK) then local chunkX = chunk.x diff --git a/libs/ChunkProperties.lua b/libs/ChunkProperties.lua new file mode 100755 index 0000000..e5b903f --- /dev/null +++ b/libs/ChunkProperties.lua @@ -0,0 +1,136 @@ +local chunkPropertyUtils = {} + +-- imported functions + +local tRemove = table.remove + +-- module code + +function chunkPropertyUtils.getNestCount(map, chunk) + return map.chunkToNests[chunk] or 0 +end + +function chunkPropertyUtils.getWormCount(map, chunk) + return map.chunkToWorms[chunk] or 0 +end + +function chunkPropertyUtils.setWormCount(map, chunk, count) + 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 + map.chunkToNests[chunk] = nil + else + map.chunkToNests[chunk] = count + end +end + +function chunkPropertyUtils.getNestCount(map, chunk) + return map.chunkToNests[chunk] or 0 +end + +function chunkPropertyUtils.getChunkBase(map, chunk) + return map.chunkToBase[chunk] +end + +function chunkPropertyUtils.setChunkBase(map, chunk, base) + map.chunkToBase[chunk] = base +end + +function chunkPropertyUtils.getWormCount(map, chunk) + return map.chunkToWorms[chunk] or 0 +end + +function chunkPropertyUtils.getEnemyStructureCount(map, chunk) + return (map.chunkToNests[chunk] or 0) + (map.chunkToWorms[chunk] or 0) +end + +function chunkPropertyUtils.getRetreatTick(map, chunk) + return map.chunkToRetreats[chunk] or 0 +end + +function chunkPropertyUtils.getRallyTick(map, chunk) + return map.chunkToRallys[chunk] or 0 +end + +function chunkPropertyUtils.setRallyTick(map, chunk, tick) + map.chunkToRallys[chunk] = tick +end + +function chunkPropertyUtils.setRetreatTick(map, chunk, tick) + map.chunkToRetreats[chunk] = tick +end + +function chunkPropertyUtils.setResourceGenerator(map, chunk, resourceGenerator) + if (resourceGenerator == 0) then + map.chunkToResource[chunk] = nil + else + map.chunkToResource[chunk] = resourceGenerator + end +end + +function chunkPropertyUtils.getResourceGenerator(map, chunk) + return map.chunkToResource[chunk] or 0 +end + +function chunkPropertyUtils.addResourceGenerator(map, chunk, delta) + map.chunkToResource[chunk] = (map.chunkToResource[chunk] or 0) + delta +end + +function chunkPropertyUtils.getPlayerBaseGenerator(map, chunk) + return map.chunkToPlayerBase[chunk] or 0 +end + +function chunkPropertyUtils.addSquadToChunk(map, chunk, squad) + if (chunk ~= squad.chunk) then + local chunkToSquad = map.chunkToSquad + chunkPropertyUtils.removeSquadFromChunk(map, squad) + if not chunkToSquad[chunk] then + chunkToSquad[chunk] = {} + end + chunkToSquad[chunk][#chunkToSquad[chunk]+1] = squad + + squad.chunk = chunk + end +end + +function chunkPropertyUtils.removeSquadFromChunk(map, squad) + local chunkToSquad = map.chunkToSquad + if squad.chunk then + local squads = chunkToSquad[squad.chunk] + if squads then + for i=#squads, 1, -1 do + if (squads[i] == squad) then + tRemove(squads, i) + break + end + end + if (#squads == 0) then + chunkToSquad[squad.chunk] = nil + end + end + end +end + +function chunkPropertyUtils.getSquadsOnChunk(map, chunk) + return map.chunkToSquad[chunk] or {} +end + +function chunkPropertyUtils.setPlayerBaseGenerator(map, chunk, playerGenerator) + if (playerGenerator == 0) then + map.chunkToPlayerBase[chunk] = nil + else + map.chunkToPlayerBase[chunk] = playerGenerator + end +end + +function chunkPropertyUtils.addPlayerBaseGenerator(map, chunk, playerGenerator) + map.chunkToPlayerBase[chunk] = (map.chunkToPlayerBase[chunk] or 0) + playerGenerator +end + +return chunkPropertyUtils diff --git a/libs/ChunkUtils.lua b/libs/ChunkUtils.lua index 427a80e..98ba708 100755 --- a/libs/ChunkUtils.lua +++ b/libs/ChunkUtils.lua @@ -2,8 +2,10 @@ local chunkUtils = {} -- imports +local baseUtils = require("BaseUtils") local constants = require("Constants") local mapUtils = require("MapUtils") +local chunkPropertyUtils = require("ChunkPropertyUtils") -- constants @@ -29,6 +31,8 @@ local CHUNK_IMPASSABLE = constants.CHUNK_IMPASSABLE local CHUNK_TICK = constants.CHUNK_TICK +local BASE_SEARCH_RADIUS = constants.BASE_SEARCH_RADIUS + local PATH_RATING = constants.PATH_RATING local PASSABLE = constants.PASSABLE @@ -37,9 +41,12 @@ local RESOURCE_GENERATOR_INCREMENT = constants.RESOURCE_GENERATOR_INCREMENT -- imported functions -local getChunkByUnalignedXY = mapUtils.getChunkByUnalignedXY +local findNearbyBase = baseUtils.findNearbyBase +local createBase = baseUtils.createBase -local tRemove = table.remove +local setChunkBase = chunkPropertyUtils.setChunkBase + +local getChunkByUnalignedXY = mapUtils.getChunkByUnalignedXY local mFloor = math.floor @@ -265,7 +272,7 @@ function chunkUtils.scoreEnemyBuildings(surface, map) return nests, worms end -function chunkUtils.initialScan(chunk, natives, surface, map) +function chunkUtils.initialScan(chunk, natives, surface, map, tick, evolutionFactor) local passScore = chunkUtils.calculatePassScore(surface, map) if (passScore >= 0.40) then @@ -281,6 +288,15 @@ function chunkUtils.initialScan(chunk, natives, surface, map) pass = CHUNK_ALL_DIRECTIONS end + if (nests > 0) or (worms > 0) then + local base = findNearbyBase(map, chunk, BASE_SEARCH_RADIUS) + if base then + setChunkBase(map, chunk, base) + else + createBase(map, natives, evolutionFactor, chunk, surface, tick) + end + end + chunkUtils.setNestCount(map, chunk, nests) chunkUtils.setPlayerBaseGenerator(map, chunk, playerObjects) chunkUtils.setResourceGenerator(map, chunk, resources) @@ -323,125 +339,6 @@ function chunkUtils.analyzeChunk(chunk, natives, surface, map) chunkUtils.setPlayerBaseGenerator(map, chunk, playerObjects) end -function chunkUtils.getNestCount(map, chunk) - return map.chunkToNests[chunk] or 0 -end - -function chunkUtils.getWormCount(map, chunk) - return map.chunkToWorms[chunk] or 0 -end - -function chunkUtils.setWormCount(map, chunk, count) - if (count == 0) then - map.chunkToWorms[chunk] = nil - else - map.chunkToWorms[chunk] = count - end -end - -function chunkUtils.setNestCount(map, chunk, count) - if (count == 0) then - map.chunkToNests[chunk] = nil - else - map.chunkToNests[chunk] = count - end -end - -function chunkUtils.getNestCount(map, chunk) - return map.chunkToNests[chunk] or 0 -end - -function chunkUtils.getWormCount(map, chunk) - return map.chunkToWorms[chunk] or 0 -end - -function chunkUtils.getEnemyStructureCount(map, chunk) - return (map.chunkToNests[chunk] or 0) + (map.chunkToWorms[chunk] or 0) -end - -function chunkUtils.getRetreatTick(map, chunk) - return map.chunkToRetreats[chunk] or 0 -end - -function chunkUtils.getRallyTick(map, chunk) - return map.chunkToRallys[chunk] or 0 -end - -function chunkUtils.setRallyTick(map, chunk, tick) - map.chunkToRallys[chunk] = tick -end - -function chunkUtils.setRetreatTick(map, chunk, tick) - map.chunkToRetreats[chunk] = tick -end - -function chunkUtils.setResourceGenerator(map, chunk, resourceGenerator) - if (resourceGenerator == 0) then - map.chunkToResource[chunk] = nil - else - map.chunkToResource[chunk] = resourceGenerator - end -end - -function chunkUtils.getResourceGenerator(map, chunk) - return map.chunkToResource[chunk] or 0 -end - -function chunkUtils.addResourceGenerator(map, chunk, delta) - map.chunkToResource[chunk] = (map.chunkToResource[chunk] or 0) + delta -end - -function chunkUtils.getPlayerBaseGenerator(map, chunk) - return map.chunkToPlayerBase[chunk] or 0 -end - -function chunkUtils.addSquadToChunk(map, chunk, squad) - if (chunk ~= squad.chunk) then - local chunkToSquad = map.chunkToSquad - chunkUtils.removeSquadFromChunk(map, squad) - if not chunkToSquad[chunk] then - chunkToSquad[chunk] = {} - end - chunkToSquad[chunk][#chunkToSquad[chunk]+1] = squad - - squad.chunk = chunk - end -end - -function chunkUtils.removeSquadFromChunk(map, squad) - local chunkToSquad = map.chunkToSquad - if squad.chunk then - local squads = chunkToSquad[squad.chunk] - if squads then - for i=#squads, 1, -1 do - if (squads[i] == squad) then - tRemove(squads, i) - break - end - end - if (#squads == 0) then - chunkToSquad[squad.chunk] = nil - end - end - end -end - -function chunkUtils.getSquadsOnChunk(map, chunk) - return map.chunkToSquad[chunk] or {} -end - -function chunkUtils.setPlayerBaseGenerator(map, chunk, playerGenerator) - if (playerGenerator == 0) then - map.chunkToPlayerBase[chunk] = nil - else - map.chunkToPlayerBase[chunk] = playerGenerator - end -end - -function chunkUtils.addPlayerBaseGenerator(map, chunk, playerGenerator) - map.chunkToPlayerBase[chunk] = (map.chunkToPlayerBase[chunk] or 0) + playerGenerator -end - function chunkUtils.createChunk(topX, topY) local chunk = { x = topX, @@ -514,15 +411,27 @@ function chunkUtils.unregisterEnemyBaseStructure(map, entity) if (leftTop ~= SENTINEL_IMPASSABLE_CHUNK) then removeEnemyStructureFromChunk(map, leftTop, entity) + if getEnemyStructureCount(map, leftTop) == 0 then + setChunkBase(map, leftTop, nil) + end end if (rightTop ~= SENTINEL_IMPASSABLE_CHUNK) then removeEnemyStructureFromChunk(map, rightTop, entity) + if getEnemyStructureCount(map, rightTop) == 0 then + setChunkBase(map, rightTop, nil) + end end if (leftBottom ~= SENTINEL_IMPASSABLE_CHUNK) then removeEnemyStructureFromChunk(map, leftBottom, entity) + if getEnemyStructureCount(map, leftBottom) == 0 then + setChunkBase(map, leftBottom, nil) + end end if (rightBottom ~= SENTINEL_IMPASSABLE_CHUNK) then removeEnemyStructureFromChunk(map, rightBottom, entity) + if getEnemyStructureCount(map, rightBottom) == 0 then + setChunkBase(map, rightBottom, nil) + end end end end diff --git a/libs/Constants.lua b/libs/Constants.lua index f0d7330..1e42faa 100755 --- a/libs/Constants.lua +++ b/libs/Constants.lua @@ -63,6 +63,8 @@ constants.CHUNK_ALL_DIRECTIONS = 3 -- constants.CHUNK_PLAYER_BORDER = 4 -- constants.CHUNK_PLAYER_INTERIOR = 5 +constants.BASE_SEARCH_RADIUS = 4 * constants.CHUNK_SIZE + -- ai constants.AI_POINT_GENERATOR_AMOUNT = 6 diff --git a/libs/MapProcessor.lua b/libs/MapProcessor.lua index fb04ea5..6da9508 100755 --- a/libs/MapProcessor.lua +++ b/libs/MapProcessor.lua @@ -10,6 +10,7 @@ local constants = require("Constants") local mapUtils = require("MapUtils") local playerUtils = require("PlayerUtils") local chunkUtils = require("ChunkUtils") +local chunkPropertyUtils = require("ChunkPropertyUtils") local mathUtils = require("MathUtils") -- constants @@ -49,8 +50,8 @@ local validPlayer = playerUtils.validPlayer local analyzeChunk = chunkUtils.analyzeChunk -local getNestCount = chunkUtils.getNestCount -local getEnemyStructureCount = chunkUtils.getEnemyStructureCount +local getNestCount = chunkPropertyUtils.getNestCount +local getEnemyStructureCount = chunkPropertyUtils.getEnemyStructureCount local canAttack = aiPredicates.canAttack diff --git a/libs/PheromoneUtils.lua b/libs/PheromoneUtils.lua index c05ecd3..7bd4afa 100755 --- a/libs/PheromoneUtils.lua +++ b/libs/PheromoneUtils.lua @@ -4,7 +4,7 @@ local pheromoneUtils = {} local mapUtils = require("MapUtils") local constants = require("Constants") -local chunkUtils = require("ChunkUtils") +local chunkPropertyUtils = require("ChunkPropertyUtils") -- constants @@ -30,9 +30,9 @@ local PATH_RATING = constants.PATH_RATING local getCardinalChunks = mapUtils.getCardinalChunks local mMax = math.max -local getEnemyStructureCount = chunkUtils.getEnemyStructureCount -local getPlayerBaseGenerator = chunkUtils.getPlayerBaseGenerator -local getResourceGenerator = chunkUtils.getResourceGenerator +local getEnemyStructureCount = chunkPropertyUtils.getEnemyStructureCount +local getPlayerBaseGenerator = chunkPropertyUtils.getPlayerBaseGenerator +local getResourceGenerator = chunkPropertyUtils.getResourceGenerator -- module code diff --git a/libs/SquadAttack.lua b/libs/SquadAttack.lua index ba561d0..fe15f66 100755 --- a/libs/SquadAttack.lua +++ b/libs/SquadAttack.lua @@ -8,7 +8,7 @@ local unitGroupUtils = require("UnitGroupUtils") local playerUtils = require("PlayerUtils") local movementUtils = require("MovementUtils") local mathUtils = require("MathUtils") -local chunkUtils = require("ChunkUtils") +local chunkPropertyUtils = require("ChunkPropertyUtils") -- constants @@ -38,7 +38,7 @@ local mRandom = math.random local findMovementPosition = movementUtils.findMovementPosition local getNeighborChunks = mapUtils.getNeighborChunks -local addSquadToChunk = chunkUtils.addSquadToChunk +local addSquadToChunk = chunkPropertyUtils.addSquadToChunk local getChunkByXY = mapUtils.getChunkByXY local positionToChunkXY = mapUtils.positionToChunkXY local addMovementPenalty = movementUtils.addMovementPenalty @@ -49,7 +49,7 @@ local positionFromDirectionAndChunk = mapUtils.positionFromDirectionAndChunk local euclideanDistanceNamed = mathUtils.euclideanDistanceNamed local playersWithinProximityToPosition = playerUtils.playersWithinProximityToPosition -local getPlayerBaseGenerator = chunkUtils.getPlayerBaseGenerator +local getPlayerBaseGenerator = chunkPropertyUtils.getPlayerBaseGenerator local scoreNeighborsForAttack = movementUtils.scoreNeighborsForAttack diff --git a/libs/SquadDefense.lua b/libs/SquadDefense.lua index b4f5597..84311da 100755 --- a/libs/SquadDefense.lua +++ b/libs/SquadDefense.lua @@ -6,7 +6,7 @@ local constants = require("Constants") local mapUtils = require("MapUtils") local unitGroupUtils = require("UnitGroupUtils") local movementUtils = require("MovementUtils") -local chunkUtils = require("ChunkUtils") +local chunkPropetyUtils = require("ChunkPropertyUtils") -- constants @@ -25,7 +25,7 @@ local SENTINEL_IMPASSABLE_CHUNK = constants.SENTINEL_IMPASSABLE_CHUNK local mRandom = math.random -local addSquadToChunk = chunkUtils.addSquadToChunk +local addSquadToChunk = chunkPropetyUtils.addSquadToChunk local calculateKamikazeThreshold = unitGroupUtils.calculateKamikazeThreshold @@ -38,10 +38,10 @@ local membersToSquad = unitGroupUtils.membersToSquad local scoreNeighborsForRetreat = movementUtils.scoreNeighborsForRetreat local findMovementPosition = movementUtils.findMovementPosition -local getRetreatTick = chunkUtils.getRetreatTick -local getPlayerBaseGenerator = chunkUtils.getPlayerBaseGenerator -local setRetreatTick = chunkUtils.setRetreatTick -local getEnemyStructureCount = chunkUtils.getEnemyStructureCount +local getRetreatTick = chunkPropetyUtils.getRetreatTick +local getPlayerBaseGenerator = chunkPropetyUtils.getPlayerBaseGenerator +local setRetreatTick = chunkPropetyUtils.setRetreatTick +local getEnemyStructureCount = chunkPropetyUtils.getEnemyStructureCount -- module code diff --git a/libs/UnitGroupUtils.lua b/libs/UnitGroupUtils.lua index a195a7d..bc3d7d4 100755 --- a/libs/UnitGroupUtils.lua +++ b/libs/UnitGroupUtils.lua @@ -5,7 +5,7 @@ local unitGroupUtils = {} local mapUtils = require("MapUtils") local mathUtils = require("MathUtils") local constants = require("Constants") -local chunkUtils = require("ChunkUtils") +local chunkPropertyUtils = require("ChunkPropertyUtils") -- constants @@ -38,8 +38,8 @@ local mLog = math.log10 local mMin = math.min -local getSquadsOnChunk = chunkUtils.getSquadsOnChunk -local removeSquadFromChunk = chunkUtils.removeSquadFromChunk +local getSquadsOnChunk = chunkPropertyUtils.getSquadsOnChunk +local removeSquadFromChunk = chunkPropertyUtils.removeSquadFromChunk local getNeighborChunks = mapUtils.getNeighborChunks