mirror of
https://github.com/veden/Rampant.git
synced 2025-03-11 14:49:32 +02:00
linted
This commit is contained in:
parent
1a4fec2c34
commit
5f3364da06
31
.luacheckrc
Normal file
31
.luacheckrc
Normal file
@ -0,0 +1,31 @@
|
||||
globals = {
|
||||
"game",
|
||||
"remote",
|
||||
"settings",
|
||||
"commands",
|
||||
"global",
|
||||
"rendering",
|
||||
"table_size",
|
||||
"script",
|
||||
"defines",
|
||||
"mapProcessorG",
|
||||
"pheromoneUtilsG",
|
||||
"aiAttackWaveG",
|
||||
"aiPlanningG",
|
||||
"aiPredicatesG",
|
||||
"constantsG",
|
||||
"chunkProcessorG",
|
||||
"chunkPropertyUtilsG",
|
||||
"chunkUtilsG",
|
||||
"interopG",
|
||||
"mapUtilsG",
|
||||
"mathUtilsG",
|
||||
"movementUtilsG",
|
||||
"playerUtilsG",
|
||||
"squadAttackG",
|
||||
"aiDefenseG",
|
||||
"stringUtilsG",
|
||||
"unitGroupUtilsG",
|
||||
"unitUtilsG",
|
||||
"baseUtilsG"
|
||||
}
|
23
Upgrade.lua
23
Upgrade.lua
@ -7,19 +7,9 @@ local mathUtils = require("libs/MathUtils")
|
||||
|
||||
-- constants
|
||||
|
||||
local CONVERSION_TABLE = constants.CONVERSION_TABLE
|
||||
|
||||
local BASE_AI_STATE_DORMANT = constants.BASE_AI_STATE_DORMANT
|
||||
|
||||
local INTERVAL_LOGIC = constants.INTERVAL_LOGIC
|
||||
local CHUNK_SIZE = constants.CHUNK_SIZE
|
||||
|
||||
local ATTACK_SCORE = constants.ATTACK_SCORE
|
||||
|
||||
local SQUAD_GUARDING = constants.SQUAD_GUARDING
|
||||
|
||||
local AI_MAX_OVERFLOW_POINTS = constants.AI_MAX_OVERFLOW_POINTS
|
||||
|
||||
-- imported functions
|
||||
|
||||
local roundToNearest = mathUtils.roundToNearest
|
||||
@ -55,7 +45,8 @@ function upgrade.attempt(natives, setNewSurface, gameSurfaces)
|
||||
natives.regroupIndex = 1
|
||||
natives.randomGenerator = game.create_random_generator(settings.startup["rampant-enemySeed"].value+1024)
|
||||
|
||||
game.map_settings.path_finder.min_steps_to_check_path_find_termination = constants.PATH_FINDER_MIN_STEPS_TO_CHECK_PATH
|
||||
game.map_settings.path_finder.min_steps_to_check_path_find_termination =
|
||||
constants.PATH_FINDER_MIN_STEPS_TO_CHECK_PATH
|
||||
|
||||
natives.evolutionTableAlignment = {}
|
||||
natives.bases = {}
|
||||
@ -129,7 +120,9 @@ function upgrade.attempt(natives, setNewSurface, gameSurfaces)
|
||||
end
|
||||
|
||||
for _,player in pairs(game.connected_players) do
|
||||
if player and player.valid and not settings.get_player_settings(player)["rampant-suppress-surface-change-warnings"].value then
|
||||
if player and player.valid and
|
||||
not settings.get_player_settings(player)["rampant-suppress-surface-change-warnings"].value
|
||||
then
|
||||
local surface = player.surface
|
||||
if (natives.activeSurface ~= surface.name) then
|
||||
local playerName = player.name
|
||||
@ -158,9 +151,9 @@ function upgrade.attempt(natives, setNewSurface, gameSurfaces)
|
||||
global.version = 113
|
||||
|
||||
natives.baseId = 0
|
||||
|
||||
|
||||
local newBases = {}
|
||||
for i=1,#natives.bases do
|
||||
for _=1,#natives.bases do
|
||||
local base = natives.bases
|
||||
base.id = natives.baseId
|
||||
newBases[base.id] = base
|
||||
@ -171,7 +164,7 @@ function upgrade.attempt(natives, setNewSurface, gameSurfaces)
|
||||
|
||||
game.map_settings.unit_group.member_disown_distance = 10
|
||||
game.map_settings.unit_group.tick_tolerance_when_member_arrives = 60
|
||||
|
||||
|
||||
natives.vengenceQueue = {}
|
||||
natives.builderCount = 0
|
||||
natives.squadCount = 0
|
||||
|
@ -20,6 +20,12 @@ Date: 06. 02. 2021
|
||||
- Halved AI temperament rate of change
|
||||
Bugfixes:
|
||||
- Fixed suicide and nuclear enemies explosion centered on target instead self
|
||||
- Fixed process spawners reading missing globals
|
||||
- Fixed potential desync in squad attack movement
|
||||
- Fixed potential desync in unit group creation event
|
||||
- Fixed potential desync in building native tables
|
||||
- Fixed find entity upgrade incorrectly calculating evolution
|
||||
|
||||
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Version: 1.0.2
|
||||
|
135
control.lua
135
control.lua
@ -4,7 +4,6 @@ local chunkPropertyUtils = require("libs/ChunkPropertyUtils")
|
||||
local unitUtils = require("libs/UnitUtils")
|
||||
local baseUtils = require("libs/BaseUtils")
|
||||
local mapUtils = require("libs/MapUtils")
|
||||
local movementUtils = require("libs/MovementUtils")
|
||||
local mathUtils = require("libs/MathUtils")
|
||||
local unitGroupUtils = require("libs/UnitGroupUtils")
|
||||
local chunkProcessor = require("libs/ChunkProcessor")
|
||||
@ -24,46 +23,28 @@ local aiPredicates = require("libs/AIPredicates")
|
||||
|
||||
-- constants
|
||||
|
||||
local DIVISOR_DEATH_TRAIL_TABLE = constants.DIVISOR_DEATH_TRAIL_TABLE
|
||||
local TRIPLE_CHUNK_SIZE = constants.TRIPLE_CHUNK_SIZE
|
||||
local INTERVAL_LOGIC = constants.INTERVAL_LOGIC
|
||||
local INTERVAL_PLAYER_PROCESS = constants.INTERVAL_PLAYER_PROCESS
|
||||
local INTERVAL_MAP_PROCESS = constants.INTERVAL_MAP_PROCESS
|
||||
local INTERVAL_ENEMY_SCAN = constants.INTERVAL_ENEMY_SCAN
|
||||
local INTERVAL_SCAN = constants.INTERVAL_SCAN
|
||||
local INTERVAL_PLAYER_SCAN = constants.INTERVAL_PLAYER_SCAN
|
||||
local INTERVAL_SQUAD = constants.INTERVAL_SQUAD
|
||||
local INTERVAL_RESQUAD = constants.INTERVAL_RESQUAD
|
||||
local INTERVAL_TEMPERAMENT = constants.INTERVAL_TEMPERAMENT
|
||||
local INTERVAL_SPAWNER = constants.INTERVAL_SPAWNER
|
||||
local INTERVAL_CHUNK_PROCESS = constants.INTERVAL_CHUNK_PROCESS
|
||||
local INTERVAL_PASS_SCAN = constants.INTERVAL_PASS_SCAN
|
||||
local INTERVAL_NEST = constants.INTERVAL_NEST
|
||||
local INTERVAL_CLEANUP = constants.INTERVAL_CLEANUP
|
||||
local INTERVAL_MAP_STATIC_PROCESS = constants.INTERVAL_MAP_STATIC_PROCESS
|
||||
local INTERVAL_VICTORY = constants.INTERVAL_VICTORY
|
||||
|
||||
local HIVE_BUILDINGS = constants.HIVE_BUILDINGS
|
||||
|
||||
local AI_SQUAD_COST = constants.AI_SQUAD_COST
|
||||
local AI_SETTLER_COST = constants.AI_SETTLER_COST
|
||||
|
||||
local RECOVER_NEST_COST = constants.RECOVER_NEST_COST
|
||||
local RECOVER_WORM_COST = constants.RECOVER_WORM_COST
|
||||
|
||||
local DOUBLE_CHUNK_SIZE = constants.DOUBLE_CHUNK_SIZE
|
||||
|
||||
local AI_MAX_BITER_GROUP_SIZE = constants.AI_MAX_BITER_GROUP_SIZE
|
||||
|
||||
local PROCESS_QUEUE_SIZE = constants.PROCESS_QUEUE_SIZE
|
||||
|
||||
local WATER_TILE_NAMES = constants.WATER_TILE_NAMES
|
||||
|
||||
local RETREAT_GRAB_RADIUS = constants.RETREAT_GRAB_RADIUS
|
||||
|
||||
local RETREAT_SPAWNER_GRAB_RADIUS = constants.RETREAT_SPAWNER_GRAB_RADIUS
|
||||
|
||||
local DEFINES_BEHAVIOR_RESULT_FAIL = defines.behavior_result.fail
|
||||
local DEFINES_COMMAND_GROUP = defines.command.group
|
||||
local DEFINES_COMMAND_WANDER = defines.command.wander
|
||||
local DEFINES_COMMAND_BUILD_BASE = defines.command.build_base
|
||||
@ -74,8 +55,6 @@ local DEFINES_COMMAND_FLEE = defines.command.flee
|
||||
local DEFINES_COMMAND_STOP = defines.command.stop
|
||||
|
||||
local DEFINES_COMPOUND_COMMAND_RETURN_LAST = defines.compound_command.return_last
|
||||
local DEFINES_COMPOUND_COMMAND_AND = defines.compound_command.logical_and
|
||||
local DEFINES_COMPOUND_COMMAND_OR = defines.compound_command.logical_or
|
||||
|
||||
local CHUNK_SIZE = constants.CHUNK_SIZE
|
||||
|
||||
@ -110,15 +89,12 @@ local processSpawners = mapProcessor.processSpawners
|
||||
|
||||
local processStaticMap = mapProcessor.processStaticMap
|
||||
|
||||
local getPlayerBaseGenerator = chunkPropertyUtils.getPlayerBaseGenerator
|
||||
|
||||
local disperseVictoryScent = pheromoneUtils.disperseVictoryScent
|
||||
|
||||
local getChunkByPosition = mapUtils.getChunkByPosition
|
||||
|
||||
local entityForPassScan = chunkUtils.entityForPassScan
|
||||
|
||||
local addMovementPenalty = movementUtils.addMovementPenalty
|
||||
local processPendingChunks = chunkProcessor.processPendingChunks
|
||||
local processScanChunks = chunkProcessor.processScanChunks
|
||||
|
||||
@ -139,8 +115,6 @@ local recycleBases = baseUtils.recycleBases
|
||||
local deathScent = pheromoneUtils.deathScent
|
||||
local victoryScent = pheromoneUtils.victoryScent
|
||||
|
||||
local regroupSquads = unitGroupUtils.regroupSquads
|
||||
|
||||
local createSquad = unitGroupUtils.createSquad
|
||||
|
||||
local createBase = baseUtils.createBase
|
||||
@ -148,8 +122,6 @@ local findNearbyBase = baseUtils.findNearbyBase
|
||||
|
||||
local processActiveNests = mapProcessor.processActiveNests
|
||||
|
||||
local removeSquadFromChunk = chunkPropertyUtils.removeSquadFromChunk
|
||||
local addDeathGenerator = chunkPropertyUtils.addDeathGenerator
|
||||
local getDeathGenerator = chunkPropertyUtils.getDeathGenerator
|
||||
|
||||
local retreatUnits = squadDefense.retreatUnits
|
||||
@ -167,7 +139,6 @@ local cleanSquads = squadAttack.cleanSquads
|
||||
local upgradeEntity = baseUtils.upgradeEntity
|
||||
local rebuildNativeTables = baseUtils.rebuildNativeTables
|
||||
|
||||
local mMin = math.min
|
||||
local mRandom = math.random
|
||||
|
||||
local tRemove = table.remove
|
||||
@ -192,7 +163,7 @@ local function onIonCannonFired(event)
|
||||
natives.points = natives.points + 4000
|
||||
local chunk = getChunkByPosition(map, event.position)
|
||||
if (chunk ~= -1) then
|
||||
rallyUnits(chunk, map, surface, event.tick)
|
||||
rallyUnits(chunk, map, event.tick)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -568,9 +539,15 @@ local function onModSettingsChange(event)
|
||||
upgrade.compareTable(natives, "safeBuildings", settings.global["rampant-safeBuildings"].value)
|
||||
|
||||
upgrade.compareTable(natives.safeEntities, "curved-rail", settings.global["rampant-safeBuildings-curvedRail"].value)
|
||||
upgrade.compareTable(natives.safeEntities, "straight-rail", settings.global["rampant-safeBuildings-straightRail"].value)
|
||||
upgrade.compareTable(natives.safeEntities, "rail-signal", settings.global["rampant-safeBuildings-railSignals"].value)
|
||||
upgrade.compareTable(natives.safeEntities, "rail-chain-signal", settings.global["rampant-safeBuildings-railChainSignals"].value)
|
||||
upgrade.compareTable(natives.safeEntities,
|
||||
"straight-rail",
|
||||
settings.global["rampant-safeBuildings-straightRail"].value)
|
||||
upgrade.compareTable(natives.safeEntities,
|
||||
"rail-signal",
|
||||
settings.global["rampant-safeBuildings-railSignals"].value)
|
||||
upgrade.compareTable(natives.safeEntities,
|
||||
"rail-chain-signal",
|
||||
settings.global["rampant-safeBuildings-railChainSignals"].value)
|
||||
upgrade.compareTable(natives.safeEntities, "train-stop", settings.global["rampant-safeBuildings-trainStops"].value)
|
||||
upgrade.compareTable(natives.safeEntities, "lamp", settings.global["rampant-safeBuildings-lamps"].value)
|
||||
|
||||
@ -593,7 +570,9 @@ local function onModSettingsChange(event)
|
||||
upgrade.compareTable(natives, "siegeAIToggle", settings.global["rampant-siegeAIToggle"].value)
|
||||
|
||||
upgrade.compareTable(natives, "attackPlayerThreshold", settings.global["rampant-attackPlayerThreshold"].value)
|
||||
upgrade.compareTable(natives, "attackUsePlayer", settings.global["rampant-attackWaveGenerationUsePlayerProximity"].value)
|
||||
upgrade.compareTable(natives,
|
||||
"attackUsePlayer",
|
||||
settings.global["rampant-attackWaveGenerationUsePlayerProximity"].value)
|
||||
|
||||
upgrade.compareTable(natives, "attackWaveMaxSize", settings.global["rampant-attackWaveMaxSize"].value)
|
||||
upgrade.compareTable(natives, "aiNocturnalMode", settings.global["rampant-permanentNocturnal"].value)
|
||||
@ -625,7 +604,7 @@ local function prepWorld(rebuild, surfaceName)
|
||||
gameSurfaces = global.gameSurfaces
|
||||
onModSettingsChange(nil)
|
||||
if natives.newEnemies then
|
||||
rebuildNativeTables(natives, game.get_surface(natives.activeSurface), game.create_random_generator(natives.enemySeed))
|
||||
rebuildNativeTables(natives, game.create_random_generator(natives.enemySeed))
|
||||
else
|
||||
natives.buildingHiveTypeLookup = {}
|
||||
natives.buildingHiveTypeLookup["biter-spawner"] = "biter-spawner"
|
||||
@ -708,7 +687,8 @@ local function onDeath(event)
|
||||
local entityType = entity.type
|
||||
if (entity.force.name == "enemy") then
|
||||
|
||||
local artilleryBlast = (cause and ((cause.type == "artillery-wagon") or (cause.type == "artillery-turret")))
|
||||
local artilleryBlast = (cause and
|
||||
((cause.type == "artillery-wagon") or (cause.type == "artillery-turret")))
|
||||
|
||||
if artilleryBlast then
|
||||
natives.artilleryBlasts = natives.artilleryBlasts + 1
|
||||
@ -731,17 +711,19 @@ local function onDeath(event)
|
||||
natives.lostEnemyUnits = natives.lostEnemyUnits + 1
|
||||
|
||||
if (mRandom() < natives.rallyThreshold) and not surface.peaceful_mode then
|
||||
rallyUnits(chunk, map, surface, tick)
|
||||
rallyUnits(chunk, map, tick)
|
||||
end
|
||||
end
|
||||
elseif event.force and (event.force.name ~= "enemy") and ((entityType == "unit-spawner") or (entityType == "turret")) then
|
||||
elseif event.force and (event.force.name ~= "enemy") and
|
||||
((entityType == "unit-spawner") or (entityType == "turret")) then
|
||||
|
||||
natives.points = natives.points + (((entityType == "unit-spawner") and RECOVER_NEST_COST) or RECOVER_WORM_COST)
|
||||
natives.points = natives.points +
|
||||
(((entityType == "unit-spawner") and RECOVER_NEST_COST) or RECOVER_WORM_COST)
|
||||
|
||||
unregisterEnemyBaseStructure(map, entity)
|
||||
|
||||
if (chunk ~= -1) then
|
||||
rallyUnits(chunk, map, surface, tick)
|
||||
rallyUnits(chunk, map, tick)
|
||||
|
||||
if cause and cause.valid then
|
||||
retreatUnits(chunk,
|
||||
@ -787,9 +769,11 @@ local function onDeath(event)
|
||||
if ((cause and ENERGY_THIEF_LOOKUP[cause.name]) or (not cause)) then
|
||||
local conversion = ENERGY_THIEF_CONVERSION_TABLE[entityType]
|
||||
if conversion then
|
||||
local newEntity = surface.create_entity({position=entity.position,
|
||||
name=convertTypeToDrainCrystal(entity.force.evolution_factor, conversion),
|
||||
direction=entity.direction})
|
||||
local newEntity = surface.create_entity({
|
||||
position=entity.position,
|
||||
name=convertTypeToDrainCrystal(entity.force.evolution_factor, conversion),
|
||||
direction=entity.direction
|
||||
})
|
||||
if (conversion == "pole") then
|
||||
local targetEntity = surface.create_entity({position=entity.position,
|
||||
name="pylon-target-rampant",
|
||||
@ -807,12 +791,18 @@ local function onDeath(event)
|
||||
end
|
||||
for _,v in pairs(wires.red) do
|
||||
if (v.valid) then
|
||||
newEntity.connect_neighbour({wire = DEFINES_WIRE_TYPE_RED, target_entity = v});
|
||||
newEntity.connect_neighbour({
|
||||
wire = DEFINES_WIRE_TYPE_RED,
|
||||
target_entity = v
|
||||
});
|
||||
end
|
||||
end
|
||||
for _,v in pairs(wires.green) do
|
||||
if (v.valid) then
|
||||
newEntity.connect_neighbour({wire = DEFINES_WIRE_TYPE_GREEN, target_entity = v});
|
||||
newEntity.connect_neighbour({
|
||||
wire = DEFINES_WIRE_TYPE_GREEN,
|
||||
target_entity = v
|
||||
});
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -827,7 +817,9 @@ local function onDeath(event)
|
||||
unregisterResource(entity, map)
|
||||
end
|
||||
end
|
||||
if creditNatives and natives.safeBuildings and (natives.safeEntities[entityType] or natives.safeEntities[entity.name]) then
|
||||
if creditNatives and natives.safeBuildings and
|
||||
(natives.safeEntities[entityType] or natives.safeEntities[entity.name])
|
||||
then
|
||||
makeImmortalEntity(surface, entity)
|
||||
else
|
||||
accountPlayerEntity(entity, natives, false, creditNatives)
|
||||
@ -971,7 +963,9 @@ end
|
||||
|
||||
local function onTriggerEntityCreated(event)
|
||||
local entity = event.entity
|
||||
if entity.valid and (entity.surface.name == natives.activeSurface) and (entity.name == "drain-trigger-rampant") then
|
||||
if entity.valid and (entity.surface.name == natives.activeSurface) and
|
||||
(entity.name == "drain-trigger-rampant")
|
||||
then
|
||||
local chunk = getChunkByPosition(map, entity.position)
|
||||
if (chunk ~= -1) then
|
||||
map.chunkToDrained[chunk] = event.tick + 60
|
||||
@ -995,13 +989,10 @@ end
|
||||
|
||||
local function onEntitySpawned(event)
|
||||
local entity = event.mine
|
||||
local unitNumber = entity.unit_number
|
||||
if natives.newEnemies and entity.valid then
|
||||
local surface = entity.surface
|
||||
local entityPosition = entity.position
|
||||
if (surface.name == natives.activeSurface) and natives.buildingHiveTypeLookup[entity.name] then
|
||||
local disPos = mathUtils.distortPosition(entity.position, 8)
|
||||
local canPlaceQuery = map.canPlaceQuery
|
||||
|
||||
local chunk = getChunkByPosition(map, disPos)
|
||||
if (chunk ~= -1) then
|
||||
@ -1031,6 +1022,7 @@ end
|
||||
local function onUnitGroupCreated(event)
|
||||
local group = event.group
|
||||
local surface = group.surface
|
||||
local squad
|
||||
if (surface.name == natives.activeSurface) and (group.force.name == "enemy") then
|
||||
if not group.is_script_driven then
|
||||
if not natives.aiNocturnalMode then
|
||||
@ -1081,25 +1073,6 @@ local function onUnitGroupCreated(event)
|
||||
end
|
||||
end
|
||||
|
||||
-- local function onCommandComplete(event)
|
||||
-- local unitNumber = event.unit_number
|
||||
-- local squad = natives.groupNumberToSquad[unitNumber]
|
||||
-- if squad then
|
||||
-- local group = squad.group
|
||||
-- if group and group.valid and (group.surface.name == natives.activeSurface) then
|
||||
-- -- if (event.result == DEFINES_BEHAVIOR_RESULT_FAIL) then
|
||||
-- -- if (#group.members == 0) then
|
||||
-- -- group.destroy()
|
||||
-- -- else
|
||||
-- -- squadDispatch(map, group.surface, squad, unitNumber)
|
||||
-- -- end
|
||||
-- -- else
|
||||
-- squadDispatch(map, group.surface, squad, unitNumber)
|
||||
-- -- end
|
||||
-- end
|
||||
-- end
|
||||
-- end
|
||||
|
||||
local function onGroupFinishedGathering(event)
|
||||
local group = event.group
|
||||
if group.valid and (group.force.name == "enemy") then
|
||||
@ -1179,7 +1152,8 @@ end
|
||||
local function onPlayerChangedSurface(event)
|
||||
local player = game.players[event.player_index]
|
||||
local surface
|
||||
if player and player.valid and not settings.get_player_settings(player)["rampant-suppress-surface-change-warnings"].value
|
||||
if player and player.valid and
|
||||
not settings.get_player_settings(player)["rampant-suppress-surface-change-warnings"].value
|
||||
then
|
||||
surface = player.surface
|
||||
if (natives.activeSurface ~= surface.name) then
|
||||
@ -1231,7 +1205,7 @@ end
|
||||
-- hooks
|
||||
|
||||
script.on_nth_tick(INTERVAL_PASS_SCAN,
|
||||
function (event)
|
||||
function ()
|
||||
processScanChunks(map,
|
||||
game.get_surface(natives.activeSurface))
|
||||
end)
|
||||
@ -1270,19 +1244,17 @@ script.on_nth_tick(INTERVAL_SPAWNER,
|
||||
end)
|
||||
|
||||
script.on_nth_tick(INTERVAL_VICTORY,
|
||||
function (event)
|
||||
function ()
|
||||
disperseVictoryScent(map)
|
||||
end)
|
||||
|
||||
script.on_nth_tick(INTERVAL_SQUAD,
|
||||
function (event)
|
||||
processVengence(map,
|
||||
game.get_surface(natives.activeSurface),
|
||||
event.tick)
|
||||
function ()
|
||||
processVengence(map, game.get_surface(natives.activeSurface))
|
||||
end)
|
||||
|
||||
script.on_nth_tick(INTERVAL_TEMPERAMENT,
|
||||
function (event)
|
||||
function ()
|
||||
temperamentPlanner(natives)
|
||||
end)
|
||||
|
||||
@ -1302,9 +1274,9 @@ script.on_event(defines.events.on_tick,
|
||||
elseif (pick == 1) then
|
||||
processPlayers(gameRef.connected_players, map, surface, tick)
|
||||
elseif (pick == 2) then
|
||||
processMap(map, surface, tick)
|
||||
processMap(map, tick)
|
||||
elseif (pick == 3) then
|
||||
processStaticMap(map, surface, tick)
|
||||
processStaticMap(map)
|
||||
elseif (pick == 4) then
|
||||
scanResourceMap(map, surface, tick)
|
||||
elseif (pick == 5) then
|
||||
@ -1315,11 +1287,12 @@ script.on_event(defines.events.on_tick,
|
||||
|
||||
cleanSquads(natives, map.squadIterator)
|
||||
processActiveNests(map, surface, tick)
|
||||
|
||||
|
||||
-- game.print({"", "--dispatch4 ", profiler, ", ", game.tick, " ", mRandom()})
|
||||
end)
|
||||
|
||||
script.on_event(defines.events.on_surface_cleared, onSurfaceCleared)
|
||||
-- script.on_event(defines.events.on_surface_deleted, onSurfaceDeleted)
|
||||
script.on_event(defines.events.on_surface_renamed, onSurfaceRenamed)
|
||||
script.on_event(defines.events.on_player_changed_surface, onPlayerChangedSurface)
|
||||
|
||||
@ -1403,7 +1376,7 @@ interop.setActiveSurface = function (surfaceName)
|
||||
end
|
||||
commands.add_command("GetRampantAISurface",
|
||||
{"description.rampant-get-surface"},
|
||||
function (event)
|
||||
function ()
|
||||
for _,player in pairs(game.connected_players) do
|
||||
if (player.valid) then
|
||||
player.print({"description.rampant-get-surface",
|
||||
|
@ -11,7 +11,6 @@ local chunkPropertyUtils = require("ChunkPropertyUtils")
|
||||
local unitGroupUtils = require("UnitGroupUtils")
|
||||
local movementUtils = require("MovementUtils")
|
||||
local mathUtils = require("MathUtils")
|
||||
local baseUtils = require("BaseUtils")
|
||||
local config = require("__Rampant__/config")
|
||||
|
||||
-- constants
|
||||
@ -35,7 +34,6 @@ local CHUNK_ALL_DIRECTIONS = constants.CHUNK_ALL_DIRECTIONS
|
||||
local CHUNK_SIZE = constants.CHUNK_SIZE
|
||||
|
||||
local RALLY_CRY_DISTANCE = constants.RALLY_CRY_DISTANCE
|
||||
local SETTLER_DISTANCE = constants.SETTLER_DISTANCE
|
||||
|
||||
local RESOURCE_MINIMUM_FORMATION_DELTA = constants.RESOURCE_MINIMUM_FORMATION_DELTA
|
||||
|
||||
@ -125,38 +123,38 @@ local function visitPattern(o, cX, cY, distance)
|
||||
local endY
|
||||
local stepY
|
||||
if (o == 0) then
|
||||
startX = cX - RALLY_CRY_DISTANCE
|
||||
endX = cX + RALLY_CRY_DISTANCE
|
||||
startX = cX - distance
|
||||
endX = cX + distance
|
||||
stepX = 32
|
||||
startY = cY - RALLY_CRY_DISTANCE
|
||||
endY = cY + RALLY_CRY_DISTANCE
|
||||
startY = cY - distance
|
||||
endY = cY + distance
|
||||
stepY = 32
|
||||
elseif (o == 1) then
|
||||
startX = cX + RALLY_CRY_DISTANCE
|
||||
endX = cX - RALLY_CRY_DISTANCE
|
||||
startX = cX + distance
|
||||
endX = cX - distance
|
||||
stepX = -32
|
||||
startY = cY + RALLY_CRY_DISTANCE
|
||||
endY = cY - RALLY_CRY_DISTANCE
|
||||
startY = cY + distance
|
||||
endY = cY - distance
|
||||
stepY = -32
|
||||
elseif (o == 2) then
|
||||
startX = cX - RALLY_CRY_DISTANCE
|
||||
endX = cX + RALLY_CRY_DISTANCE
|
||||
startX = cX - distance
|
||||
endX = cX + distance
|
||||
stepX = 32
|
||||
startY = cY + RALLY_CRY_DISTANCE
|
||||
endY = cY - RALLY_CRY_DISTANCE
|
||||
startY = cY + distance
|
||||
endY = cY - distance
|
||||
stepY = -32
|
||||
elseif (o == 3) then
|
||||
startX = cX + RALLY_CRY_DISTANCE
|
||||
endX = cX - RALLY_CRY_DISTANCE
|
||||
startX = cX + distance
|
||||
endX = cX - distance
|
||||
stepX = -32
|
||||
startY = cY - RALLY_CRY_DISTANCE
|
||||
endY = cY + RALLY_CRY_DISTANCE
|
||||
startY = cY - distance
|
||||
endY = cY + distance
|
||||
stepY = 32
|
||||
end
|
||||
return startX, endX, stepX, startY, endY, stepY
|
||||
end
|
||||
|
||||
function aiAttackWave.rallyUnits(chunk, map, surface, tick)
|
||||
function aiAttackWave.rallyUnits(chunk, map, tick)
|
||||
if ((tick - getRallyTick(map, chunk) > COOLDOWN_RALLY) and (map.natives.points >= AI_VENGENCE_SQUAD_COST)) then
|
||||
setRallyTick(map, chunk, tick)
|
||||
local cX = chunk.x
|
||||
@ -183,7 +181,7 @@ function aiAttackWave.rallyUnits(chunk, map, surface, tick)
|
||||
end
|
||||
end
|
||||
|
||||
function aiAttackWave.formSettlers(map, surface, chunk, tick)
|
||||
function aiAttackWave.formSettlers(map, surface, chunk)
|
||||
|
||||
local natives = map.natives
|
||||
if (natives.builderCount < natives.AI_MAX_BUILDER_COUNT) and
|
||||
@ -224,11 +222,10 @@ function aiAttackWave.formSettlers(map, surface, chunk, tick)
|
||||
|
||||
local scaledWaveSize = settlerWaveScaling(natives)
|
||||
map.formGroupCommand.group = squad.group
|
||||
local group = squad.group
|
||||
map.formCommand.unit_count = scaledWaveSize
|
||||
local foundUnits = surface.set_multi_command(map.formCommand)
|
||||
if (foundUnits > 0) then
|
||||
squad.kamikaze = mRandom() < calculateKamikazeThreshold(foundUnits, natives)
|
||||
squad.kamikaze = mRandom() < calculateKamikazeThreshold(foundUnits, natives)
|
||||
natives.builderCount = natives.builderCount + 1
|
||||
natives.points = natives.points - AI_SETTLER_COST
|
||||
natives.groupNumberToSquad[squad.groupNumber] = squad
|
||||
@ -268,11 +265,10 @@ function aiAttackWave.formVengenceSquad(map, surface, chunk)
|
||||
|
||||
local scaledWaveSize = attackWaveScaling(natives)
|
||||
map.formGroupCommand.group = squad.group
|
||||
local group = squad.group
|
||||
map.formCommand.unit_count = scaledWaveSize
|
||||
local foundUnits = surface.set_multi_command(map.formCommand)
|
||||
if (foundUnits > 0) then
|
||||
squad.kamikaze = mRandom() < calculateKamikazeThreshold(foundUnits, natives)
|
||||
squad.kamikaze = mRandom() < calculateKamikazeThreshold(foundUnits, natives)
|
||||
natives.groupNumberToSquad[squad.groupNumber] = squad
|
||||
natives.squadCount = natives.squadCount + 1
|
||||
natives.points = natives.points - AI_VENGENCE_SQUAD_COST
|
||||
@ -313,7 +309,6 @@ function aiAttackWave.formSquads(map, surface, chunk, tick)
|
||||
|
||||
local scaledWaveSize = attackWaveScaling(natives)
|
||||
map.formGroupCommand.group = squad.group
|
||||
local group = squad.group
|
||||
map.formCommand.unit_count = scaledWaveSize
|
||||
local foundUnits = surface.set_multi_command(map.formCommand)
|
||||
if (foundUnits > 0) then
|
||||
|
@ -30,9 +30,7 @@ local AI_MAX_POINTS = constants.AI_MAX_POINTS
|
||||
local AI_POINT_GENERATOR_AMOUNT = constants.AI_POINT_GENERATOR_AMOUNT
|
||||
|
||||
local AI_MIN_STATE_DURATION = constants.AI_MIN_STATE_DURATION
|
||||
local AI_MIN_TEMPERAMENT_DURATION = constants.AI_MIN_TEMPERAMENT_DURATION
|
||||
local AI_MAX_STATE_DURATION = constants.AI_MAX_STATE_DURATION
|
||||
local AI_MAX_TEMPERAMENT_DURATION = constants.AI_MAX_TEMPERAMENT_DURATION
|
||||
|
||||
local BASE_RALLY_CHANCE = constants.BASE_RALLY_CHANCE
|
||||
local BONUS_RALLY_CHANCE = constants.BONUS_RALLY_CHANCE
|
||||
@ -61,7 +59,8 @@ function aiPlanning.planning(natives, evolution_factor, tick)
|
||||
|
||||
local maxPoints = mMax(AI_MAX_POINTS * evolution_factor, MINIMUM_AI_POINTS)
|
||||
|
||||
if not natives.ranIncompatibleMessage and natives.newEnemies and (game.active_mods["bobenemies"] or game.active_mods["Natural_Evolution_Enemies"]) then
|
||||
if not natives.ranIncompatibleMessage and natives.newEnemies and
|
||||
(game.active_mods["bobenemies"] or game.active_mods["Natural_Evolution_Enemies"]) then
|
||||
natives.ranIncompatibleMessage = true
|
||||
game.print({"description.rampant-bobs-nee-newEnemies"})
|
||||
end
|
||||
@ -69,7 +68,9 @@ function aiPlanning.planning(natives, evolution_factor, tick)
|
||||
local maxOverflowPoints = maxPoints * 3
|
||||
|
||||
local attackWaveMaxSize = natives.attackWaveMaxSize
|
||||
natives.retreatThreshold = linearInterpolation(evolution_factor, RETREAT_MOVEMENT_PHEROMONE_LEVEL_MIN, RETREAT_MOVEMENT_PHEROMONE_LEVEL_MAX)
|
||||
natives.retreatThreshold = linearInterpolation(evolution_factor,
|
||||
RETREAT_MOVEMENT_PHEROMONE_LEVEL_MIN,
|
||||
RETREAT_MOVEMENT_PHEROMONE_LEVEL_MAX)
|
||||
natives.rallyThreshold = BASE_RALLY_CHANCE + (evolution_factor * BONUS_RALLY_CHANCE)
|
||||
natives.formSquadThreshold = mMax((0.20 * evolution_factor), 0.05)
|
||||
|
||||
@ -83,15 +84,20 @@ function aiPlanning.planning(natives, evolution_factor, tick)
|
||||
natives.attackWaveUpperBound = 3
|
||||
end
|
||||
|
||||
natives.settlerWaveSize = linearInterpolation(evolution_factor ^ 1.66667, natives.expansionMinSize, natives.expansionMaxSize)
|
||||
natives.settlerWaveSize = linearInterpolation(evolution_factor ^ 1.66667,
|
||||
natives.expansionMinSize,
|
||||
natives.expansionMaxSize)
|
||||
natives.settlerWaveDeviation = (natives.settlerWaveSize * 0.33)
|
||||
|
||||
natives.settlerCooldown = mFloor(linearInterpolation(evolution_factor ^ 1.66667, natives.expansionMaxTime, natives.expansionMinTime))
|
||||
natives.settlerCooldown = mFloor(linearInterpolation(evolution_factor ^ 1.66667,
|
||||
natives.expansionMaxTime,
|
||||
natives.expansionMinTime))
|
||||
|
||||
natives.unitRefundAmount = AI_UNIT_REFUND * evolution_factor
|
||||
natives.kamikazeThreshold = NO_RETREAT_BASE_PERCENT + (evolution_factor * NO_RETREAT_EVOLUTION_BONUS_MAX)
|
||||
|
||||
local points = mFloor((AI_POINT_GENERATOR_AMOUNT * mRandom()) + (natives.activeNests * 0.25) + ((AI_POINT_GENERATOR_AMOUNT * 0.7) * (evolution_factor ^ 2.5)) * natives.aiPointsScaler)
|
||||
local points = mFloor((AI_POINT_GENERATOR_AMOUNT * mRandom()) + (natives.activeNests * 0.25) +
|
||||
(((AI_POINT_GENERATOR_AMOUNT * 0.7) * (evolution_factor ^ 2.5)) * natives.aiPointsScaler))
|
||||
|
||||
if (natives.state == AI_STATE_ONSLAUGHT) then
|
||||
points = points * 2
|
||||
@ -326,7 +332,7 @@ function aiPlanning.temperamentPlanner(natives)
|
||||
delta = delta - val
|
||||
else
|
||||
delta = delta + val
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if (builtEnemyBuilding > 0) then
|
||||
@ -355,7 +361,8 @@ function aiPlanning.temperamentPlanner(natives)
|
||||
delta = delta + val
|
||||
end
|
||||
|
||||
print("temperament", natives.activeNests, natives.activeRaidNests, natives.destroyPlayerBuildings, natives.lostEnemyUnits,
|
||||
print("temperament", natives.activeNests, natives.activeRaidNests, natives.destroyPlayerBuildings,
|
||||
natives.lostEnemyUnits,
|
||||
natives.lostEnemyBuilding, natives.rocketLaunched, natives.builtEnemyBuilding, natives.ionCannonBlasts,
|
||||
natives.artilleryBlasts)
|
||||
|
||||
|
@ -14,8 +14,6 @@ local mapUtils = require("MapUtils")
|
||||
|
||||
local FACTION_MUTATION_MAPPING = constants.FACTION_MUTATION_MAPPING
|
||||
|
||||
local BUILDING_SPACE_LOOKUP = constants.BUILDING_SPACE_LOOKUP
|
||||
|
||||
local MAGIC_MAXIMUM_NUMBER = constants.MAGIC_MAXIMUM_NUMBER
|
||||
|
||||
local BASE_AI_STATE_DORMANT = constants.BASE_AI_STATE_DORMANT
|
||||
@ -42,26 +40,18 @@ local BASE_DISTANCE_THRESHOLD = constants.BASE_DISTANCE_THRESHOLD
|
||||
local BASE_DISTANCE_LEVEL_BONUS = constants.BASE_DISTANCE_LEVEL_BONUS
|
||||
local BASE_DISTANCE_TO_EVO_INDEX = constants.BASE_DISTANCE_TO_EVO_INDEX
|
||||
|
||||
local BASE_ALIGNMENT_EVOLUTION_BASELINE = constants.BASE_ALIGNMENT_EVOLUTION_BASELINE
|
||||
|
||||
local BASE_QUEUE_SIZE = constants.BASE_QUEUE_SIZE
|
||||
local BASE_COLLECTION_THRESHOLD = constants.BASE_COLLECTION_THRESHOLD
|
||||
|
||||
local CHUNK_SIZE = constants.CHUNK_SIZE
|
||||
local CHUNK_AND_HALF_SIZE = constants.CHUNK_AND_HALF_SIZE
|
||||
|
||||
local EVOLUTION_INCREMENTS = constants.EVOLUTION_INCREMENTS
|
||||
|
||||
-- imported functions
|
||||
|
||||
local randomTickEvent = mathUtils.randomTickEvent
|
||||
local euclideanDistancePoints = mathUtils.euclideanDistancePoints
|
||||
local roundToFloor = mathUtils.roundToFloor
|
||||
|
||||
local getChunkByPosition = mapUtils.getChunkByPosition
|
||||
|
||||
local gaussianRandomRange = mathUtils.gaussianRandomRange
|
||||
local gaussianRandomRangeRG = mathUtils.gaussianRandomRangeRG
|
||||
|
||||
local linearInterpolation = mathUtils.linearInterpolation
|
||||
|
||||
@ -78,8 +68,6 @@ local getResourceGenerator = chunkPropertyUtils.getResourceGenerator
|
||||
|
||||
local next = next
|
||||
|
||||
local tRemove = table.remove
|
||||
|
||||
local mRandom = math.random
|
||||
|
||||
-- module code
|
||||
@ -167,7 +155,6 @@ local function initialEntityUpgrade(baseAlignment, tier, maxTier, natives, useHi
|
||||
end
|
||||
if not entity then
|
||||
local roll = mRandom()
|
||||
local initial = roll
|
||||
|
||||
for ui=1,#upgrades do
|
||||
local upgrade = upgrades[ui]
|
||||
@ -219,7 +206,7 @@ end
|
||||
local function findEntityUpgrade(baseAlignment, currentEvo, evoIndex, originalEntity, natives, evolve)
|
||||
|
||||
local adjCurrentEvo = mMax(
|
||||
((baseAlignment ~= entityAlignment) and 0) or currentEvo,
|
||||
((baseAlignment ~= natives.enemyAlignmentLookup[originalEntity.name]) and 0) or currentEvo,
|
||||
0
|
||||
)
|
||||
|
||||
@ -254,10 +241,9 @@ local function findBaseInitialAlignment(natives, evoIndex)
|
||||
end
|
||||
|
||||
function baseUtils.recycleBases(natives, tick)
|
||||
local baseIndex = natives.baseIndex
|
||||
local bases = natives.bases
|
||||
local id, base = next(bases, natives.map.recycleBaseIterator)
|
||||
for i=1,2 do
|
||||
for _=1,2 do
|
||||
if not id then
|
||||
natives.map.recycleBaseIterator = nil
|
||||
return
|
||||
@ -358,8 +344,6 @@ function baseUtils.processBase(chunk, surface, natives, tick, base)
|
||||
point.x = chunk.x + (CHUNK_SIZE * mRandom())
|
||||
point.y = chunk.y + (CHUNK_SIZE * mRandom())
|
||||
|
||||
local baseAlignment = base.alignment
|
||||
|
||||
if (base.state == BASE_AI_STATE_ACTIVE) then
|
||||
local entity = surface.find_entities_filtered(map.filteredEntitiesPointQueryLimited)
|
||||
local cost = (natives.costLookup[entity.name] or MAGIC_MAXIMUM_NUMBER)
|
||||
@ -469,12 +453,7 @@ function baseUtils.createBase(natives, chunk, tick, rebuilding)
|
||||
return base
|
||||
end
|
||||
|
||||
function baseUtils.rebuildNativeTables(natives, surface, rg)
|
||||
local createEntityStmt = {
|
||||
name = nil,
|
||||
position = {0,0}
|
||||
}
|
||||
|
||||
function baseUtils.rebuildNativeTables(natives, rg)
|
||||
local alignmentSet = {}
|
||||
natives.evolutionTableAlignment = alignmentSet
|
||||
local buildingSpaceLookup = {}
|
||||
@ -493,8 +472,7 @@ function baseUtils.rebuildNativeTables(natives, surface, rg)
|
||||
natives.buildingHiveTypeLookup = buildingHiveTypeLookup
|
||||
|
||||
for i=1,10 do
|
||||
local evo = (((i - 1) * 0.1) ^ 0.5) - 0.05
|
||||
evoToTierMapping[#evoToTierMapping+1] = evo
|
||||
evoToTierMapping[#evoToTierMapping+1] = (((i - 1) * 0.1) ^ 0.5) - 0.05
|
||||
end
|
||||
|
||||
for i=1,#FACTION_SET do
|
||||
@ -506,10 +484,6 @@ function baseUtils.rebuildNativeTables(natives, surface, rg)
|
||||
buildingEvolveLookup[faction.type] = factionBuildingPicker
|
||||
|
||||
for t=1,10 do
|
||||
if (t == 1) then
|
||||
evo = faction.evo
|
||||
end
|
||||
|
||||
local alignments = alignmentSet[t]
|
||||
if not alignments then
|
||||
alignments = {}
|
||||
@ -573,16 +547,18 @@ function baseUtils.rebuildNativeTables(natives, surface, rg)
|
||||
|
||||
local buildingAcceptRate = building.acceptRate
|
||||
|
||||
local low = buildingAcceptRate[1]
|
||||
local high = buildingAcceptRate[2]
|
||||
if (low <= t) and (t <= high) then
|
||||
local buildingLow = buildingAcceptRate[1]
|
||||
local buildingHigh = buildingAcceptRate[2]
|
||||
if (buildingLow <= t) and (t <= buildingHigh) then
|
||||
for vi=1,#variationSet do
|
||||
local variation = variationSet[vi]
|
||||
buildingSet[#buildingSet+1] = variation
|
||||
end
|
||||
tieredBuildingPickerSet[#tieredBuildingPickerSet+1] = {
|
||||
distort(rg,
|
||||
linearInterpolation((t - low) / (high - low), buildingAcceptRate[3], buildingAcceptRate[4])),
|
||||
linearInterpolation((t - buildingLow) / (buildingHigh - buildingLow),
|
||||
buildingAcceptRate[3],
|
||||
buildingAcceptRate[4])),
|
||||
variationSet,
|
||||
building.type
|
||||
}
|
||||
@ -617,7 +593,7 @@ function baseUtils.rebuildNativeTables(natives, surface, rg)
|
||||
|
||||
local evoIndex = evoToTier(natives, natives.evolutionLevel)
|
||||
|
||||
for id,base in pairs(natives.bases) do
|
||||
for _,base in pairs(natives.bases) do
|
||||
for x=1,#base.alignment do
|
||||
local alignment = base.alignment[x]
|
||||
if not natives.buildingEvolveLookup[alignment] then
|
||||
|
@ -68,7 +68,7 @@ function chunkProcessor.processPendingChunks(map, surface, tick, rebuilding, flu
|
||||
if flush then
|
||||
endCount = table_size(pendingChunks)
|
||||
end
|
||||
for i=1,endCount do
|
||||
for _=1,endCount do
|
||||
if not event then
|
||||
map.chunkProcessorIterator = nil
|
||||
if (table_size(pendingChunks) == 0) then
|
||||
|
@ -17,10 +17,7 @@ local CHUNK_ALL_DIRECTIONS = constants.CHUNK_ALL_DIRECTIONS
|
||||
|
||||
-- imported functions
|
||||
|
||||
local tRemove = table.remove
|
||||
|
||||
local mMin = math.min
|
||||
local mMax = math.max
|
||||
|
||||
-- module code
|
||||
|
||||
|
@ -15,7 +15,6 @@ local chunkPropertyUtils = require("ChunkPropertyUtils")
|
||||
|
||||
local HIVE_BUILDINGS_TYPES = constants.HIVE_BUILDINGS_TYPES
|
||||
|
||||
local CHUNK_SIZE_DIVIDER = constants.CHUNK_SIZE_DIVIDER
|
||||
local DEFINES_WIRE_TYPE_RED = defines.wire_type.red
|
||||
local DEFINES_WIRE_TYPE_GREEN = defines.wire_type.green
|
||||
|
||||
@ -42,9 +41,7 @@ local RESOURCE_NORMALIZER = constants.RESOURCE_NORMALIZER
|
||||
local CHUNK_TICK = constants.CHUNK_TICK
|
||||
|
||||
local GENERATOR_PHEROMONE_LEVEL_1 = constants.GENERATOR_PHEROMONE_LEVEL_1
|
||||
local GENERATOR_PHEROMONE_LEVEL_2 = constants.GENERATOR_PHEROMONE_LEVEL_2
|
||||
local GENERATOR_PHEROMONE_LEVEL_3 = constants.GENERATOR_PHEROMONE_LEVEL_3
|
||||
local GENERATOR_PHEROMONE_LEVEL_4 = constants.GENERATOR_PHEROMONE_LEVEL_4
|
||||
local GENERATOR_PHEROMONE_LEVEL_5 = constants.GENERATOR_PHEROMONE_LEVEL_5
|
||||
local GENERATOR_PHEROMONE_LEVEL_6 = constants.GENERATOR_PHEROMONE_LEVEL_6
|
||||
|
||||
@ -88,8 +85,6 @@ local mMin = math.min
|
||||
local mMax = math.max
|
||||
local mFloor = math.floor
|
||||
|
||||
local mRandom = math.random
|
||||
|
||||
-- module code
|
||||
|
||||
local function getEntityOverlapChunks(map, entity)
|
||||
@ -204,7 +199,9 @@ function chunkUtils.initialScan(chunk, surface, map, tick, rebuilding)
|
||||
local enemyBuildings = surface.find_entities_filtered(map.filteredEntitiesEnemyStructureQuery)
|
||||
|
||||
if (waterTiles >= CHUNK_PASS_THRESHOLD) or (#enemyBuildings > 0) then
|
||||
local neutralObjects = mMax(0, mMin(1 - (surface.count_entities_filtered(map.filteredEntitiesChunkNeutral) * 0.005), 1) * 0.20)
|
||||
local neutralObjects = mMax(0,
|
||||
mMin(1 - (surface.count_entities_filtered(map.filteredEntitiesChunkNeutral) * 0.005),
|
||||
1) * 0.20)
|
||||
local pass = scanPaths(chunk, surface, map)
|
||||
|
||||
local playerObjects = scorePlayerBuildings(surface, map)
|
||||
@ -263,7 +260,8 @@ function chunkUtils.initialScan(chunk, surface, map, tick, rebuilding)
|
||||
else
|
||||
for i=1,#enemyBuildings do
|
||||
local building = enemyBuildings[i]
|
||||
local hiveType = buildingHiveTypeLookup[building.name] or (((building.type == "turret") and "turret") or "biter-spawner")
|
||||
local hiveType = buildingHiveTypeLookup[building.name] or
|
||||
(((building.type == "turret") and "turret") or "biter-spawner")
|
||||
counts[hiveType] = counts[hiveType] + 1
|
||||
end
|
||||
|
||||
@ -292,7 +290,9 @@ function chunkUtils.chunkPassScan(chunk, surface, map)
|
||||
local waterTiles = (1 - (surface.count_tiles_filtered(map.filteredTilesQuery) * 0.0009765625)) * 0.80
|
||||
|
||||
if (waterTiles >= CHUNK_PASS_THRESHOLD) then
|
||||
local neutralObjects = mMax(0, mMin(1 - (surface.count_entities_filtered(map.filteredEntitiesChunkNeutral) * 0.005), 1) * 0.20)
|
||||
local neutralObjects = mMax(0,
|
||||
mMin(1 - (surface.count_entities_filtered(map.filteredEntitiesChunkNeutral) * 0.005),
|
||||
1) * 0.20)
|
||||
local pass = scanPaths(chunk, surface, map)
|
||||
|
||||
local playerObjects = getPlayerBaseGenerator(map, chunk)
|
||||
@ -321,7 +321,9 @@ function chunkUtils.mapScanResourceChunk(chunk, surface, map)
|
||||
local resources = surface.count_entities_filtered(map.countResourcesQuery) * RESOURCE_NORMALIZER
|
||||
setResourceGenerator(map, chunk, resources)
|
||||
local waterTiles = (1 - (surface.count_tiles_filtered(map.filteredTilesQuery) * 0.0009765625)) * 0.80
|
||||
local neutralObjects = mMax(0, mMin(1 - (surface.count_entities_filtered(map.filteredEntitiesChunkNeutral) * 0.005), 1) * 0.20)
|
||||
local neutralObjects = mMax(0,
|
||||
mMin(1 - (surface.count_entities_filtered(map.filteredEntitiesChunkNeutral) * 0.005),
|
||||
1) * 0.20)
|
||||
setPathRating(map, chunk, waterTiles + neutralObjects)
|
||||
end
|
||||
|
||||
@ -334,7 +336,8 @@ function chunkUtils.mapScanEnemyChunk(chunk, surface, map)
|
||||
end
|
||||
for i=1,#buildings do
|
||||
local building = buildings[i]
|
||||
local hiveType = buildingHiveTypeLookup[building.name] or (((building.type == "turret") and "turret") or "biter-spawner")
|
||||
local hiveType = buildingHiveTypeLookup[building.name] or
|
||||
(((building.type == "turret") and "turret") or "biter-spawner")
|
||||
counts[hiveType] = counts[hiveType] + 1
|
||||
end
|
||||
|
||||
@ -373,7 +376,7 @@ function chunkUtils.colorChunk(chunk, surface, color)
|
||||
local lx = math.floor(chunk.x * CHUNK_SIZE_DIVIDER) * CHUNK_SIZE
|
||||
local ly = math.floor(chunk.y * CHUNK_SIZE_DIVIDER) * CHUNK_SIZE
|
||||
|
||||
local graphicId = rendering.draw_rectangle({
|
||||
rendering.draw_rectangle({
|
||||
color = color or {0.1, 0.3, 0.1, 0.6},
|
||||
width = 32 * 32,
|
||||
filled = true,
|
||||
@ -390,7 +393,7 @@ function chunkUtils.colorXY(x, y, surface, color)
|
||||
local lx = math.floor(x * CHUNK_SIZE_DIVIDER) * CHUNK_SIZE
|
||||
local ly = math.floor(y * CHUNK_SIZE_DIVIDER) * CHUNK_SIZE
|
||||
|
||||
local graphicId = rendering.draw_rectangle({
|
||||
rendering.draw_rectangle({
|
||||
color = color or {0.1, 0.3, 0.1, 0.6},
|
||||
width = 32 * 32,
|
||||
filled = true,
|
||||
|
@ -1113,7 +1113,8 @@ if settings.startup["rampant-trollEnemy"].value then
|
||||
name = "biter",
|
||||
minorResistances = {"physical", "explosion"},
|
||||
majorWeaknesses = {"fire"},
|
||||
attributes = {"highestHealth", "longReach", "bigger", "highestRegen", "slowMovement", "altBiterArmored"},
|
||||
attributes = {"highestHealth", "longReach", "bigger",
|
||||
"highestRegen", "slowMovement", "altBiterArmored"},
|
||||
drops = {"greenArtifact"}
|
||||
}
|
||||
},
|
||||
@ -1226,7 +1227,7 @@ if settings.startup["rampant-suicideEnemy"].value then
|
||||
type = "suicide",
|
||||
tint = {r=0.8, g=0.8, b=0.8, a=1},
|
||||
tint2 = {r=0.95, g=0.95, b=0, a=1},
|
||||
acceptRate = {1, 10, 0.05, 0.15},
|
||||
acceptRate = {3, 10, 0.05, 0.15},
|
||||
evo = 0.35,
|
||||
units = {
|
||||
{
|
||||
@ -1285,7 +1286,7 @@ if settings.startup["rampant-nuclearEnemy"].value then
|
||||
type = "nuclear",
|
||||
tint = {r=0.6, g=0.6, b=0.4, a=1},
|
||||
tint2 = {r=0.95, g=0.95, b=0, a=1},
|
||||
acceptRate = {3, 10, 0.1, 0.125},
|
||||
acceptRate = {4, 10, 0.1, 0.125},
|
||||
evo = 0.45,
|
||||
units = {
|
||||
{
|
||||
@ -1496,7 +1497,7 @@ for x=1,9 do
|
||||
elseif x > 5 and y < 5 then
|
||||
v = math.min((10-x), y)
|
||||
elseif x < 5 and y > 5 then
|
||||
v = math.min(x, (10-y))
|
||||
v = math.min(x, (10-y))
|
||||
else
|
||||
v = math.min((10-x), (10-y))
|
||||
end
|
||||
|
@ -3,8 +3,6 @@ if interopG then
|
||||
end
|
||||
local interop = {}
|
||||
|
||||
local unitGroupUtils = require("UnitGroupUtils")
|
||||
|
||||
function interop.addAIPoints(value)
|
||||
global.natives.points = global.natives.points + value
|
||||
end
|
||||
|
@ -5,7 +5,6 @@ local mapProcessor = {}
|
||||
|
||||
-- imports
|
||||
|
||||
local unitGroupUtils = require("UnitGroupUtils")
|
||||
local pheromoneUtils = require("PheromoneUtils")
|
||||
local aiAttackWave = require("AIAttackWave")
|
||||
local aiPredicates = require("AIPredicates")
|
||||
@ -26,38 +25,31 @@ local RESOURCE_QUEUE_SIZE = constants.RESOURCE_QUEUE_SIZE
|
||||
local ENEMY_QUEUE_SIZE = constants.ENEMY_QUEUE_SIZE
|
||||
local PLAYER_QUEUE_SIZE = constants.PLAYER_QUEUE_SIZE
|
||||
|
||||
local SCAN_QUEUE_SIZE = constants.SCAN_QUEUE_SIZE
|
||||
local CLEANUP_QUEUE_SIZE = constants.CLEANUP_QUEUE_SIZE
|
||||
|
||||
local CHUNK_SIZE = constants.CHUNK_SIZE
|
||||
local TRIPLE_CHUNK_SIZE = constants.TRIPLE_CHUNK_SIZE
|
||||
|
||||
local PROCESS_PLAYER_BOUND = constants.PROCESS_PLAYER_BOUND
|
||||
local CHUNK_TICK = constants.CHUNK_TICK
|
||||
|
||||
local PROCESS_STATIC_QUEUE_SIZE = constants.PROCESS_STATIC_QUEUE_SIZE
|
||||
|
||||
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 AI_STATE_AGGRESSIVE = constants.AI_STATE_AGGRESSIVE
|
||||
|
||||
local PLAYER_PHEROMONE = constants.PLAYER_PHEROMONE
|
||||
local BASE_PHEROMONE = constants.BASE_PHEROMONE
|
||||
local AI_STATE_PEACEFUL = constants.AI_STATE_PEACEFUL
|
||||
local AI_STATE_MIGRATING = constants.AI_STATE_MIGRATING
|
||||
local AI_STATE_SIEGE = constants.AI_STATE_SIEGE
|
||||
|
||||
local COOLDOWN_RALLY = constants.COOLDOWN_RALLY
|
||||
local COOLDOWN_RETREAT = constants.COOLDOWN_RETREAT
|
||||
|
||||
local BASE_PROCESS_INTERVAL = constants.BASE_PROCESS_INTERVAL
|
||||
|
||||
local AI_MAX_SQUADS_PER_CYCLE = constants.AI_MAX_SQUADS_PER_CYCLE
|
||||
|
||||
-- imported functions
|
||||
|
||||
local processStaticPheromone = pheromoneUtils.processStaticPheromone
|
||||
local processPheromone = pheromoneUtils.processPheromone
|
||||
local commitPheromone = pheromoneUtils.commitPheromone
|
||||
local playerScent = pheromoneUtils.playerScent
|
||||
|
||||
local getDeathGenerator = chunkPropertyUtils.getDeathGenerator
|
||||
local processBase = baseUtils.processBase
|
||||
@ -71,12 +63,8 @@ local formSettlers = aiAttackWave.formSettlers
|
||||
local getChunkByPosition = mapUtils.getChunkByPosition
|
||||
local getChunkByXY = mapUtils.getChunkByXY
|
||||
|
||||
local recycleBiters = unitGroupUtils.recycleBiters
|
||||
|
||||
local validPlayer = playerUtils.validPlayer
|
||||
|
||||
local createSpawnerProxy = baseUtils.createSpawnerProxy
|
||||
|
||||
local addPlayerToChunk = chunkPropertyUtils.addPlayerToChunk
|
||||
|
||||
local mapScanEnemyChunk = chunkUtils.mapScanEnemyChunk
|
||||
@ -90,13 +78,11 @@ local getNestActiveTick = chunkPropertyUtils.getNestActiveTick
|
||||
local setNestActiveTick = chunkPropertyUtils.setNestActiveTick
|
||||
|
||||
local getRaidNestActiveness = chunkPropertyUtils.getRaidNestActiveness
|
||||
local setRaidNestActiveness = chunkPropertyUtils.setRaidNestActiveness
|
||||
|
||||
|
||||
local canAttack = aiPredicates.canAttack
|
||||
local canMigrate = aiPredicates.canMigrate
|
||||
|
||||
local findNearbySquad = unitGroupUtils.findNearbySquad
|
||||
local tableSize = table_size
|
||||
|
||||
local mMin = math.min
|
||||
local mMax = math.max
|
||||
@ -113,7 +99,7 @@ local mRandom = math.random
|
||||
In theory, this might be fine as smaller bases have less surface to attack and need to have
|
||||
pheromone dissipate at a faster rate.
|
||||
--]]
|
||||
function mapProcessor.processMap(map, surface, tick)
|
||||
function mapProcessor.processMap(map, tick)
|
||||
local index = map.processIndex
|
||||
|
||||
local outgoingWave = map.outgoingScanWave
|
||||
@ -133,7 +119,7 @@ function mapProcessor.processMap(map, surface, tick)
|
||||
if (processQueueLength == 0) then
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
for x=index,endIndex,step do
|
||||
local chunk = processQueue[x]
|
||||
if chunk and (chunk[CHUNK_TICK] ~= tick) then
|
||||
@ -153,7 +139,7 @@ function mapProcessor.processMap(map, surface, tick)
|
||||
end
|
||||
end
|
||||
|
||||
function mapProcessor.processStaticMap(map, surface, tick)
|
||||
function mapProcessor.processStaticMap(map)
|
||||
local index = map.processStaticIndex
|
||||
|
||||
local outgoingWave = map.outgoingStaticScanWave
|
||||
@ -173,7 +159,7 @@ function mapProcessor.processStaticMap(map, surface, tick)
|
||||
if (processQueueLength == 0) then
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
for x=index,endIndex,step do
|
||||
local chunk = processQueue[x]
|
||||
processStaticPheromone(map, chunk)
|
||||
@ -191,7 +177,8 @@ function mapProcessor.processStaticMap(map, surface, tick)
|
||||
end
|
||||
|
||||
local function queueNestSpawners(map, chunk, tick)
|
||||
local limitPerActiveChunkTick = (map.natives.activeNests + map.natives.activeRaidNests) * DURATION_ACTIVE_NEST_DIVIDER
|
||||
local limitPerActiveChunkTick =
|
||||
(map.natives.activeNests + map.natives.activeRaidNests) * DURATION_ACTIVE_NEST_DIVIDER
|
||||
|
||||
local processActiveNest = map.processActiveNest
|
||||
|
||||
@ -238,12 +225,8 @@ function mapProcessor.processPlayers(players, map, surface, tick)
|
||||
-- randomize player order to ensure a single player isn't singled out
|
||||
local natives = map.natives
|
||||
|
||||
local roll = mRandom()
|
||||
|
||||
local allowingAttacks = canAttack(natives, surface, tick)
|
||||
|
||||
local scentStaging = map.scentStaging
|
||||
|
||||
-- not looping everyone because the cost is high enough already in multiplayer
|
||||
if (#players > 0) then
|
||||
local player = players[mRandom(#players)]
|
||||
@ -341,7 +324,9 @@ end
|
||||
Passive scan to find entities that have been generated outside the factorio event system
|
||||
--]]
|
||||
function mapProcessor.scanPlayerMap(map, surface, tick)
|
||||
if (map.nextProcessMap == tick) or (map.nextPlayerScan == tick) or (map.nextEnemyScan == tick) or (map.nextChunkProcess == tick) then
|
||||
if (map.nextProcessMap == tick) or (map.nextPlayerScan == tick) or
|
||||
(map.nextEnemyScan == tick) or (map.nextChunkProcess == tick)
|
||||
then
|
||||
return
|
||||
end
|
||||
local index = map.scanPlayerIndex
|
||||
@ -350,7 +335,7 @@ function mapProcessor.scanPlayerMap(map, surface, tick)
|
||||
local chunkBox = map.area[1]
|
||||
local processQueue = map.processQueue
|
||||
local processQueueLength = #processQueue
|
||||
|
||||
|
||||
local endIndex = mMin(index + PLAYER_QUEUE_SIZE, processQueueLength)
|
||||
|
||||
if (processQueueLength == 0) then
|
||||
@ -387,13 +372,13 @@ function mapProcessor.scanEnemyMap(map, surface, tick)
|
||||
local chunkBox = map.area[1]
|
||||
local processQueue = map.processQueue
|
||||
local processQueueLength = #processQueue
|
||||
|
||||
|
||||
local endIndex = mMin(index + ENEMY_QUEUE_SIZE, #processQueue)
|
||||
|
||||
if (processQueueLength == 0) then
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
for x=index,endIndex do
|
||||
local chunk = processQueue[x]
|
||||
|
||||
@ -414,22 +399,24 @@ function mapProcessor.scanEnemyMap(map, surface, tick)
|
||||
end
|
||||
|
||||
function mapProcessor.scanResourceMap(map, surface, tick)
|
||||
if (map.nextProcessMap == tick) or (map.nextPlayerScan == tick) or (map.nextEnemyScan == tick) or (map.nextChunkProcess == tick) then
|
||||
if (map.nextProcessMap == tick) or (map.nextPlayerScan == tick) or
|
||||
(map.nextEnemyScan == tick) or (map.nextChunkProcess == tick)
|
||||
then
|
||||
return
|
||||
end
|
||||
local index = map.scanResourceIndex
|
||||
|
||||
local offset = map.area[2]
|
||||
local chunkBox = map.area[1]
|
||||
local processQueue = map.processQueue
|
||||
local processQueue = map.processQueue
|
||||
local processQueueLength = #processQueue
|
||||
|
||||
|
||||
local endIndex = mMin(index + RESOURCE_QUEUE_SIZE, processQueueLength)
|
||||
|
||||
if (processQueueLength == 0) then
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
for x=index,endIndex do
|
||||
local chunk = processQueue[x]
|
||||
|
||||
@ -473,19 +460,19 @@ function mapProcessor.processActiveNests(map, surface, tick)
|
||||
end
|
||||
end
|
||||
|
||||
function mapProcessor.processVengence(map, surface, tick)
|
||||
function mapProcessor.processVengence(map, surface)
|
||||
local natives = map.natives
|
||||
local ss = natives.vengenceQueue
|
||||
local chunk, count = next(ss, map.deployVengenceIterator)
|
||||
local chunk = next(ss, map.deployVengenceIterator)
|
||||
if not chunk then
|
||||
map.deployVengenceIterator = nil
|
||||
if (table_size(ss) == 0) then
|
||||
if (tableSize(ss) == 0) then
|
||||
natives.vengenceQueue = {}
|
||||
end
|
||||
else
|
||||
formVengenceSquad(map, surface, chunk)
|
||||
local nextChunk
|
||||
nextChunk, count = next(ss, chunk)
|
||||
nextChunk = next(ss, chunk)
|
||||
ss[chunk] = nil
|
||||
chunk = nextChunk
|
||||
end
|
||||
@ -496,8 +483,8 @@ function mapProcessor.processNests(map, surface, tick)
|
||||
local natives = map.natives
|
||||
local bases = map.chunkToBase
|
||||
local chunks = map.chunkToNests
|
||||
local chunk, count = next(chunks, map.processNestIterator)
|
||||
for i=1,5 do
|
||||
local chunk = next(chunks, map.processNestIterator)
|
||||
for _=1,5 do
|
||||
if not chunk then
|
||||
map.processNestIterator = nil
|
||||
return
|
||||
@ -512,7 +499,7 @@ function mapProcessor.processNests(map, surface, tick)
|
||||
end
|
||||
end
|
||||
|
||||
chunk, count = next(chunks, chunk)
|
||||
chunk = next(chunks, chunk)
|
||||
end
|
||||
end
|
||||
map.processNestIterator = chunk
|
||||
@ -520,27 +507,26 @@ end
|
||||
|
||||
local function processSpawners(map, surface, tick, natives, iteration, iterator, chunks)
|
||||
|
||||
local chunk, count = next(chunks, map[iterator])
|
||||
local chunk = next(chunks, map[iterator])
|
||||
local migrate = canMigrate(natives, surface)
|
||||
local attack = canAttack(natives, surface, tick)
|
||||
for i=1,iteration do
|
||||
for _=1,iteration do
|
||||
if not chunk then
|
||||
map[iterator] = nil
|
||||
return
|
||||
else
|
||||
if migrate then
|
||||
formSettlers(map, surface, chunk, tick)
|
||||
formSettlers(map, surface, chunk)
|
||||
elseif attack then
|
||||
formSquads(map, surface, chunk, tick)
|
||||
end
|
||||
chunk, count = next(chunks, chunk)
|
||||
chunk = next(chunks, chunk)
|
||||
end
|
||||
end
|
||||
map[iterator] = chunk
|
||||
end
|
||||
|
||||
function mapProcessor.processSpawners(map, surface, tick)
|
||||
local chunks
|
||||
local natives = map.natives
|
||||
|
||||
if (natives.state ~= AI_STATE_PEACEFUL) then
|
||||
@ -551,7 +537,13 @@ function mapProcessor.processSpawners(map, surface, tick)
|
||||
else
|
||||
if (natives.state ~= AI_STATE_AGGRESSIVE) then
|
||||
processSpawners(map, surface, tick, natives, 1, "processActiveSpawnerIterator", map.chunkToActiveNest)
|
||||
processSpawners(map, surface, tick, natives, 1, "processActiveRaidSpawnerIterator", map.chunkToActiveRaidNest)
|
||||
processSpawners(map,
|
||||
surface,
|
||||
tick,
|
||||
natives,
|
||||
1,
|
||||
"processActiveRaidSpawnerIterator",
|
||||
map.chunkToActiveRaidNest)
|
||||
else
|
||||
processSpawners(map, surface, tick, natives, 2, "processActiveSpawnerIterator", map.chunkToActiveNest)
|
||||
end
|
||||
|
@ -221,7 +221,7 @@ function mapUtils.positionFromDirectionAndFlat(direction, startPosition, endPosi
|
||||
ly = ly + CHUNK_SIZE
|
||||
elseif (direction == 8) then
|
||||
lx = lx + CHUNK_SIZE
|
||||
ly = ly + CHUNK_SIZE
|
||||
ly = ly + CHUNK_SIZE
|
||||
end
|
||||
endPosition.x = lx
|
||||
endPosition.y = ly
|
||||
|
@ -38,15 +38,15 @@ function mathUtils.randomTickEvent(tick, low, high)
|
||||
end
|
||||
|
||||
function mathUtils.distort(xorRandom, num, stdDev, min, max)
|
||||
local min = min or num * 0.70
|
||||
local max = max or num * 1.30
|
||||
local amin = min or num * 0.70
|
||||
local amax = max or num * 1.30
|
||||
local sd = stdDev or 0.17
|
||||
if (num < 0) then
|
||||
local t = min
|
||||
min = max
|
||||
max = t
|
||||
amin = max
|
||||
amax = t
|
||||
end
|
||||
return mathUtils.roundToNearest(mathUtils.gaussianRandomRangeRG(num, num * sd, min, max, xorRandom), 0.01)
|
||||
return mathUtils.roundToNearest(mathUtils.gaussianRandomRangeRG(num, num * sd, amin, amax, xorRandom), 0.01)
|
||||
end
|
||||
|
||||
function mathUtils.linearInterpolation(percent, min, max)
|
||||
|
@ -8,7 +8,6 @@ local movementUtils = {}
|
||||
local constants = require("Constants")
|
||||
local mapUtils = require("MapUtils")
|
||||
local mathUtils = require("MathUtils")
|
||||
local chunkPropertyUtils = require("ChunkPropertyUtils")
|
||||
|
||||
-- constants
|
||||
|
||||
@ -44,7 +43,7 @@ function movementUtils.findMovementPositionDistort(surface, position)
|
||||
return distortPosition(pos, 8)
|
||||
end
|
||||
|
||||
function movementUtils.addMovementPenalty(map, squad, chunk)
|
||||
function movementUtils.addMovementPenalty(squad, chunk)
|
||||
if (chunk == -1) then
|
||||
return
|
||||
end
|
||||
@ -55,8 +54,6 @@ function movementUtils.addMovementPenalty(map, squad, chunk)
|
||||
if (penalty.c == chunk) then
|
||||
penalty.v = ((penaltyCount > 1) and penalty.v + 1) or penalty.v
|
||||
if (penalty.v > 2) then
|
||||
-- print("movementThreshold", #penalties, squad.group.group_number, penalty.v, squad.settlers, squad.kamikaze, squad.status)
|
||||
-- game.players[1].teleport(chunk, game.surfaces[1])
|
||||
squad.kamikaze = true
|
||||
end
|
||||
return
|
||||
@ -74,7 +71,7 @@ end
|
||||
--[[
|
||||
Expects all neighbors adjacent to a chunk
|
||||
--]]
|
||||
function movementUtils.scoreNeighborsForAttack(map, chunk, neighborDirectionChunks, scoreFunction, squad)
|
||||
function movementUtils.scoreNeighborsForAttack(map, chunk, neighborDirectionChunks, scoreFunction)
|
||||
local highestChunk = -1
|
||||
local highestScore = -MAGIC_MAXIMUM_NUMBER
|
||||
local highestDirection
|
||||
@ -83,7 +80,7 @@ function movementUtils.scoreNeighborsForAttack(map, chunk, neighborDirectionChun
|
||||
local neighborChunk = neighborDirectionChunks[x]
|
||||
if (neighborChunk ~= -1) then
|
||||
if canMoveChunkDirection(map, x, chunk, neighborChunk) or (chunk == -1) then
|
||||
local score = scoreFunction(map, squad, neighborChunk)
|
||||
local score = scoreFunction(map, neighborChunk)
|
||||
if (score > highestScore) then
|
||||
highestScore = score
|
||||
highestChunk = neighborChunk
|
||||
@ -103,7 +100,7 @@ function movementUtils.scoreNeighborsForAttack(map, chunk, neighborDirectionChun
|
||||
local neighborChunk = neighborDirectionChunks[x]
|
||||
if ((neighborChunk ~= -1) and (neighborChunk ~= chunk) and
|
||||
canMoveChunkDirection(map, x, highestChunk, neighborChunk)) then
|
||||
local score = scoreFunction(map, squad, neighborChunk)
|
||||
local score = scoreFunction(map, neighborChunk)
|
||||
if (score > nextHighestScore) then
|
||||
nextHighestScore = score
|
||||
nextHighestChunk = neighborChunk
|
||||
@ -120,7 +117,7 @@ end
|
||||
--[[
|
||||
Expects all neighbors adjacent to a chunk
|
||||
--]]
|
||||
function movementUtils.scoreNeighborsForSettling(map, chunk, neighborDirectionChunks, scoreFunction, squad)
|
||||
function movementUtils.scoreNeighborsForSettling(map, chunk, neighborDirectionChunks, scoreFunction)
|
||||
local highestChunk = -1
|
||||
local highestScore = -MAGIC_MAXIMUM_NUMBER
|
||||
local highestDirection = 0
|
||||
@ -129,7 +126,7 @@ function movementUtils.scoreNeighborsForSettling(map, chunk, neighborDirectionCh
|
||||
local neighborChunk = neighborDirectionChunks[x]
|
||||
if (neighborChunk ~= -1) then
|
||||
if canMoveChunkDirection(map, x, chunk, neighborChunk) or (chunk == -1) then
|
||||
local score = scoreFunction(map, squad, neighborChunk)
|
||||
local score = scoreFunction(map, neighborChunk)
|
||||
if (score > highestScore) then
|
||||
highestScore = score
|
||||
highestChunk = neighborChunk
|
||||
@ -139,7 +136,7 @@ function movementUtils.scoreNeighborsForSettling(map, chunk, neighborDirectionCh
|
||||
end
|
||||
end
|
||||
|
||||
if (chunk ~= -1) and (scoreFunction(map, squad, chunk) > highestScore) then
|
||||
if (chunk ~= -1) and (scoreFunction(map, chunk) > highestScore) then
|
||||
return chunk, 0, -1, 0
|
||||
end
|
||||
|
||||
@ -153,7 +150,7 @@ function movementUtils.scoreNeighborsForSettling(map, chunk, neighborDirectionCh
|
||||
local neighborChunk = neighborDirectionChunks[x]
|
||||
if ((neighborChunk ~= -1) and (neighborChunk ~= chunk) and
|
||||
canMoveChunkDirection(map, x, highestChunk, neighborChunk)) then
|
||||
local score = scoreFunction(map, squad, neighborChunk)
|
||||
local score = scoreFunction(map, neighborChunk)
|
||||
if (score > nextHighestScore) then
|
||||
nextHighestScore = score
|
||||
nextHighestChunk = neighborChunk
|
||||
@ -175,7 +172,10 @@ function movementUtils.scoreNeighborsForResource(chunk, neighborDirectionChunks,
|
||||
local highestDirection
|
||||
for x=1,8 do
|
||||
local neighborChunk = neighborDirectionChunks[x]
|
||||
if (neighborChunk ~= -1) and canMoveChunkDirection(map, x, chunk, neighborChunk) and validFunction(map, chunk, neighborChunk) then
|
||||
if (neighborChunk ~= -1) and
|
||||
canMoveChunkDirection(map, x, chunk, neighborChunk) and
|
||||
validFunction(map, chunk, neighborChunk)
|
||||
then
|
||||
local score = scoreFunction(map, neighborChunk)
|
||||
if (score > highestScore) then
|
||||
highestScore = score
|
||||
|
@ -16,9 +16,6 @@ local VICTORY_SCENT_BOUND = constants.VICTORY_SCENT_BOUND
|
||||
|
||||
local MAGIC_MAXIMUM_NUMBER = constants.MAGIC_MAXIMUM_NUMBER
|
||||
|
||||
local CHUNK_TICK = constants.CHUNK_TICK
|
||||
local NEIGHBOR_DIVIDER = constants.NEIGHBOR_DIVIDER
|
||||
|
||||
local CHUNK_ALL_DIRECTIONS = constants.CHUNK_ALL_DIRECTIONS
|
||||
local CHUNK_NORTH_SOUTH = constants.CHUNK_NORTH_SOUTH
|
||||
local CHUNK_EAST_WEST = constants.CHUNK_EAST_WEST
|
||||
@ -27,14 +24,10 @@ local BASE_PHEROMONE = constants.BASE_PHEROMONE
|
||||
local PLAYER_PHEROMONE = constants.PLAYER_PHEROMONE
|
||||
local RESOURCE_PHEROMONE = constants.RESOURCE_PHEROMONE
|
||||
|
||||
local BUILDING_PHEROMONES = constants.BUILDING_PHEROMONES
|
||||
local VICTORY_SCENT = constants.VICTORY_SCENT
|
||||
|
||||
local PLAYER_PHEROMONE_GENERATOR_AMOUNT = constants.PLAYER_PHEROMONE_GENERATOR_AMOUNT
|
||||
|
||||
local PLAYER_PHEROMONE_PERSISTANCE = constants.PLAYER_PHEROMONE_PERSISTANCE
|
||||
local RESOURCE_PHEROMONE_PERSISTANCE = constants.RESOURCE_PHEROMONE_PERSISTANCE
|
||||
|
||||
local DEATH_PHEROMONE_GENERATOR_AMOUNT = constants.DEATH_PHEROMONE_GENERATOR_AMOUNT
|
||||
|
||||
-- imported functions
|
||||
@ -50,7 +43,6 @@ local getPathRating = chunkPropertyUtils.getPathRating
|
||||
local getPassable = chunkPropertyUtils.getPassable
|
||||
local getPlayerBaseGenerator = chunkPropertyUtils.getPlayerBaseGenerator
|
||||
local getResourceGenerator = chunkPropertyUtils.getResourceGenerator
|
||||
local getDeathGenerator = chunkPropertyUtils.getDeathGenerator
|
||||
local addDeathGenerator = chunkPropertyUtils.addDeathGenerator
|
||||
|
||||
local decayDeathGenerator = chunkPropertyUtils.decayDeathGenerator
|
||||
@ -59,8 +51,6 @@ local linearInterpolation = mathUtils.linearInterpolation
|
||||
|
||||
local getChunkByXY = mapUtils.getChunkByXY
|
||||
|
||||
local mAbs = math.abs
|
||||
|
||||
local next = next
|
||||
|
||||
-- module code
|
||||
@ -302,7 +292,7 @@ function pheromoneUtils.processStaticPheromone(map, chunk)
|
||||
end
|
||||
|
||||
chunkBase = chunkBase * 0.9
|
||||
local pheromone = getPlayerBaseGenerator(map, chunk)
|
||||
pheromone = getPlayerBaseGenerator(map, chunk)
|
||||
if chunkBase < pheromone then
|
||||
chunk[BASE_PHEROMONE] = pheromone * chunkPathRating
|
||||
else
|
||||
@ -310,7 +300,7 @@ function pheromoneUtils.processStaticPheromone(map, chunk)
|
||||
end
|
||||
|
||||
chunkResource = chunkResource * 0.9
|
||||
local pheromone = getResourceGenerator(map, chunk)
|
||||
pheromone = getResourceGenerator(map, chunk)
|
||||
if (pheromone > 0) and clear then
|
||||
pheromone = linearInterpolation(pheromone, 15000, 20000)
|
||||
end
|
||||
@ -481,7 +471,7 @@ function pheromoneUtils.processPheromone(map, chunk, player)
|
||||
end
|
||||
|
||||
chunkPlayer = chunkPlayer * 0.45
|
||||
local pheromone = getPlayersOnChunk(map, chunk) * PLAYER_PHEROMONE_GENERATOR_AMOUNT
|
||||
pheromone = getPlayersOnChunk(map, chunk) * PLAYER_PHEROMONE_GENERATOR_AMOUNT
|
||||
if chunkPlayer < pheromone then
|
||||
chunk[PLAYER_PHEROMONE] = pheromone * chunkPathRating
|
||||
else
|
||||
|
@ -7,11 +7,9 @@ local squadAttack = {}
|
||||
|
||||
local constants = require("Constants")
|
||||
local mapUtils = require("MapUtils")
|
||||
local unitGroupUtils = require("UnitGroupUtils")
|
||||
local movementUtils = require("MovementUtils")
|
||||
local mathUtils = require("MathUtils")
|
||||
local chunkPropertyUtils = require("ChunkPropertyUtils")
|
||||
local chunkUtils = require("ChunkUtils")
|
||||
|
||||
-- constants
|
||||
|
||||
@ -21,12 +19,6 @@ local RESOURCE_PHEROMONE = constants.RESOURCE_PHEROMONE
|
||||
|
||||
local TEN_DEATH_PHEROMONE_GENERATOR_AMOUNT = constants.TEN_DEATH_PHEROMONE_GENERATOR_AMOUNT
|
||||
|
||||
local ATTACK_SCORE_KAMIKAZE = constants.ATTACK_SCORE_KAMIKAZE
|
||||
|
||||
local DIVISOR_DEATH_TRAIL_TABLE = constants.DIVISOR_DEATH_TRAIL_TABLE
|
||||
|
||||
local BASE_CLEAN_DISTANCE = constants.BASE_CLEAN_DISTANCE
|
||||
|
||||
local SQUAD_BUILDING = constants.SQUAD_BUILDING
|
||||
|
||||
local SQUAD_RAIDING = constants.SQUAD_RAIDING
|
||||
@ -34,28 +26,16 @@ local SQUAD_SETTLING = constants.SQUAD_SETTLING
|
||||
local SQUAD_GUARDING = constants.SQUAD_GUARDING
|
||||
local SQUAD_RETREATING = constants.SQUAD_RETREATING
|
||||
|
||||
local AI_MAX_BITER_GROUP_SIZE = constants.AI_MAX_BITER_GROUP_SIZE
|
||||
|
||||
local ATTACK_QUEUE_SIZE = constants.ATTACK_QUEUE_SIZE
|
||||
|
||||
local AI_STATE_SIEGE = constants.AI_STATE_SIEGE
|
||||
|
||||
local PLAYER_PHEROMONE_MULTIPLER = constants.PLAYER_PHEROMONE_MULTIPLER
|
||||
|
||||
local DEFINES_GROUP_FINISHED = defines.group_state.finished
|
||||
local DEFINES_GROUP_GATHERING = defines.group_state.gathering
|
||||
local DEFINES_GROUP_MOVING = defines.group_state.moving
|
||||
local DEFINES_DISTRACTION_NONE = defines.distraction.none
|
||||
local DEFINES_DISTRACTION_BY_ENEMY = defines.distraction.by_enemy
|
||||
local DEFINES_DISTRACTION_BY_ANYTHING = defines.distraction.by_anything
|
||||
|
||||
-- imported functions
|
||||
|
||||
local mRandom = math.random
|
||||
local mMin = math.min
|
||||
local tRemove = table.remove
|
||||
|
||||
|
||||
local euclideanDistancePoints = mathUtils.euclideanDistancePoints
|
||||
|
||||
local findMovementPosition = movementUtils.findMovementPosition
|
||||
@ -71,9 +51,6 @@ local addSquadToChunk = chunkPropertyUtils.addSquadToChunk
|
||||
local getChunkByXY = mapUtils.getChunkByXY
|
||||
local positionToChunkXY = mapUtils.positionToChunkXY
|
||||
local addMovementPenalty = movementUtils.addMovementPenalty
|
||||
local lookupMovementPenalty = movementUtils.lookupMovementPenalty
|
||||
local calculateKamikazeThreshold = unitGroupUtils.calculateKamikazeThreshold
|
||||
local positionFromDirectionAndChunk = mapUtils.positionFromDirectionAndChunk
|
||||
local positionFromDirectionAndFlat = mapUtils.positionFromDirectionAndFlat
|
||||
|
||||
local euclideanDistanceNamed = mathUtils.euclideanDistanceNamed
|
||||
@ -81,49 +58,46 @@ local euclideanDistanceNamed = mathUtils.euclideanDistanceNamed
|
||||
local getPlayerBaseGenerator = chunkPropertyUtils.getPlayerBaseGenerator
|
||||
local getResourceGenerator = chunkPropertyUtils.getResourceGenerator
|
||||
|
||||
local getChunkByPosition = mapUtils.getChunkByPosition
|
||||
|
||||
local scoreNeighborsForAttack = movementUtils.scoreNeighborsForAttack
|
||||
local scoreNeighborsForSettling = movementUtils.scoreNeighborsForSettling
|
||||
|
||||
-- module code
|
||||
|
||||
local function scoreResourceLocationKamikaze(map, squad, neighborChunk)
|
||||
local function scoreResourceLocationKamikaze(_, neighborChunk)
|
||||
local settle = neighborChunk[RESOURCE_PHEROMONE]
|
||||
return settle - (neighborChunk[PLAYER_PHEROMONE] * PLAYER_PHEROMONE_MULTIPLER)
|
||||
end
|
||||
|
||||
local function scoreSiegeLocationKamikaze(map, squad, neighborChunk)
|
||||
local function scoreSiegeLocationKamikaze(_, neighborChunk)
|
||||
local settle = neighborChunk[BASE_PHEROMONE] +
|
||||
neighborChunk[RESOURCE_PHEROMONE] + (neighborChunk[PLAYER_PHEROMONE] * PLAYER_PHEROMONE_MULTIPLER)
|
||||
|
||||
return settle
|
||||
end
|
||||
|
||||
local function scoreResourceLocation(map, squad, neighborChunk)
|
||||
local function scoreResourceLocation(map, neighborChunk)
|
||||
local settle = -getDeathGenerator(map, neighborChunk) + neighborChunk[RESOURCE_PHEROMONE]
|
||||
return settle - (neighborChunk[PLAYER_PHEROMONE] * PLAYER_PHEROMONE_MULTIPLER)
|
||||
end
|
||||
|
||||
local function scoreSiegeLocation(map, squad, neighborChunk)
|
||||
local function scoreSiegeLocation(map, neighborChunk)
|
||||
local settle = -getDeathGenerator(map, neighborChunk) + neighborChunk[BASE_PHEROMONE] +
|
||||
neighborChunk[RESOURCE_PHEROMONE] + (neighborChunk[PLAYER_PHEROMONE] * PLAYER_PHEROMONE_MULTIPLER)
|
||||
|
||||
return settle
|
||||
end
|
||||
|
||||
local function scoreAttackLocation(map, squad, neighborChunk)
|
||||
local function scoreAttackLocation(map, neighborChunk)
|
||||
local damage = -getDeathGenerator(map, neighborChunk) + neighborChunk[BASE_PHEROMONE] +
|
||||
(neighborChunk[PLAYER_PHEROMONE] * PLAYER_PHEROMONE_MULTIPLER)
|
||||
return damage
|
||||
end
|
||||
|
||||
local function scoreAttackKamikazeLocation(natives, squad, neighborChunk)
|
||||
local function scoreAttackKamikazeLocation(_, neighborChunk)
|
||||
local damage = neighborChunk[BASE_PHEROMONE] + (neighborChunk[PLAYER_PHEROMONE] * PLAYER_PHEROMONE_MULTIPLER)
|
||||
return damage
|
||||
end
|
||||
|
||||
|
||||
local function settleMove(map, squad, surface)
|
||||
local targetPosition = map.position
|
||||
local targetPosition2 = map.position2
|
||||
@ -133,7 +107,6 @@ local function settleMove(map, squad, surface)
|
||||
local x, y = positionToChunkXY(groupPosition)
|
||||
local chunk = getChunkByXY(map, x, y)
|
||||
local scoreFunction = scoreResourceLocation
|
||||
local groupState = group.state
|
||||
local natives = map.natives
|
||||
if (natives.state == AI_STATE_SIEGE) then
|
||||
if squad.kamikaze then
|
||||
@ -146,14 +119,13 @@ local function settleMove(map, squad, surface)
|
||||
end
|
||||
addDeathGenerator(map, chunk, TEN_DEATH_PHEROMONE_GENERATOR_AMOUNT)
|
||||
addSquadToChunk(map, chunk, squad)
|
||||
addMovementPenalty(map, squad, chunk)
|
||||
addMovementPenalty(squad, chunk)
|
||||
local distance = euclideanDistancePoints(groupPosition.x,
|
||||
groupPosition.y,
|
||||
squad.originPosition.x,
|
||||
squad.originPosition.y)
|
||||
local cmd
|
||||
local position
|
||||
local position2
|
||||
|
||||
if (distance >= squad.maxDistance) or ((getResourceGenerator(map, chunk) ~= 0) and (getNestCount(map, chunk) == 0))
|
||||
then
|
||||
@ -175,21 +147,15 @@ local function settleMove(map, squad, surface)
|
||||
|
||||
squad.status = SQUAD_BUILDING
|
||||
|
||||
-- remove in 1.1
|
||||
if (#group.members == 0) then
|
||||
-- print("killing")
|
||||
group.destroy()
|
||||
return
|
||||
end
|
||||
|
||||
group.set_command(cmd)
|
||||
else
|
||||
local attackChunk, attackDirection, nextAttackChunk, nextAttackDirection = scoreNeighborsForSettling(map,
|
||||
chunk,
|
||||
getNeighborChunks(map, x, y),
|
||||
scoreFunction,
|
||||
squad)
|
||||
|
||||
local attackChunk,
|
||||
attackDirection,
|
||||
nextAttackChunk,
|
||||
nextAttackDirection = scoreNeighborsForSettling(map,
|
||||
chunk,
|
||||
getNeighborChunks(map, x, y),
|
||||
scoreFunction)
|
||||
|
||||
if (attackChunk == -1) then
|
||||
cmd = map.wonderCommand
|
||||
@ -251,13 +217,6 @@ local function settleMove(map, squad, surface)
|
||||
cmd.distraction = DEFINES_DISTRACTION_BY_ENEMY
|
||||
end
|
||||
|
||||
-- remove in 1.1
|
||||
if (#group.members == 0) then
|
||||
-- print("killing")
|
||||
group.destroy()
|
||||
return
|
||||
end
|
||||
|
||||
squad.status = SQUAD_BUILDING
|
||||
end
|
||||
|
||||
@ -283,13 +242,14 @@ local function attackMove(map, squad, surface)
|
||||
local squadChunk = squad.chunk
|
||||
addDeathGenerator(map, squadChunk, TEN_DEATH_PHEROMONE_GENERATOR_AMOUNT)
|
||||
addSquadToChunk(map, chunk, squad)
|
||||
addMovementPenalty(map, squad, chunk)
|
||||
addMovementPenalty(squad, chunk)
|
||||
squad.frenzy = (squad.frenzy and (euclideanDistanceNamed(groupPosition, squad.frenzyPosition) < 100))
|
||||
local attackChunk, attackDirection, nextAttackChunk, nextAttackDirection = scoreNeighborsForAttack(map,
|
||||
chunk,
|
||||
getNeighborChunks(map, x, y),
|
||||
attackScorer,
|
||||
squad)
|
||||
local attackChunk, attackDirection,
|
||||
nextAttackChunk, nextAttackDirection = scoreNeighborsForAttack(map,
|
||||
chunk,
|
||||
getNeighborChunks(map, x, y),
|
||||
attackScorer)
|
||||
local cmd
|
||||
if (attackChunk == -1) then
|
||||
cmd = map.wonderCommand
|
||||
group.set_command(cmd)
|
||||
@ -379,7 +339,7 @@ function squadAttack.cleanSquads(natives, iterator)
|
||||
natives.squadCount = natives.squadCount - 1
|
||||
end
|
||||
local nextK
|
||||
nextK,squad = next(squads, k)
|
||||
nextK = next(squads, k)
|
||||
squads[k] = nil
|
||||
k = nextK
|
||||
elseif (group.state == 4) then
|
||||
@ -416,7 +376,7 @@ function squadAttack.squadDispatch(map, surface, squad)
|
||||
squad.status = SQUAD_RAIDING
|
||||
attackMove(map, squad, surface)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -9,12 +9,10 @@ local constants = require("Constants")
|
||||
local mapUtils = require("MapUtils")
|
||||
local unitGroupUtils = require("UnitGroupUtils")
|
||||
local movementUtils = require("MovementUtils")
|
||||
local chunkUtils = require("ChunkUtils")
|
||||
local chunkPropertyUtils = require("ChunkPropertyUtils")
|
||||
|
||||
-- constants
|
||||
|
||||
local DEFINES_DISTRACTION_BY_ANYTHING = defines.distraction.by_anything
|
||||
local PLAYER_PHEROMONE = constants.PLAYER_PHEROMONE
|
||||
local BASE_PHEROMONE = constants.BASE_PHEROMONE
|
||||
|
||||
@ -26,22 +24,15 @@ local COOLDOWN_RETREAT = constants.COOLDOWN_RETREAT
|
||||
|
||||
-- imported functions
|
||||
|
||||
local mRandom = math.random
|
||||
|
||||
local addSquadToChunk = chunkPropertyUtils.addSquadToChunk
|
||||
|
||||
local calculateKamikazeThreshold = unitGroupUtils.calculateKamikazeThreshold
|
||||
|
||||
local positionFromDirectionAndFlat = mapUtils.positionFromDirectionAndFlat
|
||||
local getNeighborChunks = mapUtils.getNeighborChunks
|
||||
local findNearbyRetreatingSquad = unitGroupUtils.findNearbyRetreatingSquad
|
||||
local addMovementPenalty = movementUtils.addMovementPenalty
|
||||
local createSquad = unitGroupUtils.createSquad
|
||||
local membersToSquad = unitGroupUtils.membersToSquad
|
||||
local scoreNeighborsForRetreat = movementUtils.scoreNeighborsForRetreat
|
||||
local findMovementPosition = movementUtils.findMovementPosition
|
||||
|
||||
local getSquadsOnChunk = chunkPropertyUtils.getSquadsOnChunk
|
||||
local getRetreatTick = chunkPropertyUtils.getRetreatTick
|
||||
local getPlayerBaseGenerator = chunkPropertyUtils.getPlayerBaseGenerator
|
||||
local setRetreatTick = chunkPropertyUtils.setRetreatTick
|
||||
@ -52,21 +43,22 @@ local getEnemyStructureCount = chunkPropertyUtils.getEnemyStructureCount
|
||||
|
||||
local function scoreRetreatLocation(map, neighborChunk)
|
||||
return (-neighborChunk[BASE_PHEROMONE] +
|
||||
-getDeathGenerator(map, neighborChunk) +
|
||||
-(neighborChunk[PLAYER_PHEROMONE] * PLAYER_PHEROMONE_MULTIPLER) +
|
||||
-(getPlayerBaseGenerator(map, neighborChunk) * 1000))
|
||||
-getDeathGenerator(map, neighborChunk) +
|
||||
-(neighborChunk[PLAYER_PHEROMONE] * PLAYER_PHEROMONE_MULTIPLER) +
|
||||
-(getPlayerBaseGenerator(map, neighborChunk) * 1000))
|
||||
end
|
||||
|
||||
function aiDefense.retreatUnits(chunk, cause, map, surface, tick, radius)
|
||||
if (tick - getRetreatTick(map, chunk) > COOLDOWN_RETREAT) and (getEnemyStructureCount(map, chunk) == 0) then
|
||||
|
||||
setRetreatTick(map, chunk, tick)
|
||||
local exitPath,exitDirection,nextExitPath,nextExitDirection = scoreNeighborsForRetreat(chunk,
|
||||
getNeighborChunks(map,
|
||||
chunk.x,
|
||||
chunk.y),
|
||||
scoreRetreatLocation,
|
||||
map)
|
||||
local exitPath,exitDirection,
|
||||
nextExitPath,nextExitDirection = scoreNeighborsForRetreat(chunk,
|
||||
getNeighborChunks(map,
|
||||
chunk.x,
|
||||
chunk.y),
|
||||
scoreRetreatLocation,
|
||||
map)
|
||||
local position = map.position
|
||||
local targetPosition2 = map.position2
|
||||
local retreatPosition
|
||||
|
@ -8,43 +8,14 @@ local unitGroupUtils = {}
|
||||
local mapUtils = require("MapUtils")
|
||||
local constants = require("Constants")
|
||||
local chunkPropertyUtils = require("ChunkPropertyUtils")
|
||||
local chunkUtils = require("ChunkUtils")
|
||||
local movementUtils = require("MovementUtils")
|
||||
|
||||
-- constants
|
||||
|
||||
local TEN_DEATH_PHEROMONE_GENERATOR_AMOUNT = constants.TEN_DEATH_PHEROMONE_GENERATOR_AMOUNT
|
||||
|
||||
local DIVISOR_DEATH_TRAIL_TABLE = constants.DIVISOR_DEATH_TRAIL_TABLE
|
||||
local SQUAD_QUEUE_SIZE = constants.SQUAD_QUEUE_SIZE
|
||||
|
||||
local DEFINES_GROUP_STATE_ATTACKING_TARGET = defines.group_state.attacking_target
|
||||
local DEFINES_GROUP_STATE_ATTACKING_DISTRACTION = defines.group_state.attacking_distraction
|
||||
|
||||
local SQUAD_RETREATING = constants.SQUAD_RETREATING
|
||||
local SQUAD_GUARDING = constants.SQUAD_GUARDING
|
||||
|
||||
local AI_MAX_BITER_GROUP_SIZE = constants.AI_MAX_BITER_GROUP_SIZE
|
||||
local AI_SQUAD_MERGE_THRESHOLD = constants.AI_SQUAD_MERGE_THRESHOLD
|
||||
|
||||
-- imported functions
|
||||
|
||||
local tRemove = table.remove
|
||||
|
||||
local mRandom = math.random
|
||||
|
||||
local findMovementPosition = movementUtils.findMovementPosition
|
||||
local removeSquadFromChunk = chunkPropertyUtils.removeSquadFromChunk
|
||||
local addDeathGenerator = chunkPropertyUtils.addDeathGenerator
|
||||
local getDeathGenerator = chunkPropertyUtils.getDeathGenerator
|
||||
|
||||
local next = next
|
||||
local table_size = table_size
|
||||
|
||||
local mLog = math.log10
|
||||
|
||||
local mMin = math.min
|
||||
|
||||
local getSquadsOnChunk = chunkPropertyUtils.getSquadsOnChunk
|
||||
|
||||
local getNeighborChunks = mapUtils.getNeighborChunks
|
||||
|
Loading…
x
Reference in New Issue
Block a user