From 7f8a66b78fd287b2fae690c7542e6ff92292268d Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Mon, 8 Aug 2016 14:57:07 -0400 Subject: [PATCH] v0.4.1a: buffs to the horn of plenty --- .../actors/buffs/Hunger.java | 4 + .../items/artifacts/HornOfPlenty.java | 79 +++++++++++-------- 2 files changed, 49 insertions(+), 34 deletions(-) diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Hunger.java b/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Hunger.java index 077b0f163..b036ef93b 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Hunger.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Hunger.java @@ -148,6 +148,10 @@ public class Hunger extends Buff implements Hero.Doom { return level >= STARVING; } + public int hunger() { + return (int)Math.ceil(level); + } + @Override public int icon() { if (level < HUNGRY) { diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/HornOfPlenty.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/HornOfPlenty.java index 22e982f05..0e623f245 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/HornOfPlenty.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/HornOfPlenty.java @@ -54,7 +54,7 @@ public class HornOfPlenty extends Artifact { charge = 0; partialCharge = 0; - chargeCap = 10; + chargeCap = 10 + visiblyUpgraded(); defaultAction = AC_EAT; } @@ -86,30 +86,32 @@ public class HornOfPlenty extends Artifact { if (!isEquipped(hero)) GLog.i( Messages.get(Artifact.class, "need_to_equip") ); else if (charge == 0) GLog.i( Messages.get(this, "no_food") ); else { - hero.buff(Hunger.class).satisfy((Hunger.STARVING/10) * charge); + //consume as many + int chargesToUse = Math.max( 1, hero.buff(Hunger.class).hunger() / (int)(Hunger.STARVING/10)); + if (chargesToUse > charge) chargesToUse = charge; + hero.buff(Hunger.class).satisfy((Hunger.STARVING/10) * chargesToUse); - //if you get at least 100 food energy from the horn - if (charge >= 3) { - switch (hero.heroClass) { - case WARRIOR: - if (hero.HP < hero.HT) { - hero.HP = Math.min(hero.HP + 5, hero.HT); - hero.sprite.emitter().burst(Speck.factory(Speck.HEALING), 1); - } - break; - case MAGE: - //1 charge - Buff.affect( hero, Recharging.class, 4f ); - ScrollOfRecharging.charge(hero); - break; - case ROGUE: - case HUNTRESS: - break; - } - - Statistics.foodEaten++; + //if you get at least 80 food energy from the horn + switch (hero.heroClass) { + case WARRIOR: + if (hero.HP < hero.HT) { + hero.HP = Math.min(hero.HP + 5, hero.HT); + hero.sprite.emitter().burst(Speck.factory(Speck.HEALING), 1); + } + break; + case MAGE: + //1 charge + Buff.affect( hero, Recharging.class, 4f ); + ScrollOfRecharging.charge(hero); + break; + case ROGUE: + case HUNTRESS: + break; } - charge = 0; + + Statistics.foodEaten++; + + charge -= chargesToUse; hero.sprite.operate(hero.pos); hero.busy(); @@ -121,7 +123,9 @@ public class HornOfPlenty extends Artifact { Badges.validateFoodEaten(); - image = ItemSpriteSheet.ARTIFACT_HORN1; + if (charge >= 15) image = ItemSpriteSheet.ARTIFACT_HORN4; + else if (charge >= 10) image = ItemSpriteSheet.ARTIFACT_HORN3; + else if (charge >= 5) image = ItemSpriteSheet.ARTIFACT_HORN2; updateQuickslot(); } @@ -154,12 +158,19 @@ public class HornOfPlenty extends Artifact { return desc; } + @Override + public Item upgrade() { + super.upgrade(); + chargeCap = 10 + visiblyUpgraded(); + return this; + } + @Override public void restoreFromBundle(Bundle bundle) { super.restoreFromBundle(bundle); - if (charge == chargeCap)image = ItemSpriteSheet.ARTIFACT_HORN4; - else if (charge >= 7) image = ItemSpriteSheet.ARTIFACT_HORN3; - else if (charge >= 3) image = ItemSpriteSheet.ARTIFACT_HORN2; + if (charge >= 15) image = ItemSpriteSheet.ARTIFACT_HORN4; + else if (charge >= 10) image = ItemSpriteSheet.ARTIFACT_HORN3; + else if (charge >= 5) image = ItemSpriteSheet.ARTIFACT_HORN2; } public class hornRecharge extends ArtifactBuff{ @@ -167,19 +178,19 @@ public class HornOfPlenty extends Artifact { public void gainCharge(float levelPortion) { if (charge < chargeCap) { - //generates 0.25x max hunger value every hero level, +0.025x max value per horn level - //to a max of exactly max hunger value per hero level (0.25+0.75, at horn level 30) - //This means that a standard ration will be recovered in 10 hero levels - partialCharge += Hunger.STARVING * levelPortion * (0.25f + (0.025f*level())); + //generates 0.25x max hunger value every hero level, +0.035x max value per horn level + //to a max of 1.3x max hunger value per hero level + //This means that a standard ration will be recovered in ~7.15 hero levels + partialCharge += Hunger.STARVING * levelPortion * (0.25f + (0.035f*level())); //charge is in increments of 1/10 max hunger value. while (partialCharge >= Hunger.STARVING/10) { charge++; partialCharge -= Hunger.STARVING/10; - if (charge == chargeCap)image = ItemSpriteSheet.ARTIFACT_HORN4; - else if (charge >= 7) image = ItemSpriteSheet.ARTIFACT_HORN3; - else if (charge >= 3) image = ItemSpriteSheet.ARTIFACT_HORN2; + if (charge >= 15) image = ItemSpriteSheet.ARTIFACT_HORN4; + else if (charge >= 10) image = ItemSpriteSheet.ARTIFACT_HORN3; + else if (charge >= 5) image = ItemSpriteSheet.ARTIFACT_HORN2; else image = ItemSpriteSheet.ARTIFACT_HORN1; if (charge == chargeCap){