This page is updated for Update 15
Difficulty.txt is a file that was added in Update 15 and controls much of the game's difficulty. From here you can control the customizable difficulty settings and the enemy generation algorithms.
The enemy generation difficulty curve is controlled by the "config.enemydifficulty" node. Here you can define the tier and amount of enemies that will spawn for any given "difficulty rating".
The algorithm itself and the difficulty rating differ by type of battles. For example, Scavenge difficulty is determined by the biome and distance from the base. For base defense, every day the difficulty score increases by 10, so at day 100 you would be attacked with a difficulty score of 1000. See below for more details on each battle type.
The format within the enemy difficulty setting is as follows:
# Tier 0 config.enemydifficulty.tiers.0=0 config.enemydifficulty.singlevalue.0=1 config.enemydifficulty.amountpergroup.0=2 config.enemydifficulty.totalcount.0=1 config.enemydifficulty.totalcount.19=1 config.enemydifficulty.totalcount.20=2-3 config.enemydifficulty.amountpergroup.60=3 config.enemydifficulty.totalcount.99=4-7 # Tier 1 config.enemydifficulty.tiers.100=1 config.enemydifficulty.singlevalue.100=2 config.enemydifficulty.amountpergroup.100=2 config.enemydifficulty.totalcount.100=3-4 config.enemydifficulty.amountpergroup.250=3 config.enemydifficulty.totalcount.349=5-7
Tier defines the enemy and loot tier per difficulty score. In the example above "tiers.0=0" means that at difficulty score 0 and above, enemies will be of tier 0, and then "tiers.100=1" means that above difficulty 100 the enemies will be of tier 1.
Single value should be combined with tier, and determines the relative value of a single enemy in this tier. The baseline is that each tier is worth twice that of the tier before it. These should always be defined at the same difficulty score as the tier. In the example above, at difficulty 0 a single enemy is worth 1 (singelvalue.0=1), and at difficulty 100, a single enemy is worth 2 (singlevalue.100=2).
These will be used by the algorithm to determine how many enemies of a lower or higher tier to generate, based on the settings for the current tier.
config.enemydifficulty.totalcount.0=1 config.enemydifficulty.totalcount.19=1 config.enemydifficulty.totalcount.20=2-3 config.enemydifficulty.totalcount.99=4-7
Total count determines the total amount of enemies. The settings above mean that between difficulty 0 and 19 there will be 1 enemy of the current tier (tier 0 in this case). The algorithm will multiply this value by the "singlevalue" setting, so in this case the total value of all enemies will be 1.
At difficulty 20 there will be 2 to 3 enemies total, and at difficulty 99 there will be 4 to 7 enemies. In between, however, the amount will scale depending on the actual difficulty score. Say the score is 40, that's 25% of the way from 20 to 99, so the difficulty 20 values will have a weight of 75%, and the difficulty 99 values will have a weight of 25%. The RNG will then choose a value for each level, and calculate the result according to the weights. For example, let's say the RNG chose 3 from the 20 setting, and 6 from the 99 setting - then the final result would be 3 * 75% + 6 * 25% = 3.75 - 25% of the way between 3 and 6, and that will be the total enemy count. If the difficulty score had been 80 instead of 40, the weights would be reversed and the total amount would be 3 * 25% + 6 * 75% = 5.25.
These numbers are multiplied by the "single value" of the same level. Take this example:
config.enemydifficulty.totalcount.0=3 config.enemydifficulty.singlevalue.0=1 config.enemydifficulty.totalcount.100=3 config.enemydifficulty.singlevalue.100=2
It would appear that no matter if the difficulty was 0, 50 or 99, there would always be 3 total enemies because both level 0 and level 100 have a value of 3. This is not the case, however, since at level 100 a single enemy is worth 2 and not 1, double that of a level 0 enemy. So say for difficulty 50, the calculation would be 3 * 1 * 50% + 3 * 2 * 50%, and then the total count would be 4.5, which means 4.5 enemies of tier 0, or 2.25 enemies of tier 1, that are worth 2 each.
Bottom line, the total count lets you define how many enemies of the current tier level and the algorithm will scale it automatically when between tiers.
Amount Per Group
config.enemydifficulty.amountpergroup.0=2 config.enemydifficulty.amountpergroup.60=3 config.enemydifficulty.amountpergroup.100=2 config.enemydifficulty.amountpergroup.250=3
Amount per group determines how many enemies of the current tier level will be in each group, when enemies are divided to groups (scavenge, for example).
Unlike total count, these numbers do not scale between levels, so at difficulty 0 and at difficulty of 50, the same setting will apply - 2 enemies per group. The number is, however, still multiplied by the single value. So at level 0, there will be 2 enemies per group, each worth 1, and at level 100, there will be 2 enemies per group, but each worth 2 - so a total value of 4. That means there can be 4 tier 0 enemies at level 100, or 2 level 1 enemies, per group.
These values usually have more than one milestone per tier, because as the total amount scales and grows towards the next tier, you may want bigger groups instead of many smaller groups.
Total Count Multiplier
In many instances, there will be a multiplier to the total count, which will affect the total amount of enemies, but not their tier or the number of enemies per group.
Some of these multipliers are defined in the Difficulty.txt file:
config.enemydifficulty.multipliers.defense.0=0.5 config.enemydifficulty.multipliers.defense.20=0.9 config.enemydifficulty.multipliers.defense.200=1.2 config.enemydifficulty.multipliers.rescuedefense.0=0.35 config.enemydifficulty.multipliers.randomevent.0=1 config.enemydifficulty.multipliers.encounter.0=0.4 config.enemydifficulty.multipliers.rescuestart.0=0.5 config.enemydifficulty.multipliers.scavenge.0=1
The example above defines the multiplier for different scenarios and different difficulty levels. For example, for base defense, at difficulty 0 to 20 (days 0-2), the total enemy count is 50% of what the algorithm would generate. Then at days 2-20 (difficulty 20 - 200), the total count is 90% of what it is in scavenge missions. The reason we lower them in the beginning is that the number of survivors you have while defending the base are more or less the same amount you would take on a scavenge missions. Later on, after day 20, we expect you have more survivors and your defensive capabilities are stronger than offensive capabilities, so the attack is stronger than a scavenge mission.
See below for a more detailed explanation of each combat scenario.
Enemy Generation per Battle Type
In this section we will describe how the algorithm generates enemies for each battle type.
Scavenge is the most straightforward, and uses the difficulty settings "as is". It calculates the total value for the given difficulty level based on the "totalcount" and "singlevalue" settings, then generates group after group using the "amountpergroup" setting, until the total count has been reached.
The difficulty level for scavenge combat is determined by several factors. The first two factors are which biome and the distance from base. The mapping between biome/distance to difficulty is configured in Config.txt under the "terrain.entity" nodes. Another factor is the scavenge map location, as defined in Objects.txt. These can have multipliers that are applied to the base value. For example, military bases have a difficulty of 50% above the other locations in the same biome/distance. Last, there is the scavenge multiplier defined in the Multipliers section above, this is set to 1 by default so will have no effect unless changed.
Rescue missions are a bit more complex. First, the base difficulty level of a rescue mission is determined by the amount of survivors you already have, as mapped out in Difficulty.txt:
config.rescuedifficulty.survivorcount.0=10 config.rescuedifficulty.survivorcount.4=10-59 config.rescuedifficulty.survivorcount.6=80-150
In the example above, with 0 to 3 survivors, the rescue mission base difficulty will be 10. With 4 or 5 survivors, the difficulty will be between 10 and 59.
Now, for the initial enemies in the rescue area, the regular generation algorithm is used, and the total count is multiplied by the value defined in the Multipliers section above, by default 50%. So the starting enemies of a rescue mission will be 50% of those in a scavenge mission of the same difficulty.
Next, as the player starts rescuing the trapped survivor, more enemies are spawned according to the definitions of the "trappedsurvivor" object in Objects.txt.
objects.entity.trappedsurvivor.combatactions.rescue.enemyspawn.60=0.3 objects.entity.trappedsurvivor.combatactions.rescue.enemyspawn.120=0.4 objects.entity.trappedsurvivor.combatactions.rescue.enemyspawn.180=0.4 objects.entity.trappedsurvivor.combatactions.rescue.enemyspawn.240=0.5 objects.entity.trappedsurvivor.combatactions.rescue.enemyspawn.340=0.6 objects.entity.trappedsurvivor.combatactions.rescue.enemyspawn.440=0.6 objects.entity.trappedsurvivor.combatactions.rescue.maxspawns.0=1 objects.entity.trappedsurvivor.combatactions.rescue.maxspawns.100=2 objects.entity.trappedsurvivor.combatactions.rescue.maxspawns.350=999
The first spawn begins 60 time units after the rescue attempt begins. These spawns will always consist of a single group of enemies, regardless of the "amountpergroup" setting. The total value is multiplied by the values defined above. The first spawn will have 30% of the number of enemies for the given difficulty. The second spawn at 120 time units will be 40% of the strength, and so on.
The other setting is "maxspawns", which determines how many times enemies will spawn during rescue missions. By default, they will only spawn once until difficulty 100, and two times until difficulty 350. After that they will spawn an indefinite amount of times, encouraging players to finish the rescue as quickly as possible once it's started, and get out of there quickly (however only 6 spawns are defined, at time units 60 to 440, so that is the actual maximum).
Note that time is accelerated when rescuing a survivor if no enemies are present, so the player will see the rescue progress grow real fast and enemies will spawn quickly.
Defense difficulty is determined by game time passed (in game minutes) divided by a "defense divisor" parameter:
By default, the divisor is always 144, which means that every 144 game minutes (= 2.4 game hours) the difficulty increases by one. This translates to 10 difficulty points per day (24 hours).
You can add more levels to the divisor, causing the difficulty level to increase faster or slower after reaching a certain day:
In this example, after reaching day 10 (14400 game minutes), the difficulty will increase by 20 per day (1440 minutes a day / 72 = 20).
The enemy generator uses the difficulty to generate enemies as is, the same way it would in a scavenge mission, except it's multiplied by the defense multiplier instead of the scavenge multiplier. See Total Count Multiplier above.
The difficulty of an encounter is determined by the biome and distance from base, same as with scavenge, except there is no location multiplier.
The generator creates a single group with all enemies, ignoring the "amountpergroup" value, but the total amount is multiplier by the encounter multiplier, which is 0.4 by default. This means that by default the amount of enemies in an encounter will be 40% of the amount in a scavenge mission, however they will all be in one group.
Map-based combat for random events, such as the demon scouts, settlement assistance requests, and the werewolf in night howls, use the same algorithm to generate enemies as in scavenge, and the amount is multiplied by the random event multiplier, default 1.
The difficulty for random events differs from event to event and is determined by the configuration of that specific event. Most are derived from game time.