mirror of
https://github.com/veden/Rampant.git
synced 2025-09-16 09:16:43 +02:00
ignore surfaces that will never have enemies
This commit is contained in:
18
Upgrade.lua
18
Upgrade.lua
@@ -28,6 +28,7 @@ local TRIPLE_CHUNK_SIZE = constants.TRIPLE_CHUNK_SIZE
|
|||||||
|
|
||||||
-- imported functions
|
-- imported functions
|
||||||
|
|
||||||
|
local sFind = string.find
|
||||||
local queueGeneratedChunk = mapUtils.queueGeneratedChunk
|
local queueGeneratedChunk = mapUtils.queueGeneratedChunk
|
||||||
local processPendingChunks = chunkProcessor.processPendingChunks
|
local processPendingChunks = chunkProcessor.processPendingChunks
|
||||||
|
|
||||||
@@ -425,9 +426,6 @@ function upgrade.attempt(universe)
|
|||||||
universe.random = game.create_random_generator(settings.startup["rampant--enemySeed"].value+game.default_map_gen_settings.seed)
|
universe.random = game.create_random_generator(settings.startup["rampant--enemySeed"].value+game.default_map_gen_settings.seed)
|
||||||
game.forces.enemy.kill_all_units()
|
game.forces.enemy.kill_all_units()
|
||||||
universe.maps = {}
|
universe.maps = {}
|
||||||
for _,surface in pairs(game.surfaces) do
|
|
||||||
upgrade.prepMap(universe, surface)
|
|
||||||
end
|
|
||||||
universe.activeMap = nil
|
universe.activeMap = nil
|
||||||
universe.mapIterator = nil
|
universe.mapIterator = nil
|
||||||
|
|
||||||
@@ -438,6 +436,20 @@ function upgrade.attempt(universe)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function upgrade.prepMap(universe, surface)
|
function upgrade.prepMap(universe, surface)
|
||||||
|
local surfaceName = surface.name
|
||||||
|
if sFind(surfaceName, "Factory floor") or
|
||||||
|
sFind(surfaceName, " Orbit") or
|
||||||
|
sFind(surfaceName, "clonespace") or
|
||||||
|
sFind(surfaceName, "BPL_TheLabplayer") or
|
||||||
|
sFind(surfaceName, "starmap-") or
|
||||||
|
(surfaceName == "aai-signals") or
|
||||||
|
sFind(surfaceName, "NiceFill") or
|
||||||
|
sFind(surfaceName, "Asteroid Belt") or
|
||||||
|
sFind(surfaceName, "Vault ")
|
||||||
|
then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
game.print("Rampant - Indexing surface:" .. tostring(surface.index) .. ", please wait.")
|
game.print("Rampant - Indexing surface:" .. tostring(surface.index) .. ", please wait.")
|
||||||
|
|
||||||
local surfaceIndex = surface.index
|
local surfaceIndex = surface.index
|
||||||
|
@@ -12,6 +12,7 @@ Date: 23. 11. 2021
|
|||||||
- Optimized adding new chunks to the Rampant in-memory state map
|
- Optimized adding new chunks to the Rampant in-memory state map
|
||||||
- Added minimum building cost upgrade check before base upgrade performs scanning
|
- Added minimum building cost upgrade check before base upgrade performs scanning
|
||||||
- Optimized energy thief faction
|
- Optimized energy thief faction
|
||||||
|
- Factorissimo, Space Exploration Orbits, asteroid belts, secret maps, starmap, AAI-signal, NiceFill, Blueprint lab surfaces are no longer processed
|
||||||
Tweaks:
|
Tweaks:
|
||||||
- Increase chance to upgrade an enemy structure from 5% to 30%
|
- Increase chance to upgrade an enemy structure from 5% to 30%
|
||||||
- New enemy regional bases that have two factions now do 75% on one faction and 25% on the faction for building and upgrading enemy structures
|
- New enemy regional bases that have two factions now do 75% on one faction and 25% on the faction for building and upgrading enemy structures
|
||||||
|
54
control.lua
54
control.lua
@@ -132,6 +132,9 @@ 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 map = universe.maps[event.surface.index]
|
local map = universe.maps[event.surface.index]
|
||||||
|
if not map then
|
||||||
|
return
|
||||||
|
end
|
||||||
map.ionCannonBlasts = map.ionCannonBlasts + 1
|
map.ionCannonBlasts = map.ionCannonBlasts + 1
|
||||||
map.points = map.points + 4000
|
map.points = map.points + 4000
|
||||||
if universe.aiPointsPrintGainsToChat then
|
if universe.aiPointsPrintGainsToChat then
|
||||||
@@ -308,6 +311,9 @@ local function onBuild(event)
|
|||||||
local entity = event.created_entity or event.entity
|
local entity = event.created_entity or event.entity
|
||||||
if entity.valid then
|
if entity.valid then
|
||||||
local map = universe.maps[entity.surface.index]
|
local map = universe.maps[entity.surface.index]
|
||||||
|
if not map then
|
||||||
|
return
|
||||||
|
end
|
||||||
if (entity.type == "resource") and (entity.force.name == "neutral") then
|
if (entity.type == "resource") and (entity.force.name == "neutral") then
|
||||||
registerResource(entity, map)
|
registerResource(entity, map)
|
||||||
else
|
else
|
||||||
@@ -323,6 +329,9 @@ local function onMine(event)
|
|||||||
local entity = event.entity
|
local entity = event.entity
|
||||||
if entity.valid then
|
if entity.valid then
|
||||||
local map = universe.maps[entity.surface.index]
|
local map = universe.maps[entity.surface.index]
|
||||||
|
if not map then
|
||||||
|
return
|
||||||
|
end
|
||||||
if (entity.type == "resource") and (entity.force.name == "neutral") then
|
if (entity.type == "resource") and (entity.force.name == "neutral") then
|
||||||
if (entity.amount == 0) then
|
if (entity.amount == 0) then
|
||||||
unregisterResource(entity, map)
|
unregisterResource(entity, map)
|
||||||
@@ -338,6 +347,9 @@ local function onDeath(event)
|
|||||||
if entity.valid then
|
if entity.valid then
|
||||||
local surface = entity.surface
|
local surface = entity.surface
|
||||||
local map = universe.maps[surface.index]
|
local map = universe.maps[surface.index]
|
||||||
|
if not map then
|
||||||
|
return
|
||||||
|
end
|
||||||
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
|
||||||
@@ -523,6 +535,9 @@ local function onEnemyBaseBuild(event)
|
|||||||
local entity = event.entity
|
local entity = event.entity
|
||||||
if entity.valid then
|
if entity.valid then
|
||||||
local map = universe.maps[entity.surface.index]
|
local map = universe.maps[entity.surface.index]
|
||||||
|
if not map then
|
||||||
|
return
|
||||||
|
end
|
||||||
local chunk = getChunkByPosition(map, entity.position)
|
local chunk = getChunkByPosition(map, entity.position)
|
||||||
if (chunk ~= -1) then
|
if (chunk ~= -1) then
|
||||||
local base
|
local base
|
||||||
@@ -562,6 +577,9 @@ end
|
|||||||
local function onSurfaceTileChange(event)
|
local function onSurfaceTileChange(event)
|
||||||
local surfaceIndex = event.surface_index or (event.robot and event.robot.surface and event.robot.surface.index)
|
local surfaceIndex = event.surface_index or (event.robot and event.robot.surface and event.robot.surface.index)
|
||||||
local map = universe.maps[surfaceIndex]
|
local map = universe.maps[surfaceIndex]
|
||||||
|
if not map then
|
||||||
|
return
|
||||||
|
end
|
||||||
local surface = map.surface
|
local surface = map.surface
|
||||||
local chunks = {}
|
local chunks = {}
|
||||||
local tiles = event.tiles
|
local tiles = event.tiles
|
||||||
@@ -628,7 +646,11 @@ end
|
|||||||
local function onResourceDepleted(event)
|
local function onResourceDepleted(event)
|
||||||
local entity = event.entity
|
local entity = event.entity
|
||||||
if entity.valid then
|
if entity.valid then
|
||||||
unregisterResource(entity, universe.maps[entity.surface.index])
|
local map = universe.maps[entity.surface.index]
|
||||||
|
if not map then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
unregisterResource(entity, map)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -636,6 +658,9 @@ local function onRobotCliff(event)
|
|||||||
local entity = event.robot
|
local entity = event.robot
|
||||||
if entity.valid then
|
if entity.valid then
|
||||||
local map = universe.maps[entity.surface.index]
|
local map = universe.maps[entity.surface.index]
|
||||||
|
if not map then
|
||||||
|
return
|
||||||
|
end
|
||||||
if (event.item.name == "cliff-explosives") then
|
if (event.item.name == "cliff-explosives") then
|
||||||
entityForPassScan(map, event.cliff)
|
entityForPassScan(map, event.cliff)
|
||||||
end
|
end
|
||||||
@@ -645,6 +670,9 @@ 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
|
||||||
local map = universe.maps[surface.index]
|
local map = universe.maps[surface.index]
|
||||||
|
if not map then
|
||||||
|
return
|
||||||
|
end
|
||||||
if (event.item.name == "cliff-explosives") then
|
if (event.item.name == "cliff-explosives") then
|
||||||
local position2Top = universe.position2Top
|
local position2Top = universe.position2Top
|
||||||
local position2Bottom = universe.position2Bottom
|
local position2Bottom = universe.position2Bottom
|
||||||
@@ -663,6 +691,9 @@ local function onRocketLaunch(event)
|
|||||||
local entity = event.rocket_silo or event.rocket
|
local entity = event.rocket_silo or event.rocket
|
||||||
if entity.valid then
|
if entity.valid then
|
||||||
local map = universe.maps[entity.surface.index]
|
local map = universe.maps[entity.surface.index]
|
||||||
|
if not map then
|
||||||
|
return
|
||||||
|
end
|
||||||
map.rocketLaunched = map.rocketLaunched + 1
|
map.rocketLaunched = map.rocketLaunched + 1
|
||||||
map.points = map.points + 5000
|
map.points = map.points + 5000
|
||||||
if universe.aiPointsPrintGainsToChat then
|
if universe.aiPointsPrintGainsToChat then
|
||||||
@@ -676,6 +707,9 @@ local function onTriggerEntityCreated(event)
|
|||||||
local entity = event.target_entity
|
local entity = event.target_entity
|
||||||
if (entity.valid) then
|
if (entity.valid) then
|
||||||
local map = universe.maps[event.surface_index]
|
local map = universe.maps[event.surface_index]
|
||||||
|
if not map then
|
||||||
|
return
|
||||||
|
end
|
||||||
local chunk = getChunkByPosition(map, entity.position)
|
local chunk = getChunkByPosition(map, entity.position)
|
||||||
if (chunk ~= -1) then
|
if (chunk ~= -1) then
|
||||||
map.chunkToDrained[chunk.id] = event.tick + 60
|
map.chunkToDrained[chunk.id] = event.tick + 60
|
||||||
@@ -697,6 +731,9 @@ local function onEntitySpawned(event)
|
|||||||
local entity = event.mine
|
local entity = event.mine
|
||||||
if universe.NEW_ENEMIES and entity.valid then
|
if universe.NEW_ENEMIES and entity.valid then
|
||||||
local map = universe.maps[entity.surface.index]
|
local map = universe.maps[entity.surface.index]
|
||||||
|
if not map then
|
||||||
|
return
|
||||||
|
end
|
||||||
if universe.buildingHiveTypeLookup[entity.name] then
|
if universe.buildingHiveTypeLookup[entity.name] then
|
||||||
local disPos = mathUtils.distortPosition(entity.position, 8)
|
local disPos = mathUtils.distortPosition(entity.position, 8)
|
||||||
|
|
||||||
@@ -742,6 +779,9 @@ local function onUnitGroupCreated(event)
|
|||||||
local squad
|
local squad
|
||||||
if not group.is_script_driven then
|
if not group.is_script_driven then
|
||||||
local map = universe.maps[surface.index]
|
local map = universe.maps[surface.index]
|
||||||
|
if not map then
|
||||||
|
return
|
||||||
|
end
|
||||||
if not universe.aiNocturnalMode then
|
if not universe.aiNocturnalMode then
|
||||||
local settler = mRandom() < 0.25 and
|
local settler = mRandom() < 0.25 and
|
||||||
canMigrate(map) and
|
canMigrate(map) and
|
||||||
@@ -814,6 +854,9 @@ local function onGroupFinishedGathering(event)
|
|||||||
local group = event.group
|
local group = event.group
|
||||||
if group.valid and (group.force.name == "enemy") then
|
if group.valid and (group.force.name == "enemy") then
|
||||||
local map = universe.maps[group.surface.index]
|
local map = universe.maps[group.surface.index]
|
||||||
|
if not map then
|
||||||
|
return
|
||||||
|
end
|
||||||
local squad = map.groupNumberToSquad[group.group_number]
|
local squad = map.groupNumberToSquad[group.group_number]
|
||||||
if squad then
|
if squad then
|
||||||
if squad.settler then
|
if squad.settler then
|
||||||
@@ -902,7 +945,11 @@ local function onBuilderArrived(event)
|
|||||||
targetPosition.x = builder.position.x
|
targetPosition.x = builder.position.x
|
||||||
targetPosition.y = builder.position.y
|
targetPosition.y = builder.position.y
|
||||||
|
|
||||||
local squad = universe.maps[builder.surface.index].groupNumberToSquad[builder.group_number]
|
local map = universe.maps[builder.surface.index]
|
||||||
|
if not map then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local squad = map.groupNumberToSquad[builder.group_number]
|
||||||
squad.commandTick = event.tick + COMMAND_TIMEOUT * 10
|
squad.commandTick = event.tick + COMMAND_TIMEOUT * 10
|
||||||
if universe.aiPointsPrintSpendingToChat then
|
if universe.aiPointsPrintSpendingToChat then
|
||||||
game.print("Settled: [gps=" .. targetPosition.x .. "," .. targetPosition.y .."]")
|
game.print("Settled: [gps=" .. targetPosition.x .. "," .. targetPosition.y .."]")
|
||||||
@@ -1052,6 +1099,9 @@ remote.add_interface("rampantTests",
|
|||||||
local function rampantSetAIState(event)
|
local function rampantSetAIState(event)
|
||||||
local surfaceIndex = game.players[event.player_index].surface.index
|
local surfaceIndex = game.players[event.player_index].surface.index
|
||||||
local map = universe.maps[surfaceIndex]
|
local map = universe.maps[surfaceIndex]
|
||||||
|
if not map then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
game.print(map.surface.name .. " is in " .. constants.stateEnglish[map.state])
|
game.print(map.surface.name .. " is in " .. constants.stateEnglish[map.state])
|
||||||
|
|
||||||
|
@@ -226,13 +226,15 @@ end
|
|||||||
function mapProcessor.processPlayers(players, map, tick)
|
function mapProcessor.processPlayers(players, map, tick)
|
||||||
-- put down player pheromone for player hunters
|
-- put down player pheromone for player hunters
|
||||||
-- randomize player order to ensure a single player isn't singled out
|
-- randomize player order to ensure a single player isn't singled out
|
||||||
local allowingAttacks = canAttack(map)
|
|
||||||
local universe = map.universe
|
|
||||||
|
|
||||||
-- not looping everyone because the cost is high enough already in multiplayer
|
-- not looping everyone because the cost is high enough already in multiplayer
|
||||||
if (#players > 0) then
|
if (#players > 0) then
|
||||||
local player = players[mRandom(#players)]
|
local player = players[mRandom(#players)]
|
||||||
if validPlayer(player) then
|
if validPlayer(player) then
|
||||||
|
if player.surface.index ~= map.surface.index then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local allowingAttacks = canAttack(map)
|
||||||
|
local universe = map.universe
|
||||||
local playerChunk = getChunkByPosition(map, player.character.position)
|
local playerChunk = getChunkByPosition(map, player.character.position)
|
||||||
|
|
||||||
if (playerChunk ~= -1) then
|
if (playerChunk ~= -1) then
|
||||||
|
@@ -54,8 +54,11 @@ function mapUtils.positionToChunkXY(position)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function mapUtils.queueGeneratedChunk(universe, event)
|
function mapUtils.queueGeneratedChunk(universe, event)
|
||||||
event.tick = (event.tick or game.tick) + 20
|
|
||||||
local map = universe.maps[event.surface.index]
|
local map = universe.maps[event.surface.index]
|
||||||
|
if not map then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
event.tick = (event.tick or game.tick) + 20
|
||||||
event.id = map.eventId
|
event.id = map.eventId
|
||||||
map.pendingChunks[event.id] = event
|
map.pendingChunks[event.id] = event
|
||||||
map.eventId = map.eventId + 1
|
map.eventId = map.eventId + 1
|
||||||
|
Reference in New Issue
Block a user