1
0
mirror of https://github.com/veden/Rampant.git synced 2024-12-30 21:19:46 +02:00

added support for abandoned ruins mod

This commit is contained in:
Aaron Veden 2021-12-06 21:32:44 -08:00
parent d52de9e6c2
commit e7a988aae1
No known key found for this signature in database
GPG Key ID: FF5990B1C6DD3F84
3 changed files with 77 additions and 31 deletions

View File

@ -65,6 +65,11 @@ local function addCommandSet(queriesAndCommands)
y=0
}
queriesAndCommands.playerForces = {}
queriesAndCommands.enemyForces = {}
queriesAndCommands.npcForces = {}
queriesAndCommands.nonPlayerForces = {}
queriesAndCommands.chunkOverlapArray = {
-1,
-1,
@ -95,18 +100,18 @@ local function addCommandSet(queriesAndCommands)
}
queriesAndCommands.filteredEntitiesUnitQuery = {
area=queriesAndCommands.area,
force="enemy",
force=queriesAndCommands.enemyForces,
type="unit"
}
queriesAndCommands.hasPlayerStructuresQuery = {
area=queriesAndCommands.area,
force={"enemy","neutral"},
force=queriesAndCommands.nonPlayerForces,
invert=true,
limit=1
}
queriesAndCommands.filteredEntitiesEnemyStructureQuery = {
area=queriesAndCommands.area,
force="enemy",
force=queriesAndCommands.enemyForces,
type={
"turret",
"unit-spawner"
@ -116,7 +121,7 @@ local function addCommandSet(queriesAndCommands)
position = queriesAndCommands.position,
radius = 10,
limit = 1,
force = "enemy",
force = queriesAndCommands.enemyForces,
type = {
"unit-spawner",
"turret"
@ -127,28 +132,9 @@ local function addCommandSet(queriesAndCommands)
position = queriesAndCommands.position
}
queriesAndCommands.activePlayerForces = {"player"}
for _,force in pairs(game.forces) do
local add = true
if (force.name ~= "neutral") and (force.name ~= "enemy") then
for i=1,#queriesAndCommands.activePlayerForces do
if (queriesAndCommands.activePlayerForces[i] == force.name) then
add = false
break
end
end
if add then
queriesAndCommands.activePlayerForces[#queriesAndCommands.activePlayerForces+1] = force.name
end
end
end
queriesAndCommands.filteredEntitiesPlayerQueryLowest = {
area=queriesAndCommands.area,
force=queriesAndCommands.activePlayerForces,
force=queriesAndCommands.playerForces,
collision_mask = "player-layer",
type={
"wall",
@ -158,7 +144,7 @@ local function addCommandSet(queriesAndCommands)
queriesAndCommands.filteredEntitiesPlayerQueryLow = {
area=queriesAndCommands.area,
force=queriesAndCommands.activePlayerForces,
force=queriesAndCommands.playerForces,
collision_mask = "player-layer",
type={
"splitter",
@ -176,7 +162,7 @@ local function addCommandSet(queriesAndCommands)
queriesAndCommands.filteredEntitiesPlayerQueryHigh = {
area=queriesAndCommands.area,
force=queriesAndCommands.activePlayerForces,
force=queriesAndCommands.playerForces,
collision_mask = "player-layer",
type={
"furnace",
@ -194,7 +180,7 @@ local function addCommandSet(queriesAndCommands)
queriesAndCommands.filteredEntitiesPlayerQueryHighest = {
area=queriesAndCommands.area,
force=queriesAndCommands.activePlayerForces,
force=queriesAndCommands.playerForces,
collision_mask = "player-layer",
type={
"artillery-turret",
@ -333,6 +319,34 @@ local function addCommandSet(queriesAndCommands)
unit_count = 1,
unit_search_distance = CHUNK_SIZE
}
queriesAndCommands.setCommandForces = function (npcForces, enemyForces)
for force in pairs(queriesAndCommands.playerForces) do
queriesAndCommands.playerForces[force] = nil
end
for force in pairs(queriesAndCommands.npcForces) do
queriesAndCommands.npcForces[force] = nil
end
for force in pairs(queriesAndCommands.enemyForces) do
queriesAndCommands.enemyForces[force] = nil
end
for force in pairs(queriesAndCommands.nonPlayerForces) do
queriesAndCommands.nonPlayerForces[force] = nil
end
for _,force in pairs(game.forces) do
if not npcForces[force.name] and not enemyForces[force.name] then
queriesAndCommands.playerForces[#queriesAndCommands.playerForces+1] = force.name
end
end
for force in pairs(enemyForces) do
queriesAndCommands.enemyForces[#queriesAndCommands.enemyForces+1] = force
queriesAndCommands.nonPlayerForces[#queriesAndCommands.nonPlayerForces+1] = force
end
for force in pairs(npcForces) do
queriesAndCommands.npcForces[#queriesAndCommands.npcForces+1] = force
queriesAndCommands.nonPlayerForces[#queriesAndCommands.nonPlayerForces+1] = force
end
end
end
function upgrade.attempt(universe)

View File

@ -22,6 +22,7 @@ Date: 23. 11. 2021
- Optimized processing spawners covered by pollution
- Newly generated chunks are now processed regardless of current active surface
- Neutral death events that aren't cliffs are no longer processed
- Added support for AbandonedRuins mod
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

View File

@ -146,11 +146,26 @@ local function onIonCannonFired(event)
end
end
local function onAbandonedRuins(event)
local entity = event.entity
if entity.valid and (entity.force.name ~= "enemy") then
local map = universe.maps[entity.surface.index]
if not map then
return
end
accountPlayerEntity(entity, map, true, false)
end
end
local function hookEvents()
if settings.startup["ion-cannon-radius"] ~= nil then
script.on_event(remote.call("orbital_ion_cannon", "on_ion_cannon_fired"),
onIonCannonFired)
end
if settings.global["AbandonedRuins-set"] ~= nil then
script.on_event(remote.call("AbandonedRuins", "get_on_entity_force_changed_event"),
onAbandonedRuins)
end
end
local function onLoad()
@ -296,6 +311,22 @@ local function onConfigChanged()
universe.buildingHiveTypeLookup["behemoth-worm-turret"] = "turret"
end
-- not a completed implementation needs if checks to use all forces
-- both in the data stage, commands, and if then logic
local enemyForces = {
["enemy"]=true
}
local npcForces = {
["neutral"]=true
}
if game.active_mods["AbandonedRuins"] then
npcForces["AbandonedRuins:enemy"] = true
end
universe.setCommandForces(npcForces, enemyForces)
for _,surface in pairs(game.surfaces) do
if not universe.maps then
universe.maps = {}
@ -901,13 +932,13 @@ local function onGroupFinishedGathering(event)
end
local function onForceCreated(event)
universe.activePlayerForces[#universe.activePlayerForces+1] = event.force.name
universe.playerForces[#universe.playerForces+1] = event.force.name
end
local function onForceMerged(event)
for i=#universe.activePlayerForces,1,-1 do
if (universe.activePlayerForces[i] == event.source_name) then
tRemove(universe.activePlayerForces, i)
for i=#universe.playerForces,1,-1 do
if (universe.playerForces[i] == event.source_name) then
tRemove(universe.playerForces, i)
break
end
end