From 11ae9263413fd4c0584036ca3015fecb892d834d Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Mon, 11 Mar 2019 22:49:01 -0400 Subject: [PATCH] v0.7.2: bugfixes: - fixed thieves rarely teleporting away when they are close - fixed beacon losing location when scroll holder is picked up - fixed recycle not dropping an item if inventory is full - fixed alchemy scene not saving progress when it starts up - fixed a rare freeze bug with tengu --- .../shatteredpixeldungeon/actors/mobs/Thief.java | 4 +++- .../items/bags/ScrollHolder.java | 11 +++++++++++ .../items/spells/BeaconOfReturning.java | 12 +++++++++++- .../shatteredpixeldungeon/items/spells/Recycle.java | 5 ++++- .../shatteredpixeldungeon/scenes/AlchemyScene.java | 8 ++++++++ .../shatteredpixeldungeon/sprites/TenguSprite.java | 6 ++++++ 6 files changed, 43 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Thief.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Thief.java index 4869350ef..5f09d6e9b 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Thief.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Thief.java @@ -192,7 +192,9 @@ public class Thief extends Mob { if (enemySeen) { sprite.showStatus(CharSprite.NEGATIVE, Messages.get(Mob.class, "rage")); state = HUNTING; - } else if (item != null && !Dungeon.level.heroFOV[pos]) { + } else if (item != null + && !Dungeon.level.heroFOV[pos] + && Dungeon.level.distance(Dungeon.hero.pos, pos) < 6) { int count = 32; int newPos; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/bags/ScrollHolder.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/bags/ScrollHolder.java index b28e9e2cd..3315b9c1a 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/bags/ScrollHolder.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/bags/ScrollHolder.java @@ -23,6 +23,7 @@ package com.shatteredpixel.shatteredpixeldungeon.items.bags; import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll; +import com.shatteredpixel.shatteredpixeldungeon.items.spells.BeaconOfReturning; import com.shatteredpixel.shatteredpixeldungeon.items.spells.Spell; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; @@ -39,6 +40,16 @@ public class ScrollHolder extends Bag { return item instanceof Scroll || item instanceof Spell; } + @Override + public void onDetach( ) { + super.onDetach(); + for (Item item : items) { + if (item instanceof BeaconOfReturning) { + ((BeaconOfReturning) item).returnDepth = -1; + } + } + } + @Override public int price() { return 40; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/spells/BeaconOfReturning.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/spells/BeaconOfReturning.java index 86e1ba845..21e02e117 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/spells/BeaconOfReturning.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/spells/BeaconOfReturning.java @@ -76,9 +76,19 @@ public class BeaconOfReturning extends Spell { } } + //we reset return depth when beacons are dropped to prevent + //having two stacks of beacons with different return locations + @Override - protected void onDetach() { + protected void onThrow(int cell) { returnDepth = -1; + super.onThrow(cell); + } + + @Override + public void doDrop(Hero hero) { + returnDepth = -1; + super.doDrop(hero); } private void setBeacon(Hero hero ){ diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/spells/Recycle.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/spells/Recycle.java index 796c54f26..d55113c94 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/spells/Recycle.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/spells/Recycle.java @@ -22,6 +22,7 @@ package com.shatteredpixel.shatteredpixeldungeon.items.spells; import com.shatteredpixel.shatteredpixeldungeon.Challenges; +import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; import com.shatteredpixel.shatteredpixeldungeon.items.Generator; import com.shatteredpixel.shatteredpixeldungeon.items.Item; @@ -79,7 +80,9 @@ public class Recycle extends InventorySpell { item.detach(curUser.belongings.backpack); GLog.p(Messages.get(this, "recycled", result.name())); - result.collect(); + if (!result.collect()){ + Dungeon.level.drop(result, curUser.pos).sprite.drop(); + } //TODO visuals } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/AlchemyScene.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/AlchemyScene.java index 442d366f7..e74e691bb 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/AlchemyScene.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/AlchemyScene.java @@ -282,6 +282,14 @@ public class AlchemyScene extends PixelScene { add(energyCost); fadeIn(); + + try { + Dungeon.saveAll(); + Badges.saveGlobal(); + Journal.saveGlobal(); + } catch (IOException e) { + ShatteredPixelDungeon.reportException(e); + } } @Override diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/sprites/TenguSprite.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/sprites/TenguSprite.java index 694b520e0..06f6b33c8 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/sprites/TenguSprite.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/sprites/TenguSprite.java @@ -58,6 +58,12 @@ public class TenguSprite extends MobSprite { play( run.clone() ); } + @Override + public void idle() { + isMoving = false; + super.idle(); + } + @Override public void move( int from, int to ) {