From d9783ffb1ce507f31379169ed712f477074d1b61 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Sat, 3 Nov 2018 18:20:33 -0400 Subject: [PATCH] v0.7.0b: bugfixes: - fixed none-heroes being able to use reach weapons through walls - fixed toolkit rarely being able to go above 100% charge - fixed antimagic glyph apply to more effects when used by the sad ghost - fixed elixir of restoration doing nothing when thrown - fixed exotic items not being identified in rankings (will not fix old rankings) - fixed bolas incorrectly having 15 strength - fixed some items not being known to uncursed from shops - fixed an internal typo in DungeonTileSheet.java --- .../actors/hero/Hero.java | 19 ++++++------------ .../actors/mobs/Statue.java | 2 +- .../actors/mobs/npcs/MirrorImage.java | 6 +----- .../items/ItemStatusHandler.java | 12 +++++++++++ .../items/KindOfWeapon.java | 18 +++++++++++++++++ .../items/artifacts/AlchemistsToolkit.java | 3 ++- .../items/artifacts/DriedRose.java | 9 ++------- .../items/potions/Potion.java | 14 ++++++++++++- .../potions/elixirs/ElixirOfRestoration.java | 20 +++++++++++++++++++ .../items/scrolls/Scroll.java | 15 +++++++++++++- .../items/weapon/missiles/Bolas.java | 2 +- .../levels/rooms/special/ShopRoom.java | 3 ++- .../tiles/DungeonTileSheet.java | 2 +- .../tiles/DungeonWallsTilemap.java | 2 +- 14 files changed, 94 insertions(+), 33 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java index c1f1ea869..5f3589eb4 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java @@ -108,7 +108,6 @@ import com.shatteredpixel.shatteredpixeldungeon.sprites.HeroSprite; import com.shatteredpixel.shatteredpixeldungeon.ui.AttackIndicator; import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator; import com.shatteredpixel.shatteredpixeldungeon.ui.QuickSlotButton; -import com.shatteredpixel.shatteredpixeldungeon.utils.BArray; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; import com.shatteredpixel.shatteredpixeldungeon.windows.WndMessage; import com.shatteredpixel.shatteredpixeldungeon.windows.WndResurrect; @@ -411,25 +410,19 @@ public class Hero extends Char { } public boolean canAttack(Char enemy){ - if (enemy == null || pos == enemy.pos) + if (enemy == null || pos == enemy.pos) { return false; + } //can always attack adjacent enemies - if (Dungeon.level.adjacent(pos, enemy.pos)) + if (Dungeon.level.adjacent(pos, enemy.pos)) { return true; + } KindOfWeapon wep = Dungeon.hero.belongings.weapon; - if (wep != null && Dungeon.level.distance( pos, enemy.pos ) <= wep.reachFactor(this)){ - - boolean[] passable = BArray.not(Dungeon.level.solid, null); - for (Mob m : Dungeon.level.mobs) - passable[m.pos] = false; - - PathFinder.buildDistanceMap(enemy.pos, passable, wep.reachFactor(this)); - - return PathFinder.distance[pos] <= wep.reachFactor(this); - + if (wep != null){ + return wep.canReach(this, enemy.pos); } else { return false; } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Statue.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Statue.java index 826f1ab89..db5819d3e 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Statue.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Statue.java @@ -99,7 +99,7 @@ public class Statue extends Mob { @Override protected boolean canAttack(Char enemy) { - return Dungeon.level.distance( pos, enemy.pos ) <= weapon.reachFactor(this); + return super.canAttack(enemy) || weapon.canReach(this, enemy.pos); } @Override diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/MirrorImage.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/MirrorImage.java index 66dffb171..4c40bb6fb 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/MirrorImage.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/MirrorImage.java @@ -132,11 +132,7 @@ public class MirrorImage extends NPC { @Override protected boolean canAttack(Char enemy) { - if (hero.belongings.weapon != null){ - return Dungeon.level.distance( pos, enemy.pos ) <= hero.belongings.weapon.reachFactor(this); - } else { - return super.canAttack(enemy); - } + return super.canAttack(enemy) || (hero.belongings.weapon != null && hero.belongings.weapon.canReach(this, enemy.pos)); } @Override diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/ItemStatusHandler.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/ItemStatusHandler.java index d723913f0..df9c85208 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/ItemStatusHandler.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/ItemStatusHandler.java @@ -94,6 +94,18 @@ public class ItemStatusHandler { } } } + + public void saveClassesSelectively( Bundle bundle, ArrayList> clsToSave ){ + List> items = Arrays.asList(this.items); + for (Class cls : clsToSave){ + if (items.contains(cls)){ + Class toSave = items.get(items.indexOf(cls)); + String itemName = toSave.toString(); + bundle.put( itemName + PFX_LABEL, itemLabels.get( toSave ) ); + bundle.put( itemName + PFX_KNOWN, known.contains( toSave ) ); + } + } + } private void restore( Bundle bundle, ArrayList labelsLeft ) { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/KindOfWeapon.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/KindOfWeapon.java index 1956fc3d7..402ad82ad 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/KindOfWeapon.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/KindOfWeapon.java @@ -21,10 +21,14 @@ package com.shatteredpixel.shatteredpixeldungeon.items; +import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; +import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; +import com.shatteredpixel.shatteredpixeldungeon.utils.BArray; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; +import com.watabou.utils.PathFinder; import com.watabou.utils.Random; abstract public class KindOfWeapon extends EquipableItem { @@ -104,6 +108,20 @@ abstract public class KindOfWeapon extends EquipableItem { public int reachFactor( Char owner ){ return 1; } + + public boolean canReach( Char owner, int target){ + if (Dungeon.level.distance( owner.pos, target ) > reachFactor(owner)){ + return false; + } else { + boolean[] passable = BArray.not(Dungeon.level.solid, null); + for (Mob m : Dungeon.level.mobs) + passable[m.pos] = false; + + PathFinder.buildDistanceMap(target, passable, reachFactor(owner)); + + return PathFinder.distance[owner.pos] <= reachFactor(owner); + } + } public int defenseFactor( Char owner ) { return 0; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/AlchemistsToolkit.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/AlchemistsToolkit.java index 29bbdf873..bbe8491b5 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/AlchemistsToolkit.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/AlchemistsToolkit.java @@ -113,7 +113,8 @@ public class AlchemistsToolkit extends Artifact { partialCharge -= 1; charge++; - if (charge == chargeCap){ + if (charge >= chargeCap){ + charge = chargeCap; partialCharge = 0; break; } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/DriedRose.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/DriedRose.java index 5452a227f..778aad852 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/DriedRose.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/DriedRose.java @@ -41,7 +41,6 @@ import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ShaftParticle; import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor; import com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.AntiMagic; -import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfElements; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfRetribution; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.exotic.ScrollOfPsionicBlast; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MeleeWeapon; @@ -505,11 +504,7 @@ public class DriedRose extends Artifact { @Override protected boolean canAttack(Char enemy) { - if (rose != null && rose.weapon != null) { - return Dungeon.level.distance(pos, enemy.pos) <= rose.weapon.reachFactor(this); - } else { - return super.canAttack(enemy); - } + return super.canAttack(enemy) || (rose != null && rose.weapon != null && rose.weapon.canReach(this, enemy.pos)); } @Override @@ -546,7 +541,7 @@ public class DriedRose extends Artifact { public void damage(int dmg, Object src) { //TODO improve this when I have proper damage source logic if (rose != null && rose.armor != null && rose.armor.hasGlyph(AntiMagic.class, this) - && RingOfElements.RESISTS.contains(src.getClass())){ + && AntiMagic.RESISTS.contains(src.getClass())){ dmg -= Random.NormalIntRange(rose.armor.DRMin(), rose.armor.DRMax())/3; } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/Potion.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/Potion.java index 8b7f8c224..e343f487b 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/Potion.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/Potion.java @@ -168,7 +168,19 @@ public class Potion extends Item { } public static void saveSelectively( Bundle bundle, ArrayList items ) { - handler.saveSelectively( bundle, items ); + ArrayList> classes = new ArrayList<>(); + for (Item i : items){ + if (i instanceof ExoticPotion){ + if (!classes.contains(ExoticPotion.exoToReg.get(i.getClass()))){ + classes.add(ExoticPotion.exoToReg.get(i.getClass())); + } + } else if (i instanceof Potion){ + if (!classes.contains(i.getClass())){ + classes.add(i.getClass()); + } + } + } + handler.saveClassesSelectively( bundle, classes ); } @SuppressWarnings("unchecked") diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/elixirs/ElixirOfRestoration.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/elixirs/ElixirOfRestoration.java index 450b653d5..1fd92e843 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/elixirs/ElixirOfRestoration.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/elixirs/ElixirOfRestoration.java @@ -21,12 +21,16 @@ package com.shatteredpixel.shatteredpixeldungeon.items.potions.elixirs; +import com.shatteredpixel.shatteredpixeldungeon.Assets; +import com.shatteredpixel.shatteredpixeldungeon.Dungeon; +import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Healing; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfHealing; import com.shatteredpixel.shatteredpixeldungeon.items.potions.exotic.PotionOfCleansing; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; +import com.watabou.noosa.audio.Sample; public class ElixirOfRestoration extends Elixir { @@ -40,6 +44,22 @@ public class ElixirOfRestoration extends Elixir { PotionOfCleansing.cleanse(hero); } + @Override + public void shatter(int cell) { + if (Actor.findChar(cell) == null){ + super.shatter(cell); + } else { + if (Dungeon.level.heroFOV[cell]) { + Sample.INSTANCE.play(Assets.SND_SHATTER); + splash(cell); + } + + if (Actor.findChar(cell) != null){ + PotionOfCleansing.cleanse(Actor.findChar(cell)); + } + } + } + @Override public int price() { //prices of ingredients diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/Scroll.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/Scroll.java index 55bd29ec8..c881e557b 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/Scroll.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/Scroll.java @@ -30,6 +30,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.ItemStatusHandler; import com.shatteredpixel.shatteredpixeldungeon.items.Recipe; import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.UnstableSpellbook; +import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.exotic.ExoticScroll; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.exotic.ScrollOfAntiMagic; import com.shatteredpixel.shatteredpixeldungeon.items.stones.Runestone; import com.shatteredpixel.shatteredpixeldungeon.items.stones.StoneOfAffection; @@ -114,7 +115,19 @@ public abstract class Scroll extends Item { } public static void saveSelectively( Bundle bundle, ArrayList items ) { - handler.saveSelectively( bundle, items ); + ArrayList> classes = new ArrayList<>(); + for (Item i : items){ + if (i instanceof ExoticScroll){ + if (!classes.contains(ExoticScroll.exoToReg.get(i.getClass()))){ + classes.add(ExoticScroll.exoToReg.get(i.getClass())); + } + } else if (i instanceof Scroll){ + if (!classes.contains(i.getClass())){ + classes.add(i.getClass()); + } + } + } + handler.saveClassesSelectively( bundle, classes ); } @SuppressWarnings("unchecked") diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/Bolas.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/Bolas.java index 2d6fa5819..ba79b92a4 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/Bolas.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/weapon/missiles/Bolas.java @@ -45,7 +45,7 @@ public class Bolas extends MissileWeapon { @Override public int STRReq(int lvl) { - return 15; + return 13; } @Override diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/ShopRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/ShopRoom.java index 5e520d9cc..5acc160dc 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/ShopRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/ShopRoom.java @@ -284,7 +284,8 @@ public class ShopRoom extends SpecialRoom { default: rare = new Stylus(); } - rare.cursed = rare.cursedKnown = false; + rare.cursed = false; + rare.cursedKnown = true; itemsToSpawn.add( rare ); //hard limit is 63 items + 1 shopkeeper, as shops can't be bigger than 8x8=64 internally diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/tiles/DungeonTileSheet.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/tiles/DungeonTileSheet.java index e48a3015c..45565f024 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/tiles/DungeonTileSheet.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/tiles/DungeonTileSheet.java @@ -325,7 +325,7 @@ public class DungeonTileSheet { public static final int DOOR_SIDEWAYS_LOCKED = WALL_OVERHANG+24; public static final int STATUE_OVERHANG = WALL_OVERHANG+26; - public static final int ALCHEMY_POT_OVERHAND = WALL_OVERHANG+27; + public static final int ALCHEMY_POT_OVERHANG = WALL_OVERHANG+27; public static final int BARRICADE_OVERHANG = WALL_OVERHANG+28; public static final int HIGH_GRASS_OVERHANG = WALL_OVERHANG+29; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/tiles/DungeonWallsTilemap.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/tiles/DungeonWallsTilemap.java index 78669c383..9e639b5fb 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/tiles/DungeonWallsTilemap.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/tiles/DungeonWallsTilemap.java @@ -76,7 +76,7 @@ public class DungeonWallsTilemap extends DungeonTilemap { } else if (pos + mapWidth < size && (map[pos+mapWidth] == Terrain.STATUE || map[pos+mapWidth] == Terrain.STATUE_SP)){ return DungeonTileSheet.STATUE_OVERHANG; } else if (pos + mapWidth < size && map[pos+mapWidth] == Terrain.ALCHEMY){ - return DungeonTileSheet.ALCHEMY_POT_OVERHAND; + return DungeonTileSheet.ALCHEMY_POT_OVERHANG; } else if (pos + mapWidth < size && map[pos+mapWidth] == Terrain.BARRICADE){ return DungeonTileSheet.BARRICADE_OVERHANG; } else if (pos + mapWidth < size && map[pos+mapWidth] == Terrain.HIGH_GRASS){