mirror of
https://github.com/veden/Rampant.git
synced 2025-01-28 03:29:34 +02:00
ignore surfaces that will never have enemies
This commit is contained in:
parent
e814a9c648
commit
82058d16d4
18
Upgrade.lua
18
Upgrade.lua
@ -28,6 +28,7 @@ local TRIPLE_CHUNK_SIZE = constants.TRIPLE_CHUNK_SIZE
|
||||
|
||||
-- imported functions
|
||||
|
||||
local sFind = string.find
|
||||
local queueGeneratedChunk = mapUtils.queueGeneratedChunk
|
||||
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)
|
||||
game.forces.enemy.kill_all_units()
|
||||
universe.maps = {}
|
||||
for _,surface in pairs(game.surfaces) do
|
||||
upgrade.prepMap(universe, surface)
|
||||
end
|
||||
universe.activeMap = nil
|
||||
universe.mapIterator = nil
|
||||
|
||||
@ -438,6 +436,20 @@ function upgrade.attempt(universe)
|
||||
end
|
||||
|
||||
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.")
|
||||
|
||||
local surfaceIndex = surface.index
|
||||
|
@ -12,6 +12,7 @@ Date: 23. 11. 2021
|
||||
- Optimized adding new chunks to the Rampant in-memory state map
|
||||
- Added minimum building cost upgrade check before base upgrade performs scanning
|
||||
- Optimized energy thief faction
|
||||
- Factorissimo, Space Exploration Orbits, asteroid belts, secret maps, starmap, AAI-signal, NiceFill, Blueprint lab surfaces are no longer processed
|
||||
Tweaks:
|
||||
- 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
|
||||
|
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
|
||||
--]]
|
||||
local map = universe.maps[event.surface.index]
|
||||
if not map then
|
||||
return
|
||||
end
|
||||
map.ionCannonBlasts = map.ionCannonBlasts + 1
|
||||
map.points = map.points + 4000
|
||||
if universe.aiPointsPrintGainsToChat then
|
||||
@ -308,6 +311,9 @@ local function onBuild(event)
|
||||
local entity = event.created_entity or event.entity
|
||||
if entity.valid then
|
||||
local map = universe.maps[entity.surface.index]
|
||||
if not map then
|
||||
return
|
||||
end
|
||||
if (entity.type == "resource") and (entity.force.name == "neutral") then
|
||||
registerResource(entity, map)
|
||||
else
|
||||
@ -323,6 +329,9 @@ local function onMine(event)
|
||||
local entity = event.entity
|
||||
if entity.valid then
|
||||
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.amount == 0) then
|
||||
unregisterResource(entity, map)
|
||||
@ -338,6 +347,9 @@ local function onDeath(event)
|
||||
if entity.valid then
|
||||
local surface = entity.surface
|
||||
local map = universe.maps[surface.index]
|
||||
if not map then
|
||||
return
|
||||
end
|
||||
local entityPosition = entity.position
|
||||
local chunk = getChunkByPosition(map, entityPosition)
|
||||
local cause = event.cause
|
||||
@ -523,6 +535,9 @@ local function onEnemyBaseBuild(event)
|
||||
local entity = event.entity
|
||||
if entity.valid then
|
||||
local map = universe.maps[entity.surface.index]
|
||||
if not map then
|
||||
return
|
||||
end
|
||||
local chunk = getChunkByPosition(map, entity.position)
|
||||
if (chunk ~= -1) then
|
||||
local base
|
||||
@ -562,6 +577,9 @@ end
|
||||
local function onSurfaceTileChange(event)
|
||||
local surfaceIndex = event.surface_index or (event.robot and event.robot.surface and event.robot.surface.index)
|
||||
local map = universe.maps[surfaceIndex]
|
||||
if not map then
|
||||
return
|
||||
end
|
||||
local surface = map.surface
|
||||
local chunks = {}
|
||||
local tiles = event.tiles
|
||||
@ -628,7 +646,11 @@ end
|
||||
local function onResourceDepleted(event)
|
||||
local entity = event.entity
|
||||
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
|
||||
|
||||
@ -636,6 +658,9 @@ local function onRobotCliff(event)
|
||||
local entity = event.robot
|
||||
if entity.valid then
|
||||
local map = universe.maps[entity.surface.index]
|
||||
if not map then
|
||||
return
|
||||
end
|
||||
if (event.item.name == "cliff-explosives") then
|
||||
entityForPassScan(map, event.cliff)
|
||||
end
|
||||
@ -645,6 +670,9 @@ end
|
||||
local function onUsedCapsule(event)
|
||||
local surface = game.players[event.player_index].surface
|
||||
local map = universe.maps[surface.index]
|
||||
if not map then
|
||||
return
|
||||
end
|
||||
if (event.item.name == "cliff-explosives") then
|
||||
local position2Top = universe.position2Top
|
||||
local position2Bottom = universe.position2Bottom
|
||||
@ -663,6 +691,9 @@ local function onRocketLaunch(event)
|
||||
local entity = event.rocket_silo or event.rocket
|
||||
if entity.valid then
|
||||
local map = universe.maps[entity.surface.index]
|
||||
if not map then
|
||||
return
|
||||
end
|
||||
map.rocketLaunched = map.rocketLaunched + 1
|
||||
map.points = map.points + 5000
|
||||
if universe.aiPointsPrintGainsToChat then
|
||||
@ -676,6 +707,9 @@ local function onTriggerEntityCreated(event)
|
||||
local entity = event.target_entity
|
||||
if (entity.valid) then
|
||||
local map = universe.maps[event.surface_index]
|
||||
if not map then
|
||||
return
|
||||
end
|
||||
local chunk = getChunkByPosition(map, entity.position)
|
||||
if (chunk ~= -1) then
|
||||
map.chunkToDrained[chunk.id] = event.tick + 60
|
||||
@ -697,6 +731,9 @@ local function onEntitySpawned(event)
|
||||
local entity = event.mine
|
||||
if universe.NEW_ENEMIES and entity.valid then
|
||||
local map = universe.maps[entity.surface.index]
|
||||
if not map then
|
||||
return
|
||||
end
|
||||
if universe.buildingHiveTypeLookup[entity.name] then
|
||||
local disPos = mathUtils.distortPosition(entity.position, 8)
|
||||
|
||||
@ -742,6 +779,9 @@ local function onUnitGroupCreated(event)
|
||||
local squad
|
||||
if not group.is_script_driven then
|
||||
local map = universe.maps[surface.index]
|
||||
if not map then
|
||||
return
|
||||
end
|
||||
if not universe.aiNocturnalMode then
|
||||
local settler = mRandom() < 0.25 and
|
||||
canMigrate(map) and
|
||||
@ -814,6 +854,9 @@ local function onGroupFinishedGathering(event)
|
||||
local group = event.group
|
||||
if group.valid and (group.force.name == "enemy") then
|
||||
local map = universe.maps[group.surface.index]
|
||||
if not map then
|
||||
return
|
||||
end
|
||||
local squad = map.groupNumberToSquad[group.group_number]
|
||||
if squad then
|
||||
if squad.settler then
|
||||
@ -902,7 +945,11 @@ local function onBuilderArrived(event)
|
||||
targetPosition.x = builder.position.x
|
||||
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
|
||||
if universe.aiPointsPrintSpendingToChat then
|
||||
game.print("Settled: [gps=" .. targetPosition.x .. "," .. targetPosition.y .."]")
|
||||
@ -1052,6 +1099,9 @@ remote.add_interface("rampantTests",
|
||||
local function rampantSetAIState(event)
|
||||
local surfaceIndex = game.players[event.player_index].surface.index
|
||||
local map = universe.maps[surfaceIndex]
|
||||
if not map then
|
||||
return
|
||||
end
|
||||
|
||||
game.print(map.surface.name .. " is in " .. constants.stateEnglish[map.state])
|
||||
|
||||
|
@ -226,13 +226,15 @@ end
|
||||
function mapProcessor.processPlayers(players, map, tick)
|
||||
-- put down player pheromone for player hunters
|
||||
-- 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
|
||||
if (#players > 0) then
|
||||
local player = players[mRandom(#players)]
|
||||
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)
|
||||
|
||||
if (playerChunk ~= -1) then
|
||||
|
@ -54,8 +54,11 @@ function mapUtils.positionToChunkXY(position)
|
||||
end
|
||||
|
||||
function mapUtils.queueGeneratedChunk(universe, event)
|
||||
event.tick = (event.tick or game.tick) + 20
|
||||
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
|
||||
map.pendingChunks[event.id] = event
|
||||
map.eventId = map.eventId + 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user