1
0
mirror of https://github.com/veden/Rampant.git synced 2025-03-17 20:58:35 +02:00

siege groups now detect player structures on nextAttackChunk

This commit is contained in:
Aaron Veden 2021-12-10 13:23:52 -08:00
parent 3f2bfab67c
commit 2379298259
No known key found for this signature in database
GPG Key ID: FF5990B1C6DD3F84
3 changed files with 41 additions and 18 deletions

View File

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

View File

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

View File

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