diff --git a/core/src/main/assets/messages/items/items.properties b/core/src/main/assets/messages/items/items.properties index c4aca1090..c1cc683ba 100644 --- a/core/src/main/assets/messages/items/items.properties +++ b/core/src/main/assets/messages/items/items.properties @@ -720,7 +720,9 @@ items.potions.exotic.potionofadrenalinesurge.name=potion of adrenaline surge items.potions.exotic.potionofadrenalinesurge.desc=This powerful liquid will give you a greater boost of strength that withers after an extended period of time. items.potions.exotic.potionofcleansing.name=potion of cleansing -items.potions.exotic.potionofcleansing.desc=This powerful reagent will completely neutralize all harmful effects on the drinker when quaffed. It can be thrown at a target to cleanse them as well. +items.potions.exotic.potionofcleansing.desc=This powerful reagent will render the drinker immune to all harmful effects for a few turns when quaffed. It can be thrown at a target to cleanse them as well. +items.potions.exotic.potionofcleansing$cleanse.name=Cleansed +items.potions.exotic.potionofcleansing$cleanse.desc=A potion of cleansing is granting this character temporary immunity from all harmful effects!\n\nTurns remaining: %s. items.potions.exotic.potionofcorrosivegas.name=potion of corrosive gas items.potions.exotic.potionofcorrosivegas.desc=Uncorking or shattering this pressurized glass will cause its contents to explode into a deadly cloud of corrosive rust-colored gas. The gas spreads more quickly than toxic gas and is more deadly, but also won't last as long. diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/Char.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/Char.java index 240f3173a..bb28de603 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/Char.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/Char.java @@ -50,6 +50,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Haste; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Hex; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Hunger; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.LifeLink; +import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.LostInventory; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.MagicalSleep; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Momentum; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Ooze; @@ -74,6 +75,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Elemental; import com.shatteredpixel.shatteredpixeldungeon.items.Heap; import com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.AntiMagic; import com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.Potential; +import com.shatteredpixel.shatteredpixeldungeon.items.potions.exotic.PotionOfCleansing; import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfElements; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfRetribution; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTeleportation; @@ -730,7 +732,15 @@ public abstract class Char extends Actor { } public synchronized void add( Buff buff ) { - + + if (buff(PotionOfCleansing.Cleanse.class) != null) { //cleansing buff + if (buff.type == Buff.buffType.NEGATIVE + && !(buff instanceof AllyBuff) + && !(buff instanceof LostInventory)){ + return; + } + } + buffs.add( buff ); if (Actor.chars().contains(this)) Actor.add( buff ); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java index 624380403..670d99303 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java @@ -1571,7 +1571,7 @@ public class Hero extends Char { super.add( buff ); - if (sprite != null) { + if (sprite != null && buffs().contains(buff)) { String msg = buff.heroMessage(); if (msg != null){ GLog.w(msg); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/exotic/PotionOfCleansing.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/exotic/PotionOfCleansing.java index cf54b003d..75b15662e 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/exotic/PotionOfCleansing.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/exotic/PotionOfCleansing.java @@ -27,10 +27,14 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.AllyBuff; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; +import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.FlavourBuff; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Hunger; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.LostInventory; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; +import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; +import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator; +import com.watabou.noosa.Image; import com.watabou.noosa.audio.Sample; public class PotionOfCleansing extends ExoticPotion { @@ -74,5 +78,37 @@ public class PotionOfCleansing extends ExoticPotion { ((Hunger) b).satisfy(Hunger.STARVING); } } + Buff.affect(ch, Cleanse.class, Cleanse.DURATION); + } + + public static class Cleanse extends FlavourBuff { + + public static final float DURATION = 5f; + + @Override + public int icon() { + return BuffIndicator.IMMUNITY; + } + + @Override + public void tintIcon(Image icon) { + icon.hardlight(1f, 0f, 2f); + } + + @Override + public float iconFadePercent() { + return Math.max(0, (DURATION - visualcooldown()) / DURATION); + } + + @Override + public String toString() { + return Messages.get(this, "name"); + } + + @Override + public String desc() { + return Messages.get(this, "desc", dispTurns(visualcooldown())); + } + } }