diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/actors/Char.java b/src/com/shatteredpixel/shatteredpixeldungeon/actors/Char.java index 10713832c..4f64e7fec 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/actors/Char.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/actors/Char.java @@ -20,6 +20,7 @@ package com.shatteredpixel.shatteredpixeldungeon.actors; import java.util.HashSet; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.*; +import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.CloakOfShadows; import com.watabou.noosa.audio.Sample; import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; @@ -395,7 +396,7 @@ public abstract class Char extends Actor { sprite.remove( CharSprite.State.BURNING ); } else if (buff instanceof Levitation) { sprite.remove( CharSprite.State.LEVITATING ); - } else if (buff instanceof Invisibility && invisible <= 0) { + } else if (buff instanceof Invisibility || buff instanceof CloakOfShadows.cloakStealth && invisible <= 0) { sprite.remove( CharSprite.State.INVISIBLE ); } else if (buff instanceof Paralysis) { sprite.remove( CharSprite.State.PARALYSED ); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Invisibility.java b/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Invisibility.java index 084db1333..a18d3fdd3 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Invisibility.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Invisibility.java @@ -19,7 +19,7 @@ package com.shatteredpixel.shatteredpixeldungeon.actors.buffs; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; -import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.CloakofShadows; +import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.CloakOfShadows; import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator; public class Invisibility extends FlavourBuff { @@ -57,8 +57,9 @@ public class Invisibility extends FlavourBuff { if (buff != null && Dungeon.hero.visibleEnemies() > 0) { buff.detach(); } - CloakofShadows.cloakStealth cloakBuff = Dungeon.hero.buff( CloakofShadows.cloakStealth.class ); + CloakOfShadows.cloakStealth cloakBuff = Dungeon.hero.buff( CloakOfShadows.cloakStealth.class ); if (cloakBuff != null && Dungeon.hero.visibleEnemies() > 0) { + cloakBuff.act(); cloakBuff.detach(); } } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/HeroClass.java b/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/HeroClass.java index 5ac3f300d..dab5ec9e4 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/HeroClass.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/HeroClass.java @@ -22,9 +22,9 @@ import com.shatteredpixel.shatteredpixeldungeon.Badges; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.items.TomeOfMastery; import com.shatteredpixel.shatteredpixeldungeon.items.armor.ClothArmor; +import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.CloakOfShadows; import com.shatteredpixel.shatteredpixeldungeon.items.food.Food; import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfStrength; -import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfShadows; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfIdentify; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfMagicMapping; import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfMagicMissile; @@ -140,7 +140,7 @@ public enum HeroClass { private static void initRogue( Hero hero ) { (hero.belongings.weapon = new Dagger()).identify(); (hero.belongings.armor = new ClothArmor()).identify(); - (hero.belongings.misc1 = new RingOfShadows()).upgrade().identify(); + hero.belongings.misc1 = new CloakOfShadows(); new Dart( 8 ).identify().collect(); new Food().identify().collect(); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/Artifact.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/Artifact.java index b876dcc07..e0ed527da 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/Artifact.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/Artifact.java @@ -6,6 +6,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.items.KindofMisc; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; +import com.watabou.utils.Bundle; import java.util.ArrayList; @@ -19,7 +20,7 @@ public class Artifact extends KindofMisc { protected Buff passiveBuff; protected Buff activeBuff; - protected int level = 0; + protected int level = 1; protected int charge = 0; protected int chargeCap; @@ -113,4 +114,19 @@ public class Artifact extends KindofMisc { public class ArtifactBuff extends Buff { } + + @Override + public void storeInBundle( Bundle bundle ) { + bundle.put( "level", level ); + bundle.put( "charge", charge ); + } + + @Override + public void restoreFromBundle( Bundle bundle ) { + level = bundle.getInt("level"); + charge = bundle.getInt("charge"); + } + + + } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/CloakofShadows.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/CloakofShadows.java index 5bbcd07c0..c43dc2ec5 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/CloakofShadows.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/CloakofShadows.java @@ -6,28 +6,40 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator; +import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; import com.shatteredpixel.shatteredpixeldungeon.utils.Utils; import com.watabou.noosa.audio.Sample; +import com.watabou.noosa.tweeners.AlphaTweener; +import com.watabou.utils.Bundle; import java.util.ArrayList; /** * Created by debenhame on 25/08/2014. */ -public class CloakofShadows extends Artifact { - //TODO: add requirements for entering stealth, add levelling mechanic, add bundle support, add polish +public class CloakOfShadows extends Artifact { + //TODO: refine requirements for entering stealth, finish bundle support, add polish + + //TODO: known bugs: first tick of stealth sometimes too quick. { name = "Cloak of Shadows"; image = ItemSpriteSheet.ARTIFACT_CLOAK; + level = 1; + charge = level+4; + chargeCap = level+4; } private boolean stealthed = false; + private int exp = 0; + public static final String AC_STEALTH = "STEALTH"; private static final String TXT_STATUS = "%d/%d"; + private int cooldown = 0; + @Override public ArrayList actions( Hero hero ) { ArrayList actions = super.actions( hero ); @@ -41,21 +53,43 @@ public class CloakofShadows extends Artifact { if (action.equals( AC_STEALTH )) { if (!stealthed){ - stealthed = true; - Sample.INSTANCE.play( Assets.SND_MELD ); - activeBuff = activeBuff(); - activeBuff.attachTo(hero); + if (cooldown <= 0) { + stealthed = true; + Sample.INSTANCE.play(Assets.SND_MELD); + activeBuff = activeBuff(); + activeBuff.attachTo(hero); + if (hero.sprite.parent != null) { + hero.sprite.parent.add(new AlphaTweener(hero.sprite, 0.4f, 0.4f)); + } else { + hero.sprite.alpha(0.4f); + } + hero.sprite.operate(hero.pos); + GLog.i("Your cloak blends you into the shadows."); + } else { + GLog.i("Your cloak needs " + cooldown + " more rounds to re-energize."); + } } else { stealthed = false; - hero.remove(activeBuff); + activeBuff.detach(); activeBuff = null; + hero.sprite.operate( hero.pos ); + GLog.i("You return from behind your cloak."); } } else { + if (stealthed) { + stealthed = false; + activeBuff.detach(); + activeBuff = null; + GLog.i("You return from behind your cloak."); + } super.execute(hero, action); - } + + + + } @Override @@ -71,12 +105,12 @@ public class CloakofShadows extends Artifact { @Override public String desc() { //TODO: add description - return "Need to add a description."; + return "Current CD = " + cooldown; } @Override public String status() { - return Utils.format(TXT_STATUS, charge, level+4); + return Utils.format(TXT_STATUS, charge, chargeCap); } @Override @@ -85,20 +119,23 @@ public class CloakofShadows extends Artifact { } public class cloakRecharge extends ArtifactBuff{ - int partialCharge = 0; + double partialCharge = 0; @Override public boolean act() { - if (charge < level+4) { + if (charge < chargeCap) { if (!stealthed) - partialCharge += (level + 4) / 300; + partialCharge += (chargeCap * 0.00334); - if (partialCharge >= 100) { + if (partialCharge >= 1) { charge++; - partialCharge -= 100; + partialCharge -= 1; } } else partialCharge = 0; + if (cooldown > 0) + cooldown --; + spend( TICK ); return true; @@ -125,8 +162,20 @@ public class CloakofShadows extends Artifact { @Override public boolean act(){ charge--; - if (charge <= 0) + if (charge <= 0) { detach(); + GLog.w("Your cloak has run out of energy."); + } else if (charge == 2) + GLog.w("Your cloak is almost out of energy."); + + exp += 10 + ((Hero)target).lvl; + + if (exp >= level*50 && level < 26) { + exp -= level*50; + GLog.p("Your Cloak Grows Stronger!"); + level++; + chargeCap++; + } spend( TICK ); @@ -142,7 +191,21 @@ public class CloakofShadows extends Artifact { public void detach() { target.invisible--; stealthed = false; + cooldown = 18 - (level / 2); super.detach(); } } + + @Override + public void storeInBundle( Bundle bundle ) { + super.storeInBundle(bundle); + //bundle.put("stealthed", stealthed); + } + + @Override + public void restoreFromBundle( Bundle bundle ) { + super.restoreFromBundle(bundle); + chargeCap = level+4; + //stealthed = bundle.getBoolean("stealthed"); + } }