v0.7.2: significant buffs and adjustments to ring of wealth

This commit is contained in:
Evan Debenham 2019-02-17 15:33:17 -05:00
parent cc16f96d40
commit 29436bb82c
3 changed files with 178 additions and 64 deletions

View File

@ -632,10 +632,15 @@ public abstract class Mob extends Char {
int rolls = 1; int rolls = 1;
if (properties.contains(Property.BOSS)) rolls = 15; if (properties.contains(Property.BOSS)) rolls = 15;
else if (properties.contains(Property.MINIBOSS)) rolls = 5; else if (properties.contains(Property.MINIBOSS)) rolls = 5;
ArrayList<Item> bonus = RingOfWealth.tryRareDrop(Dungeon.hero, rolls); ArrayList<Item> bonus = RingOfWealth.tryForBonusDrop(Dungeon.hero, rolls);
if (bonus != null) { if (!bonus.isEmpty()) {
for (Item b : bonus) Dungeon.level.drop(b, pos).sprite.drop(); for (Item b : bonus) Dungeon.level.drop(b, pos).sprite.drop();
new Flare(8, 32).color(0xFFFF00, true).show(sprite, 2f); if (RingOfWealth.latestDropWasRare){
new Flare(8, 48).color(0xAA00FF, true).show(sprite, 2f);
RingOfWealth.latestDropWasRare = false;
} else {
new Flare(8, 24).color(0xFFFFFF, true).show(sprite, 2f);
}
} }
} }
} }

View File

