From 82add3fdd2c9595261e03364e7b77cf5ab5143ba Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Sat, 2 Jun 2018 15:35:03 -0400 Subject: [PATCH] v0.7.0: implemented a new potion/scroll/plant, minus visuals retired well of transmutation, potion of might, scroll of infusion --- .../shatteredpixeldungeon/actors/Char.java | 6 +- .../actors/blobs/WaterOfTransmutation.java | 16 +- .../actors/buffs/Haste.java | 53 ++++ .../actors/buffs/Invisibility.java | 9 +- .../actors/hero/Hero.java | 18 +- .../items/Generator.java | 10 +- .../items/potions/Potion.java | 2 +- .../items/potions/PotionOfHaste.java | 44 +++ .../items/potions/PotionOfMight.java | 9 + .../items/scrolls/Scroll.java | 2 +- .../scrolls/ScrollOfMagicalInfusion.java | 11 +- .../items/scrolls/ScrollOfTeleportation.java | 2 +- .../items/scrolls/ScrollOfTransmutation.java | 254 ++++++++++++++++++ .../shatteredpixeldungeon/levels/Level.java | 7 + .../levels/rooms/secret/SecretWellRoom.java | 3 +- .../levels/rooms/special/MagicWellRoom.java | 6 +- .../levels/rooms/special/SpecialRoom.java | 18 -- .../plants/Swiftthistle.java | 125 +++++++++ .../shatteredpixeldungeon/windows/WndBag.java | 3 + .../messages/actors/actors.properties | 5 +- .../messages/items/items.properties | 10 + .../messages/plants/plants.properties | 6 + 22 files changed, 566 insertions(+), 53 deletions(-) create mode 100644 core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Haste.java create mode 100644 core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/PotionOfHaste.java create mode 100644 core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/ScrollOfTransmutation.java create mode 100644 core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Swiftthistle.java 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 d5b6873ab..20350f8a2 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/Char.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/Char.java @@ -39,6 +39,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Doom; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.EarthImbue; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.FireImbue; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Frost; +import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Haste; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Hunger; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.MagicalSleep; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Ooze; @@ -277,7 +278,10 @@ public abstract class Char extends Actor { } public float speed() { - return buff( Cripple.class ) == null ? baseSpeed : baseSpeed * 0.5f; + float speed = baseSpeed; + if ( buff( Cripple.class ) != null ) speed /= 2f; + if ( buff( Haste.class ) != null) speed *= 3f; + return speed; } public void damage( int dmg, Object src ) { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/WaterOfTransmutation.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/WaterOfTransmutation.java index 93879e720..82fe1a64e 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/WaterOfTransmutation.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/WaterOfTransmutation.java @@ -210,13 +210,9 @@ public class WaterOfTransmutation extends WellWater { } private Scroll changeScroll( Scroll s ) { - if (s instanceof ScrollOfUpgrade) { + if (s instanceof ScrollOfUpgrade || s instanceof ScrollOfMagicalInfusion) { - return new ScrollOfMagicalInfusion(); - - } else if (s instanceof ScrollOfMagicalInfusion) { - - return new ScrollOfUpgrade(); + return null; } else { @@ -229,13 +225,9 @@ public class WaterOfTransmutation extends WellWater { } private Potion changePotion( Potion p ) { - if (p instanceof PotionOfStrength) { + if (p instanceof PotionOfStrength || p instanceof PotionOfMight) { - return new PotionOfMight(); - - } else if (p instanceof PotionOfMight) { - - return new PotionOfStrength(); + return null; } else { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Haste.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Haste.java new file mode 100644 index 000000000..169bfcb11 --- /dev/null +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Haste.java @@ -0,0 +1,53 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * Shattered Pixel Dungeon + * Copyright (C) 2014-2018 Evan Debenham + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see + */ + +package com.shatteredpixel.shatteredpixeldungeon.actors.buffs; + +import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; +import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator; +import com.watabou.noosa.Image; + +public class Haste extends FlavourBuff { + + public static final float DURATION = 20f; + + @Override + public int icon() { + //TODO + return BuffIndicator.IMMUNITY; + } + + @Override + public void tintIcon(Image icon) { + greyIcon(icon, 5f, cooldown()); + } + + @Override + public String toString() { + return Messages.get(this, "name"); + } + + @Override + public String desc() { + return Messages.get(this, "desc", dispTurns()); + } + +} diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Invisibility.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Invisibility.java index 8d04274d8..79ad83b48 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Invisibility.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Invisibility.java @@ -28,6 +28,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroSubClass; import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.CloakOfShadows; import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.TimekeepersHourglass; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; +import com.shatteredpixel.shatteredpixeldungeon.plants.Swiftthistle; import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite; import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator; import com.watabou.noosa.Image; @@ -95,10 +96,16 @@ public class Invisibility extends FlavourBuff { if (cloakBuff != null) { cloakBuff.dispel(); } - //this isn't a form of invisibilty, but it is meant to dispel at the same time as it. + + //these aren't forms of invisibilty, but do dispel at the same time as it. TimekeepersHourglass.timeFreeze timeFreeze = Dungeon.hero.buff( TimekeepersHourglass.timeFreeze.class ); if (timeFreeze != null) { timeFreeze.detach(); } + + Swiftthistle.TimeBubble bubble = Dungeon.hero.buff( Swiftthistle.TimeBubble.class ); + if (bubble != null){ + bubble.detach(); + } } } 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 0bdd4113a..f53e51f55 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 @@ -95,6 +95,7 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; import com.shatteredpixel.shatteredpixeldungeon.levels.features.Chasm; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.plants.Earthroot; +import com.shatteredpixel.shatteredpixeldungeon.plants.Swiftthistle; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.scenes.InterlevelScene; import com.shatteredpixel.shatteredpixeldungeon.scenes.SurfaceScene; @@ -442,12 +443,19 @@ public class Hero extends Char { @Override public void spend( float time ) { justMoved = false; - TimekeepersHourglass.timeFreeze buff = buff(TimekeepersHourglass.timeFreeze.class); - if (buff != null){ - buff.processTime(time); - } else { - super.spend(time); + TimekeepersHourglass.timeFreeze freeze = buff(TimekeepersHourglass.timeFreeze.class); + if (freeze != null) { + freeze.processTime(time); + return; } + + Swiftthistle.TimeBubble bubble = buff(Swiftthistle.TimeBubble.class); + if (bubble != null){ + bubble.processTime(time); + return; + } + + super.spend(time); } public void spendAndNext( float time ) { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Generator.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Generator.java index 397b22395..a60a3ebdf 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Generator.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Generator.java @@ -50,6 +50,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.food.Pasty; import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion; import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfExperience; import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfFrost; +import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfHaste; import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfHealing; import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfInvisibility; import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfLevitation; @@ -82,6 +83,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfRecharging import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfRemoveCurse; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTeleportation; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTerror; +import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTransmutation; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfUpgrade; import com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand; import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfBlastWave; @@ -227,9 +229,9 @@ public class Generator { ScrollOfRage.class, ScrollOfTeleportation.class, ScrollOfTerror.class, - /*ScrollOfTransmutation.class*/ //1 additional scroll guaranteed on floors 6-19 + ScrollOfTransmutation.class //1 additional scroll guaranteed on floors 6-19 }; - SCROLL.probs = new float[]{ 0, 6, 4, 3, 3, 3, 2, 2, 2, 2, 2/*, 1*/ }; + SCROLL.probs = new float[]{ 0, 6, 4, 3, 3, 3, 2, 2, 2, 2, 2, 1 }; POTION.classes = new Class[]{ PotionOfStrength.class, //2 drop every chapter, see Dungeon.posNeeded() @@ -238,13 +240,13 @@ public class Generator { PotionOfFrost.class, PotionOfLiquidFlame.class, PotionOfToxicGas.class, - /* PotionOfHaste.class */ + PotionOfHaste.class, PotionOfInvisibility.class, PotionOfLevitation.class, PotionOfParalyticGas.class, PotionOfPurity.class, PotionOfExperience.class}; - POTION.probs = new float[]{ 0, 6, 4, 3, 3, 3, /*2,*/ 2, 2, 2, 2, 1 }; + POTION.probs = new float[]{ 0, 6, 4, 3, 3, 3, 2, 2, 2, 2, 2, 1 }; //TODO: add last ones when implemented WAND.classes = new Class[]{ diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/Potion.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/Potion.java index 9e8fbabd7..cc67acc02 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/Potion.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/Potion.java @@ -87,7 +87,7 @@ public class Potion extends Item { PotionOfMindVision.class, PotionOfPurity.class, PotionOfInvisibility.class, - PotionOfMight.class, + PotionOfHaste.class, PotionOfFrost.class }; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/PotionOfHaste.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/PotionOfHaste.java new file mode 100644 index 000000000..7d9d2df20 --- /dev/null +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/PotionOfHaste.java @@ -0,0 +1,44 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * Shattered Pixel Dungeon + * Copyright (C) 2014-2018 Evan Debenham + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see + */ + +package com.shatteredpixel.shatteredpixeldungeon.items.potions; + +import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; +import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Haste; +import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; +import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; +import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; + +public class PotionOfHaste extends Potion { + + { + //TODO + initials = -1; + } + + @Override + public void apply(Hero hero) { + setKnown(); + + GLog.w( Messages.get(this, "energetic") ); + Buff.prolong( hero, Haste.class, Haste.DURATION); + } +} diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/PotionOfMight.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/PotionOfMight.java index cf3c4e4e5..357c22af9 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/PotionOfMight.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/PotionOfMight.java @@ -25,12 +25,16 @@ import com.shatteredpixel.shatteredpixeldungeon.Badges; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite; +import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; public class PotionOfMight extends Potion { + + //TODO finish transitioning this item { initials = 6; + image = ItemSpriteSheet.POTION_AMBER; } @Override @@ -46,6 +50,11 @@ public class PotionOfMight extends Potion { Badges.validateStrengthAttained(); } + @Override + public boolean isKnown() { + return true; + } + @Override public int price() { return isKnown() ? 100 * quantity : super.price(); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/Scroll.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/Scroll.java index 55c420949..536bb135a 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/Scroll.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/Scroll.java @@ -60,7 +60,7 @@ public abstract class Scroll extends Item { ScrollOfRage.class, ScrollOfTerror.class, ScrollOfLullaby.class, - ScrollOfMagicalInfusion.class, + ScrollOfTransmutation.class, ScrollOfPsionicBlast.class, ScrollOfMirrorImage.class }; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/ScrollOfMagicalInfusion.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/ScrollOfMagicalInfusion.java index af9c14e44..c36098e0c 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/ScrollOfMagicalInfusion.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/ScrollOfMagicalInfusion.java @@ -28,14 +28,18 @@ import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; +import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag; public class ScrollOfMagicalInfusion extends InventoryScroll { + //TODO decide what to do with this one + { initials = 2; mode = WndBag.Mode.ENCHANTABLE; + image = ItemSpriteSheet.SCROLL_ISAZ; } @Override @@ -58,7 +62,12 @@ public class ScrollOfMagicalInfusion extends InventoryScroll { public void empoweredRead() { //does nothing for now, this should never happen. } - + + @Override + public boolean isKnown() { + return true; + } + @Override public int price() { return isKnown() ? 100 * quantity : super.price(); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/ScrollOfTeleportation.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/ScrollOfTeleportation.java index 4b26e81b3..f0c3ce66a 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/ScrollOfTeleportation.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/ScrollOfTeleportation.java @@ -95,7 +95,7 @@ public class ScrollOfTeleportation extends Scroll { Dungeon.observe(); GameScene.updateFog(); - GLog.i( Messages.get(ScrollOfTeleportation.class, "tele") ); + //GLog.i( Messages.get(ScrollOfTeleportation.class, "tele") ); } public static void teleportHero(Hero hero ) { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/ScrollOfTransmutation.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/ScrollOfTransmutation.java new file mode 100644 index 000000000..7a5816bc4 --- /dev/null +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/ScrollOfTransmutation.java @@ -0,0 +1,254 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * Shattered Pixel Dungeon + * Copyright (C) 2014-2018 Evan Debenham + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see + */ + +package com.shatteredpixel.shatteredpixeldungeon.items.scrolls; + +import com.shatteredpixel.shatteredpixeldungeon.Challenges; +import com.shatteredpixel.shatteredpixeldungeon.Dungeon; +import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; +import com.shatteredpixel.shatteredpixeldungeon.items.EquipableItem; +import com.shatteredpixel.shatteredpixeldungeon.items.Generator; +import com.shatteredpixel.shatteredpixeldungeon.items.Item; +import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.Artifact; +import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion; +import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfMight; +import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfStrength; +import com.shatteredpixel.shatteredpixeldungeon.items.rings.Ring; +import com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand; +import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon; +import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MagesStaff; +import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MeleeWeapon; +import com.shatteredpixel.shatteredpixeldungeon.journal.Catalog; +import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; +import com.shatteredpixel.shatteredpixeldungeon.plants.Plant; +import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; +import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag; +import com.watabou.utils.Random; + +public class ScrollOfTransmutation extends InventoryScroll { + + { + //TODO + initials = -1; + mode = WndBag.Mode.TRANMSUTABLE; + } + + public static boolean canTransmute(Item item){ + return item instanceof MagesStaff || item instanceof MeleeWeapon || item instanceof Potion + || item instanceof Scroll || item instanceof Ring || item instanceof Wand + || item instanceof Plant.Seed || item instanceof Artifact; + } + + @Override + protected void onItemSelected(Item item) { + + Item result; + + if (item instanceof MagesStaff) { + result = changeStaff( (MagesStaff)item ); + } else if (item instanceof MeleeWeapon) { + result = changeWeapon( (MeleeWeapon)item ); + } else if (item instanceof Scroll) { + result = changeScroll( (Scroll)item ); + } else if (item instanceof Potion) { + result = changePotion( (Potion)item ); + } else if (item instanceof Ring) { + result = changeRing( (Ring)item ); + } else if (item instanceof Wand) { + result = changeWand( (Wand)item ); + } else if (item instanceof Plant.Seed) { + result = changeSeed( (Plant.Seed)item ); + } else if (item instanceof Artifact) { + result = changeArtifact( (Artifact)item ); + } else { + result = null; + } + + if (result == null){ + //This shouldn't ever trigger + GLog.n( Messages.get(this, "nothing") ); + curItem.collect( curUser.belongings.backpack ); + } else { + if (item.isEquipped(Dungeon.hero)){ + ((EquipableItem)item).doUnequip(Dungeon.hero, false); + ((EquipableItem)result).doEquip(Dungeon.hero); + } else { + item.detach(Dungeon.hero.belongings.backpack); + result.collect(); + } + if (result.isIdentified()){ + Catalog.setSeen(result.getClass()); + } + //TODO visuals + GLog.p( Messages.get(this, "morph") ); + } + + } + + private MagesStaff changeStaff( MagesStaff staff ){ + Class wandClass = staff.wandClass(); + + if (wandClass == null){ + return null; + } else { + Wand n; + do { + n = (Wand) Generator.random(Generator.Category.WAND); + } while (Challenges.isItemBlocked(n) || n.getClass() == wandClass); + n.level(0); + staff.imbueWand(n, null); + } + + return staff; + } + + private Weapon changeWeapon(MeleeWeapon w ) { + + Weapon n; + Generator.Category c = Generator.wepTiers[w.tier-1]; + + do { + try { + n = (MeleeWeapon)c.classes[Random.chances(c.probs)].newInstance(); + } catch (Exception e) { + ShatteredPixelDungeon.reportException(e); + return null; + } + } while (Challenges.isItemBlocked(n) || n.getClass() == w.getClass()); + + int level = w.level(); + if (level > 0) { + n.upgrade( level ); + } else if (level < 0) { + n.degrade( -level ); + } + + n.enchantment = w.enchantment; + n.levelKnown = w.levelKnown; + n.cursedKnown = w.cursedKnown; + n.cursed = w.cursed; + n.augment = w.augment; + + return n; + + } + + private Ring changeRing( Ring r ) { + Ring n; + do { + n = (Ring)Generator.random( Generator.Category.RING ); + } while (Challenges.isItemBlocked(n) || n.getClass() == r.getClass()); + + n.level(0); + + int level = r.level(); + if (level > 0) { + n.upgrade( level ); + } else if (level < 0) { + n.degrade( -level ); + } + + n.levelKnown = r.levelKnown; + n.cursedKnown = r.cursedKnown; + n.cursed = r.cursed; + + return n; + } + + private Artifact changeArtifact( Artifact a ) { + Artifact n = Generator.randomArtifact(); + + if (n != null && !Challenges.isItemBlocked(n)){ + n.cursedKnown = a.cursedKnown; + n.cursed = a.cursed; + n.levelKnown = a.levelKnown; + n.transferUpgrade(a.visiblyUpgraded()); + return n; + } + + return null; + } + + private Wand changeWand( Wand w ) { + + Wand n; + do { + n = (Wand)Generator.random( Generator.Category.WAND ); + } while ( Challenges.isItemBlocked(n) || n.getClass() == w.getClass()); + + n.level( 0 ); + n.upgrade( w.level() ); + + n.levelKnown = w.levelKnown; + n.cursedKnown = w.cursedKnown; + n.cursed = w.cursed; + + return n; + } + + private Plant.Seed changeSeed( Plant.Seed s ) { + + Plant.Seed n; + + do { + n = (Plant.Seed)Generator.random( Generator.Category.SEED ); + } while (n.getClass() == s.getClass()); + + return n; + } + + private Scroll changeScroll( Scroll s ) { + if (s instanceof ScrollOfUpgrade || s instanceof ScrollOfMagicalInfusion) { + + return null; + + } else { + + Scroll n; + do { + n = (Scroll)Generator.random( Generator.Category.SCROLL ); + } while (n.getClass() == s.getClass()); + return n; + } + } + + private Potion changePotion( Potion p ) { + if (p instanceof PotionOfStrength || p instanceof PotionOfMight) { + + return null; + + } else { + + Potion n; + do { + n = (Potion)Generator.random( Generator.Category.POTION ); + } while (n.getClass() == p.getClass()); + return n; + } + } + + @Override + public void empoweredRead() { + //does nothing, this shouldn't happen + } + + +} diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java index 062c52626..c1ce46553 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java @@ -50,6 +50,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.DriedRose; import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.TimekeepersHourglass; import com.shatteredpixel.shatteredpixeldungeon.items.food.SmallRation; import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfStrength; +import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTransmutation; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfUpgrade; import com.shatteredpixel.shatteredpixeldungeon.levels.features.Chasm; import com.shatteredpixel.shatteredpixeldungeon.levels.features.Door; @@ -185,6 +186,12 @@ public abstract class Level implements Bundlable { addItemToSpawn( new Stylus() ); Dungeon.LimitedDrops.ARCANE_STYLI.count++; } + //one scroll of transmutation is guaranteed to spawn somewhere on chapter 2-4 + int transChapter = (int)((Dungeon.seed / 10) % 3) + 1; + if ( Dungeon.depth / 5 == transChapter && + Dungeon.seed % 4 + 1 == Dungeon.depth % 5){ + addItemToSpawn( new ScrollOfTransmutation() ); + } DriedRose rose = Dungeon.hero.belongings.getItem( DriedRose.class ); if (rose != null && rose.isIdentified() && !rose.cursed){ diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/secret/SecretWellRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/secret/SecretWellRoom.java index 8a7cf6992..658b76c2a 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/secret/SecretWellRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/secret/SecretWellRoom.java @@ -23,7 +23,6 @@ package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.secret; import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.WaterOfAwareness; import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.WaterOfHealth; -import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.WaterOfTransmutation; import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.WellWater; import com.shatteredpixel.shatteredpixeldungeon.levels.Level; import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; @@ -34,7 +33,7 @@ import com.watabou.utils.Random; public class SecretWellRoom extends SecretRoom { private static final Class[] WATERS = - {WaterOfAwareness.class, WaterOfHealth.class, WaterOfTransmutation.class}; + {WaterOfAwareness.class, WaterOfHealth.class}; @Override public boolean canConnect(Point p) { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/MagicWellRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/MagicWellRoom.java index 686f14e06..431d9e1cf 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/MagicWellRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/MagicWellRoom.java @@ -23,7 +23,6 @@ package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special; import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.WaterOfAwareness; import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.WaterOfHealth; -import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.WaterOfTransmutation; import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.WellWater; import com.shatteredpixel.shatteredpixeldungeon.levels.Level; import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; @@ -34,7 +33,7 @@ import com.watabou.utils.Random; public class MagicWellRoom extends SpecialRoom { private static final Class[] WATERS = - {WaterOfAwareness.class, WaterOfHealth.class, WaterOfTransmutation.class}; + {WaterOfAwareness.class, WaterOfHealth.class}; public Class overrideWater = null; @@ -52,9 +51,6 @@ public class MagicWellRoom extends SpecialRoom { overrideWater : (Class)Random.element( WATERS ); - if (waterClass == WaterOfTransmutation.class) { - SpecialRoom.disableGuaranteedWell(); - } WellWater.seed(c.x + level.width() * c.y, 1, waterClass, level); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/SpecialRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/SpecialRoom.java index ed8102584..a571af730 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/SpecialRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/SpecialRoom.java @@ -23,7 +23,6 @@ package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; -import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.WaterOfTransmutation; import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room; import com.watabou.utils.Bundle; import com.watabou.utils.Random; @@ -67,13 +66,11 @@ public class SpecialRoom extends Room { public static ArrayList> floorSpecials = new ArrayList<>(); private static int pitNeededDepth = -1; - private static int guaranteedWellDepth = Integer.MAX_VALUE; public static void initForRun() { runSpecials = (ArrayList>)ALL_SPEC.clone(); pitNeededDepth = -1; - guaranteedWellDepth = Random.IntRange( 6, 14 ); Random.shuffle(runSpecials); } @@ -97,10 +94,6 @@ public class SpecialRoom extends Room { if (pitNeededDepth == depth) pitNeededDepth = -1; } - public static void disableGuaranteedWell(){ - guaranteedWellDepth = Integer.MAX_VALUE; - } - public static SpecialRoom createRoom(){ if (Dungeon.depth == pitNeededDepth){ pitNeededDepth = -1; @@ -115,14 +108,6 @@ public class SpecialRoom extends Room { return new PitRoom(); - } else if (Dungeon.depth >= guaranteedWellDepth) { - useType( MagicWellRoom.class ); - - MagicWellRoom r = new MagicWellRoom(); - r.overrideWater = WaterOfTransmutation.class; - guaranteedWellDepth = Integer.MAX_VALUE; - return r; - } else if (floorSpecials.contains(LaboratoryRoom.class)) { useType(LaboratoryRoom.class); @@ -158,7 +143,6 @@ public class SpecialRoom extends Room { private static final String ROOMS = "special_rooms"; private static final String PIT = "pit_needed"; - private static final String WELL = "guaranteed_well"; public static void restoreRoomsFromBundle( Bundle bundle ) { runSpecials.clear(); @@ -171,12 +155,10 @@ public class SpecialRoom extends Room { ShatteredPixelDungeon.reportException(new Exception("specials array didn't exist!")); } pitNeededDepth = bundle.getInt(PIT); - guaranteedWellDepth = bundle.getInt(WELL); } public static void storeRoomsInBundle( Bundle bundle ) { bundle.put( ROOMS, runSpecials.toArray(new Class[0]) ); bundle.put( PIT, pitNeededDepth ); - bundle.put( WELL, guaranteedWellDepth ); } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Swiftthistle.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Swiftthistle.java new file mode 100644 index 000000000..5bc21527d --- /dev/null +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Swiftthistle.java @@ -0,0 +1,125 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * Shattered Pixel Dungeon + * Copyright (C) 2014-2018 Evan Debenham + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see + */ + +package com.shatteredpixel.shatteredpixeldungeon.plants; + +import com.shatteredpixel.shatteredpixeldungeon.Dungeon; +import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; +import com.shatteredpixel.shatteredpixeldungeon.actors.Char; +import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; +import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.FlavourBuff; +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.utils.Bundle; + +public class Swiftthistle extends Plant { + + { + //TODO + image = 1; + } + + @Override + public void activate() { + Char ch = Actor.findChar(pos); + if (ch == Dungeon.hero) { + Buff.affect(ch, TimeBubble.class); + } + } + + public static class Seed extends Plant.Seed { + { + //TODO + image = ItemSpriteSheet.SEED_FADELEAF; + + plantClass = Swiftthistle.class; + } + } + + public static class TimeBubble extends Buff { + + private float left = 6f; + private int pos; + + @Override + public int icon() { + //TODO + return BuffIndicator.IMMUNITY; + } + + @Override + public void tintIcon(Image icon) { + FlavourBuff.greyIcon(icon, 4f, left); + } + + @Override + public boolean attachTo(Char target) { + if (super.attachTo(target)){ + pos = target.pos; + return true; + } else { + return false; + } + } + + public void processTime( float time ){ + if (target.pos != pos){ + left = 0f; + } + + left -= time; + BuffIndicator.refreshHero(); + + if (left <= 0){ + detach(); + } + } + + @Override + public String toString() { + return Messages.get(this, "name"); + } + + @Override + public String desc() { + return Messages.get(this, "desc", dispTurns(left)); + } + + private static final String POS = "pos"; + private static final String LEFT = "left"; + + @Override + public void storeInBundle(Bundle bundle) { + super.storeInBundle(bundle); + bundle.put( POS, pos ); + bundle.put( LEFT, left ); + } + + @Override + public void restoreFromBundle(Bundle bundle) { + super.restoreFromBundle(bundle); + pos = bundle.getInt( POS ); + left = bundle.getInt( LEFT ); + } + } +} diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndBag.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndBag.java index 692a6cd5b3..ff9480061 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndBag.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndBag.java @@ -38,6 +38,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.bags.VelvetPouch; import com.shatteredpixel.shatteredpixeldungeon.items.food.Food; import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll; +import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTransmutation; import com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MeleeWeapon; @@ -79,6 +80,7 @@ public class WndBag extends WndTabbed { SCROLL, UNIDED_POTION_OR_SCROLL, EQUIPMENT, + TRANMSUTABLE, ALCHEMY } @@ -397,6 +399,7 @@ public class WndBag extends WndTabbed { mode == Mode.UNIDED_POTION_OR_SCROLL && (!item.isIdentified() && (item instanceof Scroll || item instanceof Potion)) || mode == Mode.EQUIPMENT && (item instanceof EquipableItem) || mode == Mode.ALCHEMY && (!(item instanceof EquipableItem) && item.isIdentified()) || + mode == Mode.TRANMSUTABLE && ScrollOfTransmutation.canTransmute(item) || mode == Mode.ALL ); //extra logic for cursed weapons or armor diff --git a/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/actors/actors.properties b/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/actors/actors.properties index 92339defb..86224bc8b 100644 --- a/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/actors/actors.properties +++ b/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/actors/actors.properties @@ -78,7 +78,7 @@ actors.buffs.charm.desc=A charm is manipulative magic that can make enemies temp actors.buffs.chill.name=Chilled actors.buffs.chill.freezes=%s freezes! -actors.buffs.chill.desc=Not quite frozen, but still much too cold.\n\nChilled targets perform all actions more slowly, depending on how many turns are left in the effect. At it's worst, this is equivalent to being slowed.\n\nTurns of chill remaining: %1$s.\nSpeed is reduced by: %2$s%% +actors.buffs.chill.desc=Not quite frozen, but still much too cold.\n\nChilled targets perform all actions more slowly, depending on how many turns are left in the effect. At its worst, this is equivalent to being slowed.\n\nTurns of chill remaining: %1$s.\nSpeed is reduced by: %2$s%% actors.buffs.combo.name=Combo actors.buffs.combo.combo=%d hit combo! @@ -125,6 +125,9 @@ actors.buffs.fury.desc=You are angry, enemies won't like you when you're angry.\ actors.buffs.blobimmunity.name=Purification Barrier actors.buffs.blobimmunity.desc=Some strange force is encasing you in a thin protective barrier, blocking out all harmful airborne effects.\n\nYou are immune to all area-bound effects while this barrier lasts.\n\nTurns of immunity remaining: %s. +actors.buffs.haste.name=Haste +actors.buffs.haste.desc=Energy courses through your muscles, allowing you to run at incredible speeds!\n\nWhile under the effects of haste you will run at 3x speed, but will perform all other actions at normal speed.\n\nTurns of haste remaining: %s. + actors.buffs.healing.value=%+dHP actors.buffs.hunger.hungry=Hungry diff --git a/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties b/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties index 1578b8add..e9c8052eb 100644 --- a/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties +++ b/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties @@ -456,6 +456,10 @@ items.potions.potionofexperience.desc=The storied experiences of multitudes of b items.potions.potionoffrost.name=potion of frost items.potions.potionoffrost.desc=The chemical contained in this potion will evaporate into a freezing cloud upon exposure to open air. +items.potions.potionofhaste.name=potion of haste +items.potions.potionofhaste.energetic=you feel energetic! +items.potions.potionofhaste.desc=Drinking this oddly sweet liquid will imbue you with tremendous energy for a short time, allowing you to run at high speeds. + items.potions.potionofhealing.name=potion of healing items.potions.potionofhealing.heal=Your wounds begin to close. items.potions.potionofhealing.desc=This elixir will rapidly restore your health and instantly cure many ailments. @@ -657,6 +661,12 @@ items.scrolls.scrollofterror.one=The scroll emits a brilliant flash of red light items.scrolls.scrollofterror.many=The scroll emits a brilliant flash of red light and the monsters flee! items.scrolls.scrollofterror.desc=A flash of red light will overwhelm all creatures in your field of view with terror, and they will turn and flee. Attacking a fleeing enemy will dispel the effect. +items.scrolls.scrolloftransmutation.name=scroll of transmutation +items.scrolls.scrolloftransmutation.inv_title=Transmute an item +items.scrolls.scrolloftransmutation.nothing=Nothing interesting happens. +items.scrolls.scrolloftransmutation.morph=Your item morphs into something different! +items.scrolls.scrolloftransmutation.desc=This scroll contains powerful transmutation magic. When used on an eligible item it will transform it into a different item of the same type. The magic will even preserve upgrades, enchantments, and glyphs. + items.scrolls.scrollofupgrade.name=scroll of upgrade items.scrolls.scrollofupgrade.inv_title=Upgrade an item items.scrolls.scrollofupgrade.weaken_curse=The scroll of upgrade weakens the curse on your item. diff --git a/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/plants/plants.properties b/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/plants/plants.properties index e4c1cd041..0263413e3 100644 --- a/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/plants/plants.properties +++ b/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/plants/plants.properties @@ -54,3 +54,9 @@ plants.sungrass.desc=Sungrass is renowned for its sap's slow but effective heali plants.sungrass$seed.name=seed of sungrass plants.sungrass$health.name=Herbal Healing plants.sungrass$health.desc=Sungrass possesses excellent healing properties, though it is much slower than a potion of healing.\n\nYou are currently slowly regenerating health from the sungrass plant. Moving off the plant will break the healing effect.\n\nHealing remaining: %d. + +plants.swiftthistle.name=Swiftthistle +plants.swiftthistle.desc=When trampled, swiftthistle will briefly accelerate the flow of time around it, allowing the trampler to perform several actions instantly. +plants.swiftthistle$seed.name=seed of swiftthistle +plants.swiftthistle$timebubble.name=Time Bubble +plants.swiftthistle$timebubble.desc=You are in a small bubble of accelerated time, allowing you to perform actions instantly. Attacking, moving, or using magic will break this effect however.\n\nTurns remaining: %s.