diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mob.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mob.java index 24894ff32..bb319870f 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mob.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mob.java @@ -37,6 +37,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.SoulMark; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Terror; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroSubClass; +import com.shatteredpixel.shatteredpixeldungeon.effects.Flare; import com.shatteredpixel.shatteredpixeldungeon.effects.Speck; import com.shatteredpixel.shatteredpixeldungeon.effects.Surprise; import com.shatteredpixel.shatteredpixeldungeon.effects.Wound; @@ -565,6 +566,17 @@ public abstract class Mob extends Char { Dungeon.level.drop( loot , pos ).sprite.drop(); } + if (hostile && Dungeon.hero.lvl <= maxLvl + 2){ + int rolls = 1; + if (properties.contains(Property.BOSS)) rolls = 15; + else if (properties.contains(Property.MINIBOSS)) rolls = 5; + Item bonus = RingOfWealth.tryRareDrop(Dungeon.hero, rolls); + if (bonus != null){ + Dungeon.level.drop( bonus , pos ).sprite.drop(); + new Flare(8, 32).color(0xFFFF00, true).show(sprite, 2f); + } + } + if (Dungeon.hero.isAlive() && !Dungeon.visible[pos]) { GLog.i( Messages.get(this, "died") ); } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Heap.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Heap.java index ebf2a426b..6cabcbd1c 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Heap.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Heap.java @@ -33,6 +33,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mimic; import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Wraith; import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter; +import com.shatteredpixel.shatteredpixeldungeon.effects.Flare; import com.shatteredpixel.shatteredpixeldungeon.effects.Speck; import com.shatteredpixel.shatteredpixeldungeon.effects.Splash; import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ElmoParticle; @@ -50,6 +51,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfExperience import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfHealing; import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfMight; import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfStrength; +import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfWealth; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfMagicalInfusion; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfUpgrade; @@ -149,6 +151,11 @@ public class Heap implements Bundlable { if (type != Type.MIMIC) { type = Type.HEAP; + Item bonus = RingOfWealth.tryRareDrop(hero, 1); + if (bonus != null){ + items.addFirst(bonus); + new Flare(8, 32).color(0xFFFF00, true).show(sprite, 2f); + } sprite.link(); sprite.drop(); } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfWealth.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfWealth.java index 68ec3c233..483f8355d 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfWealth.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfWealth.java @@ -22,9 +22,16 @@ package com.shatteredpixel.shatteredpixeldungeon.items.rings; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; +import com.shatteredpixel.shatteredpixeldungeon.items.Gold; +import com.shatteredpixel.shatteredpixeldungeon.items.Item; +import com.watabou.utils.Random; + +import java.util.HashSet; public class RingOfWealth extends Ring { - + + private float triesToDrop = 0; + @Override protected RingBuff buff( ) { return new Wealth(); @@ -34,15 +41,51 @@ public class RingOfWealth extends Ring { return (float)Math.pow(1.15, getBonus(target, Wealth.class)); } - //caps at a 50% bonus - public static float regularLootChanceBonus( Char target ){ - return Math.min(0.5f, 0.05f* getBonus(target, Wealth.class)); + public static Item tryRareDrop(Char target, int tries ){ + if (getBonus(target, Wealth.class) <= 0) return null; + + HashSet buffs = target.buffs(Wealth.class); + float triesToDrop = -1; + + //find the largest count (if they aren't synced yet) + for (Wealth w : buffs){ + if (w.triesToDrop() > triesToDrop){ + triesToDrop = w.triesToDrop(); + } + } + + //reset (if needed), decrement, and store counts + if (triesToDrop <= 0) triesToDrop += Random.NormalIntRange(0, 100); + triesToDrop -= dropProgression( target, tries ); + for (Wealth w : buffs){ + w.triesToDrop(triesToDrop); + } + + //now handle reward logic + if (triesToDrop <= 0){ + //TODO more drops, gold is very boring + return new Gold().random(); + } else { + return null; + } + } - public static float specialLootChance( Char target ){ - return 1f - (float)Math.pow(0.925, getBonus(target, Wealth.class)); + //caps at a 50% bonus + private static float dropProgression( Char target, int tries ){ + return tries * (float)Math.pow(1.25f, getBonus(target, Wealth.class) -1 ); } public class Wealth extends RingBuff { + + private void triesToDrop( float val){ + triesToDrop = val; + } + + private float triesToDrop(){ + return triesToDrop; + } + + } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java index 451b3cadc..7fdd3c575 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java @@ -57,9 +57,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.bags.SeedPouch; import com.shatteredpixel.shatteredpixeldungeon.items.food.Blandfruit; import com.shatteredpixel.shatteredpixeldungeon.items.food.Food; import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfHealing; -import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfMight; import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfStrength; -import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfWealth; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfMagicalInfusion; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfUpgrade; @@ -179,22 +177,14 @@ public abstract class Level implements Bundlable { addItemToSpawn( Generator.random( Generator.Category.FOOD ) ); if (Dungeon.posNeeded()) { - if (Random.Float() < RingOfWealth.specialLootChance( Dungeon.hero )) - addItemToSpawn( new PotionOfMight() ); - else - addItemToSpawn( new PotionOfStrength() ); + addItemToSpawn( new PotionOfStrength() ); Dungeon.limitedDrops.strengthPotions.count++; } if (Dungeon.souNeeded()) { - if (Random.Float() < RingOfWealth.specialLootChance( Dungeon.hero )) - addItemToSpawn( new ScrollOfMagicalInfusion() ); - else - addItemToSpawn( new ScrollOfUpgrade() ); + addItemToSpawn( new ScrollOfUpgrade() ); Dungeon.limitedDrops.upgradeScrolls.count++; } if (Dungeon.asNeeded()) { - if (Random.Float() < RingOfWealth.specialLootChance( Dungeon.hero )) - addItemToSpawn( new Stylus() ); addItemToSpawn( new Stylus() ); Dungeon.limitedDrops.arcaneStyli.count++; } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/RegularLevel.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/RegularLevel.java index 8776c8911..b4ab234ba 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/RegularLevel.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/RegularLevel.java @@ -32,7 +32,6 @@ import com.shatteredpixel.shatteredpixeldungeon.items.Generator; import com.shatteredpixel.shatteredpixeldungeon.items.Heap; import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion; -import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfWealth; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll; import com.shatteredpixel.shatteredpixeldungeon.levels.builders.Builder; import com.shatteredpixel.shatteredpixeldungeon.levels.builders.LoopBuilder; @@ -311,11 +310,8 @@ public abstract class RegularLevel extends Level { @Override protected void createItems() { - int nItems = 3; - - while (Random.Float() < (0.3f + RingOfWealth.regularLootChanceBonus( Dungeon.hero ))) { - nItems++; - } + // drops 3/4/5 items 60%/30%/10% of the time + int nItems = 3 + Random.chances(new float[]{6, 3, 1}); for (int i=0; i < nItems; i++) { Heap.Type type = null;