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
Bugfixes:
- Removed layer-13 from projectiles
- script_raised_built now looks for enemy faction and registers as needed
---------------------------------------------------------------------------------------------------
Version: 3.1.2

View File

@ -337,19 +337,67 @@ local function onConfigChanged()
end
end
local function onBuild(event)
local entity = event.created_entity or event.entity
local function onEnemyBaseBuild(event)
local entity = event.entity or event.created_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)
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
accountPlayerEntity(entity, map, true)
if universe.safeEntities[entity.type] or universe.safeEntities[entity.name] then
entity.destructible = false
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 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
@ -511,49 +559,6 @@ local function onDeath(event)
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 chunk = getChunkByPosition(map, position)

View File

@ -1,7 +1,7 @@
{
"name" : "Rampant",
"factorio_version" : "1.1",
"version" : "3.1.2",
"version" : "3.1.3",
"title" : "Rampant",
"author" : "Veden",
"homepage" : "https://forums.factorio.com/viewtopic.php?f=94&t=31445",