From a7d8bc673586e5f862c79517a1692eac8f83b489 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Wed, 30 Mar 2022 16:23:41 -0400 Subject: [PATCH] v1.2.1: the game now tries to preserve quickslot for transmuted items --- .../items/scrolls/ScrollOfTransmutation.java | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/ScrollOfTransmutation.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/ScrollOfTransmutation.java index ca2cd7371..e3325043c 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/ScrollOfTransmutation.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/ScrollOfTransmutation.java @@ -23,6 +23,7 @@ package com.shatteredpixel.shatteredpixeldungeon.items.scrolls; import com.shatteredpixel.shatteredpixeldungeon.Challenges; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; +import com.shatteredpixel.shatteredpixeldungeon.QuickSlot; import com.shatteredpixel.shatteredpixeldungeon.effects.Speck; import com.shatteredpixel.shatteredpixeldungeon.effects.Transmuting; import com.shatteredpixel.shatteredpixeldungeon.items.EquipableItem; @@ -83,14 +84,25 @@ public class ScrollOfTransmutation extends InventoryScroll { GLog.n( Messages.get(this, "nothing") ); curItem.collect( curUser.belongings.backpack ); } else { - if (item.isEquipped(Dungeon.hero)){ - item.cursed = false; //to allow it to be unequipped - ((EquipableItem)item).doUnequip(Dungeon.hero, false); - ((EquipableItem)result).doEquip(Dungeon.hero); - } else { - item.detach(Dungeon.hero.belongings.backpack); - if (!result.collect()){ - Dungeon.level.drop(result, curUser.pos).sprite.drop(); + if (result != item) { + int slot = Dungeon.quickslot.getSlot(item); + if (item.isEquipped(Dungeon.hero)) { + item.cursed = false; //to allow it to be unequipped + ((EquipableItem) item).doUnequip(Dungeon.hero, false); + ((EquipableItem) result).doEquip(Dungeon.hero); + } else { + item.detach(Dungeon.hero.belongings.backpack); + if (!result.collect()) { + Dungeon.level.drop(result, curUser.pos).sprite.drop(); + } else if (Dungeon.hero.belongings.getSimilar(result) != null){ + result = Dungeon.hero.belongings.getSimilar(result); + } + } + if (slot != -1 + && result.defaultAction != null + && !Dungeon.quickslot.isNonePlaceholder(slot) + && Dungeon.hero.belongings.contains(result)){ + Dungeon.quickslot.setSlot(slot, result); } } if (result.isIdentified()){