v1.3.0: changed nature's bounty to track berried dropped, not available

This commit is contained in:
Evan Debenham
2022-04-19 16:27:30 -04:00
parent f32fa4105f
commit 02dc3a4ec3
2 changed files with 18 additions and 13 deletions

View File

@@ -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)){

View File

@@ -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();
}
}
}