1
0
mirror of https://github.com/veden/Rampant.git synced 2025-09-16 09:16:43 +02:00

see changelog

This commit is contained in:
Aaron Veden
2020-05-15 13:51:38 -07:00
parent 17a5c716c6
commit 14e82d074e
21 changed files with 404 additions and 400 deletions

View File

@@ -127,8 +127,8 @@ function upgrade.attempt(natives, setNewSurface, gameSurfaces)
natives.pendingStealGroups = {} natives.pendingStealGroups = {}
natives.pendingStealGroups.len = 1 natives.pendingStealGroups.len = 1
end end
if (global.version < 109) then if (global.version < 110) then
global.version = 109 global.version = 110
local gameSurfs local gameSurfs
if not gameSurfaces then if not gameSurfaces then
@@ -161,8 +161,20 @@ function upgrade.attempt(natives, setNewSurface, gameSurfaces)
end end
end end
for i=1,natives.squads.len do
natives.squads[i].chunk = -1
end
for i=1,natives.pendingAttack.len do
natives.pendingAttack[i].chunk = -1
end
for i=1,#natives.building do
natives.building[i].chunk = -1
end
if not setNewSurface then if not setNewSurface then
game.get_surface(natives.activeSurface).print("Rampant - Version 0.18.9") game.get_surface(natives.activeSurface).print("Rampant - Version 0.18.11")
end end
end end

View File

@@ -1,8 +1,21 @@
--------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------
Version: 0.18.11 Version: 0.18.11
Date: 13. 4 2020 Date: 13. 4 2020
Improvements:
- Groups stolen from vanilla AI can now become settlers based on ai state
- AI now gains extra credits based on the number of spawners in pollution
Tweaks:
- Increased chance to 45% for both attack and settle on a map processing logic cycle
- Squads and settlers created per map scan capped at 7
Bugfixes: Bugfixes:
- fixed script_raised_destroy not being pass to the onDeath handler - fixed script_raised_destroy not being pass to the onDeath handler
- fixed SENTINEL_IMPASSABLE_CHUNK not being defined in base entity upgrade handler
- fixed rapid in squad defense to rabid (Thanks to jnshi)
- fixed squads being able to record movement penalties for SENTINEL_IMPASSABLE_CHUNK
- fixed squads being able to be added to SENTINEL_IMPASSABLE_CHUNK
- fixed new unit scalers now have a minimum of 0.0001
- fixed tile changes using surface index instead of surface name
- fixed squad cap due to spawning not taking into account pending squads
--------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------
Version: 0.18.10 Version: 0.18.10

View File

