v2.2.0: overhauled logic for item consumption when use has multi steps
This commit is contained in:
@@ -153,6 +153,7 @@ public class UnstableSpellbook extends Artifact {
|
||||
handler.detach();
|
||||
if (index == 1){
|
||||
Scroll scroll = Reflection.newInstance(ExoticScroll.regToExo.get(fScroll.getClass()));
|
||||
curItem = scroll;
|
||||
charge--;
|
||||
scroll.anonymize();
|
||||
scroll.doRead();
|
||||
|
||||
@@ -44,11 +44,19 @@ public class PotionOfDivineInspiration extends ExoticPotion {
|
||||
icon = ItemSpriteSheet.Icons.POTION_DIVINE;
|
||||
}
|
||||
|
||||
protected static boolean identifiedByUse = false;
|
||||
|
||||
@Override
|
||||
//need to override drink so that time isn't spent right away
|
||||
protected void drink(final Hero hero) {
|
||||
curUser = hero;
|
||||
curItem = this;
|
||||
|
||||
if (!isKnown()) {
|
||||
identify();
|
||||
curItem = detach( hero.belongings.backpack );
|
||||
identifiedByUse = true;
|
||||
} else {
|
||||
identifiedByUse = false;
|
||||
}
|
||||
|
||||
boolean[] enabled = new boolean[5];
|
||||
enabled[1] = enabled[2] = enabled[3] = enabled[4] = true;
|
||||
@@ -71,10 +79,6 @@ public class PotionOfDivineInspiration extends ExoticPotion {
|
||||
}
|
||||
}
|
||||
|
||||
if (!isIdentified()) {
|
||||
curItem.detach(curUser.belongings.backpack);
|
||||
}
|
||||
|
||||
GameScene.show(new WndOptions(
|
||||
new ItemSprite(this),
|
||||
Messages.titleCase(trueName()),
|
||||
@@ -96,11 +100,11 @@ public class PotionOfDivineInspiration extends ExoticPotion {
|
||||
if (index != -1){
|
||||
Buff.affect(curUser, DivineInspirationTracker.class).setBoosted(index+1);
|
||||
|
||||
if (isIdentified()) {
|
||||
if (!identifiedByUse) {
|
||||
curItem.detach(curUser.belongings.backpack);
|
||||
}
|
||||
identifiedByUse = false;
|
||||
|
||||
identify();
|
||||
curUser.busy();
|
||||
curUser.sprite.operate(curUser.pos);
|
||||
|
||||
@@ -132,7 +136,7 @@ public class PotionOfDivineInspiration extends ExoticPotion {
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
//window can be closed if potion is already IDed
|
||||
if (isIdentified()){
|
||||
if (!identifiedByUse){
|
||||
super.onBackPressed();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,11 +60,10 @@ public class PotionOfDragonsBreath extends ExoticPotion {
|
||||
@Override
|
||||
//need to override drink so that time isn't spent right away
|
||||
protected void drink(final Hero hero) {
|
||||
curUser = hero;
|
||||
curItem = detach( hero.belongings.backpack );
|
||||
|
||||
if (!isKnown()) {
|
||||
identify();
|
||||
curItem = detach( hero.belongings.backpack );
|
||||
identifiedByUse = true;
|
||||
} else {
|
||||
identifiedByUse = false;
|
||||
@@ -116,9 +115,10 @@ public class PotionOfDragonsBreath extends ExoticPotion {
|
||||
} );
|
||||
}
|
||||
});
|
||||
} else if (cell == null && !anonymous){
|
||||
curItem.collect( curUser.belongings.backpack );
|
||||
} else if (cell != null) {
|
||||
if (!identifiedByUse) {
|
||||
curItem.detach(curUser.belongings.backpack);
|
||||
}
|
||||
potionAlreadyUsed = true;
|
||||
identifiedByUse = false;
|
||||
curUser.busy();
|
||||
@@ -127,8 +127,6 @@ public class PotionOfDragonsBreath extends ExoticPotion {
|
||||
@Override
|
||||
public void call() {
|
||||
|
||||
curItem.detach(curUser.belongings.backpack);
|
||||
|
||||
curUser.sprite.idle();
|
||||
curUser.sprite.zap(cell);
|
||||
Sample.INSTANCE.play( Assets.Sounds.BURNING );
|
||||
|
||||
@@ -49,11 +49,10 @@ public class PotionOfMastery extends ExoticPotion {
|
||||
@Override
|
||||
//need to override drink so that time isn't spent right away
|
||||
protected void drink(final Hero hero) {
|
||||
curUser = hero;
|
||||
curItem = detach( hero.belongings.backpack );
|
||||
|
||||
if (!isKnown()) {
|
||||
identify();
|
||||
curItem = detach( hero.belongings.backpack );
|
||||
identifiedByUse = true;
|
||||
} else {
|
||||
identifiedByUse = false;
|
||||
@@ -99,8 +98,6 @@ public class PotionOfMastery extends ExoticPotion {
|
||||
}
|
||||
public void onBackPressed() {}
|
||||
} );
|
||||
} else if (item == null && !anonymous){
|
||||
curItem.collect( curUser.belongings.backpack );
|
||||
} else if (item != null) {
|
||||
|
||||
if (item instanceof Weapon) {
|
||||
@@ -114,7 +111,11 @@ public class PotionOfMastery extends ExoticPotion {
|
||||
|
||||
Sample.INSTANCE.play( Assets.Sounds.DRINK );
|
||||
curUser.sprite.operate(curUser.pos);
|
||||
curItem.detach(curUser.belongings.backpack);
|
||||
|
||||
if (!identifiedByUse) {
|
||||
curItem.detach(curUser.belongings.backpack);
|
||||
}
|
||||
identifiedByUse = false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ public abstract class InventoryScroll extends Scroll {
|
||||
|
||||
if (!isKnown()) {
|
||||
identify();
|
||||
curItem = detach( curUser.belongings.backpack );
|
||||
identifiedByUse = true;
|
||||
} else {
|
||||
identifiedByUse = false;
|
||||
@@ -109,7 +110,10 @@ public abstract class InventoryScroll extends Scroll {
|
||||
}
|
||||
|
||||
if (item != null) {
|
||||
|
||||
|
||||
if (!identifiedByUse) {
|
||||
curItem = detach(curUser.belongings.backpack);
|
||||
}
|
||||
((InventoryScroll)curItem).onItemSelected( item );
|
||||
((InventoryScroll)curItem).readAnimation();
|
||||
|
||||
@@ -119,10 +123,6 @@ public abstract class InventoryScroll extends Scroll {
|
||||
|
||||
((InventoryScroll)curItem).confirmCancelation();
|
||||
|
||||
} else if (!((Scroll)curItem).anonymous) {
|
||||
|
||||
curItem.collect( curUser.belongings.backpack );
|
||||
|
||||
} else {
|
||||
|
||||
curUser.spendAndNext( TIME_TO_READ );
|
||||
|
||||
@@ -171,8 +171,6 @@ public abstract class Scroll extends Item {
|
||||
&& !(this instanceof ScrollOfRemoveCurse || this instanceof ScrollOfAntiMagic)){
|
||||
GLog.n( Messages.get(this, "cursed") );
|
||||
} else {
|
||||
curUser = hero;
|
||||
curItem = detach( hero.belongings.backpack );
|
||||
doRead();
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,8 @@ public class ScrollOfLullaby extends Scroll {
|
||||
|
||||
@Override
|
||||
public void doRead() {
|
||||
|
||||
|
||||
detach(curUser.belongings.backpack);
|
||||
curUser.sprite.centerEmitter().start( Speck.factory( Speck.NOTE ), 0.3f, 5 );
|
||||
Sample.INSTANCE.play( Assets.Sounds.LULLABY );
|
||||
|
||||
|
||||
@@ -41,7 +41,8 @@ public class ScrollOfMagicMapping extends Scroll {
|
||||
|
||||
@Override
|
||||
public void doRead() {
|
||||
|
||||
|
||||
detach(curUser.belongings.backpack);
|
||||
int length = Dungeon.level.length();
|
||||
int[] map = Dungeon.level.map;
|
||||
boolean[] mapped = Dungeon.level.mapped;
|
||||
|
||||
@@ -46,6 +46,7 @@ public class ScrollOfMirrorImage extends Scroll {
|
||||
|
||||
@Override
|
||||
public void doRead() {
|
||||
detach(curUser.belongings.backpack);
|
||||
if ( spawnImages(curUser, NIMAGES) > 0){
|
||||
GLog.i(Messages.get(this, "copies"));
|
||||
} else {
|
||||
|
||||
@@ -42,6 +42,7 @@ public class ScrollOfRage extends Scroll {
|
||||
@Override
|
||||
public void doRead() {
|
||||
|
||||
detach(curUser.belongings.backpack);
|
||||
for (Mob mob : Dungeon.level.mobs.toArray( new Mob[0] )) {
|
||||
mob.beckon( curUser.pos );
|
||||
if (mob.alignment != Char.Alignment.ALLY && Dungeon.level.heroFOV[mob.pos]) {
|
||||
|
||||
@@ -42,6 +42,7 @@ public class ScrollOfRecharging extends Scroll {
|
||||
@Override
|
||||
public void doRead() {
|
||||
|
||||
detach(curUser.belongings.backpack);
|
||||
Buff.affect(curUser, Recharging.class, Recharging.DURATION);
|
||||
charge(curUser);
|
||||
|
||||
|
||||
@@ -50,6 +50,8 @@ public class ScrollOfRemoveCurse extends InventoryScroll {
|
||||
|
||||
@Override
|
||||
public void doRead() {
|
||||
|
||||
detach(curUser.belongings.backpack);
|
||||
TormentedSpirit spirit = null;
|
||||
for (int i : PathFinder.NEIGHBOURS8){
|
||||
if (Actor.findChar(curUser.pos+i) instanceof TormentedSpirit){
|
||||
|
||||
@@ -41,7 +41,8 @@ public class ScrollOfRetribution extends Scroll {
|
||||
|
||||
@Override
|
||||
public void doRead() {
|
||||
|
||||
|
||||
detach(curUser.belongings.backpack);
|
||||
GameScene.flash( 0x80FFFFFF );
|
||||
|
||||
//scales from 0x to 1x power, maxing at ~10% HP
|
||||
|
||||
@@ -57,6 +57,7 @@ public class ScrollOfTeleportation extends Scroll {
|
||||
@Override
|
||||
public void doRead() {
|
||||
|
||||
detach(curUser.belongings.backpack);
|
||||
Sample.INSTANCE.play( Assets.Sounds.READ );
|
||||
|
||||
if (teleportPreferringUnseen( curUser )){
|
||||
|
||||
@@ -41,7 +41,8 @@ public class ScrollOfTerror extends Scroll {
|
||||
|
||||
@Override
|
||||
public void doRead() {
|
||||
|
||||
|
||||
detach(curUser.belongings.backpack);
|
||||
new Flare( 5, 32 ).color( 0xFF0000, true ).show( curUser.sprite, 2f );
|
||||
Sample.INSTANCE.play( Assets.Sounds.READ );
|
||||
|
||||
|
||||
@@ -34,7 +34,8 @@ public class ScrollOfAntiMagic extends ExoticScroll {
|
||||
|
||||
@Override
|
||||
public void doRead() {
|
||||
|
||||
|
||||
detach(curUser.belongings.backpack);
|
||||
Buff.affect( curUser, MagicImmune.class, MagicImmune.DURATION );
|
||||
new Flare( 5, 32 ).color( 0x00FF00, true ).show( curUser.sprite, 2f );
|
||||
|
||||
|
||||
@@ -50,6 +50,8 @@ public class ScrollOfChallenge extends ExoticScroll {
|
||||
|
||||
@Override
|
||||
public void doRead() {
|
||||
|
||||
detach(curUser.belongings.backpack);
|
||||
for (Mob mob : Dungeon.level.mobs.toArray( new Mob[0] )) {
|
||||
mob.beckon( curUser.pos );
|
||||
}
|
||||
|
||||
@@ -51,7 +51,8 @@ public class ScrollOfDivination extends ExoticScroll {
|
||||
|
||||
@Override
|
||||
public void doRead() {
|
||||
|
||||
|
||||
detach(curUser.belongings.backpack);
|
||||
curUser.sprite.parent.add( new Identification( curUser.sprite.center().offset( 0, -16 ) ) );
|
||||
|
||||
Sample.INSTANCE.play( Assets.Sounds.READ );
|
||||
|
||||
@@ -40,6 +40,8 @@ public class ScrollOfDread extends ExoticScroll {
|
||||
|
||||
@Override
|
||||
public void doRead() {
|
||||
|
||||
detach(curUser.belongings.backpack);
|
||||
new Flare( 5, 32 ).color( 0xFF0000, true ).show( curUser.sprite, 2f );
|
||||
Sample.INSTANCE.play( Assets.Sounds.READ );
|
||||
|
||||
|
||||
@@ -59,6 +59,7 @@ public class ScrollOfEnchantment extends ExoticScroll {
|
||||
public void doRead() {
|
||||
if (!isKnown()) {
|
||||
identify();
|
||||
curItem = detach(curUser.belongings.backpack);
|
||||
identifiedByUse = true;
|
||||
} else {
|
||||
identifiedByUse = false;
|
||||
@@ -113,6 +114,10 @@ public class ScrollOfEnchantment extends ExoticScroll {
|
||||
public void onSelect(final Item item) {
|
||||
|
||||
if (item instanceof Weapon){
|
||||
if (!identifiedByUse) {
|
||||
curItem.detach(curUser.belongings.backpack);
|
||||
}
|
||||
identifiedByUse = false;
|
||||
|
||||
final Weapon.Enchantment enchants[] = new Weapon.Enchantment[3];
|
||||
|
||||
@@ -124,6 +129,10 @@ public class ScrollOfEnchantment extends ExoticScroll {
|
||||
GameScene.show(new WndEnchantSelect((Weapon) item, enchants[0], enchants[1], enchants[2]));
|
||||
|
||||
} else if (item instanceof Armor) {
|
||||
if (!identifiedByUse) {
|
||||
curItem.detach(curUser.belongings.backpack);
|
||||
}
|
||||
identifiedByUse = false;
|
||||
|
||||
final Armor.Glyph glyphs[] = new Armor.Glyph[3];
|
||||
|
||||
@@ -133,12 +142,8 @@ public class ScrollOfEnchantment extends ExoticScroll {
|
||||
glyphs[2] = Armor.Glyph.random( existing, glyphs[0].getClass(), glyphs[1].getClass());
|
||||
|
||||
GameScene.show(new WndGlyphSelect((Armor) item, glyphs[0], glyphs[1], glyphs[2]));
|
||||
} else {
|
||||
if (!identifiedByUse){
|
||||
curItem.collect();
|
||||
} else {
|
||||
((ScrollOfEnchantment)curItem).confirmCancelation();
|
||||
}
|
||||
} else if (identifiedByUse){
|
||||
((ScrollOfEnchantment)curItem).confirmCancelation();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -35,6 +35,8 @@ public class ScrollOfForesight extends ExoticScroll {
|
||||
|
||||
@Override
|
||||
public void doRead() {
|
||||
|
||||
detach(curUser.belongings.backpack);
|
||||
Sample.INSTANCE.play( Assets.Sounds.READ );
|
||||
|
||||
Buff.affect(curUser, Foresight.class, Foresight.DURATION);
|
||||
|
||||
@@ -58,6 +58,7 @@ public class ScrollOfMetamorphosis extends ExoticScroll {
|
||||
public void doRead() {
|
||||
if (!isKnown()) {
|
||||
identify();
|
||||
curItem = detach(curUser.belongings.backpack);
|
||||
identifiedByUse = true;
|
||||
} else {
|
||||
identifiedByUse = false;
|
||||
@@ -156,7 +157,6 @@ public class ScrollOfMetamorphosis extends ExoticScroll {
|
||||
((ScrollOfMetamorphosis)curItem).confirmCancelation(this);
|
||||
} else {
|
||||
super.onBackPressed();
|
||||
curItem.collect();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,6 +193,11 @@ public class ScrollOfMetamorphosis extends ExoticScroll {
|
||||
public WndMetamorphReplace(Talent replacing, int tier){
|
||||
super();
|
||||
|
||||
if (!identifiedByUse) {
|
||||
curItem.detach(curUser.belongings.backpack);
|
||||
}
|
||||
identifiedByUse = false;
|
||||
|
||||
INSTANCE = this;
|
||||
|
||||
this.replacing = replacing;
|
||||
|
||||
@@ -37,7 +37,8 @@ public class ScrollOfMysticalEnergy extends ExoticScroll {
|
||||
|
||||
@Override
|
||||
public void doRead() {
|
||||
|
||||
|
||||
detach(curUser.belongings.backpack);
|
||||
//append buff
|
||||
Buff.affect(curUser, ArtifactRecharge.class).set( 30 ).ignoreHornOfPlenty = false;
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ public class ScrollOfPassage extends ExoticScroll {
|
||||
@Override
|
||||
public void doRead() {
|
||||
|
||||
detach(curUser.belongings.backpack);
|
||||
identify();
|
||||
readAnimation();
|
||||
|
||||
|
||||
@@ -39,7 +39,8 @@ public class ScrollOfPrismaticImage extends ExoticScroll {
|
||||
|
||||
@Override
|
||||
public void doRead() {
|
||||
|
||||
|
||||
detach(curUser.belongings.backpack);
|
||||
boolean found = false;
|
||||
for (Mob m : Dungeon.level.mobs.toArray(new Mob[0])){
|
||||
if (m instanceof PrismaticImage){
|
||||
|
||||
@@ -43,7 +43,8 @@ public class ScrollOfPsionicBlast extends ExoticScroll {
|
||||
|
||||
@Override
|
||||
public void doRead() {
|
||||
|
||||
|
||||
detach(curUser.belongings.backpack);
|
||||
GameScene.flash( 0x80FFFFFF );
|
||||
|
||||
Sample.INSTANCE.play( Assets.Sounds.BLAST );
|
||||
|
||||
@@ -44,10 +44,18 @@ public class ScrollOfSirensSong extends ExoticScroll {
|
||||
{
|
||||
icon = ItemSpriteSheet.Icons.SCROLL_SIREN;
|
||||
}
|
||||
|
||||
protected static boolean identifiedByUse = false;
|
||||
|
||||
@Override
|
||||
public void doRead() {
|
||||
if (!anonymous) curItem.collect(); //we detach it later
|
||||
if (!isKnown()) {
|
||||
identify();
|
||||
curItem = detach(curUser.belongings.backpack);
|
||||
identifiedByUse = true;
|
||||
} else {
|
||||
identifiedByUse = false;
|
||||
}
|
||||
GameScene.selectCell(targeter);
|
||||
}
|
||||
|
||||
@@ -67,14 +75,12 @@ public class ScrollOfSirensSong extends ExoticScroll {
|
||||
}
|
||||
}
|
||||
|
||||
if (target == null && isKnown() && !anonymous){
|
||||
if (target == null && !anonymous && !identifiedByUse){
|
||||
GLog.w(Messages.get(ScrollOfSirensSong.class, "cancel"));
|
||||
return;
|
||||
|
||||
} else {
|
||||
|
||||
detach(curUser.belongings.backpack);
|
||||
|
||||
curUser.sprite.centerEmitter().start( Speck.factory( Speck.HEART ), 0.2f, 5 );
|
||||
Sample.INSTANCE.play( Assets.Sounds.CHARMS );
|
||||
Sample.INSTANCE.playDelayed( Assets.Sounds.LULLABY, 0.1f );
|
||||
@@ -99,7 +105,10 @@ public class ScrollOfSirensSong extends ExoticScroll {
|
||||
GLog.w(Messages.get(ScrollOfSirensSong.class, "no_target"));
|
||||
}
|
||||
|
||||
identify();
|
||||
if (!identifiedByUse) {
|
||||
curItem.detach(curUser.belongings.backpack);
|
||||
}
|
||||
identifiedByUse = false;
|
||||
|
||||
readAnimation();
|
||||
|
||||
|
||||
@@ -52,7 +52,6 @@ public abstract class InventoryStone extends Runestone {
|
||||
public void execute(Hero hero, String action) {
|
||||
super.execute(hero, action);
|
||||
if (action.equals(AC_USE)){
|
||||
curItem = detach( hero.belongings.backpack );
|
||||
activate(curUser.pos);
|
||||
}
|
||||
}
|
||||
@@ -66,7 +65,7 @@ public abstract class InventoryStone extends Runestone {
|
||||
curUser.spend( 1f );
|
||||
curUser.busy();
|
||||
curUser.sprite.operate(curUser.pos);
|
||||
|
||||
|
||||
Sample.INSTANCE.play( Assets.Sounds.READ );
|
||||
Invisibility.dispel();
|
||||
}
|
||||
@@ -110,11 +109,9 @@ public abstract class InventoryStone extends Runestone {
|
||||
}
|
||||
|
||||
if (item != null) {
|
||||
|
||||
|
||||
((InventoryStone)curItem).onItemSelected( item );
|
||||
|
||||
} else{
|
||||
curItem.collect( curUser.belongings.backpack );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -60,6 +60,7 @@ public class StoneOfAugmentation extends InventoryStone {
|
||||
weapon.augment = augment;
|
||||
useAnimation();
|
||||
ScrollOfUpgrade.upgrade(curUser);
|
||||
curItem.detach( curUser.belongings.backpack );
|
||||
|
||||
}
|
||||
|
||||
@@ -68,6 +69,7 @@ public class StoneOfAugmentation extends InventoryStone {
|
||||
armor.augment = augment;
|
||||
useAnimation();
|
||||
ScrollOfUpgrade.upgrade(curUser);
|
||||
curItem.detach( curUser.belongings.backpack );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -48,6 +48,7 @@ public class StoneOfEnchantment extends InventoryStone {
|
||||
|
||||
@Override
|
||||
protected void onItemSelected(Item item) {
|
||||
curItem.detach( curUser.belongings.backpack );
|
||||
|
||||
if (item instanceof Weapon) {
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ public class StoneOfIntuition extends InventoryStone {
|
||||
|
||||
@Override
|
||||
protected void onItemSelected(Item item) {
|
||||
|
||||
|
||||
GameScene.show( new WndGuess(item));
|
||||
|
||||
}
|
||||
@@ -110,12 +110,13 @@ public class StoneOfIntuition extends InventoryStone {
|
||||
|
||||
if (curUser.buff(IntuitionUseTracker.class) == null){
|
||||
GLog.h( Messages.get(WndGuess.class, "preserved") );
|
||||
new StoneOfIntuition().collect();
|
||||
Buff.affect(curUser, IntuitionUseTracker.class);
|
||||
} else {
|
||||
curItem.detach( curUser.belongings.backpack );
|
||||
curUser.buff(IntuitionUseTracker.class).detach();
|
||||
}
|
||||
} else {
|
||||
curItem.detach( curUser.belongings.backpack );
|
||||
if (curUser.buff(IntuitionUseTracker.class) != null) {
|
||||
curUser.buff(IntuitionUseTracker.class).detach();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user