From d382ed74c3004f199401b371749934b6c758bc87 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Sun, 12 Feb 2023 23:15:56 -0500 Subject: [PATCH] v2.0.0: charged shot is now cleared when xbow is unequipped --- .../items/weapon/melee/Crossbow.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/Crossbow.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/Crossbow.java index 57baf9f91..08aaaccb6 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/Crossbow.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/Crossbow.java @@ -26,6 +26,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.FlavourBuff; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; +import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfForce; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator; @@ -42,6 +43,21 @@ public class Crossbow extends MeleeWeapon { tier = 4; } + + @Override + public boolean doUnequip(Hero hero, boolean collect, boolean single) { + if (super.doUnequip(hero, collect, single)){ + if (hero.buff(ChargedShot.class) != null && + !(hero.belongings.weapon() instanceof Crossbow) + && !(hero.belongings.secondWep() instanceof Crossbow)){ + //clear charged shot if no crossbow is equipped + hero.buff(ChargedShot.class).detach(); + } + return true; + } else { + return false; + } + } @Override public int max(int lvl) { @@ -57,13 +73,13 @@ public class Crossbow extends MeleeWeapon { } beforeAbilityUsed(hero); - Buff.prolong(hero, ChargedShot.class, 100f); + Buff.affect(hero, ChargedShot.class); hero.sprite.operate(hero.pos); hero.next(); afterAbilityUsed(hero); } - public static class ChargedShot extends FlavourBuff{ + public static class ChargedShot extends Buff{ { announced = true;