v0.7.1: fixed various bugs with missile weapon functionality

This commit is contained in:
Evan Debenham 2018-12-01 14:22:01 -05:00
parent c05fdef69e
commit 90a76fbf12
2 changed files with 28 additions and 14 deletions

View File

@ -259,6 +259,11 @@ public class SpiritBow extends Weapon {
if (flurryCount == -1) flurryCount = 3; if (flurryCount == -1) flurryCount = 3;
final Char enemy = Actor.findChar( cell ); final Char enemy = Actor.findChar( cell );
if (enemy == null){
user.spendAndNext(castDelay(user, dst));
return;
}
QuickSlotButton.target(enemy); QuickSlotButton.target(enemy);
final boolean last = flurryCount == 1; final boolean last = flurryCount == 1;

View File

@ -97,23 +97,26 @@ abstract public class MissileWeapon extends Weapon {
@Override @Override
public Item upgrade() { public Item upgrade() {
if (!bundleRestoring) {
if (quantity > 1) {
MissileWeapon left = (MissileWeapon) split(quantity - 1);
left.parent = null;
if (quantity > 1){ super.upgrade();
MissileWeapon left = (MissileWeapon) split(quantity - 1);
left.parent = null;
super.upgrade(); //deal with full inventory.
if (!left.collect()) {
//deal with full inventory. Dungeon.level.drop(left, Dungeon.hero.pos);
if (!left.collect()){ }
Dungeon.level.drop( left, Dungeon.hero.pos); } else {
super.upgrade();
} }
} else {
super.upgrade();
}
durability = MAX_DURABILITY; durability = MAX_DURABILITY;
return this; return this;
} else {
return super.upgrade();
}
} }
@Override @Override
@ -269,7 +272,9 @@ abstract public class MissileWeapon extends Weapon {
@Override @Override
public Item split(int amount) { public Item split(int amount) {
bundleRestoring = true;
Item split = super.split(amount); Item split = super.split(amount);
bundleRestoring = false;
//unless the thrown weapon will break, split off a max durability item and //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 //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); bundle.put(DURABILITY, durability);
} }
private static boolean bundleRestoring = false;
@Override @Override
public void restoreFromBundle(Bundle bundle) { public void restoreFromBundle(Bundle bundle) {
bundleRestoring = true;
super.restoreFromBundle(bundle); super.restoreFromBundle(bundle);
bundleRestoring = false;
//compatibility with pre-0.6.3 saves //compatibility with pre-0.6.3 saves
if (bundle.contains(DURABILITY)) { if (bundle.contains(DURABILITY)) {
durability = bundle.getInt(DURABILITY); durability = bundle.getInt(DURABILITY);