diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Talent.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Talent.java index 9200ab1af..b836daf0f 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Talent.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Talent.java @@ -229,11 +229,7 @@ public enum Talent { return Messages.get(this, name() + ".desc"); } - public static void onTalentUpgraded( Hero hero, Talent talent){ - if (talent == NATURES_BOUNTY){ - if ( hero.pointsInTalent(NATURES_BOUNTY) == 1) Buff.count(hero, NatureBerriesAvailable.class, 4); - else Buff.count(hero, NatureBerriesAvailable.class, 2); - } + public static void onTalentUpgraded( Hero hero, Talent talent ){ if (talent == ARMSMASTERS_INTUITION && hero.pointsInTalent(ARMSMASTERS_INTUITION) == 2){ if (hero.belongings.weapon() != null) hero.belongings.weapon().identify(); @@ -269,7 +265,8 @@ public enum Talent { } public static class CachedRationsDropped extends CounterBuff{{revivePersists = true;}}; - public static class NatureBerriesAvailable extends CounterBuff{{revivePersists = true;}}; + public static class NatureBerriesAvailable extends CounterBuff{{revivePersists = true;}}; //for pre-1.3.0 saves + public static class NatureBerriesDropped extends CounterBuff{{revivePersists = true;}}; public static void onFoodEaten( Hero hero, float foodVal, Item foodSource ){ if (hero.hasTalent(HEARTY_MEAL)){ diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/features/HighGrass.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/features/HighGrass.java index 905514021..a62ef74be 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/features/HighGrass.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/features/HighGrass.java @@ -88,10 +88,21 @@ public class HighGrass { } //berries try to drop on floors 2/3/4/6/7/8, to a max of 4/6 - Talent.NatureBerriesAvailable berries = ch.buff(Talent.NatureBerriesAvailable.class); - if (berries != null) { + if (ch instanceof Hero && ((Hero) ch).hasTalent(Talent.NATURES_BOUNTY)){ + int berriesAvailable = 2 + 2*((Hero) ch).pointsInTalent(Talent.NATURES_BOUNTY); + + //pre-1.3.0 saves + Talent.NatureBerriesAvailable oldAvailable = ch.buff(Talent.NatureBerriesAvailable.class); + if (oldAvailable != null){ + Buff.affect(ch, Talent.NatureBerriesDropped.class).countUp(berriesAvailable - oldAvailable.count()); + oldAvailable.detach(); + } + + Talent.NatureBerriesDropped dropped = Buff.affect(ch, Talent.NatureBerriesDropped.class); + berriesAvailable -= dropped.count(); + int targetFloor = 2 + 2*((Hero)ch).pointsInTalent(Talent.NATURES_BOUNTY); - targetFloor -= berries.count(); + targetFloor -= berriesAvailable; targetFloor += (targetFloor >= 5) ? 3 : 2; //If we're behind: 1/10, if we're on page: 1/30, if we're ahead: 1/90 @@ -101,11 +112,8 @@ public class HighGrass { else if (Dungeon.depth < targetFloor) droppingBerry = Random.Int(90) == 0; if (droppingBerry){ - berries.countDown(1); + dropped.countUp(1); level.drop(new Berry(), pos).sprite.drop(); - if (berries.count() <= 0){ - berries.detach(); - } } }