@@ -46,8 +46,6 @@ local WATER_TILE_NAMES = constants.WATER_TILE_NAMES
local MOVEMENT_PHEROMONE = constants.MOVEMENT_PHEROMONE local MOVEMENT_PHEROMONE = constants.MOVEMENT_PHEROMONE
local SENTINEL_IMPASSABLE_CHUNK = constants.SENTINEL_IMPASSABLE_CHUNK
local RETREAT_GRAB_RADIUS = constants.RETREAT_GRAB_RADIUS local RETREAT_GRAB_RADIUS = constants.RETREAT_GRAB_RADIUS
local RETREAT_SPAWNER_GRAB_RADIUS = constants.RETREAT_SPAWNER_GRAB_RADIUS local RETREAT_SPAWNER_GRAB_RADIUS = constants.RETREAT_SPAWNER_GRAB_RADIUS
@@ -157,7 +155,7 @@ local function onIonCannonFired(event)
natives.ionCannonBlasts = natives.ionCannonBlasts + 1 natives.ionCannonBlasts = natives.ionCannonBlasts + 1
natives.points = natives.points + 3000 natives.points = natives.points + 3000
local chunk = getChunkByPosition(map, event.position) local chunk = getChunkByPosition(map, event.position)
if (chunk ~= SENTINEL_IMPASSABLE_CHUNK) then if (chunk ~= -1) then
rallyUnits(chunk, map, surface, event.tick) rallyUnits(chunk, map, surface, event.tick)
end end
end end
@@ -227,20 +225,20 @@ local function rebuildMap()
-- preallocating memory to be used in code, making it fast by reducing garbage generated. -- preallocating memory to be used in code, making it fast by reducing garbage generated.
map.neighbors = { map.neighbors = {
SENTINEL_IMPASSABLE_CHUNK, -1,
SENTINEL_IMPASSABLE_CHUNK, -1,
SENTINEL_IMPASSABLE_CHUNK, -1,
SENTINEL_IMPASSABLE_CHUNK, -1,
SENTINEL_IMPASSABLE_CHUNK, -1,
SENTINEL_IMPASSABLE_CHUNK, -1,
SENTINEL_IMPASSABLE_CHUNK, -1,
SENTINEL_IMPASSABLE_CHUNK -1
} }
map.cardinalNeighbors = { map.cardinalNeighbors = {
SENTINEL_IMPASSABLE_CHUNK, -1,
SENTINEL_IMPASSABLE_CHUNK, -1,
SENTINEL_IMPASSABLE_CHUNK, -1,
SENTINEL_IMPASSABLE_CHUNK -1
} }
map.position = { map.position = {
x=0, x=0,
@@ -264,10 +262,10 @@ local function rebuildMap()
map.chunkScanCounts = {} map.chunkScanCounts = {}
map.chunkOverlapArray = { map.chunkOverlapArray = {
SENTINEL_IMPASSABLE_CHUNK, -1,
SENTINEL_IMPASSABLE_CHUNK, -1,
SENTINEL_IMPASSABLE_CHUNK, -1,
SENTINEL_IMPASSABLE_CHUNK -1
} }
-- map.mapOrdering = {} -- map.mapOrdering = {}
@@ -606,140 +604,142 @@ end
local function onDeath(event) local function onDeath(event)
local entity = event.entity local entity = event.entity
local surface = entity.surface if entity.valid then
if (surface.name == natives.activeSurface) then local surface = entity.surface
local entityPosition = entity.position if (surface.name == natives.activeSurface) then
local chunk = getChunkByPosition(map, entityPosition) local entityPosition = entity.position
local cause = event.cause local chunk = getChunkByPosition(map, entityPosition)
local tick = event.tick local cause = event.cause
local entityType = entity.type local tick = event.tick
if (entity.force.name == "enemy") then 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 if artilleryBlast then
natives.artilleryBlasts = natives.artilleryBlasts + 1 natives.artilleryBlasts = natives.artilleryBlasts + 1
end
if (entityType == "unit") then
if (chunk ~= SENTINEL_IMPASSABLE_CHUNK) then
-- drop death pheromone where unit died
deathScent(map, chunk)
if event.force and (event.force.name ~= "enemy") and (chunk[MOVEMENT_PHEROMONE] < -natives.retreatThreshold) then
natives.lostEnemyUnits = natives.lostEnemyUnits + 1
retreatUnits(chunk,
entityPosition,
convertUnitGroupToSquad(natives, entity.unit_group),
map,
surface,
tick,
(artilleryBlast and RETREAT_SPAWNER_GRAB_RADIUS) or RETREAT_GRAB_RADIUS,
artilleryBlast)
if (mRandom() < natives.rallyThreshold) and not surface.peaceful_mode then
rallyUnits(chunk, map, surface, tick)
end
end
end end
elseif event.force and (event.force.name ~= "enemy") and ((entityType == "unit-spawner") or (entityType == "turret")) then if (entityType == "unit") then
if (chunk ~= -1) then
-- drop death pheromone where unit died
deathScent(map, chunk)
natives.points = natives.points + (((entityType == "unit-spawner") and RECOVER_NEST_COST) or RECOVER_WORM_COST) if event.force and (event.force.name ~= "enemy") and (chunk[MOVEMENT_PHEROMONE] < -natives.retreatThreshold) then
if (chunk ~= SENTINEL_IMPASSABLE_CHUNK) then natives.lostEnemyUnits = natives.lostEnemyUnits + 1
unregisterEnemyBaseStructure(map, entity)
rallyUnits(chunk, map, surface, tick) retreatUnits(chunk,
entityPosition,
convertUnitGroupToSquad(natives, entity.unit_group),
map,
surface,
tick,
(artilleryBlast and RETREAT_SPAWNER_GRAB_RADIUS) or RETREAT_GRAB_RADIUS,
artilleryBlast)
retreatUnits(chunk, if (mRandom() < natives.rallyThreshold) and not surface.peaceful_mode then
entityPosition, rallyUnits(chunk, map, surface, tick)
nil,
map,
surface,
tick,
RETREAT_SPAWNER_GRAB_RADIUS,
(cause and ((cause.type == "artillery-wagon") or (cause.type == "artillery-turret"))))
end
end
local pair = natives.drainPylons[entity.unit_number]
if pair then
local target = pair[1]
local pole = pair[2]
if target == entity then
natives.drainPylons[entity.unit_number] = nil
if pole.valid then
natives.drainPylons[pole.unit_number] = nil
pole.die()
end
elseif (pole == entity) then
natives.drainPylons[entity.unit_number] = nil
if target.valid then
natives.drainPylons[target.unit_number] = nil
target.destroy()
end
end
end
elseif (entity.force.name ~= "enemy") then
local creditNatives = false
if (event.force ~= nil) and (event.force.name == "enemy") then
creditNatives = true
if (chunk ~= SENTINEL_IMPASSABLE_CHUNK) then
victoryScent(map, chunk, entityType)
end
local drained = (entityType == "electric-turret") and map.chunkToDrained[chunk]
if (cause ~= nil) or (drained and (drained - tick) > 0) then
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})
if (conversion == "pole") then
local targetEntity = surface.create_entity({position=entity.position,
name="pylon-target-rampant",
direction=entity.direction})
targetEntity.backer_name = ""
local pair = {targetEntity, newEntity}
natives.drainPylons[targetEntity.unit_number] = pair
natives.drainPylons[newEntity.unit_number] = pair
local wires = entity.neighbours
if wires then
for _,v in pairs(wires.copper) do
if (v.valid) then
newEntity.connect_neighbour(v);
end
end
for _,v in pairs(wires.red) do
if (v.valid) then
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});
end
end
end
elseif newEntity.backer_name then
newEntity.backer_name = ""
end end
end end
end end
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)
if (chunk ~= -1) then
unregisterEnemyBaseStructure(map, entity)
rallyUnits(chunk, map, surface, tick)
retreatUnits(chunk,
entityPosition,
nil,
map,
surface,
tick,
RETREAT_SPAWNER_GRAB_RADIUS,
(cause and ((cause.type == "artillery-wagon") or (cause.type == "artillery-turret"))))
end
end end
elseif (entity.type == "resource") and (entity.force.name == "neutral") then
if (entity.amount == 0) then local pair = natives.drainPylons[entity.unit_number]
unregisterResource(entity, map) if pair then
local target = pair[1]
local pole = pair[2]
if target == entity then
natives.drainPylons[entity.unit_number] = nil
if pole.valid then
natives.drainPylons[pole.unit_number] = nil
pole.die()
end
elseif (pole == entity) then
natives.drainPylons[entity.unit_number] = nil
if target.valid then
natives.drainPylons[target.unit_number] = nil
target.destroy()
end
end
end
elseif (entity.force.name ~= "enemy") then
local creditNatives = false
if (event.force ~= nil) and (event.force.name == "enemy") then
creditNatives = true
if (chunk ~= -1) then
victoryScent(map, chunk, entityType)
end
local drained = (entityType == "electric-turret") and map.chunkToDrained[chunk]
if (cause ~= nil) or (drained and (drained - tick) > 0) then
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})
if (conversion == "pole") then
local targetEntity = surface.create_entity({position=entity.position,
name="pylon-target-rampant",
direction=entity.direction})
targetEntity.backer_name = ""
local pair = {targetEntity, newEntity}
natives.drainPylons[targetEntity.unit_number] = pair
natives.drainPylons[newEntity.unit_number] = pair
local wires = entity.neighbours
if wires then
for _,v in pairs(wires.copper) do
if (v.valid) then
newEntity.connect_neighbour(v);
end
end
for _,v in pairs(wires.red) do
if (v.valid) then
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});
end
end
end
elseif newEntity.backer_name then
newEntity.backer_name = ""
end
end
end
end
elseif (entity.type == "resource") and (entity.force.name == "neutral") then
if (entity.amount == 0) then
unregisterResource(entity, map)
end
end
if creditNatives and natives.safeBuildings and (natives.safeEntities[entityType] or natives.safeEntities[entity.name]) then
makeImmortalEntity(surface, entity)
else
accountPlayerEntity(entity, natives, false, creditNatives)
end end
end
if creditNatives and natives.safeBuildings and (natives.safeEntities[entityType] or natives.safeEntities[entity.name]) then
makeImmortalEntity(surface, entity)
else
accountPlayerEntity(entity, natives, false, creditNatives)
end end
end end
end end
@@ -747,38 +747,41 @@ end
local function onEnemyBaseBuild(event) local function onEnemyBaseBuild(event)
local entity = event.entity local entity = event.entity
local surface = entity.surface if entity.valid then
local surface = entity.surface
if entity.valid and (surface.name == natives.activeSurface) then if (surface.name == natives.activeSurface) then
local chunk = getChunkByPosition(map, entity.position) local chunk = getChunkByPosition(map, entity.position)
if (chunk ~= SENTINEL_IMPASSABLE_CHUNK) then if (chunk ~= -1) then
local base local base
if natives.newEnemies then if natives.newEnemies then
base = findNearbyBase(map, chunk) base = findNearbyBase(map, chunk)
if not base then if not base then
base = createBase(natives, base = createBase(natives,
chunk, chunk,
event.tick) event.tick)
end
entity = upgradeEntity(entity,
surface,
base.alignment,
natives,
nil,
true)
end
if entity and entity.valid then
event.entity = registerEnemyBaseStructure(map, entity, base, surface)
end end
entity = upgradeEntity(entity,
surface,
base.alignment,
natives,
nil,
true)
end
if entity and entity.valid then
event.entity = registerEnemyBaseStructure(map, entity, base, surface)
end end
end end
end end
end end
local function onSurfaceTileChange(event) local function onSurfaceTileChange(event)
local surfaceName = event.surface_index or (event.robot and event.robot.surface and event.robot.surface.name) local surfaceIndex = event.surface_index or (event.robot and event.robot.surface and event.robot.surface.index)
if event.item and local surfaceName = game.surfaces[surfaceIndex].name
if (surfaceName == natives.activeSurface) and
((event.item.name == "landfill") or (event.item.name == "waterfill")) and ((event.item.name == "landfill") or (event.item.name == "waterfill")) and
(surfaceName == natives.activeSurface) event.item
then then
local surface = game.get_surface(natives.activeSurface) local surface = game.get_surface(natives.activeSurface)
local chunks = {} local chunks = {}
@@ -787,7 +790,7 @@ local function onSurfaceTileChange(event)
local position = tiles[i].position local position = tiles[i].position
local chunk = getChunkByPosition(map, position) local chunk = getChunkByPosition(map, position)
if (chunk ~= SENTINEL_IMPASSABLE_CHUNK) then if (chunk ~= -1) then
map.chunkToPassScan[chunk] = true map.chunkToPassScan[chunk] = true
else else
local x,y = positionToChunkXY(position) local x,y = positionToChunkXY(position)
@@ -820,14 +823,14 @@ end
local function onRobotCliff(event) local function onRobotCliff(event)
local surface = event.robot.surface local surface = event.robot.surface
if (event.item.name == "cliff-explosives") and (surface.name == natives.activeSurface) then if (surface.name == natives.activeSurface) and (event.item.name == "cliff-explosives") then
entityForPassScan(map, event.cliff) entityForPassScan(map, event.cliff)
end end
end end
local function onUsedCapsule(event) local function onUsedCapsule(event)
local surface = game.players[event.player_index].surface local surface = game.players[event.player_index].surface
if (event.item.name == "cliff-explosives") and (surface.name == natives.activeSurface) then if (surface.name == natives.activeSurface) and (event.item.name == "cliff-explosives") then
map.position2Top.x = event.position.x-0.75 map.position2Top.x = event.position.x-0.75
map.position2Top.y = event.position.y-0.75 map.position2Top.y = event.position.y-0.75
map.position2Bottom.x = event.position.x+0.75 map.position2Bottom.x = event.position.x+0.75
@@ -849,9 +852,9 @@ end
local function onTriggerEntityCreated(event) local function onTriggerEntityCreated(event)
local entity = event.entity local entity = event.entity
if entity.valid 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) local chunk = getChunkByPosition(map, entity.position)
if (chunk ~= SENTINEL_IMPASSABLE_CHUNK) then if (chunk ~= -1) then
map.chunkToDrained[chunk] = event.tick + 60 map.chunkToDrained[chunk] = event.tick + 60
end end
entity.destroy() entity.destroy()
@@ -875,18 +878,18 @@ end
local function onEntitySpawned(event) local function onEntitySpawned(event)
local entity = event.entity local entity = event.entity
if natives.newEnemies and (entity.valid and entity.type ~= "unit") then if natives.newEnemies and entity.valid then
if natives.buildingHiveTypeLookup[entity.name] then local surface = entity.surface
if (surface.name == natives.activeSurface) and (entity.type ~= "unit") then
if natives.buildingHiveTypeLookup[entity.name] then
local spawner = event.spawner
local spawner = event.spawner
local surface = entity.surface
if (surface.name == natives.activeSurface) then
local disPos = mathUtils.distortPosition(entity.position, 8) local disPos = mathUtils.distortPosition(entity.position, 8)
local canPlaceQuery = map.canPlaceQuery local canPlaceQuery = map.canPlaceQuery
local chunk = getChunkByPosition(map, disPos) local chunk = getChunkByPosition(map, disPos)
if (chunk ~= SENTINEL_IMPASSABLE_CHUNK) then if (chunk ~= -1) then
local base = findNearbyBase(map, chunk) local base = findNearbyBase(map, chunk)
if not base then if not base then
base = createBase(natives, base = createBase(natives,
@@ -914,7 +917,7 @@ end
local function onUnitGroupCreated(event) local function onUnitGroupCreated(event)
local group = event.group local group = event.group
if (group.force.name == "enemy") then if (group.surface.name == natives.activeSurface) and (group.force.name == "enemy") then
if not group.is_script_driven then if not group.is_script_driven then
natives.pendingStealGroups.len = natives.pendingStealGroups.len + 1 natives.pendingStealGroups.len = natives.pendingStealGroups.len + 1
natives.pendingStealGroups[natives.pendingStealGroups.len] = group natives.pendingStealGroups[natives.pendingStealGroups.len] = group
@@ -1109,6 +1112,7 @@ script.on_event(defines.events.on_pre_robot_exploded_cliff, onRobotCliff)
script.on_event(defines.events.on_biter_base_built, onEnemyBaseBuild) script.on_event(defines.events.on_biter_base_built, onEnemyBaseBuild)
script.on_event({defines.events.on_player_mined_entity, script.on_event({defines.events.on_player_mined_entity,
defines.events.on_robot_mined_entity}, onMine) defines.events.on_robot_mined_entity}, onMine)
script.on_event({defines.events.on_built_entity, script.on_event({defines.events.on_built_entity,
defines.events.on_robot_built_entity, defines.events.on_robot_built_entity,
defines.events.script_raised_built, defines.events.script_raised_built,

View File

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

View File

@@ -46,8 +46,6 @@ local AI_STATE_SIEGE = constants.AI_STATE_SIEGE
local AI_STATE_RAIDING = constants.AI_STATE_RAIDING local AI_STATE_RAIDING = constants.AI_STATE_RAIDING
local SENTINEL_IMPASSABLE_CHUNK = constants.SENTINEL_IMPASSABLE_CHUNK
-- imported functions -- imported functions
local randomTickEvent = mathUtils.randomTickEvent local randomTickEvent = mathUtils.randomTickEvent
@@ -132,7 +130,7 @@ function aiAttackWave.rallyUnits(chunk, map, surface, tick)
for y=cY - RALLY_CRY_DISTANCE, cY + RALLY_CRY_DISTANCE, 32 do for y=cY - RALLY_CRY_DISTANCE, cY + RALLY_CRY_DISTANCE, 32 do
if (x ~= cX) and (y ~= cY) then if (x ~= cX) and (y ~= cY) then
local rallyChunk = getChunkByXY(map, x, y) local rallyChunk = getChunkByXY(map, x, y)
if (rallyChunk ~= SENTINEL_IMPASSABLE_CHUNK) and (getNestCount(map, rallyChunk) > 0) then if (rallyChunk ~= -1) and (getNestCount(map, rallyChunk) > 0) then
if not aiAttackWave.formVengenceSquad(map, surface, rallyChunk) then if not aiAttackWave.formVengenceSquad(map, surface, rallyChunk) then
return false return false
end end
@@ -152,7 +150,7 @@ function aiAttackWave.formAttackWave(chunk, map, surface, tick)
for y=cY - RALLY_CRY_DISTANCE, cY + RALLY_CRY_DISTANCE, 32 do for y=cY - RALLY_CRY_DISTANCE, cY + RALLY_CRY_DISTANCE, 32 do
if (x ~= cX) and (y ~= cY) then if (x ~= cX) and (y ~= cY) then
local rallyChunk = getChunkByXY(map, x, y) local rallyChunk = getChunkByXY(map, x, y)
if (rallyChunk ~= SENTINEL_IMPASSABLE_CHUNK) and (getNestCount(map, rallyChunk) > 0) then if (rallyChunk ~= -1) and (getNestCount(map, rallyChunk) > 0) then
if not aiAttackWave.formSquads(map, surface, rallyChunk, tick) then if not aiAttackWave.formSquads(map, surface, rallyChunk, tick) then
return false return false
end end
@@ -172,7 +170,7 @@ local function noNearbySettlers(map, chunk, tick)
for y=cY - SETTLER_DISTANCE, cY + SETTLER_DISTANCE, 32 do for y=cY - SETTLER_DISTANCE, cY + SETTLER_DISTANCE, 32 do
if (x ~= cX) and (y ~= cY) then if (x ~= cX) and (y ~= cY) then
local c = getChunkByXY(map, x, y) local c = getChunkByXY(map, x, y)
if (c ~= SENTINEL_IMPASSABLE_CHUNK) and ((tick - getChunkSettlerTick(map, c)) < 0) then if (c ~= -1) and ((tick - getChunkSettlerTick(map, c)) < 0) then
return false return false
end end
end end
@@ -183,7 +181,10 @@ end
function aiAttackWave.formSettlers(map, surface, chunk, tick) function aiAttackWave.formSettlers(map, surface, chunk, tick)
local natives = map.natives local natives = map.natives
if (mRandom() < natives.formSquadThreshold) and ((natives.squads.len + #natives.building) < AI_MAX_SQUAD_COUNT) then if (mRandom() < natives.formSquadThreshold) and
((natives.squads.len + #natives.building) < AI_MAX_SQUAD_COUNT) and
(natives.remainingSquads > 0)
then
local squadPath, squadDirection local squadPath, squadDirection
if (natives.state == AI_STATE_SIEGE) then if (natives.state == AI_STATE_SIEGE) then
@@ -199,7 +200,7 @@ function aiAttackWave.formSettlers(map, surface, chunk, tick)
map) map)
end end
if (squadPath ~= SENTINEL_IMPASSABLE_CHUNK) and noNearbySettlers(map, chunk, tick) then if (squadPath ~= -1) and noNearbySettlers(map, chunk, tick) then
local squadPosition = surface.find_non_colliding_position("chunk-scanner-squad-rampant", local squadPosition = surface.find_non_colliding_position("chunk-scanner-squad-rampant",
positionFromDirectionAndChunk(squadDirection, positionFromDirectionAndChunk(squadDirection,
chunk, chunk,
@@ -226,6 +227,7 @@ function aiAttackWave.formSettlers(map, surface, chunk, tick)
local pending = natives.pendingAttack local pending = natives.pendingAttack
pending.len = pending.len + 1 pending.len = pending.len + 1
squad.cycles = 30 squad.cycles = 30
natives.remainingSquads = natives.remainingSquads - 1
pending[pending.len] = squad pending[pending.len] = squad
natives.points = natives.points - AI_SETTLER_COST natives.points = natives.points - AI_SETTLER_COST
else else
@@ -237,7 +239,7 @@ function aiAttackWave.formSettlers(map, surface, chunk, tick)
end end
end end
return (natives.points - AI_SETTLER_COST) > 0 return ((natives.points - AI_SETTLER_COST) > 0) and (natives.remainingSquads > 0)
end end
function aiAttackWave.formVengenceSquad(map, surface, chunk) function aiAttackWave.formVengenceSquad(map, surface, chunk)
@@ -248,7 +250,7 @@ function aiAttackWave.formVengenceSquad(map, surface, chunk)
validUnitGroupLocation, validUnitGroupLocation,
scoreUnitGroupLocation, scoreUnitGroupLocation,
map) map)
if (squadPath ~= SENTINEL_IMPASSABLE_CHUNK) then if (squadPath ~= -1) then
local squadPosition = surface.find_non_colliding_position("chunk-scanner-squad-rampant", local squadPosition = surface.find_non_colliding_position("chunk-scanner-squad-rampant",
positionFromDirectionAndChunk(squadDirection, positionFromDirectionAndChunk(squadDirection,
chunk, chunk,
@@ -289,13 +291,14 @@ function aiAttackWave.formSquads(map, surface, chunk, tick)
local natives = map.natives local natives = map.natives
if attackWaveValidCandidate(chunk, natives, map) and if attackWaveValidCandidate(chunk, natives, map) and
(mRandom() < natives.formSquadThreshold) and (mRandom() < natives.formSquadThreshold) and
(natives.squads.len < AI_MAX_SQUAD_COUNT) (natives.squads.len + natives.pendingAttack.len < AI_MAX_SQUAD_COUNT) and
(natives.remainingSquads > 0)
then then
local squadPath, squadDirection = scoreNeighborsForFormation(getNeighborChunks(map, chunk.x, chunk.y), local squadPath, squadDirection = scoreNeighborsForFormation(getNeighborChunks(map, chunk.x, chunk.y),
validUnitGroupLocation, validUnitGroupLocation,
scoreUnitGroupLocation, scoreUnitGroupLocation,
map) map)
if (squadPath ~= SENTINEL_IMPASSABLE_CHUNK) then if (squadPath ~= -1) then
local squadPosition = surface.find_non_colliding_position("chunk-scanner-squad-rampant", local squadPosition = surface.find_non_colliding_position("chunk-scanner-squad-rampant",
positionFromDirectionAndChunk(squadDirection, positionFromDirectionAndChunk(squadDirection,
chunk, chunk,
@@ -320,6 +323,7 @@ function aiAttackWave.formSquads(map, surface, chunk, tick)
squad.cycles = 30 squad.cycles = 30
pending[pending.len] = squad pending[pending.len] = squad
natives.points = natives.points - AI_SQUAD_COST natives.points = natives.points - AI_SQUAD_COST
natives.remainingSquads = natives.remainingSquads - 1
if tick and (natives.state == AI_STATE_AGGRESSIVE) then if tick and (natives.state == AI_STATE_AGGRESSIVE) then
natives.canAttackTick = randomTickEvent(tick, natives.canAttackTick = randomTickEvent(tick,
AGGRESSIVE_CAN_ATTACK_WAIT_MIN_DURATION, AGGRESSIVE_CAN_ATTACK_WAIT_MIN_DURATION,
@@ -335,7 +339,7 @@ function aiAttackWave.formSquads(map, surface, chunk, tick)
end end
end end
return (natives.points - AI_SQUAD_COST) > 0 return ((natives.points - AI_SQUAD_COST) > 0) and (natives.remainingSquads > 0)
end end

View File

@@ -91,7 +91,7 @@ function aiPlanning.planning(natives, evolution_factor, tick)
natives.unitRefundAmount = AI_UNIT_REFUND * evolution_factor natives.unitRefundAmount = AI_UNIT_REFUND * evolution_factor
natives.kamikazeThreshold = NO_RETREAT_BASE_PERCENT + (evolution_factor * NO_RETREAT_EVOLUTION_BONUS_MAX) natives.kamikazeThreshold = NO_RETREAT_BASE_PERCENT + (evolution_factor * NO_RETREAT_EVOLUTION_BONUS_MAX)
local points = mFloor((AI_POINT_GENERATOR_AMOUNT * mRandom()) + ((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 if (natives.state == AI_STATE_ONSLAUGHT) then
points = points * 2 points = points * 2

View File

@@ -20,10 +20,10 @@ local AI_STATE_ONSLAUGHT = constants.AI_STATE_ONSLAUGHT
-- module code -- module code
function aiPredicates.canAttack(natives, surface) function aiPredicates.canAttack(natives, surface)
return ((natives.state == AI_STATE_AGGRESSIVE) or (natives.state == AI_STATE_RAIDING) or (natives.state == AI_STATE_ONSLAUGHT)) local goodAI = ((natives.state == AI_STATE_AGGRESSIVE) or (natives.state == AI_STATE_RAIDING) or (natives.state == AI_STATE_ONSLAUGHT))
and not surface.peaceful_mode local notPeaceful = not surface.peaceful_mode
and ((not natives.aiNocturnalMode) or local noctural = (not natives.aiNocturnalMode) or (natives.aiNocturnalMode and surface.darkness > 0.65)
(natives.aiNocturnalMode and surface.darkness > 0.65)) return goodAI and notPeaceful and noctural
end end
function aiPredicates.canMigrate(natives, surface) function aiPredicates.canMigrate(natives, surface)

View File

@@ -274,7 +274,7 @@ local function findEntityUpgrade(baseAlignment, currentEvo, evoIndex, originalEn
if evolve then if evolve then
local chunk = getChunkByPosition(natives.map, originalEntity.position) local chunk = getChunkByPosition(natives.map, originalEntity.position)
local makeHive = (chunk ~= SENTINEL_IMPASSABLE_CHUNK) and (getResourceGenerator(natives.map, chunk) > 0) and (mRandom() < 0.2) local makeHive = (chunk ~= -1) and (getResourceGenerator(natives.map, chunk) > 0) and (mRandom() < 0.2)
return initialEntityUpgrade(baseAlignment, tier, maxTier, natives, (makeHive and "hive")) return initialEntityUpgrade(baseAlignment, tier, maxTier, natives, (makeHive and "hive"))
else else

View File

@@ -13,8 +13,6 @@ local constants = require("Constants")
local CHUNK_SIZE = constants.CHUNK_SIZE local CHUNK_SIZE = constants.CHUNK_SIZE
local SENTINEL_IMPASSABLE_CHUNK = constants.SENTINEL_IMPASSABLE_CHUNK
local MAX_TICKS_BEFORE_SORT_CHUNKS = constants.MAX_TICKS_BEFORE_SORT_CHUNKS local MAX_TICKS_BEFORE_SORT_CHUNKS = constants.MAX_TICKS_BEFORE_SORT_CHUNKS
-- imported functions -- imported functions
@@ -83,7 +81,7 @@ function chunkProcessor.processPendingChunks(map, surface, pendingStack, tick, r
chunk = initialScan(chunk, surface, map, tick, rebuilding) chunk = initialScan(chunk, surface, map, tick, rebuilding)
if (chunk ~= SENTINEL_IMPASSABLE_CHUNK) then if (chunk ~= -1) then
map[x][y] = chunk map[x][y] = chunk
processQueue[#processQueue+1] = chunk processQueue[#processQueue+1] = chunk
end end
@@ -122,7 +120,7 @@ function chunkProcessor.processScanChunks(map, surface)
chunk = chunkPassScan(chunk, surface, map) chunk = chunkPassScan(chunk, surface, map)
if (chunk == SENTINEL_IMPASSABLE_CHUNK) then if (chunk == -1) then
map[x][y] = nil map[x][y] = nil
chunkCount = chunkCount + 1 chunkCount = chunkCount + 1

View File

@@ -246,7 +246,7 @@ end
function chunkPropertyUtils.addSquadToChunk(map, chunk, squad) function chunkPropertyUtils.addSquadToChunk(map, chunk, squad)
local chunkToSquad = map.chunkToSquad local chunkToSquad = map.chunkToSquad
if squad.chunk ~= chunk then if (chunk ~= -1) and (squad.chunk ~= chunk) then
chunkPropertyUtils.removeSquadFromChunk(map, squad) chunkPropertyUtils.removeSquadFromChunk(map, squad)
local squads = chunkToSquad[chunk] local squads = chunkToSquad[chunk]
if not squads then if not squads then

View File

@@ -23,8 +23,6 @@ local DEFINES_WIRE_TYPE_GREEN = defines.wire_type.green
local CHUNK_PASS_THRESHOLD = constants.CHUNK_PASS_THRESHOLD local CHUNK_PASS_THRESHOLD = constants.CHUNK_PASS_THRESHOLD
local SENTINEL_IMPASSABLE_CHUNK = constants.SENTINEL_IMPASSABLE_CHUNK
local AI_STATE_ONSLAUGHT = constants.AI_STATE_ONSLAUGHT local AI_STATE_ONSLAUGHT = constants.AI_STATE_ONSLAUGHT
local BASE_PHEROMONE = constants.BASE_PHEROMONE local BASE_PHEROMONE = constants.BASE_PHEROMONE
@@ -99,10 +97,10 @@ local function getEntityOverlapChunks(map, entity)
local boundingBox = entity.prototype.collision_box or entity.prototype.selection_box; local boundingBox = entity.prototype.collision_box or entity.prototype.selection_box;
local overlapArray = map.chunkOverlapArray local overlapArray = map.chunkOverlapArray
overlapArray[1] = SENTINEL_IMPASSABLE_CHUNK --LeftTop overlapArray[1] = -1 --LeftTop
overlapArray[2] = SENTINEL_IMPASSABLE_CHUNK --RightTop overlapArray[2] = -1 --RightTop
overlapArray[3] = SENTINEL_IMPASSABLE_CHUNK --LeftBottom overlapArray[3] = -1 --LeftBottom
overlapArray[4] = SENTINEL_IMPASSABLE_CHUNK --RightBottom overlapArray[4] = -1 --RightBottom
if boundingBox then if boundingBox then
local center = entity.position local center = entity.position
@@ -203,14 +201,13 @@ end
function chunkUtils.initialScan(chunk, surface, map, tick, rebuilding) function chunkUtils.initialScan(chunk, surface, map, tick, rebuilding)
local passScore = 1 - (surface.count_tiles_filtered(map.filteredTilesQuery) * 0.0009765625) local passScore = 1 - (surface.count_tiles_filtered(map.filteredTilesQuery) * 0.0009765625)
local natives = map.natives local natives = map.natives
local enemyBuildings = surface.find_entities_filtered(map.filteredEntitiesEnemyStructureQuery)
if (passScore >= CHUNK_PASS_THRESHOLD) then if (passScore >= CHUNK_PASS_THRESHOLD) or (#enemyBuildings > 0) then
local pass = scanPaths(chunk, surface, map) local pass = scanPaths(chunk, surface, map)
local playerObjects = scorePlayerBuildings(surface, map) local playerObjects = scorePlayerBuildings(surface, map)
local enemyBuildings = surface.find_entities_filtered(map.filteredEntitiesEnemyStructureQuery)
if ((playerObjects > 0) or (#enemyBuildings > 0)) and (pass == CHUNK_IMPASSABLE) then if ((playerObjects > 0) or (#enemyBuildings > 0)) and (pass == CHUNK_IMPASSABLE) then
pass = CHUNK_ALL_DIRECTIONS pass = CHUNK_ALL_DIRECTIONS
end end
@@ -287,7 +284,7 @@ function chunkUtils.initialScan(chunk, surface, map, tick, rebuilding)
end end
end end
return SENTINEL_IMPASSABLE_CHUNK return -1
end end
function chunkUtils.chunkPassScan(chunk, surface, map) function chunkUtils.chunkPassScan(chunk, surface, map)
@@ -310,7 +307,7 @@ function chunkUtils.chunkPassScan(chunk, surface, map)
return chunk return chunk
end end
return SENTINEL_IMPASSABLE_CHUNK return -1
end end
function chunkUtils.mapScanChunk(chunk, surface, map) function chunkUtils.mapScanChunk(chunk, surface, map)
@@ -345,7 +342,7 @@ function chunkUtils.entityForPassScan(map, entity)
for i=1,#overlapArray do for i=1,#overlapArray do
local chunk = overlapArray[i] local chunk = overlapArray[i]
if (chunk ~= SENTINEL_IMPASSABLE_CHUNK) then if (chunk ~= -1) then
map.chunkToPassScan[chunk] = true map.chunkToPassScan[chunk] = true
end end
end end
@@ -420,7 +417,7 @@ function chunkUtils.registerEnemyBaseStructure(map, entity, base, surface)
for i=1,#overlapArray do for i=1,#overlapArray do
local chunk = overlapArray[i] local chunk = overlapArray[i]
if (chunk ~= SENTINEL_IMPASSABLE_CHUNK) then if (chunk ~= -1) then
setFunc(map, chunk, getFunc(map, chunk) + 1) setFunc(map, chunk, getFunc(map, chunk) + 1)
setChunkBase(map, chunk, base) setChunkBase(map, chunk, base)
processNestActiveness(map, chunk, natives, surface) processNestActiveness(map, chunk, natives, surface)
@@ -475,7 +472,7 @@ function chunkUtils.unregisterEnemyBaseStructure(map, entity)
for i=1,#overlapArray do for i=1,#overlapArray do
local chunk = overlapArray[i] local chunk = overlapArray[i]
if (chunk ~= SENTINEL_IMPASSABLE_CHUNK) then if (chunk ~= -1) then
local count = getFunc(map, chunk) local count = getFunc(map, chunk)
if count then if count then
if (count <= 1) then if (count <= 1) then
@@ -517,7 +514,7 @@ function chunkUtils.accountPlayerEntity(entity, natives, addObject, creditNative
for i=1,#overlapArray do for i=1,#overlapArray do
local chunk = overlapArray[i] local chunk = overlapArray[i]
if (chunk ~= SENTINEL_IMPASSABLE_CHUNK) then if (chunk ~= -1) then
addPlayerBaseGenerator(map, chunk, entityValue) addPlayerBaseGenerator(map, chunk, entityValue)
end end
end end
@@ -533,7 +530,7 @@ function chunkUtils.unregisterResource(entity, map)
for i=1,#overlapArray do for i=1,#overlapArray do
local chunk = overlapArray[i] local chunk = overlapArray[i]
if (chunk ~= SENTINEL_IMPASSABLE_CHUNK) then if (chunk ~= -1) then
addResourceGenerator(map, chunk, -RESOURCE_NORMALIZER) addResourceGenerator(map, chunk, -RESOURCE_NORMALIZER)
end end
end end
@@ -544,7 +541,7 @@ function chunkUtils.registerResource(entity, map)
for i=1,#overlapArray do for i=1,#overlapArray do
local chunk = overlapArray[i] local chunk = overlapArray[i]
if (chunk ~= SENTINEL_IMPASSABLE_CHUNK) then if (chunk ~= -1) then
addResourceGenerator(map, chunk, RESOURCE_NORMALIZER) addResourceGenerator(map, chunk, RESOURCE_NORMALIZER)
end end
end end

View File

@@ -121,11 +121,13 @@ constants.RAIDING_MINIMUM_BASE_THRESHOLD = 550
constants.AI_UNIT_REFUND = 3 constants.AI_UNIT_REFUND = 3
constants.AI_MAX_SQUAD_COUNT = 35 constants.AI_MAX_SQUAD_COUNT = 60
constants.AI_MAX_BITER_GROUP_SIZE = 450 constants.AI_MAX_BITER_GROUP_SIZE = 450
constants.AI_SQUAD_MERGE_THRESHOLD = constants.AI_MAX_BITER_GROUP_SIZE * 0.75 constants.AI_SQUAD_MERGE_THRESHOLD = constants.AI_MAX_BITER_GROUP_SIZE * 0.75
constants.AI_MAX_SQUADS_PER_CYCLE = 7
constants.AI_STATE_PEACEFUL = 1 constants.AI_STATE_PEACEFUL = 1
constants.AI_STATE_AGGRESSIVE = 2 constants.AI_STATE_AGGRESSIVE = 2
-- constants.AI_STATE_NOCTURNAL = 3 -- constants.AI_STATE_NOCTURNAL = 3
@@ -393,17 +395,6 @@ constants.BASE_ALIGNMENT_NE_PINK = 28
-- sentinels -- sentinels
constants.SENTINEL_IMPASSABLE_CHUNK = {}
constants.SENTINEL_IMPASSABLE_CHUNK.name = "ImpassableChunk"
constants.SENTINEL_IMPASSABLE_CHUNK[constants.MOVEMENT_PHEROMONE] = constants.IMPASSABLE_TERRAIN_GENERATOR_AMOUNT
constants.SENTINEL_IMPASSABLE_CHUNK[constants.BASE_PHEROMONE] = constants.IMPASSABLE_TERRAIN_GENERATOR_AMOUNT
constants.SENTINEL_IMPASSABLE_CHUNK[constants.PLAYER_PHEROMONE] = constants.IMPASSABLE_TERRAIN_GENERATOR_AMOUNT
constants.SENTINEL_IMPASSABLE_CHUNK[constants.RESOURCE_PHEROMONE] = constants.IMPASSABLE_TERRAIN_GENERATOR_AMOUNT
constants.SENTINEL_IMPASSABLE_CHUNK[constants.CHUNK_TICK] = 0
constants.SENTINEL_IMPASSABLE_CHUNK.x = -1
constants.SENTINEL_IMPASSABLE_CHUNK.y = -1
constants.ENERGY_THIEF_CONVERSION_TABLE = { constants.ENERGY_THIEF_CONVERSION_TABLE = {
["generator"] = "unit", ["generator"] = "unit",
["pump"] = "smallUnit", ["pump"] = "smallUnit",

View File

@@ -31,8 +31,6 @@ local TRIPLE_CHUNK_SIZE = constants.TRIPLE_CHUNK_SIZE
local PROCESS_PLAYER_BOUND = constants.PROCESS_PLAYER_BOUND local PROCESS_PLAYER_BOUND = constants.PROCESS_PLAYER_BOUND
local CHUNK_TICK = constants.CHUNK_TICK local CHUNK_TICK = constants.CHUNK_TICK
local SENTINEL_IMPASSABLE_CHUNK = constants.SENTINEL_IMPASSABLE_CHUNK
local AI_SQUAD_COST = constants.AI_SQUAD_COST local AI_SQUAD_COST = constants.AI_SQUAD_COST
local AI_VENGENCE_SQUAD_COST = constants.AI_VENGENCE_SQUAD_COST local AI_VENGENCE_SQUAD_COST = constants.AI_VENGENCE_SQUAD_COST
local AI_SETTLER_COST = constants.AI_SETTLER_COST local AI_SETTLER_COST = constants.AI_SETTLER_COST
@@ -111,21 +109,23 @@ function mapProcessor.processMap(map, surface, tick)
local chunkToBase = map.chunkToBase local chunkToBase = map.chunkToBase
local natives = map.natives
if (index == 1) then if (index == 1) then
roll = mRandom() roll = mRandom()
map.processRoll = roll map.processRoll = roll
natives.remainingSquads = constants.AI_MAX_SQUADS_PER_CYCLE
print("squads", natives.squads.len, natives.pendingAttack.len, #natives.building)
end end
local natives = map.natives
local newEnemies = natives.newEnemies local newEnemies = natives.newEnemies
local scentStaging = map.scentStaging local scentStaging = map.scentStaging
local squads = canAttack(natives, surface) and (0.11 <= roll) and (roll <= 0.35) and (natives.points >= AI_SQUAD_COST) local squads = canAttack(natives, surface) and (roll <= 0.45) and (natives.points >= AI_SQUAD_COST)
if squads and (natives.state == AI_STATE_AGGRESSIVE) and (tick < natives.canAttackTick) then if squads and (natives.state == AI_STATE_AGGRESSIVE) and (tick < natives.canAttackTick) then
squads = false squads = false
end end
local settlers = canMigrate(natives, surface) and (0.90 <= roll) and (natives.points >= AI_SETTLER_COST) local settlers = canMigrate(natives, surface) and (roll <= 0.45) and (natives.points >= AI_SETTLER_COST)
local processQueue = map.processQueue local processQueue = map.processQueue
local endIndex = mMin(index + PROCESS_QUEUE_SIZE, #processQueue) local endIndex = mMin(index + PROCESS_QUEUE_SIZE, #processQueue)
@@ -230,7 +230,7 @@ function mapProcessor.processPlayers(players, map, surface, tick)
if validPlayer(player, natives) then if validPlayer(player, natives) then
local playerChunk = getChunkByPosition(map, player.character.position) local playerChunk = getChunkByPosition(map, player.character.position)
if (playerChunk ~= SENTINEL_IMPASSABLE_CHUNK) then if (playerChunk ~= -1) then
local i = 1 local i = 1
local vengence = (allowingAttacks and local vengence = (allowingAttacks and
(natives.points >= AI_VENGENCE_SQUAD_COST) and (natives.points >= AI_VENGENCE_SQUAD_COST) and
@@ -240,7 +240,7 @@ function mapProcessor.processPlayers(players, map, surface, tick)
for y=playerChunk.y - PROCESS_PLAYER_BOUND, playerChunk.y + PROCESS_PLAYER_BOUND, 32 do for y=playerChunk.y - PROCESS_PLAYER_BOUND, playerChunk.y + PROCESS_PLAYER_BOUND, 32 do
local chunk = getChunkByXY(map, x, y) local chunk = getChunkByXY(map, x, y)
if (chunk ~= SENTINEL_IMPASSABLE_CHUNK) and (chunk[CHUNK_TICK] ~= tick) then if (chunk ~= -1) and (chunk[CHUNK_TICK] ~= tick) then
processPheromone(map, chunk, scentStaging[i]) processPheromone(map, chunk, scentStaging[i])
processNestActiveness(map, chunk, natives, surface) processNestActiveness(map, chunk, natives, surface)
@@ -258,7 +258,7 @@ function mapProcessor.processPlayers(players, map, surface, tick)
for x=playerChunk.x - PROCESS_PLAYER_BOUND, playerChunk.x + PROCESS_PLAYER_BOUND, 32 do for x=playerChunk.x - PROCESS_PLAYER_BOUND, playerChunk.x + PROCESS_PLAYER_BOUND, 32 do
for y=playerChunk.y - PROCESS_PLAYER_BOUND, playerChunk.y + PROCESS_PLAYER_BOUND, 32 do for y=playerChunk.y - PROCESS_PLAYER_BOUND, playerChunk.y + PROCESS_PLAYER_BOUND, 32 do
local chunk = getChunkByXY(map, x, y) local chunk = getChunkByXY(map, x, y)
if (chunk ~= SENTINEL_IMPASSABLE_CHUNK) and (chunk[CHUNK_TICK] ~= tick) then if (chunk ~= -1) and (chunk[CHUNK_TICK] ~= tick) then
commitPheromone(map, chunk, scentStaging[i], tick) commitPheromone(map, chunk, scentStaging[i], tick)
end end
i = i + 1 i = i + 1
@@ -273,7 +273,7 @@ function mapProcessor.processPlayers(players, map, surface, tick)
if validPlayer(player, natives) then if validPlayer(player, natives) then
local playerChunk = getChunkByPosition(map, player.character.position) local playerChunk = getChunkByPosition(map, player.character.position)
if (playerChunk ~= SENTINEL_IMPASSABLE_CHUNK) then if (playerChunk ~= -1) then
playerScent(playerChunk) playerScent(playerChunk)
end end
end end

View File

@@ -19,8 +19,6 @@ local CHUNK_ALL_DIRECTIONS = constants.CHUNK_ALL_DIRECTIONS
local CHUNK_SIZE = constants.CHUNK_SIZE local CHUNK_SIZE = constants.CHUNK_SIZE
local SENTINEL_IMPASSABLE_CHUNK = constants.SENTINEL_IMPASSABLE_CHUNK
local CHUNK_SIZE_DIVIDER = constants.CHUNK_SIZE_DIVIDER local CHUNK_SIZE_DIVIDER = constants.CHUNK_SIZE_DIVIDER
-- imported functions -- imported functions
@@ -33,27 +31,27 @@ local getPassable = chunkPropertyUtils.getPassable
function mapUtils.getChunkByXY(map, x, y) function mapUtils.getChunkByXY(map, x, y)
local chunkX = map[x] local chunkX = map[x]
if chunkX then if chunkX then
return chunkX[y] or SENTINEL_IMPASSABLE_CHUNK return chunkX[y] or -1
end end
return SENTINEL_IMPASSABLE_CHUNK return -1
end end
function mapUtils.getChunkByPosition(map, position) function mapUtils.getChunkByPosition(map, position)
local chunkX = map[mFloor(position.x * CHUNK_SIZE_DIVIDER) * CHUNK_SIZE] local chunkX = map[mFloor(position.x * CHUNK_SIZE_DIVIDER) * CHUNK_SIZE]
if chunkX then if chunkX then
local chunkY = mFloor(position.y * CHUNK_SIZE_DIVIDER) * CHUNK_SIZE local chunkY = mFloor(position.y * CHUNK_SIZE_DIVIDER) * CHUNK_SIZE
return chunkX[chunkY] or SENTINEL_IMPASSABLE_CHUNK return chunkX[chunkY] or -1
end end
return SENTINEL_IMPASSABLE_CHUNK return -1
end end
function mapUtils.getChunkByUnalignedXY(map, x, y) function mapUtils.getChunkByUnalignedXY(map, x, y)
local chunkX = map[mFloor(x * CHUNK_SIZE_DIVIDER) * CHUNK_SIZE] local chunkX = map[mFloor(x * CHUNK_SIZE_DIVIDER) * CHUNK_SIZE]
if chunkX then if chunkX then
local chunkY = mFloor(y * CHUNK_SIZE_DIVIDER) * CHUNK_SIZE local chunkY = mFloor(y * CHUNK_SIZE_DIVIDER) * CHUNK_SIZE
return chunkX[chunkY] or SENTINEL_IMPASSABLE_CHUNK return chunkX[chunkY] or -1
end end
return SENTINEL_IMPASSABLE_CHUNK return -1
end end
function mapUtils.positionToChunkXY(position) function mapUtils.positionToChunkXY(position)
@@ -75,33 +73,33 @@ function mapUtils.getNeighborChunks(map, x, y)
local chunkYRow3 = y + CHUNK_SIZE local chunkYRow3 = y + CHUNK_SIZE
local xChunks = map[x-CHUNK_SIZE] local xChunks = map[x-CHUNK_SIZE]
if xChunks then if xChunks then
neighbors[1] = xChunks[chunkYRow1] or SENTINEL_IMPASSABLE_CHUNK neighbors[1] = xChunks[chunkYRow1] or -1
neighbors[4] = xChunks[y] or SENTINEL_IMPASSABLE_CHUNK neighbors[4] = xChunks[y] or -1
neighbors[6] = xChunks[chunkYRow3] or SENTINEL_IMPASSABLE_CHUNK neighbors[6] = xChunks[chunkYRow3] or -1
else else
neighbors[1] = SENTINEL_IMPASSABLE_CHUNK neighbors[1] = -1
neighbors[4] = SENTINEL_IMPASSABLE_CHUNK neighbors[4] = -1
neighbors[6] = SENTINEL_IMPASSABLE_CHUNK neighbors[6] = -1
end end
xChunks = map[x+CHUNK_SIZE] xChunks = map[x+CHUNK_SIZE]
if xChunks then if xChunks then
neighbors[3] = xChunks[chunkYRow1] or SENTINEL_IMPASSABLE_CHUNK neighbors[3] = xChunks[chunkYRow1] or -1
neighbors[5] = xChunks[y] or SENTINEL_IMPASSABLE_CHUNK neighbors[5] = xChunks[y] or -1
neighbors[8] = xChunks[chunkYRow3] or SENTINEL_IMPASSABLE_CHUNK neighbors[8] = xChunks[chunkYRow3] or -1
else else
neighbors[3] = SENTINEL_IMPASSABLE_CHUNK neighbors[3] = -1
neighbors[5] = SENTINEL_IMPASSABLE_CHUNK neighbors[5] = -1
neighbors[8] = SENTINEL_IMPASSABLE_CHUNK neighbors[8] = -1
end end
xChunks = map[x] xChunks = map[x]
if xChunks then if xChunks then
neighbors[2] = xChunks[chunkYRow1] or SENTINEL_IMPASSABLE_CHUNK neighbors[2] = xChunks[chunkYRow1] or -1
neighbors[7] = xChunks[chunkYRow3] or SENTINEL_IMPASSABLE_CHUNK neighbors[7] = xChunks[chunkYRow3] or -1
else else
neighbors[2] = SENTINEL_IMPASSABLE_CHUNK neighbors[2] = -1
neighbors[7] = SENTINEL_IMPASSABLE_CHUNK neighbors[7] = -1
end end
return neighbors return neighbors
end end
@@ -149,25 +147,25 @@ function mapUtils.getCardinalChunks(map, x, y)
local neighbors = map.cardinalNeighbors local neighbors = map.cardinalNeighbors
local xChunks = map[x] local xChunks = map[x]
if xChunks then if xChunks then
neighbors[1] = xChunks[y-CHUNK_SIZE] or SENTINEL_IMPASSABLE_CHUNK neighbors[1] = xChunks[y-CHUNK_SIZE] or -1
neighbors[4] = xChunks[y+CHUNK_SIZE] or SENTINEL_IMPASSABLE_CHUNK neighbors[4] = xChunks[y+CHUNK_SIZE] or -1
else else
neighbors[1] = SENTINEL_IMPASSABLE_CHUNK neighbors[1] = -1
neighbors[4] = SENTINEL_IMPASSABLE_CHUNK neighbors[4] = -1
end end
xChunks = map[x-CHUNK_SIZE] xChunks = map[x-CHUNK_SIZE]
if xChunks then if xChunks then
neighbors[2] = xChunks[y] or SENTINEL_IMPASSABLE_CHUNK neighbors[2] = xChunks[y] or -1
else else
neighbors[2] = SENTINEL_IMPASSABLE_CHUNK neighbors[2] = -1
end end
xChunks = map[x+CHUNK_SIZE] xChunks = map[x+CHUNK_SIZE]
if xChunks then if xChunks then
neighbors[3] = xChunks[y] or SENTINEL_IMPASSABLE_CHUNK neighbors[3] = xChunks[y] or -1
else else
neighbors[3] = SENTINEL_IMPASSABLE_CHUNK neighbors[3] = -1
end end
return neighbors return neighbors
end end

View File

@@ -15,8 +15,6 @@ local MOVEMENT_PENALTY_AMOUNT = constants.MOVEMENT_PENALTY_AMOUNT
local MAGIC_MAXIMUM_NUMBER = constants.MAGIC_MAXIMUM_NUMBER local MAGIC_MAXIMUM_NUMBER = constants.MAGIC_MAXIMUM_NUMBER
local SENTINEL_IMPASSABLE_CHUNK = constants.SENTINEL_IMPASSABLE_CHUNK
-- imported functions -- imported functions
local canMoveChunkDirection = mapUtils.canMoveChunkDirection local canMoveChunkDirection = mapUtils.canMoveChunkDirection
@@ -56,6 +54,9 @@ function movementUtils.findMovementPositionDistort(surface, position)
end end
function movementUtils.addMovementPenalty(units, chunk) function movementUtils.addMovementPenalty(units, chunk)
if (chunk == -1) or (squadChunk == chunk) then
return
end
local penalties = units.penalties local penalties = units.penalties
for i=1,#penalties do for i=1,#penalties do
local penalty = penalties[i] local penalty = penalties[i]
@@ -88,36 +89,37 @@ end
Expects all neighbors adjacent to a chunk Expects all neighbors adjacent to a chunk
--]] --]]
function movementUtils.scoreNeighborsForAttack(map, chunk, neighborDirectionChunks, scoreFunction, squad) function movementUtils.scoreNeighborsForAttack(map, chunk, neighborDirectionChunks, scoreFunction, squad)
local highestChunk = SENTINEL_IMPASSABLE_CHUNK local highestChunk = -1
local highestScore = -MAGIC_MAXIMUM_NUMBER local highestScore = -MAGIC_MAXIMUM_NUMBER
local highestDirection local highestDirection
local nextHighestChunk = SENTINEL_IMPASSABLE_CHUNK local nextHighestChunk = -1
local nextHighestScore = -MAGIC_MAXIMUM_NUMBER local nextHighestScore = -MAGIC_MAXIMUM_NUMBER
local nextHighestDirection local nextHighestDirection
local natives = map.natives local natives = map.natives
for x=1,8 do for x=1,8 do
local neighborChunk = neighborDirectionChunks[x] local neighborChunk = neighborDirectionChunks[x]
if ((neighborChunk ~= SENTINEL_IMPASSABLE_CHUNK) and canMoveChunkDirection(map, x, chunk, neighborChunk)) or if (neighborChunk ~= -1) then
(chunk == SENTINEL_IMPASSABLE_CHUNK) then if canMoveChunkDirection(map, x, chunk, neighborChunk) or (chunk == -1) then
local score = scoreFunction(natives, squad, neighborChunk) local score = scoreFunction(natives, squad, neighborChunk)
if (score > highestScore) then if (score > highestScore) then
highestScore = score highestScore = score
highestChunk = neighborChunk highestChunk = neighborChunk
highestDirection = x highestDirection = x
end
end end
end end
end end
if (highestChunk ~= SENTINEL_IMPASSABLE_CHUNK) then if (highestChunk ~= -1) then
neighborDirectionChunks = getNeighborChunks(map, highestChunk.x, highestChunk.y) neighborDirectionChunks = getNeighborChunks(map, highestChunk.x, highestChunk.y)
for x=1,8 do for x=1,8 do
local neighborChunk = neighborDirectionChunks[x] local neighborChunk = neighborDirectionChunks[x]
if ((neighborChunk ~= SENTINEL_IMPASSABLE_CHUNK) and (neighborChunk ~= chunk) and if ((neighborChunk ~= -1) and (neighborChunk ~= chunk) and
canMoveChunkDirection(map, x, highestChunk, neighborChunk)) then canMoveChunkDirection(map, x, highestChunk, neighborChunk)) then
local score = scoreFunction(natives, squad, neighborChunk) local score = scoreFunction(natives, squad, neighborChunk)
if (score > nextHighestScore) then if (score > nextHighestScore) then
@@ -130,7 +132,7 @@ function movementUtils.scoreNeighborsForAttack(map, chunk, neighborDirectionChun
end end
if (nextHighestChunk == nil) then if (nextHighestChunk == nil) then
nextHighestChunk = SENTINEL_IMPASSABLE_CHUNK nextHighestChunk = -1
end end
return highestChunk, highestDirection, nextHighestChunk, nextHighestDirection return highestChunk, highestDirection, nextHighestChunk, nextHighestDirection
@@ -141,37 +143,38 @@ end
Expects all neighbors adjacent to a chunk Expects all neighbors adjacent to a chunk
--]] --]]
function movementUtils.scoreNeighborsForSettling(map, chunk, neighborDirectionChunks, scoreFunction, squad) function movementUtils.scoreNeighborsForSettling(map, chunk, neighborDirectionChunks, scoreFunction, squad)
local highestChunk = SENTINEL_IMPASSABLE_CHUNK local highestChunk = -1
local highestScore = -MAGIC_MAXIMUM_NUMBER local highestScore = -MAGIC_MAXIMUM_NUMBER
local highestDirection = 0 local highestDirection = 0
for x=1,8 do for x=1,8 do
local neighborChunk = neighborDirectionChunks[x] local neighborChunk = neighborDirectionChunks[x]
if ((neighborChunk ~= SENTINEL_IMPASSABLE_CHUNK) and canMoveChunkDirection(map, x, chunk, neighborChunk)) or if (neighborChunk ~= -1) then
(chunk == SENTINEL_IMPASSABLE_CHUNK) then if canMoveChunkDirection(map, x, chunk, neighborChunk) or (chunk == -1) then
local score = scoreFunction(squad, neighborChunk) local score = scoreFunction(squad, neighborChunk)
if (score > highestScore) then if (score > highestScore) then
highestScore = score highestScore = score
highestChunk = neighborChunk highestChunk = neighborChunk
highestDirection = x highestDirection = x
end
end end
end end
end end
if (chunk ~= SENTINEL_IMPASSABLE_CHUNK) and (scoreFunction(squad, chunk) > highestScore) then if (chunk ~= -1) and (scoreFunction(squad, chunk) > highestScore) then
return chunk, 0, SENTINEL_IMPASSABLE_CHUNK, 0 return chunk, 0, -1, 0
end end
local nextHighestChunk = SENTINEL_IMPASSABLE_CHUNK local nextHighestChunk = -1
local nextHighestScore = -MAGIC_MAXIMUM_NUMBER local nextHighestScore = -MAGIC_MAXIMUM_NUMBER
local nextHighestDirection = 0 local nextHighestDirection = 0
if (highestChunk ~= SENTINEL_IMPASSABLE_CHUNK) then if (highestChunk ~= -1) then
neighborDirectionChunks = getNeighborChunks(map, highestChunk.x, highestChunk.y) neighborDirectionChunks = getNeighborChunks(map, highestChunk.x, highestChunk.y)
for x=1,8 do for x=1,8 do
local neighborChunk = neighborDirectionChunks[x] local neighborChunk = neighborDirectionChunks[x]
if ((neighborChunk ~= SENTINEL_IMPASSABLE_CHUNK) and (neighborChunk ~= chunk) and if ((neighborChunk ~= -1) and (neighborChunk ~= chunk) and
canMoveChunkDirection(map, x, highestChunk, neighborChunk)) then canMoveChunkDirection(map, x, highestChunk, neighborChunk)) then
local score = scoreFunction(squad, neighborChunk) local score = scoreFunction(squad, neighborChunk)
if (score > nextHighestScore) then if (score > nextHighestScore) then
@@ -190,12 +193,12 @@ end
Expects all neighbors adjacent to a chunk Expects all neighbors adjacent to a chunk
--]] --]]
function movementUtils.scoreNeighborsForResource(chunk, neighborDirectionChunks, validFunction, scoreFunction, map) function movementUtils.scoreNeighborsForResource(chunk, neighborDirectionChunks, validFunction, scoreFunction, map)
local highestChunk = SENTINEL_IMPASSABLE_CHUNK local highestChunk = -1
local highestScore = -MAGIC_MAXIMUM_NUMBER local highestScore = -MAGIC_MAXIMUM_NUMBER
local highestDirection local highestDirection
for x=1,8 do for x=1,8 do
local neighborChunk = neighborDirectionChunks[x] local neighborChunk = neighborDirectionChunks[x]
if (neighborChunk ~= SENTINEL_IMPASSABLE_CHUNK) 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(neighborChunk) local score = scoreFunction(neighborChunk)
if (score > highestScore) then if (score > highestScore) then
highestScore = score highestScore = score
@@ -205,8 +208,8 @@ function movementUtils.scoreNeighborsForResource(chunk, neighborDirectionChunks,
end end
end end
if (chunk ~= SENTINEL_IMPASSABLE_CHUNK) and (scoreFunction(chunk) > highestScore) then if (chunk ~= -1) and (scoreFunction(chunk) > highestScore) then
return SENTINEL_IMPASSABLE_CHUNK, -1 return -1, -1
end end
return highestChunk, highestDirection return highestChunk, highestDirection
@@ -216,33 +219,34 @@ end
Expects all neighbors adjacent to a chunk Expects all neighbors adjacent to a chunk
--]] --]]
function movementUtils.scoreNeighborsForRetreat(chunk, neighborDirectionChunks, scoreFunction, map) function movementUtils.scoreNeighborsForRetreat(chunk, neighborDirectionChunks, scoreFunction, map)
local highestChunk = SENTINEL_IMPASSABLE_CHUNK local highestChunk = -1
local highestScore = -MAGIC_MAXIMUM_NUMBER local highestScore = -MAGIC_MAXIMUM_NUMBER
local highestDirection local highestDirection
local nextHighestChunk = SENTINEL_IMPASSABLE_CHUNK local nextHighestChunk = -1
local nextHighestScore = -MAGIC_MAXIMUM_NUMBER local nextHighestScore = -MAGIC_MAXIMUM_NUMBER
local nextHighestDirection local nextHighestDirection
for x=1,8 do for x=1,8 do
local neighborChunk = neighborDirectionChunks[x] local neighborChunk = neighborDirectionChunks[x]
if ((neighborChunk ~= SENTINEL_IMPASSABLE_CHUNK) and canMoveChunkDirection(map, x, chunk, neighborChunk)) or if (neighborChunk ~= -1) then
(chunk == SENTINEL_IMPASSABLE_CHUNK) then if canMoveChunkDirection(map, x, chunk, neighborChunk) or (chunk == -1) then
local score = scoreFunction(map, neighborChunk) local score = scoreFunction(map, neighborChunk)
if (score > highestScore) then if (score > highestScore) then
highestScore = score highestScore = score
highestChunk = neighborChunk highestChunk = neighborChunk
highestDirection = x highestDirection = x
end
end end
end end
end end
if (highestChunk ~= SENTINEL_IMPASSABLE_CHUNK) then if (highestChunk ~= -1) then
neighborDirectionChunks = getNeighborChunks(map, highestChunk.x, highestChunk.y) neighborDirectionChunks = getNeighborChunks(map, highestChunk.x, highestChunk.y)
for x=1,8 do for x=1,8 do
local neighborChunk = neighborDirectionChunks[x] local neighborChunk = neighborDirectionChunks[x]
if ((neighborChunk ~= SENTINEL_IMPASSABLE_CHUNK) and (neighborChunk ~= chunk) and if ((neighborChunk ~= -1) and (neighborChunk ~= chunk) and
canMoveChunkDirection(map, x, highestChunk, neighborChunk)) then canMoveChunkDirection(map, x, highestChunk, neighborChunk)) then
local score = scoreFunction(map, neighborChunk) local score = scoreFunction(map, neighborChunk)
if (score > nextHighestScore) then if (score > nextHighestScore) then
@@ -255,7 +259,7 @@ function movementUtils.scoreNeighborsForRetreat(chunk, neighborDirectionChunks,
end end
if (nextHighestChunk == nil) then if (nextHighestChunk == nil) then
nextHighestChunk = SENTINEL_IMPASSABLE_CHUNK nextHighestChunk = -1
end end
return highestChunk, highestDirection, nextHighestChunk, nextHighestDirection return highestChunk, highestDirection, nextHighestChunk, nextHighestDirection
@@ -266,12 +270,12 @@ end
Expects all neighbors adjacent to a chunk Expects all neighbors adjacent to a chunk
--]] --]]
function movementUtils.scoreNeighborsForFormation(neighborChunks, validFunction, scoreFunction, map) function movementUtils.scoreNeighborsForFormation(neighborChunks, validFunction, scoreFunction, map)
local highestChunk = SENTINEL_IMPASSABLE_CHUNK local highestChunk = -1
local highestScore = -MAGIC_MAXIMUM_NUMBER local highestScore = -MAGIC_MAXIMUM_NUMBER
local highestDirection local highestDirection
for x=1,8 do for x=1,8 do
local neighborChunk = neighborChunks[x] local neighborChunk = neighborChunks[x]
if (neighborChunk ~= SENTINEL_IMPASSABLE_CHUNK) and validFunction(map, neighborChunk) then if (neighborChunk ~= -1) and validFunction(map, neighborChunk) then
local score = scoreFunction(neighborChunk) local score = scoreFunction(neighborChunk)
if (score > highestScore) then if (score > highestScore) then
highestScore = score highestScore = score

View File

@@ -25,7 +25,6 @@ local RESOURCE_PHEROMONE = constants.RESOURCE_PHEROMONE
local BUILDING_PHEROMONES = constants.BUILDING_PHEROMONES local BUILDING_PHEROMONES = constants.BUILDING_PHEROMONES
local VICTORY_SCENT = constants.VICTORY_SCENT local VICTORY_SCENT = constants.VICTORY_SCENT
local SENTINEL_IMPASSABLE_CHUNK = constants.SENTINEL_IMPASSABLE_CHUNK
local PLAYER_PHEROMONE_GENERATOR_AMOUNT = constants.PLAYER_PHEROMONE_GENERATOR_AMOUNT local PLAYER_PHEROMONE_GENERATOR_AMOUNT = constants.PLAYER_PHEROMONE_GENERATOR_AMOUNT
@@ -116,7 +115,7 @@ function pheromoneUtils.processPheromone(map, chunk, staging)
if (chunkPass == CHUNK_ALL_DIRECTIONS) then if (chunkPass == CHUNK_ALL_DIRECTIONS) then
neighbor = tempNeighbors[2] neighbor = tempNeighbors[2]
neighborPass = getPassable(map, neighbor) neighborPass = getPassable(map, neighbor)
if ((neighbor ~= SENTINEL_IMPASSABLE_CHUNK) and if ((neighbor ~= -1) and
((neighborPass == CHUNK_ALL_DIRECTIONS) or (neighborPass == CHUNK_NORTH_SOUTH))) then ((neighborPass == CHUNK_ALL_DIRECTIONS) or (neighborPass == CHUNK_NORTH_SOUTH))) then
neighborCount = neighborCount + 1 neighborCount = neighborCount + 1
movementTotal = movementTotal + (neighbor[MOVEMENT_PHEROMONE] - chunkMovement) movementTotal = movementTotal + (neighbor[MOVEMENT_PHEROMONE] - chunkMovement)
@@ -127,7 +126,7 @@ function pheromoneUtils.processPheromone(map, chunk, staging)
neighbor = tempNeighbors[7] neighbor = tempNeighbors[7]
neighborPass = getPassable(map, neighbor) neighborPass = getPassable(map, neighbor)
if ((neighbor ~= SENTINEL_IMPASSABLE_CHUNK) and if ((neighbor ~= -1) and
((neighborPass == CHUNK_ALL_DIRECTIONS) or (neighborPass == CHUNK_NORTH_SOUTH))) then ((neighborPass == CHUNK_ALL_DIRECTIONS) or (neighborPass == CHUNK_NORTH_SOUTH))) then
neighborCount = neighborCount + 1 neighborCount = neighborCount + 1
movementTotal = movementTotal + (neighbor[MOVEMENT_PHEROMONE] - chunkMovement) movementTotal = movementTotal + (neighbor[MOVEMENT_PHEROMONE] - chunkMovement)
@@ -138,7 +137,7 @@ function pheromoneUtils.processPheromone(map, chunk, staging)
neighbor = tempNeighbors[4] neighbor = tempNeighbors[4]
neighborPass = getPassable(map, neighbor) neighborPass = getPassable(map, neighbor)
if ((neighbor ~= SENTINEL_IMPASSABLE_CHUNK) and if ((neighbor ~= -1) and
((neighborPass == CHUNK_ALL_DIRECTIONS) or (neighborPass == CHUNK_EAST_WEST))) then ((neighborPass == CHUNK_ALL_DIRECTIONS) or (neighborPass == CHUNK_EAST_WEST))) then
neighborCount = neighborCount + 1 neighborCount = neighborCount + 1
movementTotal = movementTotal + (neighbor[MOVEMENT_PHEROMONE] - chunkMovement) movementTotal = movementTotal + (neighbor[MOVEMENT_PHEROMONE] - chunkMovement)
@@ -149,7 +148,7 @@ function pheromoneUtils.processPheromone(map, chunk, staging)
neighbor = tempNeighbors[5] neighbor = tempNeighbors[5]
neighborPass = getPassable(map, neighbor) neighborPass = getPassable(map, neighbor)
if ((neighbor ~= SENTINEL_IMPASSABLE_CHUNK) and if ((neighbor ~= -1) and
((neighborPass == CHUNK_ALL_DIRECTIONS) or (neighborPass == CHUNK_EAST_WEST))) then ((neighborPass == CHUNK_ALL_DIRECTIONS) or (neighborPass == CHUNK_EAST_WEST))) then
neighborCount = neighborCount + 1 neighborCount = neighborCount + 1
movementTotal = movementTotal + (neighbor[MOVEMENT_PHEROMONE] - chunkMovement) movementTotal = movementTotal + (neighbor[MOVEMENT_PHEROMONE] - chunkMovement)
@@ -160,7 +159,7 @@ function pheromoneUtils.processPheromone(map, chunk, staging)
neighbor = tempNeighbors[1] neighbor = tempNeighbors[1]
neighborPass = getPassable(map, neighbor) neighborPass = getPassable(map, neighbor)
if (neighbor ~= SENTINEL_IMPASSABLE_CHUNK) and (neighborPass == CHUNK_ALL_DIRECTIONS) then if (neighbor ~= -1) and (neighborPass == CHUNK_ALL_DIRECTIONS) then
neighborCount = neighborCount + 1 neighborCount = neighborCount + 1
movementTotal = movementTotal + (neighbor[MOVEMENT_PHEROMONE] - chunkMovement) movementTotal = movementTotal + (neighbor[MOVEMENT_PHEROMONE] - chunkMovement)
baseTotal = baseTotal + (neighbor[BASE_PHEROMONE] - chunkBase) baseTotal = baseTotal + (neighbor[BASE_PHEROMONE] - chunkBase)
@@ -170,7 +169,7 @@ function pheromoneUtils.processPheromone(map, chunk, staging)
neighbor = tempNeighbors[3] neighbor = tempNeighbors[3]
neighborPass = getPassable(map, neighbor) neighborPass = getPassable(map, neighbor)
if (neighbor ~= SENTINEL_IMPASSABLE_CHUNK) and (neighborPass == CHUNK_ALL_DIRECTIONS) then if (neighbor ~= -1) and (neighborPass == CHUNK_ALL_DIRECTIONS) then
neighborCount = neighborCount + 1 neighborCount = neighborCount + 1
movementTotal = movementTotal + (neighbor[MOVEMENT_PHEROMONE] - chunkMovement) movementTotal = movementTotal + (neighbor[MOVEMENT_PHEROMONE] - chunkMovement)
baseTotal = baseTotal + (neighbor[BASE_PHEROMONE] - chunkBase) baseTotal = baseTotal + (neighbor[BASE_PHEROMONE] - chunkBase)
@@ -180,7 +179,7 @@ function pheromoneUtils.processPheromone(map, chunk, staging)
neighbor = tempNeighbors[6] neighbor = tempNeighbors[6]
neighborPass = getPassable(map, neighbor) neighborPass = getPassable(map, neighbor)
if (neighbor ~= SENTINEL_IMPASSABLE_CHUNK) and (neighborPass == CHUNK_ALL_DIRECTIONS) then if (neighbor ~= -1) and (neighborPass == CHUNK_ALL_DIRECTIONS) then
neighborCount = neighborCount + 1 neighborCount = neighborCount + 1
movementTotal = movementTotal + (neighbor[MOVEMENT_PHEROMONE] - chunkMovement) movementTotal = movementTotal + (neighbor[MOVEMENT_PHEROMONE] - chunkMovement)
baseTotal = baseTotal + (neighbor[BASE_PHEROMONE] - chunkBase) baseTotal = baseTotal + (neighbor[BASE_PHEROMONE] - chunkBase)
@@ -190,7 +189,7 @@ function pheromoneUtils.processPheromone(map, chunk, staging)
neighbor = tempNeighbors[8] neighbor = tempNeighbors[8]
neighborPass = getPassable(map, neighbor) neighborPass = getPassable(map, neighbor)
if (neighbor ~= SENTINEL_IMPASSABLE_CHUNK) and (neighborPass == CHUNK_ALL_DIRECTIONS) then if (neighbor ~= -1) and (neighborPass == CHUNK_ALL_DIRECTIONS) then
neighborCount = neighborCount + 1 neighborCount = neighborCount + 1
movementTotal = movementTotal + (neighbor[MOVEMENT_PHEROMONE] - chunkMovement) movementTotal = movementTotal + (neighbor[MOVEMENT_PHEROMONE] - chunkMovement)
baseTotal = baseTotal + (neighbor[BASE_PHEROMONE] - chunkBase) baseTotal = baseTotal + (neighbor[BASE_PHEROMONE] - chunkBase)
@@ -202,7 +201,7 @@ function pheromoneUtils.processPheromone(map, chunk, staging)
neighbor = tempNeighbors[4] neighbor = tempNeighbors[4]
neighborPass = getPassable(map, neighbor) neighborPass = getPassable(map, neighbor)
if ((neighbor ~= SENTINEL_IMPASSABLE_CHUNK) and if ((neighbor ~= -1) and
((neighborPass == CHUNK_ALL_DIRECTIONS) or (neighborPass == CHUNK_EAST_WEST))) then ((neighborPass == CHUNK_ALL_DIRECTIONS) or (neighborPass == CHUNK_EAST_WEST))) then
neighborCount = neighborCount + 1 neighborCount = neighborCount + 1
movementTotal = movementTotal + (neighbor[MOVEMENT_PHEROMONE] - chunkMovement) movementTotal = movementTotal + (neighbor[MOVEMENT_PHEROMONE] - chunkMovement)
@@ -213,7 +212,7 @@ function pheromoneUtils.processPheromone(map, chunk, staging)
neighbor = tempNeighbors[5] neighbor = tempNeighbors[5]
neighborPass = getPassable(map, neighbor) neighborPass = getPassable(map, neighbor)
if ((neighbor ~= SENTINEL_IMPASSABLE_CHUNK) and if ((neighbor ~= -1) and
((neighborPass == CHUNK_ALL_DIRECTIONS) or (neighborPass == CHUNK_EAST_WEST))) then ((neighborPass == CHUNK_ALL_DIRECTIONS) or (neighborPass == CHUNK_EAST_WEST))) then
neighborCount = neighborCount + 1 neighborCount = neighborCount + 1
movementTotal = movementTotal + (neighbor[MOVEMENT_PHEROMONE] - chunkMovement) movementTotal = movementTotal + (neighbor[MOVEMENT_PHEROMONE] - chunkMovement)
@@ -226,7 +225,7 @@ function pheromoneUtils.processPheromone(map, chunk, staging)
neighbor = tempNeighbors[2] neighbor = tempNeighbors[2]
neighborPass = getPassable(map, neighbor) neighborPass = getPassable(map, neighbor)
if ((neighbor ~= SENTINEL_IMPASSABLE_CHUNK) and if ((neighbor ~= -1) and
((neighborPass == CHUNK_ALL_DIRECTIONS) or (neighborPass == CHUNK_NORTH_SOUTH))) then ((neighborPass == CHUNK_ALL_DIRECTIONS) or (neighborPass == CHUNK_NORTH_SOUTH))) then
neighborCount = neighborCount + 1 neighborCount = neighborCount + 1
movementTotal = movementTotal + (neighbor[MOVEMENT_PHEROMONE] - chunkMovement) movementTotal = movementTotal + (neighbor[MOVEMENT_PHEROMONE] - chunkMovement)
@@ -237,7 +236,7 @@ function pheromoneUtils.processPheromone(map, chunk, staging)
neighbor = tempNeighbors[7] neighbor = tempNeighbors[7]
neighborPass = getPassable(map, neighbor) neighborPass = getPassable(map, neighbor)
if ((neighbor ~= SENTINEL_IMPASSABLE_CHUNK) and if ((neighbor ~= -1) and
((neighborPass == CHUNK_ALL_DIRECTIONS) or (neighborPass == CHUNK_NORTH_SOUTH))) then ((neighborPass == CHUNK_ALL_DIRECTIONS) or (neighborPass == CHUNK_NORTH_SOUTH))) then
neighborCount = neighborCount + 1 neighborCount = neighborCount + 1
movementTotal = movementTotal + (neighbor[MOVEMENT_PHEROMONE] - chunkMovement) movementTotal = movementTotal + (neighbor[MOVEMENT_PHEROMONE] - chunkMovement)

View File

@@ -12,6 +12,7 @@ local movementUtils = require("MovementUtils")
local mathUtils = require("MathUtils") local mathUtils = require("MathUtils")
local chunkPropertyUtils = require("ChunkPropertyUtils") local chunkPropertyUtils = require("ChunkPropertyUtils")
local chunkUtils = require("ChunkUtils") local chunkUtils = require("ChunkUtils")
local aiPredicates = require("AIPredicates")
-- constants -- constants
@@ -48,14 +49,14 @@ local DEFINES_DISTRACTION_NONE = defines.distraction.none
local DEFINES_DISTRACTION_BY_ENEMY = defines.distraction.by_enemy local DEFINES_DISTRACTION_BY_ENEMY = defines.distraction.by_enemy
local DEFINES_DISTRACTION_BY_ANYTHING = defines.distraction.by_anything local DEFINES_DISTRACTION_BY_ANYTHING = defines.distraction.by_anything
local SENTINEL_IMPASSABLE_CHUNK = constants.SENTINEL_IMPASSABLE_CHUNK
-- imported functions -- imported functions
local mRandom = math.random local mRandom = math.random
local mMin = math.min local mMin = math.min
local tRemove = table.remove local tRemove = table.remove
local canMigrate = aiPredicates.canMigrate
local euclideanDistancePoints = mathUtils.euclideanDistancePoints local euclideanDistancePoints = mathUtils.euclideanDistancePoints
local findMovementPosition = movementUtils.findMovementPosition local findMovementPosition = movementUtils.findMovementPosition
@@ -134,12 +135,8 @@ local function settleMove(map, squad, surface)
if (natives.state == AI_STATE_SIEGE) then if (natives.state == AI_STATE_SIEGE) then
scoreFunction = scoreSiegeLocation scoreFunction = scoreSiegeLocation
end end
if squad.chunk and (squad.chunk ~= SENTINEL_IMPASSABLE_CHUNK) and (squad.chunk ~= chunk) then addMovementPenalty(squad, squad.chunk)
addMovementPenalty(squad, squad.chunk) addSquadToChunk(map, chunk, squad)
end
if (chunk ~= SENTINEL_IMPASSABLE_CHUNK) then
addSquadToChunk(map, chunk, squad)
end
local distance = euclideanDistancePoints(groupPosition.x, local distance = euclideanDistancePoints(groupPosition.x,
groupPosition.y, groupPosition.y,
squad.originPosition.x, squad.originPosition.x,
@@ -195,7 +192,7 @@ local function settleMove(map, squad, surface)
scoreFunction, scoreFunction,
squad) squad)
if (attackChunk == SENTINEL_IMPASSABLE_CHUNK) then if (attackChunk == -1) then
squad.cycles = 30 squad.cycles = 30
cmd = map.wonderCommand cmd = map.wonderCommand
group.set_command(cmd) group.set_command(cmd)
@@ -235,7 +232,7 @@ local function settleMove(map, squad, surface)
end end
end end
if (nextAttackChunk ~= SENTINEL_IMPASSABLE_CHUNK) then if (nextAttackChunk ~= -1) then
positionFromDirectionAndFlat(nextAttackDirection, targetPosition, targetPosition2) positionFromDirectionAndFlat(nextAttackDirection, targetPosition, targetPosition2)
position2 = findMovementPosition(surface, targetPosition2) position2 = findMovementPosition(surface, targetPosition2)
@@ -305,19 +302,15 @@ local function attackMove(map, squad, surface)
or scoreAttackLocation or scoreAttackLocation
local squadChunk = squad.chunk local squadChunk = squad.chunk
if (squadChunk ~= SENTINEL_IMPASSABLE_CHUNK) and (squadChunk ~= chunk) then addMovementPenalty(squad, squadChunk)
addMovementPenalty(squad, squadChunk) addSquadToChunk(map, chunk, squad)
end
if (chunk ~= SENTINEL_IMPASSABLE_CHUNK)then
addSquadToChunk(map, chunk, squad)
end
squad.frenzy = (squad.frenzy and (euclideanDistanceNamed(groupPosition, squad.frenzyPosition) < 100)) squad.frenzy = (squad.frenzy and (euclideanDistanceNamed(groupPosition, squad.frenzyPosition) < 100))
local attackChunk, attackDirection, nextAttackChunk, nextAttackDirection = scoreNeighborsForAttack(map, local attackChunk, attackDirection, nextAttackChunk, nextAttackDirection = scoreNeighborsForAttack(map,
chunk, chunk,
getNeighborChunks(map, x, y), getNeighborChunks(map, x, y),
attackScorer, attackScorer,
squad) squad)
if (attackChunk == SENTINEL_IMPASSABLE_CHUNK) then if (attackChunk == -1) then
squad.cycles = 30 squad.cycles = 30
cmd = map.wonderCommand cmd = map.wonderCommand
group.set_command(cmd) group.set_command(cmd)
@@ -359,7 +352,7 @@ local function attackMove(map, squad, surface)
local position2 local position2
if (nextAttackChunk ~= SENTINEL_IMPASSABLE_CHUNK) then if (nextAttackChunk ~= -1) then
positionFromDirectionAndFlat(nextAttackDirection, targetPosition, targetPosition2) positionFromDirectionAndFlat(nextAttackDirection, targetPosition, targetPosition2)
position2 = findMovementPosition(surface, targetPosition2) position2 = findMovementPosition(surface, targetPosition2)
@@ -436,9 +429,7 @@ function squadAttack.squadsDispatch(map, surface)
attackMove(map, squad, surface) attackMove(map, squad, surface)
else else
local chunk = getChunkByPosition(map, group.position) local chunk = getChunkByPosition(map, group.position)
if (chunk ~= SENTINEL_IMPASSABLE_CHUNK) then addSquadToChunk(map, chunk, squad)
addSquadToChunk(map, chunk, squad)
end
end end
elseif (status == SQUAD_SETTLING) then elseif (status == SQUAD_SETTLING) then
x = x + 1 x = x + 1
@@ -450,9 +441,7 @@ function squadAttack.squadsDispatch(map, surface)
settleMove(map, squad, surface) settleMove(map, squad, surface)
else else
local chunk = getChunkByPosition(map, group.position) local chunk = getChunkByPosition(map, group.position)
if (chunk ~= SENTINEL_IMPASSABLE_CHUNK) then addSquadToChunk(map, chunk, squad)
addSquadToChunk(map, chunk, squad)
end
end end
elseif (status == SQUAD_RETREATING) then elseif (status == SQUAD_RETREATING) then
if (groupState == DEFINES_GROUP_FINISHED) or if (groupState == DEFINES_GROUP_FINISHED) or
@@ -467,9 +456,7 @@ function squadAttack.squadsDispatch(map, surface)
squads[x] = squad squads[x] = squad
end end
local chunk = getChunkByPosition(map, group.position) local chunk = getChunkByPosition(map, group.position)
if (chunk ~= SENTINEL_IMPASSABLE_CHUNK) then addSquadToChunk(map, chunk, squad)
addSquadToChunk(map, chunk, squad)
end
elseif (status == SQUAD_BUILDING) then elseif (status == SQUAD_BUILDING) then
removeSquadFromChunk(map, squad) removeSquadFromChunk(map, squad)
natives.building[#natives.building+1] = squad natives.building[#natives.building+1] = squad
@@ -515,7 +502,8 @@ function squadAttack.squadsBeginAttack(natives, surface)
local group = pendingStealGroups[i] local group = pendingStealGroups[i]
if group and group.valid then if group and group.valid then
if (group.state ~= DEFINES_GROUP_GATHERING) then if (group.state ~= DEFINES_GROUP_GATHERING) then
local squad = createSquad(group.position, surface, nil, false) local settlers = canMigrate(natives, surface) and (mRandom() > 0.25)
local squad = createSquad(group.position, surface, nil, settlers)
pendingAttack.len = pendingAttack.len + 1 pendingAttack.len = pendingAttack.len + 1
pendingAttack[pendingAttack.len] = squad pendingAttack[pendingAttack.len] = squad
cmd.group = squad.group cmd.group = squad.group

View File

@@ -23,8 +23,6 @@ local SQUAD_RETREATING = constants.SQUAD_RETREATING
local INTERVAL_RETREAT = constants.INTERVAL_RETREAT local INTERVAL_RETREAT = constants.INTERVAL_RETREAT
local SENTINEL_IMPASSABLE_CHUNK = constants.SENTINEL_IMPASSABLE_CHUNK
-- imported functions -- imported functions
local mRandom = math.random local mRandom = math.random
@@ -92,7 +90,7 @@ function aiDefense.retreatUnits(chunk, position, squad, map, surface, tick, radi
chunk.y), chunk.y),
scoreRetreatLocation, scoreRetreatLocation,
map) map)
if (exitPath ~= SENTINEL_IMPASSABLE_CHUNK) then if (exitPath ~= -1) then
local targetPosition = map.position local targetPosition = map.position
local targetPosition2 = map.position2 local targetPosition2 = map.position2
@@ -104,7 +102,7 @@ function aiDefense.retreatUnits(chunk, position, squad, map, surface, tick, radi
return return
end end
if (nextExitPath ~= SENTINEL_IMPASSABLE_CHUNK) then if (nextExitPath ~= -1) then
positionFromDirectionAndFlat(nextExitDirection, retreatPosition, targetPosition2) positionFromDirectionAndFlat(nextExitDirection, retreatPosition, targetPosition2)
local retreatPosition2 = findMovementPosition(surface, targetPosition2) local retreatPosition2 = findMovementPosition(surface, targetPosition2)
@@ -142,7 +140,7 @@ function aiDefense.retreatUnits(chunk, position, squad, map, surface, tick, radi
end end
end end
if not newSquad.rapid then if not newSquad.rabid then
newSquad.frenzy = true newSquad.frenzy = true
local squadPosition = newSquad.group.position local squadPosition = newSquad.group.position
newSquad.frenzyPosition.x = squadPosition.x newSquad.frenzyPosition.x = squadPosition.x

View File

@@ -28,8 +28,6 @@ local NO_RETREAT_SQUAD_SIZE_BONUS_MAX = constants.NO_RETREAT_SQUAD_SIZE_BONUS_MA
local AI_MAX_BITER_GROUP_SIZE = constants.AI_MAX_BITER_GROUP_SIZE local AI_MAX_BITER_GROUP_SIZE = constants.AI_MAX_BITER_GROUP_SIZE
local AI_SQUAD_MERGE_THRESHOLD = constants.AI_SQUAD_MERGE_THRESHOLD local AI_SQUAD_MERGE_THRESHOLD = constants.AI_SQUAD_MERGE_THRESHOLD
local SENTINEL_IMPASSABLE_CHUNK = constants.SENTINEL_IMPASSABLE_CHUNK
-- imported functions -- imported functions
local tRemove = table.remove local tRemove = table.remove
@@ -63,7 +61,7 @@ function unitGroupUtils.findNearbyRetreatingSquad(map, chunk)
for i=1,#neighbors do for i=1,#neighbors do
local neighbor = neighbors[i] local neighbor = neighbors[i]
if neighbor ~= SENTINEL_IMPASSABLE_CHUNK then if neighbor ~= -1 then
squads = getSquadsOnChunk(map, neighbor) squads = getSquadsOnChunk(map, neighbor)
for squadIndex=1,#squads do for squadIndex=1,#squads do
local squad = squads[squadIndex] local squad = squads[squadIndex]
@@ -92,7 +90,7 @@ function unitGroupUtils.findNearbySquad(map, chunk)
for i=1,#neighbors do for i=1,#neighbors do
local neighbor = neighbors[i] local neighbor = neighbors[i]
if neighbor ~= SENTINEL_IMPASSABLE_CHUNK then if neighbor ~= -1 then
squads = getSquadsOnChunk(map, neighbor) squads = getSquadsOnChunk(map, neighbor)
for squadIndex=1,#squads do for squadIndex=1,#squads do
local squad = squads[squadIndex] local squad = squads[squadIndex]
@@ -125,7 +123,7 @@ function unitGroupUtils.createSquad(position, surface, group, settlers)
attackScoreFunction = 1, attackScoreFunction = 1,
originPosition = {x = 0, originPosition = {x = 0,
y = 0}, y = 0},
chunk = SENTINEL_IMPASSABLE_CHUNK chunk = -1
} }
if position then if position then
@@ -242,7 +240,7 @@ function unitGroupUtils.regroupSquads(natives)
local status = squad.status local status = squad.status
local chunk = squad.chunk local chunk = squad.chunk
if (chunk ~= SENTINEL_IMPASSABLE_CHUNK) then if (chunk ~= -1) then
local chunkSquads = getSquadsOnChunk(map, chunk) local chunkSquads = getSquadsOnChunk(map, chunk)
for p=1,#chunkSquads do for p=1,#chunkSquads do
local mergeSquad = chunkSquads[p] local mergeSquad = chunkSquads[p]

View File

@@ -465,7 +465,7 @@ data:extend({
description = "rampant-unitBiterHealthScaler", description = "rampant-unitBiterHealthScaler",
setting_type = "startup", setting_type = "startup",
default_value = 1.0, default_value = 1.0,
minimum_value = 0.0, minimum_value = 0.0001,
maximum_value = 100000.0, maximum_value = 100000.0,
order = "p[modifier]-a[unit]", order = "p[modifier]-a[unit]",
per_user = false per_user = false
@@ -477,7 +477,7 @@ data:extend({
description = "rampant-unitBiterHealingScaler", description = "rampant-unitBiterHealingScaler",
setting_type = "startup", setting_type = "startup",
default_value = 1.0, default_value = 1.0,
minimum_value = 0.0, minimum_value = 0.0001,
maximum_value = 100000.0, maximum_value = 100000.0,
order = "p[modifier]-a[unit]", order = "p[modifier]-a[unit]",
per_user = false per_user = false
@@ -489,7 +489,7 @@ data:extend({
description = "rampant-unitBiterSpeedScaler", description = "rampant-unitBiterSpeedScaler",
setting_type = "startup", setting_type = "startup",
default_value = 1.0, default_value = 1.0,
minimum_value = 0.0, minimum_value = 0.0001,
maximum_value = 100000.0, maximum_value = 100000.0,
order = "p[modifier]-b[unit]", order = "p[modifier]-b[unit]",
per_user = false per_user = false
@@ -501,7 +501,7 @@ data:extend({
description = "rampant-unitBiterDamageScaler", description = "rampant-unitBiterDamageScaler",
setting_type = "startup", setting_type = "startup",
default_value = 1.0, default_value = 1.0,
minimum_value = 0.0, minimum_value = 0.0001,
maximum_value = 100000.0, maximum_value = 100000.0,
order = "p[modifier]-c[unit]", order = "p[modifier]-c[unit]",
per_user = false per_user = false
@@ -513,7 +513,7 @@ data:extend({
description = "rampant-unitBiterRangeScaler", description = "rampant-unitBiterRangeScaler",
setting_type = "startup", setting_type = "startup",
default_value = 1.0, default_value = 1.0,
minimum_value = 0.0, minimum_value = 0.0001,
maximum_value = 100000.0, maximum_value = 100000.0,
order = "p[modifier]-d[unit]", order = "p[modifier]-d[unit]",
per_user = false per_user = false
@@ -525,7 +525,7 @@ data:extend({
description = "rampant-unitSpitterHealthScaler", description = "rampant-unitSpitterHealthScaler",
setting_type = "startup", setting_type = "startup",
default_value = 1.0, default_value = 1.0,
minimum_value = 0.0, minimum_value = 0.0001,
maximum_value = 100000.0, maximum_value = 100000.0,
order = "p[modifier]-e[unit]", order = "p[modifier]-e[unit]",
per_user = false per_user = false
@@ -537,7 +537,7 @@ data:extend({
description = "rampant-unitSpitterHealingScaler", description = "rampant-unitSpitterHealingScaler",
setting_type = "startup", setting_type = "startup",
default_value = 1.0, default_value = 1.0,
minimum_value = 0.0, minimum_value = 0.0001,
maximum_value = 100000.0, maximum_value = 100000.0,
order = "p[modifier]-e[unit]", order = "p[modifier]-e[unit]",
per_user = false per_user = false
@@ -549,7 +549,7 @@ data:extend({
description = "rampant-unitSpitterSpeedScaler", description = "rampant-unitSpitterSpeedScaler",
setting_type = "startup", setting_type = "startup",
default_value = 1.0, default_value = 1.0,
minimum_value = 0.0, minimum_value = 0.0001,
maximum_value = 100000.0, maximum_value = 100000.0,
order = "p[modifier]-f[unit]", order = "p[modifier]-f[unit]",
per_user = false per_user = false
@@ -561,7 +561,7 @@ data:extend({
description = "rampant-unitSpitterDamageScaler", description = "rampant-unitSpitterDamageScaler",
setting_type = "startup", setting_type = "startup",
default_value = 1.0, default_value = 1.0,
minimum_value = 0.0, minimum_value = 0.0001,
maximum_value = 100000.0, maximum_value = 100000.0,
order = "p[modifier]-g[unit]", order = "p[modifier]-g[unit]",
per_user = false per_user = false
@@ -573,7 +573,7 @@ data:extend({
description = "rampant-unitSpitterRangeScaler", description = "rampant-unitSpitterRangeScaler",
setting_type = "startup", setting_type = "startup",
default_value = 1.0, default_value = 1.0,
minimum_value = 0.0, minimum_value = 0.0001,
maximum_value = 100000.0, maximum_value = 100000.0,
order = "p[modifier]-h[unit]", order = "p[modifier]-h[unit]",
per_user = false per_user = false
@@ -585,7 +585,7 @@ data:extend({
description = "rampant-unitDroneHealthScaler", description = "rampant-unitDroneHealthScaler",
setting_type = "startup", setting_type = "startup",
default_value = 1.0, default_value = 1.0,
minimum_value = 0.0, minimum_value = 0.0001,
maximum_value = 100000.0, maximum_value = 100000.0,
order = "p[modifier]-i[unit]", order = "p[modifier]-i[unit]",
per_user = false per_user = false
@@ -597,7 +597,7 @@ data:extend({
description = "rampant-unitDroneHealingScaler", description = "rampant-unitDroneHealingScaler",
setting_type = "startup", setting_type = "startup",
default_value = 1.0, default_value = 1.0,
minimum_value = 0.0, minimum_value = 0.0001,
maximum_value = 100000.0, maximum_value = 100000.0,
order = "p[modifier]-i[unit]", order = "p[modifier]-i[unit]",
per_user = false per_user = false
@@ -609,7 +609,7 @@ data:extend({
description = "rampant-unitDroneSpeedScaler", description = "rampant-unitDroneSpeedScaler",
setting_type = "startup", setting_type = "startup",
default_value = 1.0, default_value = 1.0,
minimum_value = 0.0, minimum_value = 0.0001,
maximum_value = 100000.0, maximum_value = 100000.0,
order = "p[modifier]-j[unit]", order = "p[modifier]-j[unit]",
per_user = false per_user = false
@@ -621,7 +621,7 @@ data:extend({
description = "rampant-unitDroneDamageScaler", description = "rampant-unitDroneDamageScaler",
setting_type = "startup", setting_type = "startup",
default_value = 1.0, default_value = 1.0,
minimum_value = 0.0, minimum_value = 0.0001,
maximum_value = 100000.0, maximum_value = 100000.0,
order = "p[modifier]-k[unit]", order = "p[modifier]-k[unit]",
per_user = false per_user = false
@@ -633,7 +633,7 @@ data:extend({
description = "rampant-unitDroneRangeScaler", description = "rampant-unitDroneRangeScaler",
setting_type = "startup", setting_type = "startup",
default_value = 1.0, default_value = 1.0,
minimum_value = 0.0, minimum_value = 0.0001,
maximum_value = 100000.0, maximum_value = 100000.0,
order = "p[modifier]-l[unit]", order = "p[modifier]-l[unit]",
per_user = false per_user = false
@@ -645,7 +645,7 @@ data:extend({
description = "rampant-unitWormHealthScaler", description = "rampant-unitWormHealthScaler",
setting_type = "startup", setting_type = "startup",
default_value = 1.0, default_value = 1.0,
minimum_value = 0.0, minimum_value = 0.0001,
maximum_value = 100000.0, maximum_value = 100000.0,
order = "p[modifier]-m[unit]", order = "p[modifier]-m[unit]",
per_user = false per_user = false
@@ -657,7 +657,7 @@ data:extend({
description = "rampant-unitWormHealingScaler", description = "rampant-unitWormHealingScaler",
setting_type = "startup", setting_type = "startup",
default_value = 1.0, default_value = 1.0,
minimum_value = 0.0, minimum_value = 0.0001,
maximum_value = 100000.0, maximum_value = 100000.0,
order = "p[modifier]-m[unit]", order = "p[modifier]-m[unit]",
per_user = false per_user = false
@@ -669,7 +669,7 @@ data:extend({
description = "rampant-unitWormDamageScaler", description = "rampant-unitWormDamageScaler",
setting_type = "startup", setting_type = "startup",
default_value = 1.0, default_value = 1.0,
minimum_value = 0.0, minimum_value = 0.0001,
maximum_value = 100000.0, maximum_value = 100000.0,
order = "p[modifier]-n[unit]", order = "p[modifier]-n[unit]",
per_user = false per_user = false
@@ -681,7 +681,7 @@ data:extend({
description = "rampant-unitWormRangeScaler", description = "rampant-unitWormRangeScaler",
setting_type = "startup", setting_type = "startup",
default_value = 1.0, default_value = 1.0,
minimum_value = 0.0, minimum_value = 0.0001,
maximum_value = 100000.0, maximum_value = 100000.0,
order = "p[modifier]-o[unit]", order = "p[modifier]-o[unit]",
per_user = false per_user = false
@@ -693,7 +693,7 @@ data:extend({
description = "rampant-unitSpawnerHealthScaler", description = "rampant-unitSpawnerHealthScaler",
setting_type = "startup", setting_type = "startup",
default_value = 1.0, default_value = 1.0,
minimum_value = 0.0, minimum_value = 0.0001,
maximum_value = 100000.0, maximum_value = 100000.0,
order = "p[modifier]-p[unit]", order = "p[modifier]-p[unit]",
per_user = false per_user = false
@@ -705,7 +705,7 @@ data:extend({
description = "rampant-unitSpawnerHealingScaler", description = "rampant-unitSpawnerHealingScaler",
setting_type = "startup", setting_type = "startup",
default_value = 1.0, default_value = 1.0,
minimum_value = 0.0, minimum_value = 0.0001,
maximum_value = 100000.0, maximum_value = 100000.0,
order = "p[modifier]-p[unit]", order = "p[modifier]-p[unit]",
per_user = false per_user = false
@@ -717,7 +717,7 @@ data:extend({
description = "rampant-unitSpawnerOwnedScaler", description = "rampant-unitSpawnerOwnedScaler",
setting_type = "startup", setting_type = "startup",
default_value = 1.0, default_value = 1.0,
minimum_value = 0.0, minimum_value = 0.0001,
maximum_value = 100000.0, maximum_value = 100000.0,
order = "p[modifier]-q[unit]", order = "p[modifier]-q[unit]",
per_user = false per_user = false
@@ -729,7 +729,7 @@ data:extend({
description = "rampant-unitSpawnerSpawnScaler", description = "rampant-unitSpawnerSpawnScaler",
setting_type = "startup", setting_type = "startup",
default_value = 1.0, default_value = 1.0,
minimum_value = 0.0, minimum_value = 0.0001,
maximum_value = 100000.0, maximum_value = 100000.0,
order = "p[modifier]-r[unit]", order = "p[modifier]-r[unit]",
per_user = false per_user = false
@@ -741,7 +741,7 @@ data:extend({
description = "rampant-unitSpawnerRespawnScaler", description = "rampant-unitSpawnerRespawnScaler",
setting_type = "startup", setting_type = "startup",
default_value = 1.0, default_value = 1.0,
minimum_value = 0.0, minimum_value = 0.0001,
maximum_value = 100000.0, maximum_value = 100000.0,
order = "p[modifier]-r[unit]", order = "p[modifier]-r[unit]",
per_user = false per_user = false
@@ -754,7 +754,7 @@ data:extend({
description = "rampant-unitHiveRespawnScaler", description = "rampant-unitHiveRespawnScaler",
setting_type = "startup", setting_type = "startup",
default_value = 1.0, default_value = 1.0,
minimum_value = 0.0, minimum_value = 0.0001,
maximum_value = 100000.0, maximum_value = 100000.0,
order = "p[modifier]-r[unit]", order = "p[modifier]-r[unit]",
per_user = false per_user = false
@@ -766,7 +766,7 @@ data:extend({
description = "rampant-unitHiveHealthScaler", description = "rampant-unitHiveHealthScaler",
setting_type = "startup", setting_type = "startup",
default_value = 1.0, default_value = 1.0,
minimum_value = 0.0, minimum_value = 0.0001,
maximum_value = 100000.0, maximum_value = 100000.0,
order = "p[modifier]-r[unit]", order = "p[modifier]-r[unit]",
per_user = false per_user = false
@@ -778,7 +778,7 @@ data:extend({
description = "rampant-unitHiveHealingScaler", description = "rampant-unitHiveHealingScaler",
setting_type = "startup", setting_type = "startup",
default_value = 1.0, default_value = 1.0,
minimum_value = 0.0, minimum_value = 0.0001,
maximum_value = 100000.0, maximum_value = 100000.0,
order = "p[modifier]-r[unit]", order = "p[modifier]-r[unit]",
per_user = false per_user = false

View File

@@ -174,7 +174,7 @@ function tests.getOffsetChunk(x, y)
end end
function tests.aiStats() function tests.aiStats()
print(global.natives.points, game.tick, global.natives.state, global.natives.temperament, global.natives.stateTick, global.natives.temperamentTick) print(global.natives.points, game.tick, global.natives.state, global.natives.temperament, global.natives.stateTick, global.natives.temperamentTick, global.natives.activeNests, global.natives.activeRaidNests)
end end
function tests.fillableDirtTest() function tests.fillableDirtTest()