From ecce6365953d53ee27d636fdb4d5655baaee0fa1 Mon Sep 17 00:00:00 2001 From: Aaron Veden Date: Sat, 27 Jan 2018 17:02:33 -0800 Subject: [PATCH] fix for null group and setting options --- Upgrade.lua | 6 +- changelog.txt | 8 ++ info.json | 2 +- libs/BaseUtils.lua | 20 +++-- libs/Constants.lua | 163 +++++++++++++++++++++++--------------- libs/UnitGroupUtils.lua | 2 +- locale/en/locale.cfg | 14 +++- prototypes/Acid.lua | 11 ++- prototypes/Electric.lua | 7 +- prototypes/Fast.lua | 11 ++- prototypes/Fire.lua | 11 ++- prototypes/Inferno.lua | 7 +- prototypes/Laser.lua | 11 ++- prototypes/Neutral.lua | 11 ++- prototypes/Nuclear.lua | 7 +- prototypes/Physical.lua | 13 ++- prototypes/Suicide.lua | 7 +- prototypes/SwarmUtils.lua | 17 ++-- prototypes/Troll.lua | 17 ++-- settings.lua | 82 ++++++++++++++++--- 20 files changed, 287 insertions(+), 140 deletions(-) diff --git a/Upgrade.lua b/Upgrade.lua index 876c2f7..8469353 100755 --- a/Upgrade.lua +++ b/Upgrade.lua @@ -191,10 +191,10 @@ function upgrade.attempt(natives) game.surfaces[1].print("Rampant - Version 0.16.9") global.version = constants.VERSION_44 end - if (global.version < constants.VERSION_45) then + if (global.version < constants.VERSION_46) then - game.surfaces[1].print("Rampant - Version 0.16.10") - global.version = constants.VERSION_45 + game.surfaces[1].print("Rampant - Version 0.16.11") + global.version = constants.VERSION_46 end return starting ~= global.version, natives diff --git a/changelog.txt b/changelog.txt index 0e3a973..e055651 100755 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,11 @@ +--------------------------------------------------------------------------------------------------- +Version: 0.16.11 +Date: 1. 27. 2018 + Bugfixes: + - A a null check for nil'ed squad groups (https://mods.factorio.com/mod/Rampant/discussion/5a6d09cb9a95f7000b165865) + Improvements: + - Added setting options for changing tiers and variations to allow for a smaller memory footprint + --------------------------------------------------------------------------------------------------- Version: 0.16.10 Date: 1. 27. 2018 diff --git a/info.json b/info.json index f8f9538..eacf75c 100755 --- a/info.json +++ b/info.json @@ -1,7 +1,7 @@ { "name" : "Rampant", "factorio_version" : "0.16", - "version" : "0.16.10", + "version" : "0.16.11", "title" : "Rampant", "author" : "Veden", "homepage" : "https://forums.factorio.com/viewtopic.php?f=94&t=31445", diff --git a/libs/BaseUtils.lua b/libs/BaseUtils.lua index 16c0ccf..6eb1ce9 100755 --- a/libs/BaseUtils.lua +++ b/libs/BaseUtils.lua @@ -8,6 +8,9 @@ local chunkPropertyUtils = require("ChunkPropertyUtils") -- constants +local TIER_SET_10 = constants.TIER_SET_10 +local TIER_SET_5 = constants.TIER_SET_5 + local NEUTRAL_WORM_TIERS = constants.NEUTRAL_WORM_TIERS local NEUTRAL_WORM_VARIATIONS = constants.NEUTRAL_WORM_VARIATIONS local NEUTRAL_NEST_TIERS = constants.NEUTRAL_NEST_TIERS @@ -355,9 +358,10 @@ end local function processUnitClass(biterVariation, biterTier, spitterVariation, spitterTier, wormVariation, wormTier, surface, natives, baseAlignment, baseAlignmentString) local position = { x = 0, y = 0 } - - for v=1,biterVariation do - for t=1,biterTier do + + for tier=1,biterTier do + local t = ((biterTier == 5) and TIER_SET_5[tier]) or TIER_SET_10[tier] + for v=1,biterVariation do local entity = surface.create_entity({ name= baseAlignmentString .. "-biter-nest-v" .. v .. "-t" .. t .. "-rampant", position = position @@ -366,8 +370,9 @@ local function processUnitClass(biterVariation, biterTier, spitterVariation, spi entity.destroy() end end - for v=1,spitterVariation do - for t=1,spitterTier do + for tier=1,spitterTier do + local t = ((spitterTier == 5) and TIER_SET_5[tier]) or TIER_SET_10[tier] + for v=1,spitterVariation do local entity = surface.create_entity({ name=baseAlignmentString .. "-spitter-nest-v" .. v .. "-t" .. t .. "-rampant", position = position @@ -376,8 +381,9 @@ local function processUnitClass(biterVariation, biterTier, spitterVariation, spi entity.destroy() end end - for v=1,wormVariation do - for t=1,wormTier do + for tier=1,wormTier do + local t = ((wormTier == 5) and TIER_SET_5[tier]) or TIER_SET_10[tier] + for v=1,wormVariation do local entity = surface.create_entity({ name=baseAlignmentString .. "-worm-v" .. v .. "-t" .. t .. "-rampant", position = position diff --git a/libs/Constants.lua b/libs/Constants.lua index d3c8207..3df5a6c 100755 --- a/libs/Constants.lua +++ b/libs/Constants.lua @@ -19,7 +19,7 @@ constants.VERSION_33 = 33 constants.VERSION_38 = 38 constants.VERSION_41 = 41 constants.VERSION_44 = 44 -constants.VERSION_45 = 45 +constants.VERSION_46 = 46 -- misc @@ -307,82 +307,119 @@ constants.SENTINEL_IMPASSABLE_CHUNK.y = -1 -- unit spawners -local variations = settings.startup["rampant-newEnemyVariations"].value -local tiers = 10 +constants.TIER_SET_5 = { 1, 3, 5, 7, 10 } +constants.TIER_SET_10 = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 } -constants.NEUTRAL_NEST_TIERS = tiers -constants.NEUTRAL_NEST_VARIATIONS = variations -constants.NEUTRAL_WORM_TIERS = tiers -constants.NEUTRAL_WORM_VARIATIONS = variations +local nestVariations = settings.startup["rampant-newEnemyNestVariations"].value +local nestTiers = settings.startup["rampant-newEnemyNestTiers"].value +local wormVariations = settings.startup["rampant-newEnemyWormVariations"].value +local wormTiers = settings.startup["rampant-newEnemyWormTiers"].value +local unitVariations = settings.startup["rampant-newEnemyUnitVariations"].value +local unitTiers = settings.startup["rampant-newEnemyUnitTiers"].value -constants.ACID_NEST_TIERS = tiers -constants.ACID_NEST_VARIATIONS = variations -constants.ACID_WORM_TIERS = tiers -constants.ACID_WORM_VARIATIONS = variations +constants.NEUTRAL_NEST_TIERS = nestTiers +constants.NEUTRAL_NEST_VARIATIONS = nestVariations +constants.NEUTRAL_WORM_TIERS = wormTiers +constants.NEUTRAL_WORM_VARIATIONS = wormVariations +constants.NEUTRAL_UNIT_TIERS = unitTiers +constants.NEUTRAL_UNIT_VARIATIONS = unitVariations -constants.FIRE_NEST_TIERS = tiers -constants.FIRE_NEST_VARIATIONS = variations -constants.FIRE_WORM_TIERS = tiers -constants.FIRE_WORM_VARIATIONS = variations +constants.ACID_NEST_TIERS = nestTiers +constants.ACID_NEST_VARIATIONS = nestVariations +constants.ACID_WORM_TIERS = wormTiers +constants.ACID_WORM_VARIATIONS = wormVariations +constants.ACID_UNIT_TIERS = unitTiers +constants.ACID_UNIT_VARIATIONS = unitVariations -constants.PHYSICAL_NEST_TIERS = tiers -constants.PHYSICAL_NEST_VARIATIONS = variations -constants.PHYSICAL_WORM_TIERS = tiers -constants.PHYSICAL_WORM_VARIATIONS = variations +constants.FIRE_NEST_TIERS = nestTiers +constants.FIRE_NEST_VARIATIONS = nestVariations +constants.FIRE_WORM_TIERS = wormTiers +constants.FIRE_WORM_VARIATIONS = wormVariations +constants.FIRE_UNIT_TIERS = unitTiers +constants.FIRE_UNIT_VARIATIONS = unitVariations -constants.TROLL_NEST_TIERS = tiers -constants.TROLL_NEST_VARIATIONS = variations -constants.TROLL_WORM_TIERS = tiers -constants.TROLL_WORM_VARIATIONS = variations +constants.PHYSICAL_NEST_TIERS = nestTiers +constants.PHYSICAL_NEST_VARIATIONS = nestVariations +constants.PHYSICAL_WORM_TIERS = wormTiers +constants.PHYSICAL_WORM_VARIATIONS = wormVariations +constants.PHYSICAL_UNIT_TIERS = unitTiers +constants.PHYSICAL_UNIT_VARIATIONS = unitVariations -constants.FAST_NEST_TIERS = tiers -constants.FAST_NEST_VARIATIONS = variations -constants.FAST_WORM_TIERS = tiers -constants.FAST_WORM_VARIATIONS = variations +constants.TROLL_NEST_TIERS = nestTiers +constants.TROLL_NEST_VARIATIONS = nestVariations +constants.TROLL_WORM_TIERS = wormTiers +constants.TROLL_WORM_VARIATIONS = wormVariations +constants.TROLL_UNIT_TIERS = unitTiers +constants.TROLL_UNIT_VARIATIONS = unitVariations -constants.SUICIDE_NEST_TIERS = tiers -constants.SUICIDE_NEST_VARIATIONS = variations -constants.SUICIDE_WORM_TIERS = tiers -constants.SUICIDE_WORM_VARIATIONS = variations +constants.FAST_NEST_TIERS = nestTiers +constants.FAST_NEST_VARIATIONS = nestVariations +constants.FAST_WORM_TIERS = wormTiers +constants.FAST_WORM_VARIATIONS = wormVariations +constants.FAST_UNIT_TIERS = unitTiers +constants.FAST_UNIT_VARIATIONS = unitVariations -constants.WASP_NEST_TIERS = tiers -constants.WASP_NEST_VARIATIONS = variations -constants.WASP_WORM_TIERS = tiers -constants.WASP_WORM_VARIATIONS = variations +constants.SUICIDE_NEST_TIERS = nestTiers +constants.SUICIDE_NEST_VARIATIONS = nestVariations +constants.SUICIDE_WORM_TIERS = wormTiers +constants.SUICIDE_WORM_VARIATIONS = wormVariations +constants.SUICIDE_UNIT_TIERS = unitTiers +constants.SUICIDE_UNIT_VARIATIONS = unitVariations -constants.POISON_NEST_TIERS = tiers -constants.POISON_NEST_VARIATIONS = variations -constants.POISON_WORM_TIERS = tiers -constants.POISON_WORM_VARIATIONS = variations +constants.WASP_NEST_TIERS = nestTiers +constants.WASP_NEST_VARIATIONS = nestVariations +constants.WASP_WORM_TIERS = wormTiers +constants.WASP_WORM_VARIATIONS = wormVariations +constants.WASP_UNIT_TIERS = unitTiers +constants.WASP_UNIT_VARIATIONS = unitVariations -constants.DECAYING_NEST_TIERS = tiers -constants.DECAYING_NEST_VARIATIONS = variations -constants.DECAYING_WORM_TIERS = tiers -constants.DECAYING_WORM_VARIATIONS = variations +constants.POISON_NEST_TIERS = nestTiers +constants.POISON_NEST_VARIATIONS = nestVariations +constants.POISON_WORM_TIERS = wormTiers +constants.POISON_WORM_VARIATIONS = wormVariations +constants.POISON_UNIT_TIERS = unitTiers +constants.POISON_UNIT_VARIATIONS = unitVariations -constants.UNDYING_NEST_TIERS = tiers -constants.UNDYING_NEST_VARIATIONS = variations -constants.UNDYING_WORM_TIERS = tiers -constants.UNDYING_WORM_VARIATIONS = variations +constants.DECAYING_NEST_TIERS = nestTiers +constants.DECAYING_NEST_VARIATIONS = nestVariations +constants.DECAYING_WORM_TIERS = wormTiers +constants.DECAYING_WORM_VARIATIONS = wormVariations +constants.DECAYING_UNIT_TIERS = unitTiers +constants.DECAYING_UNIT_VARIATIONS = unitVariations -constants.ELECTRIC_NEST_TIERS = tiers -constants.ELECTRIC_NEST_VARIATIONS = variations -constants.ELECTRIC_WORM_TIERS = tiers -constants.ELECTRIC_WORM_VARIATIONS = variations +constants.UNDYING_NEST_TIERS = nestTiers +constants.UNDYING_NEST_VARIATIONS = nestVariations +constants.UNDYING_WORM_TIERS = wormTiers +constants.UNDYING_WORM_VARIATIONS = wormVariations +constants.UNDYING_UNIT_TIERS = unitTiers +constants.UNDYING_UNIT_VARIATIONS = unitVariations -constants.LASER_NEST_TIERS = tiers -constants.LASER_NEST_VARIATIONS = variations -constants.LASER_WORM_TIERS = tiers -constants.LASER_WORM_VARIATIONS = variations +constants.ELECTRIC_NEST_TIERS = nestTiers +constants.ELECTRIC_NEST_VARIATIONS = nestVariations +constants.ELECTRIC_WORM_TIERS = wormTiers +constants.ELECTRIC_WORM_VARIATIONS = wormVariations +constants.ELECTRIC_UNIT_TIERS = unitTiers +constants.ELECTRIC_UNIT_VARIATIONS = unitVariations -constants.INFERNO_NEST_TIERS = tiers -constants.INFERNO_NEST_VARIATIONS = variations -constants.INFERNO_WORM_TIERS = tiers -constants.INFERNO_WORM_VARIATIONS = variations +constants.LASER_NEST_TIERS = nestTiers +constants.LASER_NEST_VARIATIONS = nestVariations +constants.LASER_WORM_TIERS = wormTiers +constants.LASER_WORM_VARIATIONS = wormVariations +constants.LASER_UNIT_TIERS = unitTiers +constants.LASER_UNIT_VARIATIONS = unitVariations -constants.NUCLEAR_NEST_TIERS = tiers -constants.NUCLEAR_NEST_VARIATIONS = variations -constants.NUCLEAR_WORM_TIERS = tiers -constants.NUCLEAR_WORM_VARIATIONS = variations +constants.INFERNO_NEST_TIERS = nestTiers +constants.INFERNO_NEST_VARIATIONS = nestVariations +constants.INFERNO_WORM_TIERS = wormTiers +constants.INFERNO_WORM_VARIATIONS = wormVariations +constants.INFERNO_UNIT_TIERS = unitTiers +constants.INFERNO_UNIT_VARIATIONS = unitVariations + +constants.NUCLEAR_NEST_TIERS = nestTiers +constants.NUCLEAR_NEST_VARIATIONS = nestVariations +constants.NUCLEAR_WORM_TIERS = wormTiers +constants.NUCLEAR_WORM_VARIATIONS = wormVariations +constants.NUCLEAR_UNIT_TIERS = unitTiers +constants.NUCLEAR_UNIT_VARIATIONS = unitVariations return constants diff --git a/libs/UnitGroupUtils.lua b/libs/UnitGroupUtils.lua index c366b02..fef3826 100755 --- a/libs/UnitGroupUtils.lua +++ b/libs/UnitGroupUtils.lua @@ -155,7 +155,7 @@ function unitGroupUtils.cleanSquads(natives, map) for i=1, squadCount do local squad = squads[i] local group = squad.group - if group.valid then + if group and group.valid then local memberCount = #group.members if (memberCount == 0) then removeSquadFromChunk(map, squad) diff --git a/locale/en/locale.cfg b/locale/en/locale.cfg index f9a2465..0558f59 100755 --- a/locale/en/locale.cfg +++ b/locale/en/locale.cfg @@ -9030,7 +9030,12 @@ rampant-enableSwarm=Enable the swarm rampant-newEnemies=Enable new enemies rampant-enemySeed=Enemy Random Seed rampant-deadZoneFrequency=Enemy deadzone frequency -rampant-newEnemyVariations=Enemy Variations +rampant-newEnemyNestVariations=Nest Variations +rampant-newEnemyNestTiers=Nest Tiers +rampant-newEnemyWormVariations=Worm Variations +rampant-newEnemyWormTiers=Worm Tiers +rampant-newEnemyUnitVariations=Unit Variations +rampant-newEnemyUnitTiers=Unit Tiers [mod-setting-description] rampant-useDumbProjectiles=Turns off homing projectiles for worms and spitters @@ -9060,4 +9065,9 @@ rampant-attack-warning=Shows a message warning players that an attack wave is in rampant-newEnemies=Adds news enemies that will be dispersed over the world. This increases the RAM requirements minimum 2GB to 8GB. rampant-enemySeed=The seed that powers all of the unit generation, so change this if you want the enemy stats to change rampant-deadZoneFrequency=The percentage of zones that start out with worms or nests -rampant-newEnemyVariations=This number corresponds to the number of variations per tier of of each unit, unit spawner, and worm types. This increases the RAM requirements minimum 2GB to 8GB. Min 1, Max 20 \ No newline at end of file +rampant-newEnemyNestVariations=This number corresponds to the number of variations per tier. The higher the number the smoother the enemy power curve. Min 1, Max 20 +rampant-newEnemyNestTiers=This number corresponds to number of tiers. The higher the number the smoother the enemy power curve. +rampant-newEnemyWormVariations=This number corresponds to the number of variations per tier. The higher the number the smoother the enemy power curve. Min 1, Max 20 +rampant-newEnemyWormTiers=This number corresponds to number of tiers. The higher the number the smoother the enemy power curve. +rampant-newEnemyUnitVariations=This number corresponds to the number of variations per tier. The higher the number the smoother the enemy power curve. Min 1, Max 20 +rampant-newEnemyUnitTiers=This number corresponds to number of tiers. The higher the number the smoother the enemy power curve. \ No newline at end of file diff --git a/prototypes/Acid.lua b/prototypes/Acid.lua index 9c49950..8a3a880 100755 --- a/prototypes/Acid.lua +++ b/prototypes/Acid.lua @@ -8,6 +8,9 @@ local constants = require("Constants") -- constants +local ACID_UNIT_TIERS = constants.ACID_UNIT_TIERS +local ACID_UNIT_VARIATIONS = constants.ACID_UNIT_VARIATIONS + local ACID_NEST_TIERS = constants.ACID_NEST_TIERS local ACID_NEST_VARIATIONS = constants.ACID_NEST_VARIATIONS @@ -542,12 +545,12 @@ buildUnitSpawner( createMeleeAttack, { - unit = 10, + unit = ACID_UNIT_VARIATIONS, unitSpawner = ACID_NEST_VARIATIONS }, { - unit = 10, + unit = ACID_UNIT_TIERS, unitSpawner = ACID_NEST_TIERS } ) @@ -1161,12 +1164,12 @@ buildUnitSpawner( end, { - unit = 10, + unit = ACID_UNIT_VARIATIONS, unitSpawner = ACID_NEST_VARIATIONS }, { - unit = 10, + unit = ACID_UNIT_TIERS, unitSpawner = ACID_NEST_TIERS } ) diff --git a/prototypes/Electric.lua b/prototypes/Electric.lua index c99dbb7..82e5f81 100755 --- a/prototypes/Electric.lua +++ b/prototypes/Electric.lua @@ -8,6 +8,9 @@ local constants = require("Constants") -- constants +local ELECTRIC_UNIT_TIERS = constants.ELECTRIC_UNIT_TIERS +local ELECTRIC_UNIT_VARIATIONS = constants.ELECTRIC_UNIT_VARIATIONS + local ELECTRIC_NEST_TIERS = constants.ELECTRIC_NEST_TIERS local ELECTRIC_NEST_VARIATIONS = constants.ELECTRIC_NEST_VARIATIONS @@ -589,12 +592,12 @@ buildUnitSpawner( end, { - unit = 10, + unit = ELECTRIC_UNIT_VARIATIONS, unitSpawner = ELECTRIC_NEST_VARIATIONS }, { - unit = 10, + unit = ELECTRIC_UNIT_TIERS, unitSpawner = ELECTRIC_NEST_TIERS } ) diff --git a/prototypes/Fast.lua b/prototypes/Fast.lua index 0478ce7..74a7bdb 100755 --- a/prototypes/Fast.lua +++ b/prototypes/Fast.lua @@ -8,6 +8,9 @@ local constants = require("Constants") -- constants +local FAST_UNIT_TIERS = constants.FAST_UNIT_TIERS +local FAST_UNIT_VARIATIONS = constants.FAST_UNIT_VARIATIONS + local FAST_NEST_TIERS = constants.FAST_NEST_TIERS local FAST_NEST_VARIATIONS = constants.FAST_NEST_VARIATIONS @@ -506,12 +509,12 @@ buildUnitSpawner( createMeleeAttack, { - unit = 10, + unit = FAST_UNIT_VARIATIONS, unitSpawner = FAST_NEST_VARIATIONS }, { - unit = 10, + unit = FAST_UNIT_TIERS, unitSpawner = FAST_NEST_TIERS } ) @@ -1020,12 +1023,12 @@ buildUnitSpawner( end, { - unit = 10, + unit = FAST_UNIT_VARIATIONS, unitSpawner = FAST_NEST_VARIATIONS }, { - unit = 10, + unit = FAST_UNIT_TIERS, unitSpawner = FAST_NEST_TIERS } ) diff --git a/prototypes/Fire.lua b/prototypes/Fire.lua index 9d945d3..e61724c 100755 --- a/prototypes/Fire.lua +++ b/prototypes/Fire.lua @@ -8,6 +8,9 @@ local constants = require("Constants") -- constants +local FIRE_UNIT_TIERS = constants.FIRE_UNIT_TIERS +local FIRE_UNIT_VARIATIONS = constants.FIRE_UNIT_VARIATIONS + local FIRE_NEST_TIERS = constants.FIRE_NEST_TIERS local FIRE_NEST_VARIATIONS = constants.FIRE_NEST_VARIATIONS @@ -569,12 +572,12 @@ buildUnitSpawner( createMeleeAttack, { - unit = 10, + unit = FIRE_UNIT_VARIATIONS, unitSpawner = FIRE_NEST_VARIATIONS }, { - unit = 10, + unit = FIRE_UNIT_TIERS, unitSpawner = FIRE_NEST_TIERS } ) @@ -1177,12 +1180,12 @@ buildUnitSpawner( end, { - unit = 10, + unit = FIRE_UNIT_VARIATIONS, unitSpawner = FIRE_NEST_VARIATIONS }, { - unit = 10, + unit = FIRE_UNIT_TIERS, unitSpawner = FIRE_NEST_TIERS } ) diff --git a/prototypes/Inferno.lua b/prototypes/Inferno.lua index 69524e2..30f6049 100755 --- a/prototypes/Inferno.lua +++ b/prototypes/Inferno.lua @@ -9,6 +9,9 @@ local math3d = require("math3d") -- constants +local INFERNO_UNIT_TIERS = constants.INFERNO_UNIT_TIERS +local INFERNO_UNIT_VARIATIONS = constants.INFERNO_UNIT_VARIATIONS + local INFERNO_NEST_TIERS = constants.INFERNO_NEST_TIERS local INFERNO_NEST_VARIATIONS = constants.INFERNO_NEST_VARIATIONS @@ -679,12 +682,12 @@ buildUnitSpawner( end, { - unit = 10, + unit = INFERNO_UNIT_VARIATIONS, unitSpawner = INFERNO_NEST_VARIATIONS }, { - unit = 10, + unit = INFERNO_UNIT_TIERS, unitSpawner = INFERNO_NEST_TIERS } ) diff --git a/prototypes/Laser.lua b/prototypes/Laser.lua index a8a8599..730e168 100755 --- a/prototypes/Laser.lua +++ b/prototypes/Laser.lua @@ -8,6 +8,9 @@ local constants = require("Constants") -- constants +local LASER_UNIT_TIERS = constants.LASER_UNIT_TIERS +local LASER_UNIT_VARIATIONS = constants.LASER_UNIT_VARIATIONS + local LASER_NEST_TIERS = constants.LASER_NEST_TIERS local LASER_NEST_VARIATIONS = constants.LASER_NEST_VARIATIONS @@ -543,12 +546,12 @@ buildUnitSpawner( createMeleeAttack, { - unit = 10, + unit = LASER_UNIT_VARIATIONS, unitSpawner = LASER_NEST_VARIATIONS }, { - unit = 10, + unit = LASER_UNIT_TIERS, unitSpawner = LASER_NEST_TIERS } ) @@ -1094,12 +1097,12 @@ buildUnitSpawner( end, { - unit = 10, + unit = LASER_UNIT_VARIATIONS, unitSpawner = LASER_NEST_VARIATIONS }, { - unit = 10, + unit = LASER_UNIT_TIERS, unitSpawner = LASER_NEST_TIERS } ) diff --git a/prototypes/Neutral.lua b/prototypes/Neutral.lua index 77e28cc..f15c592 100755 --- a/prototypes/Neutral.lua +++ b/prototypes/Neutral.lua @@ -8,6 +8,9 @@ local constants = require("Constants") -- constants +local NEUTRAL_UNIT_TIERS = constants.NEUTRAL_UNIT_TIERS +local NEUTRAL_UNIT_VARIATIONS = constants.NEUTRAL_UNIT_VARIATIONS + local NEUTRAL_NEST_TIERS = constants.NEUTRAL_NEST_TIERS local NEUTRAL_NEST_VARIATIONS = constants.NEUTRAL_NEST_VARIATIONS @@ -484,12 +487,12 @@ buildUnitSpawner( createMeleeAttack, { - unit = 10, + unit = NEUTRAL_UNIT_VARIATIONS, unitSpawner = NEUTRAL_NEST_VARIATIONS }, { - unit = 10, + unit = NEUTRAL_UNIT_TIERS, unitSpawner = NEUTRAL_NEST_TIERS } ) @@ -977,12 +980,12 @@ buildUnitSpawner( end, { - unit = 10, + unit = NEUTRAL_UNIT_VARIATIONS, unitSpawner = NEUTRAL_NEST_VARIATIONS }, { - unit = 10, + unit = NEUTRAL_UNIT_TIERS, unitSpawner = NEUTRAL_NEST_TIERS } ) diff --git a/prototypes/Nuclear.lua b/prototypes/Nuclear.lua index f8130cc..778072b 100755 --- a/prototypes/Nuclear.lua +++ b/prototypes/Nuclear.lua @@ -9,6 +9,9 @@ local constants = require("Constants") -- constants +local NUCLEAR_UNIT_TIERS = constants.NUCLEAR_UNIT_TIERS +local NUCLEAR_UNIT_VARIATIONS = constants.NUCLEAR_UNIT_VARIATIONS + local NUCLEAR_NEST_TIERS = constants.NUCLEAR_NEST_TIERS local NUCLEAR_NEST_VARIATIONS = constants.NUCLEAR_NEST_VARIATIONS @@ -540,12 +543,12 @@ buildUnitSpawner( createSuicideAttack, { - unit = 10, + unit = NUCLEAR_UNIT_VARIATIONS, unitSpawner = NUCLEAR_NEST_VARIATIONS }, { - unit = 10, + unit = NUCLEAR_UNIT_TIERS, unitSpawner = NUCLEAR_NEST_TIERS } ) diff --git a/prototypes/Physical.lua b/prototypes/Physical.lua index e78cc13..5ac0b9a 100755 --- a/prototypes/Physical.lua +++ b/prototypes/Physical.lua @@ -2,14 +2,15 @@ local physicalBall = require("utils/AttackBall") local biterUtils = require("utils/BiterUtils") -local smokeUtils = require("utils/SmokeUtils") local swarmUtils = require("SwarmUtils") -local colorUtils = require("utils/ColorUtils") package.path = "../libs/?.lua;" .. package.path local constants = require("Constants") -- constants +local PHYSICAL_UNIT_TIERS = constants.PHYSICAL_UNIT_TIERS +local PHYSICAL_UNIT_VARIATIONS = constants.PHYSICAL_UNIT_VARIATIONS + local PHYSICAL_NEST_TIERS = constants.PHYSICAL_NEST_TIERS local PHYSICAL_NEST_VARIATIONS = constants.PHYSICAL_NEST_VARIATIONS @@ -18,10 +19,6 @@ local PHYSICAL_WORM_VARIATIONS = constants.PHYSICAL_WORM_VARIATIONS -- imported functions -local makeColor = colorUtils.makeColor - -local makeSmokeSoft = smokeUtils.makeSmokeSoft - local buildUnitSpawner = swarmUtils.buildUnitSpawner local buildWorm = swarmUtils.buildWorm local createAttackBall = physicalBall.createAttackBall @@ -491,12 +488,12 @@ buildUnitSpawner( createMeleeAttack, { - unit = 10, + unit = PHYSICAL_UNIT_VARIATIONS, unitSpawner = PHYSICAL_NEST_VARIATIONS }, { - unit = 10, + unit = PHYSICAL_UNIT_TIERS, unitSpawner = PHYSICAL_NEST_TIERS } ) diff --git a/prototypes/Suicide.lua b/prototypes/Suicide.lua index 178ca7e..7f43ee3 100755 --- a/prototypes/Suicide.lua +++ b/prototypes/Suicide.lua @@ -9,6 +9,9 @@ local constants = require("Constants") -- constants +local SUICIDE_UNIT_TIERS = constants.SUICIDE_UNIT_TIERS +local SUICIDE_UNIT_VARIATIONS = constants.SUICIDE_UNIT_VARIATIONS + local SUICIDE_NEST_TIERS = constants.SUICIDE_NEST_TIERS local SUICIDE_NEST_VARIATIONS = constants.SUICIDE_NEST_VARIATIONS @@ -566,12 +569,12 @@ buildUnitSpawner( createSuicideAttack, { - unit = 10, + unit = SUICIDE_UNIT_VARIATIONS, unitSpawner = SUICIDE_NEST_VARIATIONS }, { - unit = 10, + unit = SUICIDE_UNIT_TIERS, unitSpawner = SUICIDE_NEST_TIERS } ) diff --git a/prototypes/SwarmUtils.lua b/prototypes/SwarmUtils.lua index 0705fa2..3b56b5f 100755 --- a/prototypes/SwarmUtils.lua +++ b/prototypes/SwarmUtils.lua @@ -4,6 +4,7 @@ local swarmUtils = {} local biterUtils = require("utils/BiterUtils") package.path = "../?.lua;" .. package.path local mathUtils = require("libs/MathUtils") +local constants = require("libs/Constants") -- imported functions @@ -18,6 +19,9 @@ local mFloor = math.floor local deepcopy = util.table.deepcopy +local TIER_SET_10 = constants.TIER_SET_10 +local TIER_SET_5 = constants.TIER_SET_5 + local xorRandom = mathUtils.xorRandom(settings.startup["rampant-enemySeed"].value) local makeBiterCorpse = biterUtils.makeBiterCorpse @@ -40,9 +44,9 @@ local function unitSetToProbabilityTable(upgradeTable, unitSet) end if upgradeTable then - local points = #upgradeTable * 10 + local points = #unitSet * 10 while (points > 0) do - local index = mFloor(xorRandom() * #upgradeTable)+1 + local index = mFloor(xorRandom() * #unitSet)+1 local upgrade = upgradeTable[index] dividers[index] = dividers[index] + upgrade @@ -280,7 +284,8 @@ end local function buildUnits(template, attackGenerator, upgradeTable, variations, tiers) local unitSet = {} - for t=1, tiers do + for tier=1, tiers do + local t = ((tiers == 5) and TIER_SET_5[tier]) or TIER_SET_10[tier] local result = {} for i=1,variations do @@ -327,7 +332,8 @@ function swarmUtils.buildUnitSpawner(templates, upgradeTable, attackGenerator, v variations.unit, tiers.unit) - for t=1, tiers.unitSpawner do + for tier=1, tiers.unitSpawner do + local t = ((tiers.unitSpawner == 5) and TIER_SET_5[tier]) or TIER_SET_10[tier] for i=1,variations.unitSpawner do local unitSpawner = deepcopy(templates.unitSpawner) unitSpawner.name = unitSpawner.name .. "-v" .. i .. "-t" .. t @@ -352,7 +358,8 @@ function swarmUtils.buildUnitSpawner(templates, upgradeTable, attackGenerator, v end function swarmUtils.buildWorm(template, upgradeTable, attackGenerator, variations, tiers) - for t=1, tiers do + for tier=1, tiers do + local t = ((tiers == 5) and TIER_SET_5[tier]) or TIER_SET_10[tier] for i=1,variations do local worm = deepcopy(template) worm.name = worm.name .. "-v" .. i .. "-t" .. t diff --git a/prototypes/Troll.lua b/prototypes/Troll.lua index e8d9fed..bfe8633 100755 --- a/prototypes/Troll.lua +++ b/prototypes/Troll.lua @@ -2,14 +2,15 @@ local acidBall = require("utils/AttackBall") local biterUtils = require("utils/BiterUtils") -local smokeUtils = require("utils/SmokeUtils") local swarmUtils = require("SwarmUtils") -local colorUtils = require("utils/ColorUtils") package.path = "../libs/?.lua;" .. package.path local constants = require("Constants") -- constants +local TROLL_UNIT_TIERS = constants.TROLL_UNIT_TIERS +local TROLL_UNIT_VARIATIONS = constants.TROLL_UNIT_VARIATIONS + local TROLL_NEST_TIERS = constants.TROLL_NEST_TIERS local TROLL_NEST_VARIATIONS = constants.TROLL_NEST_VARIATIONS @@ -18,10 +19,6 @@ local TROLL_WORM_VARIATIONS = constants.TROLL_WORM_VARIATIONS -- imported functions -local makeColor = colorUtils.makeColor - -local makeSmokeSoft = smokeUtils.makeSmokeSoft - local buildUnitSpawner = swarmUtils.buildUnitSpawner local buildWorm = swarmUtils.buildWorm local createAttackBall = acidBall.createAttackBall @@ -520,12 +517,12 @@ buildUnitSpawner( createMeleeAttack, { - unit = 10, + unit = TROLL_UNIT_VARIATIONS, unitSpawner = TROLL_NEST_VARIATIONS }, { - unit = 10, + unit = TROLL_UNIT_TIERS, unitSpawner = TROLL_NEST_TIERS } ) @@ -1044,12 +1041,12 @@ buildUnitSpawner( end, { - unit = 10, + unit = TROLL_UNIT_VARIATIONS, unitSpawner = TROLL_NEST_VARIATIONS }, { - unit = 10, + unit = TROLL_UNIT_TIERS, unitSpawner = TROLL_NEST_TIERS } ) diff --git a/settings.lua b/settings.lua index c176283..a6eb60a 100755 --- a/settings.lua +++ b/settings.lua @@ -66,17 +66,6 @@ data:extend({ order = "c[modifier]-a[threshold]", per_user = false }, - - { - type = "int-setting", - name = "rampant-newEnemyVariations", - setting_type = "startup", - minimum_value = 1, - maximum_value = 20, - default_value = 1, - order = "d[modifier]-b[wave]", - per_user = false - }, { type = "int-setting", @@ -257,8 +246,77 @@ data:extend({ default_value = false, order = "l[modifier]-b[unit]", per_user = false + }, + + + { + type = "int-setting", + name = "rampant-newEnemyNestTiers", + description = "rampant-newEnemyNestTiers", + setting_type = "startup", + default_value = 5, + allowed_values = { 5, 10 }, + order = "l[modifer]-b[seed]", + per_user = false + }, + + { + type = "int-setting", + name = "rampant-newEnemyNestVariations", + description = "rampant-newEnemyNestVariations", + setting_type = "startup", + minimum_value = 1, + maximum_value = 20, + default_value = 1, + order = "d[modifier]-b[wave]", + per_user = false + }, + + { + type = "int-setting", + name = "rampant-newEnemyWormTiers", + description = "rampant-newEnemyWormTiers", + setting_type = "startup", + default_value = 5, + allowed_values = { 5, 10 }, + order = "l[modifer]-b[seed]", + per_user = false + }, + + { + type = "int-setting", + name = "rampant-newEnemyWormVariations", + description = "rampant-newEnemyWormVariations", + setting_type = "startup", + minimum_value = 1, + maximum_value = 20, + default_value = 1, + order = "d[modifier]-b[wave]", + per_user = false + }, + + { + type = "int-setting", + name = "rampant-newEnemyUnitTiers", + description = "rampant-newEnemyUnitTiers", + setting_type = "startup", + default_value = 5, + allowed_values = { 5, 10 }, + order = "l[modifer]-b[seed]", + per_user = false + }, + + { + type = "int-setting", + name = "rampant-newEnemyUnitVariations", + description = "rampant-newEnemyUnitVariations", + setting_type = "startup", + minimum_value = 1, + maximum_value = 20, + default_value = 1, + order = "d[modifier]-b[wave]", + per_user = false } - -- { -- type = "bool-setting",