From b6dd63a649f5b332c1601518e39476961668acbe Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Sun, 30 Jun 2024 13:44:55 -0400 Subject: [PATCH] v2.5.0: fixed ghost and smith enchant RNG outcomes affecting levelgen --- .../actors/mobs/npcs/Blacksmith.java | 10 +++++++--- .../shatteredpixeldungeon/actors/mobs/npcs/Ghost.java | 10 +++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Blacksmith.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Blacksmith.java index cb9310aba..0291374dc 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Blacksmith.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Blacksmith.java @@ -469,10 +469,14 @@ public class Blacksmith extends NPC { } // 30% base chance to be enchanted, stored separately so status isn't revealed early + //we generate first so that the outcome doesn't affect the number of RNG rolls + smithEnchant = Weapon.Enchantment.random(); + smithGlyph = Armor.Glyph.random(); + float enchantRoll = Random.Float(); - if (enchantRoll <= 0.3f * ParchmentScrap.enchantChanceMultiplier()){ - smithEnchant = Weapon.Enchantment.random(); - smithGlyph = Armor.Glyph.random(); + if (enchantRoll > 0.3f * ParchmentScrap.enchantChanceMultiplier()){ + smithEnchant = null; + smithGlyph = null; } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Ghost.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Ghost.java index 317aaaefb..7340dd15a 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Ghost.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Ghost.java @@ -351,10 +351,14 @@ public class Ghost extends NPC { armor.upgrade(itemLevel); // 20% base chance to be enchanted, stored separately so status isn't revealed early + //we generate first so that the outcome doesn't affect the number of RNG rolls + enchant = Weapon.Enchantment.random(); + glyph = Armor.Glyph.random(); + float enchantRoll = Random.Float(); - if (enchantRoll < 0.2f * ParchmentScrap.enchantChanceMultiplier()){ - enchant = Weapon.Enchantment.random(); - glyph = Armor.Glyph.random(); + if (enchantRoll > 0.2f * ParchmentScrap.enchantChanceMultiplier()){ + enchant = null; + glyph = null; } }