From ed5d5a56ee893aa5d3dbc000f396cba6ad472f24 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Fri, 9 Jul 2021 17:54:03 -0400 Subject: [PATCH] v0.9.4: fixed magical charge and scroll empower interacting incorrectly --- .../shatteredpixeldungeon/items/wands/Wand.java | 17 +++++++++++------ .../items/wands/WandOfMagicMissile.java | 17 ++++++++++++++--- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/Wand.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/Wand.java index e7d715ce5..d91817581 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/Wand.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/Wand.java @@ -369,14 +369,19 @@ public abstract class Wand extends Item { curCharges -= cursed ? 1 : chargesPerCast(); - ScrollEmpower empower = curUser.buff(ScrollEmpower.class); - if (empower != null){ - empower.detach(); - } - + //remove magic charge at a higher priority, if we are benefiting from it are and not the + //wand that just applied it WandOfMagicMissile.MagicCharge buff = curUser.buff(WandOfMagicMissile.MagicCharge.class); - if (buff != null && buff.level() > super.buffedLvl()){ + if (buff != null + && buff.wandJustApplied() != this + && buff.level() == buffedLvl() + && buffedLvl() > super.buffedLvl()){ buff.detach(); + } else { + ScrollEmpower empower = curUser.buff(ScrollEmpower.class); + if (empower != null){ + empower.detach(); + } } //if the wand is owned by the hero, but not in their inventory, it must be in the staff diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfMagicMissile.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfMagicMissile.java index 9b1bb0635..0b80c2ef1 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfMagicMissile.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfMagicMissile.java @@ -67,7 +67,7 @@ public class WandOfMagicMissile extends DamageWand { //apply the magic charge buff if we have another wand in inventory of a lower level, or already have the buff for (Wand.Charger wandCharger : curUser.buffs(Wand.Charger.class)){ if (wandCharger.wand().buffedLvl() < buffedLvl() || curUser.buff(MagicCharge.class) != null){ - Buff.prolong(curUser, MagicCharge.class, MagicCharge.DURATION).setLevel(buffedLvl()); + Buff.prolong(curUser, MagicCharge.class, MagicCharge.DURATION).setup(this); break; } } @@ -102,9 +102,13 @@ public class WandOfMagicMissile extends DamageWand { public static float DURATION = 4f; private int level = 0; + private Wand wandJustApplied; //we don't bundle this as it's only used right as the buff is applied - public void setLevel(int level){ - this.level = Math.max(level, this.level); + public void setup(Wand wand){ + if (level < wand.buffedLvl()){ + this.level = wand.buffedLvl(); + this.wandJustApplied = wand; + } } @Override @@ -117,6 +121,13 @@ public class WandOfMagicMissile extends DamageWand { return this.level; } + //this is used briefly so that a wand of magic missile can't clear the buff it just applied + public Wand wandJustApplied(){ + Wand result = this.wandJustApplied; + this.wandJustApplied = null; + return result; + } + @Override public int icon() { return BuffIndicator.UPGRADE;