mirror of
https://github.com/veden/Rampant.git
synced 2025-01-16 02:33:53 +02:00
Fix penalties null index
This commit is contained in:
parent
7f22a29b22
commit
51e5eb7502
@ -313,6 +313,15 @@ function upgrade.attempt(natives)
|
|||||||
game.surfaces[natives.activeSurface].print("Rampant - Version 0.17.28")
|
game.surfaces[natives.activeSurface].print("Rampant - Version 0.17.28")
|
||||||
global.version = 95
|
global.version = 95
|
||||||
end
|
end
|
||||||
|
if (global.version < 96) then
|
||||||
|
|
||||||
|
for i=#natives.squads,1,-1 do
|
||||||
|
natives.squads[i].penalties = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
game.surfaces[natives.activeSurface].print("Rampant - Version 0.17.29")
|
||||||
|
global.version = 96
|
||||||
|
end
|
||||||
|
|
||||||
return starting ~= global.version, natives
|
return starting ~= global.version, natives
|
||||||
end
|
end
|
||||||
|
412
control.lua
412
control.lua
@ -135,27 +135,27 @@ local pendingChunks -- chunks that have yet to be processed by the mod
|
|||||||
|
|
||||||
local function onIonCannonFired(event)
|
local function onIonCannonFired(event)
|
||||||
--[[
|
--[[
|
||||||
event.force, event.surface, event.player_index, event.position, event.radius
|
event.force, event.surface, event.player_index, event.position, event.radius
|
||||||
--]]
|
--]]
|
||||||
local surface = event.surface
|
local surface = event.surface
|
||||||
if (surface.index == natives.activeSurface) then
|
if (surface.index == natives.activeSurface) then
|
||||||
natives.points = natives.points + 3000
|
natives.points = natives.points + 3000
|
||||||
if (natives.points > AI_MAX_OVERFLOW_POINTS) then
|
if (natives.points > AI_MAX_OVERFLOW_POINTS) then
|
||||||
natives.points = AI_MAX_OVERFLOW_POINTS
|
natives.points = AI_MAX_OVERFLOW_POINTS
|
||||||
end
|
end
|
||||||
local chunk = getChunkByPosition(map, event.position)
|
local chunk = getChunkByPosition(map, event.position)
|
||||||
if (chunk ~= SENTINEL_IMPASSABLE_CHUNK) then
|
if (chunk ~= SENTINEL_IMPASSABLE_CHUNK) then
|
||||||
rallyUnits(chunk, map, surface, natives, event.tick)
|
rallyUnits(chunk, map, surface, natives, event.tick)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function hookEvents()
|
local function hookEvents()
|
||||||
if config.ionCannonPresent then
|
if config.ionCannonPresent then
|
||||||
script.on_event(remote.call("orbital_ion_cannon", "on_ion_cannon_fired"),
|
script.on_event(remote.call("orbital_ion_cannon", "on_ion_cannon_fired"),
|
||||||
onIonCannonFired)
|
onIonCannonFired)
|
||||||
-- script.on_event(remote.call("orbital_ion_cannon", "on_ion_cannon_targeted"),
|
-- script.on_event(remote.call("orbital_ion_cannon", "on_ion_cannon_targeted"),
|
||||||
-- onIonCannonTargeted)
|
-- onIonCannonTargeted)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -243,7 +243,7 @@ local function rebuildMap()
|
|||||||
map.scentStaging = {}
|
map.scentStaging = {}
|
||||||
|
|
||||||
for x=1,PROCESS_QUEUE_SIZE+1 do
|
for x=1,PROCESS_QUEUE_SIZE+1 do
|
||||||
map.scentStaging[x] = {0,0,0,0}
|
map.scentStaging[x] = {0,0,0,0}
|
||||||
end
|
end
|
||||||
|
|
||||||
map.chunkOverlapArray = {
|
map.chunkOverlapArray = {
|
||||||
@ -304,25 +304,25 @@ local function rebuildMap()
|
|||||||
map.filteredTilesQuery = { collision_mask="water-tile", area=map.area }
|
map.filteredTilesQuery = { collision_mask="water-tile", area=map.area }
|
||||||
|
|
||||||
map.attackCommand = {
|
map.attackCommand = {
|
||||||
type = DEFINES_COMMAND_ATTACK_AREA,
|
type = DEFINES_COMMAND_ATTACK_AREA,
|
||||||
destination = map.position,
|
destination = map.position,
|
||||||
radius = CHUNK_SIZE,
|
radius = CHUNK_SIZE,
|
||||||
distraction = DEFINES_DISTRACTION_BY_ANYTHING
|
distraction = DEFINES_DISTRACTION_BY_ANYTHING
|
||||||
}
|
}
|
||||||
|
|
||||||
map.moveCommand = {
|
map.moveCommand = {
|
||||||
type = DEFINES_COMMAND_GO_TO_LOCATION,
|
type = DEFINES_COMMAND_GO_TO_LOCATION,
|
||||||
destination = map.position,
|
destination = map.position,
|
||||||
radius = 2,
|
radius = 2,
|
||||||
pathfind_flags = { prefer_straight_paths = true },
|
pathfind_flags = { prefer_straight_paths = true },
|
||||||
distraction = DEFINES_DISTRACTION_BY_ENEMY
|
distraction = DEFINES_DISTRACTION_BY_ENEMY
|
||||||
}
|
}
|
||||||
|
|
||||||
map.settleCommand = {
|
map.settleCommand = {
|
||||||
type = DEFINES_COMMAND_BUILD_BASE,
|
type = DEFINES_COMMAND_BUILD_BASE,
|
||||||
destination = map.position,
|
destination = map.position,
|
||||||
distraction = DEFINES_DISTRACTION_BY_ENEMY,
|
distraction = DEFINES_DISTRACTION_BY_ENEMY,
|
||||||
ignore_planner = true
|
ignore_planner = true
|
||||||
}
|
}
|
||||||
|
|
||||||
map.wonderCommand = {
|
map.wonderCommand = {
|
||||||
@ -376,7 +376,7 @@ end
|
|||||||
local function onModSettingsChange(event)
|
local function onModSettingsChange(event)
|
||||||
|
|
||||||
if event and ((string.sub(event.setting, 1, 7) ~= "rampant") or (string.sub(event.setting, 1, 18) == "rampant-arsenal")) then
|
if event and ((string.sub(event.setting, 1, 7) ~= "rampant") or (string.sub(event.setting, 1, 18) == "rampant-arsenal")) then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
upgrade.compareTable(natives, "safeBuildings", settings.global["rampant-safeBuildings"].value)
|
upgrade.compareTable(natives, "safeBuildings", settings.global["rampant-safeBuildings"].value)
|
||||||
@ -389,13 +389,13 @@ local function onModSettingsChange(event)
|
|||||||
upgrade.compareTable(natives.safeEntities, "lamp", settings.global["rampant-safeBuildings-lamps"].value)
|
upgrade.compareTable(natives.safeEntities, "lamp", settings.global["rampant-safeBuildings-lamps"].value)
|
||||||
|
|
||||||
local changed, newValue = upgrade.compareTable(natives.safeEntityName,
|
local changed, newValue = upgrade.compareTable(natives.safeEntityName,
|
||||||
"big-electric-pole",
|
"big-electric-pole",
|
||||||
settings.global["rampant-safeBuildings-bigElectricPole"].value)
|
settings.global["rampant-safeBuildings-bigElectricPole"].value)
|
||||||
if changed then
|
if changed then
|
||||||
natives.safeEntityName["big-electric-pole"] = newValue
|
natives.safeEntityName["big-electric-pole"] = newValue
|
||||||
natives.safeEntityName["big-electric-pole-2"] = newValue
|
natives.safeEntityName["big-electric-pole-2"] = newValue
|
||||||
natives.safeEntityName["big-electric-pole-3"] = newValue
|
natives.safeEntityName["big-electric-pole-3"] = newValue
|
||||||
natives.safeEntityName["big-electric-pole-4"] = newValue
|
natives.safeEntityName["big-electric-pole-4"] = newValue
|
||||||
natives.safeEntityName["lighted-big-electric-pole-4"] = newValue
|
natives.safeEntityName["lighted-big-electric-pole-4"] = newValue
|
||||||
natives.safeEntityName["lighted-big-electric-pole-3"] = newValue
|
natives.safeEntityName["lighted-big-electric-pole-3"] = newValue
|
||||||
natives.safeEntityName["lighted-big-electric-pole-2"] = newValue
|
natives.safeEntityName["lighted-big-electric-pole-2"] = newValue
|
||||||
@ -432,41 +432,41 @@ local function prepWorld(rebuild)
|
|||||||
local upgraded
|
local upgraded
|
||||||
|
|
||||||
if (game.surfaces["battle_surface_2"] ~= nil) then
|
if (game.surfaces["battle_surface_2"] ~= nil) then
|
||||||
natives.activeSurface = game.surfaces["battle_surface_2"].index
|
natives.activeSurface = game.surfaces["battle_surface_2"].index
|
||||||
elseif (game.surfaces["battle_surface_1"] ~= nil) then
|
elseif (game.surfaces["battle_surface_1"] ~= nil) then
|
||||||
natives.activeSurface = game.surfaces["battle_surface_1"].index
|
natives.activeSurface = game.surfaces["battle_surface_1"].index
|
||||||
else
|
else
|
||||||
natives.activeSurface = game.surfaces["nauvis"].index
|
natives.activeSurface = game.surfaces["nauvis"].index
|
||||||
end
|
end
|
||||||
|
|
||||||
upgraded, natives = upgrade.attempt(natives)
|
upgraded, natives = upgrade.attempt(natives)
|
||||||
onModSettingsChange(nil)
|
onModSettingsChange(nil)
|
||||||
if natives.newEnemies then
|
if natives.newEnemies then
|
||||||
rebuildNativeTables(natives, game.surfaces[natives.activeSurface], game.create_random_generator(natives.enemySeed))
|
rebuildNativeTables(natives, game.surfaces[natives.activeSurface], game.create_random_generator(natives.enemySeed))
|
||||||
end
|
end
|
||||||
if upgraded then
|
if upgraded then
|
||||||
rebuildMap()
|
rebuildMap()
|
||||||
|
|
||||||
-- clear pending chunks, will be added when loop runs below
|
-- clear pending chunks, will be added when loop runs below
|
||||||
global.pendingChunks = {}
|
global.pendingChunks = {}
|
||||||
pendingChunks = global.pendingChunks
|
pendingChunks = global.pendingChunks
|
||||||
|
|
||||||
-- queue all current chunks that wont be generated during play
|
-- queue all current chunks that wont be generated during play
|
||||||
local surface = game.surfaces[natives.activeSurface]
|
local surface = game.surfaces[natives.activeSurface]
|
||||||
local tick = game.tick
|
local tick = game.tick
|
||||||
natives.nextChunkSort = 0
|
natives.nextChunkSort = 0
|
||||||
for chunk in surface.get_chunks() do
|
for chunk in surface.get_chunks() do
|
||||||
onChunkGenerated({ tick = tick,
|
onChunkGenerated({ tick = tick,
|
||||||
surface = surface,
|
surface = surface,
|
||||||
area = { left_top = { x = chunk.x * 32,
|
area = { left_top = { x = chunk.x * 32,
|
||||||
y = chunk.y * 32 }}})
|
y = chunk.y * 32 }}})
|
||||||
end
|
end
|
||||||
|
|
||||||
if natives.newEnemies and rebuild then
|
if natives.newEnemies and rebuild then
|
||||||
game.forces.enemy.kill_all_units()
|
game.forces.enemy.kill_all_units()
|
||||||
end
|
end
|
||||||
|
|
||||||
processPendingChunks(natives, map, surface, pendingChunks, tick, game.forces.enemy.evolution_factor, rebuild)
|
processPendingChunks(natives, map, surface, pendingChunks, tick, game.forces.enemy.evolution_factor, rebuild)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -475,12 +475,12 @@ local function onConfigChanged()
|
|||||||
end
|
end
|
||||||
|
|
||||||
script.on_nth_tick(INTERVAL_PLAYER_PROCESS,
|
script.on_nth_tick(INTERVAL_PLAYER_PROCESS,
|
||||||
function (event)
|
function (event)
|
||||||
|
|
||||||
local gameRef = game
|
local gameRef = game
|
||||||
local surface = gameRef.surfaces[natives.activeSurface]
|
local surface = gameRef.surfaces[natives.activeSurface]
|
||||||
|
|
||||||
processPlayers(gameRef.players,
|
processPlayers(gameRef.players,
|
||||||
map,
|
map,
|
||||||
surface,
|
surface,
|
||||||
natives,
|
natives,
|
||||||
@ -488,12 +488,12 @@ script.on_nth_tick(INTERVAL_PLAYER_PROCESS,
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
script.on_nth_tick(INTERVAL_MAP_PROCESS,
|
script.on_nth_tick(INTERVAL_MAP_PROCESS,
|
||||||
function (event)
|
function (event)
|
||||||
|
|
||||||
local gameRef = game
|
local gameRef = game
|
||||||
local surface = gameRef.surfaces[natives.activeSurface]
|
local surface = gameRef.surfaces[natives.activeSurface]
|
||||||
|
|
||||||
processMap(map,
|
processMap(map,
|
||||||
surface,
|
surface,
|
||||||
natives,
|
natives,
|
||||||
event.tick,
|
event.tick,
|
||||||
@ -502,36 +502,36 @@ end)
|
|||||||
|
|
||||||
|
|
||||||
script.on_nth_tick(INTERVAL_SCAN,
|
script.on_nth_tick(INTERVAL_SCAN,
|
||||||
function (event)
|
function (event)
|
||||||
local tick = event.tick
|
local tick = event.tick
|
||||||
local gameRef = game
|
local gameRef = game
|
||||||
local surface = gameRef.surfaces[natives.activeSurface]
|
local surface = gameRef.surfaces[natives.activeSurface]
|
||||||
|
|
||||||
processPendingChunks(natives, map, surface, pendingChunks, tick, gameRef.forces.enemy.evolution_factor)
|
processPendingChunks(natives, map, surface, pendingChunks, tick, gameRef.forces.enemy.evolution_factor)
|
||||||
|
|
||||||
scanMap(map, surface, natives, tick)
|
scanMap(map, surface, natives, tick)
|
||||||
|
|
||||||
map.chunkToPassScan = processScanChunks(map, surface)
|
map.chunkToPassScan = processScanChunks(map, surface)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
script.on_nth_tick(INTERVAL_LOGIC,
|
script.on_nth_tick(INTERVAL_LOGIC,
|
||||||
function (event)
|
function (event)
|
||||||
local tick = event.tick
|
local tick = event.tick
|
||||||
|
|
||||||
planning(natives,
|
planning(natives,
|
||||||
game.forces.enemy.evolution_factor,
|
game.forces.enemy.evolution_factor,
|
||||||
tick)
|
tick)
|
||||||
|
|
||||||
if natives.newEnemies then
|
if natives.newEnemies then
|
||||||
recycleBases(natives, tick)
|
recycleBases(natives, tick)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
script.on_nth_tick(INTERVAL_SQUAD,
|
script.on_nth_tick(INTERVAL_SQUAD,
|
||||||
function ()
|
function ()
|
||||||
local surface = game.surfaces[natives.activeSurface]
|
local surface = game.surfaces[natives.activeSurface]
|
||||||
squadsBeginAttack(natives)
|
squadsBeginAttack(natives)
|
||||||
squadsDispatch(map, surface, natives)
|
squadsDispatch(map, surface, natives)
|
||||||
|
|
||||||
regroupSquads(natives, map)
|
regroupSquads(natives, map)
|
||||||
|
|
||||||
@ -572,35 +572,35 @@ local function onDeath(event)
|
|||||||
local entity = event.entity
|
local entity = event.entity
|
||||||
local surface = entity.surface
|
local surface = entity.surface
|
||||||
if (surface.index == natives.activeSurface) then
|
if (surface.index == natives.activeSurface) then
|
||||||
local entityPosition = entity.position
|
local entityPosition = entity.position
|
||||||
local chunk = getChunkByPosition(map, entityPosition)
|
local chunk = getChunkByPosition(map, entityPosition)
|
||||||
local cause = event.cause
|
local cause = event.cause
|
||||||
local tick = event.tick
|
local tick = event.tick
|
||||||
if (entity.force.name == "enemy") then
|
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 (entity.type == "unit") then
|
if (entity.type == "unit") then
|
||||||
if (chunk ~= SENTINEL_IMPASSABLE_CHUNK) then
|
if (chunk ~= SENTINEL_IMPASSABLE_CHUNK) then
|
||||||
-- drop death pheromone where unit died
|
-- drop death pheromone where unit died
|
||||||
deathScent(map, chunk)
|
deathScent(map, chunk)
|
||||||
|
|
||||||
if event.force and (event.force.name ~= "enemy") and (chunk[MOVEMENT_PHEROMONE] < -natives.retreatThreshold) then
|
if event.force and (event.force.name ~= "enemy") and (chunk[MOVEMENT_PHEROMONE] < -natives.retreatThreshold) then
|
||||||
|
|
||||||
retreatUnits(chunk,
|
retreatUnits(chunk,
|
||||||
entityPosition,
|
entityPosition,
|
||||||
convertUnitGroupToSquad(natives, entity.unit_group),
|
convertUnitGroupToSquad(natives, entity.unit_group),
|
||||||
map,
|
map,
|
||||||
surface,
|
surface,
|
||||||
natives,
|
natives,
|
||||||
tick,
|
tick,
|
||||||
(artilleryBlast and RETREAT_SPAWNER_GRAB_RADIUS) or RETREAT_GRAB_RADIUS,
|
(artilleryBlast and RETREAT_SPAWNER_GRAB_RADIUS) or RETREAT_GRAB_RADIUS,
|
||||||
artilleryBlast)
|
artilleryBlast)
|
||||||
|
|
||||||
if (mRandom() < natives.rallyThreshold) and not surface.peaceful_mode then
|
if (mRandom() < natives.rallyThreshold) and not surface.peaceful_mode then
|
||||||
rallyUnits(chunk, map, surface, natives, tick)
|
rallyUnits(chunk, map, surface, natives, tick)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local cloudName = POISON_LOOKUP[entity.name]
|
local cloudName = POISON_LOOKUP[entity.name]
|
||||||
@ -617,21 +617,21 @@ local function onDeath(event)
|
|||||||
natives.points = AI_MAX_OVERFLOW_POINTS
|
natives.points = AI_MAX_OVERFLOW_POINTS
|
||||||
end
|
end
|
||||||
|
|
||||||
if (chunk ~= SENTINEL_IMPASSABLE_CHUNK) then
|
if (chunk ~= SENTINEL_IMPASSABLE_CHUNK) then
|
||||||
unregisterEnemyBaseStructure(map, entity)
|
unregisterEnemyBaseStructure(map, entity)
|
||||||
|
|
||||||
rallyUnits(chunk, map, surface, natives, tick)
|
rallyUnits(chunk, map, surface, natives, tick)
|
||||||
|
|
||||||
retreatUnits(chunk,
|
retreatUnits(chunk,
|
||||||
entityPosition,
|
entityPosition,
|
||||||
nil,
|
nil,
|
||||||
map,
|
map,
|
||||||
surface,
|
surface,
|
||||||
natives,
|
natives,
|
||||||
tick,
|
tick,
|
||||||
RETREAT_SPAWNER_GRAB_RADIUS,
|
RETREAT_SPAWNER_GRAB_RADIUS,
|
||||||
(cause and ((cause.type == "artillery-wagon") or (cause.type == "artillery-turret"))))
|
(cause and ((cause.type == "artillery-wagon") or (cause.type == "artillery-turret"))))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- if (cause and not artilleryBlast) then
|
-- if (cause and not artilleryBlast) then
|
||||||
@ -662,22 +662,22 @@ local function onDeath(event)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif (entity.force.name ~= "enemy") then
|
elseif (entity.force.name ~= "enemy") then
|
||||||
local creditNatives = false
|
local creditNatives = false
|
||||||
if (event.force ~= nil) and (event.force.name == "enemy") then
|
if (event.force ~= nil) and (event.force.name == "enemy") then
|
||||||
creditNatives = true
|
creditNatives = true
|
||||||
if (chunk ~= SENTINEL_IMPASSABLE_CHUNK) then
|
if (chunk ~= SENTINEL_IMPASSABLE_CHUNK) then
|
||||||
victoryScent(map, chunk, entity.type)
|
victoryScent(map, chunk, entity.type)
|
||||||
end
|
end
|
||||||
|
|
||||||
local drained = (entity.type == "electric-turret") and map.chunkToDrained[chunk]
|
local drained = (entity.type == "electric-turret") and map.chunkToDrained[chunk]
|
||||||
if (cause ~= nil) or (drained and (drained - tick) > 0) then
|
if (cause ~= nil) or (drained and (drained - tick) > 0) then
|
||||||
if ((cause and ENERGY_THIEF_LOOKUP[cause.name]) or (not cause)) then
|
if ((cause and ENERGY_THIEF_LOOKUP[cause.name]) or (not cause)) then
|
||||||
local conversion = ENERGY_THIEF_CONVERSION_TABLE[entity.type]
|
local conversion = ENERGY_THIEF_CONVERSION_TABLE[entity.type]
|
||||||
if conversion then
|
if conversion then
|
||||||
local newEntity = surface.create_entity({position=entity.position,
|
local newEntity = surface.create_entity({position=entity.position,
|
||||||
name=convertTypeToDrainCrystal(entity.force.evolution_factor, conversion),
|
name=convertTypeToDrainCrystal(entity.force.evolution_factor, conversion),
|
||||||
direction=entity.direction})
|
direction=entity.direction})
|
||||||
if (conversion == "pole") then
|
if (conversion == "pole") then
|
||||||
local targetEntity = surface.create_entity({position=entity.position,
|
local targetEntity = surface.create_entity({position=entity.position,
|
||||||
name="pylon-target-rampant",
|
name="pylon-target-rampant",
|
||||||
direction=entity.direction})
|
direction=entity.direction})
|
||||||
@ -685,8 +685,8 @@ local function onDeath(event)
|
|||||||
local pair = {targetEntity, newEntity}
|
local pair = {targetEntity, newEntity}
|
||||||
natives.drainPylons[targetEntity.unit_number] = pair
|
natives.drainPylons[targetEntity.unit_number] = pair
|
||||||
natives.drainPylons[newEntity.unit_number] = pair
|
natives.drainPylons[newEntity.unit_number] = pair
|
||||||
local wires = entity.neighbours
|
local wires = entity.neighbours
|
||||||
if wires then
|
if wires then
|
||||||
for _,v in pairs(wires.copper) do
|
for _,v in pairs(wires.copper) do
|
||||||
if (v.valid) then
|
if (v.valid) then
|
||||||
newEntity.connect_neighbour(v);
|
newEntity.connect_neighbour(v);
|
||||||
@ -702,20 +702,20 @@ local function onDeath(event)
|
|||||||
newEntity.connect_neighbour({wire = DEFINES_WIRE_TYPE_GREEN, target_entity = v});
|
newEntity.connect_neighbour({wire = DEFINES_WIRE_TYPE_GREEN, target_entity = v});
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif newEntity.backer_name then
|
elseif newEntity.backer_name then
|
||||||
newEntity.backer_name = ""
|
newEntity.backer_name = ""
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
if creditNatives and natives.safeBuildings and (natives.safeEntities[entity.type] or natives.safeEntityName[entity.name]) then
|
if creditNatives and natives.safeBuildings and (natives.safeEntities[entity.type] or natives.safeEntityName[entity.name]) then
|
||||||
makeImmortalEntity(surface, entity)
|
makeImmortalEntity(surface, entity)
|
||||||
else
|
else
|
||||||
accountPlayerEntity(map, entity, natives, false, creditNatives)
|
accountPlayerEntity(map, entity, natives, false, creditNatives)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -726,8 +726,8 @@ local function onEnemyBaseBuild(event)
|
|||||||
|
|
||||||
if entity.valid and (surface.index == natives.activeSurface) then
|
if entity.valid and (surface.index == natives.activeSurface) then
|
||||||
|
|
||||||
local chunk = getChunkByPosition(map, entity.position)
|
local chunk = getChunkByPosition(map, entity.position)
|
||||||
if (chunk ~= SENTINEL_IMPASSABLE_CHUNK) then
|
if (chunk ~= SENTINEL_IMPASSABLE_CHUNK) then
|
||||||
-- print(entity.name)
|
-- print(entity.name)
|
||||||
local evolutionFactor = entity.force.evolution_factor
|
local evolutionFactor = entity.force.evolution_factor
|
||||||
local base
|
local base
|
||||||
@ -759,40 +759,40 @@ local function onSurfaceTileChange(event)
|
|||||||
((event.item.name == "landfill") or (event.item.name == "waterfill")) and
|
((event.item.name == "landfill") or (event.item.name == "waterfill")) and
|
||||||
(surfaceIndex == natives.activeSurface)
|
(surfaceIndex == natives.activeSurface)
|
||||||
then
|
then
|
||||||
local surface = game.surfaces[natives.activeSurface]
|
local surface = game.surfaces[natives.activeSurface]
|
||||||
local chunks = {}
|
local chunks = {}
|
||||||
local tiles = event.tiles
|
local tiles = event.tiles
|
||||||
for i=1,#tiles do
|
for i=1,#tiles do
|
||||||
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 ~= SENTINEL_IMPASSABLE_CHUNK) then
|
||||||
map.chunkToPassScan[chunk] = true
|
map.chunkToPassScan[chunk] = true
|
||||||
else
|
else
|
||||||
local x,y = positionToChunkXY(position)
|
local x,y = positionToChunkXY(position)
|
||||||
local addMe = true
|
local addMe = true
|
||||||
for ci=1,#chunks do
|
for ci=1,#chunks do
|
||||||
local c = chunks[ci]
|
local c = chunks[ci]
|
||||||
if (c.x == x) and (c.y == y) then
|
if (c.x == x) and (c.y == y) then
|
||||||
addMe = false
|
addMe = false
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if addMe then
|
if addMe then
|
||||||
local chunkXY = {x=x,y=y}
|
local chunkXY = {x=x,y=y}
|
||||||
chunks[#chunks+1] = chunkXY
|
chunks[#chunks+1] = chunkXY
|
||||||
onChunkGenerated({area = { left_top = chunkXY },
|
onChunkGenerated({area = { left_top = chunkXY },
|
||||||
surface = surface})
|
surface = surface})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function onResourceDepleted(event)
|
local function onResourceDepleted(event)
|
||||||
local entity = event.entity
|
local entity = event.entity
|
||||||
if (entity.surface.index == natives.activeSurface) then
|
if (entity.surface.index == natives.activeSurface) then
|
||||||
unregisterResource(entity, map)
|
unregisterResource(entity, map)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -807,22 +807,22 @@ 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.index == natives.activeSurface) then
|
if (event.item.name == "cliff-explosives") and (surface.index == natives.activeSurface) then
|
||||||
local cliffs = surface.find_entities_filtered({area={{event.position.x-0.75,event.position.y-0.75},
|
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}},
|
{event.position.x+0.75,event.position.y+0.75}},
|
||||||
type="cliff"})
|
type="cliff"})
|
||||||
for i=1,#cliffs do
|
for i=1,#cliffs do
|
||||||
entityForPassScan(map, cliffs[i])
|
entityForPassScan(map, cliffs[i])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function onRocketLaunch(event)
|
local function onRocketLaunch(event)
|
||||||
local entity = event.rocket_silo or event.rocket
|
local entity = event.rocket_silo or event.rocket
|
||||||
if entity and (entity.surface.index == natives.activeSurface) then
|
if entity and (entity.surface.index == natives.activeSurface) then
|
||||||
natives.points = natives.points + 2000
|
natives.points = natives.points + 2000
|
||||||
if (natives.points > AI_MAX_OVERFLOW_POINTS) then
|
if (natives.points > AI_MAX_OVERFLOW_POINTS) then
|
||||||
natives.points = AI_MAX_OVERFLOW_POINTS
|
natives.points = AI_MAX_OVERFLOW_POINTS
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -873,7 +873,7 @@ script.on_configuration_changed(onConfigChanged)
|
|||||||
|
|
||||||
script.on_event(defines.events.on_resource_depleted, onResourceDepleted)
|
script.on_event(defines.events.on_resource_depleted, onResourceDepleted)
|
||||||
script.on_event({defines.events.on_player_built_tile,
|
script.on_event({defines.events.on_player_built_tile,
|
||||||
defines.events.on_robot_built_tile}, onSurfaceTileChange)
|
defines.events.on_robot_built_tile}, onSurfaceTileChange)
|
||||||
|
|
||||||
script.on_event(defines.events.on_player_used_capsule, onUsedCapsule)
|
script.on_event(defines.events.on_player_used_capsule, onUsedCapsule)
|
||||||
|
|
||||||
@ -896,38 +896,38 @@ script.on_event(defines.events.on_force_created, onForceCreated)
|
|||||||
script.on_event(defines.events.on_forces_merged, onForceMerged)
|
script.on_event(defines.events.on_forces_merged, onForceMerged)
|
||||||
|
|
||||||
remote.add_interface("rampantTests",
|
remote.add_interface("rampantTests",
|
||||||
{
|
{
|
||||||
pheromoneLevels = tests.pheromoneLevels,
|
pheromoneLevels = tests.pheromoneLevels,
|
||||||
activeSquads = tests.activeSquads,
|
activeSquads = tests.activeSquads,
|
||||||
entitiesOnPlayerChunk = tests.entitiesOnPlayerChunk,
|
entitiesOnPlayerChunk = tests.entitiesOnPlayerChunk,
|
||||||
findNearestPlayerEnemy = tests.findNearestPlayerEnemy,
|
findNearestPlayerEnemy = tests.findNearestPlayerEnemy,
|
||||||
morePoints = tests.morePoints,
|
morePoints = tests.morePoints,
|
||||||
aiStats = tests.aiStats,
|
aiStats = tests.aiStats,
|
||||||
dumpEnvironment = tests.dumpEnvironment,
|
dumpEnvironment = tests.dumpEnvironment,
|
||||||
fillableDirtTest = tests.fillableDirtTest,
|
fillableDirtTest = tests.fillableDirtTest,
|
||||||
tunnelTest = tests.tunnelTest,
|
tunnelTest = tests.tunnelTest,
|
||||||
dumpNatives = tests.dumpatives,
|
dumpNatives = tests.dumpatives,
|
||||||
createEnemy = tests.createEnemy,
|
createEnemy = tests.createEnemy,
|
||||||
attackOrigin = tests.attackOrigin,
|
attackOrigin = tests.attackOrigin,
|
||||||
cheatMode = tests.cheatMode,
|
cheatMode = tests.cheatMode,
|
||||||
gaussianRandomTest = tests.gaussianRandomTest,
|
gaussianRandomTest = tests.gaussianRandomTest,
|
||||||
reveal = tests.reveal,
|
reveal = tests.reveal,
|
||||||
showMovementGrid = tests.showMovementGrid,
|
showMovementGrid = tests.showMovementGrid,
|
||||||
showBaseGrid = tests.showBaseGrid,
|
showBaseGrid = tests.showBaseGrid,
|
||||||
baseStats = tests.baseStats,
|
baseStats = tests.baseStats,
|
||||||
mergeBases = tests.mergeBases,
|
mergeBases = tests.mergeBases,
|
||||||
clearBases = tests.clearBases,
|
clearBases = tests.clearBases,
|
||||||
getOffsetChunk = tests.getOffsetChunk,
|
getOffsetChunk = tests.getOffsetChunk,
|
||||||
registeredNest = tests.registeredNest,
|
registeredNest = tests.registeredNest,
|
||||||
colorResourcePoints = tests.colorResourcePoints,
|
colorResourcePoints = tests.colorResourcePoints,
|
||||||
entityStats = tests.entityStats,
|
entityStats = tests.entityStats,
|
||||||
stepAdvanceTendrils = tests.stepAdvanceTendrils,
|
stepAdvanceTendrils = tests.stepAdvanceTendrils,
|
||||||
unitGroupBuild = tests.unitGroupBuild,
|
unitGroupBuild = tests.unitGroupBuild,
|
||||||
exportAiState = tests.exportAiState(nil),
|
exportAiState = tests.exportAiState(nil),
|
||||||
createEnergyTest = tests.createEnergyTest,
|
createEnergyTest = tests.createEnergyTest,
|
||||||
killActiveSquads = tests.killActiveSquads,
|
killActiveSquads = tests.killActiveSquads,
|
||||||
scanChunkPaths = tests.scanChunkPaths
|
scanChunkPaths = tests.scanChunkPaths
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
remote.add_interface("rampant", interop)
|
remote.add_interface("rampant", interop)
|
||||||
|
6
make.rkt
6
make.rkt
@ -4,7 +4,7 @@
|
|||||||
(require file/zip)
|
(require file/zip)
|
||||||
(require json)
|
(require json)
|
||||||
|
|
||||||
(define modFolder "/data/games/factorio/mods/")
|
(define modFolder "/mnt/gallery/gameFiles/factorio/mods/")
|
||||||
(define zipModFolder "/data/games/factorio2/mods/")
|
(define zipModFolder "/data/games/factorio2/mods/")
|
||||||
(define configuration (call-with-input-file "info.json"
|
(define configuration (call-with-input-file "info.json"
|
||||||
(lambda (port)
|
(lambda (port)
|
||||||
@ -91,6 +91,4 @@
|
|||||||
|
|
||||||
(define (runStart)
|
(define (runStart)
|
||||||
(copyFiles modFolder)
|
(copyFiles modFolder)
|
||||||
;;(copyFiles zipModFolder)
|
(system*/exit-code "factorio")))
|
||||||
;; (makeZip modFolder)
|
|
||||||
(system*/exit-code "/data/games/factorio/bin/x64/factorio")))
|
|
||||||
|
Loading…
Reference in New Issue
Block a user