From 9c92ab8154f71b657c4a55d8426ef2870de626c2 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Thu, 7 Apr 2022 19:19:56 -0400 Subject: [PATCH] v1.2.2: fixed items spawning as IDed counting as being IDed by the hero --- .../actors/mobs/ArmoredStatue.java | 2 +- .../actors/mobs/Statue.java | 2 +- .../shatteredpixeldungeon/items/Item.java | 13 ++++++++++--- .../items/potions/Potion.java | 4 ++-- .../items/rings/Ring.java | 4 ++-- .../items/scrolls/Scroll.java | 4 ++-- .../items/wands/Wand.java | 4 ++-- .../levels/rooms/special/ShopRoom.java | 18 +++++++++--------- .../shatteredpixeldungeon/windows/WndImp.java | 2 +- .../windows/WndSadGhost.java | 2 +- .../windows/WndWandmaker.java | 2 +- 11 files changed, 32 insertions(+), 25 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/ArmoredStatue.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/ArmoredStatue.java index 248edfa30..39fae814a 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/ArmoredStatue.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/ArmoredStatue.java @@ -133,7 +133,7 @@ public class ArmoredStatue extends Statue { @Override public void die( Object cause ) { - armor.identify(); + armor.identify(false); Dungeon.level.drop( armor, pos ).sprite.drop(); super.die( cause ); } 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 381f190ff..88ab0e7c9 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 @@ -145,7 +145,7 @@ public class Statue extends Mob { @Override public void die( Object cause ) { - weapon.identify(); + weapon.identify(false); Dungeon.level.drop( weapon, pos ).sprite.drop(); super.die( cause ); } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Item.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Item.java index 3df72888a..600ca5e83 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Item.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Item.java @@ -214,7 +214,9 @@ public class Item implements Bundlable { item.merge( this ); item.updateQuickslot(); if (Dungeon.hero != null && Dungeon.hero.isAlive()) { + Badges.validateItemLevelAquired( this ); Talent.onItemCollected(Dungeon.hero, item); + if (isIdentified()) Catalog.setSeen(getClass()); } return true; } @@ -224,6 +226,7 @@ public class Item implements Bundlable { if (Dungeon.hero != null && Dungeon.hero.isAlive()) { Badges.validateItemLevelAquired( this ); Talent.onItemCollected( Dungeon.hero, this ); + if (isIdentified()) Catalog.setSeen(getClass()); } items.add( this ); @@ -395,10 +398,14 @@ public class Item implements Bundlable { public boolean isEquipped( Hero hero ) { return false; } - - public Item identify() { - if (Dungeon.hero != null && Dungeon.hero.isAlive()){ + public final Item identify(){ + return identify(true); + } + + public Item identify( boolean byHero ) { + + if (byHero && Dungeon.hero != null && Dungeon.hero.isAlive()){ Catalog.setSeen(getClass()); if (!isIdentified()) Talent.onItemIdentified(Dungeon.hero, this); } 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 9034854a1..699c4edb0 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 @@ -352,8 +352,8 @@ public class Potion extends Item { } @Override - public Item identify() { - super.identify(); + public Item identify( boolean byHero ) { + super.identify(byHero); if (!isKnown()) { setKnown(); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/Ring.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/Ring.java index 135ca18a3..afeb5ddb5 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/Ring.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/Ring.java @@ -198,10 +198,10 @@ public class Ring extends KindofMisc { } @Override - public Item identify() { + public Item identify( boolean byHero ) { setKnown(); levelsToID = 0; - return super.identify(); + return super.identify(byHero); } @Override 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 b3abda23d..b60d32ef4 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 @@ -211,8 +211,8 @@ public abstract class Scroll extends Item { } @Override - public Item identify() { - super.identify(); + public Item identify( boolean byHero ) { + super.identify(byHero); if (!isKnown()) { setKnown(); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/Wand.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/Wand.java index 17ee72498..c9ddf9236 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/Wand.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/Wand.java @@ -215,10 +215,10 @@ public abstract class Wand extends Item { } @Override - public Item identify() { + public Item identify( boolean byHero ) { curChargeKnown = true; - super.identify(); + super.identify(byHero); updateQuickslot(); 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 cd54ddc4b..e806d3d63 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 @@ -156,26 +156,26 @@ public class ShopRoom extends SpecialRoom { switch (Dungeon.depth) { case 6: default: w = (MeleeWeapon) Generator.random(Generator.wepTiers[1]); - itemsToSpawn.add( Generator.random(Generator.misTiers[1]).quantity(2).identify() ); - itemsToSpawn.add( new LeatherArmor().identify() ); + itemsToSpawn.add( Generator.random(Generator.misTiers[1]).quantity(2).identify(false) ); + itemsToSpawn.add( new LeatherArmor().identify(false) ); break; case 11: w = (MeleeWeapon) Generator.random(Generator.wepTiers[2]); - itemsToSpawn.add( Generator.random(Generator.misTiers[2]).quantity(2).identify() ); - itemsToSpawn.add( new MailArmor().identify() ); + itemsToSpawn.add( Generator.random(Generator.misTiers[2]).quantity(2).identify(false) ); + itemsToSpawn.add( new MailArmor().identify(false) ); break; case 16: w = (MeleeWeapon) Generator.random(Generator.wepTiers[3]); - itemsToSpawn.add( Generator.random(Generator.misTiers[3]).quantity(2).identify() ); - itemsToSpawn.add( new ScaleArmor().identify() ); + itemsToSpawn.add( Generator.random(Generator.misTiers[3]).quantity(2).identify(false) ); + itemsToSpawn.add( new ScaleArmor().identify(false) ); break; case 20: case 21: w = (MeleeWeapon) Generator.random(Generator.wepTiers[4]); - itemsToSpawn.add( Generator.random(Generator.misTiers[4]).quantity(2).identify() ); - itemsToSpawn.add( new PlateArmor().identify() ); + itemsToSpawn.add( Generator.random(Generator.misTiers[4]).quantity(2).identify(false) ); + itemsToSpawn.add( new PlateArmor().identify(false) ); itemsToSpawn.add( new Torch() ); itemsToSpawn.add( new Torch() ); itemsToSpawn.add( new Torch() ); @@ -184,7 +184,7 @@ public class ShopRoom extends SpecialRoom { w.enchant(null); w.cursed = false; w.level(0); - w.identify(); + w.identify(false); itemsToSpawn.add(w); itemsToSpawn.add( TippedDart.randomTipped(2) ); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndImp.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndImp.java index 2c0f75628..9f486453d 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndImp.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndImp.java @@ -73,7 +73,7 @@ public class WndImp extends Window { tokens.detachAll( Dungeon.hero.belongings.backpack ); if (reward == null) return; - reward.identify(); + reward.identify(false); if (reward.doPickUp( Dungeon.hero )) { GLog.i( Messages.get(Dungeon.hero, "you_now_have", reward.name()) ); } else { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndSadGhost.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndSadGhost.java index bb7c72dd5..9c92c7284 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndSadGhost.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndSadGhost.java @@ -110,7 +110,7 @@ public class WndSadGhost extends Window { ((Armor) reward).inscribe(Ghost.Quest.glyph); } - reward.identify(); + reward.identify(false); if (reward.doPickUp( Dungeon.hero )) { GLog.i( Messages.get(Dungeon.hero, "you_now_have", reward.name()) ); } else { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndWandmaker.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndWandmaker.java index b06774793..6a9d8cbed 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndWandmaker.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndWandmaker.java @@ -101,7 +101,7 @@ public class WndWandmaker extends Window { questItem.detach( Dungeon.hero.belongings.backpack ); - reward.identify(); + reward.identify(false); if (reward.doPickUp( Dungeon.hero )) { GLog.i( Messages.get(Dungeon.hero, "you_now_have", reward.name()) ); } else {