From 0ba2ca4302bc2160262b7027d2e6d0a9e9a48c20 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Wed, 19 Nov 2014 01:36:36 -0500 Subject: [PATCH] v0.2.3: artifacts can now be cursed (couple rough edges to smooth out) --- .../actors/buffs/Regeneration.java | 7 +- .../actors/hero/Hero.java | 6 +- .../actors/hero/HeroClass.java | 10 +++ .../items/Generator.java | 2 + .../items/artifacts/Artifact.java | 73 +++++++++++++------ .../items/artifacts/ChaliceOfBlood.java | 10 +-- .../items/artifacts/HornOfPlenty.java | 15 ++-- .../items/artifacts/SandalsOfNature.java | 17 +++-- .../items/artifacts/TalismanOfForesight.java | 22 +++--- .../items/food/Food.java | 20 ++++- .../levels/features/HighGrass.java | 25 ++++--- .../shatteredpixeldungeon/ui/ItemSlot.java | 2 +- 12 files changed, 143 insertions(+), 66 deletions(-) diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Regeneration.java b/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Regeneration.java index 9a1dc3bb6..a03a03e0e 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Regeneration.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Regeneration.java @@ -28,12 +28,13 @@ public class Regeneration extends Buff { @Override public boolean act() { if (target.isAlive()) { - - if (target.HP < target.HT && !((Hero)target).isStarving()) { + + ChaliceOfBlood.chaliceRegen regenBuff = Dungeon.hero.buff( ChaliceOfBlood.chaliceRegen.class); + + if (target.HP < target.HT && !((Hero)target).isStarving() && !(regenBuff != null && regenBuff.isCursed())) { target.HP += 1; } - ChaliceOfBlood.chaliceRegen regenBuff = Dungeon.hero.buff( ChaliceOfBlood.chaliceRegen.class); if (regenBuff != null) spend( Math.max(REGENERATION_DELAY - regenBuff.level(), 0.5f) ); else diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java b/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java index a930e5d36..a3b05c5a0 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java @@ -591,7 +591,9 @@ public class Hero extends Char { if (item instanceof Dewdrop) { } else { - + + //TODO: this is triggering very rigidly, consider some sort of refactor + //specifically, right now is causing wrong output with a cursed horn of plenty. if ((item instanceof ScrollOfUpgrade && ((ScrollOfUpgrade)item).isKnown()) || (item instanceof PotionOfStrength && ((PotionOfStrength)item).isKnown())) { GLog.p( TXT_YOU_NOW_HAVE, item.name() ); @@ -1368,7 +1370,7 @@ public class Hero extends Char { for (int y = ay; y <= by; y++) { for (int x = ax, p = ax + y * Level.WIDTH; x <= bx; x++, p++) { - if (Dungeon.visible[p]) { + if (Dungeon.visible[p] && !(foresight != null && foresight.isCursed())) { if (intentional) { sprite.parent.addToBack( new CheckedCell( p ) ); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/HeroClass.java b/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/HeroClass.java index 590908103..4c512648b 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/HeroClass.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/HeroClass.java @@ -24,8 +24,10 @@ 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.artifacts.HornOfPlenty; import com.shatteredpixel.shatteredpixeldungeon.items.food.Food; import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfStrength; +import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfMight; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfIdentify; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfMagicMapping; import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfMagicMissile; @@ -116,6 +118,14 @@ public enum HeroClass { if (!Dungeon.isChallenged(Challenges.NO_FOOD)) new Food().identify().collect(); + + new ScrollOfIdentify().collect(); + + HornOfPlenty horn = new HornOfPlenty(); + horn.cursed = true; + horn.collect(); + + new RingOfMight().collect(); } public Badges.Badge masteryBadge() { diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/Generator.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/Generator.java index 5f7f56197..1878cbf14 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/Generator.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/Generator.java @@ -316,6 +316,8 @@ public class Generator { cat.probs[i] = 0; spawnedArtifacts.add(cat.classes[i].getSimpleName()); + artifact.random(); + return artifact; } catch (Exception e) { diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/Artifact.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/Artifact.java index bd38b431d..0e029b996 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/Artifact.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/Artifact.java @@ -1,12 +1,15 @@ package com.shatteredpixel.shatteredpixeldungeon.items.artifacts; +import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; +import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.KindofMisc; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; import com.shatteredpixel.shatteredpixeldungeon.utils.Utils; import com.watabou.utils.Bundle; +import com.watabou.utils.Random; import java.util.ArrayList; @@ -14,10 +17,6 @@ import java.util.ArrayList; * Created by Evan on 24/08/2014. */ public class Artifact extends KindofMisc { -//TODO: add artifact transform method and tie it into well of transformation, scheduled for 0.2.3 - { - levelKnown = true; - } private static final float TIME_TO_EQUIP = 1f; @@ -83,6 +82,13 @@ public class Artifact extends KindofMisc { activate( hero ); + cursedKnown = true; + identify(); + if (cursed) { + equipCursed( hero ); + GLog.n( "the " + this.name + " painfully binds itself to you" ); + } + hero.spendAndNext( TIME_TO_EQUIP ); return true; @@ -133,14 +139,22 @@ public class Artifact extends KindofMisc { } @Override - public boolean isIdentified() { - return true; + public String info() { + if (cursed && cursedKnown && !isEquipped( Dungeon.hero )) { + + return desc() + "\n\nYou can feel a malevolent magic lurking within the " + name() + "."; + + } else { + + return desc(); + + } } @Override public String toString() { - if (levelKnown && level != 0) { + if (levelKnown && level/levelCap != 0) { if (chargeCap > 0) { return Utils.format( TXT_TO_STRING_LVL_CHARGE, name(), visiblyUpgraded(), charge, chargeCap ); } else { @@ -155,6 +169,29 @@ public class Artifact extends KindofMisc { } } + @Override + public Item random() { + if (Random.Float() < 0.3f) { + cursed = true; + } + return this; + } + + @Override + public int price() { + int price = 200; + if (level > 0) + price += 30*((level*10)/levelCap); + if (cursed && cursedKnown) { + price /= 2; + } + if (price < 1) { + price = 1; + } + return price; + } + + protected ArtifactBuff passiveBuff() { return null; } @@ -163,6 +200,14 @@ public class Artifact extends KindofMisc { public class ArtifactBuff extends Buff { + public int level() { + return level; + } + + public boolean isCursed() { + return cursed; + } + } private static final String IMAGE = "image"; @@ -187,18 +232,4 @@ public class Artifact extends KindofMisc { charge = bundle.getInt( CHARGE ); partialCharge = bundle.getFloat( PARTIALCHARGE ); } - - @Override - public int price() { - int price = 200; - if (level > 0) - price += 30*((level*10)/levelCap); - if (cursed && cursedKnown) { - price /= 2; - } - if (price < 1) { - price = 1; - } - return price; - } } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/ChaliceOfBlood.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/ChaliceOfBlood.java index a8db5c1d8..373f3bba6 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/ChaliceOfBlood.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/ChaliceOfBlood.java @@ -43,7 +43,7 @@ public class ChaliceOfBlood extends Artifact { @Override public ArrayList actions( Hero hero ) { ArrayList actions = super.actions( hero ); - if (isEquipped( hero ) && level < levelCap) + if (isEquipped( hero ) && level < levelCap && !cursed) actions.add(AC_PRICK); return actions; } @@ -133,7 +133,9 @@ public class ChaliceOfBlood extends Artifact { if (isEquipped (Dungeon.hero)){ desc += "\n\n"; - if (level == 0) + if (cursed) + desc += "The cursed chalice has bound itself to your hand, and is slowly tugging at your life energy."; + else if (level == 0) desc += "As you hold the chalice, you feel oddly compelled to prick yourself on the sharp gems."; else if (level < 3) desc += "Some of your blood is pooled into the chalice, you can subtly feel the chalice feeding life " + @@ -155,9 +157,7 @@ public class ChaliceOfBlood extends Artifact { } public class chaliceRegen extends ArtifactBuff { - public int level() { - return level; - } + } } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/HornOfPlenty.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/HornOfPlenty.java index 1191f214a..e3e888b50 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/HornOfPlenty.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/HornOfPlenty.java @@ -53,7 +53,7 @@ public class HornOfPlenty extends Artifact { ArrayList actions = super.actions( hero ); if (isEquipped( hero ) && charge > 0) actions.add(AC_EAT); - if (isEquipped( hero ) && level < 30) + if (isEquipped( hero ) && level < 30 && !cursed) actions.add(AC_STORE); return actions; } @@ -126,10 +126,15 @@ public class HornOfPlenty extends Artifact { desc += "The horn is overflowing! A delicious array of fruit and veg is filling the horn up to its brim."; if ( isEquipped( Dungeon.hero ) ){ - desc += "\n\nThe horn rests at your side and is surprisingly lightweight, even with food in it."; + if (!cursed) { + desc += "\n\nThe horn rests at your side and is surprisingly lightweight, even with food in it."; - if (level < 15) - desc += " Perhaps there is a way to increase the horn's power by giving it food energy."; + if (level < 15) + desc += " Perhaps there is a way to increase the horn's power by giving it food energy."; + } else { + desc += "\n\nThe cursed horn has bound itself to your side, " + + "it seems to be eager to take food rather than produce it."; + } } return desc; @@ -144,7 +149,7 @@ public class HornOfPlenty extends Artifact { @Override public boolean act() { - if (charge < chargeCap) { + if (charge < chargeCap && !cursed) { //generates 0.2 food value every round, +0.01667 value per level //to a max of ~0.7 food value per round (0.2+~0.5, at level 30) diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/SandalsOfNature.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/SandalsOfNature.java index 43cd4d94e..f05b72a2a 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/SandalsOfNature.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/SandalsOfNature.java @@ -48,7 +48,7 @@ public class SandalsOfNature extends Artifact { @Override public ArrayList actions( Hero hero ) { ArrayList actions = super.actions( hero ); - if (isEquipped( hero ) && level < 3) + if (isEquipped( hero ) && level < 3 && !cursed) actions.add(AC_FEED); if (isEquipped( hero ) && charge > 0) actions.add(AC_ROOT); @@ -104,8 +104,12 @@ public class SandalsOfNature extends Artifact { if ( isEquipped ( Dungeon.hero ) ){ desc += "\n\n"; - if (level == 0) - desc += "The sandals wrap snugly around your feet, they seem happy to be worn."; + if (level == 0) { + if (!cursed) + desc += "The sandals wrap snugly around your feet, they seem happy to be worn."; + else + desc += "The cursed sandals wrap tightly around your feet."; + } else if (level == 1) desc += "The shoes fit on loosely but quickly tighten to make a perfect fit."; else if (level == 2) @@ -113,7 +117,10 @@ public class SandalsOfNature extends Artifact { else desc += "The greaves are thick and weighty, but very easy to move in, as if they are moving with you."; - desc += " You feel more attuned with nature while wearing them."; + if (!cursed) + desc += " You feel more attuned with nature while wearing them."; + else + desc += " They are blocking any attunement with nature."; if (level > 0) desc += "\n\nThe footwear has gained the ability to form up into a sort of immobile natural armour, " + @@ -153,11 +160,9 @@ public class SandalsOfNature extends Artifact { } public class Naturalism extends ArtifactBuff{ - public int level() { return level; } public void charge() { if (charge < 25*level){ charge++; - } } } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/TalismanOfForesight.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/TalismanOfForesight.java index 11e3aa157..933eef856 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/TalismanOfForesight.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/TalismanOfForesight.java @@ -5,9 +5,6 @@ import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Awareness; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; -import com.shatteredpixel.shatteredpixeldungeon.effects.CheckedCell; -import com.shatteredpixel.shatteredpixeldungeon.effects.SpellSprite; -import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfMagicMapping; import com.shatteredpixel.shatteredpixeldungeon.levels.Level; import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; @@ -16,7 +13,6 @@ 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.utils.Random; import java.util.ArrayList; @@ -41,7 +37,7 @@ public class TalismanOfForesight extends Artifact { @Override public ArrayList actions( Hero hero ) { ArrayList actions = super.actions( hero ); - if (isEquipped( hero ) && charge == 100) + if (isEquipped( hero ) && charge == 100 && !cursed) actions.add(AC_SCRY); return actions; } @@ -90,10 +86,14 @@ public class TalismanOfForesight extends Artifact { String desc = "A smooth stone, almost too big for your pocket or hand, with strange engravings on it. " + "You feel like it's watching you, assessing your every move."; if ( isEquipped( Dungeon.hero ) ){ - desc += "\n\nWhen you hold the talisman you feel like your senses are heightened."; - if (charge == 100) - desc += "\n\nThe talisman is radiating energy, prodding at your mind. You wonder what would " + - "happen if you let it in."; + if (!cursed) { + desc += "\n\nWhen you hold the talisman you feel like your senses are heightened."; + if (charge == 100) + desc += "\n\nThe talisman is radiating energy, prodding at your mind. You wonder what would " + + "happen if you let it in."; + } else { + desc += "\n\nThe cursed talisman is intently staring into you, making it impossible to concentrate."; + } } return desc; @@ -137,7 +137,7 @@ public class TalismanOfForesight extends Artifact { } } - if (smthFound == true){ + if (smthFound == true || !cursed){ if (warn == 0){ GLog.w("You feel uneasy."); if (target instanceof Hero){ @@ -153,7 +153,7 @@ public class TalismanOfForesight extends Artifact { BuffIndicator.refreshHero(); //fully charges in 2400 turns at lvl=0, scaling to 800 turns at lvl = 10. - if (charge < 100) { + if (charge < 100 && !cursed) { partialCharge += (1f / 24) + (((float) level) / 80); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/food/Food.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/food/Food.java index 238464cb4..1f46f9252 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/food/Food.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/food/Food.java @@ -17,9 +17,6 @@ */ package com.shatteredpixel.shatteredpixeldungeon.items.food; -import java.util.ArrayList; - -import com.watabou.noosa.audio.Sample; import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Badges; import com.shatteredpixel.shatteredpixeldungeon.Statistics; @@ -28,9 +25,14 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.effects.Speck; import com.shatteredpixel.shatteredpixeldungeon.effects.SpellSprite; import com.shatteredpixel.shatteredpixeldungeon.items.Item; +import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.Artifact; +import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.HornOfPlenty; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfRecharging; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; +import com.watabou.noosa.audio.Sample; + +import java.util.ArrayList; public class Food extends Item { @@ -99,6 +101,18 @@ public class Food extends Item { } } + + @Override + public boolean doPickUp( Hero hero ){ + Artifact.ArtifactBuff buff = hero.buff( HornOfPlenty.hornRecharge.class ); + if (buff != null && buff.isCursed()){ + GLog.n("Your cursed horn greedily devours the food!"); + Sample.INSTANCE.play( Assets.SND_EAT ); + hero.spendAndNext( TIME_TO_PICK_UP ); + return true; + } + return super.doPickUp( hero ); + } @Override public String info() { diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/levels/features/HighGrass.java b/src/com/shatteredpixel/shatteredpixeldungeon/levels/features/HighGrass.java index e6cb55337..f0d06b0d7 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/levels/features/HighGrass.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/levels/features/HighGrass.java @@ -43,22 +43,29 @@ public class HighGrass { if (!Dungeon.isChallenged( Challenges.NO_HERBALISM )) { int naturalismLevel = 0; + if (ch != null) { SandalsOfNature.Naturalism naturalism = ch.buff( SandalsOfNature.Naturalism.class ); if (naturalism != null) { - naturalismLevel = naturalism.level()+1; - naturalism.charge(); + if (!naturalism.isCursed()) { + naturalismLevel = naturalism.level() + 1; + naturalism.charge(); + } else { + naturalismLevel = -1; + } } } - // Seed - if (Random.Int(18-((int)(naturalismLevel*3.34))) == 0) { - level.drop( Generator.random( Generator.Category.SEED ), pos ).sprite.drop(); - } + if (naturalismLevel >= 0) { + // Seed + if (Random.Int(18 - ((int) (naturalismLevel * 3.34))) == 0) { + level.drop(Generator.random(Generator.Category.SEED), pos).sprite.drop(); + } - // Dew - if (Random.Int( 6-naturalismLevel ) == 0) { - level.drop( new Dewdrop(), pos ).sprite.drop(); + // Dew + if (Random.Int(6 - naturalismLevel) == 0) { + level.drop(new Dewdrop(), pos).sprite.drop(); + } } } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/ui/ItemSlot.java b/src/com/shatteredpixel/shatteredpixeldungeon/ui/ItemSlot.java index bd5cb18bf..eb708faa4 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/ui/ItemSlot.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/ui/ItemSlot.java @@ -171,7 +171,7 @@ public class ItemSlot extends Button { int level = item.visiblyUpgraded(); - if (level != 0 || (item.cursed && item.cursedKnown)) { + if (level != 0) { bottomRight.text( item.levelKnown ? Utils.format( TXT_LEVEL, level ) : "" ); bottomRight.measure(); bottomRight.hardlight( level > 0 ? UPGRADED : DEGRADED );