From 5c1526e430a5f8171bd14e4daa2d521a8bdddd67 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Wed, 13 Aug 2014 00:26:16 -0400 Subject: [PATCH] V0.1.1: more work on lullaby. --- .../actors/buffs/Drowsy.java | 21 ++++++++++++++----- .../actors/mobs/Mob.java | 4 +++- .../items/scrolls/ScrollOfLullaby.java | 10 +++------ 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Drowsy.java b/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Drowsy.java index 083ddb4c0..3ea3452bd 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Drowsy.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Drowsy.java @@ -17,12 +17,15 @@ */ package com.shatteredpixel.shatteredpixeldungeon.actors.buffs; +import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; -public class Drowsy extends FlavourBuff { +public class Drowsy extends Buff { - public static final float DURATION = 4f; + public static final float STEP = 5f; + + private boolean placed = false; @Override public int icon() { @@ -31,9 +34,17 @@ public class Drowsy extends FlavourBuff { @Override public boolean act(){ - Buff.affect(target, MagicalSleep.class); - GLog.i("You fall into a deep magical sleep."); - return super.act(); + if (placed) { + Buff.affect(target, MagicalSleep.class); + if (target instanceof Hero) + GLog.i("You fall into a deep magical sleep."); + detach(); + return true; + } else { + placed = true; + spend(STEP); + return true; + } } @Override diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mob.java b/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mob.java index b571a2abc..b2b05af54 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mob.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mob.java @@ -295,9 +295,11 @@ public abstract class Mob extends Char { state = State.FLEEING; } else if (buff instanceof Sleep || buff instanceof MagicalSleep) { if (sprite != null) { - new Flare( 4, 32 ).color( 0x44ffff, true ).show( sprite, 2f ) ; + //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/scrolls/ScrollOfLullaby.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/ScrollOfLullaby.java index c74d3e7ea..9a9e545d3 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/ScrollOfLullaby.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/ScrollOfLullaby.java @@ -41,19 +41,15 @@ public class ScrollOfLullaby extends Scroll { curUser.sprite.centerEmitter().start( Speck.factory( Speck.NOTE ), 0.3f, 5 ); Sample.INSTANCE.play( Assets.SND_LULLABY ); Invisibility.dispel(); - - int count = 0; - Mob affected = null; + for (Mob mob : Dungeon.level.mobs.toArray( new Mob[0] )) { if (Level.fieldOfView[mob.pos]) { Buff.affect( mob, Drowsy.class ); - if (mob.buff( Drowsy.class ) != null) { - affected = mob; - count++; - } } } + Buff.affect( curUser, Drowsy.class ); + GLog.i( "The scroll utters a soothing melody. You feel very sleepy." ); setKnown();