From 842d7efce5e289eba8d844a43f60e3917e462d7f Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Tue, 24 Sep 2024 12:19:03 -0400 Subject: [PATCH] v2.5.3: added stones of detect magic, replacing stones of disarming --- .../assets/messages/items/items.properties | 8 ++ .../items/Generator.java | 4 +- .../items/scrolls/Scroll.java | 4 +- .../items/stones/StoneOfDetectMagic.java | 90 +++++++++++++++++++ .../items/stones/StoneOfDisarming.java | 3 +- .../sprites/ItemSpriteSheet.java | 2 +- 6 files changed, 105 insertions(+), 6 deletions(-) create mode 100644 core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/stones/StoneOfDetectMagic.java diff --git a/core/src/main/assets/messages/items/items.properties b/core/src/main/assets/messages/items/items.properties index 3538aa9b8..c68858eb6 100644 --- a/core/src/main/assets/messages/items/items.properties +++ b/core/src/main/assets/messages/items/items.properties @@ -1289,6 +1289,14 @@ items.stones.stoneofclairvoyance.desc=This stone will instantly reveal all tiles items.stones.stoneofdeepsleep.name=stone of deep sleep items.stones.stoneofdeepsleep.desc=When this stone is thrown at an enemy, it will put them into a deep magical sleep. Magically slept enemies will sleep forever until disturbed. +items.stones.stoneofdetectmagic.name=stone of detect magic +items.stones.stoneofdetectmagic.inv_title=Detect an item +items.stones.stoneofdetectmagic.detected_none=You don't detect any magic affecting this item. +items.stones.stoneofdetectmagic.detected_both=You detect both positive and malevolent magic affecting this item! +items.stones.stoneofdetectmagic.detected_good=You detect positive magic affecting this item! +items.stones.stoneofdetectmagic.detected_bad=You detect malevolent magic affecting this item! +items.stones.stoneofdetectmagic.desc=This runestone is able to detect magic affecting an item. Using this stone on an unidentified item will tell you if it is affected by a malevolent curse and whether it is affected by positive magic such as an enchantment or upgrades. + items.stones.stoneofdisarming.name=stone of disarming items.stones.stoneofdisarming.desc=This runestone holds magic that can disable malicious traps hidden throughout the dungeon. It will disarm up to 9 traps around the area it is thrown at. diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Generator.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Generator.java index cefc10418..4e3c5909d 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Generator.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Generator.java @@ -101,7 +101,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.stones.StoneOfBlast; import com.shatteredpixel.shatteredpixeldungeon.items.stones.StoneOfBlink; import com.shatteredpixel.shatteredpixeldungeon.items.stones.StoneOfClairvoyance; import com.shatteredpixel.shatteredpixeldungeon.items.stones.StoneOfDeepSleep; -import com.shatteredpixel.shatteredpixeldungeon.items.stones.StoneOfDisarming; +import com.shatteredpixel.shatteredpixeldungeon.items.stones.StoneOfDetectMagic; import com.shatteredpixel.shatteredpixeldungeon.items.stones.StoneOfEnchantment; import com.shatteredpixel.shatteredpixeldungeon.items.stones.StoneOfFear; import com.shatteredpixel.shatteredpixeldungeon.items.stones.StoneOfFlock; @@ -374,7 +374,7 @@ public class Generator { STONE.classes = new Class[]{ StoneOfEnchantment.class, //1 is guaranteed to drop on floors 6-19 StoneOfIntuition.class, //1 additional stone is also dropped on floors 1-3 - StoneOfDisarming.class, + StoneOfDetectMagic.class, StoneOfFlock.class, StoneOfShock.class, StoneOfBlink.class, 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 27e4bcf92..972ddbc6b 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 @@ -42,7 +42,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.stones.StoneOfBlast; import com.shatteredpixel.shatteredpixeldungeon.items.stones.StoneOfBlink; import com.shatteredpixel.shatteredpixeldungeon.items.stones.StoneOfClairvoyance; import com.shatteredpixel.shatteredpixeldungeon.items.stones.StoneOfDeepSleep; -import com.shatteredpixel.shatteredpixeldungeon.items.stones.StoneOfDisarming; +import com.shatteredpixel.shatteredpixeldungeon.items.stones.StoneOfDetectMagic; import com.shatteredpixel.shatteredpixeldungeon.items.stones.StoneOfEnchantment; import com.shatteredpixel.shatteredpixeldungeon.items.stones.StoneOfFear; import com.shatteredpixel.shatteredpixeldungeon.items.stones.StoneOfFlock; @@ -314,7 +314,7 @@ public abstract class Scroll extends Item { stones.put(ScrollOfRetribution.class, StoneOfBlast.class); stones.put(ScrollOfRage.class, StoneOfAggression.class); stones.put(ScrollOfRecharging.class, StoneOfShock.class); - stones.put(ScrollOfRemoveCurse.class, StoneOfDisarming.class); + stones.put(ScrollOfRemoveCurse.class, StoneOfDetectMagic.class); stones.put(ScrollOfTeleportation.class, StoneOfBlink.class); stones.put(ScrollOfTerror.class, StoneOfFear.class); stones.put(ScrollOfTransmutation.class, StoneOfAugmentation.class); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/stones/StoneOfDetectMagic.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/stones/StoneOfDetectMagic.java new file mode 100644 index 000000000..925c7ac6b --- /dev/null +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/stones/StoneOfDetectMagic.java @@ -0,0 +1,90 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * Shattered Pixel Dungeon + * Copyright (C) 2014-2024 Evan Debenham + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see + */ + +package com.shatteredpixel.shatteredpixeldungeon.items.stones; + +import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Belongings; +import com.shatteredpixel.shatteredpixeldungeon.items.EquipableItem; +import com.shatteredpixel.shatteredpixeldungeon.items.Item; +import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor; +import com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand; +import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon; +import com.shatteredpixel.shatteredpixeldungeon.journal.Catalog; +import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; +import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; +import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; + +public class StoneOfDetectMagic extends InventoryStone { + + { + preferredBag = Belongings.Backpack.class; + image = ItemSpriteSheet.STONE_DETECT; + } + + @Override + public boolean usableOnItem(Item item){ + return (item instanceof EquipableItem || item instanceof Wand) + && (!item.isIdentified() || !item.cursedKnown); + } + + @Override + protected void onItemSelected(Item item) { + + item.cursedKnown = true; + useAnimation(); + + boolean negativeMagic = false; + boolean positiveMagic = false; + + negativeMagic = item.cursed; + if (!negativeMagic){ + if (item instanceof Weapon && ((Weapon) item).hasCurseEnchant()){ + negativeMagic = true; + } else if (item instanceof Armor && ((Armor) item).hasCurseGlyph()){ + negativeMagic = true; + } + } + + positiveMagic = item.trueLevel() > 0; + if (!positiveMagic){ + if (item instanceof Weapon && ((Weapon) item).hasGoodEnchant()){ + positiveMagic = true; + } else if (item instanceof Armor && ((Armor) item).hasGoodGlyph()){ + positiveMagic = true; + } + } + + if (!positiveMagic && !negativeMagic){ + GLog.i(Messages.get(this, "detected_none")); + } else if (positiveMagic && negativeMagic) { + GLog.h(Messages.get(this, "detected_both")); + } else if (positiveMagic){ + GLog.p(Messages.get(this, "detected_good")); + } else if (negativeMagic){ + GLog.w(Messages.get(this, "detected_bad")); + } + + curItem.detach( curUser.belongings.backpack ); + Catalog.countUse(getClass()); + + } + +} diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/stones/StoneOfDisarming.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/stones/StoneOfDisarming.java index a90ea7621..f9e931876 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/stones/StoneOfDisarming.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/stones/StoneOfDisarming.java @@ -35,12 +35,13 @@ import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; +//for pre-v2.5.3 saves, add a conversion in v3.0 and remove entirely later public class StoneOfDisarming extends Runestone { private static final int DIST = 8; { - image = ItemSpriteSheet.STONE_DISARM; + image = ItemSpriteSheet.STONE_DETECT; } @Override diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/sprites/ItemSpriteSheet.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/sprites/ItemSpriteSheet.java index c4acae7b1..4b22c71c0 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/sprites/ItemSpriteSheet.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/sprites/ItemSpriteSheet.java @@ -556,7 +556,7 @@ public class ItemSpriteSheet { public static final int STONE_BLINK = STONES+4; public static final int STONE_CLAIRVOYANCE = STONES+5; public static final int STONE_SLEEP = STONES+6; - public static final int STONE_DISARM = STONES+7; + public static final int STONE_DETECT = STONES+7; public static final int STONE_ENCHANT = STONES+8; public static final int STONE_FLOCK = STONES+9; public static final int STONE_INTUITION = STONES+10;