diff --git a/core/src/main/assets/messages/items/items.properties b/core/src/main/assets/messages/items/items.properties index 703c4b43b..780ef40e9 100644 --- a/core/src/main/assets/messages/items/items.properties +++ b/core/src/main/assets/messages/items/items.properties @@ -742,7 +742,7 @@ items.potions.brews.shockingbrew.name=shocking brew items.potions.brews.shockingbrew.desc=When shattered, this brew will unleash an electrical storm in a wide area around the location it breaks at. items.potions.brews.unstablebrew.name=unstable brew -items.potions.brews.unstablebrew.desc=This magical brew glows with shifting colors of the rainbow. When drank or thrown it will trigger the effect of a random potion. +items.potions.brews.unstablebrew.desc=This magical brew glows with shifting colors of the rainbow.\n\nWhen drank or thrown it will trigger the effect of a random potion. The potion effect will be more likely to be suitable to how the brew is used. ###elixirs items.potions.elixirs.elixirofarcanearmor.name=elixir of arcane armor @@ -1225,7 +1225,7 @@ items.spells.telekineticgrab.no_target=There's nothing to grab there. items.spells.telekineticgrab.desc=This spell allows the caster to remotely grab all items at a location, or all thrown weapons stuck to an enemy!\n\nIt can't be used to grab items that someone else owns, or to grab containers like chests. items.spells.unstablespell.name=unstable spell -items.spells.unstablespell.desc=This small black square crystal has shifting runic symbols on each of its surfaces. When activated, it will trigger the effect of a random scroll. +items.spells.unstablespell.desc=This small black square crystal has shifting runic symbols on each of its surfaces.\n\nWhen activated, it will trigger the effect of a random scroll. The scroll effect will be more or less likely to be combat-focused depending on whether there are enemies in your field of view. items.spells.wildenergy.name=wild energy items.spells.wildenergy.desc=This spell contains some of the cursed energy which powered DM-300. When cast, it will recharge your wands and worn artifacts, while also triggering a random cursed wand effect. You are able to choose a direction for this cursed magic to shoot in, however. diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/Potion.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/Potion.java index 8e1629f0b..070259c05 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/Potion.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/Potion.java @@ -101,8 +101,8 @@ public class Potion extends Item { put("ivory",ItemSpriteSheet.POTION_IVORY); } }; - - private static final HashSet> mustThrowPots = new HashSet<>(); + + protected static final HashSet> mustThrowPots = new HashSet<>(); static{ mustThrowPots.add(PotionOfToxicGas.class); mustThrowPots.add(PotionOfLiquidFlame.class); @@ -118,7 +118,7 @@ public class Potion extends Item { //also all brews except unstable, hardcoded } - private static final HashSet> canThrowPots = new HashSet<>(); + protected static final HashSet> canThrowPots = new HashSet<>(); static{ canThrowPots.add(PotionOfPurity.class); canThrowPots.add(PotionOfLevitation.class); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/brews/UnstableBrew.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/brews/UnstableBrew.java index 3261e52a8..b9a6cfa58 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/brews/UnstableBrew.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/brews/UnstableBrew.java @@ -81,18 +81,35 @@ public class UnstableBrew extends Brew { @Override public void apply(Hero hero) { - Potion p = Reflection.newInstance(Random.chances(potionChances)); //Don't allow this to roll healing in pharma - while (Dungeon.isChallenged(Challenges.NO_HEALING) && p instanceof PotionOfHealing){ + if (Dungeon.isChallenged(Challenges.NO_HEALING)){ + potionChances.put(PotionOfHealing.class, 0f); + } + + Potion p = Reflection.newInstance(Random.chances(potionChances)); + + //reroll the potion once if it wasn't a good potion to drink + if (mustThrowPots.contains(p.getClass())){ p = Reflection.newInstance(Random.chances(potionChances)); } + p.anonymize(); p.apply(hero); + + if (Dungeon.isChallenged(Challenges.NO_HEALING)){ + potionChances.put(PotionOfHealing.class, 3f); + } } @Override public void shatter(int cell) { Potion p = Reflection.newInstance(Random.chances(potionChances)); + + //reroll the potion once if it wasn't a good potion to throw + if (!mustThrowPots.contains(p.getClass()) && !canThrowPots.contains(p.getClass())){ + p = Reflection.newInstance(Random.chances(potionChances)); + } + p.anonymize(); curItem = p; p.shatter(cell); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/spells/UnstableSpell.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/spells/UnstableSpell.java index 8ea36d076..9b21c6fea 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/spells/UnstableSpell.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/spells/UnstableSpell.java @@ -43,6 +43,7 @@ import com.watabou.utils.Reflection; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; public class UnstableSpell extends Spell { @@ -64,6 +65,28 @@ public class UnstableSpell extends Spell { scrollChances.put( ScrollOfTerror.class, 2f ); scrollChances.put( ScrollOfTransmutation.class, 1f ); } + + private static HashSet> nonCombatScrolls = new HashSet<>(); + static { + nonCombatScrolls.add( ScrollOfIdentify.class ); + nonCombatScrolls.add( ScrollOfRemoveCurse.class ); + nonCombatScrolls.add( ScrollOfMagicMapping.class ); + nonCombatScrolls.add( ScrollOfRecharging.class ); + nonCombatScrolls.add( ScrollOfLullaby.class ); + nonCombatScrolls.add( ScrollOfTeleportation.class ); + nonCombatScrolls.add( ScrollOfTransmutation.class ); + } + + private static HashSet> combatScrolls = new HashSet<>(); + static { + combatScrolls.add( ScrollOfMirrorImage.class ); + combatScrolls.add( ScrollOfRecharging.class ); + combatScrolls.add( ScrollOfLullaby.class ); + combatScrolls.add( ScrollOfRetribution.class ); + combatScrolls.add( ScrollOfRage.class ); + combatScrolls.add( ScrollOfTeleportation.class ); + combatScrolls.add( ScrollOfTerror.class ); + } @Override protected void onCast(Hero hero) { @@ -72,6 +95,17 @@ public class UnstableSpell extends Spell { updateQuickslot(); Scroll s = Reflection.newInstance(Random.chances(scrollChances)); + + boolean enemy = hero.visibleEnemies() != 0; + + //reroll the scroll once if there is an enemy and it is a non-combat scroll + // or if there is no enemy and it is a combat scroll + if (enemy && nonCombatScrolls.contains(s.getClass())){ + s = Reflection.newInstance(Random.chances(scrollChances)); + } else if (!enemy && combatScrolls.contains(s.getClass())){ + s = Reflection.newInstance(Random.chances(scrollChances)); + } + s.anonymize(); curItem = s; s.doRead();