1
0
mirror of https://github.com/veden/Rampant.git synced 2025-01-14 02:23:01 +02:00

36625d3: New enemies can be removed through a console command

This commit is contained in:
Aaron Veden 2022-12-30 13:37:06 -08:00
parent b4c9c75f10
commit 7e8a581c40
No known key found for this signature in database
GPG Key ID: FF5990B1C6DD3F84
3 changed files with 66 additions and 0 deletions

View File

@ -1,5 +1,7 @@
---------------------------------------------------------------------------------------------------
Version: 3.2.0
Improvements:
- Added console command /rampantRemoveNewEnemies which changes all new enemies to vanilla enemies for allowing the disabling of new enemies on an existing save
Compatibility:
- Added interface for adding and removing excluded surfaces
Tweaks:

View File

@ -38,6 +38,7 @@ local queryUtils = require("libs/QueryUtils")
-- constants
local VANILLA_ENTITY_TYPE_LOOKUP = constants.VANILLA_ENTITY_TYPE_LOOKUP
local ENTITY_SKIP_COUNT_LOOKUP = constants.ENTITY_SKIP_COUNT_LOOKUP
local BUILDING_HIVE_TYPE_LOOKUP = constants.BUILDING_HIVE_TYPE_LOOKUP
@ -156,6 +157,8 @@ local tRemove = table.remove
local sFind = string.find
local mRandom = math.random
-- local references to global
local universe -- manages the chunks that make up the game universe
@ -1126,11 +1129,71 @@ local function removeExcludeSurface(surfaceName)
end
end
local function removeNewEnemies()
game.print({"description.rampant--removeNewEnemies"})
universe.NEW_ENEMIES = false
for _,map in pairs(universe.maps) do
local surface = map.surface
if surface.valid then
local entities = surface.find_entities_filtered({
force=universe.enemyForces,
type={
"turret",
"unit-spawner"
}
})
for entityIndex = 1,#entities do
local entity = entities[entityIndex]
if entity.valid and not VANILLA_ENTITY_TYPE_LOOKUP[entity.name] then
local position = entity.position
local newEntityName
local entityType = entity.type
unregisterEnemyBaseStructure(map, entity, nil, true)
entity.destroy()
if entityType == "unit-spawner" then
if mRandom() < 0.5 then
newEntityName = "biter-spawner"
else
newEntityName = "spitter-spawner"
end
elseif entityType == "turret" then
if universe.evolutionLevel >= 0.9 then
newEntityName = "behemoth-worm-turret"
elseif universe.evolutionLevel >= 0.5 then
newEntityName = "big-worm-turret"
elseif universe.evolutionLevel >= 0.3 then
newEntityName = "medium-worm-turret"
else
newEntityName = "small-worm-turret"
end
end
local newEntity = surface.create_entity({
name=newEntityName,
position=position
})
local chunk = getChunkByPosition(map, position)
if chunk ~= -1 then
local base = findNearbyBase(map, chunk)
if not base then
base = createBase(map,
chunk,
game.tick)
end
registerEnemyBaseStructure(map, newEntity, base)
end
end
end
end
end
end
remote.add_interface("Rampant", {
addExcludeSurface = addExcludeSurface,
removeExcludeSurface = removeExcludeSurface
})
commands.add_command('rampantRemoveNewEnemies', "", removeNewEnemies)
local function rampantSetAIState(event)
if event.parameter then
local target

View File

@ -332,6 +332,7 @@ rampant--adaptation2DebugMessage=Faction has mutated bacause the damage type cal
rampant--adaptation1DebugMessage=Faction has mutated bacause the damage type called __1__. Now the Faction will produce __2__. Faction mutations __5__ out of __6__. [gps=__3__,__4__]
rampant--adaptationFrozenDebugMessage=Faction will no longer mutate into new factions. [gps=__1__,__2__]
rampant--adaptationResetDebugMessage=Faction mutations have been reset. __2__ of __3__ mutations remaining. [gps=__1__,__2__]
rampant--removeNewEnemies=Starting removal of new enemies.\nPlease Wait...\nOnce this is completed, save your game, exit to the main menu, disable the Rampant Mod setting new enemies, load your save and and save your game, and now the new enemies should be disabled. \n\nIf you run this command and don't disable the new enemies then any mod configuration changes will cause the new enemies to be re-enabled.
rampant--laserEnemyName=Laser Biter
rampant--waspEnemyName=Wasp Biter
rampant--spawnerEnemyName=Spawner Biter