1
0
mirror of https://github.com/veden/Rampant.git synced 2024-12-26 20:54:12 +02:00

FACTO-189: script_raised_built should now try to register enemy buildings

This commit is contained in:
Aaron Veden 2022-06-22 19:10:36 -07:00
parent 120e9b86c2
commit 08a7ab7e29
No known key found for this signature in database
GPG Key ID: FF5990B1C6DD3F84
3 changed files with 57 additions and 51 deletions

View File

@ -4,6 +4,7 @@ Version: 3.1.3
- Added interface for adding and removing excluded surfaces - Added interface for adding and removing excluded surfaces
Bugfixes: Bugfixes:
- Removed layer-13 from projectiles - Removed layer-13 from projectiles
- script_raised_built now looks for enemy faction and registers as needed
--------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------
Version: 3.1.2 Version: 3.1.2

View File

@ -337,19 +337,67 @@ local function onConfigChanged()
end end
end end
local function onBuild(event) local function onEnemyBaseBuild(event)
local entity = event.created_entity or event.entity local entity = event.entity or event.created_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 if not map then
return return
end end
if (entity.type == "resource") and (entity.force.name == "neutral") then map.activeSurface = true
registerResource(entity, map) local chunk = getChunkByPosition(map, entity.position)
if (chunk ~= -1) then
local base = findNearbyBase(map, chunk)
if not base then
base = createBase(map,
chunk,
event.tick)
end
registerEnemyBaseStructure(map, entity, base)
if universe.NEW_ENEMIES then
upgradeEntity(entity,
base,
map,
nil,
true,
true)
end
else else
accountPlayerEntity(entity, map, true) local x,y = positionToChunkXY(entity.position)
if universe.safeEntities[entity.type] or universe.safeEntities[entity.name] then onChunkGenerated({
entity.destructible = false surface = entity.surface,
tick = event.tick,
area = {
left_top = {
x = x,
y = y
}
}
})
end
end
end
local function onBuild(event)
local entity = event.created_entity or event.entity
if entity.valid then
local entityForceName = entity.force.name
if entityForceName == "enemy" and universe.buildingHiveTypeLookup[entity.name] then
onEnemyBaseBuild(event)
else
local map = universe.maps[entity.surface.index]
if not map then
return
end
if (entity.type == "resource") and (entityForceName == "neutral") then
registerResource(entity, map)
else
accountPlayerEntity(entity, map, true)
if universe.safeEntities[entity.type] or universe.safeEntities[entity.name] then
entity.destructible = false
end
end end
end end
end end
@ -511,49 +559,6 @@ local function onDeath(event)
end end
end end
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
map.activeSurface = true
local chunk = getChunkByPosition(map, entity.position)
if (chunk ~= -1) then
local base = findNearbyBase(map, chunk)
if not base then
base = createBase(map,
chunk,
event.tick)
end
registerEnemyBaseStructure(map, entity, base)
if universe.NEW_ENEMIES then
upgradeEntity(entity,
base,
map,
nil,
true,
true)
end
else
local x,y = positionToChunkXY(entity.position)
onChunkGenerated({
surface = entity.surface,
tick = event.tick,
area = {
left_top = {
x = x,
y = y
}
}
})
end
end
end
local function processSurfaceTile(map, position, chunks, tick) local function processSurfaceTile(map, position, chunks, tick)
local chunk = getChunkByPosition(map, position) local chunk = getChunkByPosition(map, position)

View File

@ -1,7 +1,7 @@
{ {
"name" : "Rampant", "name" : "Rampant",
"factorio_version" : "1.1", "factorio_version" : "1.1",
"version" : "3.1.2", "version" : "3.1.3",
"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",