v1.2.1: the game now tries to preserve quickslot for transmuted items

This commit is contained in:
Evan Debenham 2022-03-30 16:23:41 -04:00
parent 64283a2e32
commit a7d8bc6735

View File

@ -23,6 +23,7 @@ package com.shatteredpixel.shatteredpixeldungeon.items.scrolls;
import com.shatteredpixel.shatteredpixeldungeon.Challenges; import com.shatteredpixel.shatteredpixeldungeon.Challenges;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.QuickSlot;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck; import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.effects.Transmuting; import com.shatteredpixel.shatteredpixeldungeon.effects.Transmuting;
import com.shatteredpixel.shatteredpixeldungeon.items.EquipableItem; import com.shatteredpixel.shatteredpixeldungeon.items.EquipableItem;
@ -83,14 +84,25 @@ public class ScrollOfTransmutation extends InventoryScroll {
GLog.n( Messages.get(this, "nothing") ); GLog.n( Messages.get(this, "nothing") );
curItem.collect( curUser.belongings.backpack ); curItem.collect( curUser.belongings.backpack );
} else { } else {
if (item.isEquipped(Dungeon.hero)){ if (result != item) {
item.cursed = false; //to allow it to be unequipped int slot = Dungeon.quickslot.getSlot(item);
((EquipableItem)item).doUnequip(Dungeon.hero, false); if (item.isEquipped(Dungeon.hero)) {
((EquipableItem)result).doEquip(Dungeon.hero); item.cursed = false; //to allow it to be unequipped
} else { ((EquipableItem) item).doUnequip(Dungeon.hero, false);
item.detach(Dungeon.hero.belongings.backpack); ((EquipableItem) result).doEquip(Dungeon.hero);
if (!result.collect()){ } else {
Dungeon.level.drop(result, curUser.pos).sprite.drop(); 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()){ if (result.isIdentified()){