diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/actors/Char.java b/src/com/shatteredpixel/shatteredpixeldungeon/actors/Char.java index 3ca3d5b5a..10713832c 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/actors/Char.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/actors/Char.java @@ -367,7 +367,7 @@ public abstract class Char extends Actor { sprite.showStatus( CharSprite.NEGATIVE, "bleeding" ); - } else if (buff instanceof Sleep) { + } else if (buff instanceof Sleep || buff instanceof MagicalSleep) { sprite.idle(); } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Drowsy.java b/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Drowsy.java index 3ea3452bd..c6a76570e 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Drowsy.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Drowsy.java @@ -35,10 +35,18 @@ public class Drowsy extends Buff { @Override public boolean act(){ if (placed) { - Buff.affect(target, MagicalSleep.class); + if (target instanceof Hero) - GLog.i("You fall into a deep magical sleep."); - detach(); + if (target.HP == target.HT) { + GLog.i("You are too healthy, and resist the urge to sleep."); + detach(); + } else { + GLog.i("You fall into a deep magical sleep."); + Buff.affect(target, MagicalSleep.class); + detach(); + } + else + Buff.affect(target, MagicalSleep.class); return true; } else { placed = true; diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java b/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java index e3859cb80..3ee38b0e2 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java @@ -21,6 +21,7 @@ import java.util.ArrayList; import java.util.HashSet; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Drowsy; +import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter; import com.watabou.noosa.Camera; import com.watabou.noosa.Game; import com.watabou.noosa.audio.Sample; @@ -823,7 +824,7 @@ public class Hero extends Char { restoreHealth = false; if (this.buff(Drowsy.class) != null){ Buff.detach(this, Drowsy.class); - GLog.i("The pain helps you resist the urge to sleep."); + GLog.w("The pain helps you resist the urge to sleep."); } super.damage( dmg, src ); @@ -1101,6 +1102,7 @@ public class Hero extends Char { this.HP = HT; //TODO: add sparkle effect new Flare(8, 32).color(0xFFFF66, true).show(sprite, 2f); + CellEmitter.get(this.pos).start(Speck.factory(Speck.LIGHT), 0.2f, 3); ankh.detach(belongings.backpack); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mob.java b/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mob.java index b2b05af54..3d6b6f0c0 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mob.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mob.java @@ -294,10 +294,6 @@ public abstract class Mob extends Char { } else if (buff instanceof Terror) { state = State.FLEEING; } else if (buff instanceof Sleep || buff instanceof MagicalSleep) { - if (sprite != null) { - //new Flare( 4, 32 ).color( 0x44ffff, true ).show( sprite, 2f ) ; - this.sprite().showSleep(); - } state = State.SLEEPING; this.sprite().showSleep(); postpone( Sleep.SWS ); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/Ankh.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/Ankh.java index 05dfc9b38..79252e7db 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/Ankh.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/Ankh.java @@ -19,6 +19,8 @@ package com.shatteredpixel.shatteredpixeldungeon.items; import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; +import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter; +import com.shatteredpixel.shatteredpixeldungeon.effects.Speck; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite.Glowing; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; @@ -82,6 +84,7 @@ public class Ankh extends Item { //TODO: add sparkle effect Sample.INSTANCE.play( Assets.SND_DRINK ); + CellEmitter.get(hero.pos).start(Speck.factory(Speck.LIGHT), 0.2f, 3); hero.sprite.operate( hero.pos ); } } else { diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/food/Blandfruit.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/food/Blandfruit.java index ce32ba6b4..ecfda3521 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/food/Blandfruit.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/food/Blandfruit.java @@ -128,7 +128,7 @@ public class Blandfruit extends Food { potionAttrib instanceof PotionOfParalyticGas || potionAttrib instanceof PotionOfFrost){ potionAttrib.execute(hero, action); - detach( hero.belongings.backpack ); + //detaches in Potion.cast, this is an awkward workaround due to throwing being on a different thread. } else { super.execute(hero, action); } @@ -154,6 +154,7 @@ public class Blandfruit extends Food { try { potionAttrib = (Potion)plant.newInstance(); + potionAttrib.ownedByFruit = true; } catch (Exception e) { return null; } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/potions/Potion.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/potions/Potion.java index 7aa6861a9..440b81afd 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/potions/Potion.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/potions/Potion.java @@ -86,6 +86,8 @@ public class Potion extends Item { private static ItemStatusHandler handler; private String color; + + public boolean ownedByFruit = false; { stackable = true; @@ -217,21 +219,31 @@ public class Potion extends Item { Sample.INSTANCE.play( Assets.SND_SHATTER ); splash( cell ); } + + @Override + public void cast( final Hero user, int dst ) { + super.cast(user, dst); + //if this potion is owned by a fruit, finds it and detaches it. + //TODO: add remove code here + } public boolean isKnown() { return handler.isKnown( this ); } public void setKnown() { - if (!isKnown()) { - handler.know( this ); - } - - Badges.validateAllPotionsIdentified(); + if (!ownedByFruit) { + if (!isKnown()) { + handler.know(this); + } + + Badges.validateAllPotionsIdentified(); + } } @Override public Item identify() { + setKnown(); return this; } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/ScrollOfLullaby.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/ScrollOfLullaby.java index 9a9e545d3..b58b5fed5 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/ScrollOfLullaby.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/ScrollOfLullaby.java @@ -45,6 +45,7 @@ public class ScrollOfLullaby extends Scroll { for (Mob mob : Dungeon.level.mobs.toArray( new Mob[0] )) { if (Level.fieldOfView[mob.pos]) { Buff.affect( mob, Drowsy.class ); + mob.sprite.centerEmitter().start( Speck.factory( Speck.NOTE ), 0.3f, 5 ); } }