v0.3.0: wand of firebolt rework mostly implemented.

This commit is contained in:
Evan Debenham 2015-04-27 02:00:52 -04:00
parent 663f3f3727
commit 8c1f4aed38

View File

@ -17,67 +17,110 @@
*/ */
package com.shatteredpixel.shatteredpixeldungeon.items.wands; package com.shatteredpixel.shatteredpixeldungeon.items.wands;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Cripple;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Paralysis;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MagesStaff; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MagesStaff;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.watabou.noosa.audio.Sample; import com.watabou.noosa.audio.Sample;
import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.ResultDescriptions;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob; import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Fire; import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Fire;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Burning; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Burning;
import com.shatteredpixel.shatteredpixeldungeon.effects.MagicMissile;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.FlameParticle;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level; import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica; import com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
import com.watabou.noosa.audio.Sample;
import com.watabou.utils.Callback; import com.watabou.utils.Callback;
import com.watabou.utils.Random; import com.watabou.utils.Random;
import java.util.HashSet;
//TODO: rename to fireblast
public class WandOfFirebolt extends Wand { public class WandOfFirebolt extends Wand {
{ {
name = "Wand of Firebolt"; name = "Wand of Firebolt";
image = ItemSpriteSheet.WAND_FIREBOLT; image = ItemSpriteSheet.WAND_FIREBOLT;
collisionProperties = Ballistica.STOP_TERRAIN;
} }
private HashSet<Integer> affectedCells;
private int direction = 0;
@Override @Override
protected void onZap( Ballistica bolt ) { protected void onZap( Ballistica bolt ) {
int level = level(); int level = level();
for (int c : bolt.subPath(0, bolt.dist)) { affectedCells = new HashSet<>();
if (Level.flamable[c]) {
GameScene.add( Blob.seed( c, 1, Fire.class ) ); int maxDist = 1 + chargesPerCast()*2;
int dist = Math.min(bolt.dist, maxDist);
for (int i = 0; i < Level.NEIGHBOURS8.length; i++){
if (bolt.sourcePos+Level.NEIGHBOURS8[i] == bolt.path.get(1)){
direction = i;
break;
} }
} }
int cell = bolt.collisionPos; float strength = maxDist;
for (int c : bolt.subPath(1, dist)) {
strength--; //as we start at dist 1, not 0.
affectedCells.add(c);
spreadFlames(c + Level.NEIGHBOURS8[left(direction)], strength - 1);
spreadFlames(c + Level.NEIGHBOURS8[direction], strength - 1);
spreadFlames(c + Level.NEIGHBOURS8[right(direction)], strength - 1);
}
GameScene.add( Blob.seed( cell, 1, Fire.class ) ); if (Level.flamable[bolt.sourcePos]){
GameScene.add( Blob.seed( bolt.sourcePos, 2, Fire.class ) );
}
Char ch = Actor.findChar( cell ); for( int cell : affectedCells){
if (ch != null) { GameScene.add( Blob.seed( cell, 1+chargesPerCast(), Fire.class ) );
Char ch = Actor.findChar( cell );
if (ch != null) {
ch.damage( Random.Int( 1, 8 + level * level ), this ); ch.damage(Random.NormalIntRange(1, (int) (8 + (level * level * (1 + chargesPerCast()) / 6f))), this);
Buff.affect( ch, Burning.class ).reignite( ch ); Buff.affect( ch, Burning.class ).reignite( ch );
switch(chargesPerCast()){
ch.sprite.emitter().burst( FlameParticle.FACTORY, 5 ); case 1:
Buff.affect(ch, Cripple.class, 3f); break;
if (ch == curUser && !ch.isAlive()) { case 2:
Dungeon.fail( Utils.format( ResultDescriptions.ITEM, name ) ); Buff.affect(ch, Cripple.class, 6f); break;
GLog.n( "You killed yourself with your own Wand of Firebolt..." ); case 3:
Buff.affect(ch, Paralysis.class, 3f); break;
case 4:
Buff.affect(ch, Paralysis.class, 6f); break;
}
} }
} }
} }
//burn... BURNNNNN!.....
private void spreadFlames(int cell, float strength){
if (strength >= 0 && Level.passable[cell]){
affectedCells.add(cell);
if (strength >= 1.5f) {
spreadFlames(cell + Level.NEIGHBOURS8[left(direction)], strength-1.5f);
spreadFlames(cell + Level.NEIGHBOURS8[direction], strength-1.5f);
spreadFlames(cell + Level.NEIGHBOURS8[right(direction)], strength-1.5f);
}
}
}
private int left(int direction){
return direction == 0 ? 7 : direction-1;
}
private int right(int direction){
return direction == 7 ? 0 : direction+1;
}
@Override @Override
public void onHit(MagesStaff staff, Char attacker, Char defender, int damage) { public void onHit(MagesStaff staff, Char attacker, Char defender, int damage) {
//acts like blazing enchantment, package conflict..... //acts like blazing enchantment, package conflict.....
@ -87,12 +130,21 @@ public class WandOfFirebolt extends Wand {
@Override @Override
protected void fx( Ballistica bolt, Callback callback ) { protected void fx( Ballistica bolt, Callback callback ) {
MagicMissile.fire( curUser.sprite.parent, bolt.sourcePos, bolt.collisionPos, callback ); //TODO: add new effects
//MagicMissile.fire( curUser.sprite.parent, bolt.sourcePos, bolt.collisionPos, callback );
Sample.INSTANCE.play( Assets.SND_ZAP ); Sample.INSTANCE.play( Assets.SND_ZAP );
callback.call();
}
@Override
protected int chargesPerCast() {
//consumes 40% of current charges, rounded up, with a minimum of one.
return Math.max(1, (int)Math.ceil(curCharges*0.4f));
} }
@Override @Override
public String desc() { public String desc() {
//TODO add new description
return return
"This wand unleashes bursts of magical fire. It will ignite " + "This wand unleashes bursts of magical fire. It will ignite " +
"flammable terrain, and will damage and burn a creature it hits."; "flammable terrain, and will damage and burn a creature it hits.";