Files
shattered-pixel-dungeon-web…/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfAvalanche.java
T
2015-06-07 21:54:40 -04:00

109 lines
3.7 KiB
Java

/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.wands;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MagesStaff;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.watabou.noosa.Camera;
import com.watabou.noosa.audio.Sample;
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.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Paralysis;
import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter;
import com.shatteredpixel.shatteredpixeldungeon.effects.MagicMissile;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica;
import com.shatteredpixel.shatteredpixeldungeon.utils.BArray;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
import com.watabou.utils.Callback;
import com.watabou.utils.PathFinder;
import com.watabou.utils.Random;
public class WandOfAvalanche extends Wand {
{
name = "Wand of Avalanche";
image = ItemSpriteSheet.WAND_LIVING_EARTH;
collisionProperties = Ballistica.STOP_TERRAIN;
}
@Override
protected void onZap( Ballistica bolt ) {
Sample.INSTANCE.play( Assets.SND_ROCKS );
int level = level();
int size = 1 + level / 3;
PathFinder.buildDistanceMap( bolt.collisionPos, BArray.not( Level.solid, null ), size );
for (int i=0; i < Level.LENGTH; i++) {
int d = PathFinder.distance[i];
if (d < Integer.MAX_VALUE) {
Char ch = Actor.findChar( i );
if (ch != null) {
ch.sprite.flash();
ch.damage( Random.Int( 2, 6 + (size - d) * 2 ), this );
if (ch.isAlive() && Random.Int( 2 + d ) == 0) {
Buff.prolong( ch, Paralysis.class, Random.IntRange( 2, 6 ) );
}
}
CellEmitter.get( i ).start( Speck.factory( Speck.ROCK ), 0.07f, 3 + (size - d) );
Camera.main.shake( 3, 0.07f * (3 + (size - d)) );
}
}
if (!curUser.isAlive()) {
Dungeon.fail( Utils.format( ResultDescriptions.ITEM, name ) );
GLog.n( "You killed yourself with your own Wand of Avalanche..." );
}
}
@Override
public void onHit(MagesStaff staff, Char attacker, Char defender, int damage) {
}
@Override
protected void fx( Ballistica bolt, Callback callback ) {
MagicMissile.earth( curUser.sprite.parent, bolt.sourcePos, bolt.collisionPos, callback );
Sample.INSTANCE.play( Assets.SND_ZAP );
}
@Override
public String desc() {
return
"When a discharge of this wand hits a wall (or any other solid obstacle) it causes " +
"an avalanche of stones, damaging and stunning all creatures in the affected area.";
}
}