Enemies

## Level

The level of a monster is determined according to the following algorithm:

1. Initialize the monster level to zero,
2. Consider the "Monster Level System" option, which can be either "Player", "Level" or "Both" (the default). If the "Player" level system is active, add to the level the level of the player, multiplied by the "Monster Level Weight" option (default 1.0). If the "Level" system is active, add the map number, multiplied by the "Monster Map Weight" option (default 3.0),
3. If the player has a negative value for the Luck stat, add the absolute value of Luck,
4. Multiply the monster level by a random value between the configurable range 0.8 to 1.2,
5. If the monster is a boss, add 10 times the game difficulty level,
6. If the monster is a megaboss, add 1000 times the number of players divided by 8,

## Stats

Every monster has a unique set of stat values, of the same types available to the player. Generating the stats follows this algorithm:

1. Determine the pool of stat points to allocate as 40 plus the game difficulty times the monster level,
2. If monster stat specialization is enabled (it is by default), randomly choose two stats to emphasize and four stats to deemphasize. The emphasized stats have on average 50% higher values than the unaffected stats, and the deemphasized have on average half the unaffected value,
3. Otherwise, assign the stat points uniformly at random,
4. Ensure that every monster has at least a value of one for every stat.

## Aura generation

After initial level and stat generation, a monster may be given one or more auras. First, there is a roll to determine whether the monster has an aura at all. This depends primarily on the luck stat of the monster. More precisely,

```
AuraChance = 31 + MonsterAuraCurve * 100 / 97) + (MonsterLuck * 100 / 97))

```

where MonsterAuraCurve is an option that defaults to zero. The AuraChance is forced within 0 to 1000 and is then adjusted by:

```
AuraChance  = AuraChance^2 / 10000

```

to represent the percent chance of the monster having an aura. On Hell difficulty or above, AuraChance is increased by 5%. Auras are more likely when the player is on a Kill Aura mission. During the All Auras or Harmonized Auras map event a monster will always have an aura.

If the monster is lucky enough to have auras, the next roll determines the number of auras. This depends mostly on the energy stat of the monster. More precisely, a random number AuraRand is chosen between MonsterEnergy/10 and 200. Then AuraNumber is computed as:

```
AuraNumber = AuraRand^2 / 4000

```

and AuraNumber is bounded between 1 and 9. That many auras are selected at random.

If the "Are you a bad enough dude?" option is enabled, all monsters will have every aura.

## Aura effects

Just like player auras, monster auras come in 9 different colors and pertain to a particular stat, with the exception of the white aura. When killed, a monster with an aura will drop a vial that boosts the corresponding stat, with white dropping a stim. There is also a 2% chance of dropping a rare vial.

### White

Doubles the level of the monster and adds the corresponding amount of stat points, which are distributed randomly, without specialization. The monster will level up other monsters within 512 distance, every this many seconds (min 1):

```
60.0 - MonsterEnergy / 16.75

```

### Red

* Doubles the Strength stat
* When damaged, has a percentage chance of cursing the player, increased by the monster Strength and decreased by the distance to the player:

```
CurseChance = MonsterStrength / 10 - DistanceToPlayer / 5.12

```

* When EP attacked, has a percentage chance of silencing the player that is more dependent on the monster Strength, and less on distance:

```
SilenceChance = MonsterStrength / 5 - DistanceToPlayer / 10.24

```

### Pink

Doubles the Vitality stat, and resurrects dead monsters within 128 distance of the monster with the pink aura. This happens every this many seconds:

```
(30 - (20 * MonsterVitality / 1000))

```

where MonsterVitality is capped at 1000.

### Blue

Doubles the Energy stat and drains EP of nearby players, as long as the monster can see the player and is closer to the player than:

```
MonsterRadius * GameSkill * 4 + MonsterRadius

```

where MonsterRadius is the radius of the monster collision box.

It is not possible to steal from players with a level 3 or higher pink aura, or a pink soul.

The drain amount is proportional to the energy stat of the monster and a configurable multiplier (1.0):

```
MonsterEnergy / 10 * AuraStealAmountOption

```

### Purple

Doubles the Regeneration stat and triples the speed of regeneration. Monsters within 512 distance of a monster with a purple aura heal 10% of their health at the same rate as regeneration.

### Orange

Doubles the Agility stat and tries to teleport to the farthest player it can see, every 10 seconds, with the percentage chance of success:

```
DistanceToPlayer / 40.96 + 25.0 * MonsterAgility / 1000.0

```

### Dark Blue

Doubles the Capacity stat and tries to steal ammo from the player. To steal, the monster must see the player and be within the same distance as for draining EP using the Blue aura.

The amount stolen is generally:

```
MonsterCapacity / AmmoTypeDivisor * AuraStealAmountOption

```

where the AmmoTypeDivisor is 7.5 for bullets, 30 for shells, 60 for rockets and 20 for cells.

### Yellow

Doubles the Luck stat and tries to steal money from the player. To steal, the monster must see the player and be within the same distance as for draining EP using the Blue aura. The amount of credits stolen is:

```
MonsterLuck * AuraStealAmountOption

```

## Regeneration

Monsters regenerate health over time. The increase per 30 seconds is:

```
RegenAmount = (MonsterHealthMax * MonsterRegeneration) / 1000

```

Once the monster has regenerated 10 times its maximum health, the RegenAmount is further divided by 10.

## Threat level

The threat level of a monster is the sum of all of the following (up to a cap of 10):

* The base threat level of a Doom RLA monster, if applicable,
* The sum of all the monster's stats, divided by 800,
* The number of auras on the monster,
* 1 point for a boss, 2 additional for a megaboss.