v0.2.3: refactored item dropping, added to/refactored drop limiter variables. Health potions are no longer farmable. This needs testing!
This commit is contained in:
@@ -19,8 +19,10 @@ package com.shatteredpixel.shatteredpixeldungeon.actors.mobs;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfHealing;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Leech;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.BatSprite;
|
||||
@@ -42,7 +44,7 @@ public class Bat extends Mob {
|
||||
flying = true;
|
||||
|
||||
loot = new PotionOfHealing();
|
||||
lootChance = 0.125f;
|
||||
lootChance = 0.1667f; //by default, see die()
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -77,6 +79,19 @@ public class Bat extends Mob {
|
||||
|
||||
return damage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void die( Object cause ){
|
||||
//sets drop chance
|
||||
lootChance = 1f/((6 + Dungeon.limitedDrops.batHP.count ));
|
||||
super.die( cause );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Item createLoot(){
|
||||
Dungeon.limitedDrops.batHP.count++;
|
||||
return super.createLoot();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String description() {
|
||||
|
||||
@@ -360,9 +360,19 @@ public abstract class Mob extends Char {
|
||||
public void die( Object cause ) {
|
||||
|
||||
super.die( cause );
|
||||
|
||||
float lootChance = this.lootChance;
|
||||
int bonus = 0;
|
||||
for (Buff buff : Dungeon.hero.buffs(RingOfWealth.Wealth.class)) {
|
||||
bonus += ((RingOfWealth.Wealth) buff).level;
|
||||
}
|
||||
|
||||
lootChance *= Math.pow(1.1, bonus);
|
||||
|
||||
if (Dungeon.hero.lvl <= maxLvl + 2) {
|
||||
dropLoot();
|
||||
if (Random.Float() < lootChance && Dungeon.hero.lvl <= maxLvl + 2) {
|
||||
Item loot = createLoot();
|
||||
if (loot != null)
|
||||
Dungeon.level.drop( loot , pos ).sprite.drop();
|
||||
}
|
||||
|
||||
if (Dungeon.hero.isAlive() && !Dungeon.visible[pos]) {
|
||||
@@ -374,32 +384,22 @@ public abstract class Mob extends Char {
|
||||
protected float lootChance = 0;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void dropLoot() {
|
||||
float lootChance = this.lootChance;
|
||||
int bonus = 0;
|
||||
for (Buff buff : Dungeon.hero.buffs(RingOfWealth.Wealth.class)) {
|
||||
bonus += ((RingOfWealth.Wealth) buff).level;
|
||||
protected Item createLoot() {
|
||||
Item item;
|
||||
if (loot instanceof Generator.Category) {
|
||||
|
||||
item = Generator.random( (Generator.Category)loot );
|
||||
|
||||
} else if (loot instanceof Class<?>) {
|
||||
|
||||
item = Generator.random( (Class<? extends Item>)loot );
|
||||
|
||||
} else {
|
||||
|
||||
item = (Item)loot;
|
||||
|
||||
}
|
||||
|
||||
lootChance *= Math.pow(1.1, bonus);
|
||||
|
||||
if (loot != null && Random.Float() < lootChance) {
|
||||
Item item = null;
|
||||
if (loot instanceof Generator.Category) {
|
||||
|
||||
item = Generator.random( (Generator.Category)loot );
|
||||
|
||||
} else if (loot instanceof Class<?>) {
|
||||
|
||||
item = Generator.random( (Class<? extends Item>)loot );
|
||||
|
||||
} else {
|
||||
|
||||
item = (Item)loot;
|
||||
|
||||
}
|
||||
Dungeon.level.drop( item, pos ).sprite.drop();
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public boolean reset() {
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Cripple;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Light;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Poison;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.food.MysteryMeat;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfHealing;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Leech;
|
||||
@@ -47,7 +48,7 @@ public class Scorpio extends Mob {
|
||||
maxLvl = 25;
|
||||
|
||||
loot = new PotionOfHealing();
|
||||
lootChance = 0.125f;
|
||||
lootChance = 0.2f;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -89,11 +90,13 @@ public class Scorpio extends Mob {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dropLoot() {
|
||||
if (Random.Int( 8 ) == 0) {
|
||||
Dungeon.level.drop( new PotionOfHealing(), pos ).sprite.drop();
|
||||
} else if (Random.Int( 6 ) == 0) {
|
||||
Dungeon.level.drop( new MysteryMeat(), pos ).sprite.drop();
|
||||
protected Item createLoot() {
|
||||
//5/count+5 total chance of getting healing, failing the 2nd roll drops mystery meat instead.
|
||||
if (Random.Int( 5 + Dungeon.limitedDrops.scorpioHP.count ) <= 4) {
|
||||
Dungeon.limitedDrops.scorpioHP.count++;
|
||||
return (Item)loot;
|
||||
} else {
|
||||
return new MysteryMeat();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -46,6 +46,9 @@ public class Skeleton extends Mob {
|
||||
|
||||
EXP = 5;
|
||||
maxLvl = 10;
|
||||
|
||||
loot = Generator.Category.WEAPON;
|
||||
lootChance = 0.2f;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -81,18 +84,16 @@ public class Skeleton extends Mob {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dropLoot() {
|
||||
if (Random.Int( 5 ) == 0) {
|
||||
Item loot = Generator.random( Generator.Category.WEAPON );
|
||||
for (int i=0; i < 2; i++) {
|
||||
Item l = Generator.random( Generator.Category.WEAPON );
|
||||
if (l.level < loot.level) {
|
||||
loot = l;
|
||||
}
|
||||
}
|
||||
Dungeon.level.drop( loot, pos ).sprite.drop();
|
||||
}
|
||||
}
|
||||
protected Item createLoot() {
|
||||
Item loot = Generator.random( Generator.Category.WEAPON );
|
||||
for (int i=0; i < 2; i++) {
|
||||
Item l = Generator.random( Generator.Category.WEAPON );
|
||||
if (l.level < loot.level) {
|
||||
loot = l;
|
||||
}
|
||||
}
|
||||
return loot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int attackSkill( Char target ) {
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Burning;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Poison;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Pushing;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfHealing;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||
@@ -47,6 +48,9 @@ public class Swarm extends Mob {
|
||||
maxLvl = 10;
|
||||
|
||||
flying = true;
|
||||
|
||||
loot = new PotionOfHealing();
|
||||
lootChance = 0.2f; //by default, see die()
|
||||
}
|
||||
|
||||
private static final float SPLIT_DELAY = 1f;
|
||||
@@ -130,11 +134,17 @@ public class Swarm extends Mob {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dropLoot() {
|
||||
if (Random.Int( 6 * (int)Math.pow(2 , generation) ) == 0) {
|
||||
Dungeon.level.drop( new PotionOfHealing(), pos ).sprite.drop();
|
||||
}
|
||||
}
|
||||
public void die( Object cause ){
|
||||
//sets drop chance
|
||||
lootChance = 1f/((5 + Dungeon.limitedDrops.swarmHP.count ) * generation );
|
||||
super.die( cause );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Item createLoot(){
|
||||
Dungeon.limitedDrops.swarmHP.count++;
|
||||
return super.createLoot();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String description() {
|
||||
|
||||
@@ -25,6 +25,8 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Weakness;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfHealing;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Death;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica;
|
||||
@@ -124,6 +126,23 @@ public class Warlock extends Mob implements Callback {
|
||||
public void call() {
|
||||
next();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item createLoot(){
|
||||
Item loot = super.createLoot();
|
||||
|
||||
if (loot instanceof PotionOfHealing){
|
||||
|
||||
//count/10 chance of not dropping potion
|
||||
if (Random.Int(10)-Dungeon.limitedDrops.warlockHP.count < 0){
|
||||
return null;
|
||||
} else
|
||||
Dungeon.limitedDrops.warlockHP.count++;
|
||||
|
||||
}
|
||||
|
||||
return loot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String description() {
|
||||
|
||||
Reference in New Issue
Block a user