v0.3.0: added chilled debuff

This commit is contained in:
Evan Debenham
2015-04-25 01:33:50 -04:00
parent 6507df2824
commit 3f1043e4b9
9 changed files with 121 additions and 14 deletions
@@ -244,9 +244,6 @@ public abstract class Char extends Actor {
}
if (this.buff(Frost.class) != null){
Buff.detach( this, Frost.class );
if (Level.water[this.pos]) {
Buff.prolong(this, Paralysis.class, 1f);
}
}
if (this.buff(MagicalSleep.class) != null){
Buff.detach(this, MagicalSleep.class);
@@ -301,6 +298,9 @@ public abstract class Char extends Actor {
float timeScale = 1f;
if (buff( Slow.class ) != null) {
timeScale *= 0.5f;
//slowed and chilled do not stack
} else if (buff( Chill.class ) != null) {
timeScale *= buff( Chill.class ).speedFactor();
}
if (buff( Speed.class ) != null) {
timeScale *= 2.0f;
@@ -363,6 +363,11 @@ public abstract class Char extends Actor {
sprite.showStatus( CharSprite.NEGATIVE, "slowed" );
} else if (buff instanceof Chill) {
sprite.showStatus( CharSprite.NEGATIVE, "chilled" );
sprite.add( CharSprite.State.CHILLED );
} else if (buff instanceof MindVision) {
sprite.showStatus( CharSprite.POSITIVE, "mind" );
@@ -427,7 +432,9 @@ public abstract class Char extends Actor {
sprite.remove( CharSprite.State.PARALYSED );
} else if (buff instanceof Frost) {
sprite.remove( CharSprite.State.FROZEN );
}
} else if (buff instanceof Chill) {
sprite.remove( CharSprite.State.CHILLED );
}
}
public void remove( Class<? extends Buff> buffClass ) {
@@ -457,6 +464,8 @@ public abstract class Char extends Actor {
sprite.add( CharSprite.State.FROZEN );
} else if (buff instanceof Light) {
sprite.add( CharSprite.State.ILLUMINATED );
} else if (buff instanceof Chill) {
sprite.add( CharSprite.State.CHILLED );
}
}
}
@@ -61,7 +61,7 @@ public class Burning extends Buff implements Hero.Doom {
super.restoreFromBundle(bundle);
left = bundle.getFloat( LEFT );
}
@Override
public boolean act() {
@@ -72,6 +72,7 @@ public class Burning extends Buff implements Hero.Doom {
}
target.damage( Random.Int( 1, 5 ), this );
Buff.detach( target, Chill.class);
if (target instanceof Hero) {
@@ -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";
}
}
@@ -26,6 +26,7 @@ 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.items.rings.RingOfElements.Resistance;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
@@ -40,7 +41,8 @@ public class Frost extends FlavourBuff {
if (super.attachTo( target )) {
target.paralysed = true;
Burning.detach( target, Burning.class );
Buff.detach( target, Burning.class );
Buff.detach( target, Chill.class );
if (target instanceof Hero) {
@@ -80,6 +82,9 @@ public class Frost extends FlavourBuff {
public void detach() {
super.detach();
Paralysis.unfreeze( target );
if (Level.water[target.pos]){
Buff.prolong(target, Chill.class, 6f);
}
}
@Override
@@ -22,6 +22,7 @@ import java.util.HashSet;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Burning;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Chill;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Frost;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfLiquidFlame;
@@ -80,7 +81,7 @@ public class Elemental extends Mob {
HP++;
sprite.emitter().burst( Speck.factory( Speck.HEALING ), 1 );
}
} else if (buff instanceof Frost) {
} else if (buff instanceof Frost || buff instanceof Chill) {
if (Level.water[this.pos])
damage( Random.NormalIntRange( HT / 2, HT ), buff );
else