1
0
mirror of https://github.com/veden/Rampant.git synced 2025-01-28 03:29:34 +02:00

need to finish migration code

This commit is contained in:
Aaron Veden 2018-02-12 23:10:17 -08:00
parent 3dc5eb2670
commit 45df8df069
13 changed files with 238 additions and 114 deletions

View File

@ -139,14 +139,6 @@ function upgrade.attempt(natives)
global.version = constants.VERSION_26
end
if (global.version < constants.VERSION_27) then
natives.useCustomAI = constants.DEV_CUSTOM_AI
-- natives.useCustomAI = settings.startup["rampant-useCustomAI"].value
if natives.useCustomAI then
game.forces.enemy.ai_controllable = false
else
game.forces.enemy.ai_controllable = true
end
game.surfaces[1].print("Rampant - Version 0.15.17")
global.version = constants.VERSION_27
@ -197,10 +189,17 @@ function upgrade.attempt(natives)
game.surfaces[1].print("Rampant - Version 0.16.16")
global.version = constants.VERSION_51
end
if (global.version < constants.VERSION_55) then
if (global.version < constants.VERSION_56) then
natives.expansion = game.map_settings.enemy_expansion.enabled
natives.expansionMaxDistance = game.map_settings.enemy_expansion.max_expansion_distance
natives.expansionMinTime = game.map_settings.enemy_expansion.min_expansion_cooldown
natives.expansionMaxTime = game.map_settings.enemy_expansion.max_expansion_cooldown
natives.expansionMinSize = game.map_settings.enemy_expansion.settler_group_min_size
natives.expansionMaxSize = game.map_settings.enemy_expansion.settler_group_max_size
game.surfaces[1].print("Rampant - Version 0.16.20")
global.version = constants.VERSION_55
game.surfaces[1].print("Rampant - Version 0.16.21")
global.version = constants.VERSION_56
end
return starting ~= global.version, natives

View File

@ -1,3 +1,12 @@
---------------------------------------------------------------------------------------------------
Version: 0.16.21
Date: 2. 12. 2018
Improvements:
- All other robots now take damage from biter projectiles and explosions (https://mods.factorio.com/mod/Rampant/discussion/5a81bd380333a5000c939c7f)
Bugfixes:
- Inverted comparsion of squad spreading roll
---------------------------------------------------------------------------------------------------
Version: 0.16.20
Date: 2. 11. 2018

View File

@ -40,6 +40,7 @@ local RETREAT_GRAB_RADIUS = constants.RETREAT_GRAB_RADIUS
local RETREAT_SPAWNER_GRAB_RADIUS = constants.RETREAT_SPAWNER_GRAB_RADIUS
local DEFINES_COMMAND_GROUP = defines.command.group
local DEFINES_COMMAND_BUILD_BASE = defines.command.build_base
local DEFINES_COMMAND_ATTACK_AREA = defines.command.attack_area
local CHUNK_SIZE = constants.CHUNK_SIZE
@ -49,6 +50,8 @@ local DEFINES_DISTRACTION_BY_ENEMY = defines.distraction.by_enemy
-- imported functions
local squadsDispatch = squadAttack.squadsDispatch
local positionToChunkXY = mapUtils.positionToChunkXY
local roundToNearest = mathUtils.roundToNearest
@ -80,7 +83,6 @@ local convertUnitGroupToSquad = unitGroupUtils.convertUnitGroupToSquad
local createBase = baseUtils.createBase
local squadsAttack = squadAttack.squadsAttack
local squadsBeginAttack = squadAttack.squadsBeginAttack
local retreatUnits = squadDefense.retreatUnits
@ -224,6 +226,13 @@ local function rebuildMap()
distraction = DEFINES_DISTRACTION_BY_ENEMY
}
map.settleCommand = {
type = DEFINES_COMMAND_BUILD_BASE,
position = map.position,
distraction = DEFINES_DISTRACTION_BY_ENEMY,
ignore_planner = true
}
map.retreatCommand = { type = DEFINES_COMMAND_GROUP,
group = nil,
distraction = DEFINES_DISTRACTION_NONE }
@ -280,13 +289,12 @@ local function onModSettingsChange(event)
upgrade.compareTable(natives, "enemySeed", settings.startup["rampant-enemySeed"].value)
-- RE-ENABLE WHEN COMPLETE
natives.useCustomAI = constants.DEV_CUSTOM_AI
-- changed, newValue = upgrade.compareTable(natives, "useCustomAI", settings.startup["rampant-useCustomAI"].value)
-- if natives.useCustomAI then
-- game.forces.enemy.ai_controllable = false
-- else
-- game.forces.enemy.ai_controllable = true
-- end
upgrade.compareTable(natives, "useCustomAI", settings.startup["rampant-useCustomAI"].value)
if natives.useCustomAI then
game.forces.enemy.ai_controllable = false
else
game.forces.enemy.ai_controllable = true
end
-- if changed and newValue then
-- rebuildMap()
-- return false
@ -371,7 +379,7 @@ local function onTick(event)
regroupSquads(natives, map)
squadsBeginAttack(natives, gameRef.players)
squadsAttack(map, gameRef.surfaces[1], natives)
squadsDispatch(map, gameRef.surfaces[1], natives)
end
end

