1
0
mirror of https://github.com/veden/Rampant.git synced 2025-01-10 00:28:31 +02:00
Rampant/control.lua

548 lines
19 KiB
Lua
Raw Normal View History

-- imports
2017-01-20 07:58:36 +02:00
local mapUtils = require("libs/MapUtils")
2016-08-07 05:38:47 +02:00
local unitGroupUtils = require("libs/UnitGroupUtils")
local chunkProcessor = require("libs/ChunkProcessor")
2017-05-19 09:47:24 +02:00
local baseProcessor = require("libs/BaseProcessor")
local mapProcessor = require("libs/MapProcessor")
local constants = require("libs/Constants")
local pheromoneUtils = require("libs/PheromoneUtils")
local squadDefense = require("libs/SquadDefense")
local squadAttack = require("libs/SquadAttack")
local aiAttackWave = require("libs/AIAttackWave")
2016-10-15 02:00:18 +02:00
local aiPlanning = require("libs/AIPlanning")
2017-05-06 11:03:28 +02:00
local interop = require("libs/Interop")
2016-08-22 00:59:17 +02:00
local tests = require("tests")
2017-11-21 09:27:03 +02:00
local chunkUtils = require("libs/ChunkUtils")
2017-05-19 09:47:24 +02:00
local upgrade = require("Upgrade")
2017-06-01 03:46:53 +02:00
local mathUtils = require("libs/MathUtils")
2017-06-01 09:03:07 +02:00
local config = require("config")
2016-10-15 02:00:18 +02:00
-- constants
local INTERVAL_LOGIC = constants.INTERVAL_LOGIC
local INTERVAL_PROCESS = constants.INTERVAL_PROCESS
local INTERVAL_CHUNK = constants.INTERVAL_CHUNK
local INTERVAL_SCAN = constants.INTERVAL_SCAN
local INTERVAL_SQUAD = constants.INTERVAL_SQUAD
2016-10-15 02:00:18 +02:00
2017-01-20 07:58:36 +02:00
local MOVEMENT_PHEROMONE = constants.MOVEMENT_PHEROMONE
2017-11-21 09:27:03 +02:00
local SENTINEL_IMPASSABLE_CHUNK = constants.SENTINEL_IMPASSABLE_CHUNK
2017-08-08 10:19:51 +02:00
2017-06-01 09:03:07 +02:00
local AI_MAX_OVERFLOW_POINTS = constants.AI_MAX_OVERFLOW_POINTS
local RETREAT_GRAB_RADIUS = constants.RETREAT_GRAB_RADIUS
local RETREAT_SPAWNER_GRAB_RADIUS = constants.RETREAT_SPAWNER_GRAB_RADIUS
2018-01-14 07:48:21 +02:00
local DEFINES_COMMAND_GROUP = defines.command.group
local DEFINES_COMMAND_ATTACK_AREA = defines.command.attack_area
local CHUNK_SIZE = constants.CHUNK_SIZE
local DEFINES_DISTRACTION_NONE = defines.distraction.none
local DEFINES_DISTRACTION_BY_ENEMY = defines.distraction.by_enemy
2017-06-01 03:46:53 +02:00
-- imported functions
2017-01-20 07:58:36 +02:00
2017-06-01 03:46:53 +02:00
local roundToNearest = mathUtils.roundToNearest
2017-01-20 07:58:36 +02:00
-- imported functions
2017-01-20 07:58:36 +02:00
local getChunkByPosition = mapUtils.getChunkByPosition
2018-01-02 20:36:23 +02:00
local entityForPassScan = chunkUtils.entityForPassScan
local processPendingChunks = chunkProcessor.processPendingChunks
local processScanChunks = chunkProcessor.processScanChunks
local processMap = mapProcessor.processMap
2016-10-15 02:00:18 +02:00
local processPlayers = mapProcessor.processPlayers
2016-08-29 02:05:28 +02:00
local scanMap = mapProcessor.scanMap
2016-10-15 02:00:18 +02:00
local planning = aiPlanning.planning
local rallyUnits = aiAttackWave.rallyUnits
2017-01-20 07:58:36 +02:00
local deathScent = pheromoneUtils.deathScent
2017-04-22 01:14:04 +02:00
local victoryScent = pheromoneUtils.victoryScent
local cleanSquads = unitGroupUtils.cleanSquads
local regroupSquads = unitGroupUtils.regroupSquads
local convertUnitGroupToSquad = unitGroupUtils.convertUnitGroupToSquad
local squadsAttack = squadAttack.squadsAttack
local squadsBeginAttack = squadAttack.squadsBeginAttack
local retreatUnits = squadDefense.retreatUnits
2017-11-21 09:27:03 +02:00
local addRemovePlayerEntity = chunkUtils.addRemovePlayerEntity
local unregisterEnemyBaseStructure = chunkUtils.unregisterEnemyBaseStructure
local registerEnemyBaseStructure = chunkUtils.registerEnemyBaseStructure
local makeImmortalEntity = chunkUtils.makeImmortalEntity
local positionToChunkXY = mapUtils.positionToChunkXY
2017-05-19 09:47:24 +02:00
local processBases = baseProcessor.processBases
2016-10-15 02:00:18 +02:00
local mRandom = math.random
2016-08-25 02:05:20 +02:00
-- local references to global
2018-01-14 07:48:21 +02:00
local map -- manages the chunks that make up the game world
local natives -- manages the enemy units, structures, and ai
local pendingChunks -- chunks that have yet to be processed by the mod
2016-08-25 02:05:20 +02:00
-- hook functions
2017-07-05 00:52:20 +02:00
local function onIonCannonFired(event)
--[[
event.force, event.surface, event.player_index, event.position, event.radius
--]]
local surface = event.surface
if (surface.index == 1) then
natives.points = natives.points + 3000
if (natives.points > AI_MAX_OVERFLOW_POINTS) then
natives.points = AI_MAX_OVERFLOW_POINTS
end
2018-01-14 07:48:21 +02:00
local chunk = getChunkByPosition(map, event.position)
2017-11-21 09:27:03 +02:00
if (chunk ~= SENTINEL_IMPASSABLE_CHUNK) then
2018-01-14 07:48:21 +02:00
rallyUnits(chunk, map, surface, natives, event.tick)
2017-07-05 00:52:20 +02:00
end
end
end
local function hookEvents()
if config.ionCannonPresent then
script.on_event(remote.call("orbital_ion_cannon", "on_ion_cannon_fired"),
onIonCannonFired)
-- script.on_event(remote.call("orbital_ion_cannon", "on_ion_cannon_targeted"),
-- onIonCannonTargeted)
end
end
2016-09-13 00:33:00 +02:00
local function onLoad()
2018-01-14 07:48:21 +02:00
map = global.map
2016-08-25 02:05:20 +02:00
natives = global.natives
pendingChunks = global.pendingChunks
2017-07-05 00:52:20 +02:00
hookEvents()
end
2016-09-13 00:33:00 +02:00
local function onChunkGenerated(event)
-- queue generated chunk for delayed processing, queuing is required because some mods (RSO) mess with chunk as they
-- are generated, which messes up the scoring.
if (event.surface.index == 1) then
pendingChunks[#pendingChunks+1] = event
end
2016-08-25 02:05:20 +02:00
end
2017-06-01 03:46:53 +02:00
local function rebuildRegionMap()
game.surfaces[1].print("Rampant - Reindexing chunks, please wait.")
2018-01-14 07:48:21 +02:00
-- clear old map processing Queue
2017-05-28 06:50:37 +02:00
-- prevents queue adding duplicate chunks
-- chunks are by key, so should overwrite old
2017-06-01 03:46:53 +02:00
2018-01-14 07:48:21 +02:00
global.map = {}
map = global.map
map.processQueue = {}
map.processIndex = 1
map.scanIndex = 1
map.chunkToHives = {}
map.chunkToNests = {}
map.chunkToWorms = {}
map.chunkToRetreats = {}
map.chunkToRallys = {}
map.chunkToPlayerBase = {}
map.chunkToResource = {}
map.chunkToPassScan = {}
map.chunkToSquad = {}
-- preallocating memory to be used in code, making it fast by reducing garbage generated.
2018-01-14 07:48:21 +02:00
map.neighbors = { SENTINEL_IMPASSABLE_CHUNK,
2017-11-21 09:27:03 +02:00
SENTINEL_IMPASSABLE_CHUNK,
SENTINEL_IMPASSABLE_CHUNK,
SENTINEL_IMPASSABLE_CHUNK,
SENTINEL_IMPASSABLE_CHUNK,
SENTINEL_IMPASSABLE_CHUNK,
SENTINEL_IMPASSABLE_CHUNK,
SENTINEL_IMPASSABLE_CHUNK }
2018-01-14 07:48:21 +02:00
map.cardinalNeighbors = { SENTINEL_IMPASSABLE_CHUNK,
2017-11-21 09:27:03 +02:00
SENTINEL_IMPASSABLE_CHUNK,
SENTINEL_IMPASSABLE_CHUNK,
SENTINEL_IMPASSABLE_CHUNK }
2018-01-14 07:48:21 +02:00
map.position = {x=0,
y=0}
2017-12-21 05:50:36 +02:00
--this is shared between two different queries
2018-01-14 07:48:21 +02:00
map.area = {{0, 0}, {0, 0}}
map.countResourcesQuery = { area=map.area, type="resource" }
map.filteredEntitiesEnemyQuery = { area=map.area, force="enemy" }
map.filteredEntitiesEnemyUnitQuery = { area=map.area, force="enemy", type="unit", limit=301 }
map.filteredEntitiesEnemyTypeQuery = { area=map.area, force="enemy", type="unit-spawner" }
map.filteredEntitiesPlayerQuery = { area=map.area, force="player" }
map.canPlaceQuery = { name="", position={0,0} }
map.filteredTilesQuery = { name="", area=map.area }
map.attackAreaCommand = {
type = DEFINES_COMMAND_ATTACK_AREA,
destination = map.position,
radius = CHUNK_SIZE,
distraction = DEFINES_DISTRACTION_BY_ENEMY
}
map.retreatCommand = { type = DEFINES_COMMAND_GROUP,
group = nil,
distraction = DEFINES_DISTRACTION_NONE }
2017-06-01 03:46:53 +02:00
-- switched over to tick event
2018-01-14 07:48:21 +02:00
map.logicTick = roundToNearest(game.tick + INTERVAL_LOGIC, INTERVAL_LOGIC)
map.scanTick = roundToNearest(game.tick + INTERVAL_SCAN, INTERVAL_SCAN)
map.processTick = roundToNearest(game.tick + INTERVAL_PROCESS, INTERVAL_PROCESS)
map.chunkTick = roundToNearest(game.tick + INTERVAL_CHUNK, INTERVAL_CHUNK)
map.squadTick = roundToNearest(game.tick + INTERVAL_SQUAD, INTERVAL_SQUAD)
2017-06-01 03:46:53 +02:00
2017-05-28 06:50:37 +02:00
-- clear pending chunks, will be added when loop runs below
2017-06-11 02:59:06 +02:00
global.pendingChunks = {}
pendingChunks = global.pendingChunks
2017-05-28 06:50:37 +02:00
-- queue all current chunks that wont be generated during play
local surface = game.surfaces[1]
2017-06-01 03:46:53 +02:00
local tick = game.tick
2017-05-28 06:50:37 +02:00
for chunk in surface.get_chunks() do
2017-06-01 03:46:53 +02:00
onChunkGenerated({ tick = tick,
2017-05-28 06:50:37 +02:00
surface = surface,
area = { left_top = { x = chunk.x * 32,
y = chunk.y * 32 }}})
2017-06-01 03:46:53 +02:00
end
2017-06-24 20:41:57 +02:00
2018-01-14 07:48:21 +02:00
processPendingChunks(natives, map, surface, pendingChunks, tick)
2017-05-28 06:50:37 +02:00
end
2017-05-06 11:03:28 +02:00
local function onModSettingsChange(event)
2017-05-27 02:58:33 +02:00
2017-05-06 11:03:28 +02:00
if event and (string.sub(event.setting, 1, 7) ~= "rampant") then
2017-05-28 06:50:37 +02:00
return false
2017-05-06 11:03:28 +02:00
end
2017-06-01 03:46:53 +02:00
upgrade.compareTable(natives, "safeBuildings", settings.global["rampant-safeBuildings"].value)
2017-05-06 11:03:28 +02:00
2017-06-01 03:46:53 +02:00
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, "train-stop", settings.global["rampant-safeBuildings-trainStops"].value)
2017-06-03 03:24:56 +02:00
upgrade.compareTable(natives.safeEntities, "lamp", settings.global["rampant-safeBuildings-lamps"].value)
2017-06-01 03:46:53 +02:00
local changed, newValue = upgrade.compareTable(natives.safeEntityName,
"big-electric-pole",
settings.global["rampant-safeBuildings-bigElectricPole"].value)
if changed then
natives.safeEntityName["big-electric-pole"] = newValue
natives.safeEntityName["big-electric-pole-2"] = newValue
natives.safeEntityName["big-electric-pole-3"] = newValue
natives.safeEntityName["big-electric-pole-4"] = newValue
end
2017-06-01 03:46:53 +02:00
upgrade.compareTable(natives, "attackUsePlayer", settings.global["rampant-attackWaveGenerationUsePlayerProximity"].value)
upgrade.compareTable(natives, "attackUsePollution", settings.global["rampant-attackWaveGenerationUsePollution"].value)
2017-05-06 11:03:28 +02:00
2017-06-01 03:46:53 +02:00
upgrade.compareTable(natives, "attackThresholdMin", settings.global["rampant-attackWaveGenerationThresholdMin"].value)
upgrade.compareTable(natives, "attackThresholdMax", settings.global["rampant-attackWaveGenerationThresholdMax"].value)
upgrade.compareTable(natives, "attackThresholdRange", natives.attackThresholdMax - natives.attackThresholdMin)
upgrade.compareTable(natives, "attackWaveMaxSize", settings.global["rampant-attackWaveMaxSize"].value)
upgrade.compareTable(natives, "attackPlayerThreshold", settings.global["rampant-attackPlayerThreshold"].value)
upgrade.compareTable(natives, "aiNocturnalMode", settings.global["rampant-permanentNocturnal"].value)
upgrade.compareTable(natives, "aiPointsScaler", settings.global["rampant-aiPointsScaler"].value)
2017-06-11 02:59:06 +02:00
-- RE-ENABLE WHEN COMPLETE
natives.useCustomAI = constants.DEV_CUSTOM_AI
-- changed, newValue = upgrade.compareTable(natives, "useCustomAI", settings.startup["rampant-useCustomAI"].value)
-- if natives.useCustomAI then
-- game.forces.enemy.ai_controllable = false
-- else
-- game.forces.enemy.ai_controllable = true
-- end
-- if changed and newValue then
-- rebuildRegionMap()
-- return false
-- end
2017-05-28 06:50:37 +02:00
return true
end
2017-05-27 02:58:33 +02:00
2017-05-28 06:50:37 +02:00
local function onConfigChanged()
local upgraded
2017-11-21 09:27:03 +02:00
upgraded, natives = upgrade.attempt(natives)
if upgraded and onModSettingsChange(nil) then
2017-06-01 03:46:53 +02:00
rebuildRegionMap()
2017-05-27 02:58:33 +02:00
end
end
2016-11-04 01:51:35 +02:00
local function onTick(event)
local tick = event.tick
2018-01-14 07:48:21 +02:00
if (tick == map.processTick) then
map.processTick = map.processTick + INTERVAL_PROCESS
local gameRef = game
2017-08-11 08:37:23 +02:00
local surface = gameRef.surfaces[1]
2018-01-14 07:48:21 +02:00
processPlayers(gameRef.players, map, surface, natives, tick)
2017-05-27 02:58:33 +02:00
2018-01-14 07:48:21 +02:00
processMap(map, surface, natives, tick)
end
2018-01-14 07:48:21 +02:00
if (tick == map.scanTick) then
map.scanTick = map.scanTick + INTERVAL_SCAN
local surface = game.surfaces[1]
2016-10-15 02:00:18 +02:00
2018-01-14 07:48:21 +02:00
processPendingChunks(natives, map, surface, pendingChunks, tick)
2017-01-20 07:58:36 +02:00
2018-01-14 07:48:21 +02:00
scanMap(map, surface, natives)
2018-01-14 07:48:21 +02:00
map.chunkToPassScan = processScanChunks(map, surface)
end
2018-01-14 07:48:21 +02:00
if (tick == map.logicTick) then
map.logicTick = map.logicTick + INTERVAL_LOGIC
2017-06-01 03:46:53 +02:00
local gameRef = game
local surface = gameRef.surfaces[1]
planning(natives,
gameRef.forces.enemy.evolution_factor,
tick,
surface)
2017-05-19 09:47:24 +02:00
if natives.useCustomAI then
2018-01-14 07:48:21 +02:00
processBases(map, surface, natives, tick)
2017-12-31 21:12:40 +02:00
end
end
2018-01-14 07:48:21 +02:00
if (tick == map.squadTick) then
map.squadTick = map.squadTick + INTERVAL_SQUAD
2016-09-13 00:33:00 +02:00
local gameRef = game
2018-01-14 07:48:21 +02:00
cleanSquads(natives, map)
regroupSquads(natives, map)
squadsBeginAttack(natives, gameRef.players)
2018-01-14 07:48:21 +02:00
squadsAttack(map, gameRef.surfaces[1], natives)
2016-08-20 20:24:22 +02:00
end
end
2016-09-13 00:33:00 +02:00
local function onBuild(event)
2017-11-21 09:27:03 +02:00
local entity = event.created_entity
if (entity.surface.index == 1) then
2018-01-14 07:48:21 +02:00
addRemovePlayerEntity(map, entity, natives, true, false)
if natives.safeBuildings then
if natives.safeEntities[entity.type] or natives.safeEntityName[entity.name] then
entity.destructible = false
end
end
end
end
2017-08-08 10:19:51 +02:00
local function onMine(event)
local entity = event.entity
local surface = entity.surface
if (surface.index == 1) then
2018-01-14 07:48:21 +02:00
addRemovePlayerEntity(map, entity, natives, false, false)
end
end
2016-09-13 00:33:00 +02:00
local function onDeath(event)
local entity = event.entity
local surface = entity.surface
if (surface.index == 1) then
2017-11-21 09:27:03 +02:00
local entityPosition = entity.position
2018-01-14 07:48:21 +02:00
local chunk = getChunkByPosition(map, entityPosition)
local cause = event.cause
if (entity.force.name == "enemy") then
if (entity.type == "unit") then
if (chunk ~= SENTINEL_IMPASSABLE_CHUNK) then
2017-01-20 07:58:36 +02:00
-- drop death pheromone where unit died
deathScent(chunk)
2017-01-20 07:58:36 +02:00
if event.force and (event.force.name == "player") and (chunk[MOVEMENT_PHEROMONE] < natives.retreatThreshold) then
local tick = event.tick
2017-06-01 03:46:53 +02:00
local artilleryBlast = (cause and ((cause.type == "artillery-wagon") or (cause.type == "artillery-turret")))
retreatUnits(chunk,
2017-06-09 07:18:59 +02:00
entityPosition,
2017-11-21 09:27:03 +02:00
convertUnitGroupToSquad(natives, entity.unit_group),
2018-01-14 07:48:21 +02:00
map,
2017-06-01 03:46:53 +02:00
surface,
natives,
tick,
(artilleryBlast and RETREAT_SPAWNER_GRAB_RADIUS) or RETREAT_GRAB_RADIUS,
artilleryBlast)
2017-11-21 09:27:03 +02:00
if (mRandom() < natives.rallyThreshold) and not surface.peaceful_mode then
2018-01-14 07:48:21 +02:00
rallyUnits(chunk, map, surface, natives, tick)
2017-01-20 07:58:36 +02:00
end
end
end
elseif event.force and (event.force.name == "player") and (entity.type == "unit-spawner") or (entity.type == "turret") then
local tick = event.tick
if (chunk ~= SENTINEL_IMPASSABLE_CHUNK) then
2018-01-14 07:48:21 +02:00
unregisterEnemyBaseStructure(map, entity)
2018-01-14 07:48:21 +02:00
rallyUnits(chunk, map, surface, natives, tick)
retreatUnits(chunk,
entityPosition,
nil,
2018-01-14 07:48:21 +02:00
map,
surface,
natives,
tick,
RETREAT_SPAWNER_GRAB_RADIUS,
(cause and ((cause.type == "artillery-wagon") or (cause.type == "artillery-turret"))))
end
end
elseif (entity.force.name == "player") then
2016-11-04 01:51:35 +02:00
local creditNatives = false
if (event.force ~= nil) and (event.force.name == "enemy") then
creditNatives = true
if (chunk ~= SENTINEL_IMPASSABLE_CHUNK) then
victoryScent(chunk, entity.type)
2017-05-27 02:58:33 +02:00
end
2016-11-04 01:51:35 +02:00
end
2017-05-06 11:03:28 +02:00
if creditNatives and natives.safeBuildings and (natives.safeEntities[entity.type] or natives.safeEntityName[entity.name]) then
makeImmortalEntity(surface, entity)
else
2018-01-14 07:48:21 +02:00
addRemovePlayerEntity(map, entity, natives, false, creditNatives)
end
end
end
end
2017-06-01 03:46:53 +02:00
local function onEnemyBaseBuild(event)
local entity = event.entity
local surface = entity.surface
if (surface.index == 1) then
2018-01-14 07:48:21 +02:00
registerEnemyBaseStructure(map, entity, nil)
end
2017-06-01 03:46:53 +02:00
end
local function onSurfaceTileChange(event)
2018-01-18 07:34:23 +02:00
local surfaceIndex = event.surface_index or (event.robot and event.robot.surface.index)
if (event.item.name == "landfill") and (surfaceIndex == 1) then
local surface = game.surfaces[1]
local chunks = {}
local tiles = event.tiles
for i=1,#tiles do
local position = tiles[i].position
local chunk = getChunkByPosition(map, position, true)
-- weird bug with table pointer equality using name instead pointer comparison
if not chunk.name then
2018-01-14 07:48:21 +02:00
map.chunkToPassScan[chunk] = true
else
local x,y = positionToChunkXY(position)
local addMe = true
for ci=1,#chunks do
local c = chunks[ci]
if (c.x == x) and (c.y == y) then
addMe = false
break
end
end
if addMe then
local chunkXY = {x=x,y=y}
chunks[#chunks+1] = chunkXY
onChunkGenerated({area = { left_top = chunkXY },
surface = surface})
end
end
end
end
end
local function onResourceDepleted(event)
local entity = event.entity
if (entity.surface.index == 1) then
2018-01-14 07:48:21 +02:00
chunkUtils.unregisterResource(entity, map)
end
end
local function onUsedCapsule(event)
local surface = game.players[event.player_index].surface
if (event.item.name == "cliff-explosives") and (surface.index == 1) then
local cliffs = surface.find_entities_filtered({area={{event.position.x-0.75,event.position.y-0.75},
{event.position.x+0.75,event.position.y+0.75}},
type="cliff"})
for i=1,#cliffs do
2018-01-14 07:48:21 +02:00
entityForPassScan(map, cliffs[i])
end
end
end
2016-09-13 00:33:00 +02:00
local function onInit()
2018-01-14 07:48:21 +02:00
global.map = {}
2016-09-13 00:33:00 +02:00
global.pendingChunks = {}
global.natives = {}
2018-01-14 07:48:21 +02:00
map = global.map
2016-09-13 00:33:00 +02:00
natives = global.natives
pendingChunks = global.pendingChunks
onConfigChanged()
2017-07-05 00:52:20 +02:00
hookEvents()
2016-09-13 00:33:00 +02:00
end
-- hooks
script.on_init(onInit)
script.on_load(onLoad)
2017-11-21 09:27:03 +02:00
script.on_event(defines.events.on_runtime_mod_setting_changed, onModSettingsChange)
2016-08-25 02:05:20 +02:00
script.on_configuration_changed(onConfigChanged)
script.on_event(defines.events.on_resource_depleted, onResourceDepleted)
script.on_event({defines.events.on_player_built_tile,
defines.events.on_robot_built_tile}, onSurfaceTileChange)
script.on_event(defines.events.on_player_used_capsule, onUsedCapsule)
2017-11-21 09:27:03 +02:00
script.on_event(defines.events.on_biter_base_built, onEnemyBaseBuild)
2017-08-14 02:35:44 +02:00
script.on_event({defines.events.on_player_mined_entity,
2017-11-21 09:27:03 +02:00
defines.events.on_robot_mined_entity}, onMine)
script.on_event({defines.events.on_built_entity,
2017-11-21 09:27:03 +02:00
defines.events.on_robot_built_entity}, onBuild)
2016-09-09 12:02:50 +02:00
script.on_event(defines.events.on_entity_died, onDeath)
script.on_event(defines.events.on_tick, onTick)
script.on_event(defines.events.on_chunk_generated, onChunkGenerated)
2017-05-08 08:56:11 +02:00
remote.add_interface("rampantTests",
{
pheromoneLevels = tests.pheromoneLevels,
activeSquads = tests.activeSquads,
entitiesOnPlayerChunk = tests.entitiesOnPlayerChunk,
findNearestPlayerEnemy = tests.findNearestPlayerEnemy,
aiStats = tests.aiStats,
fillableDirtTest = tests.fillableDirtTest,
tunnelTest = tests.tunnelTest,
createEnemy = tests.createEnemy,
attackOrigin = tests.attackOrigin,
cheatMode = tests.cheatMode,
gaussianRandomTest = tests.gaussianRandomTest,
reveal = tests.reveal,
2017-12-31 21:36:23 +02:00
showMovementGrid = tests.showMovementGrid,
2017-05-08 08:56:11 +02:00
baseStats = tests.baseStats,
mergeBases = tests.mergeBases,
2017-05-28 06:50:37 +02:00
clearBases = tests.clearBases,
getOffsetChunk = tests.getOffsetChunk,
2017-06-08 02:57:24 +02:00
registeredNest = tests.registeredNest,
2017-12-31 21:36:23 +02:00
colorResourcePoints = tests.colorResourcePoints,
stepAdvanceTendrils = tests.stepAdvanceTendrils,
exportAiState = tests.exportAiState(onTick)
2017-05-08 08:56:11 +02:00
}
)
2017-05-06 11:03:28 +02:00
remote.add_interface("rampant", interop)