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

View File

@ -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,6 +432,8 @@ 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 );
}
}
@ -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 );
}
}
}

View File

@ -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) {

View File

@ -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";
}
}

View File

@ -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

View File

@ -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

View File

@ -61,6 +61,7 @@ public class IceBlock extends Gizmo {
public static IceBlock freeze( CharSprite sprite ) {
IceBlock iceBlock = new IceBlock( sprite );
if (sprite.parent != null)
sprite.parent.add( iceBlock );
return iceBlock;

View File

@ -230,6 +230,7 @@ public class Weapon extends KindOfWeapon {
return enchantment != null ? enchantment.glowing() : null;
}
//FIXME: most enchantment names are pretty broken, should refactor
public static abstract class Enchantment implements Bundlable {
private static final Class<?>[] enchants = new Class<?>[]{

View File

@ -19,6 +19,7 @@ package com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Chill;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite.Glowing;
@ -39,8 +40,8 @@ public class Slow extends Weapon.Enchantment {
if (Random.Int( level + 4 ) >= 3) {
Buff.prolong( defender, com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Slow.class,
Random.Float( 1, 1.5f + level ) );
Buff.affect( defender, Chill.class,
Random.Float( 1, 3f ) );
return true;
} else {

View File

@ -17,6 +17,7 @@
*/
package com.shatteredpixel.shatteredpixeldungeon.sprites;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.SnowParticle;
import com.watabou.noosa.Game;
import com.watabou.noosa.MovieClip;
import com.watabou.noosa.Visual;
@ -55,7 +56,7 @@ public class CharSprite extends MovieClip implements Tweener.Listener, MovieClip
private static final float FLASH_INTERVAL = 0.05f;
public enum State {
BURNING, LEVITATING, INVISIBLE, PARALYSED, FROZEN, ILLUMINATED
BURNING, LEVITATING, INVISIBLE, PARALYSED, FROZEN, ILLUMINATED, CHILLED
}
protected Animation idle;
@ -70,6 +71,7 @@ public class CharSprite extends MovieClip implements Tweener.Listener, MovieClip
protected Tweener motion;
protected Emitter burning;
protected Emitter chilled;
protected Emitter levitation;
protected IceBlock iceBlock;
@ -100,7 +102,6 @@ public class CharSprite extends MovieClip implements Tweener.Listener, MovieClip
place( ch.pos );
turnTo( ch.pos, Random.Int( Level.LENGTH ) );
if (parent != null)
ch.updateSpriteState();
}
@ -277,6 +278,10 @@ public class CharSprite extends MovieClip implements Tweener.Listener, MovieClip
case ILLUMINATED:
GameScene.effect( halo = new TorchHalo( this ) );
break;
case CHILLED:
chilled = emitter();
chilled.pour(SnowParticle.FACTORY, 0.1f);
break;
}
}
@ -312,6 +317,11 @@ public class CharSprite extends MovieClip implements Tweener.Listener, MovieClip
halo.putOut();
}
break;
case CHILLED:
if (chilled != null){
chilled.on = false;
chilled = null;
}
}
}