View File

@ -31,6 +31,20 @@ if settings.startup["rampant-useDumbProjectiles"].value then
end
end
for _, robot in pairs(data.raw["logistic-robot"]) do
if not robot.collision_mask then
robot.collision_mask = {}
end
robot.collision_mask[#robot.collision_mask+1] = "layer-11"
end
for _, robot in pairs(data.raw["construction-robot"]) do
if not robot.collision_mask then
robot.collision_mask = {}
end
robot.collision_mask[#robot.collision_mask+1] = "layer-11"
end
for _, robot in pairs(data.raw["combat-robot"]) do
if not robot.collision_mask then
robot.collision_mask = {}

View File

@ -1,7 +1,7 @@
{
"name" : "Rampant",
"factorio_version" : "0.16",
"version" : "0.16.20",
"version" : "0.16.21",
"title" : "Rampant",
"author" : "Veden",
"homepage" : "https://forums.factorio.com/viewtopic.php?f=94&t=31445",

View File

@ -8,6 +8,7 @@ local constants = require("Constants")
local AI_STATE_RAIDING = constants.AI_STATE_RAIDING
local AI_STATE_AGGRESSIVE = constants.AI_STATE_AGGRESSIVE
local AI_STATE_MIGRATING = constants.AI_STATE_MI
local AI_STATE_NOCTURNAL = constants.AI_STATE_NOCTURNAL
-- imported functions
@ -20,6 +21,11 @@ function aiPredicates.canAttack(natives, surface)
(natives.state == AI_STATE_RAIDING)) and not surface.peaceful_mode
end
function aiPredicates.canMigrate(natives, surface)
return ((natives.state == AI_STATE_MIGRATING) or
aiPredicates.canAttackDark(natives, surface)) and natives.expansion
end
function aiPredicates.isDark(surface)
return surface.darkness > 0.65
end

View File

@ -20,7 +20,7 @@ constants.VERSION_38 = 38
constants.VERSION_41 = 41
constants.VERSION_44 = 44
constants.VERSION_51 = 51
constants.VERSION_55 = 55
constants.VERSION_56 = 56
-- misc
@ -77,12 +77,11 @@ constants.EVOLUTION_INCREMENTS = 0.05
-- ai
constants.AI_POINT_GENERATOR_AMOUNT = 6
constants.AI_SCOUT_COST = 45
constants.AI_SQUAD_COST = 175
constants.AI_NEST_COST = 10
constants.AI_WORM_COST = 2
constants.AI_VENGENCE_SQUAD_COST = 45
constants.AI_SETTLER_COST = 75
constants.AI_SETTLER_COST = 300
constants.AI_BASE_BUILDING_COST = 500
constants.AI_TUNNEL_COST = 100
constants.AI_MAX_POINTS = 10000
@ -101,6 +100,7 @@ constants.AI_STATE_PEACEFUL = 1
constants.AI_STATE_AGGRESSIVE = 2
constants.AI_STATE_NOCTURNAL = 3
constants.AI_STATE_RAIDING = 4
constants.AI_STATE_MIGRATING = 5
constants.AI_MIN_STATE_DURATION = 1
constants.AI_MAX_STATE_DURATION = 4
@ -253,6 +253,8 @@ constants.SQUAD_RETREATING = 1 -- used during squad retreat
constants.SQUAD_GUARDING = 2 -- used when squad is idle
constants.SQUAD_BURROWING = 3
constants.SQUAD_RAIDING = 4 -- used when player stuff is close
constants.SQUAD_SETTLING = 5
constants.SQUAD_BUILDING = 6
-- Squad Related

View File

@ -29,6 +29,7 @@ local SENTINEL_IMPASSABLE_CHUNK = constants.SENTINEL_IMPASSABLE_CHUNK
local AI_SQUAD_COST = constants.AI_SQUAD_COST
local AI_VENGENCE_SQUAD_COST = constants.AI_VENGENCE_SQUAD_COST
local AI_SETTLER_COST = constants.AI_SETTLER_COST
local MOVEMENT_PHEROMONE = constants.MOVEMENT_PHEROMONE
@ -45,6 +46,7 @@ local processPheromone = pheromoneUtils.processPheromone
local playerScent = pheromoneUtils.playerScent
local formSquads = aiAttackWave.formSquads
local formSettlers = aiAttackWave.formSettlers
local getChunkByPosition = mapUtils.getChunkByPosition
local getChunkByXY = mapUtils.getChunkByXY
@ -105,6 +107,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 settlers = canAttack(natives, surface) and (0.90 <= roll) and (natives.points >= AI_SETTLER_COST)
local processQueue = map.processQueue
local endIndex = mMin(index + PROCESS_QUEUE_SIZE, #processQueue)
@ -117,9 +120,14 @@ function mapProcessor.processMap(map, surface, natives, tick, evolutionFactor)
processPheromone(map, chunk)
local chunkRoll = mRandom()
if squads and (getNestCount(map, chunk) > 0) and (chunkRoll < 0.90) then
squads = formSquads(map, surface, natives, chunk, AI_SQUAD_COST)
if (getNestCount(map, chunk) > 0) then
if squads and (chunkRoll > 0.90) then
squads = formSquads(map, surface, natives, chunk, AI_SQUAD_COST)
end
if settlers and (chunkRoll < 0.10) then
settlers = formSettlers(map, surface, natives, chunk, AI_SETTLER_COST)
end
end
if newEnemies then

View File

@ -105,28 +105,28 @@ end
--[[
Expects all neighbors adjacent to a chunk
--]]
function movementUtils.scoreNeighborsForResource(chunk, neighborDirectionChunks, scoreFunction, squad, threshold)
local highestChunk = SENTINEL_IMPASSABLE_CHUNK
local highestScore = -MAGIC_MAXIMUM_NUMBER
local highestDirection
for x=1,8 do
local neighborChunk = neighborDirectionChunks[x]
if (neighborChunk ~= SENTINEL_IMPASSABLE_CHUNK) and canMoveChunkDirection(x, chunk, neighborChunk) and (neighborChunk[RESOURCE_PHEROMONE] > (threshold or 1)) then
local score = scoreFunction(squad, neighborChunk)
if (score > highestScore) then
highestScore = score
highestChunk = neighborChunk
highestDirection = x
end
end
end
-- function movementUtils.scoreNeighborsForResource(chunk, neighborDirectionChunks, scoreFunction, squad)
-- local highestChunk = SENTINEL_IMPASSABLE_CHUNK
-- local highestScore = -MAGIC_MAXIMUM_NUMBER
-- local highestDirection
-- for x=1,8 do
-- local neighborChunk = neighborDirectionChunks[x]
-- if (neighborChunk ~= SENTINEL_IMPASSABLE_CHUNK) and canMoveChunkDirection(x, chunk, neighborChunk) then
-- local score = scoreFunction(squad, neighborChunk)
-- if (score > highestScore) then
-- highestScore = score
-- highestChunk = neighborChunk
-- highestDirection = x
-- end
-- end
-- end
if scoreFunction(squad, chunk) > highestScore then
return SENTINEL_IMPASSABLE_CHUNK, -1
end
-- if scoreFunction(squad, chunk) > highestScore then
-- return SENTINEL_IMPASSABLE_CHUNK, -1
-- end
return highestChunk, highestDirection
end
-- return highestChunk, highestDirection
-- end
--[[
Expects all neighbors adjacent to a chunk

View File

@ -43,9 +43,6 @@ function pheromoneUtils.scents(map, chunk)
if (resourceGenerator > 0) and (enemyCount == 0) then
chunk[RESOURCE_PHEROMONE] = chunk[RESOURCE_PHEROMONE] + mMax(resourceGenerator * 1000, 900)
end
if (enemyCount > 0) then
chunk[RESOURCE_PHEROMONE] = chunk[RESOURCE_PHEROMONE] - enemyCount
end
end
function pheromoneUtils.victoryScent(chunk, entityType)
@ -64,12 +61,14 @@ function pheromoneUtils.playerScent(playerChunk)
end
function pheromoneUtils.processPheromone(map, chunk)
local chunkMovement = chunk[MOVEMENT_PHEROMONE]
local chunkBase = chunk[BASE_PHEROMONE]
local chunkPlayer = chunk[PLAYER_PHEROMONE]
local chunkResource = chunk[RESOURCE_PHEROMONE]
local chunkPathRating = chunk[PATH_RATING]
local clear = (getEnemyStructureCount(map, chunk) == 0)
local tempNeighbors = getCardinalChunks(map, chunk.x, chunk.y)
@ -109,7 +108,11 @@ function pheromoneUtils.processPheromone(map, chunk)
chunk[MOVEMENT_PHEROMONE] = (chunkMovement + (0.125 * movementTotal)) * MOVEMENT_PHEROMONE_PERSISTANCE * chunkPathRating
chunk[BASE_PHEROMONE] = (chunkBase + (0.35 * baseTotal)) * BASE_PHEROMONE_PERSISTANCE * chunkPathRating
chunk[PLAYER_PHEROMONE] = (chunkPlayer + (0.25 * playerTotal)) * PLAYER_PHEROMONE_PERSISTANCE * chunkPathRating
chunk[RESOURCE_PHEROMONE] = (chunkResource + (0.35 * resourceTotal)) * RESOURCE_PHEROMONE_PERSISTANCE * chunkPathRating
if clear then
chunk[RESOURCE_PHEROMONE] = (chunkResource + (0.35 * resourceTotal)) * RESOURCE_PHEROMONE_PERSISTANCE * chunkPathRating
else
chunk[RESOURCE_PHEROMONE] = (chunkResource + (0.35 * resourceTotal)) * 0.1
end
end
return pheromoneUtils

View File

@ -15,8 +15,10 @@ local chunkPropertyUtils = require("ChunkPropertyUtils")
local PLAYER_PHEROMONE = constants.PLAYER_PHEROMONE
local MOVEMENT_PHEROMONE = constants.MOVEMENT_PHEROMONE
local BASE_PHEROMONE = constants.BASE_PHEROMONE
local RESOURCE_PHEROMONE = constants.RESOURCE_PHEROMONE
local SQUAD_RAIDING = constants.SQUAD_RAIDING
local SQUAD_SETTLING = constants.SQUAD_SETTLING
local SQUAD_GUARDING = constants.SQUAD_GUARDING
local PLAYER_PHEROMONE_MULTIPLER = constants.PLAYER_PHEROMONE_MULTIPLER
@ -52,72 +54,134 @@ local playersWithinProximityToPosition = playerUtils.playersWithinProximityToPos
local getPlayerBaseGenerator = chunkPropertyUtils.getPlayerBaseGenerator
local scoreNeighborsForAttack = movementUtils.scoreNeighborsForAttack
local scoreNeighborsForResource = movementUtils.scoreNeighborsForResource
-- module code
local function scoreResourceLocation(squad, neighborChunk)
local settle = (2*neighborChunk[MOVEMENT_PHEROMONE]) + neighborChunk[RESOURCE_PHEROMONE]
return settle - lookupMovementPenalty(squad, neighborChunk)
end
local function scoreAttackLocation(squad, neighborChunk)
local damage = (2*neighborChunk[MOVEMENT_PHEROMONE]) + neighborChunk[BASE_PHEROMONE] + (neighborChunk[PLAYER_PHEROMONE] * PLAYER_PHEROMONE_MULTIPLER)
return damage - lookupMovementPenalty(squad, neighborChunk)
end
function squadAttack.squadsAttack(map, surface, natives)
local function settleMove(map, attackPosition, attackCmd, squad, group, natives, surface)
local groupState = group.state
if (groupState == DEFINES_GROUP_FINISHED) or (groupState == DEFINES_GROUP_GATHERING) or ((groupState == DEFINES_GROUP_MOVING) and (squad.cycles == 0)) then
local groupPosition = group.position
local x, y = positionToChunkXY(groupPosition)
local chunk = getChunkByXY(map, x, y)
local attackChunk, attackDirection = scoreNeighborsForAttack(chunk,
getNeighborChunks(map, x, y),
scoreResourceLocation,
squad)
if (chunk ~= SENTINEL_IMPASSABLE_CHUNK) then
addSquadToChunk(map, chunk, squad)
addMovementPenalty(natives, squad, chunk)
elseif (attackChunk ~= SENTINEL_IMPASSABLE_CHUNK) then
addSquadToChunk(map, attackChunk, squad)
addMovementPenalty(natives, squad, attackChunk)
end
if group.valid and (attackChunk ~= SENTINEL_IMPASSABLE_CHUNK) then
local resourceGenerator = getResourceGenerator(map, attackChunk)
-- or max distance is hit
if (resourceGenerator == 0) or ((groupState == DEFINES_GROUP_FINISHED) or (groupState == DEFINES_GROUP_GATHERING)) then
squad.cycles = ((#squad.group.members > 80) and 6) or 4
attackCmd.distraction = DEFINES_DISTRACTION_BY_ENEMY
local position = findMovementPosition(surface, positionFromDirectionAndChunk(attackDirection, groupPosition, attackPosition, 1.35))
if position then
attackPosition.x = position.x
attackPosition.y = position.y
group.set_command(attackCmd)
group.start_moving()
else
addMovementPenalty(natives, squad, attackChunk)
end
elseif (resourceGenerator ~= 0) then
-- settle chunk
end
end
end
end
local function attackMove(map, attackPosition, attackCmd, squad, group, natives, surface)
local groupState = group.state
if (groupState == DEFINES_GROUP_FINISHED) or (groupState == DEFINES_GROUP_GATHERING) or ((groupState == DEFINES_GROUP_MOVING) and (squad.cycles == 0)) then
local groupPosition = group.position
local x, y = positionToChunkXY(groupPosition)
local chunk = getChunkByXY(map, x, y)
local attackChunk, attackDirection = scoreNeighborsForAttack(chunk,
getNeighborChunks(map, x, y),
scoreAttackLocation,
squad)
if (chunk ~= SENTINEL_IMPASSABLE_CHUNK) then
addSquadToChunk(map, chunk, squad)
addMovementPenalty(natives, squad, chunk)
elseif (attackChunk ~= SENTINEL_IMPASSABLE_CHUNK) then
addSquadToChunk(map, attackChunk, squad)
addMovementPenalty(natives, squad, attackChunk)
end
if group.valid and (attackChunk ~= SENTINEL_IMPASSABLE_CHUNK) then
local playerBaseGenerator = getPlayerBaseGenerator(map, attackChunk)
if (playerBaseGenerator == 0) or ((groupState == DEFINES_GROUP_FINISHED) or (groupState == DEFINES_GROUP_GATHERING)) then
squad.cycles = ((#squad.group.members > 80) and 6) or 4
local moreFrenzy = not squad.rabid and squad.frenzy and (euclideanDistanceNamed(groupPosition, squad.frenzyPosition) < 100)
squad.frenzy = moreFrenzy
if squad.rabid or squad.frenzy then
attackCmd.distraction = DEFINES_DISTRACTION_BY_ANYTHING
else
attackCmd.distraction = DEFINES_DISTRACTION_BY_ENEMY
end
local position = findMovementPosition(surface, positionFromDirectionAndChunk(attackDirection, groupPosition, attackPosition, 1.35))
if position then
attackPosition.x = position.x
attackPosition.y = position.y
group.set_command(attackCmd)
group.start_moving()
else
addMovementPenalty(natives, squad, attackChunk)
end
elseif not squad.frenzy and not squad.rabid and
((groupState == DEFINES_GROUP_ATTACKING_DISTRACTION) or (groupState == DEFINES_GROUP_ATTACKING_TARGET) or
(playerBaseGenerator ~= 0)) then
squad.frenzy = true
squad.frenzyPosition.x = groupPosition.x
squad.frenzyPosition.y = groupPosition.y
end
end
end
end
function squadAttack.squadsDispatch(map, surface, natives)
local squads = natives.squads
local attackPosition = map.position
local attackCmd = map.attackAreaCommand
local settleCmd = map.settleCommand
for i=1,#squads do
local squad = squads[i]
local group = squad.group
if group and group.valid and (squad.status == SQUAD_RAIDING) then
local groupState = group.state
if (groupState == DEFINES_GROUP_FINISHED) or (groupState == DEFINES_GROUP_GATHERING) or ((groupState == DEFINES_GROUP_MOVING) and (squad.cycles == 0)) then
local groupPosition = group.position
local x, y = positionToChunkXY(groupPosition)
local chunk = getChunkByXY(map, x, y)
local attackChunk, attackDirection = scoreNeighborsForAttack(chunk,
getNeighborChunks(map, x, y),
scoreAttackLocation,
squad)
if (chunk ~= SENTINEL_IMPASSABLE_CHUNK) then
addSquadToChunk(map, chunk, squad)
addMovementPenalty(natives, squad, chunk)
elseif (attackChunk ~= SENTINEL_IMPASSABLE_CHUNK) then
addSquadToChunk(map, attackChunk, squad)
addMovementPenalty(natives, squad, attackChunk)
end
if group.valid and (attackChunk ~= SENTINEL_IMPASSABLE_CHUNK) then
local playerBaseGenerator = getPlayerBaseGenerator(map, attackChunk)
if (playerBaseGenerator == 0) or ((groupState == DEFINES_GROUP_FINISHED) or (groupState == DEFINES_GROUP_GATHERING)) then
squad.cycles = ((#squad.group.members > 80) and 6) or 4
if group and group.valid then
local moreFrenzy = not squad.rabid and squad.frenzy and (euclideanDistanceNamed(groupPosition, squad.frenzyPosition) < 100)
squad.frenzy = moreFrenzy
if squad.rabid or squad.frenzy then
attackCmd.distraction = DEFINES_DISTRACTION_BY_ANYTHING
else
attackCmd.distraction = DEFINES_DISTRACTION_BY_ENEMY
end
local position = findMovementPosition(surface, positionFromDirectionAndChunk(attackDirection, groupPosition, attackPosition, 1.35))
if position then
attackPosition.x = position.x
attackPosition.y = position.y
group.set_command(attackCmd)
group.start_moving()
else
addMovementPenalty(natives, squad, attackChunk)
end
elseif not squad.frenzy and not squad.rabid and
((groupState == DEFINES_GROUP_ATTACKING_DISTRACTION) or (groupState == DEFINES_GROUP_ATTACKING_TARGET) or
(playerBaseGenerator ~= 0)) then
squad.frenzy = true
squad.frenzyPosition.x = groupPosition.x
squad.frenzyPosition.y = groupPosition.y
end
end
if (squad.status == SQUAD_RAIDING) then
attackMove(map, attackPosition, attackCmd, squad, group, natives, surface)
elseif (squad.status == SQUAD_SETTLING) then
settleMove(map, attackPosition, settleCmd, squad, group, natives, surface)
end
end
end
@ -128,7 +192,7 @@ function squadAttack.squadsBeginAttack(natives, players)
for i=1,#squads do
local squad = squads[i]
local group = squad.group
if (squad.status == SQUAD_GUARDING) and group and group.valid then
if not squad.settlers and (squad.status == SQUAD_GUARDING) and group and group.valid then
local kamikazeThreshold = calculateKamikazeThreshold(#squad.group.members, natives)
local groupPosition = group.position

View File

@ -19,6 +19,7 @@ local DEFINES_GROUP_STATE_ATTACKING_DISTRACTION = defines.group_state.attacking_
local SQUAD_RETREATING = constants.SQUAD_RETREATING
local SQUAD_GUARDING = constants.SQUAD_GUARDING
local SQUAD_SETTLING = constants.SQUAD_SETTLING
local GROUP_MERGE_DISTANCE = constants.GROUP_MERGE_DISTANCE
local RETREAT_FILTER = constants.RETREAT_FILTER
@ -106,6 +107,7 @@ function unitGroupUtils.createSquad(position, surface, natives, group)
group = unitGroup,
status = SQUAD_GUARDING,
penalties = {},
settlers = false,
rabid = false,
frenzy = false,
kamikaze = false,
@ -177,13 +179,22 @@ function unitGroupUtils.cleanSquads(natives, map)
local status = squad.status
local cycles = squad.cycles
if (status == SQUAD_RETREATING) and (cycles == 0) then
squad.status = SQUAD_GUARDING
if squad.settlers then
squad.status = SQUAD_SETTLING
else
squad.status = SQUAD_GUARDING
end
squad.frenzy = true
local squadPosition = group.position
squad.frenzyPosition.x = squadPosition.x
squad.frenzyPosition.y = squadPosition.y
elseif (group.state == DEFINES_GROUP_STATE_FINISHED) then
squad.status = SQUAD_GUARDING
if squad.settlers then
squad.status = SQUAD_SETTLING
else
squad.status = SQUAD_GUARDING
end
elseif (cycles > 0) then
squad.cycles = cycles - 1
end

View File

@ -383,14 +383,14 @@ data:extend({
-- ,
-- {
-- type = "bool-setting",
-- name = "rampant-useCustomAI",
-- description = "rampant-useCustomAI",
-- setting_type = 'startup',
-- default_value = false,
-- order = "h[total]-a[ai]",
-- per_user = false
-- }
{
type = "bool-setting",
name = "rampant-useCustomAI",
description = "rampant-useCustomAI",
setting_type = 'startup',
default_value = true,
order = "h[total]-a[ai]",
per_user = false
}
})