From fdfae8e2150f3979c466bea7355570551f247c8a Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Tue, 26 Aug 2014 09:58:14 -0400 Subject: [PATCH] V0.2.0: added safety checks for invisibility (fixes bug with new item). --- .../actors/buffs/Invisibility.java | 3 ++- .../items/artifacts/CloakOfShadows.java | 11 ++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Invisibility.java b/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Invisibility.java index a18d3fdd3..86b95e842 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Invisibility.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Invisibility.java @@ -38,7 +38,8 @@ public class Invisibility extends FlavourBuff { @Override public void detach() { - target.invisible--; + if (target.invisible > 0) + target.invisible--; super.detach(); } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/CloakOfShadows.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/CloakOfShadows.java index c43dc2ec5..366583eca 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/CloakOfShadows.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/CloakOfShadows.java @@ -129,6 +129,10 @@ public class CloakOfShadows extends Artifact { if (partialCharge >= 1) { charge++; partialCharge -= 1; + if (charge == chargeCap){ + GLog.p("Your cloak is fully charged."); + partialCharge = 0; + } } } else partialCharge = 0; @@ -153,6 +157,7 @@ public class CloakOfShadows extends Artifact { public boolean attachTo( Char target ) { if (super.attachTo( target )) { target.invisible++; + spend(TICK); return true; } else { return false; @@ -165,8 +170,7 @@ public class CloakOfShadows extends Artifact { 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; @@ -189,7 +193,8 @@ public class CloakOfShadows extends Artifact { @Override public void detach() { - target.invisible--; + if (target.invisible > 0) + target.invisible--; stealthed = false; cooldown = 18 - (level / 2); super.detach();