Difficulty
Difficulty is a hidden number used by the game to determine how many enemies need to be spawned at the end of level generation (before cluster spawns take effect) and which weapons are allowed to drop at a time. With higher difficulty more enemies are going to spawn and higher-tier weapons may drop.
Difficulty starts at 1 on 1-1, and is incremented by 1 (2 in hardmode) every time the player enters a new level, at the beginning of level generation. Skipping levels will decrease your difficulty relative to a normal run and visiting bonus levels, such as pizza sewers and crown vaults, will increase it.
Weapon Drops
Weapon drop logic relies on difficulty to determine how many weapons are allowed to drop at any point. As difficulty naturally increases more and more weapons are able to drop, typically with the later weapons being the more powerful ones, creating a steady power progression in the run.
Internally, every weapon has a set tier, a number used for comparison against difficulty. If a weapon's tier is higher than current difficulty it can't drop, but if it's equal or lower than current difficulty it can, with the same odds as every other weapon.
Different sources of weapons have different bonuses that are added to the difficulty number while choosing the weapon to drop, with some being able to find more advanced weapons earlier than others. The bonuses include:
- Enemy drop: +0 (neutral)
- Chest: +1
- Big chest: +1
- Cursed chest: +3
- Big cursed chest: +4
- Crib giant chest: +6
- Gun gun: +10
Both types of cursed chests have a tier floor that prevents weapons of tier lower than 3 from ever dropping. Robot's Ultra A (Refined Taste) sets the tier floor to 6 for every weapon source, even overriding cursed chests' default floor. Playing as robot also gives an additional +1 bonus that stacks with normal bonuses.
Hardmode performs some manipulations on the difficulty number before using it to choose the dropped weapon. The effective difficulty is adjusted using this formula: `ceil((diff - 13) / 3)`. Considering hardmode's starting difficulty of 18 and doubled difficulty growth rate, this brings the effective difficulty down to preloop levels and slows down its growth by 33% compared to normal mode. This adjustment is made before drop bonuses are applied.
The way players think about weapons' minimum difficulty required to drop is typically in levels where the difficulty required is just reached, without any increases from pizza, vaults or others, with +1 chest drop bonus being the baseline, and enemy drops having a -1 penalty. It's not technically correct, but common.
Examples
Wrench has a tier of `1`, and at the very beginning of the run on 1-1 may drop from enemies like maggot nests. Assault rifle has a tier of `2` and won't drop from enemies on the same level, but can be found from chests because of their drop bonus of +1. In common notation both of them are 1-1 weapons, and both drop there because chest bonus is the assumption.
Triple Machinegun has a tier of `4`. On 1-3 the difficulty is only `3`, but this weapon may drop from a chest. In common notation it's a 1-3 weapon because of this.
Pop Gun has a tier of `3`, and from chests may be found on 1-2. Playing as robot gives a constant +1 drop bonus that allows the character to find this weapon from a chest even on 1-1: `1+1+1`.
Auto Crossbow has a tier of `7`. Normally the earliest you can get it from a normal chest is 3-2 (`6+1`), but if in the run you visited Pizza sewers your difficulty will be higher. Pizza difficulty is an additional level, meaning that visiting it doesn't skip any of the normal path levels. 2-1 to 2-? to 3-1 is a longer path than 2-1 to 3-1, and increments the difficulty more. With this increment you may find the Auto Crossbow on 3-1 (`6+1`).
Energy Sword has a tier of `10`, and from normal chests may be found on 5-1. On 3-3 without any difficulty increases the difficulty is `7`, which is just enough to find the energy sword from a cursed chest: `7+3`.
Going into Oasis from 1-1 will take you to 1-? and then 3-3. With this path, you've been on 3 levels and so you have `3` difficulty on 3-3, compared to the normal `7` this is a loss of `4` difficulty. A weapon that may be found on 3-3 (assuming chest bonus) will only start dropping from 5-3.
Super Plasma Cannon has a tier of `16`. Having gone into pizza and a vault, on 5-2 the difficulty will be `12`. Cursed chests have a drop bonus of +3, and playing as Robot will give another +1 bonus that will be just enough to find SPC this early: `12+3+1`. Other characters can find it from a 5-3 cursed chest.
A run that has gone into the Jungle but didn't get any other difficulty increases on 5-3 will have the exact same difficulty as a completely straight run. Jungle is not an additional level; it replaces 5-2 with itself, leaving the path length exactly the same as normal (5-1 5-2 5-3 vs 5-1 5-? 5-3).
Charts
Enemy Quantity
The difficulty number is used by the level generator as the odds of an enemy spawning on each floor tile and as a minimum of enemies that must spawn on a level.
After the level generator has finished building the layout of the level, it begins population. Population also involves placing down props and vaults, but for the purpose of this section only enemy spawning will be described.
The generator cycles through every floor tile it has placed. Floors that are too close to the player's spawn point will be skipped, along with floors that already have a chest or rad canister on them. Then, a stage-specific check is done, and if it's succesful an enemy will be spawned on the current floor. Each cycle may spawn its own enemy on the same floor tiles. The cycles end after they've gone through every floor.
There are three stages of enemy population:
- The first stage rolls `difficulty/(difficulty+10)` to decide if an enemy should spawn on the current floor.
- The second stage always spawns an enemy on the current floor if the number of currently spawned enemies is lower than `3+(difficulty/1.5)`. When there are enough enemies it will do nothing more, but if the difficulty is high enough it may run out of floor tiles before the minimum can be reached. In that case the stage will not be re-run, limiting it to the amount of floor tiles.
- The third stage only happens with Crown of Blood. It rolls `difficulty/(difficulty+8)` to decide if it should spawn an enemy on the current floor.
Cluster Spawns
On loops, after normal enemy population is done the level generator will begin multiplying the enemies. Similar to floors, the generator cycles through every spawned enemy and for each one of them rolls `loop/60`. If the roll succeeds, `loop+3` more additional enemies of the same type will spawn in the same place.