mirror of
https://github.com/veden/Rampant.git
synced 2025-03-17 20:58:35 +02:00
cf049a3: Added removeFactionName console command
This commit is contained in:
parent
fbd2961b27
commit
51679780c9
@ -2,6 +2,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
|
||||
- Added console command /rampantRemoveFaction to remove individual factions on existing saves
|
||||
- Added minimum evolution of 20% before faction adaptation will happen with mod setting to configure
|
||||
Compatibility:
|
||||
- Added interface for adding and removing excluded surfaces
|
||||
@ -16,6 +17,7 @@ Version: 3.2.0
|
||||
- Fixed settler groups not respecting expansion map setting for min and max time
|
||||
- Fixed faction mutation mutating to an existing faction is no longer counted towards max number of mutations per base
|
||||
- Corrected typo of `randominess` to `randomness` in tooltips
|
||||
- Fixed alignmentTable being nil due to an invalid reference to the neutral faction
|
||||
Optimizations:
|
||||
- Moved most constants out of global
|
||||
- Removed new enemy variations setting
|
||||
|
110
control.lua
110
control.lua
@ -38,6 +38,11 @@ local queryUtils = require("libs/QueryUtils")
|
||||
|
||||
-- constants
|
||||
|
||||
local FACTION_SET = constants.FACTION_SET
|
||||
|
||||
local BUILDING_EVOLVE_LOOKUP = constants.BUILDING_EVOLVE_LOOKUP
|
||||
|
||||
local ENEMY_ALIGNMENT_LOOKUP = constants.ENEMY_ALIGNMENT_LOOKUP
|
||||
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
|
||||
@ -60,6 +65,9 @@ local DEV_HIVE_TTL = constants.DEV_HIVE_TTL
|
||||
|
||||
-- imported functions
|
||||
|
||||
local isMember = stringUtils.isMember
|
||||
local split = stringUtils.split
|
||||
|
||||
local planning = aiPlanning.planning
|
||||
|
||||
local addBasesToAllEnemyStructures = chunkUtils.addBasesToAllEnemyStructures
|
||||
@ -74,6 +82,8 @@ local linearInterpolation = mathUtils.linearInterpolation
|
||||
local gaussianRandomRangeRG = mathUtils.gaussianRandomRangeRG
|
||||
local prepMap = upgrade.prepMap
|
||||
|
||||
local findBaseInitialAlignment = baseUtils.findBaseInitialAlignment
|
||||
|
||||
local processBaseAIs = aiPlanning.processBaseAIs
|
||||
|
||||
local registerEnemyBaseStructure = chunkUtils.registerEnemyBaseStructure
|
||||
@ -300,10 +310,6 @@ local function onConfigChanged()
|
||||
universe["ENEMY_VARIATIONS"] = 1-- settings.startup["rampant--newEnemyVariations"].value
|
||||
universe["NEW_ENEMIES"] = settings.startup["rampant--newEnemies"].value
|
||||
|
||||
if universe.NEW_ENEMIES then
|
||||
rebuildNativeTables(universe)
|
||||
end
|
||||
|
||||
-- not a completed implementation needs if checks to use all forces
|
||||
-- both in the data stage, commands, and if then logic
|
||||
local enemyForces = {
|
||||
@ -1192,12 +1198,108 @@ local function removeNewEnemies()
|
||||
end
|
||||
end
|
||||
|
||||
local function removeFaction(cmd)
|
||||
local factionNames = cmd.parameter
|
||||
if not factionNames then
|
||||
game.print({"description.rampant--removeFactionNames"})
|
||||
return
|
||||
end
|
||||
factionNames = split(factionNames)
|
||||
for _,factionName in pairs(factionNames) do
|
||||
local found = false
|
||||
if (factionName ~= "neutral") then
|
||||
for _,faction in pairs(FACTION_SET) do
|
||||
if (faction.type == factionName) then
|
||||
found = true
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
if not found then
|
||||
game.print({"description.rampant--removeFactionNames"})
|
||||
return
|
||||
end
|
||||
end
|
||||
local localizedFactionNames = ""
|
||||
for _,name in pairs(factionNames) do
|
||||
if localizedFactionNames == "" then
|
||||
localizedFactionNames = name
|
||||
else
|
||||
localizedFactionNames = localizedFactionNames .. "," .. name
|
||||
end
|
||||
end
|
||||
game.print({"description.rampant--removeFaction", localizedFactionNames})
|
||||
|
||||
for _,base in pairs(universe.bases) do
|
||||
if isMember(base.alignment[1], factionNames) then
|
||||
base.alignment = findBaseInitialAlignment(universe, universe.evolutionLevel, factionNames)
|
||||
elseif isMember(base.alignment[2], factionNames) then
|
||||
base.alignment = findBaseInitialAlignment(universe, universe.evolutionLevel, factionNames)
|
||||
end
|
||||
end
|
||||
|
||||
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 isMember(ENEMY_ALIGNMENT_LOOKUP[entity.name], factionNames) 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)
|
||||
commands.add_command('rampantRemoveFaction', "", removeFaction)
|
||||
|
||||
local function rampantSetAIState(event)
|
||||
if event.parameter then
|
||||
|
@ -21,6 +21,7 @@ local baseUtils = {}
|
||||
|
||||
-- imports
|
||||
|
||||
local stringUtils = require("StringUtils")
|
||||
local mathUtils = require("MathUtils")
|
||||
local constants = require("Constants")
|
||||
local chunkPropertyUtils = require("ChunkPropertyUtils")
|
||||
@ -62,6 +63,8 @@ local BASE_AI_STATE_PEACEFUL = constants.BASE_AI_STATE_PEACEFUL
|
||||
|
||||
-- imported functions
|
||||
|
||||
local isMember = stringUtils.isMember
|
||||
|
||||
local setPositionXYInQuery = queryUtils.setPositionXYInQuery
|
||||
|
||||
local euclideanDistancePoints = mathUtils.euclideanDistancePoints
|
||||
@ -96,13 +99,25 @@ local function evoToTier(universe, evolutionFactor, maxSkips)
|
||||
return v
|
||||
end
|
||||
|
||||
local function findBaseMutation(universe, targetEvolution)
|
||||
local function findBaseMutation(universe, targetEvolution, excludeFactions)
|
||||
local tier = evoToTier(universe, targetEvolution or universe.evolutionLevel, 2)
|
||||
local availableAlignments
|
||||
local alignments = EVOLUTION_TABLE_ALIGNMENT[tier]
|
||||
|
||||
if excludeFactions then
|
||||
availableAlignments = {}
|
||||
for _,alignment in pairs(alignments) do
|
||||
if not isMember(alignment[2], excludeFactions) then
|
||||
availableAlignments[#availableAlignments+1] = alignment
|
||||
end
|
||||
end
|
||||
else
|
||||
availableAlignments = alignments
|
||||
end
|
||||
|
||||
local roll = universe.random()
|
||||
for i=1,#alignments do
|
||||
local alignment = alignments[i]
|
||||
for i=1,#availableAlignments do
|
||||
local alignment = availableAlignments[i]
|
||||
|
||||
roll = roll - alignment[1]
|
||||
|
||||
@ -110,7 +125,7 @@ local function findBaseMutation(universe, targetEvolution)
|
||||
return alignment[2]
|
||||
end
|
||||
end
|
||||
return alignments[#alignments]
|
||||
return availableAlignments[#availableAlignments]
|
||||
end
|
||||
|
||||
local function initialEntityUpgrade(baseAlignment, tier, maxTier, map, useHiveType, entityType)
|
||||
@ -131,7 +146,7 @@ local function initialEntityUpgrade(baseAlignment, tier, maxTier, map, useHiveTy
|
||||
|
||||
local alignmentTable = BUILDING_EVOLVE_LOOKUP[baseAlignment]
|
||||
if not alignmentTable then
|
||||
alignmentTable = BUILDING_EVOLVE_LOOKUP[BASE_ALIGNMENT_NEUTRAL]
|
||||
alignmentTable = BUILDING_EVOLVE_LOOKUP["neutral"]
|
||||
end
|
||||
local upgrades = alignmentTable[useTier]
|
||||
|
||||
@ -247,15 +262,16 @@ function baseUtils.findEntityUpgrade(baseAlignment, currentEvo, evoIndex, origin
|
||||
end
|
||||
end
|
||||
|
||||
local function findBaseInitialAlignment(universe, evoIndex)
|
||||
-- local
|
||||
function baseUtils.findBaseInitialAlignment(universe, evoIndex, excludeFactions)
|
||||
local dev = evoIndex * 0.15
|
||||
local evoTop = gaussianRandomRangeRG(evoIndex - (evoIndex * 0.075), dev, 0, evoIndex, universe.random)
|
||||
|
||||
local result
|
||||
if universe.random() < 0.05 then
|
||||
result = {findBaseMutation(universe, evoTop), findBaseMutation(universe, evoTop)}
|
||||
result = {findBaseMutation(universe, evoTop, excludeFactions), findBaseMutation(universe, evoTop, excludeFactions)}
|
||||
else
|
||||
result = {findBaseMutation(universe, evoTop)}
|
||||
result = {findBaseMutation(universe, evoTop, excludeFactions)}
|
||||
end
|
||||
|
||||
return result
|
||||
@ -500,24 +516,5 @@ function baseUtils.createBase(map, chunk, tick)
|
||||
return base
|
||||
end
|
||||
|
||||
function baseUtils.rebuildNativeTables(universe)
|
||||
local evoIndex = evoToTier(universe, universe.evolutionLevel, 2)
|
||||
|
||||
if universe.bases then
|
||||
for _,base in pairs(universe.bases) do
|
||||
for x=1,2 do
|
||||
local alignment = base.alignment[x]
|
||||
if alignment and not BUILDING_EVOLVE_LOOKUP[alignment] then
|
||||
base.alignment = findBaseInitialAlignment(universe, evoIndex)
|
||||
break
|
||||
elseif not alignment and (x == 1) then
|
||||
base.alignment = findBaseInitialAlignment(universe, evoIndex)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
baseUtilsG = baseUtils
|
||||
return baseUtils
|
||||
|
@ -20,10 +20,41 @@ end
|
||||
local stringUtils = {}
|
||||
|
||||
local sSub = string.sub
|
||||
local sGMatch = string.gmatch
|
||||
|
||||
function stringUtils.isRampantSetting(str)
|
||||
return sSub(str, 1, #"rampant--") == "rampant--"
|
||||
end
|
||||
|
||||
function stringUtils.split(str)
|
||||
local result = {}
|
||||
for i in sGMatch(str, "[a-zA-Z-]+") do
|
||||
result[#result+1] = i
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
function stringUtils.isMember(str, set)
|
||||
for _,s in pairs(set) do
|
||||
if str == s then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function stringUtils.intersection(set1, set2)
|
||||
local result = {}
|
||||
for s1 in pairs(set1) do
|
||||
for s2 in pairs(set2) do
|
||||
if s1 == s2 then
|
||||
result[#result+1] = s1
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
stringUtilsG = stringUtils
|
||||
return stringUtils
|
||||
|
@ -287,20 +287,20 @@ rampant--unitHiveRespawnScaler=Scales by a percentage all new enemy unit hive ti
|
||||
rampant--raidAIToggle=Toggles the ai raiding parties from outside your pollution cloud
|
||||
rampant--siegeAIToggle=Toggles the ai siege parties from outside your pollution cloud that attack or nest
|
||||
|
||||
rampant--laserEnemy=Laser Biter Faction, Laser is major resistance, electric is a minor resistance. Has Biters and Spitter unit types.
|
||||
rampant--waspEnemy=Wasp Biter Faction, Spitter only units and each spitter spits small drones.
|
||||
rampant--spawnerEnemy=Spawner Biter Faction, Only Spitters produced by spawners and spitters make eggs that hatch into biters.
|
||||
rampant--trollEnemy=Regenerative Biter Faction, High health regeneration, major weakness to fire, minor resistance to physical, minor resistance to explosive.
|
||||
rampant--fastEnemy=Fast Biter Faction, High rate of movement, minor resistance to explosive.
|
||||
rampant--infernoEnemy=Inferno Biter Faction, Only Spitters that spit flaming acid that burns everything. Major resistance to Acid & Fire, Minor weakness to poison.
|
||||
rampant--nuclearEnemy=Nuclear Biter Faction, Only Biters that explode like a atomic bomb. Major weakness to explosive.
|
||||
rampant--electricEnemy=Electric Biter Faction, Only Biters with a short range attack that hits multiple entities in a line. Major resistance to Electric, Minor resistance to Laser.
|
||||
rampant--fireEnemy=Fire Biter Faction, Major resistance to Acid & Fire.
|
||||
rampant--suicideEnemy=Suicide Biter Faction, Only Biters that explode when they attack. Minor resistance to Poison, Major weakness to explosive.
|
||||
rampant--physicalEnemy=Brutal Biter Faction, Only Biters. Major resistance to physical, Major resistance to explosive, Minor Weakness to Electric.
|
||||
rampant--acidEnemy=Acid Biter Faction, Major resistance to Acid, Minor resistance to Poison.
|
||||
rampant--energyThiefEnemy=Sapper Biter Faction, Major resistance to Electric, Minor resistance to Laser. Destroying powered structures creates draining crystals.
|
||||
rampant--poisonEnemy=Poison Biter Faction, Only Biters. On death creates a cloud that heals biters and hurts player objects. Major resistance to Poison, Minor weakness to Electric, Minor weakness to Explosive, Minor weakness to Laser, Minor resistance to Fire.
|
||||
rampant--laserEnemy=Laser Biter Faction, Laser is major resistance, electric is a minor resistance. Has Biters and Spitter unit types. If you are removing factions or all new enemies from an existing save use the console commands: either /rampantRemoveFaction or /rampantRemoveNewEnemies
|
||||
rampant--waspEnemy=Wasp Biter Faction, Spitter only units and each spitter spits small drones. If you are removing factions or all new enemies from an existing save use the console commands: either /rampantRemoveFaction or /rampantRemoveNewEnemies
|
||||
rampant--spawnerEnemy=Spawner Biter Faction, Only Spitters produced by spawners and spitters make eggs that hatch into biters. If you are removing factions or all new enemies from an existing save use the console commands: either /rampantRemoveFaction or /rampantRemoveNewEnemies
|
||||
rampant--trollEnemy=Regenerative Biter Faction, High health regeneration, major weakness to fire, minor resistance to physical, minor resistance to explosive. If you are removing factions or all new enemies from an existing save use the console commands: either /rampantRemoveFaction or /rampantRemoveNewEnemies
|
||||
rampant--fastEnemy=Fast Biter Faction, High rate of movement, minor resistance to explosive. If you are removing factions or all new enemies from an existing save use the console commands: either /rampantRemoveFaction or /rampantRemoveNewEnemies
|
||||
rampant--infernoEnemy=Inferno Biter Faction, Only Spitters that spit flaming acid that burns everything. Major resistance to Acid & Fire, Minor weakness to poison. If you are removing factions or all new enemies from an existing save use the console commands: either /rampantRemoveFaction or /rampantRemoveNewEnemies
|
||||
rampant--nuclearEnemy=Nuclear Biter Faction, Only Biters that explode like a atomic bomb. Major weakness to explosive. If you are removing factions or all new enemies from an existing save use the console commands: either /rampantRemoveFaction or /rampantRemoveNewEnemies
|
||||
rampant--electricEnemy=Electric Biter Faction, Only Biters with a short range attack that hits multiple entities in a line. Major resistance to Electric, Minor resistance to Laser. If you are removing factions or all new enemies from an existing save use the console commands: either /rampantRemoveFaction or /rampantRemoveNewEnemies
|
||||
rampant--fireEnemy=Fire Biter Faction, Major resistance to Acid & Fire. If you are removing factions or all new enemies from an existing save use the console commands: either /rampantRemoveFaction or /rampantRemoveNewEnemies
|
||||
rampant--suicideEnemy=Suicide Biter Faction, Only Biters that explode when they attack. Minor resistance to Poison, Major weakness to explosive. If you are removing factions or all new enemies from an existing save use the console commands: either /rampantRemoveFaction or /rampantRemoveNewEnemies
|
||||
rampant--physicalEnemy=Brutal Biter Faction, Only Biters. Major resistance to physical, Major resistance to explosive, Minor Weakness to Electric. If you are removing factions or all new enemies from an existing save use the console commands: either /rampantRemoveFaction or /rampantRemoveNewEnemies
|
||||
rampant--acidEnemy=Acid Biter Faction, Major resistance to Acid, Minor resistance to Poison. If you are removing factions or all new enemies from an existing save use the console commands: either /rampantRemoveFaction or /rampantRemoveNewEnemies
|
||||
rampant--energyThiefEnemy=Sapper Biter Faction, Major resistance to Electric, Minor resistance to Laser. Destroying powered structures creates draining crystals. If you are removing factions or all new enemies from an existing save use the console commands: either /rampantRemoveFaction or /rampantRemoveNewEnemies
|
||||
rampant--poisonEnemy=Poison Biter Faction, Only Biters. On death creates a cloud that heals biters and hurts player objects. Major resistance to Poison, Minor weakness to Electric, Minor weakness to Explosive, Minor weakness to Laser, Minor resistance to Fire. If you are removing factions or all new enemies from an existing save use the console commands: either /rampantRemoveFaction or /rampantRemoveNewEnemies
|
||||
|
||||
rampant--neutralTints=All colors should have 8 hex characters rrggbbaa, first color is the base color, second color is the tinting color, third color is the hives color
|
||||
rampant--laserTints=All colors should have 8 hex characters rrggbbaa, first color is the base color, second color is the tinting color, third color is the hives color
|
||||
@ -335,6 +335,8 @@ rampant--adaptation1DebugMessage=Faction has mutated bacause the damage type cal
|
||||
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--removeFaction=Starting removal of enemy faction:__1__.\nPlease Wait...\nOnce this is completed, save your game, exit to the main menu, disable the Rampant Mod setting that correspond to the removed factions, load your save and and save your game, and now the factions should be disabled.\nFactions will revert to vanilla spawners and worms, but will mutate overtime to the correct factions.
|
||||
rampant--removeFactionNames=Invalid faction name, the options are:\nacid,laser,fire,inferno,wasp,spawner,electric,physical,troll,poison,suicide,nuclear,energy-thief,fast\n/rampantRemoveFaction factionName1,factionName2,...
|
||||
rampant--laserEnemyName=Laser Biter
|
||||
rampant--waspEnemyName=Wasp Biter
|
||||
rampant--spawnerEnemyName=Spawner Biter
|
||||
|
Loading…
x
Reference in New Issue
Block a user