@ -140,10 +140,15 @@ public class Heap implements Bundlable {
if (type != Type.MIMIC) { if (type != Type.MIMIC) {
type = Type.HEAP; type = Type.HEAP;
ArrayList<Item> bonus = RingOfWealth.tryRareDrop(hero, 1); ArrayList<Item> bonus = RingOfWealth.tryForBonusDrop(hero, 1);
if (bonus != null){ if (!bonus.isEmpty()) {
items.addAll(0, bonus); items.addAll(0, bonus);
new Flare(8, 32).color(0xFFFF00, true).show(sprite, 2f); if (RingOfWealth.latestDropWasRare){
new Flare(8, 48).color(0xAA00FF, true).show(sprite, 2f);
RingOfWealth.latestDropWasRare = false;
} else {
new Flare(8, 24).color(0xFFFFFF, true).show(sprite, 2f);
}
} }
sprite.link(); sprite.link();
sprite.drop(); sprite.drop();

View File

@ -21,13 +21,21 @@
package com.shatteredpixel.shatteredpixeldungeon.items.rings; package com.shatteredpixel.shatteredpixeldungeon.items.rings;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.items.Generator; import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
import com.shatteredpixel.shatteredpixeldungeon.items.Gold; import com.shatteredpixel.shatteredpixeldungeon.items.Gold;
import com.shatteredpixel.shatteredpixeldungeon.items.Honeypot;
import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.bombs.Bomb; import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.AlchemicalCatalyst;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfExperience;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTransmutation;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.exotic.ScrollOfEnchantment;
import com.shatteredpixel.shatteredpixeldungeon.items.spells.ArcaneCatalyst;
import com.shatteredpixel.shatteredpixeldungeon.items.stones.StoneOfEnchantment;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.watabou.utils.Bundle;
import com.watabou.utils.Random; import com.watabou.utils.Random;
import java.text.DecimalFormat; import java.text.DecimalFormat;
@ -36,7 +44,10 @@ import java.util.HashSet;
public class RingOfWealth extends Ring { public class RingOfWealth extends Ring {
private float triesToDrop = 0; private float triesToDrop = Float.MIN_VALUE;
private int dropsToRare = Integer.MIN_VALUE;
public static boolean latestDropWasRare = false;
public String statsInfo() { public String statsInfo() {
if (isIdentified()){ if (isIdentified()){
@ -46,6 +57,23 @@ public class RingOfWealth extends Ring {
} }
} }
private static final String TRIES_TO_DROP = "tries_to_drop";
private static final String DROPS_TO_RARE = "drops_to_rare";
@Override
public void storeInBundle(Bundle bundle) {
super.storeInBundle(bundle);
bundle.put(TRIES_TO_DROP, triesToDrop);
bundle.put(DROPS_TO_RARE, dropsToRare);
}
@Override
public void restoreFromBundle(Bundle bundle) {
super.restoreFromBundle(bundle);
triesToDrop = bundle.getFloat(TRIES_TO_DROP);
dropsToRare = bundle.getInt(DROPS_TO_RARE);
}
@Override @Override
protected RingBuff buff( ) { protected RingBuff buff( ) {
return new Wealth(); return new Wealth();
@ -55,86 +83,155 @@ public class RingOfWealth extends Ring {
return (float)Math.pow(1.2, getBonus(target, Wealth.class)); return (float)Math.pow(1.2, getBonus(target, Wealth.class));
} }
public static ArrayList<Item> tryRareDrop(Char target, int tries ){ public static ArrayList<Item> tryForBonusDrop(Char target, int tries ){
if (getBonus(target, Wealth.class) <= 0) return null; if (getBonus(target, Wealth.class) <= 0) return null;
HashSet<Wealth> buffs = target.buffs(Wealth.class); HashSet<Wealth> buffs = target.buffs(Wealth.class);
float triesToDrop = -1; float triesToDrop = Float.MIN_VALUE;
int dropsToRare = Integer.MIN_VALUE;
//find the largest count (if they aren't synced yet) //find the largest count (if they aren't synced yet)
for (Wealth w : buffs){ for (Wealth w : buffs){
if (w.triesToDrop() > triesToDrop){ if (w.triesToDrop() > triesToDrop){
triesToDrop = w.triesToDrop(); triesToDrop = w.triesToDrop();
dropsToRare = w.dropsToRare();
} }
} }
//reset (if needed), decrement, and store counts //reset (if needed), decrement, and store counts
if (triesToDrop <= 0) triesToDrop += Random.NormalIntRange(15, 60); if (triesToDrop == Float.MIN_VALUE) {
triesToDrop -= dropProgression( target, tries ); triesToDrop = Random.NormalIntRange(0, 60);
for (Wealth w : buffs){ dropsToRare = Random.NormalIntRange(0, 20);
w.triesToDrop(triesToDrop);
} }
//now handle reward logic //now handle reward logic
if (triesToDrop <= 0){ ArrayList<Item> drops = new ArrayList<>();
return generateRareDrop();
triesToDrop -= dropProgression(target, tries);
while ( triesToDrop <= 0 ){
if (dropsToRare <= 0){
drops.add(genRareDrop());
latestDropWasRare = true;
dropsToRare = Random.NormalIntRange(0, 20);
} else { } else {
return null; drops.add(genStandardDrop());
dropsToRare--;
}
triesToDrop += Random.NormalIntRange(0, 60);
} }
//store values back into rings
for (Wealth w : buffs){
w.triesToDrop(triesToDrop);
w.dropsToRare(dropsToRare);
} }
//TODO this is a start, but i'm sure this could be made more interesting... return drops;
private static ArrayList<Item> generateRareDrop(){ }
public static Item genStandardDrop(){
float roll = Random.Float(); float roll = Random.Float();
ArrayList<Item> items = new ArrayList<>(); if (roll < 0.3f){ //30% chance
if (roll < 0.6f){ Item result = new Gold().random();
switch (Random.Int(3)){ result.quantity(Math.round(result.quantity() * Random.NormalFloat(0.33f, 1f)));
case 0: return result;
items.add(new Gold().random()); } else if (roll < 0.7f){ //40% chance
break; return genBasicConsumable();
case 1: } else if (roll < 0.9f){ //20% chance
items.add(Generator.random(Generator.Category.POTION)); return genExoticConsumable();
break; } else { //10% chance
case 2: if (Random.Int(3) != 0){
items.add(Generator.random(Generator.Category.SCROLL)); Weapon weapon = Generator.randomWeapon();
break; weapon.enchant(null);
} weapon.cursed = false;
} else if (roll < 0.9f){ weapon.cursedKnown = true;
switch (Random.Int(3)){ weapon.level(0);
case 0: return weapon;
items.add(Generator.random(Generator.Category.SEED));
items.add(Generator.random(Generator.Category.SEED));
items.add(Generator.random(Generator.Category.SEED));
items.add(Generator.random(Generator.Category.SEED));
items.add(Generator.random(Generator.Category.SEED));
break;
case 1:
items.add(Generator.random(Random.Int(2) == 0 ? Generator.Category.POTION : Generator.Category.SCROLL ));
items.add(Generator.random(Random.Int(2) == 0 ? Generator.Category.POTION : Generator.Category.SCROLL ));
items.add(Generator.random(Random.Int(2) == 0 ? Generator.Category.POTION : Generator.Category.SCROLL ));
break;
case 2:
items.add(new Bomb().random());
items.add(new Honeypot());
break;
}
} else { } else {
Gold g = new Gold(); Armor armor = Generator.randomArmor();
g.random(); armor.inscribe(null);
g.quantity(g.quantity()*5); armor.cursed = false;
items.add(g); armor.cursedKnown = true;
armor.level(0);
return armor;
}
}
}
private static Item genBasicConsumable(){
float roll = Random.Float();
if (roll < 0.4f){ //40% chance
return Generator.random(Generator.Category.STONE);
} else if (roll < 0.7f){ //30% chance
return Generator.random(Generator.Category.POTION);
} else { //30% chance
return Generator.random(Generator.Category.SCROLL);
}
}
private static Item genExoticConsumable(){
float roll = Random.Float();
if (roll < 0.3f){ //30% chance
return Generator.random(Generator.Category.POTION);
} else if (roll < 0.6f) { //30% chance
return Generator.random(Generator.Category.SCROLL);
} else { //40% chance
return Random.Int(2) == 0 ? new AlchemicalCatalyst() : new ArcaneCatalyst();
}
}
public static Item genRareDrop(){
float roll = Random.Float();
if (roll < 0.3f){ //30% chance
Item result = new Gold().random();
result.quantity(Math.round(result.quantity() * Random.NormalFloat(3f, 6f)));
return result;
} else if (roll < 0.7f){ //40% chance
return genHighValueConsumable();
} else if (roll < 0.9f){ //20% chance
Item result = Random.Int(2) == 0 ? Generator.random(Generator.Category.ARTIFACT) : Generator.random(Generator.Category.RING);
result.cursed = false;
result.cursedKnown = true;
return result;
} else { //10% chance
if (Random.Int(3) != 0){
Weapon weapon = Generator.randomWeapon((Dungeon.depth / 5) + 1);
weapon.upgrade(1);
weapon.enchant(Weapon.Enchantment.random());
weapon.cursed = false;
weapon.cursedKnown = true;
return weapon;
} else {
Armor armor = Generator.randomArmor((Dungeon.depth / 5) + 1);
armor.upgrade();
armor.inscribe(Armor.Glyph.random());
armor.cursed = false;
armor.cursedKnown = true;
return armor;
}
}
}
private static Item genHighValueConsumable(){
switch( Random.Int(4) ){ //25% chance each
case 0: default:
return new StoneOfEnchantment();
case 1:
return new ScrollOfEnchantment();
case 2:
return new PotionOfExperience();
case 3:
return new ScrollOfTransmutation();
} }
return items;
} }
private static float dropProgression( Char target, int tries ){ private static float dropProgression( Char target, int tries ){
return tries * (float)Math.pow(1.2f, getBonus(target, Wealth.class) -1 ); return tries * (float)Math.pow(1.2f, getBonus(target, Wealth.class) );
} }
public class Wealth extends RingBuff { public class Wealth extends RingBuff {
private void triesToDrop( float val){ private void triesToDrop( float val ){
triesToDrop = val; triesToDrop = val;
} }
@ -142,6 +239,13 @@ public class RingOfWealth extends Ring {
return triesToDrop; return triesToDrop;
} }
private void dropsToRare( int val ) {
dropsToRare = val;
}
private int dropsToRare(){
return dropsToRare;
}
} }
} }