From 90a76fbf12206d6e8eafa8ebf5569c23c2261a73 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Sat, 1 Dec 2018 14:22:01 -0500 Subject: [PATCH] v0.7.1: fixed various bugs with missile weapon functionality --- .../items/weapon/SpiritBow.java | 5 +++ .../items/weapon/missiles/MissileWeapon.java | 37 ++++++++++++------- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/SpiritBow.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/SpiritBow.java index 852af8a23..da45248d9 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/SpiritBow.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/SpiritBow.java @@ -259,6 +259,11 @@ public class SpiritBow extends Weapon { if (flurryCount == -1) flurryCount = 3; final Char enemy = Actor.findChar( cell ); + + if (enemy == null){ + user.spendAndNext(castDelay(user, dst)); + return; + } QuickSlotButton.target(enemy); final boolean last = flurryCount == 1; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/MissileWeapon.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/MissileWeapon.java index 4db005141..56e5bb855 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/MissileWeapon.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/MissileWeapon.java @@ -97,23 +97,26 @@ abstract public class MissileWeapon extends Weapon { @Override public Item upgrade() { - - if (quantity > 1){ - MissileWeapon left = (MissileWeapon) split(quantity - 1); - left.parent = null; - - super.upgrade(); - - //deal with full inventory. - if (!left.collect()){ - Dungeon.level.drop( left, Dungeon.hero.pos); + if (!bundleRestoring) { + if (quantity > 1) { + MissileWeapon left = (MissileWeapon) split(quantity - 1); + left.parent = null; + + super.upgrade(); + + //deal with full inventory. + if (!left.collect()) { + Dungeon.level.drop(left, Dungeon.hero.pos); + } + } else { + super.upgrade(); } + + durability = MAX_DURABILITY; + return this; } else { - super.upgrade(); + return super.upgrade(); } - - durability = MAX_DURABILITY; - return this; } @Override @@ -269,7 +272,9 @@ abstract public class MissileWeapon extends Weapon { @Override public Item split(int amount) { + bundleRestoring = true; Item split = super.split(amount); + bundleRestoring = false; //unless the thrown weapon will break, split off a max durability item and //have it reduce the durability of the main stack. Cleaner to the player this way @@ -352,9 +357,13 @@ abstract public class MissileWeapon extends Weapon { bundle.put(DURABILITY, durability); } + private static boolean bundleRestoring = false; + @Override public void restoreFromBundle(Bundle bundle) { + bundleRestoring = true; super.restoreFromBundle(bundle); + bundleRestoring = false; //compatibility with pre-0.6.3 saves if (bundle.contains(DURABILITY)) { durability = bundle.getInt(DURABILITY);