v0.6.1: partially reworked ring of wealth

This commit is contained in:
Evan Debenham 2017-06-30 00:42:28 -04:00
parent 39eedbd46d
commit e07098a580
5 changed files with 72 additions and 24 deletions

View File

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

View File

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

View File

@ -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<Wealth> 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();
}
}
public static float specialLootChance( Char target ){
return 1f - (float)Math.pow(0.925, getBonus(target, Wealth.class));
//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;
}
}
//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;
}
}
}

View File

@ -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() );
Dungeon.limitedDrops.strengthPotions.count++;
}
if (Dungeon.souNeeded()) {
if (Random.Float() < RingOfWealth.specialLootChance( Dungeon.hero ))
addItemToSpawn( new ScrollOfMagicalInfusion() );
else
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++;
}

View File

@ -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;