v2.4.0: unstable brew/spell are now more likely to roll a useful effect

This commit is contained in:
Evan Debenham
2024-03-07 14:20:54 -05:00
parent 9b723f36bc
commit bf0b95aa96
4 changed files with 58 additions and 7 deletions

View File

@@ -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.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.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 ###elixirs
items.potions.elixirs.elixirofarcanearmor.name=elixir of arcane armor 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.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.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.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. 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.

View File

@@ -101,8 +101,8 @@ public class Potion extends Item {
put("ivory",ItemSpriteSheet.POTION_IVORY); put("ivory",ItemSpriteSheet.POTION_IVORY);
} }
}; };
private static final HashSet<Class<?extends Potion>> mustThrowPots = new HashSet<>(); protected static final HashSet<Class<?extends Potion>> mustThrowPots = new HashSet<>();
static{ static{
mustThrowPots.add(PotionOfToxicGas.class); mustThrowPots.add(PotionOfToxicGas.class);
mustThrowPots.add(PotionOfLiquidFlame.class); mustThrowPots.add(PotionOfLiquidFlame.class);
@@ -118,7 +118,7 @@ public class Potion extends Item {
//also all brews except unstable, hardcoded //also all brews except unstable, hardcoded
} }
private static final HashSet<Class<?extends Potion>> canThrowPots = new HashSet<>(); protected static final HashSet<Class<?extends Potion>> canThrowPots = new HashSet<>();
static{ static{
canThrowPots.add(PotionOfPurity.class); canThrowPots.add(PotionOfPurity.class);
canThrowPots.add(PotionOfLevitation.class); canThrowPots.add(PotionOfLevitation.class);

View File

@@ -81,18 +81,35 @@ public class UnstableBrew extends Brew {
@Override @Override
public void apply(Hero hero) { public void apply(Hero hero) {
Potion p = Reflection.newInstance(Random.chances(potionChances));
//Don't allow this to roll healing in pharma //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 = Reflection.newInstance(Random.chances(potionChances));
} }
p.anonymize(); p.anonymize();
p.apply(hero); p.apply(hero);
if (Dungeon.isChallenged(Challenges.NO_HEALING)){
potionChances.put(PotionOfHealing.class, 3f);
}
} }
@Override @Override
public void shatter(int cell) { public void shatter(int cell) {
Potion p = Reflection.newInstance(Random.chances(potionChances)); 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(); p.anonymize();
curItem = p; curItem = p;
p.shatter(cell); p.shatter(cell);

View File

@@ -43,6 +43,7 @@ import com.watabou.utils.Reflection;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
public class UnstableSpell extends Spell { public class UnstableSpell extends Spell {
@@ -64,6 +65,28 @@ public class UnstableSpell extends Spell {
scrollChances.put( ScrollOfTerror.class, 2f ); scrollChances.put( ScrollOfTerror.class, 2f );
scrollChances.put( ScrollOfTransmutation.class, 1f ); scrollChances.put( ScrollOfTransmutation.class, 1f );
} }
private static HashSet<Class<? extends Scroll>> 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<Class<? extends Scroll>> 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 @Override
protected void onCast(Hero hero) { protected void onCast(Hero hero) {
@@ -72,6 +95,17 @@ public class UnstableSpell extends Spell {
updateQuickslot(); updateQuickslot();
Scroll s = Reflection.newInstance(Random.chances(scrollChances)); 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(); s.anonymize();
curItem = s; curItem = s;
s.doRead(); s.doRead();