From 99760aac8675e44d6db9121d91890ab8fabe124c Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Thu, 9 Jun 2016 05:48:32 -0400 Subject: [PATCH] v0.4.0: adjusted some scroll logic --- .../items/Generator.java | 2 +- .../items/scrolls/ScrollOfRemoveCurse.java | 32 ++++++++----------- .../levels/painters/LibraryPainter.java | 9 +++++- .../messages/items/items.properties | 9 +++--- .../shatteredpixeldungeon/windows/WndBag.java | 14 ++++++++ 5 files changed, 41 insertions(+), 25 deletions(-) diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/Generator.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/Generator.java index 178bae0aa..89ec5460a 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/Generator.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/Generator.java @@ -116,7 +116,7 @@ public class Generator { ScrollOfMagicalInfusion.class, ScrollOfPsionicBlast.class, ScrollOfMirrorImage.class }; - Category.SCROLL.probs = new float[]{ 30, 10, 15, 0, 15, 15, 12, 8, 8, 0, 4, 10 }; + Category.SCROLL.probs = new float[]{ 35, 10, 25, 0, 15, 15, 12, 8, 8, 0, 4, 10 }; Category.POTION.classes = new Class[]{ PotionOfHealing.class, diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/ScrollOfRemoveCurse.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/ScrollOfRemoveCurse.java index 07ad661c9..03c8b86f8 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/ScrollOfRemoveCurse.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/ScrollOfRemoveCurse.java @@ -29,44 +29,35 @@ import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ShadowParticle import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor; import com.shatteredpixel.shatteredpixeldungeon.items.bags.Bag; +import com.shatteredpixel.shatteredpixeldungeon.items.rings.Ring; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; +import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag; import com.watabou.noosa.audio.Sample; -public class ScrollOfRemoveCurse extends Scroll { +public class ScrollOfRemoveCurse extends InventoryScroll { { initials = 8; + mode = WndBag.Mode.UNIDED_OR_CURSED; } @Override - protected void doRead() { - + protected void onItemSelected(Item item) { new Flare( 6, 32 ).show( curUser.sprite, 2f ) ; - Sample.INSTANCE.play( Assets.SND_READ ); - Invisibility.dispel(); - - boolean procced = uncurse( curUser, curUser.belongings.backpack.items.toArray( new Item[0] ) ); - procced = uncurse( curUser, - curUser.belongings.weapon, - curUser.belongings.armor, - curUser.belongings.misc1, - curUser.belongings.misc2) || procced; - + + boolean procced = uncurse( curUser, item ); + Weakness.detach( curUser, Weakness.class ); - + if (procced) { GLog.p( Messages.get(this, "cleansed") ); } else { GLog.i( Messages.get(this, "not_cleansed") ); } - - setKnown(); - - readAnimation(); } - + public static boolean uncurse( Hero hero, Item... items ) { boolean procced = false; @@ -91,6 +82,9 @@ public class ScrollOfRemoveCurse extends Scroll { procced = true; } } + if (item instanceof Ring && item.level() <= 0){ + item.upgrade(1 - item.level()); + } if (item instanceof Bag){ for (Item bagItem : ((Bag)item).items){ if (bagItem != null && bagItem.cursed) { diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/levels/painters/LibraryPainter.java b/src/com/shatteredpixel/shatteredpixeldungeon/levels/painters/LibraryPainter.java index def73c5b4..9f84b6322 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/levels/painters/LibraryPainter.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/levels/painters/LibraryPainter.java @@ -25,6 +25,8 @@ import com.shatteredpixel.shatteredpixeldungeon.items.Generator; import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.keys.IronKey; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll; +import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfIdentify; +import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfRemoveCurse; import com.shatteredpixel.shatteredpixeldungeon.levels.Level; import com.shatteredpixel.shatteredpixeldungeon.levels.Room; import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; @@ -72,7 +74,12 @@ public class LibraryPainter extends Painter { do { pos = room.random(); } while (level.map[pos] != Terrain.EMPTY || level.heaps.get( pos ) != null); - level.drop( prize( level), pos ); + Item item; + if (i == 0) + item = Random.Int(2) == 0 ? new ScrollOfIdentify() : new ScrollOfRemoveCurse(); + else + item = prize( level ); + level.drop( item, pos ); } entrance.set( Room.Door.Type.LOCKED ); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties b/src/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties index 97dd675b2..66e2abbc1 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties +++ b/src/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties @@ -598,9 +598,10 @@ items.scrolls.scrollofrecharging.surge=A surge of energy courses through your bo items.scrolls.scrollofrecharging.desc=The raw magical power bound up in this parchment will, when released, charge up all the users wands over time. items.scrolls.scrollofremovecurse.name=scroll of remove curse -items.scrolls.scrollofremovecurse.cleansed=Your pack glows with a cleansing light, and a malevolent energy disperses. -items.scrolls.scrollofremovecurse.not_cleansed=Your pack glows with a cleansing light, but nothing happens. -items.scrolls.scrollofremovecurse.desc=The incantation on this scroll will instantly strip from the reader's weapon, armor, rings and carried items any evil enchantments that might prevent the wearer from removing them. +items.scrolls.scrollofremovecurse.inv_title=Select an item to cleanse +items.scrolls.scrollofremovecurse.cleansed=Your item glows with a cleansing light, and a malevolent energy disperses! +items.scrolls.scrollofremovecurse.not_cleansed=Your item glows with a cleansing light, but nothing happens. +items.scrolls.scrollofremovecurse.desc=The incantation on this scroll will instantly strip any curses from a single weapon, ring, wand, armor, or artifact. items.scrolls.scrollofteleportation.name=scroll of teleportation items.scrolls.scrollofteleportation.tele=In a blink of an eye you were teleported to another location of the level. @@ -616,7 +617,7 @@ items.scrolls.scrollofterror.desc=A flash of red light will overwhelm all creatu items.scrolls.scrollofupgrade.name=scroll of upgrade items.scrolls.scrollofupgrade.inv_title=Select an item to upgrade items.scrolls.scrollofupgrade.looks_better=Your %s certainly looks better now -items.scrolls.scrollofupgrade.desc=This scroll will upgrade a single item, improving its quality. A wand will increase in power and in number of charges; a weapon will inflict more damage; a suit of armor will better absorb damage; the effect of a ring on its wearer will intensify. Weapons and armor will also require less strength to use, and any curses on the item will be lifted. +items.scrolls.scrollofupgrade.desc=This scroll will upgrade a single item, improving its quality. A wand will increase in power and number of charges, weapons and armor will deal and block more damage, and the effects of rings will intensify. This scroll is even able to dispel curse effects, though it is not as potent as a scroll of remove curse. diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndBag.java b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndBag.java index be753d8c3..9a336fb60 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndBag.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndBag.java @@ -39,6 +39,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.food.Food; import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll; import com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand; +import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MeleeWeapon; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.Boomerang; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; @@ -60,6 +61,7 @@ public class WndBag extends WndTabbed { public static enum Mode { ALL, UNIDENTIFED, + UNIDED_OR_CURSED, UPGRADEABLE, QUICKSLOT, FOR_SALE, @@ -367,6 +369,7 @@ public class WndBag extends WndTabbed { mode == Mode.FOR_SALE && (item.price() > 0) && (!item.isEquipped( Dungeon.hero ) || !item.cursed) || mode == Mode.UPGRADEABLE && item.isUpgradable() || mode == Mode.UNIDENTIFED && !item.isIdentified() || + mode == Mode.UNIDED_OR_CURSED && (item instanceof EquipableItem && (!item.isIdentified() || item.cursed)) || mode == Mode.QUICKSLOT && (item.defaultAction != null) || mode == Mode.WEAPON && (item instanceof MeleeWeapon || item instanceof Boomerang) || mode == Mode.ARMOR && (item instanceof Armor) || @@ -379,6 +382,17 @@ public class WndBag extends WndTabbed { mode == Mode.EQUIPMENT && (item instanceof EquipableItem) || mode == Mode.ALL ); + //extra logic for cursed weapons or armor + if (!active && mode == Mode.UNIDED_OR_CURSED){ + if (item instanceof Weapon){ + Weapon w = (Weapon) item; + enable(w.enchantment != null && w.enchantment.curse()); + } + if (item instanceof Armor){ + Armor a = (Armor) item; + enable(a.glyph != null && a.glyph.curse()); + } + } } } else { bg.color( NORMAL );