From f844ee05d41d4d6f8534e8bccb051f7df516b14c Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Mon, 20 Apr 2015 02:03:54 -0400 Subject: [PATCH] v0.3.0: made some changes to EXP earning logic, reworked the warlock, added a level cap at level 30, buffed the potion of experience a bit. --- .../actors/buffs/Hunger.java | 30 +++++++++-- .../actors/hero/Hero.java | 51 ++++++++++++------- .../actors/mobs/Mob.java | 2 +- .../items/potions/PotionOfExperience.java | 2 +- 4 files changed, 60 insertions(+), 25 deletions(-) diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Hunger.java b/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Hunger.java index 69c457a13..dba574ac4 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Hunger.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Hunger.java @@ -18,15 +18,16 @@ package com.shatteredpixel.shatteredpixeldungeon.actors.buffs; import com.shatteredpixel.shatteredpixeldungeon.Badges; +import com.shatteredpixel.shatteredpixeldungeon.Challenges; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.ResultDescriptions; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass; +import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroSubClass; import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.Artifact; import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.HornOfPlenty; import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; -import com.shatteredpixel.shatteredpixeldungeon.utils.Utils; import com.watabou.utils.Bundle; import com.watabou.utils.Random; @@ -113,20 +114,41 @@ public class Hunger extends Buff implements Hero.Doom { return true; } - + public void satisfy( float energy ) { + if (((Hero) target).subClass == HeroSubClass.WARLOCK) + return; + Artifact.ArtifactBuff buff = target.buff( HornOfPlenty.hornRecharge.class ); if (buff != null && buff.isCursed()){ - energy = Math.round(energy*0.67f); + energy *= 0.67f; GLog.n("The cursed horn steals some of the food energy as you eat."); } + + reduceHunger( energy ); + } + + public void consumeSoul( float energy ){ + + if (level >= STARVING) + energy *= 1.5f; + else if (level < HUNGRY) + energy *= 0.75f; + + reduceHunger( energy ); + } + + private void reduceHunger( float energy ) { + if (Dungeon.isChallenged(Challenges.NO_FOOD)) + return; + level -= energy; if (level < 0) { level = 0; } else if (level > STARVING) { level = STARVING; } - + BuffIndicator.refreshHero(); } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java b/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java index 5cd04aaa4..055395955 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java @@ -121,10 +121,13 @@ public class Hero extends Char { private static final String TXT_LEAVE = "One does not simply leave Pixel Dungeon."; + public static final int MAX_LEVEL = 30; private static final String TXT_LEVEL_UP = "level up!"; private static final String TXT_NEW_LEVEL = "Welcome to level %d! Now you are healthier and more focused. " + "It's easier for you to hit enemies and dodge their attacks."; + private static final String TXT_LEVEL_CAP = + "You can't gain any more levels, but your experiences still give you a burst of energy!"; public static final String TXT_YOU_NOW_HAVE = "You now have %s"; @@ -1090,22 +1093,43 @@ public class Hero extends Char { public void earnExp( int exp ) { this.exp += exp; + + if (subClass == HeroSubClass.WARLOCK) { + + float percent = exp/(float)maxExp(); + int healed = Math.round(Math.min(HT - HP, HT * percent * 0.3f)); + if (healed > 0) { + HP += healed; + sprite.emitter().burst( Speck.factory( Speck.HEALING ), (int)(percent*10) ); + } + + (buff( Hunger.class )).consumeSoul( Hunger.STARVING*percent ); + } boolean levelUp = false; while (this.exp >= maxExp()) { this.exp -= maxExp(); - lvl++; - - HT += 5; - HP += 5; - attackSkill++; - defenseSkill++; + if (lvl < MAX_LEVEL) { + lvl++; + levelUp = true; + + HT += 5; + HP += 5; + attackSkill++; + defenseSkill++; + + } else { + //TODO: add blessed buff here + + this.exp = 0; + + GLog.p( "You cannot grow stronger, but your experiences do give you a surge of power!" ); + //TODO: holy SFX + } if (lvl < 10) { updateAwareness(); } - - levelUp = true; } if (levelUp) { @@ -1116,17 +1140,6 @@ public class Hero extends Char { Badges.validateLevelReached(); } - - if (subClass == HeroSubClass.WARLOCK) { - - int value = Math.min( HT - HP, 1 + (Dungeon.depth - 1) / 5 ); - if (value > 0) { - HP += value; - sprite.emitter().burst( Speck.factory( Speck.HEALING ), 1 ); - } - - ((Hunger)buff( Hunger.class )).satisfy( 10 ); - } } public int maxExp() { diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mob.java b/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mob.java index 5e548d4ed..60d464676 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mob.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mob.java @@ -67,7 +67,7 @@ public abstract class Mob extends Char { protected int defenseSkill = 0; protected int EXP = 1; - protected int maxLvl = 30; + protected int maxLvl = Hero.MAX_LEVEL; protected Char enemy; protected boolean enemySeen; diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/potions/PotionOfExperience.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/potions/PotionOfExperience.java index babc4de04..8a0d02b01 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/potions/PotionOfExperience.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/potions/PotionOfExperience.java @@ -31,7 +31,7 @@ public class PotionOfExperience extends Potion { @Override public void apply( Hero hero ) { setKnown(); - hero.earnExp( hero.maxExp() - hero.exp ); + hero.earnExp( hero.maxExp() ); } @Override