Here's partial code that makes the magic happen:
Code:
{
EnemyDifficulty enemyDifficulty = Game.Instance.Player.Difficulty.EnemyDifficulty;
int num = (int)(enemyDifficulty - 1);
BlueprintDifficultyList.StatsAdjustmentPreset adjustmentPreset =
BlueprintRoot.Instance.DifficultyList.GetAdjustmentPreset(Game.Instance.Player.Difficulty.StatsAdjustmentsType);
int value = BasicStatBonus * (adjustmentPreset.BasicStatBonusMultiplier + num);
int value2 = DerivativeStatBonus * (adjustmentPreset.DerivativeStatBonusMultiplier + num);
//the BasicStatBonusMultiplier and DerivativeStatBonusMultiplier seem to default to 1.
It's possible that certain monsters or bosses have that stat set higher, which would effectively
act the same as increasing the Enemy Difficulty setting another notch without an upper-limit.
m_StrengthModifier = base.Owner.Stats.Strength.AddModifier(value, this, ModifierDescriptor.Difficulty);
//does the same for the other 5 stats
m_SkillPerceptionModifier = base.Owner.Stats.SkillPerception.AddModifier(value2, this, ModifierDescriptor.Difficulty);
//does the same for AC, attack modifier, and saves.
}
It looks more complicated that it is, but gist is the math works out so that the weak, normal, strengthened, and insane options grant a -2, 0, +2, +4 bonus to the modifiers of various stats. The important distinction to make here is that the bonus is added to the modifier and not the base score. So if a Troll has a Strength of 26 (+8), bumping the difficulty up one notch would turn it into a 26 (+10). Notice that the actual Strength score doesn't increase; just the modifier.
Anyway, it does that for the six core stats (Str, Dex, Con, Int, Wis, Cha), and then does it again for perception, AC, attack, and saves. The problem here is that the "derivative" stats are double-dipping when the difficulty changes. So a Normal Troll has +8 Strength mod, but a Strengthened Troll will have a +10 and a +2 attack modifier. So end result is a Strengthened Troll effectively has 8 higher strength than normal. If you bump it up to an Insane Troll, it gets a +12 Strength mod and a +4 attack modifier, effectively granting the troll 16 Strength higher than normal.
The exact same thing is happening with AC, because it gets both a Dexterity mod boost and a flat AC boost. Same with saving throws and perception.