v0.3.0: added chilled debuff
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Thief;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.food.FrozenCarpaccio;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.food.MysteryMeat;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
/**
|
||||
* Created by debenhame on 23/04/2015.
|
||||
*/
|
||||
public class Chill extends FlavourBuff {
|
||||
|
||||
private static final String TXT_FREEZES = "%s freezes!";
|
||||
|
||||
@Override
|
||||
public boolean attachTo(Char target) {
|
||||
//can't chill what's frozen!
|
||||
if (target.buff(Frost.class) != null) return false;
|
||||
|
||||
if (super.attachTo(target)){
|
||||
Burning.detach( target, Burning.class );
|
||||
|
||||
//chance of potion breaking is the same as speed factor.
|
||||
if (Random.Float(1f) > speedFactor() && target instanceof Hero) {
|
||||
|
||||
Hero hero = (Hero)target;
|
||||
Item item = hero.belongings.randomUnequipped();
|
||||
if (item instanceof Potion) {
|
||||
|
||||
item = item.detach( hero.belongings.backpack );
|
||||
GLog.w(TXT_FREEZES, item.toString());
|
||||
((Potion) item).shatter(hero.pos);
|
||||
|
||||
} else if (item instanceof MysteryMeat) {
|
||||
|
||||
item = item.detach( hero.belongings.backpack );
|
||||
FrozenCarpaccio carpaccio = new FrozenCarpaccio();
|
||||
if (!carpaccio.collect( hero.belongings.backpack )) {
|
||||
Dungeon.level.drop( carpaccio, target.pos ).sprite.drop();
|
||||
}
|
||||
GLog.w(TXT_FREEZES, item.toString());
|
||||
|
||||
}
|
||||
} else if (target instanceof Thief && ((Thief)target).item instanceof Potion) {
|
||||
|
||||
((Potion) ((Thief)target).item).shatter( target.pos );
|
||||
((Thief) target).item = null;
|
||||
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//reduces speed by 10% for every turn remaining, capping at 50%
|
||||
public float speedFactor(){
|
||||
return Math.max(0.5f, 1 - cooldown()*0.1f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int icon() {
|
||||
return BuffIndicator.FROST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Chilled";
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user