1
0
mirror of https://github.com/veden/Rampant.git synced 2025-03-11 14:49:32 +02:00

working raid ai mode

This commit is contained in:
Aaron Veden 2018-02-10 00:42:17 -08:00
parent 2b40676e53
commit 8c2ec80651
4 changed files with 16 additions and 11 deletions

View File

@ -96,8 +96,7 @@ local function validUnitGroupLocation(map, neighborChunk)
end
function aiAttackWave.rallyUnits(chunk, map, surface, natives, tick)
if ((tick - getRallyTick(map, chunk) > INTERVAL_LOGIC) and (natives.points >= AI_VENGENCE_SQUAD_COST) -- and
-- (#natives.squads < natives.maxSquads)
if ((tick - getRallyTick(map, chunk) > INTERVAL_LOGIC) and (natives.points >= AI_VENGENCE_SQUAD_COST)
) then
setRallyTick(map, chunk, tick)
local cX = chunk.x
@ -108,8 +107,7 @@ function aiAttackWave.rallyUnits(chunk, map, surface, natives, tick)
local rallyChunk = getChunkByXY(map, x, y)
if (rallyChunk ~= SENTINEL_IMPASSABLE_CHUNK) and (getNestCount(map, rallyChunk) > 0) then
aiAttackWave.formSquads(map, surface, natives, rallyChunk, AI_VENGENCE_SQUAD_COST)
if (natives.points < AI_VENGENCE_SQUAD_COST) -- and (#natives.squads < natives.maxSquads)
then
if (natives.points < AI_VENGENCE_SQUAD_COST) then
return
end
end

View File

@ -18,6 +18,8 @@ local AI_STATE_NOCTURNAL = constants.AI_STATE_NOCTURNAL
local AI_UNIT_REFUND = constants.AI_UNIT_REFUND
local AI_MAX_OVERFLOW_POINTS = constants.AI_MAX_OVERFLOW_POINTS
local AI_MAX_POINTS = constants.AI_MAX_POINTS
local AI_POINT_GENERATOR_AMOUNT = constants.AI_POINT_GENERATOR_AMOUNT
@ -64,7 +66,6 @@ function aiPlanning.planning(natives, evolution_factor, tick, surface, connected
local attackWaveMaxSize = natives.attackWaveMaxSize
natives.retreatThreshold = -(evolution_factor * RETREAT_MOVEMENT_PHEROMONE_LEVEL)
-- natives.maxSquads = AI_MAX_SQUAD_COUNT * evolution_factor
natives.rallyThreshold = BASE_RALLY_CHANCE + (evolution_factor * BONUS_RALLY_CHANCE)
natives.formSquadThreshold = mMax((0.25 * evolution_factor), 0.10)
natives.attackWaveSize = attackWaveMaxSize * (evolution_factor ^ 1.66667)
@ -97,10 +98,15 @@ function aiPlanning.planning(natives, evolution_factor, tick, surface, connected
natives.state = AI_STATE_NOCTURNAL
else
roll = mRandom()
if (roll > 0.03) then
if (roll > 0.08) then
natives.state = AI_STATE_AGGRESSIVE
else
natives.state = AI_STATE_RAIDING
natives.points = natives.points + 1000
if (natives.points > AI_MAX_OVERFLOW_POINTS) then
natives.points = AI_MAX_OVERFLOW_POINTS
end
end
end
natives.stateTick = randomTickEvent(tick, AI_MIN_STATE_DURATION, AI_MAX_STATE_DURATION)
@ -109,9 +115,9 @@ function aiPlanning.planning(natives, evolution_factor, tick, surface, connected
if isShockwaveReady(evolution_factor, natives, surface, tick, maxPoints) then
natives.lastShakeMessage = tick
for _, player in pairs(connectedPlayers) do
if player.mod_settings["rampant-attack-warning"].value then
player.print("Rampant: The ground begins to shake")
end
if player.mod_settings["rampant-attack-warning"].value then
player.print("Rampant: The ground begins to shake")
end
end
end

View File

@ -15,7 +15,8 @@ local AI_STATE_NOCTURNAL = constants.AI_STATE_NOCTURNAL
-- module code
function aiPredicates.canAttack(natives, surface)
return ((natives.state == AI_STATE_AGGRESSIVE) or aiPredicates.canAttackDark(natives, surface) or
return ((natives.state == AI_STATE_AGGRESSIVE) or
aiPredicates.canAttackDark(natives, surface) or
(natives.state == AI_STATE_RAIDING)) and not surface.peaceful_mode
end

View File

@ -101,7 +101,7 @@ function mapProcessor.processMap(map, surface, natives, tick, evolutionFactor)
local newEnemies = natives.newEnemies
local squads = canAttack(natives, surface) and (0.11 <= roll) and (roll <= 0.35) and (natives.points >= AI_SQUAD_COST)
local processQueue = map.processQueue
local endIndex = mMin(index + PROCESS_QUEUE_SIZE, #processQueue)
for x=index,endIndex do