v0.6.3: corruption now causes enemies to drop loot and projectiles

This commit is contained in:
Evan Debenham 2018-01-20 15:33:57 -05:00
parent 0182bae2a0
commit 8461500d66
5 changed files with 46 additions and 29 deletions

View File

@ -22,6 +22,7 @@
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs; package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite; import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator; import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
@ -38,6 +39,13 @@ public class Corruption extends Buff {
public boolean attachTo(Char target) { public boolean attachTo(Char target) {
if (super.attachTo(target)){ if (super.attachTo(target)){
target.alignment = Char.Alignment.ALLY; target.alignment = Char.Alignment.ALLY;
if (target instanceof Mob){
((Mob) target).rollToDropLoot();
}
PinCushion p = target.buff(PinCushion.class);
if (p != null){
p.detach();
}
return true; return true;
} else { } else {
return false; return false;

View File

@ -39,7 +39,7 @@ public class Bandit extends Thief {
{ {
spriteClass = BanditSprite.class; spriteClass = BanditSprite.class;
//1 in 30 chance to be a crazy bandit, equates to overall 1/90 chance. //1 in 50 chance to be a crazy bandit, equates to overall 1/150 chance.
lootChance = 0.333f; lootChance = 0.333f;
} }

View File

@ -45,6 +45,7 @@ import com.shatteredpixel.shatteredpixeldungeon.effects.Wound;
import com.shatteredpixel.shatteredpixeldungeon.items.Generator; import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.TimekeepersHourglass; import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.TimekeepersHourglass;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.Ring;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfAccuracy; import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfAccuracy;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfWealth; import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfWealth;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
@ -555,24 +556,8 @@ public abstract class Mob extends Char {
super.die( cause ); super.die( cause );
float lootChance = this.lootChance; if (alignment == Alignment.ENEMY){
lootChance *= RingOfWealth.dropChanceMultiplier( Dungeon.hero ); rollToDropLoot();
if (Random.Float() < lootChance && Dungeon.hero.lvl <= maxLvl + 2) {
Item loot = createLoot();
if (loot != null)
Dungeon.level.drop( loot , pos ).sprite.drop();
}
if (alignment == Alignment.ENEMY && Dungeon.hero.lvl <= maxLvl + 2){
int rolls = 1;
if (properties.contains(Property.BOSS)) rolls = 15;
else if (properties.contains(Property.MINIBOSS)) rolls = 5;
ArrayList<Item> bonus = RingOfWealth.tryRareDrop(Dungeon.hero, rolls);
if (bonus != null){
for (Item b : bonus) Dungeon.level.drop( b , pos ).sprite.drop();
new Flare(8, 32).color(0xFFFF00, true).show(sprite, 2f);
}
} }
if (Dungeon.hero.isAlive() && !Dungeon.level.heroFOV[pos]) { if (Dungeon.hero.isAlive() && !Dungeon.level.heroFOV[pos]) {
@ -580,6 +565,32 @@ public abstract class Mob extends Char {
} }
} }
public void rollToDropLoot(){
if (Dungeon.hero.lvl > maxLvl + 2) return;
float lootChance = this.lootChance;
lootChance *= RingOfWealth.dropChanceMultiplier( Dungeon.hero );
if (Random.Float() < lootChance) {
Item loot = createLoot();
if (loot != null) {
Dungeon.level.drop(loot, pos).sprite.drop();
}
}
//ring of wealth logic
if (Ring.getBonus(Dungeon.hero, RingOfWealth.Wealth.class) > 0) {
int rolls = 1;
if (properties.contains(Property.BOSS)) rolls = 15;
else if (properties.contains(Property.MINIBOSS)) rolls = 5;
ArrayList<Item> bonus = RingOfWealth.tryRareDrop(Dungeon.hero, rolls);
if (bonus != null) {
for (Item b : bonus) Dungeon.level.drop(b, pos).sprite.drop();
new Flare(8, 32).color(0xFFFF00, true).show(sprite, 2f);
}
}
}
protected Object loot = null; protected Object loot = null;
protected float lootChance = 0; protected float lootChance = 0;

View File

@ -54,7 +54,7 @@ public class Swarm extends Mob {
flying = true; flying = true;
loot = new PotionOfHealing(); loot = new PotionOfHealing();
lootChance = 0.1667f; //by default, see die() lootChance = 0.1667f; //by default, see rollToDropLoot()
} }
private static final float SPLIT_DELAY = 1f; private static final float SPLIT_DELAY = 1f;
@ -138,12 +138,12 @@ public class Swarm extends Mob {
} }
@Override @Override
public void die( Object cause ){ public void rollToDropLoot() {
//sets drop chance //sets drop chance
lootChance = 1f/((6 + 2* Dungeon.LimitedDrops.SWARM_HP.count ) * (generation+1) ); lootChance = 1f/((6 + 2* Dungeon.LimitedDrops.SWARM_HP.count ) * (generation+1) );
super.die( cause ); super.rollToDropLoot();
} }
@Override @Override
protected Item createLoot(){ protected Item createLoot(){
Dungeon.LimitedDrops.SWARM_HP.count++; Dungeon.LimitedDrops.SWARM_HP.count++;

View File

@ -91,19 +91,17 @@ public class Thief extends Mob {
protected float attackDelay() { protected float attackDelay() {
return 0.5f; return 0.5f;
} }
@Override @Override
public void die( Object cause ) { public void rollToDropLoot() {
super.die( cause );
if (item != null) { if (item != null) {
Dungeon.level.drop( item, pos ).sprite.drop(); Dungeon.level.drop( item, pos ).sprite.drop();
//updates position //updates position
if (item instanceof Honeypot.ShatteredPot) ((Honeypot.ShatteredPot)item).setHolder( this ); if (item instanceof Honeypot.ShatteredPot) ((Honeypot.ShatteredPot)item).setHolder( this );
} }
super.rollToDropLoot();
} }
@Override @Override
protected Item createLoot(){ protected Item createLoot(){
if (!Dungeon.LimitedDrops.THIEVES_ARMBAND.dropped()) { if (!Dungeon.LimitedDrops.THIEVES_ARMBAND.dropped()) {