diff --git a/changelog.txt b/changelog.txt index d961831..298ab35 100644 --- a/changelog.txt +++ b/changelog.txt @@ -33,6 +33,7 @@ Date: 23. 11. 2021 - Map cleanup is now processed regardless of current active map - Chunk pass scanning is now processed regardless of current active map - Siege AI state now sends roughly 1 raid group every 3 settler groups if raiding is enabled + - Siege groups now try to settle just outside player structures as opposed to attacking Tweaks: - Increase chance to upgrade an enemy structure from 5% to 30% - New enemy regional bases that have two factions now do 75% on one faction and 25% on the faction for building and upgrading enemy structures diff --git a/libs/MapUtils.lua b/libs/MapUtils.lua index 1184110..518ec55 100644 --- a/libs/MapUtils.lua +++ b/libs/MapUtils.lua @@ -214,29 +214,32 @@ function mapUtils.positionFromDirectionAndChunk(direction, startPosition, endPos return endPosition end -function mapUtils.positionFromDirectionAndFlat(direction, startPosition, endPosition) +function mapUtils.positionFromDirectionAndFlat(direction, startPosition, endPosition, multipler) local lx = startPosition.x local ly = startPosition.y + if not multipler then + multipler = 1 + end if (direction == 1) then - lx = lx - CHUNK_SIZE - ly = ly - CHUNK_SIZE + lx = lx - CHUNK_SIZE * multipler + ly = ly - CHUNK_SIZE * multipler elseif (direction == 2) then - ly = ly - CHUNK_SIZE + ly = ly - CHUNK_SIZE * multipler elseif (direction == 3) then - lx = lx + CHUNK_SIZE - ly = ly - CHUNK_SIZE + lx = lx + CHUNK_SIZE * multipler + ly = ly - CHUNK_SIZE * multipler elseif (direction == 4) then - lx = lx - CHUNK_SIZE + lx = lx - CHUNK_SIZE * multipler elseif (direction == 5) then - lx = lx + CHUNK_SIZE + lx = lx + CHUNK_SIZE * multipler elseif (direction == 6) then - lx = lx - CHUNK_SIZE - ly = ly + CHUNK_SIZE + lx = lx - CHUNK_SIZE * multipler + ly = ly + CHUNK_SIZE * multipler elseif (direction == 7) then - ly = ly + CHUNK_SIZE + ly = ly + CHUNK_SIZE * multipler elseif (direction == 8) then - lx = lx + CHUNK_SIZE - ly = ly + CHUNK_SIZE + lx = lx + CHUNK_SIZE * multipler + ly = ly + CHUNK_SIZE * multipler end endPosition.x = lx endPosition.y = ly diff --git a/libs/SquadAttack.lua b/libs/SquadAttack.lua index 79e335d..98fcaf1 100644 --- a/libs/SquadAttack.lua +++ b/libs/SquadAttack.lua @@ -176,10 +176,19 @@ local function settleMove(map, squad) local attackPlayerThreshold = universe.attackPlayerThreshold if (nextAttackChunk ~= -1) then - attackChunk = nextAttackChunk - positionFromDirectionAndFlat(attackDirection, groupPosition, targetPosition) - positionFromDirectionAndFlat(nextAttackDirection, targetPosition, targetPosition2) - position = findMovementPosition(surface, targetPosition2) + if (getPlayerBaseGenerator(map,nextAttackChunk) == 0) or (map.state ~= AI_STATE_SIEGE) then + attackChunk = nextAttackChunk + positionFromDirectionAndFlat(attackDirection, groupPosition, targetPosition) + positionFromDirectionAndFlat(nextAttackDirection, targetPosition, targetPosition2) + position = findMovementPosition(surface, targetPosition2) + else + positionFromDirectionAndFlat(nextAttackDirection, groupPosition, targetPosition, 1.3) + position = findMovementPosition(surface, targetPosition) + if not position then + positionFromDirectionAndFlat(attackDirection, groupPosition, targetPosition, 1.3) + position = findMovementPosition(surface, targetPosition) + end + end else positionFromDirectionAndFlat(attackDirection, groupPosition, targetPosition) position = findMovementPosition(surface, targetPosition) @@ -199,7 +208,17 @@ local function settleMove(map, squad) return end - if (getPlayerBaseGenerator(map, attackChunk) ~= 0) or + if (nextAttackChunk ~= -1) and (map.state == AI_STATE_SIEGE) and (getPlayerBaseGenerator(map, nextAttackChunk) ~= 0) then + cmd = universe.settleCommand + cmd.destination.x = targetPosition.x + cmd.destination.y = targetPosition.y + squad.status = SQUAD_BUILDING + if squad.kamikaze then + cmd.distraction = DEFINES_DISTRACTION_NONE + else + cmd.distraction = DEFINES_DISTRACTION_BY_ENEMY + end + elseif (getPlayerBaseGenerator(map, attackChunk) ~= 0) or (attackChunk[PLAYER_PHEROMONE] >= attackPlayerThreshold) then cmd = universe.attackCommand